/* Шрифт UZ Sans вшитий у застосунок: static/fonts/. */
@font-face { font-family: 'UZ Sans'; font-weight: 350; font-display: swap; src: url('/fonts/UZSans-Light.woff') format('woff'); }
@font-face { font-family: 'UZ Sans'; font-weight: 400; font-display: swap; src: url('/fonts/UZSans-Regular.woff') format('woff'); }
@font-face { font-family: 'UZ Sans'; font-weight: 500; font-display: swap; src: url('/fonts/UZSans-Medium.woff') format('woff'); }
@font-face { font-family: 'UZ Sans'; font-weight: 600; font-display: swap; src: url('/fonts/UZSans-SemiBold.woff') format('woff'); }
@font-face { font-family: 'UZ Sans'; font-weight: 700; font-display: swap; src: url('/fonts/UZSans-Bold.woff') format('woff'); }

:root {
  --navy: #151F6D;
  --navy-2: #24308A;
  --cream: #F4EEDC;
  --yellow: #FFC72C;
  --bg: #F3F4F8;
  --card: #FFFFFF;
  --text: #141933;
  --muted: #646B8A;
  --line: #E1E3EE;
  --ok: #1E9E5A;
  --warn: #D98A00;
  --bad: #D93025;
  --ink: #151F6D;       /* акцентний текст (номери, активна вкладка) */
  --soft: #E8EAF5;      /* світлі кнопки, позначки */
  --press: #EEF0F8;
  --field: #FFFFFF;
  --ok-bg: #E2F4EA;
  --warn-bg: #FFF1D0;
  --bad-bg: #FDE3E1;
  --none-bg: #ECEDF3;
  --open-bg: #FFF3D6;
  --open-fg: #8A5A00;
  --now-bg: #FFF8E1;
  --radius: 14px;
  --font: 'UZ Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
/* Темна тема: ті самі кольори УЗ, приглушені для ночі (вибір у «Ще» → «Тема»). */
:root[data-theme=dark] {
  --navy: #26349A;
  --navy-2: #A9B8FF;
  --bg: #0C1130;
  --card: #161D45;
  --text: #E6E8F4;
  --muted: #9AA2C8;
  --line: #29315F;
  --ok: #52CF8A;
  --warn: #F2B648;
  --bad: #FF7B72;
  --ink: #D2DAFF;
  --soft: #252E66;
  --press: #1F275A;
  --field: #10163A;
  --ok-bg: #123A2A;
  --warn-bg: #3A2D0C;
  --bad-bg: #47191C;
  --none-bg: #242B57;
  --open-bg: #3A2D0C;
  --open-fg: #F2B648;
  --now-bg: #322B0E;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
a { color: var(--navy-2); }
button, input, select, textarea { font: inherit; color: inherit; }

/* Шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  background: var(--navy); color: var(--cream); padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--cream); text-decoration: none; font-weight: 700; }
.brand img { border-radius: 7px; }
.brand img.uz { border-radius: 0; }
.top h1 { flex: 1; margin: 0; font-size: 16px; font-weight: 400; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { font-size: 12px; background: rgba(244,238,220,.15); border-radius: 99px; padding: 3px 9px; white-space: nowrap; }
.who:empty { display: none; }
.sync { font-size: 12px; background: var(--yellow); color: var(--navy); border-radius: 99px; padding: 3px 9px; white-space: nowrap;
  text-decoration: none; font-weight: 700; }
.chip.pend { background: var(--yellow); color: var(--navy); }
.offline { background: var(--yellow); color: var(--navy); text-align: center; font-size: 14px; padding: 6px; }

.view { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(env(safe-area-inset-bottom) + 90px); }

/* Нижнє меню */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 6px;
  font-size: 12px; color: var(--muted); text-decoration: none; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--ink); font-weight: 700; }

