/* Car City Finance — премиальный интерфейс.
   Две темы: «Жемчуг» (светлая, по умолчанию) и «Полночь» (тёмная). Акцент — шампанское золото.
   Карточки из матового стекла, живой фон, плотная сетка блоков без пустот. */

:root {
  color-scheme: light;
  --bg: #F1EEE7; --bg-2: #E8E3D8;
  --surface: rgba(255, 255, 255, .74); --surface-solid: #FFFFFF; --surface-2: rgba(22, 22, 30, .045); --surface-3: rgba(22, 22, 30, .075);
  --line: rgba(22, 22, 30, .08); --line-2: rgba(22, 22, 30, .14); --grid: rgba(22, 22, 30, .07);
  --text: #15161C; --text-2: #5B5F69; --muted: #8B8F98;
  --gold: #B8862B; --gold-hi: #E9C46A; --gold-lo: #94681A; --accent-text: #8A6214; --on-gold: #1B1406;
  --gold-grad: linear-gradient(135deg, #F6DE9A 0%, #E2B04E 45%, #B9832A 100%);
  --gold-line: linear-gradient(90deg, rgba(184, 134, 43, 0), rgba(184, 134, 43, .55), rgba(184, 134, 43, 0));
  /* категории (контрастные и различимые при дальтонизме): 1 сапфир, 2 янтарь, 3 бирюза, 4 аметист */
  --c1: #2F6FDB; --c2: #D08A12; --c3: #0E9488; --c4: #7B5CD6;
  --inc: var(--c1); --exp: var(--c2); --lease: var(--c4);
  --non-1: #6E737C; --non-2: #9A9EA6; --non-3: #BEC1C7; --non-4: #D7D9DD;
  --good: #13824A; --bad: #C8341F; --warn: #94681A;
  --font-display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --font-text: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-xl: 30px; --r-card: 24px; --r-md: 16px; --r-sm: 12px; --r-pill: 999px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 2px rgba(18, 18, 26, .04), 0 18px 40px -22px rgba(18, 18, 26, .28);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 2px 6px rgba(18, 18, 26, .06), 0 30px 60px -26px rgba(18, 18, 26, .38);
  --blur: saturate(160%) blur(18px);
  --hero-ink: #F4EFE3; --hero-ink-2: rgba(244, 239, 227, .72);
  --amb-1: rgba(233, 196, 106, .34); --amb-2: rgba(47, 111, 219, .16); --amb-3: rgba(123, 92, 214, .12);
  --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1);
  --rail-w: 232px; --top-h: 68px; --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07080B; --bg-2: #0D0F14;
  --surface: rgba(20, 22, 29, .68); --surface-solid: #13151B; --surface-2: rgba(255, 255, 255, .045); --surface-3: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .075); --line-2: rgba(255, 255, 255, .13); --grid: rgba(255, 255, 255, .06);
  --text: #EEEBE4; --text-2: #A4A7AF; --muted: #757A84;
  --gold: #E5B24B; --gold-hi: #F7D88C; --gold-lo: #B9832A; --accent-text: #F1C66A; --on-gold: #1B1406;
  --gold-line: linear-gradient(90deg, rgba(229, 178, 75, 0), rgba(229, 178, 75, .6), rgba(229, 178, 75, 0));
  --c1: #5C9BFF; --c2: #F0B03E; --c3: #2CC9B6; --c4: #A88BFA;
  --non-1: #8C919B; --non-2: #626771; --non-3: #464A53; --non-4: #33363D;
  --good: #4ADE80; --bad: #FF7A6B; --warn: #F1C66A;
  --shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 24px 50px -26px rgba(0, 0, 0, .9);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 34px 70px -28px rgba(0, 0, 0, .95);
  --amb-1: rgba(229, 178, 75, .16); --amb-2: rgba(92, 155, 255, .12); --amb-3: rgba(168, 139, 250, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font-text); font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--gold) 35%, transparent); }
