:root {
  color-scheme: light;
  --bg: #f8f8f8;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --border: #d9d9d9;
  --border-strong: #16295b;
  --text: #1d1d1f;
  --text-2: #626570;
  --muted: #7a7d87;
  --heading: #16295b;
  --navy: #16295b;
  --accent: #265aa6;
  --accent-hover: #347ce9;
  --accent-soft: #e6edf7;
  --band: #ffc000;
  --s1: #265aa6; --s2: #e09a0b; --s3: #00968c; --s4: #d24726;
  --up: #2e8431; --down: #d62020;
  --warn-bg: #fff6dc; --warn-text: #856404;
  --err-bg: #fdeaea; --err-text: #a51b1b;
  --ok-bg: #e6f3e6; --ok-text: #155724;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161b1f; --surface: #1f262b; --surface-2: #283036; --border: #2c353b; --border-strong: #4b565e;
    --text: #ebe8e4; --text-2: #aeb8bd; --muted: #86939b; --heading: #f6f3ef;
    --navy: #13234d; --accent: #3ea6ff; --accent-hover: #7cc2ff; --accent-soft: #1b3358; --band: #e0a800;
    --s1: #2f8fe6; --s2: #b8800f; --s3: #00a89d; --s4: #e05a38;
    --up: #5cc46a; --down: #f07a7a;
    --warn-bg: #3a2e0c; --warn-text: #f5cf6b;
    --err-bg: #3d1717; --err-text: #f7a3a3;
    --ok-bg: #12301f; --ok-text: #7fdca4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161b1f; --surface: #1f262b; --surface-2: #283036; --border: #2c353b; --border-strong: #4b565e;
  --text: #ebe8e4; --text-2: #aeb8bd; --muted: #86939b; --heading: #f6f3ef;
  --navy: #13234d; --accent: #3ea6ff; --accent-hover: #7cc2ff; --accent-soft: #1b3358; --band: #e0a800;
  --s1: #2f8fe6; --s2: #b8800f; --s3: #00a89d; --s4: #e05a38;
  --up: #5cc46a; --down: #f07a7a;
  --warn-bg: #3a2e0c; --warn-text: #f5cf6b;
  --err-bg: #3d1717; --err-text: #f7a3a3;
  --ok-bg: #12301f; --ok-text: #7fdca4;
}

/* Стиль за мотивами zp.edu.ua: Roboto, темно-синя смуга меню, прямі кути, тонкі рамки */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 36px; line-height: 1.15; font-weight: 400; color: var(--heading); margin: 0 0 6px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 0 0 14px; font-weight: 500; color: var(--heading); }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 600; color: var(--text-2); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--accent); }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1328px; margin: 0 auto; padding: 14px 24px; background: var(--bg);
}
.brand { display: inline-flex; flex-direction: column; align-items: stretch; line-height: 1; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-name {
  font: 700 27px/1 "Roboto Condensed", "Roboto", sans-serif; text-transform: uppercase;
  color: var(--accent); letter-spacing: -.2px;
}
.brand-band {
  margin-top: 3px; padding: 2px 8px; background: var(--band); color: #16295b;
  font: 700 9.5px/1.3 "Roboto", sans-serif; text-transform: uppercase; letter-spacing: .12em; text-align: center;
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; padding: 0; cursor: pointer;
  background: transparent; border: 0; color: var(--text);
}
.icon-btn:hover { color: var(--accent); }
.icon-btn:disabled { opacity: .6; cursor: default; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#last-run { padding-right: 12px; margin-right: 4px; border-right: 1px solid var(--border); }

.nav-bar { position: sticky; top: 0; z-index: 10; background: var(--navy); }
.nav-inner { max-width: 1328px; margin: 0 auto; padding: 0 24px; display: flex; overflow-x: auto; scrollbar-width: none; }
.nav-inner::-webkit-scrollbar { display: none; }
.nav-inner a {
  position: relative; padding: 17px 22px; color: #fff; white-space: nowrap; font-weight: 500; font-size: 15.5px;
}
.nav-inner a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-inner a.active { background: rgba(255,255,255,.1); }
.nav-inner a.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--band); }

main { max-width: 1328px; margin: 0 auto; padding: 32px 24px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }

