/* «Радар смены» — палитра BuildOS (ink + латунь) в материале «жидкое стекло».
   Стекло = полупрозрачная заливка + размытие фона + блик сверху + мягкая тень. */
:root {
  --ink: #0e1116;
  --ink2: #151a21;
  --line: #252c36;
  --tx: #e8eaed;
  --soft: #9aa3ae;
  --brass: #c79a4b;
  --brass-hi: #dcb56c;
  --brass-ink: #16120a;
  --ok: #5fb88b;
  --warn: #E0A64B;
  --bad: #E07A3C;
  --crit: #D9534F;
  --blue: #6aa7e8;
  --violet: #b59cf0;

  --glass: rgba(255, 255, 255, .055);
  --glass-2: rgba(255, 255, 255, .085);
  --glass-edge: rgba(255, 255, 255, .11);
  --glass-hi: rgba(255, 255, 255, .16);
  --blur: blur(22px) saturate(170%);
  --r: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ink); }
body {
  margin: 0; color: var(--tx); min-height: 100vh;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: calc(76px + var(--safe-t)) 0 calc(104px + var(--safe-b));
  background: var(--ink);
  overscroll-behavior-y: none;
}
/* живой фон под стеклом: латунное и зелёное свечение */
body::before {
  content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 35% at 15% 10%, rgba(199, 154, 75, .22), transparent 70%),
    radial-gradient(35% 30% at 90% 35%, rgba(95, 184, 139, .10), transparent 70%),
    radial-gradient(45% 40% at 40% 100%, rgba(106, 167, 232, .10), transparent 70%),
    var(--ink);
  animation: drift 40s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(3%, -2%, 0) scale(1.05); } }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .big, .timer, .kpi .v { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

.glass {
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  border: 1px solid var(--glass-edge);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), inset 0 -1px 0 rgba(0,0,0,.25), 0 12px 32px rgba(0, 0, 0, .35);
}

/* ---------- верхняя плашка таймера ---------- */
.bar {
  position: fixed; z-index: 50; left: 12px; right: 12px; top: calc(var(--safe-t) + 8px);
  max-width: 696px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 16px; border-radius: 999px;
  cursor: pointer;
}
.bar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--soft); flex: none; }
.bar-main { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.bar-sub { color: var(--soft); font: 12px/1.2 var(--mono); margin-left: auto; text-align: right; letter-spacing: .02em; }
.bar.live .dot { background: var(--ok); box-shadow: 0 0 0 5px rgba(95, 184, 139, .18); }
.bar.paused .dot { background: var(--blue); }
.bar.warn .dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(224, 166, 75, .2); }
.bar.warn .bar-main { color: var(--warn); }
.bar.danger, .bar.over { border-color: rgba(217, 83, 79, .55); background: linear-gradient(180deg, rgba(217, 83, 79, .32), rgba(120, 20, 20, .35)); }
.bar.danger .dot, .bar.over .dot { background: var(--crit); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }

/* ---------- нижнее меню-«пилюля» ---------- */
.tabs {
  position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(var(--safe-b) + 10px);
  max-width: 520px; margin: 0 auto; padding: 6px; border-radius: 30px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
}
.tabs button {
  background: none; border: 0; border-radius: 24px; padding: 7px 0 6px; color: var(--soft);
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 58px; transition: background .2s, color .2s;
}
.tabs svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs span { font-size: 10.5px; font-weight: 600; }
.tabs button.on { color: var(--brass-hi); background: rgba(199, 154, 75, .16); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }

main { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; animation: fadeUp .25s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
h2 {
  font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em;
  color: var(--soft); margin: 26px 4px 10px;
}
h2:first-child { margin-top: 6px; }
.card { border-radius: var(--r); padding: 16px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.muted { color: var(--soft); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 > *, .grid3 > * { min-width: 0; }
input { min-width: 0; }
input[type=datetime-local] { font-size: 15px; padding: 12px 10px; -webkit-appearance: none; appearance: none; }
.pos { color: var(--ok); }
.neg { color: var(--crit) !important; }

/* ---------- кнопки ---------- */
.btn {
  border: 1px solid var(--glass-edge); border-radius: 18px; padding: 14px 16px; font-weight: 700; font-size: 16px;
  background: var(--glass-2); min-height: 52px; width: 100%;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--glass-hi);
  transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn.primary {
  background: linear-gradient(180deg, var(--brass-hi), var(--brass) 55%, #a97f36);
  color: var(--brass-ink); border-color: rgba(255, 225, 160, .45);
  box-shadow: inset 0 1px 0 rgba(255, 240, 200, .6), 0 10px 26px rgba(199, 154, 75, .28);
}
.btn.ok { background: linear-gradient(180deg, #74cc9f, var(--ok)); color: #06200f; border-color: rgba(190, 255, 220, .35); }
.btn.danger { background: rgba(217, 83, 79, .14); color: #f08f8c; border-color: rgba(217, 83, 79, .35); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.sm { min-height: 38px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 14px; }
.btn-xl { min-height: 68px; font-size: 20px; border-radius: 24px; letter-spacing: .01em; }

/* ---------- кольцо таймера ---------- */
.ring-wrap { position: relative; width: min(78vw, 300px); aspect-ratio: 1; margin: 4px auto 6px; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { stroke: rgba(255, 255, 255, .07); }
.ring-bar { transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1), stroke .4s; filter: drop-shadow(0 0 10px currentColor); }
.ring-tick { stroke: rgba(255, 255, 255, .35); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.timer { font-size: clamp(44px, 14vw, 60px); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.timer-label { font: 11px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--soft); margin-top: 8px; }
.timer-sub { font-size: 14px; color: var(--soft); margin-top: 6px; }
.timer-sub b { color: var(--tx); }
.lv-ok { color: var(--ok); } .lv-warn { color: var(--warn); } .lv-danger { color: var(--bad); } .lv-over { color: var(--crit); } .lv-rest { color: var(--blue); }
.rest-box { border-radius: 16px; padding: 12px; margin-top: 12px; background: rgba(106, 167, 232, .1); border: 1px solid rgba(106, 167, 232, .28); font-size: 14px; }
.rest-box.done { background: rgba(95, 184, 139, .1); border-color: rgba(95, 184, 139, .35); }
.alert { border-radius: 16px; padding: 12px 14px; margin-top: 12px; font-weight: 600; font-size: 14px; }
.alert.warn { background: rgba(224, 166, 75, .12); color: var(--warn); border: 1px solid rgba(224, 166, 75, .3); }
.alert.danger { background: rgba(217, 83, 79, .15); color: #f08f8c; border: 1px solid rgba(217, 83, 79, .35); }

/* ---------- цифры ---------- */
.kpi { border-radius: 20px; padding: 14px; }
.kpi .v { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.kpi .l { font: 10.5px/1.35 var(--mono); color: var(--soft); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
.kpi.accent .v { color: var(--brass-hi); }
.progress { height: 8px; background: rgba(255,255,255,.07); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > b { display: block; height: 100%; background: linear-gradient(90deg, var(--brass), var(--brass-hi)); border-radius: 4px; transition: width .6s; }

/* ---------- зоны ---------- */
.zone { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 20px; margin-bottom: 8px; }
.zone .score { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-weight: 800; font-size: 20px; flex: none; }
.lvl-high { background: rgba(224, 122, 60, .2); color: #f3a06c; box-shadow: inset 0 0 0 1px rgba(224,122,60,.35); }
.lvl-mid { background: rgba(199, 154, 75, .18); color: var(--brass-hi); box-shadow: inset 0 0 0 1px rgba(199,154,75,.3); }
.lvl-low { background: rgba(255,255,255,.05); color: var(--soft); }
.zone .name { font-weight: 700; font-size: 17px; }
.zone .why { font-size: 13px; color: var(--soft); margin-top: 3px; }
.zone .dist { text-align: right; font-size: 13px; color: var(--soft); flex: none; }
.zone .dist b { display: block; font-size: 17px; color: var(--tx); }
.pill { display: inline-block; font: 600 10px/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--soft); margin-right: 4px; vertical-align: middle; }
.pill.ext { color: var(--violet); border-color: rgba(181, 156, 240, .4); }
.pill.calc { color: var(--blue); border-color: rgba(106, 167, 232, .4); }
.pill.pers { color: var(--ok); border-color: rgba(95, 184, 139, .4); }
.pill.stale { color: var(--warn); border-color: rgba(224, 166, 75, .4); }
.pill.on { color: var(--brass-hi); border-color: rgba(199, 154, 75, .5); }

.seg { display: flex; border-radius: 18px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 14px; font-weight: 600; font-size: 13.5px; color: var(--soft); transition: background .2s, color .2s; }
.seg button.on { background: rgba(255, 255, 255, .1); color: var(--tx); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 8px rgba(0,0,0,.25); }

#map { height: 54vh; min-height: 300px; border-radius: var(--r); margin-bottom: 12px; background: #111; overflow: hidden; }
.leaflet-container { background: #0b0d10; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: rgba(21, 26, 33, .92); color: var(--tx); backdrop-filter: blur(12px); }
.map-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 2px #000, 0 0 5px #000; }
.map-label::before { display: none; }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.8) contrast(.9) saturate(.5); }

/* ---------- таблицы/формы ---------- */
.lines { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lines td { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.lines td:last-child { text-align: right; white-space: nowrap; }
.lines tr.total td { font-weight: 800; font-size: 19px; border-bottom: 0; padding-top: 12px; }
.lines tr.sub td { color: var(--soft); font-size: 13.5px; }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font: 10.5px/1.3 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--soft); margin: 0 0 6px 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea, input.in {
  width: 100%; background: rgba(0, 0, 0, .28); border: 1px solid var(--glass-edge); border-radius: 14px;
  padding: 12px 14px; font-size: 17px; min-height: 50px; box-shadow: inset 0 1px 3px rgba(0,0,0,.3);
}
textarea { min-height: 160px; font: 14px/1.4 var(--mono); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(199, 154, 75, .2); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.switch:last-child { border-bottom: 0; }
.switch input[type=checkbox] { width: 50px; height: 30px; appearance: none; -webkit-appearance: none; background: rgba(255,255,255,.12); border-radius: 15px; position: relative; flex: none; transition: background .2s; }
.switch input[type=checkbox]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .2s; }
.switch input[type=checkbox]:checked { background: var(--ok); }
.switch input[type=checkbox]:checked::after { transform: translateX(20px); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--glass-edge); background: rgba(255,255,255,.05); border-radius: 999px; padding: 8px 13px; font-size: 14px; }
.chip.on { background: rgba(199, 154, 75, .22); color: var(--brass-hi); border-color: rgba(199, 154, 75, .55); font-weight: 700; }
.item-edit { display: grid; grid-template-columns: 1fr 88px 38px; gap: 6px; align-items: center; margin-bottom: 6px; }
.item-edit input, .item-edit select { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.opts { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 0 0 12px 4px; font-size: 13px; color: var(--soft); }
.opts select { min-height: 34px; padding: 4px 8px; width: auto; font-size: 13px; border-radius: 10px; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--glass-edge); background: rgba(255,255,255,.05); display: grid; place-items: center; color: var(--soft); }

/* ---------- лист снизу ---------- */
.sheet { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; animation: fadeIn .2s; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet-card {
  width: 100%; max-width: 720px; margin: 0 auto; border-radius: 30px 30px 0 0; padding: 10px 16px calc(18px + var(--safe-b));
  max-height: 90vh; overflow: auto; animation: slideUp .28s cubic-bezier(.2, .9, .25, 1);
  background: linear-gradient(180deg, rgba(34, 40, 49, .88), rgba(20, 24, 30, .94));
  border: 1px solid var(--glass-edge); border-bottom: 0;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 -20px 50px rgba(0,0,0,.5);
}
.sheet-card::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 0 auto 14px; }
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-card h3 { margin: 0 0 14px; font-size: 21px; }
.amount-in { font-size: 46px !important; font-weight: 800; text-align: center; min-height: 80px !important; letter-spacing: -.02em; }
.keypad-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.keypad-chips button { min-height: 46px; border-radius: 14px; border: 1px solid var(--glass-edge); background: rgba(255,255,255,.06); font-weight: 700; }
.keypad-chips button:active { background: rgba(199,154,75,.25); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 120; border-radius: 999px; padding: 12px 20px; text-align: center; font-weight: 600; max-width: calc(100% - 32px); animation: fadeUp .2s; background: rgba(34, 40, 49, .9); border: 1px solid var(--glass-edge); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.empty { text-align: center; color: var(--soft); padding: 24px 12px; }
.ev { padding: 14px; border-radius: 20px; margin-bottom: 8px; }
.ev .t { font-weight: 700; }
.ev .meta { font-size: 13px; color: var(--soft); margin-top: 4px; }
.ev .win { font-weight: 700; color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.ev.now { border-color: rgba(199, 154, 75, .55); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px rgba(199,154,75,.25), 0 12px 32px rgba(0,0,0,.35); }
.ev .score { border-radius: 12px; padding: 4px 9px; font-weight: 800; }
a { color: var(--blue); }
details summary { cursor: pointer; padding: 8px 4px; color: var(--soft); font-size: 14px; }
.src-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 14px; }
.hist-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.hist-row:last-child { border-bottom: 0; }
.hist-row.tap { cursor: pointer; }
.split { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 6px; background: rgba(255,255,255,.06); }
.split .c { background: var(--brass); } .split .k { background: var(--blue); }

/* ---------- столбики дохода ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; margin: 16px 0 6px; padding: 0 2px; }
.bars.month { gap: 2px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar-col i { display: block; width: 100%; min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--brass-hi), var(--brass)); box-shadow: 0 0 12px rgba(199,154,75,.3); transition: height .5s; }
.bar-col i.neg-bar { background: var(--crit); box-shadow: none; }
.bar-col span { font: 10px/1 var(--mono); color: var(--soft); }
.bars.month .bar-col span { font-size: 8px; }

/* ---------- метки событий на карте ---------- */
.ev-pin-wrap { background: none; border: 0; }
.ev-pin { display: flex; flex-direction: column; align-items: center; gap: 1px; width: 46px; }
.ev-pin i { font-style: normal; font-weight: 800; font-size: 13px; line-height: 1; padding: 4px 8px; border-radius: 12px; background: var(--violet); color: #160f2b; border: 2px solid rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.ev-pin.now i { background: var(--bad); color: #fff; }
.ev-pin.hi i { font-size: 15px; padding: 5px 9px; }
.ev-pin span { font: 600 10px/1 var(--mono); color: #fff; text-shadow: 0 1px 3px #000, 0 0 5px #000; }
.seg-sm button { font-size: 12.5px; padding: 10px 2px; }
.goal .progress { height: 10px; }

/* ---------- вход ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; padding: 0 16px; }
.brand { text-align: center; margin-bottom: 26px; }
.brand img { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 16px 40px rgba(199,154,75,.3); }
.brand h1 { margin: 16px 0 4px; font-size: 28px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--soft); font: 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .12em; }
body.auth-mode { padding-top: calc(20px + var(--safe-t)); }
body.auth-mode .bar, body.auth-mode .tabs { display: none; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