.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
h1 { font: 300 clamp(26px, 3.4vw, 40px)/1.08 var(--font-display); letter-spacing: -.025em; margin: 0; text-wrap: balance; }
h2 { font: 400 16px/1.25 var(--font-display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h3 { font: 500 14px/1.3 var(--font-text); margin: 0; color: var(--text-2); }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- живой фон */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(120% 80% at 50% -10%, var(--bg-2), var(--bg) 60%); }
.ambient i { position: absolute; border-radius: 50%; filter: blur(70px); will-change: transform; }
.ambient .a1 { width: 52vw; height: 52vw; left: -12vw; top: -20vw; background: var(--amb-1); animation: drift1 26s ease-in-out infinite alternate; }
.ambient .a2 { width: 46vw; height: 46vw; right: -14vw; top: 8vh; background: var(--amb-2); animation: drift2 32s ease-in-out infinite alternate; }
.ambient .a3 { width: 40vw; height: 40vw; left: 30vw; bottom: -22vw; background: var(--amb-3); animation: drift3 38s ease-in-out infinite alternate; }
.ambient::after { content: ""; position: absolute; inset: 0; opacity: .35;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 9%, transparent) .8px, transparent .9px);
  background-size: 22px 22px; mask-image: linear-gradient(180deg, #000, transparent 70%); }
@keyframes drift1 { to { transform: translate3d(8vw, 6vh, 0) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-10vw, 10vh, 0) scale(.9); } }
@keyframes drift3 { to { transform: translate3d(-6vw, -8vh, 0) scale(1.15); } }

/* ---------------------------------------------------------------- оболочка */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--gold-line); opacity: .7; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; text-decoration: none; }
.brand .logo { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--gold) 70%, transparent), 0 8px 20px -8px color-mix(in srgb, var(--gold) 60%, transparent); }
.brand .logo img { width: 42px; height: 42px; border-radius: 50%; object-fit: contain; display: block; }
.brand .t { display: grid; gap: 0; line-height: 1.15; }
.brand .t .mono { font-size: 9.5px; }
.brand b { font: 500 16px/1.15 var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.brand b em { font-style: normal; background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.userchip { display: inline-flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.userchip .ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 500 13px var(--font-display);
  background: var(--gold-grad); color: var(--on-gold); }
.userchip .who { display: grid; line-height: 1.2; min-width: 0; }
.userchip b { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.userchip small { color: var(--muted); font-size: 11.5px; }
.icon-btn { width: 42px; height: 42px; padding: 0; justify-content: center; border-radius: 14px; }
.logout-form { margin: 0; display: contents; }
.on-dark { display: none; } [data-theme="dark"] .on-dark { display: inline; } [data-theme="dark"] .on-light { display: none; }

.shell { position: relative; z-index: 1; display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); gap: 0;
  max-width: 1680px; margin: 0 auto; }
.wrap { min-width: 0; padding: 22px max(22px, env(safe-area-inset-right)) 80px 6px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
.wrap > * { min-width: 0; }

/* левая панель вкладок */
.rail { position: sticky; top: calc(var(--top-h) + var(--safe-t)); align-self: start; height: calc(100vh - var(--top-h) - var(--safe-t));
  padding: 22px 4px 22px max(18px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 4px; }
.rail-cap { padding: 14px 14px 6px; }
.rail-cap:first-child { padding-top: 2px; }
.rail-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px;
  text-decoration: none; color: var(--text-2); font-weight: 500; font-size: 14.5px; transition: color .25s var(--ease), background-color .25s var(--ease), transform .25s var(--ease); }
.rail-item:hover { color: var(--text); background: var(--surface-2); }
.rail-item:active { transform: scale(.98); }
.rail-item.on { color: var(--text); background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.rail-item.on .ic { color: var(--gold); }
.rail-item.on::before { content: ""; position: absolute; left: -10px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px;
  background: var(--gold-grad); box-shadow: 0 0 12px var(--gold); }
.rail-glow { margin-top: auto; height: 120px; border-radius: 20px; opacity: .5;
  background: radial-gradient(60% 60% at 50% 100%, color-mix(in srgb, var(--gold) 30%, transparent), transparent 70%); }

/* нижняя панель вкладок (телефон, PWA) */
.tabbar { display: none; }
.sheet, .sheet-backdrop { display: none; }

/* ---------------------------------------------------------------- кнопки и поля */
button, .btn, select, input, textarea { font: inherit; font-size: 14px; color: var(--text); }
button, .btn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 7px 16px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-decoration: none;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  transition: border-color .25s var(--ease), background-color .25s var(--ease), box-shadow .25s var(--ease), transform .2s var(--ease), color .2s; }
button:hover, .btn:hover { border-color: var(--line-2); box-shadow: 0 8px 22px -14px rgba(0, 0, 0, .35); }
button:active, .btn:active { transform: translateY(1px) scale(.985); }
button.ghost { background: transparent; backdrop-filter: none; }
button.primary, .btn.primary { background: var(--gold-grad); color: var(--on-gold); font-weight: 600; border-color: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .55) inset, 0 10px 24px -12px color-mix(in srgb, var(--gold) 85%, transparent); overflow: hidden; }
button.primary::after, .btn.primary::after { content: ""; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%); transition: transform .8s var(--ease); }
button.primary:hover::after, .btn.primary:hover::after { transform: translateX(120%); }
button.danger { color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
select, input[type=text], input[type=password], input[type=number], input[type=time], input[type=url], input[type=date], textarea {
  background: var(--surface-solid); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 9px 13px; min-height: 40px; width: 100%;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 18%, transparent); }
select { width: auto; appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=date] { width: auto; min-width: 0; }
textarea { font-family: var(--font-mono); font-size: 12px; min-height: 120px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); }

