/* Портал АГТЕХ — тема: оранжевый #FF6A00, чёрный #111318, белый. */

:root {
  --orange: #ff6a00;
  --orange-soft: #fff2e8;
  --orange-dark: #d95400;
  --black: #111318;
  --black-2: #1b1e25;
  --black-3: #272b34;
  --line: #e6e8ec;
  --line-2: #f1f2f4;
  --text: #1a1c22;
  --muted: #6b7280;
  --ok: #17803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf1e0;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --info: #1d4ed8;
  --info-soft: #eaf0ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 19, 24, .06), 0 8px 24px rgba(17, 19, 24, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", Inter, system-ui, -apple-system, Arial, sans-serif;
  color: var(--text);
  background: #f6f7f9;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--orange-dark); }

.app { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }

/* --- боковое меню --- */
.sidebar {
  background: var(--black);
  color: #e8eaee;
  padding: 18px 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--orange); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-text { font-weight: 700; letter-spacing: .2px; display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-weight: 400; font-size: 11px; color: #9aa1ad; letter-spacing: .3px; }
.stage-chip {
  font-size: 11px; color: #ffd9bd; background: rgba(255, 106, 0, .14);
  border: 1px solid rgba(255, 106, 0, .3); border-radius: 999px; padding: 5px 10px; text-align: center;
}
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #7d8593; margin: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px; color: #d7dae1; font-size: 13.5px;
}
.nav-item:hover { background: var(--black-2); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; opacity: .95; }
.nav-title { flex: 1; }
.nav-num { font-size: 10px; color: #8d94a1; background: var(--black-3); border-radius: 5px; padding: 1px 5px; }
.nav-item.active .nav-num { background: rgba(255, 255, 255, .25); color: #fff; }
.nav-stub { font-size: 9.5px; color: #ffb27a; border: 1px solid #55341c; border-radius: 5px; padding: 0 4px; }
.sidebar-foot { border-top: 1px solid #262a33; padding-top: 10px; font-size: 11.5px; color: #8d94a1; }
.foot-row { display: flex; justify-content: space-between; padding: 2px 0; }
.foot-row b { color: #fff; }
.foot-note { margin-top: 6px; color: #6f7784; }

/* --- верхняя панель --- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--line); padding: 11px 22px;
}
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs b { color: var(--text); font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-switch { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.role-switch select {
  font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.bell {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}
.bell.on { color: #fff; background: var(--orange); border-color: var(--orange); }
.content { padding: 20px 22px 32px; }
.foot { margin-top: auto; padding: 12px 22px 20px; font-size: 11.5px; color: var(--muted); }

/* --- заголовки и панели --- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 21px; }
.page-head p { margin: 0; color: var(--muted); max-width: 760px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow);
}
.metric .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.metric .value { font-size: 24px; font-weight: 700; margin: 5px 0 2px; }
.metric .hint { font-size: 12px; color: var(--muted); }
.metric.accent { border-left: 3px solid var(--orange); }
.metric.danger { border-left: 3px solid var(--danger); }
.metric.ok { border-left: 3px solid var(--ok); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-2); background: #fff;
}
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head .sub { font-size: 12px; color: var(--muted); }
.panel-body { padding: 14px 16px; }
.panel-body.tight { padding: 0; }
.panel-body.scroll { max-height: 380px; overflow: auto; }

/* --- таблицы --- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; position: sticky; top: 0; }
.tbl tbody tr:hover { background: #fffaf6; }
.tbl tr.link { cursor: pointer; }
.tbl tr.warn { background: var(--warn-soft); }
.tbl tr.danger { background: var(--danger-soft); }
.tbl tr.check { background: #fffbeb; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl .muted { color: var(--muted); }
.tbl-empty { padding: 18px 16px; color: var(--muted); font-size: 13px; }

/* --- метки --- */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--line-2); color: #414751;
}
.pill.accent { background: var(--orange-soft); color: var(--orange-dark); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.muted { background: #f1f2f4; color: var(--muted); }
.pill.stub { background: #fff; border: 1px dashed var(--orange); color: var(--orange-dark); }

/* --- фильтры и кнопки --- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input[type=text], .filters input[type=search] {
  font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filters .spacer { flex: 1; }
.filters .count { font-size: 12.5px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
.btn:hover { border-color: var(--orange); color: var(--orange-dark); }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--orange-dark); border-color: var(--orange-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #f3c8c5; }

/* --- формы --- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 13.5px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
.field textarea { min-height: 78px; resize: vertical; }
.field.wide { grid-column: 1 / -1; }

/* --- служебные блоки --- */
.note {
  background: var(--orange-soft); border: 1px solid #ffd7ba; border-left: 3px solid var(--orange);
  border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 14px;
}
.note.stub { background: #fff; border: 1px dashed var(--orange); border-left: 3px dashed var(--orange); }
.note.muted { background: #fafbfc; border-color: var(--line); border-left-color: var(--line); color: var(--muted); }
.note b { color: var(--text); }
.rules { margin: 0; padding-left: 18px; font-size: 13px; color: #3d434d; }
.rules li { margin-bottom: 4px; }

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 7px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.stepper { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.step {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f1f2f4; color: #525963;
  border: 1px solid transparent;
}
.step.done { background: var(--ok-soft); color: var(--ok); }
.step.current { background: var(--orange); color: #fff; font-weight: 600; }
.step-sep { color: var(--line); }

.bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--orange); }
.bar.ok > span { background: var(--ok); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.feed .ico {
  width: 28px; height: 28px; border-radius: 8px; background: var(--orange-soft); color: var(--orange-dark);
  display: grid; place-items: center; flex: none; font-size: 13px;
}
.feed .ico.письмо { background: var(--info-soft); color: var(--info); }
.feed .ico.звонок { background: var(--ok-soft); color: var(--ok); }
.feed .ico.счёт { background: var(--warn-soft); color: var(--warn); }
.feed .t { font-size: 13.5px; }
.feed .m { font-size: 11.5px; color: var(--muted); }
.feed .b { font-size: 12.5px; color: #4b515a; }

details.exp { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
details.exp > summary {
  cursor: pointer; padding: 10px 13px; font-weight: 600; font-size: 13.5px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
details.exp > summary::marker { color: var(--orange); }
details.exp[open] > summary { border-bottom: 1px solid var(--line-2); }
details.exp .inner { padding: 12px 13px; }

.tag { font-size: 11px; color: var(--muted); background: #f6f7f9; border-radius: 6px; padding: 2px 7px; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hr { height: 1px; background: var(--line-2); margin: 12px 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 10px; }
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px;
  display: flex; flex-direction: column; gap: 5px;
}
.tile:hover { border-color: var(--orange); box-shadow: var(--shadow); }
.tile .t { font-weight: 600; font-size: 13.5px; }
.tile .d { font-size: 12px; color: var(--muted); }
.tile .n { font-size: 10.5px; color: var(--orange-dark); }

.checklist { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.checklist li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line-2); }
.checklist li:last-child { border-bottom: 0; }
.checklist .state { color: var(--muted); font-size: 12px; }
.checklist .state.готово, .checklist .state.демо-данные { color: var(--ok); }
.checklist .state.этап { color: var(--orange-dark); }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .content { padding: 14px; }
  .kv { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .foot, .filters, .head-actions, .btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .panel { box-shadow: none; break-inside: avoid; }
}

/* ---- Этап 3.5: вход и карточка пользователя ---- */
.login-body { margin: 0; background: #111318; color: #f2f3f5;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 430px; padding: 24px; }
.login-card { background: #fff; color: #111318; border-radius: 16px; padding: 26px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-title { font-size: 20px; font-weight: 700; }
.login-sub { font-size: 12px; color: #6b7280; }
.login-form { display: grid; gap: 12px; margin-top: 6px; }
.login-form label { display: grid; gap: 5px; font-size: 13px; color: #374151; }
.login-form input { font: inherit; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; }
.login-form input:focus { outline: 2px solid #FF6A00; border-color: #FF6A00; }
.login-form .btn { justify-content: center; padding: 11px; font-size: 15px; }
.login-hint { margin-top: 12px; font-size: 12px; color: #6b7280; }
.login-foot { margin-top: 14px; text-align: center; font-size: 12px; color: #9aa1ab; }
.user-chip { display: inline-grid; margin-right: 10px; text-align: right; line-height: 1.15; }
.user-chip b { font-size: 13px; }
.user-chip small { color: #6b7280; font-size: 11px; }
.note.ok { border-left-color: #16a34a; }
.note.danger { border-left-color: #dc2626; }

/* ---- Этап 3.5: цепочка статусов ---- */
.status-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; }
.status-step { padding: 5px 10px; border-radius: 999px; font-size: 12px;
  background: #f1f2f4; color: #4b5563; white-space: nowrap; }
.status-step.done { background: #fff1e6; color: #b4530a; }
.status-step.current { background: #FF6A00; color: #fff; font-weight: 600; }
.status-step.current.danger { background: #dc2626; }
.status-arrow { color: #b9bec7; font-size: 12px; }
.status-step.danger { }
.note.warn { border-left-color: #f59e0b; }
.form-grid label input, .form-grid label select { font: inherit; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.rules li { font-size: 12px; }

/* ---- Этап 3.6: папки почты ---- */
.mail-folders { align-self: start; position: sticky; top: 12px; }
.folder-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
.folder-row:last-child { border-bottom: 0; }
.folder-row:hover { background: #faf7f4; }
.folder-row.active { background: #fff1e6; font-weight: 600; box-shadow: inset 3px 0 0 #FF6A00; }
.folder-name { flex: 1; }
.folder-count { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; color: #4b5563; }
.folder-new { background: #FF6A00; color: #fff; border-radius: 999px; font-size: 11px;
  padding: 1px 7px; white-space: nowrap; }

tr.dimmed td { color: #8b8f96; }
tr.dimmed td .pill { opacity: .85; }
