:root {
  --paper: #EEF2F4;
  --surface: #FFFFFF;
  --ink: #1D2B36;
  --muted: #56636F;
  --line: #D5DCE2;
  --brand: #23415A;
  --brand-soft: #E2EBF2;
  --done: #2E7D5B;
  --done-bg: #E3F2EA;
  --progress: #9A5B00;
  --progress-bg: #FBEFD9;
  --pending: #A23B3B;
  --pending-bg: #F8E3E3;
  --radius: 10px;
  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 3px solid #5B8DB8; outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- top bar */
.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { color: #fff; text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: .55rem; }
.brand-mark { background: #fff; color: var(--brand); border-radius: 6px; font-size: .75rem; padding: .2rem .35rem; letter-spacing: .02em; }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { color: #D3E0EB; text-decoration: none; padding: .4rem .75rem; border-radius: 6px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: rgba(255,255,255,.16); color: #fff; }
.who { display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.who a, .who .linkish { color: #D3E0EB; }
.who-name { color: #fff; font-weight: 700; }
.who form { margin: 0; }

/* ---------- page */
.page { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p { margin: 0; }

.flashes { margin-bottom: 1rem; display: grid; gap: .5rem; }
.flash { margin: 0; padding: .65rem .9rem; border-radius: 8px; border-left: 4px solid; background: var(--surface); }
.flash-ok { border-color: var(--done); }
.flash-error { border-color: var(--pending); }
.flash-warn { border-color: var(--progress); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.panel + .panel { margin-top: 1rem; }

/* ---------- forms */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #B9C4CD; border-radius: 8px; padding: .55rem .7rem;
}
textarea { resize: vertical; min-height: 2.6rem; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 2px solid var(--brand-soft); }
.field { margin-bottom: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; font-weight: 400; }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check input { width: 1.1rem; height: 1.1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 700; border-radius: 8px; padding: .55rem 1rem; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #1A3348; }
.btn-ghost { background: #fff; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-small { padding: .3rem .65rem; font-size: .875rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* ---------- status pills */
.pill { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: .1rem .55rem; white-space: nowrap; }
.s-done { color: var(--done); background: var(--done-bg); }
.s-in-progress { color: var(--progress); background: var(--progress-bg); }
.s-pending { color: var(--pending); background: var(--pending-bg); }
.pill-off { color: var(--muted); background: #E7ECEF; }
.pill-admin { color: var(--brand); background: var(--brand-soft); }

/* ---------- login */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-size: 1.5rem; }

/* ---------- day sheet (employee) */
.layout-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.day-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.day-tabs a { text-decoration: none; padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: #fff; font-size: .9rem; }
.day-tabs a.on { border-color: var(--brand); background: var(--brand); color: #fff; }
.sheet-date { font-size: 2rem; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.sheet-meta { color: var(--muted); margin-bottom: 1rem; }

.task-rows { list-style: none; margin: 0 0 .75rem; padding: 0; counter-reset: task; }
.task-row { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 9.5rem 5.5rem 2rem; gap: .5rem; align-items: start; padding: .5rem 0; border-bottom: 1px dashed var(--line); }
.task-row::before { counter-increment: task; content: counter(task); font-weight: 700; color: var(--muted); padding-top: .55rem; text-align: right; }
.task-row textarea { min-height: 2.6rem; }
.task-head { display: grid; grid-template-columns: 2rem minmax(0, 1fr) 9.5rem 5.5rem 2rem; gap: .5rem; font-size: .8rem; color: var(--muted); font-weight: 700; padding-bottom: .25rem; border-bottom: 1px solid var(--line); }
.task-head span:first-child { grid-column: 2; }
.remove-row { border: 0; background: none; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer; padding: .5rem 0; border-radius: 6px; }
.remove-row:hover { color: var(--pending); background: var(--pending-bg); }

/* ---------- report blocks */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; scroll-margin-top: 1rem; }
.report + .report { margin-top: .75rem; }
.report-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.report-head h3 { margin: 0; }
.report-head .muted { font-size: .875rem; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: .5rem; padding: .35rem 0; border-top: 1px solid #EDF0F2; align-items: baseline; }
.items li:first-child { border-top: 0; }
.items .n { color: var(--muted); font-weight: 700; text-align: right; font-size: .9rem; }
.items .t { white-space: pre-wrap; overflow-wrap: anywhere; }
.items .m { display: flex; gap: .4rem; align-items: center; }
.items .h { color: var(--muted); font-size: .85rem; }
.notes { margin: .6rem 0 0; padding: .55rem .75rem; background: #F5F7F9; border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.notes strong { display: block; font-size: .8rem; color: var(--muted); }

.comments { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .65rem; }
.comment { border-left: 3px solid var(--brand); padding: .15rem 0 .15rem .7rem; margin-bottom: .55rem; }
.comment p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .by { font-size: .8rem; color: var(--muted); display: flex; gap: .6rem; align-items: center; }
.comment .by form { margin: 0; }
.comment-form { display: flex; gap: .5rem; align-items: flex-start; }
.comment-form textarea { min-height: 2.5rem; }

.missing { background: transparent; border-style: dashed; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

/* ---------- admin day header */
.day-nav { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.day-nav form { display: flex; gap: .5rem; margin: 0; }
.day-nav input[type=date] { width: auto; }
.tally { display: flex; align-items: center; gap: 1rem; margin: .25rem 0 1rem; flex-wrap: wrap; }
.tally-bar { flex: 1; min-width: 180px; height: 10px; background: #DCE3E8; border-radius: 999px; overflow: hidden; }
.tally-bar span { display: block; height: 100%; background: var(--done); }
.tally strong { font-size: 1.1rem; }
.filters { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters a { text-decoration: none; padding: .3rem .75rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-size: .9rem; }
.filters a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.missing-names { font-size: .9rem; color: var(--muted); margin: -.25rem 0 1rem; }

/* ---------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid #E6EBEF; vertical-align: top; }
th { background: #F5F7F9; font-size: .82rem; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: #F5F7F9; }
.warn-num { color: var(--pending); font-weight: 700; }

/* ---------- reports filter */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem 1rem; align-items: end; }
.filter-bar .field { margin: 0; }
.export { display: flex; gap: .5rem; flex-wrap: wrap; }
.range-title { font-size: 1.5rem; font-weight: 700; margin: 1.5rem 0 .25rem; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* ---------- responsive */
@media (max-width: 860px) {
  .layout-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 1rem .85rem 3rem; }
  .who-name { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .sheet-date { font-size: 1.6rem; }
  .task-head { display: none; }
  .task-row { grid-template-columns: 1.5rem minmax(0, 1fr) 2rem; }
  .task-row textarea { grid-column: 2 / 3; }
  .task-row select { grid-column: 2 / 3; }
  .task-row input[type=number] { grid-column: 2 / 3; }
  .task-row .remove-row { grid-column: 3; grid-row: 1; }
  .comment-form { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media print {
  .topbar, .comment-form, .filters, .day-nav, .no-print { display: none !important; }
  body { background: #fff; }
}
