/* Layout: корпоративный портал — левое меню на цветном фоне, белые панели в рабочей области */
:root {
  --ground-1: #2a8fd8;
  --ground-2: #1a5ea6;
  --panel: #ffffff;
  --panel-soft: #f5f7f8;
  --text: #333333;
  --text-muted: #828b95;
  --line: #dfe3e8;
  --link: #2067b0;
  --primary: #3bc8f5;
  --primary-hover: #3eddff;
  --success: #bbed21;
  --success-hover: #d2f95f;
  --success-text: #535c69;
  --menu-text: rgba(255, 255, 255, .85);
  --menu-active: rgba(255, 255, 255, .22);
  --menu-hover: rgba(255, 255, 255, .12);
  --shadow: 0 2px 4px rgba(0, 0, 0, .06);
  --font: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  /* Имена для страниц отчётов (P&L и др.) */
  --bg: var(--panel-soft);
  --surface: var(--panel);
  --muted: var(--text-muted);
  --border: var(--line);
  --accent: var(--link);
  --accent-soft: var(--panel-soft);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground-1: #16324f;
    --ground-2: #0d1d30;
    --panel: #1f2a37;
    --panel-soft: #263342;
    --text: #e6eaef;
    --text-muted: #9aa5b1;
    --line: #34404e;
    --link: #6fb2f2;
    --menu-text: rgba(255, 255, 255, .8);
    --menu-active: rgba(255, 255, 255, .14);
    --menu-hover: rgba(255, 255, 255, .08);
    --shadow: 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ground-1: #16324f;
  --ground-2: #0d1d30;
  --panel: #1f2a37;
  --panel-soft: #263342;
  --text: #e6eaef;
  --text-muted: #9aa5b1;
  --line: #34404e;
  --link: #6fb2f2;
  --menu-text: rgba(255, 255, 255, .8);
  --menu-active: rgba(255, 255, 255, .14);
  --menu-hover: rgba(255, 255, 255, .08);
  --shadow: 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--ground-2) linear-gradient(160deg, var(--ground-1) 0%, var(--ground-2) 100%) fixed;
  min-height: 100vh;
}

a { color: var(--link); }

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

/* Левое меню */
.sidebar {
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .2);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-title {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255, 255, 255, .55);
}

