/* ============================================================
   Crew Attendance v2 — design tokens, layout, components
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #eaf0f8;
  --text: #0b1830;
  --muted: #566782;
  --border: #d6dfec;
  --primary: #0b63c4;
  --primary-hover: #094f9d;
  --on-primary: #ffffff;
  --accent: #0d9488;
  --danger: #c62828;
  --warn: #b45309;
  --ok: #15803d;
  --c-present: #15803d;
  --c-late: #b45309;
  --c-absent: #c62828;
  --c-leave: #5b4fd6;
  --c-sick: #0e7490;
  --ink: #ffffff;
  --shadow: 0 1px 2px rgb(11 24 48 / 6%), 0 8px 24px rgb(11 24 48 / 6%);
  --r: 16px;
  --r-sm: 10px;
  --nav-h: 68px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #070f1d; --surface: #0e1a2f; --surface-2: #15243d; --text: #e7eefa; --muted: #98a8c5;
    --border: #1f3250; --primary: #5aa0f5; --primary-hover: #7ab4f8; --on-primary: #04101f;
    --accent: #2dd4bf; --danger: #ff7b7b; --warn: #fbbf24; --ok: #3ddc84;
    --c-present: #3ddc84; --c-late: #fbbf24; --c-absent: #ff7b7b; --c-leave: #a9a4ff; --c-sick: #5fd3e8;
    --ink: #06101f; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070f1d; --surface: #0e1a2f; --surface-2: #15243d; --text: #e7eefa; --muted: #98a8c5;
  --border: #1f3250; --primary: #5aa0f5; --primary-hover: #7ab4f8; --on-primary: #04101f;
  --accent: #2dd4bf; --danger: #ff7b7b; --warn: #fbbf24; --ok: #3ddc84;
  --c-present: #3ddc84; --c-late: #fbbf24; --c-absent: #ff7b7b; --c-leave: #a9a4ff; --c-sick: #5fd3e8;
  --ink: #06101f; --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px rgb(0 0 0 / 30%);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.45; font-size: 15px; min-height: 100dvh;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 70%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 16px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--on-primary); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100dvh; }
.main-col { flex: 1; min-width: 0; }
main { padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px); max-width: 1180px; margin: 0 auto; outline: none; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.vessel { display: flex; align-items: center; gap: 12px; min-width: 0; }
.vessel-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #0b63c4, #0b1d3a); flex: none; }
.vessel-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vessel-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.vessel-sub #imoText:not(:empty)::before { content: "·"; margin: 0 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.off { background: var(--warn); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Navigation: bottom bar on phones */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.nav-brand, .nav-foot { display: none; }
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; padding: 6px 4px; border: 0; border-radius: 12px; background: transparent;
  color: var(--muted); font-size: 11.5px; font-weight: 600; transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--surface-2); }
.nav-btn[aria-current="page"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }

@media (min-width: 960px) {
  .nav {
    position: sticky; top: 0; height: 100dvh; width: 244px; flex: none; flex-direction: column; gap: 4px;
    padding: 22px 14px; border-top: 0; border-right: 1px solid var(--border); background: var(--surface); backdrop-filter: none;
  }
  .nav-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; }
  .nav-brand img { border-radius: 10px; }
  .nav-brand strong { display: block; font-size: 16px; }
  .nav-brand span { font-size: 12px; color: var(--muted); }
  .nav-btn { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; font-size: 14.5px; min-height: 46px; }
  .nav-foot { display: block; margin-top: auto; padding: 8px; font-size: 12px; color: var(--muted); }
  main { padding: 28px 36px 56px; }
  .topbar { padding-left: 36px; padding-right: 36px; }
}

/* ---------- Panels ---------- */
.panel { animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px 16px; flex-wrap: wrap; margin: 6px 0 16px; }
.panel-head h2 { font-size: 26px; font-weight: 750; outline: none; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; margin-bottom: 10px; }
h3.mt { margin-top: 22px; }

