:root {
  --ink: #1d2b36;
  --muted: #5d6b76;
  --line: #d9e2e7;
  --bg: #f4f7f8;
  --card: #fff;
  --sea: #0e7490;
  --sea-dark: #0b5568;
  --sand: #fef6e4;
  --bad: #b42318;
  --good: #067647;
  --dv: 'Faruma', 'Noto Sans Thaana', 'MV Boli', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--sea); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1.2rem 0 .4rem; }
code { background: #e8eef1; padding: 0 .3em; border-radius: 4px; }

.top { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; background: var(--sea-dark); color: #fff; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.top .brand { color: #fff; font-weight: 700; text-decoration: none; }
.top nav { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; }
.top nav a { color: #d6eef4; text-decoration: none; padding: .3rem .7rem; border-radius: 6px; }
.top nav a.on, .top nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.top .tools { display: flex; gap: .6rem; align-items: center; }
.chip { font-family: var(--dv); border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; border-radius: 999px; padding: .1rem .8rem; cursor: pointer; font-size: 1rem; }
.chip.on { background: #fff; color: var(--sea-dark); }
button.link { background: none; border: 0; color: #d6eef4; cursor: pointer; font: inherit; }
form.inline { display: inline; }

main { max-width: 1180px; margin: 0 auto; padding: 1.2rem; }
.flash { padding: .6rem 1rem; border-radius: 8px; margin-bottom: .8rem; background: #e7f6ee; color: var(--good); }
.flash.error { background: #fdecea; color: var(--bad); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.card.big { border-color: var(--sea); }
.card .label { color: var(--muted); font-size: .85rem; }
.card .value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: .85rem; }
.bad { color: var(--bad) !important; font-weight: 600; }
.ok { color: var(--good); }

.panel, fieldset { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 .4rem; }
.hint { color: var(--muted); font-size: .85rem; display: block; margin: .3rem 0; }
.gaps li { color: var(--bad); }
.todo li { margin: .2rem 0; }

.stack label { display: block; margin: .5rem 0; font-size: .9rem; color: var(--muted); }
.stack label.short { max-width: 240px; }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: .15rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid #8fd3e3; border-color: var(--sea); }
.dv { font-family: var(--dv); font-size: 1.05rem; line-height: 1.9; }
textarea.dv { resize: vertical; }
.row2, .row3, .row5 { display: grid; gap: .8rem; }
.row2 { grid-template-columns: 1fr 1fr; }
.row3 { grid-template-columns: 1fr 1fr 1fr; }
.row5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 760px) { .row2, .row3, .row5 { grid-template-columns: 1fr; } }
.sec { border-top: 1px dashed var(--line); padding-top: .4rem; margin-top: .6rem; }

.actions { display: flex; gap: .8rem; align-items: center; padding: .8rem 0; }
.actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding-top: 1.4rem; }
button.primary, .btn { background: var(--sea); color: #fff; border: 0; border-radius: 8px; padding: .55rem 1.2rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn { background: #fff; color: var(--sea); border: 1px solid var(--sea); }
button.primary:hover { background: var(--sea-dark); }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: .35rem .4rem; text-align: left; vertical-align: middle; }
table.grid th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.grid .num, .right { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.past td { color: var(--muted); text-decoration: line-through; }
table.grid tr.sum td { font-weight: 700; }
table.grid tr.new td { background: #fafcfd; }
table.items td:nth-child(2) { width: 34%; }
table.items td:nth-child(3) { width: 11%; }
input.tiny { width: 4.5rem; }
input.money { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.auto { display: inline-block; padding: .4rem .6rem; color: var(--sea-dark); font-weight: 600; }

.box { max-width: 380px; margin: 3rem auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.4rem; }
.box label { display: block; margin: .6rem 0; }
.box button { width: 100%; margin-top: .6rem; }

/* ---- Phase 2 ---- */
.swatch { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 4px; border: 1px solid rgba(0,0,0,.2); vertical-align: -.15em; }
.swatch.big { width: .9em; height: .9em; }
input[type=color] { padding: .15rem; height: 2.4rem; }
input.mid { width: 8.5rem; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
label.check input, td input[type=checkbox], td input[type=radio] { width: auto; margin: 0; }
label.check.inline { display: inline-flex; }
.hint.inline { display: inline; }
.bar { height: 6px; background: var(--line); border-radius: 99px; margin-top: .4rem; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--sea); }
table.tasks td:nth-child(2) { width: 38%; }
table.tasks td:nth-child(5) { width: 26%; }
table.tasks textarea { min-height: 2.3rem; }
tr.st-done td { background: #f3faf6; }
tr.st-done input, tr.st-done textarea { color: var(--muted); }
tr.st-waiting td:first-child, tr.st-sent td:first-child { box-shadow: inset 3px 0 #f79009; }
tr.st-approved td:first-child, tr.st-printed td:first-child { box-shadow: inset 3px 0 var(--good); }
tr.late td { background: #fff6f5; }
.panel.danger { display: flex; gap: 1rem; align-items: center; border-color: #f4c7c3; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.list-due li { margin: .15rem 0; }
a.card { color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--sea); }
table.tasks select { min-width: 9.5rem; }

/* ---- Phase 3 ---- */
nav.sub { display: flex; gap: .2rem; flex-wrap: wrap; padding: .35rem 1.2rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 2.9rem; z-index: 9; }
nav.sub a { text-decoration: none; padding: .25rem .7rem; border-radius: 6px; color: var(--muted); font-size: .92rem; }
nav.sub a.on { background: #e3f1f5; color: var(--sea-dark); font-weight: 600; }
nav.sub a.ext { margin-left: auto; }
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.nowrap { white-space: nowrap; }
input.time { width: 6.5rem; font-variant-numeric: tabular-nums; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
button.big { font-size: 1.1rem; padding: .8rem 1.6rem; }
.link-btn { background: none; border: 0; color: var(--sea); cursor: pointer; font: inherit; padding: .2rem .4rem; text-decoration: underline; }
.link-btn.bad { color: var(--bad); }
.badge { display: inline-block; padding: .1rem .6rem; border-radius: 99px; font-size: .82rem; font-weight: 600; background: #eef2f4; color: var(--muted); }
.badge.rs-out { background: #e0f2fe; color: #075985; }
.badge.rs-back { background: #dcfce7; color: #166534; }
.badge.rs-dq { background: #fee2e2; color: #991b1b; }
tr.rs-dq td { background: #fff6f5; }
tr.rejected td { color: var(--muted); text-decoration: line-through; }
tr.rejected td:nth-last-child(-n+2) { text-decoration: none; }

/* Weigh-in */
.team-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.team-picker a { display: flex; flex-direction: column; min-width: 8.5rem; padding: .5rem .8rem; border-radius: 10px; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-right: 8px solid var(--c); }
.team-picker a.on { background: var(--c); border-color: var(--c); }
.team-picker a.on, .team-picker a.on small { color: var(--on); }
.team-picker a.rs-dq { opacity: .55; }
.team-picker small { color: var(--muted); font-size: .78rem; }
input.huge { font-size: 1.6rem; font-weight: 700; padding: .4rem .6rem; font-variant-numeric: tabular-nums; }
.weigh-form select { font-size: 1.1rem; height: 3.05rem; }

/* Fish cutting */
.cut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.cut { background: #fff; border: 1px solid var(--line); border-top: 8px solid var(--c); border-radius: 12px; padding: .8rem 1rem; }
.cut.running { box-shadow: 0 0 0 2px #8fd3e3; }
.cut.done { background: #f3faf6; }
.cut-head { display: flex; gap: .5rem; align-items: center; }
.place { background: var(--sea); color: #fff; border-radius: 99px; padding: 0 .6rem; font-weight: 700; }
.watch { font: 800 2.6rem/1.2 system-ui, sans-serif; font-variant-numeric: tabular-nums; margin: .3rem 0; }
.cut-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.cut-actions .fix { display: flex; gap: .2rem; margin-left: auto; }

/* Live graphics */
.row2.align-top { align-items: start; }
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #24323a; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.steps li { margin: .35rem 0; }
.layers { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.layer-form { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; }
.layer-form.is-on { border-color: #f04438; box-shadow: 0 0 0 2px #fecdca; }
.layer-form label { display: block; margin: .4rem 0; color: var(--muted); font-size: .9rem; }
.layer-head { display: flex; justify-content: space-between; align-items: center; }
.pill { font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 99px; background: #eef2f4; color: var(--muted); }
.is-on .pill { background: #f04438; color: #fff; }
.top .who { color: #d6eef4; font-size: .9rem; }
.newpass { background: var(--sand); border: 1px solid #f2d28b; border-radius: 12px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.newpass code { font-size: 1.5rem; font-weight: 700; background: #fff; padding: .2rem .6rem; letter-spacing: .05em; }
tr.off td { color: var(--muted); }