.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 20px;
  color: var(--menu-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.menu a:hover { background: var(--menu-hover); color: #fff; }
.menu a[aria-current="page"] { background: var(--menu-active); color: #fff; }
.menu a:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.menu svg { flex: none; opacity: .9; }

/* Рабочая область */
.workarea {
  padding: 18px 24px 32px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: #fff;
  min-height: 32px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 300;
  text-wrap: balance;
}

.topbar .period {
  font-size: 13px;
  color: rgba(255, 255, 255, .8);
}

.breadcrumbs {
  font-size: 13px;
  color: rgba(255, 255, 255, .75);
}
.breadcrumbs a { color: #fff; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

.panel {
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.panel-head .hint {
  color: var(--text-muted);
  font-size: 13px;
}

/* Плитки отчётов */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.tile:hover, .tile:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(59, 200, 245, .18);
  outline: none;
}

.tile .icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
}
.tile .icon.blue { background: #2fc6f6; }
.tile .icon.green { background: #9dcf00; }
.tile .icon.orange { background: #ffa900; }

.tile .name {
  font-size: 18px;
  font-weight: 700;
}

.tile .desc {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
}

/* Кнопки */
.btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 20px;
  border-radius: 18px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  text-decoration: none;
  border: 0;
  cursor: pointer;
}

.btn-success { background: var(--success); color: var(--success-text); }
.tile:hover .btn-success { background: var(--success-hover); }

.btn-light {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line);
}

.placeholder {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--panel-soft);
  border-radius: 10px;
}

.menu-title:not(:first-child) { margin-top: 12px; }

/* Вкладки категорий на главной */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 0;
  border-radius: 20px;
  padding: 9px 18px;
  cursor: pointer;
}
.tab:hover { background: rgba(255, 255, 255, .24); }
.tab[aria-selected="true"] { background: var(--panel); color: var(--text); }
.tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.tile.soon { cursor: default; border-style: dashed; }
.tile.soon:hover { border-color: var(--line); box-shadow: none; }
.tile .icon.gray { background: #a8adb4; }
.tile .icon.violet { background: #8c7ae6; }
.status {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px 10px;
}

/* Плашка «пример данных» */
.example {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff6e5;
  color: #7a5200;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.example b { font-weight: 700; }

/* Фильтры и показатели на страницах разделов */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.arrow-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; cursor: pointer;
  color: var(--text); background: var(--panel-soft); border: 1px solid var(--line); border-radius: 50%;
}
.arrow-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--link); }
.arrow-btn:disabled { opacity: .4; cursor: default; }
.period-label { font-weight: 700; font-size: 16px; min-width: 9em; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font-family: var(--font); font-size: 13px; cursor: pointer; color: var(--text);
  background: var(--panel-soft); border: 1px solid var(--line); border-radius: 16px; padding: 6px 14px;
}
.seg button[aria-pressed="true"] { border-color: var(--link); color: var(--link); font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.stat {
  background: var(--panel-soft);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat .lbl { font-size: 12px; color: var(--text-muted); }
.stat .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .val.bad { color: #c0362c; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.table-wrap { overflow-x: auto; }
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.grid-table th, .grid-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}
.grid-table th { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.grid-table .l { text-align: left; }
.grid-table tbody tr:hover td { background: var(--panel-soft); }

/* Табель */
.tabel th.d, .tabel td.d { text-align: center; padding: 6px 2px; min-width: 28px; font-size: 12px; }
.tabel th.we { color: #c0362c; }
.tabel td.name { position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 190px; }
.tabel td.name small { display: block; color: var(--text-muted); font-size: 11px; }
.tabel td.sum { font-weight: 700; }
.code { display: inline-block; min-width: 24px; padding: 2px 0; border-radius: 4px; font-weight: 600; font-size: 11px; }
.c-ya { color: var(--text); }
.c-v { color: var(--text-muted); background: var(--panel-soft); }
.c-b { background: #fde2e1; color: #a1251c; }
.c-ot { background: #dcefff; color: #1a5ea6; }
.c-k { background: #ece7ff; color: #5b45c2; }
.c-nn { background: #c0362c; color: #fff; }
.c-late { box-shadow: inset 0 -2px 0 #ffa900; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--text-muted); align-items: center; }
.legend span.code { margin-right: 4px; text-align: center; }

/* Звонки */
.pill-s { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 8px; }
.pill-s.miss { background: #fde2e1; color: #a1251c; }
.pill-s.ok { background: #e3f6d0; color: #3d6b00; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-soft); min-width: 80px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); }

/* Вход и заявка на доступ */
.locked .layout { display: none; }
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.gate-card {
  width: min(460px, 100%);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .18);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gate-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.gate-brand .brand-mark { background: var(--ground-1); color: #fff; }
.gate-title { margin: 0; font-size: 20px; font-weight: 600; }
.gate-text { margin: 0; color: var(--text-muted); line-height: 1.55; }
.gate-note { margin: 0; background: #fff6e5; color: #7a5200; border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.5; }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gf { display: flex; flex-direction: column; gap: 5px; }
.gf > span { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.gf > span i { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; }
.gf input, .gf select, .gf textarea {
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
.gf input:focus-visible, .gf select:focus-visible, .gf textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.gate-err { margin: 0; color: #c0362c; font-size: 13px; line-height: 1.5; }
.gate-form .btn { align-self: stretch; justify-content: center; height: 40px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: default; }

.whoami { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: rgba(255, 255, 255, .85); font-size: 13px; }
.whoami img { width: 28px; height: 28px; border-radius: 50%; }
.whoami { flex-wrap: wrap; margin-block: auto 0; }
.whoami .logout {
  font-family: var(--font); font-size: 12px; font-weight: 600; cursor: pointer;
  color: #fff; background: rgba(255, 255, 255, .14); border: 0; border-radius: 14px; padding: 5px 12px;
}
.whoami .logout:hover { background: rgba(255, 255, 255, .24); }

/* Страница «Доступ» */
.btn-sm { height: 30px; padding: 0 14px; font-size: 11px; border-radius: 15px; }
.btn-danger { background: transparent; color: #c0362c; border: 1px solid #e8b4b0; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.who { display: flex; align-items: center; gap: 8px; }
.who img { width: 24px; height: 24px; border-radius: 50%; }
.steps { margin: 0; padding-left: 20px; line-height: 1.7; color: var(--text); }
.empty { color: var(--text-muted); padding: 16px 0; }

/* Телефон: меню становится горизонтальной полосой сверху */
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 14px 16px 0; gap: 12px; }
  .menu { flex-direction: row; overflow-x: auto; }
  .menu-title { display: none; }
  .menu a { white-space: nowrap; }
  .workarea { padding: 4px 16px 24px; }
  .panel { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
}