/* Картки і списки */
.card { display: block; background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  color: inherit; text-decoration: none; box-shadow: 0 1px 2px rgba(21,31,109,.06); border: 1px solid var(--line); }
a.card:active { background: var(--press); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.num { font-weight: 700; font-size: 18px; color: var(--ink); }
.name { color: var(--navy-2); }
.sub { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; font-size: 12px; border-radius: 99px; padding: 2px 8px; background: var(--soft); color: var(--ink); vertical-align: middle; }
.chip.uz { background: var(--cream); color: #151F6D; }
.chip.closed { background: var(--ok-bg); color: var(--ok); }
.chip.open { background: var(--open-bg); color: var(--open-fg); }
.section-title { margin: 18px 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Затримка */
.delay { font-weight: 700; border-radius: 10px; padding: 4px 9px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delay.big { font-size: 26px; padding: 6px 14px; }
.d-none { background: var(--none-bg); color: var(--muted); }
.d-ok { background: var(--ok-bg); color: var(--ok); }
.d-warn { background: var(--warn-bg); color: var(--warn); }
.d-bad { background: var(--bad-bg); color: var(--bad); }

/* Підсумок дня */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--navy); color: var(--cream); border-radius: var(--radius); padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; opacity: .85; }

/* Панель інструментів */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar input[type=search] { flex: 1 1 160px; }
.datebar { display: flex; gap: 6px; align-items: center; flex: 1 1 100%; }
.datebar input { flex: 1; }

/* Кнопки й поля */
.btn { border: 0; border-radius: 12px; padding: 10px 14px; background: var(--navy); color: var(--cream); font-weight: 700;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn.light { background: var(--soft); color: var(--ink); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.btn.icon { min-width: 44px; padding: 10px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--field); min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-2); outline-offset: 0; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 16px; }
label.check input { width: 22px; min-height: 22px; height: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1 1 auto; }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; }

/* Таблиця графіка (як у службовому розкладі) */
.tt-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); }
table.tt { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tt th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 400; padding: 8px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tt td { padding: 9px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tt th:first-child, .tt td:first-child { padding-left: 10px; }
.tt th:last-child, .tt td:last-child { padding-right: 8px; text-align: right; }
.tt tr:last-child td { border-bottom: 0; }
.tt .st { font-weight: 700; }
.tt .t { white-space: nowrap; }
.tt tr.pass td { color: var(--muted); font-style: italic; }
.tt tr.done td.st::before { content: '●'; color: var(--ok); margin-right: 5px; font-size: 11px; vertical-align: 2px; }
.tt tr.hl td { background: var(--soft); }
.tt tr.now td { background: var(--now-bg); }
.tt tr.now td.st::before { content: '▶'; color: var(--ink); margin-right: 5px; font-size: 11px; }
.tt tr.tap { cursor: pointer; }
.tt .fc { color: var(--muted); }
.tt .delay { font-size: 12px; padding: 2px 4px; }
.tt .delay.fc { background: none; }

/* Редактор зупинок */
.stop-edit { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.stop-edit .grid4 { display: grid; grid-template-columns: 1fr 1fr 70px; gap: 6px; margin-top: 6px; }
.stop-edit .row input { flex: 1; }
.stop-edit .ctl { display: flex; gap: 4px; }
.stop-edit .ctl button { min-width: 40px; min-height: 40px; border: 0; border-radius: 10px; background: var(--soft); color: var(--ink); font-weight: 700; }
.stop-edit .car { display: grid; grid-template-columns: 152px 1fr 66px; gap: 6px; margin-top: 6px; }
.stop-edit .row input[name=pos] { flex: none; width: 56px; text-align: center; }

/* Модальні вікна */
dialog { background: var(--card); color: var(--text); border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 30px); }
dialog::backdrop { background: rgba(10,15,50,.5); }
.modal { padding: 16px; }
.modal h2 { margin: 0 0 6px; font-size: 19px; color: var(--ink); }

/* Вхід */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; }
.login img.logo { width: 170px; height: auto; border-radius: 0; margin-bottom: 14px; }
[data-theme=dark] .for-light, :root:not([data-theme=dark]) .for-dark { display: none; }
.login h2 { color: var(--ink); margin: 12px 0 2px; font-size: 26px; }
.login form { text-align: left; margin-top: 16px; }
.disclaimer { color: var(--muted); font-size: 12px; text-align: center; margin-top: 22px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 76px);
  background: var(--navy); color: var(--cream); padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
pre.ex { background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px; font-size: 12px; overflow-x: auto; }

/* Затримки УЗ: перемикач категорій */
.seg { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; }
.seg button { flex: none; border: 1px solid var(--line, #D5D9E6); background: var(--card); color: inherit; border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600; }
.uzinfo { margin: 2px 2px 10px; }

/* Табло станції (як bahn.expert) */
.st-card { padding: 14px; font-weight: 600; }
.star { color: var(--muted); font-size: 18px; }
.star.on { color: var(--yellow); }
.btn.star { font-size: 20px; color: var(--muted); }
.btn.star.on { color: var(--yellow); }
#bt { flex: 1 1 150px; min-width: 0; }
.brow { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; }
.btime { width: 52px; flex: none; font-variant-numeric: tabular-nums; }
.btime b { font-size: 18px; color: var(--ink); }
.btime sup { font-size: 10px; color: var(--muted); margin-left: 1px; }
.btime .real { font-weight: 700; font-size: 14px; background: none; padding: 0; }
.real.d-ok { color: var(--ok); } .real.d-warn { color: var(--warn); } .real.d-bad { color: var(--bad); } .real.d-none { color: var(--muted); }
.bdest { font-weight: 700; margin-top: 2px; }
.bside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.brow.gone { opacity: .55; }
.brow.maybe { border-style: dashed; }
.brow.cancel .btime b, .brow.cancel .bdest { text-decoration: line-through; color: var(--muted); }
