/* ФОКАС CRM — фирменные цвета и базовая типографика */
:root {
  --orange: #FF4E00;
  --orange-hover: #E04400;
  --orange-soft: #FFF2EC;
  --blue: #003399;
  --blue-hover: #002673;
  --blue-soft: #EEF3FB;
  --bg: #FBFBF9;
  --card: #FFFFFF;
  --line: #E6E8EC;
  --sidebar: #12151C;
  --text: #1A1D23;
  --muted: #5C6470;
  --red: #D92D20;
  --red-soft: #FEECEB;
  --green: #12805C;
  --green-soft: #E8F5F0;
  --yellow: #B7791F;
  --yellow-soft: #FFF6E5;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(18, 21, 28, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--blue-soft); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 8px 0; }

/* ===== Экран входа ===== */
.login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background:
    linear-gradient(rgba(18, 21, 28, .72), rgba(18, 21, 28, .82)),
    url("/static/img/fokas-cover.jpg") center / cover no-repeat;
}
.login-card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px 32px 26px;
  width: 100%;
  max-width: 400px;
}
.login-logo { display: block; height: 38px; margin: 0 auto 14px; }
.login-tagline {
  text-align: center;
  font-weight: 700;
  letter-spacing: .06em;
  font-size: 13px;
  color: var(--text);
  margin: 0 0 20px;
}
.login-tagline span { display: block; font-weight: 400; letter-spacing: 0; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.login-status { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-hint { font-size: 12px; color: var(--muted); margin: 16px 0 0; border-top: 1px solid var(--line); padding-top: 12px; }
.login-footer { color: rgba(255, 255, 255, .85); font-size: 12px; text-align: center; line-height: 1.7; }

/* ===== Оболочка ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--sidebar);
  color: #B7BDC9;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.side-logo { padding: 20px 18px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.side-logo img { height: 28px; display: block; }
.side-nav { padding: 10px 0; flex: 1; }
.side-nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  color: #B7BDC9;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.side-nav button:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.side-nav button.active {
  color: #fff;
  border-left-color: var(--orange);
  background: rgba(255, 78, 0, .14);
  font-weight: 600;
}
.side-nav .ic { width: 18px; height: 18px; flex: 0 0 18px; }
.side-user { border-top: 1px solid rgba(255, 255, 255, .08); padding: 14px 16px; }
.side-user-name { color: #fff; font-weight: 600; font-size: 14px; }
.side-user .badge { margin-top: 6px; }
.side-logout {
  margin-top: 12px;
  width: 100%;
  background: none;
  border: 1px solid rgba(255, 255, 255, .22);
  color: #B7BDC9;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  font-size: 13px;
}
.side-logout:hover { border-color: var(--orange); color: #fff; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 26px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; min-width: 0; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
}
.menu-toggle svg { width: 100%; height: 100%; }
.sidebar-overlay { display: none; }
.main { padding: 22px 26px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ===== Карточки, сетки ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card h2 { font-size: 16px; margin-bottom: 12px; }
.card h3 { font-size: 14px; margin-bottom: 10px; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table-wrap { border-radius: var(--radius); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.kpi:hover { box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.kpi-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi-orange { border-top: 3px solid var(--orange); }
.kpi-orange .kpi-value { color: var(--orange-hover); }
.kpi-blue { border-top: 3px solid var(--blue); }
.kpi-blue .kpi-value { color: var(--blue); }
.kpi-red { border-top: 3px solid var(--red); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-green { border-top: 3px solid var(--green); }
.kpi-green .kpi-value { color: var(--green); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ===== Таблицы ===== */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #FAFAF7; }
.tbl .num { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; background: var(--bg); }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 340px; }
.clip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ===== Бейджи ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.6;
}
.badge-orange { background: var(--orange-soft); color: var(--orange-hover); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-gray { background: #F0F1F4; color: var(--muted); }
.badge-dark { background: rgba(255, 78, 0, .18); color: #FF8A57; }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); border-color: var(--orange-hover); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-ghost { border-color: transparent; background: none; color: var(--blue); }
.btn-ghost:hover { background: var(--blue-soft); }

/* ===== Формы ===== */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }
textarea { resize: vertical; min-height: 70px; }
select option:disabled { color: #B0B5BE; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.inline select { width: auto; padding: 5px 8px; font-size: 12.5px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 8px 0; }
.check input { width: auto; }

/* ===== Панели, вкладки, тулбар ===== */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { border-color: var(--orange); color: var(--orange-hover); }
.tab.active { background: var(--orange-soft); border-color: var(--orange); color: var(--orange-hover); }
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
details.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 14px;
  padding: 0;
}
details.panel summary {
  cursor: pointer;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 13.5px;
  list-style: none;
  user-select: none;
}
details.panel summary::before { content: "▸ "; color: var(--orange); }
details.panel[open] summary::before { content: "▾ "; }
details.panel .panel-body { padding: 4px 18px 16px; border-top: 1px solid var(--line); }

/* ===== Уведомления и пустые состояния ===== */
.notice { border-radius: 10px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.notice-blue { background: var(--blue-soft); border-color: #C9D8F0; color: var(--blue); }
.notice-orange { background: var(--orange-soft); border-color: #FFD4C2; color: var(--orange-hover); }
.notice-red { background: var(--red-soft); border-color: #F6C6C2; color: var(--red); }
.notice-green { background: var(--green-soft); border-color: #BFE3D6; color: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 34px 16px; font-size: 13.5px; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ===== Дашборд: график и внимание ===== */
.chart { display: flex; align-items: flex-end; gap: 18px; overflow-x: auto; padding: 10px 4px 0; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 52px; }
.chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; }
.bar { width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-agency { background: var(--orange); }
.bar-transit { background: var(--blue); }
.bar-expenses { background: #9AA1AC; }
.chart-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 12px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.attention-list { display: flex; flex-direction: column; gap: 8px; }
.attention-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
  text-align: left;
  width: 100%;
}
.attention-item:hover { box-shadow: var(--shadow); }
.attention-item .badge { flex: 0 0 auto; }
.attention-red { border-left: 3px solid var(--red); }
.attention-yellow { border-left: 3px solid var(--yellow); }
.attention-blue { border-left: 3px solid var(--blue); }
.attention-orange { border-left: 3px solid var(--orange); }

/* ===== Пагинация ===== */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager .spacer { flex: 1; }

/* ===== Прогресс отзывов ===== */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--orange); }
.progress-fill.done { background: var(--green); }

/* ===== Услуги ===== */
.materials { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.material {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.material img { width: 100%; height: 120px; object-fit: cover; display: block; }
.material div { padding: 10px 14px; font-size: 13px; font-weight: 600; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.svc-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--card); }
.svc-name { font-weight: 600; font-size: 13.5px; }
.svc-price { color: var(--orange-hover); font-weight: 800; font-size: 17px; margin-top: 6px; }
.svc-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.cat-title { font-size: 14px; font-weight: 700; margin: 18px 0 10px; color: var(--blue); }
.script-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--card); }
.script-q { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.script-a { font-size: 13px; color: var(--text); white-space: pre-wrap; }
.script-tags { margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.script-note { color: var(--muted); font-size: 12px; margin-top: 6px; }
.script-actions { margin-top: 10px; }

/* ===== Пароли рекламных кабинетов ===== */
.pass-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== Матрица видимости ===== */
.matrix-wrap { overflow-x: auto; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; white-space: nowrap; }
.matrix input { width: auto; }

/* ===== Модальные окна ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 21, 28, .55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .3);
}
.modal-wide { max-width: 880px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 2;
}
.modal-head h3 { font-size: 16px; }
.modal-x {
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.modal-x:hover { color: var(--text); }
.modal-body { padding: 18px 20px 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.confirm-text { font-size: 14px; margin: 0; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 16px; margin-bottom: 16px; }
.info-item .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.info-item .v { font-size: 14px; margin-top: 2px; word-break: break-word; }
.modal-section { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.modal-section h4 { font-size: 14px; margin-bottom: 10px; }

/* ===== Тосты ===== */
.toast-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: min(420px, calc(100vw - 36px));
}
.toast {
  padding: 12px 16px;
  border-radius: 11px;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  animation: toast-in .2s ease-out;
  word-break: break-word;
}
.toast-error { background: var(--red); }
.toast-ok { background: var(--green); }
.toast-warn { background: var(--yellow); }
.toast-info { background: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Адаптивность ===== */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform .2s ease-out;
    box-shadow: 0 0 60px rgba(0, 0, 0, .4);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(18, 21, 28, .5);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .sidebar-overlay.show { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: block; }
  .main { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 16px; }
  .topbar-user .topbar-name { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 19px; }
  .login-card { padding: 26px 20px 20px; }
  .modal-backdrop { padding: 8px; }
}
