:root {
  --navy: #0B1F4B; --navy-2: #1E3A7A; --blue: #1E4FD8; --blue-dark: #163DA8; --blue-soft: #EEF3FD;
  --green: #0E7A55; --purple: #5B3BC4; --orange: #B85A00; --gold: #F2A516; --gold-ink: #1A1300;
  --bg: #EEF2F8; --card: #FFFFFF; --line: #DCE3EE; --field: #CBD3E0; --ink: #0F1B2D; --muted: #556070;
  --a-bg: #E3EBFC; --a-ink: #163DA8; --b-bg: #FFF0D6; --b-ink: #7A4300; --danger: #A12A2A;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.mono, .num { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- buttons & fields ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--field); background: #fff; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #9AA6B8; color: var(--ink); }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: #142D66; color: #fff; }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 700; }
.btn-gold:hover { background: #E19A0F; color: var(--gold-ink); }
.btn-danger { color: var(--danger); border-color: #E3B4B4; }
.btn-link { border: 0; background: none; color: var(--blue); font-weight: 600; padding: 0; min-height: 44px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select { width: 100%; height: 44px; border: 1px solid var(--field); border-radius: 10px; padding: 0 12px; background: #fff; font-size: 15px; }
.field input.time { font-family: "JetBrains Mono", ui-monospace, monospace; }
.field input[aria-invalid="true"] { border-color: var(--danger); background: #FFF6F6; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { min-height: 44px; border-radius: 10px; border: 1px solid var(--field); background: #fff; font-weight: 600; font-size: 14px; padding: 6px 8px; }
.seg button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.choice { min-height: 56px; border-radius: 10px; border: 1px solid var(--field); background: #fff; padding: 8px 12px; text-align: left; font-weight: 600; font-size: 14px; display: flex; flex-direction: column; gap: 2px; }
.choice small { font-weight: 500; color: var(--muted); font-size: 12px; }
.choice[aria-pressed="true"] { border: 2px solid var(--blue); background: var(--blue-soft); padding: 7px 11px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; }
.tabs button { min-height: 56px; border: 0; background: #E9EEF6; color: #3A4556; font-weight: 700; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tabs button small { font-weight: 500; font-size: 12px; }
.tabs button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.tabs button[aria-pressed="true"] small { color: #C3CDE0; }
.notice { margin: 0; font-size: 14px; min-height: 0; }
.notice:not(:empty) { padding: 10px 14px; border-radius: 10px; background: #FFF6E5; border: 1px solid #F2D29A; color: #6B3D00; }
.notice.ok:not(:empty) { background: #E8F6EF; border-color: #A9DCC3; color: #0B5B3F; }
.hint { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--navy); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; padding: 0 8px; }
.brand:hover { color: #fff; }
.brand img { display: block; width: 184px; height: auto; }
.sidenav { display: flex; flex-direction: column; gap: 4px; }
.sidenav a { min-height: 44px; padding: 0 14px; border-radius: 10px; display: flex; align-items: center; justify-content: space-between; color: #DDE4F0; text-decoration: none; font-weight: 600; font-size: 15px; }
.sidenav a:hover { background: #142D66; color: #fff; }
.sidenav a[aria-current="page"] { background: var(--blue); color: #fff; }
.badge { font-size: 11px; font-weight: 700; background: var(--gold); color: var(--gold-ink); padding: 2px 8px; border-radius: 999px; }
.side-foot { margin-top: auto; font-size: 13px; color: #C3CDE0; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; word-break: break-all; }
.side-foot button { align-self: flex-start; background: none; border: 0; color: #fff; font-weight: 600; padding: 8px 0; }
.content { flex: 1; min-width: 0; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.topbar { display: none; }
.bottomnav { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 700; }
.pagehead { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; }
.pagehead h1 { margin: 0; font-size: 22px; font-weight: 800; }
.pagehead p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.pagehead .tools { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.cols > .main { flex: 2 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.cols > .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

/* ---------- dashboard ---------- */
.hero { border-radius: 18px; overflow: hidden; background: var(--navy); color: #fff; }
.hero picture, .hero img { display: block; width: 100%; }
.hero img { aspect-ratio: 2.2 / 1; object-fit: cover; object-position: center 20%; }
.hero .welcome { padding: 18px 26px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.hero h1 { margin: 0; font-size: 24px; font-weight: 800; }
.hero p { margin: 2px 0 0; color: #DDE4F0; font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { min-height: 116px; border-radius: 16px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; text-decoration: none; }
.tile:hover { color: #fff; filter: brightness(1.08); }
.tile b { font-size: 19px; }
.tile span { font-size: 13px; line-height: 1.4; }
.t-blue { background: var(--blue); } .t-green { background: var(--green); } .t-purple { background: var(--purple); } .t-orange { background: var(--orange); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat b { font: 600 26px "JetBrains Mono", ui-monospace, monospace; }
.stat small { font-size: 12px; color: var(--muted); }
.chip { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chip.A { background: var(--a-bg); color: var(--a-ink); } .chip.B { background: var(--b-bg); color: var(--b-ink); }
.devchips { display: flex; gap: 6px; flex-wrap: wrap; }
.devchips button { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--field); background: #fff; font-weight: 600; font-size: 13px; }
.devchips button[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* dashboard summary (banner + totals) */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.dtop { background: var(--navy); color: #fff; border-radius: 18px; overflow: hidden; position: relative; padding-bottom: 20px; }
.dimg { position: relative; }
.dimg img { display: block; width: 100%; aspect-ratio: 2.6 / 1; object-fit: cover; object-position: center 22%; }
.dimg::after { content: ""; position: absolute; inset: 45% 0 0 0; background: linear-gradient(to bottom, rgba(11,31,75,0), var(--navy)); }
.dwelcome { position: relative; margin-top: -64px; padding: 0 24px; display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.dwelcome span { display: block; font-size: 15px; color: #DDE4F0; }
.dwelcome b { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; }
.dmonth select { appearance: none; -webkit-appearance: none; height: 48px; padding: 0 40px 0 18px; border-radius: 14px; border: 0; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230F1B2D' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center; color: var(--ink); font-weight: 700; font-size: 16px; cursor: pointer; }
.dsum { margin: 18px 24px 0; border: 1px solid rgba(255,255,255,.18); border-radius: 18px; padding: 18px; background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 14px; }
.dtotal { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.dtotal span { display: block; font-size: 15px; color: #DDE4F0; font-weight: 600; }
.dtotal b { display: block; font: 700 54px/1.05 "JetBrains Mono", ui-monospace, monospace; letter-spacing: -1px; }
.dtotal small { font-size: 15px; color: #DDE4F0; padding-bottom: 8px; }
.dgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.dcell { background: rgba(255,255,255,.08); border-radius: 14px; padding: 14px 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.dcell span { font-size: 14px; font-weight: 600; margin-top: 4px; }
.dcell b { font: 700 22px "JetBrains Mono", ui-monospace, monospace; }
/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 900px; }
table.data th { background: #F3F6FB; text-align: left; font-size: 12px; color: #3A4556; padding: 12px 10px; white-space: nowrap; }
table.data td { padding: 11px 10px; border-top: 1px solid #E6EBF3; vertical-align: top; }
table.data td.num { white-space: nowrap; }
table.data tbody tr[data-id] { cursor: pointer; }
table.data tbody tr[data-id]:hover { background: #F7F9FD; }
table.data tfoot td { border-top: 2px solid var(--navy); background: var(--blue-soft); font-weight: 700; padding: 12px 10px; }
.list { display: flex; flex-direction: column; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #E6EBF3; text-decoration: none; color: var(--ink); }
.list .row:first-child { border-top: 0; }
.list .row:hover { color: var(--ink); background: #F7F9FD; }
.list .d { width: 56px; flex-shrink: 0; font-weight: 700; }
.list .m { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list .m b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .m small { color: var(--muted); }
.list .t { font: 600 16px "JetBrains Mono", ui-monospace, monospace; }

/* ---------- ITL form ---------- */
.timebox { padding: 18px 20px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: end; }
.result { min-height: 44px; border-radius: 10px; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; gap: 8px; }
.result span { font-size: 12px; color: #C3CDE0; }
.result b { font: 600 17px "JetBrains Mono", ui-monospace, monospace; }
.auto { min-height: 44px; display: flex; align-items: center; font: 600 17px "JetBrains Mono", ui-monospace, monospace; }
.preview { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; }
.preview dt { color: var(--muted); }
.preview dd { margin: 0; font-weight: 700; word-break: break-word; }
.sigbox { height: 96px; border: 1px dashed var(--field); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #FAFBFD; }
.sigbox img { max-height: 84px; max-width: 90%; }

.presets { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.presets button { min-height: 48px; border-radius: 10px; border: 1px solid var(--field); background: #fff; font: 600 15px "JetBrains Mono", ui-monospace, monospace; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.presets button small { font: 500 11px Inter, system-ui, sans-serif; color: var(--muted); }
.presets button[aria-pressed="true"] { border: 2px solid var(--blue); background: var(--blue-soft); }
@media (max-width: 900px) { .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.datebox { position: relative; display: block; }
.datebox input.dmy { padding-right: 48px; font-family: "JetBrains Mono", ui-monospace, monospace; }
.datebox .calbtn { position: absolute; right: 2px; top: 2px; width: 44px; height: 40px; border: 0; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.datebox .calbtn:hover { color: var(--ink); background: #F3F6FB; }
.datebox input.native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
/* ---------- profile ---------- */
.pad { width: 100%; height: 190px; border: 1px dashed var(--field); border-radius: 12px; background: #FAFBFD; touch-action: none; display: block; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; background: var(--navy); }
.auth .visual { flex: 1 1 50%; position: relative; overflow: hidden; }
.auth .visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 12% 30%; }
.auth .panel { flex: 0 1 520px; background: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth h2 { margin: 0; font-size: 26px; font-weight: 800; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth .switch { display: grid; grid-template-columns: 1fr 1fr; background: #E9EEF6; border-radius: 12px; padding: 4px; }
.auth .switch button { min-height: 44px; border-radius: 9px; border: 0; background: transparent; font-weight: 700; color: #3A4556; }
.auth .switch button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.auth details { font-size: 14px; color: var(--muted); }
.auth details summary { cursor: pointer; min-height: 32px; }

/* ---------- admin ---------- */
.users { display: flex; flex-direction: column; }
.users .u { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid #E6EBF3; }
.users .u:first-child { border-top: 0; }
.users .u .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.users .u .btn { min-height: 38px; padding: 0 12px; font-size: 13px; }
.linkbox { font: 13px "JetBrains Mono", monospace; word-break: break-all; background: #F3F6FB; border-radius: 8px; padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .tiles, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timebox { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .timebox .result { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .content { padding: 0 16px calc(96px + env(safe-area-inset-bottom)); gap: 16px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: #fff; margin: 0 -16px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; position: sticky; top: 0; z-index: 5; }
  .topbar .brand { padding: 0; }
  .topbar .brand img { width: auto; height: 40px; }
  .bottomnav { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
  .bottomnav a { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-decoration: none; }
  .bottomnav a::before { content: ""; width: 22px; height: 4px; border-radius: 2px; background: transparent; }
  .bottomnav a[aria-current="page"] { color: var(--blue); }
  .bottomnav a[aria-current="page"]::before { background: var(--blue); }
  .hero { margin: 0 -16px; border-radius: 0; }
  .topbar + .hero { margin-top: -16px; }
  .is-dash .topbar { display: none; }
  .dtop { margin: 0 -16px; border-radius: 0 0 22px 22px; }
  .dimg img { aspect-ratio: auto; height: auto; object-fit: fill; }
  .dimg::after { display: none; }
  .dwelcome { padding: 0 16px; margin-top: 14px; align-items: center; }
  .dwelcome b { font-size: 22px; }
  .dsum { margin: 16px 16px 0; padding: 16px 14px; }
  .dtotal b { font-size: 46px; }
  .dgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dcell b { font-size: 20px; }
  .hero img { aspect-ratio: 16 / 9; object-position: center; }
  .hero .welcome { padding: 14px 16px; }
  .hero h1 { font-size: 20px; }
  .tiles { gap: 10px; }
  .tile { min-height: 92px; padding: 14px; }
  .tile b { font-size: 16px; }
  .stats { gap: 10px; }
  .stat b { font-size: 20px; }
  .pagehead { padding: 14px 16px; }
  .card { padding: 14px 16px; }
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3.choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols > .side { position: static; }
  .actions .btn { flex: 1 1 auto; }
  .auth { flex-direction: column; background: #fff; }
  .auth .visual { flex: none; aspect-ratio: 16 / 9; }
  .auth .visual img { object-position: center; }
  .auth .panel { flex: 1; padding: 24px 20px 32px; margin-top: -20px; border-radius: 22px 22px 0 0; position: relative; justify-content: flex-start; }
}
@media (min-width: 600px) and (max-width: 900px) and (orientation: portrait) {
  .auth .visual { aspect-ratio: 4 / 3; }
}
@media (max-width: 420px) {
  .g2.tight { grid-template-columns: 1fr; }
  .timebox { padding: 14px 16px; }
}

/* ---------- print (PDF) ---------- */
#print { display: none; }
@page { size: A4; margin: 0; }
@page itl { size: 297mm 210mm; margin: 0; }
@page act { size: 215.9mm 330.2mm; margin: 0; }
@media print {
  html, body { background: #fff !important; margin: 0; }
  #app { display: none !important; }
  #print { display: block; }
  .sheet { break-after: page; page-break-after: always; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
}
.sheet { background: #fff; overflow: hidden; }
.sheet svg { display: block; width: 100%; height: 100%; }
.sheet.itl { page: itl; width: 297mm; height: 209.5mm; }
.sheet.act { page: act; width: 215.9mm; height: 329.8mm; }