/* ---------------------------------------------------------------- герой и период */
.hero { position: relative; border-radius: var(--r-xl); overflow: hidden; padding: 26px 26px 20px; color: var(--hero-ink);
  background: #0A0B0F; box-shadow: 0 30px 70px -36px rgba(10, 10, 16, .85); isolation: isolate; animation: rise .7s var(--ease) both; }
.hero-bg { position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(100deg, rgba(8, 9, 12, .92) 0%, rgba(8, 9, 12, .55) 48%, rgba(8, 9, 12, .25) 100%), url('/static/bg-dark.webp') center 55%/cover no-repeat;
  animation: heroPan 30s ease-in-out infinite alternate; }
.hero::after { content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
@keyframes heroPan { to { background-position: 0 0, center 40%; transform: scale(1.04); } }
.hero-head { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; }
.hero-title { display: grid; gap: 8px; min-width: 0; }
.hero .kicker { color: var(--gold-hi); letter-spacing: .2em; }
.hero h1 { color: #FBF7EC; text-shadow: 0 2px 30px rgba(0, 0, 0, .5); }
.hero-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--hero-ink-2); font-size: 13px; }
.hero-meta > span:not(:first-child)::before { content: "·"; margin-right: 14px; opacity: .5; }
.live { display: inline-flex; align-items: center; gap: 8px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }

.period { margin-top: 20px; display: grid; gap: 14px; }
.period .frow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip, .hero .chip-select { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 6px 14px; border-radius: var(--r-pill);
  font-size: 13.5px; text-decoration: none; color: var(--hero-ink); background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: background-color .25s var(--ease), border-color .25s var(--ease), color .25s; }
.chip .ic { width: 16px; height: 16px; }
.chip:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .22); box-shadow: none; }
.chip.on { color: #1B1406; background: linear-gradient(135deg, #F6DE9A, #E2B04E); border-color: transparent; font-weight: 600;
  box-shadow: 0 8px 22px -10px rgba(226, 176, 78, .8); }