/* ---------- Buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px; font-weight: 650; font-size: 14px; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1a0505; }
.btn-install { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; min-height: 40px; padding: 0 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field.grow { flex: 1; }
.field.inline { margin: 0; }
.field label { font-size: 13px; font-weight: 650; color: var(--muted); }
input[type="text"], input[type="search"], input[type="date"], input[type="month"], input[type="number"], select, textarea, #deptInput, .field input {
  width: 100%; min-height: 44px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav input { width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.toolbar select { width: auto; min-width: 150px; }
.search { position: relative; flex: 1; min-width: 200px; }
.search .i { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.search input { padding-left: 40px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 14px; margin-bottom: 14px; }
.segmented button { border: 0; background: transparent; padding: 0 16px; min-height: 40px; border-radius: 10px; font-weight: 650; font-size: 14px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 14%); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 99px; background: var(--surface-2); font-size: 13px; font-weight: 600; }
.chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.chip button:hover { background: var(--border); color: var(--text); }
.chip .i { width: 14px; height: 14px; }

/* ---------- Today ---------- */
.hero { margin-bottom: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface)); }
.hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.hero .big { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.hero .big small { font-size: 20px; color: var(--muted); font-weight: 650; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 14px 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: inherit; transition: width .3s ease; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.stat { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; font-size: 13px; font-weight: 650; }
.stat b { font-size: 15px; }
.stat i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.day-meta { padding: 0; margin-bottom: 4px; }
.day-meta summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; cursor: pointer; border-radius: var(--r); }
.day-meta summary::-webkit-details-marker { display: none; }
.sum-title { font-weight: 700; font-size: 14px; white-space: nowrap; }
.sum-preview { flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-meta .chev { color: var(--muted); transition: transform .15s; }
.day-meta[open] .chev { transform: rotate(90deg); }
.day-meta-fields { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 14px 2px; }
.day-meta-fields .field:first-child { width: 190px; }

.s-present { --c: var(--c-present); } .s-late { --c: var(--c-late); } .s-absent { --c: var(--c-absent); }
.s-leave { --c: var(--c-leave); } .s-sick { --c: var(--c-sick); } .s-none { --c: var(--muted); }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 12px; border-radius: 14px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--border)); }
.banner.info { background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.banner .i { color: var(--warn); }
.banner.info .i { color: var(--primary); }
.banner p { flex: 1; font-size: 14px; }
.banner .btn { min-height: 36px; padding: 0 12px; }

.daily-list { display: flex; flex-direction: column; gap: 10px; }
.row { display: grid; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.row.marked { border-left: 4px solid var(--c); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #fff; background: hsl(var(--h, 210) 58% 38%); }
.nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-note { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.row-note .i { width: 14px; height: 14px; }
.seg { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.seg-btn {
  min-height: 46px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2);
  font-weight: 750; font-size: 14px; transition: background .12s, transform .1s;
}
.seg-btn:hover { border-color: var(--c); }
.seg-btn .long { display: none; }
.seg-btn[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: var(--ink); }
.seg-btn:active { transform: scale(.96); }
.row-extra { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ot { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.ot button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--surface); display: grid; place-items: center; box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }
.ot button:disabled { opacity: .4; box-shadow: none; }
.ot output { min-width: 78px; text-align: center; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.ot output.on { color: var(--primary); }

@media (min-width: 760px) {
  .row { grid-template-columns: minmax(200px, 1fr) auto auto; align-items: center; }
  .seg { grid-template-columns: repeat(5, auto); }
  .seg-btn { padding: 0 14px; min-width: 62px; }
  .seg-btn .short { display: none; }
  .seg-btn .long { display: inline; font-size: 13px; }
}

/* ---------- Crew ---------- */
.crew-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.crew-card { display: flex; flex-direction: column; gap: 12px; }
.crew-card.archived { opacity: .7; }
.crew-top { display: flex; align-items: center; gap: 12px; }
.crew-top .who { flex: 1; }
.crew-actions { display: flex; gap: 2px; }
.crew-actions .icon-btn { border: 0; background: transparent; width: 40px; height: 40px; color: var(--muted); }
.crew-actions .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, var(--surface)); color: var(--ok); }
.badge.warn { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }

/* ---------- Empty / welcome ---------- */
.empty { text-align: center; padding: 44px 20px; border: 2px dashed var(--border); border-radius: var(--r); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.empty .art { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--accent)); }
.empty .art .i { width: 30px; height: 30px; }
.empty h3 { font-size: 20px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }
.empty .btn-row { justify-content: center; }
.empty ul { list-style: none; padding: 0; margin: 20px auto 0; display: grid; gap: 6px; max-width: 360px; text-align: left; font-size: 13.5px; color: var(--muted); }
.empty li::before { content: "✓"; color: var(--ok); font-weight: 800; margin-right: 8px; }
#panel-today.is-empty :is(.hero, .day-meta, .toolbar) { display: none; }

/* ---------- Month ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 14px 16px; }
.kpi b { display: block; font-size: 26px; letter-spacing: -.02em; line-height: 1.1; }
.kpi span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
thead th:first-child { z-index: 3; background: var(--surface-2); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--surface-2); }
tfoot td { font-weight: 750; background: var(--surface-2); position: sticky; bottom: 0; }
.pill { display: inline-block; min-width: 30px; padding: 2px 8px; border-radius: 99px; font-weight: 700; text-align: center; background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--c); }
.pill.zero { background: transparent; color: var(--muted); font-weight: 500; }
.rate { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.rate i { display: block; width: 56px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rate i b { display: block; height: 100%; background: var(--ok); }
.rate.low i b { background: var(--warn); }
.rate.bad i b { background: var(--danger); }
.grid th, .grid td { padding: 3px; text-align: center; }
.grid thead th { padding: 6px 2px; min-width: 34px; line-height: 1.15; }
.grid thead th small { display: block; font-weight: 500; opacity: .75; }
.grid thead th.today { color: var(--primary); }
.grid .wk { background: color-mix(in srgb, var(--muted) 8%, var(--surface)); }
.grid { width: max-content; min-width: 100%; }
.grid td:first-child { padding: 6px 12px; min-width: 150px; text-align: left; }
.g { position: relative; width: 32px; height: 32px; border: 0; border-radius: 8px; font-weight: 750; font-size: 12px; background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: var(--c); }
.g.s-none { background: transparent; color: var(--border); }
.g.s-none:hover { background: var(--surface-2); }
.g.ot::after { content: ""; position: absolute; right: 3px; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; background: var(--c); }

/* ---------- Reports & settings ---------- */
.export-grid, .settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); margin-bottom: 16px; }
.export-card p { color: var(--muted); font-size: 14px; margin-bottom: 16px; min-height: 60px; }
.export-icon { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 12px; color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.danger-card { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.file-btn { cursor: pointer; }
.card > p { margin-bottom: 14px; }

/* ---------- Dialog ---------- */
dialog { border: 0; padding: 0; background: transparent; max-width: 520px; width: calc(100% - 24px); margin: auto; color: var(--text); }
dialog::backdrop { background: rgb(4 10 22 / 55%); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 24px 80px rgb(0 0 0 / 35%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 0 20px; }
.dlg-head h3 { font-size: 18px; }
.dlg-head .icon-btn { border: 0; background: transparent; }
.dlg-body { padding: 14px 20px 6px; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.dlg-body .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-body .radio { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; cursor: pointer; }
.dlg-body .radio input { margin-top: 3px; accent-color: var(--primary); }
.dlg-body .radio span { font-size: 13px; color: var(--muted); display: block; }
.dlg-body .hint { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 200; left: 12px; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 460px; width: fit-content; padding: 10px 12px 10px 16px;
  background: #0b1830; color: #f2f6fd; border-radius: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / 30%); font-size: 14px; animation: pop .2s ease-out;
}
:root[data-theme="dark"] .toast { background: #e7eefa; color: #0b1830; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #e7eefa; color: #0b1830; } }
.toast.error { border-left: 4px solid #ff6b6b; }
.toast.success { border-left: 4px solid #34d399; }
.toast button { border: 0; background: rgb(255 255 255 / 14%); color: inherit; padding: 6px 12px; border-radius: 9px; font-weight: 700; min-height: 34px; }
:root[data-theme="dark"] .toast button { background: rgb(0 0 0 / 10%); }
@media (min-width: 960px) { .toasts { left: 244px; bottom: 24px; } }

@media (max-width: 640px) {
  main { padding-top: 10px; }
  .panel-head { margin-bottom: 10px; }
  .date-nav { width: 100%; }
  .date-nav input { flex: 1; min-width: 0; }
  .hero { padding: 14px; margin-bottom: 10px; }
  .hero .big { font-size: 30px; }
  .hero .big small { font-size: 16px; }
  .bar { margin: 10px 0; }
  .stats { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
  .stats::-webkit-scrollbar { display: none; }
  .stat { flex: none; padding: 5px 10px; }
  .toolbar { margin: 10px 0; gap: 8px; }
  .search { min-width: 0; }
  .toolbar select { min-width: 0; max-width: 46%; }
  .toolbar-actions { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; margin-left: 0; gap: 6px; }
  .toolbar-actions .btn { min-height: 42px; padding: 0 6px; font-size: 12.5px; gap: 5px; }
  .toolbar-actions .i { width: 16px; height: 16px; }
  .row { padding: 12px; gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi b { font-size: 22px; }
  .grid td:first-child { min-width: 104px; }
}
@media (max-width: 520px) {
  .btn-row .btn { flex: 1; }
  .panel-head h2 { font-size: 23px; }
  .dlg-body .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  .nav, .topbar, .toasts, .toolbar, .btn, .icon-btn { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; }
  .panel { display: none !important; }
  #panel-month { display: block !important; }
  .table-wrap { max-height: none; overflow: visible; box-shadow: none; }
}
