/* Платформа SHAMBI — общий стиль */
:root {
  color-scheme: light;
  --bg: #f7f5f0; --surface: #ffffff; --surface-2: #fbfaf7; --border: #e8e4da;
  --text: #1f2328; --text-2: #5e6470; --muted: #8a8f98;
  --brand: #2f6f62; --brand-soft: #e3efeb;
  --bar: #2a78d6; --pos: #2a78d6; --neg: #e34948; --track: #f0efec;
  --warn: #fab219; --ok: #0ca30c;
  --s-wb: #2a78d6; --s-oz: #eb6834;
  --shadow: 0 1px 2px rgba(31,35,40,.04), 0 6px 20px rgba(31,35,40,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131312; --surface: #1c1c1a; --surface-2: #222220; --border: #31312d;
    --text: #f4f3ee; --text-2: #c3c2b7; --muted: #8f8e86;
    --brand: #5fb3a1; --brand-soft: #1f3330;
    --bar: #3987e5; --pos: #3987e5; --neg: #e66767; --track: #383835;
    --s-wb: #3987e5; --s-oz: #d95926;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312; --surface: #1c1c1a; --surface-2: #222220; --border: #31312d;
  --text: #f4f3ee; --text-2: #c3c2b7; --muted: #8f8e86;
  --brand: #5fb3a1; --brand-soft: #1f3330;
  --bar: #3987e5; --pos: #3987e5; --neg: #e66767; --track: #383835;
  --s-wb: #3987e5; --s-oz: #d95926;
  --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 56px; }

/* Шапка */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo .mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.logo .name { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.logo .sub { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); }
.top .sp { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.nav { display: flex; gap: 6px; flex-wrap: wrap; margin: -8px 0 20px; }
.nav a { text-decoration: none; padding: 7px 14px; border-radius: 999px; font-size: 13px; color: var(--text-2);
  border: 1px solid transparent; }
.nav a:hover { background: var(--surface); border-color: var(--border); }
.nav a.on { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600; }

h1 { font-size: 30px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 16px; margin: 0 0 4px; }
h3.group { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin: 28px 0 12px; font-weight: 600; }
.lead { color: var(--text-2); margin: 0 0 20px; max-width: 760px; }
.note { color: var(--muted); font-size: 12px; margin: 2px 0 12px; }

/* Карточки и плашки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile, .card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.tile .k { color: var(--text-2); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 650; margin: 2px 0; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12px; color: var(--muted); }
.tile.dark { background: var(--text); border-color: var(--text); }
.tile.dark .k, .tile.dark .d { color: var(--bg); opacity: .75; }
.tile.dark .v { color: var(--bg); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; margin-bottom: 12px; }
.card + .card { margin-top: 0; }
.stack > * + * { margin-top: 12px; }

/* Отделы на главной */
.depts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.dept { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; text-decoration: none; box-shadow: var(--shadow); min-height: 200px; }
a.dept:hover { border-color: var(--brand); }
.dept .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 22px; }
.dept .t { font-size: 18px; font-weight: 650; margin-top: 4px; }
.dept .x { color: var(--text-2); font-size: 13px; flex: 1; }
.dept .f { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.badge { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; font-weight: 600; }
.badge.on { background: var(--brand-soft); color: var(--brand); }
.badge.dev { background: var(--track); color: var(--muted); }
.dept.off { opacity: .7; box-shadow: none; }

/* Графики-полосы */
.bars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.row { display: grid; grid-template-columns: minmax(90px, 36%) 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
.row .lbl { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .val { font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; min-width: 72px; }
.row:hover .lbl { color: var(--text); }
.track { position: relative; height: 14px; }
.fill { position: absolute; top: 0; height: 14px; background: var(--bar); }
.fill.pos { background: var(--pos); border-radius: 0 4px 4px 0; }
.fill.neg { background: var(--neg); border-radius: 4px 0 0 4px; }
.axis0 { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.ref { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1px dashed var(--text-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
#tip { position: fixed; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); display: none; max-width: 300px; z-index: 50; }

/* Таблицы */
.scroll { overflow: auto; max-height: 560px; }
table { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface); color: var(--text-2); font-weight: 600; }
th.sort { cursor: pointer; }
th:first-child, td:first-child { text-align: left; }
td.l, th.l { text-align: left; }
td.neg { color: var(--neg); }
table.heat td { text-align: center; }
table.heat td:first-child { text-align: left; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
input, select, textarea, button { font: inherit; color: var(--text); }
input[type=search], input[type=text], input[type=date], select, textarea {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); }
button { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button:hover { border-color: var(--brand); }
.warn { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }

/* Задачник */
.board { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px; min-height: 240px; }
.col h2 { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 10px; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.task .tt { font-weight: 600; margin-bottom: 6px; }
.task .meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--text-2); margin-bottom: 8px; }
.task .meta span { background: var(--track); padding: 2px 6px; border-radius: 5px; }
.task .meta span.hi { background: #fde2e1; color: #9b1c1c; }
.task .meta span.late { background: #fff1d6; color: #7a4b00; }
.task .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.task .acts button { padding: 3px 8px; font-size: 11px; }
.task .desc { font-size: 12px; color: var(--text-2); margin-bottom: 8px; white-space: pre-wrap; }
form.add { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
form.add label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
form.add .full { grid-column: 1 / -1; }

@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .grid2 { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  form.add { grid-template-columns: 1fr 1fr; }
}

/* Переключатель площадки */
.mpsw { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.mpsw button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; font-size: 12px; color: var(--text-2); }
.mpsw button.on { background: var(--brand); color: #fff; font-weight: 600; }
.mpbadge { font-size: 13px; font-weight: 600; vertical-align: middle; padding: 3px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); letter-spacing: 0; }

/* Роли: финансовые блоки скрыты у сотрудников без доступа к финансам */
.nofin [data-fin] { display: none !important; }
a.pill { text-decoration: none; color: inherit; }

/* Галочки у строк таблиц */
td.sel, th.sel { width: 26px; text-align: center !important; padding-left: 4px; padding-right: 4px; }
td.sel input, th.sel input { cursor: pointer; }