.hero .chip-select { padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--hero-ink-2) 50%), linear-gradient(135deg, var(--hero-ink-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; background-color: rgba(255, 255, 255, .07); }
.hero .chip-select option { color: #111; }
.more-toggle { display: none; }
.period-adv { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; padding: 14px; border-radius: 20px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.field { display: grid; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 260px; }
.field .lab { color: var(--hero-ink-2); font-size: 10px; }
.range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.range > i { color: var(--hero-ink-2); font-style: normal; }
.hero select, .hero input[type=date] { background-color: rgba(0, 0, 0, .28); color: var(--hero-ink); border-color: rgba(255, 255, 255, .14); color-scheme: dark; min-height: 38px; }
.hero select { background-image: linear-gradient(45deg, transparent 50%, var(--hero-ink-2) 50%), linear-gradient(135deg, var(--hero-ink-2) 50%, transparent 50%); }
.hero select option { color: #111; background: #fff; }
.period-note { flex-basis: 100%; margin: 0; color: var(--hero-ink-2); font-size: 12.5px; }

/* примечания к данным (бывшие жёлтые плашки) */
.notes-wrap:empty { display: none; }
.notes { border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); overflow: hidden; animation: rise .6s var(--ease) .1s both; }
.notes summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; color: var(--text); }
.notes summary::-webkit-details-marker { display: none; }
.notes .n-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--gold) 16%, transparent); color: var(--accent-text); }
.notes .n-ic .ic { width: 18px; height: 18px; }
.notes .n-t { display: grid; min-width: 0; line-height: 1.3; }
.notes .n-t b { font-weight: 500; font-size: 14px; }
.notes .n-t span { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notes .n-count { margin-left: auto; font: 500 12px var(--font-mono); padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); flex: none; }
.notes .n-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .3s var(--ease); flex: none; }
.notes[open] .n-chev { transform: rotate(90deg); }
.notes ol { margin: 0; padding: 4px 16px 14px 60px; display: grid; gap: 8px; color: var(--text-2); font-size: 13.5px; counter-reset: n; list-style: none; }
.notes li { position: relative; }
.notes li::before { counter-increment: n; content: counter(n, decimal-leading-zero); position: absolute; left: -32px; top: 1px;
  font: 500 11px var(--font-mono); color: var(--accent-text); }

/* ---------------------------------------------------------------- панель доски */
.boardbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 -4px; }
.sec-title { font: 400 20px/1.2 var(--font-display); letter-spacing: -.015em; }
.boardbar .edit-hint { color: var(--muted); font-size: 13px; }
#editLayout.on { background: var(--gold-grad); color: var(--on-gold); border-color: transparent; font-weight: 600; }

/* ---------------------------------------------------------------- доска: плотная сетка без пустот */
.board { --gap: 16px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: row;
  column-gap: var(--gap); row-gap: var(--gap); align-items: stretch; }
.w { grid-column: span 12; min-width: 0; position: relative; container-type: inline-size;
  animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms);
  transition: box-shadow .35s var(--ease), transform .35s var(--ease), opacity .3s var(--ease), border-color .35s var(--ease); }
.w[data-size="wide"] { grid-column: span 8; }
.w[data-size="narrow"] { grid-column: span 4; }
.w[data-size="half"] { grid-column: span 6; }
.board .w.off, .board .w.user-off { display: none; }
.board.editing .w.user-off:not(.off) { display: block; opacity: .42; filter: grayscale(.8); }
.board.editing .w.user-off .w-in > :not(.chead):not(.w-head-float) { pointer-events: none; }
.w-eye.is-off { color: var(--accent-text); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.w-in { display: flex; flex-direction: column; gap: 14px; min-width: 0; flex: 1 1 auto; }
.w-in > * { min-width: 0; }
.w-in > .chart:not(.short) { flex: 1 1 auto; }
.chart > canvas { position: absolute; left: 0; top: 0; }

/* карточка из матового стекла с бликом и подсветкой за курсором */
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px 22px;
  min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.card.w { display: flex; flex-direction: column; overflow: hidden; }
.w.plain { display: flex; flex-direction: column; }
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .4s var(--ease);
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--gold) 13%, transparent), transparent 60%); }
.card::after { content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 1px; background: var(--gold-line); opacity: .55; pointer-events: none; }
@media (hover: hover) { .card:hover::before { opacity: 1; } .card.w:hover { box-shadow: var(--shadow-lift); border-color: var(--line-2); } }