/* ---------- картки ---------- */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.files-grid { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); align-items: start; }
.files-grid > * { min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 0;
  padding: 20px 22px; min-width: 0;
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

.card.tile { display: flex; flex-direction: column; }
.tile .label {
  color: var(--text-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em;
  display: flex; justify-content: space-between; gap: 8px;
}
.tile .value { font-size: 34px; font-weight: 500; color: var(--heading); margin: auto 0 4px; padding-top: 10px; letter-spacing: -.5px; line-height: 1.1; }
.tile .sub { font-size: 13px; color: var(--muted); }
.tile.sm .value { font-size: 26px; }
/* плитки-посилання на огляді — як темно-сині плитки розділів на zp.edu.ua */
a.card.tile {
  position: relative; background: var(--navy); border-color: var(--navy); color: #fff;
  transition: background .15s;
}
a.card.tile::after {
  content: "→"; position: absolute; right: 20px; top: 16px; font-size: 20px; color: rgba(255,255,255,.55); transition: transform .15s, color .15s;
}
a.card.tile:hover { background: var(--accent); border-color: var(--accent); }
a.card.tile:hover::after { transform: translateX(4px); color: #fff; }
a.card.tile .label { color: rgba(255,255,255,.75); padding-right: 28px; }
a.card.tile .value { color: #fff; }
a.card.tile .sub { color: rgba(255,255,255,.7); }
a.card.tile .delta.up { color: #8fe39c; }
a.card.tile .delta.down { color: #ffaaaa; }
a.card.tile .delta.zero { color: rgba(255,255,255,.7); }
.periods { display: grid; gap: 3px; font-size: 13px; }
.periods > div { display: flex; justify-content: space-between; gap: 8px; }
.delta { font-weight: 600; font-size: 13px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.zero { color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 0; white-space: nowrap; letter-spacing: .02em;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.err { background: var(--err-bg); color: var(--err-text); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }

.notice { padding: 12px 16px; margin-bottom: 16px; font-size: 14px; border-left: 3px solid; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.err { background: var(--err-bg); color: var(--err-text); }
.notice.info { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .btn { margin-top: 10px; }

/* ---------- таблиці ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 600; color: var(--text-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; background: var(--surface); position: sticky; top: 0; border-bottom: 1px solid var(--border-strong); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
td.num, th.num { text-align: right; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.bar-cell { position: relative; min-width: 120px; }
.bar-cell .bar { height: 8px; border-radius: 0 2px 2px 0; background: var(--s1); min-width: 2px; }
.data-table td { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- форми ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
label.field input, label.field select, label.field textarea { font-size: 15px; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 0; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 0; padding: 10px 20px;
  border: 1px solid var(--navy); background: var(--navy); color: #fff; white-space: nowrap; transition: background .15s, border-color .15s;
}
:root[data-theme="dark"] .btn:not(.ghost):not(.danger) { background: var(--accent); border-color: var(--accent); color: #0d1b2e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn:not(.ghost):not(.danger) { background: var(--accent); border-color: var(--accent); color: #0d1b2e; } }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--heading); border-color: var(--border); }
.btn.ghost:hover { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--down); border-color: var(--border); }
.btn.danger:hover { background: var(--down); border-color: var(--down); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.icon { padding: 7px 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 0; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--text-2); padding: 6px 12px; cursor: pointer; }
.seg button:hover { color: var(--accent); }
.seg button.on { background: var(--navy); color: #fff; font-weight: 500; }

.dropzone {
  display: block; border: 1px dashed var(--border-strong); border-radius: 0; padding: 32px; text-align: center;
  color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--heading); font-weight: 500; font-size: 16px; }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list .day { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; padding: 12px 0 6px; }
.file-list li.f {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; border-left: 3px solid transparent;
}
.file-list li.f:hover { background: var(--surface-2); }
.file-list li.f.active { background: var(--accent-soft); border-left-color: var(--accent); }
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.filters { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter-row select, .filter-row input { flex: 1 1 140px; }
.filter-row .btn { flex: 0 0 auto; }

.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 360px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 0; margin-right: 5px; vertical-align: -1px; }

pre.code {
  background: var(--surface-2); border-radius: 0; padding: 14px; overflow-x: auto; font-size: 12px;
  max-height: 340px;
}
details summary { cursor: pointer; font-weight: 500; color: var(--heading); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 12px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 0; font-size: 14px; border-left: 3px solid var(--band);
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--down); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 0; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.hist { display: grid; gap: 4px; }
.hist-row {
  display: grid; grid-template-columns: 92px 1fr 48px; align-items: center; gap: 10px;
  font: inherit; font-size: 13px; color: var(--text); background: none; border: 0;
  padding: 7px 8px; border-radius: 0; cursor: pointer; text-align: left;
}
.hist-row:hover { background: var(--surface-2); }
.hist-row.on { background: var(--accent-soft); }
.hist-label { color: var(--text-2); }
.hist-bar { height: 14px; background: var(--surface-2); overflow: hidden; }
.hist-bar > span { display: block; height: 100%; background: var(--s1); min-width: 2px; border-radius: 0 2px 2px 0; }
.hist-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.bday { border-top: 3px solid var(--band); }
.icon-title { display: flex; align-items: center; gap: 10px; }
.icon-title svg { color: var(--accent); flex: none; }
.bday-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; }
.bday-list li { padding: 9px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.bday-name { font-weight: 500; }
.card h3 { text-transform: uppercase; letter-spacing: .07em; font-size: 11.5px; color: var(--text-2); }

/* ---------- вхід ---------- */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login { width: min(360px, 100%); display: grid; gap: 18px; padding: 32px 28px; border-color: transparent; }
.login .brand { align-self: start; justify-self: start; }
.login .btn { width: 100%; padding: 12px; }
.login .notice { margin: 0; }

@media (max-width: 900px) {
  .files-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .top { padding: 10px 16px; }
  .brand-name { font-size: 21px; }
  .brand-band { font-size: 8px; }
  #last-run { display: none; }
  .nav-inner { padding: 0 8px; }
  .nav-inner a { padding: 14px 14px; font-size: 14.5px; }
  main { padding: 20px 16px 36px; }
  h1 { font-size: 28px; }
  .card { padding: 16px; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .tile .value { font-size: 26px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .g4 > .card { padding: 14px; }
  .g4 .tile .value { font-size: 22px; }
  .g4 .tile .label { font-size: 10.5px; }
  a.card.tile::after { right: 12px; top: 10px; font-size: 16px; }
}