.chead { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.chead h2 { flex: 1 1 auto; }
.chead .sum { font: 500 13px var(--font-mono); letter-spacing: -.01em; color: var(--text-2); white-space: nowrap; }
.chead.sub { margin-top: 4px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.info-btn { width: 30px; height: 30px; min-height: 30px; padding: 0; justify-content: center; border-radius: 10px; color: var(--muted); background: transparent; backdrop-filter: none; border-color: transparent; }
.info-btn:hover { color: var(--accent-text); background: var(--surface-2); box-shadow: none; }
.info-btn .ic { width: 18px; height: 18px; }
.w .hint { display: none; }
.w.show-hint .hint { display: block; position: relative; margin: 0; padding: 11px 14px 11px 40px; border-radius: 14px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line); animation: rise .35s var(--ease) both; }
.w.show-hint .hint::before { content: "i"; position: absolute; left: 13px; top: 11px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font: 600 11px var(--font-mono); color: var(--on-gold); background: var(--gold-grad); }
.w.show-hint .info-btn { color: var(--accent-text); background: var(--surface-2); }
.hint { color: var(--muted); font-size: 13px; margin: 0; max-width: 80ch; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@container (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#daysTbl td:first-child, #cmpTbl td:first-child { white-space: nowrap; }
.kpi { position: relative; overflow: hidden; display: grid; gap: 4px; align-content: start; min-width: 0; padding: 18px 20px 12px;
  border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); transition: transform .4s var(--ease), box-shadow .4s var(--ease); }
.kpi::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; height: 120%; pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--kc, var(--gold)) 22%, transparent), transparent); opacity: .7; }
.kpi::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--kc, var(--gold)), transparent); opacity: .8; }
.kpi:first-child { background: linear-gradient(160deg, #15161C, #0B0C10 70%); border-color: rgba(255, 255, 255, .08); color: #F4EFE3; --kc: var(--gold-hi); }
.kpi:first-child .mono, .kpi:first-child .c { color: rgba(244, 239, 227, .66); }
.kpi:first-child .v { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi:first-child .v small { color: rgba(244, 239, 227, .6); -webkit-text-fill-color: rgba(244, 239, 227, .6); }
@media (hover: hover) { .kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); } }
.kpi .mono { display: flex; align-items: center; gap: 2px; }
.kpi .v { font: 300 clamp(22px, 2.3vw, 30px)/1.12 var(--font-display); letter-spacing: -.03em; white-space: nowrap; margin-top: 4px; }
.kpi .v small { font-size: 14px; color: var(--text-2); margin-left: 2px; }
.kpi .c { font-size: 13px; color: var(--text-2); min-height: 20px; }
.kpi .spark { height: 46px; position: relative; margin-top: 6px; min-width: 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 10px currentColor; }

/* графики */
.chart { position: relative; height: 300px; min-width: 0; width: 100%; }
.chart canvas { max-width: 100%; }
.chart.short { height: 240px; }
.chart.tall { height: 370px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--text-2); font-size: 12.5px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 0; }
.legend i.line { width: 16px; height: 0; border-radius: 0; border-top: 2px dashed var(--text-2); vertical-align: 3px; }
.legend b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.donut-wrap { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: center; }
.donut-wrap .chart { height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font: 300 18px/1.1 var(--font-display); letter-spacing: -.02em; }
.donut-center span { font-size: 11.5px; color: var(--muted); }

/* строки с полосами */
.bars { display: grid; gap: 2px; }
.row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(40px, 1fr) auto; gap: 2px 14px; align-items: center;
  padding: 8px 8px; border-radius: 12px; transition: background-color .2s var(--ease); }
.row.click { cursor: pointer; }
.row.click:hover { background: var(--surface-2); }
.row .n { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.row .n small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.row .chev { display: inline-block; width: 14px; color: var(--muted); transition: transform .25s var(--ease); }
.row.open .chev { transform: rotate(90deg); color: var(--accent-text); }
.row .track { position: relative; height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.row .fill { position: absolute; inset: 0 auto 0 0; border-radius: var(--r-pill); min-width: 4px;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .4), rgba(255, 255, 255, 0) 65%);
  box-shadow: 0 0 14px -2px currentColor; transform-origin: left; animation: grow .9s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }
.row .val { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; display: grid; justify-items: end; font-size: 14px; }
.row .val small { font-size: 11.5px; color: var(--muted); }
.row.sub { padding: 4px 8px 4px 30px; font-size: 13.5px; color: var(--text-2); }
.row.sub .track { background: none; }
.row.sub .fill { opacity: .5; box-shadow: none; }
.row.total { border-top: 1px solid var(--line-2); border-radius: 0; margin-top: 6px; padding-top: 12px; font-weight: 600; }
.row .sw { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: 0; }
.split { display: flex; height: 14px; border-radius: var(--r-pill); overflow: hidden; gap: 3px; }
.split i { display: block; height: 100%; border-radius: var(--r-pill); background-image: linear-gradient(180deg, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0) 70%);
  transform-origin: left; animation: grow 1s var(--ease) both; }

/* таблицы */
.tbl { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 13.5px; }
th { text-align: left; font: 500 10.5px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.sec td { font-weight: 600; background: var(--surface-2); border-bottom-color: transparent; }
tr.sec td:first-child { border-radius: 12px 0 0 12px; } tr.sec td:last-child { border-radius: 0 12px 12px 0; }
tr.acc td:first-child { padding-left: 26px; color: var(--text-2); }
tbody tr { transition: background-color .2s; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.neg { color: var(--bad); } .pos { color: var(--good); }
.scrollbox { max-height: 560px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.tbl.scrollbox thead th { position: sticky; top: 0; background: var(--surface-solid); z-index: 1; }

/* пиллы, теги, сообщения */
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; padding: 3px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; background: var(--surface-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.pill.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: color-mix(in srgb, var(--good) 9%, transparent); }
.pill.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: color-mix(in srgb, var(--bad) 9%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--gold) 40%, transparent); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.note { font-size: 13px; color: var(--text-2); max-width: 82ch; }
.note b { color: var(--text); font-weight: 500; }
.msg { position: relative; padding: 12px 16px 12px 44px; border-radius: var(--r-md); font-size: 14px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); animation: rise .5s var(--ease) both; }
.msg::before { content: ""; position: absolute; left: 16px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%;
  background: var(--gold-grad); box-shadow: 0 0 12px color-mix(in srgb, var(--gold) 60%, transparent); }
.msg.ok::before { background: var(--good); box-shadow: 0 0 12px var(--good); }
.msg.err { color: var(--bad); } .msg.err::before { background: var(--bad); box-shadow: 0 0 12px var(--bad); }
details > summary { cursor: pointer; color: var(--text-2); }
code { font-family: var(--font-mono); font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); }

/* ---------------------------------------------------------------- админка */
.grid2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.grid2.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form { display: grid; gap: 14px; max-width: 760px; }
.form .row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wrap > .card, .wrap > .grid2 { animation: rise .6s var(--ease) both; }

/* ---------------------------------------------------------------- вход */
.auth-page .ambient { display: none; }
.auth { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr); }
.auth-visual { position: relative; overflow: hidden; display: flex; align-items: end; padding: clamp(28px, 5vw, 64px);
  background: linear-gradient(180deg, rgba(6, 7, 10, .1), rgba(6, 7, 10, .82)), url('/static/bg-dark.webp') center/cover no-repeat #07080B; color: #F4EFE3; }
.auth-visual::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 50% at 30% 40%, rgba(233, 196, 106, .14), transparent 70%); animation: glow 9s ease-in-out infinite alternate; }
@keyframes glow { to { opacity: .4; transform: scale(1.08); } }
.auth-copy { position: relative; z-index: 1; display: grid; gap: 14px; max-width: 560px; animation: rise 1s var(--ease) both; }
.auth-copy .mono { color: var(--gold-hi); letter-spacing: .2em; }
.auth-title { margin: 0; font: 300 clamp(32px, 4.4vw, 58px)/1.05 var(--font-display); letter-spacing: -.035em; }
.auth-title em { font-style: normal; background: linear-gradient(135deg, #F8E4A8, #E2B04E 55%, #C08A2E); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { margin: 0; color: rgba(244, 239, 227, .72); font-size: 15px; max-width: 46ch; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; background: var(--bg); position: relative; }
.auth-panel::before { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 50% at 50% 0%, var(--amb-1), transparent 70%); pointer-events: none; }
.auth-card { width: min(100%, 420px); padding: 30px 28px; gap: 18px; animation: rise .8s var(--ease) .1s both; }
.auth-card h1 { font-size: 26px !important; }
.auth .qr { background: #fff; border-radius: 18px; padding: 10px; justify-self: center; line-height: 0; box-shadow: var(--shadow); }
.code-input { font: 400 26px var(--font-mono) !important; letter-spacing: .35em; text-align: center; }
.auth-card .primary { justify-content: center; min-height: 46px; }

/* ---------------------------------------------------------------- режим настройки доски */
.w-head-float { display: none; justify-content: flex-end; margin-bottom: 8px; }
.w-tools { display: none; gap: 6px; align-items: center; margin-left: auto; }
.w-tools button { min-height: 30px; padding: 2px 10px; font-size: 12.5px; }
.w-grip { display: inline-grid; place-items: center; width: 32px; height: 30px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); cursor: grab; user-select: none; }
.w-grip .ic { width: 16px; height: 16px; }
.board.editing .w-tools { display: inline-flex; }
.board.editing .w-head-float { display: flex; }
.board.editing .w { outline: 1.5px dashed color-mix(in srgb, var(--gold) 65%, transparent); outline-offset: 3px; border-radius: var(--r-card); cursor: grab; }
.board.editing .w.plain { padding: 8px; }
.w.dragging { opacity: .35; transform: scale(.98); }
.w.drop-before::before, .w.drop-after::after { content: ""; position: absolute; left: 10px; right: 10px; height: 3px; border-radius: 3px; z-index: 3; opacity: 1;
  background: var(--gold-grad); box-shadow: 0 0 16px var(--gold); inset: auto 10px; }
.w.drop-before::before { top: -10px; } .w.drop-after::after { bottom: -10px; top: auto; }

/* узкие блоки: донат над списком */
@container (max-width: 520px) {
  .donut-wrap { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap .chart { max-width: 210px; margin: 0 auto; width: 100%; }
  .row { grid-template-columns: minmax(0, 1.6fr) minmax(28px, .7fr) auto; gap: 2px 10px; }
}

/* ---------------------------------------------------------------- планшеты 7–11" */
@media (max-width: 1240px) {
  :root { --rail-w: 84px; }
  .rail { padding: 18px 0 18px 12px; align-items: center; }
  .rail-cap { display: none; }
  .rail-item { flex-direction: column; gap: 4px; padding: 10px 2px; width: 76px; font-size: 9.5px; text-align: center; line-height: 1.15; letter-spacing: -.01em; }
  .rail-item span { max-width: 74px; overflow-wrap: anywhere; }
  .rail-item.on::before { left: -12px; }
  .userchip .who { display: none; }
  .userchip { padding: 4px; }
}
@media (max-width: 1100px) {
}

/* ---------------------------------------------------------------- телефоны и PWA (4–7") */
@media (max-width: 760px) {
  :root { --top-h: 58px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .wrap { padding: 14px 12px calc(var(--tab-h) + var(--safe-b) + 28px); gap: 14px; }
  .topbar { gap: 8px; }
  .topbar .userchip, .topbar .logout-form { display: none; }
  .hero-meta { flex-direction: column; gap: 2px; }
  .hero-meta > span:not(:first-child)::before { display: none; }
  .brand .logo, .brand .logo img { width: 38px; height: 38px; }
  .w[data-size] { grid-column: span 12; }
  .board { --gap: 12px; }
  .card { padding: 16px; border-radius: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 14px 8px; border-radius: 20px; }
  .kpi:first-child, .kpi:last-child { grid-column: 1 / -1; }
  .kpi .v { font-size: 20px; }
  .kpi:first-child .v { font-size: 28px; }
  .kpi .c { font-size: 12px; }
  .kpi .spark { height: 34px; }
  .hero { padding: 18px 16px 16px; border-radius: 24px; }
  .period { margin-top: 14px; }
  .period .presets { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; scroll-snap-type: x proximity; }
  .period .presets::-webkit-scrollbar { display: none; }
  .seg { flex-wrap: nowrap; }
  .chip, .hero .chip-select { white-space: nowrap; flex: none; scroll-snap-align: start; }
  .more-toggle { display: inline-flex; }
  .period:not(.open) .period-adv { display: none; }
  .period-adv { padding: 12px; gap: 10px; }
  .period-adv .primary { width: 100%; justify-content: center; }
  .field { width: 100%; }
  .chart { height: 250px; }
  .chart.tall { height: 330px; }
  .boardbar { margin: 2px 0 -2px; }
  .sec-title { font-size: 18px; }
  .boardbar .edit-hint { flex-basis: 100%; order: 3; }
  .row { padding: 8px 4px; }
  .tbl { margin: 0 -4px; }
  table { font-size: 13px; }
  .grid2, .grid2.even { grid-template-columns: minmax(0, 1fr); }

  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 10px; right: 10px;
    bottom: calc(10px + var(--safe-b)); height: var(--tab-h); padding: 6px; border-radius: 22px;
    background: color-mix(in srgb, var(--surface-solid) 78%, transparent); border: 1px solid var(--line-2);
    backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .25) inset; }
  .tab { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 0; padding: 0;
    border: 0; border-radius: 16px; background: transparent; backdrop-filter: none; color: var(--muted); font-size: 10.5px; font-weight: 500; text-decoration: none; }
  .tab:hover { box-shadow: none; }
  .tab .ic { width: 22px; height: 22px; transition: transform .35s var(--spring); }
  .tab.on { color: var(--text); }
  .tab.on .ic { color: var(--gold); transform: translateY(-1px) scale(1.08); }
  .tab-ind { position: absolute; z-index: 0; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5); border-radius: 16px;
    background: var(--surface-2); border: 1px solid var(--line); transform: translateX(calc(var(--ti, 0) * 100%)); transition: transform .45s var(--spring); }
  .sheet-backdrop { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(5, 6, 9, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; transition: opacity .3s var(--ease); }
  .sheet-backdrop.show { opacity: 1; }
  .sheet { display: grid; gap: 4px; position: fixed; z-index: 50; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); padding: 10px 10px 12px;
    border-radius: 26px; background: var(--surface-solid); border: 1px solid var(--line-2); box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, .5);
    transform: translateY(110%); transition: transform .45s var(--spring); max-height: 80vh; overflow: auto; }
  .sheet.show { transform: none; }
  .sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); justify-self: center; margin: 2px 0 8px; }
  .sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 14px; border-radius: 16px; border: 0; background: transparent;
    backdrop-filter: none; text-decoration: none; color: var(--text); font-size: 15px; min-height: 52px; }
  .sheet-item:hover, .sheet-item.on { background: var(--surface-2); box-shadow: none; }
  .sheet-item .ic { color: var(--accent-text); }
  .sheet .logout-form { display: block; }

  .auth { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .auth-visual { min-height: 34vh; padding: 28px 22px; }
  .auth-title { font-size: 30px; }
  .auth-panel { padding: 0 14px 30px; background: transparent; }
  .auth-panel::before { display: none; }
  .auth-card { margin-top: -38px; }
  .auth-page { background: var(--bg); }
}
/* совсем маленькие экраны (4–4.7") */
@media (max-width: 380px) {
  .wrap { padding-left: 10px; padding-right: 10px; }
  .kpi .v { font-size: 17px; }
  .kpi:first-child .v { font-size: 24px; }
  .kpi .c { font-size: 11.5px; }
  .tab span { font-size: 9.5px; }
  .brand .t .mono { display: none; }
  h1 { font-size: 24px; }
  .chip, .hero .chip-select { font-size: 12.5px; padding: 5px 12px; min-height: 34px; }
  .donut-wrap .chart { height: 180px; }
}
/* планшет в PWA: нижняя панель тоже есть */
@media (display-mode: standalone) and (min-width: 761px) and (max-width: 1240px) {
  .topbar { padding-top: max(var(--safe-t), 8px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .ambient, .topbar, .rail, .tabbar, .boardbar, .period, .sheet { display: none !important; }
  .shell { display: block; } .card, .kpi { box-shadow: none; backdrop-filter: none; }
}



.board.is-empty::after { content: "Все блоки этого раздела скрыты. Нажмите «Настроить вид», чтобы вернуть нужные."; grid-column: 1 / -1;
  padding: 40px 20px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-2); border-radius: var(--r-card); }
