:root {
  --navy-900: #071a33;
  --navy: #0b2545;
  --navy-700: #13315c;
  --navy-500: #1d4e89;
  --navy-100: #e6edf7;
  --navy-50: #f3f6fb;
  --white: #ffffff;
  --ink: #0f1b2d;
  --muted: #55657a;
  --line: #d5deea;
  --ok: #17703a;
  --ok-bg: #e5f4ea;
  --warn: #8a5300;
  --warn-bg: #fff3d6;
  --bad: #a3141f;
  --bad-bg: #fde8ea;
  --info-bg: #e8f0fb;
  --radius: 14px;
  --tap: 52px;
  --shadow: 0 1px 2px rgba(7, 26, 51, .08), 0 4px 14px rgba(7, 26, 51, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--navy-50);
}
a { color: var(--navy-500); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; color: var(--navy); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; margin-top: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.mono, .t-time, .time { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .6rem;
  padding: calc(env(safe-area-inset-top) + .6rem) 1rem .6rem;
  background: var(--navy); color: var(--white);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; }
.brand-icon { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(255,255,255,.35); }
.topbar-sub { flex: 1; font-size: .82rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-account {
  color: var(--white); text-decoration: none; font-weight: 700; font-size: .85rem;
  border: 1px solid rgba(255,255,255,.45); border-radius: 999px; padding: .35rem .75rem; min-height: 36px;
  display: inline-flex; align-items: center;
}
.app { max-width: 760px; margin: 0 auto; padding: 1rem 1rem calc(96px + env(safe-area-inset-bottom)); }
.loading { text-align: center; color: var(--muted); padding: 3rem 0; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--white); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(7, 26, 51, .08);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 600; position: relative;
}
.tabbar a.active { color: var(--navy); }
.tabbar a.active::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--navy); border-radius: 0 0 3px 3px; }
.tab-icon { font-size: 1.35rem; line-height: 1; }
.tab-badge {
  position: absolute; top: 7px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--bad); color: var(--white); font-size: .72rem; line-height: 20px; text-align: center;
}

.toast {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 560px; margin: 0 auto; padding: .9rem 1rem; border-radius: 12px;
  background: var(--navy-900); color: var(--white); font-weight: 600; box-shadow: var(--shadow);
}
.toast.error { background: var(--bad); }

/* ---------- building blocks ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.page-head h1 { margin: 0; }
.stack > * + * { margin-top: .6rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .7rem 1.2rem; border-radius: 12px; border: 2px solid var(--navy);
  background: var(--navy); color: var(--white); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--white); color: var(--navy); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--navy-500); min-height: 44px; padding: .5rem .8rem; }
.btn.danger { background: var(--white); color: var(--bad); border-color: var(--bad); }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.small { min-height: 44px; padding: .45rem .9rem; font-size: .92rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

label { display: block; font-weight: 700; color: var(--navy); margin: .7rem 0 .25rem; font-size: .95rem; }
.hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .8rem; font: inherit; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px; background: var(--white);
}
input[type=file] { width: 100%; min-height: var(--tap); padding: .7rem; border: 2px dashed var(--navy-500); border-radius: 12px; background: var(--navy-50); font: inherit; }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 600; color: var(--ink); min-height: 44px; }
.check input { width: 22px; height: 22px; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--navy-100); color: var(--navy); white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.night { background: var(--navy); color: var(--white); }
.chip.outline { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.banner { border-radius: 12px; padding: .8rem 1rem; margin: .75rem 0; border-left: 5px solid var(--navy-500); background: var(--info-bg); }
.banner.warn { border-color: #d48a00; background: var(--warn-bg); }
.banner.bad { border-color: var(--bad); background: var(--bad-bg); }
.banner.ok { border-color: var(--ok); background: var(--ok-bg); }
.banner strong { display: block; margin-bottom: .15rem; }

/* ---------- auth ---------- */
.auth { max-width: 440px; margin: 0 auto; padding-top: 1rem; }
.auth-hero { text-align: center; background: var(--navy); color: var(--white); border-radius: var(--radius); padding: 1.6rem 1rem 1.4rem; margin-bottom: 1rem; }
.auth-hero img { width: 64px; height: 64px; border-radius: 14px; border: 2px solid rgba(255,255,255,.4); }
.auth-hero h1 { color: var(--white); font-size: 1.9rem; margin: .5rem 0 .15rem; }
.auth-hero p { margin: 0; opacity: .85; }

/* ---------- duty day + watch cards ---------- */
.duty-day { margin-top: 1.1rem; }
.duty-day-head {
  background: var(--navy); color: var(--white); border-radius: var(--radius) var(--radius) 0 0; padding: .85rem 1rem;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.duty-day-head h2 { color: var(--white); margin: 0; font-size: 1.15rem; }
.duty-day-head .sub { font-size: .82rem; opacity: .85; }
.duty-day-body { background: var(--white); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: .25rem 1rem 1rem; box-shadow: var(--shadow); }
.group-title { display: flex; align-items: center; gap: .5rem; margin: 1rem 0 .4rem; font-size: .8rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--navy-500); }
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.group-empty { color: var(--muted); font-size: .9rem; margin: 0 0 .25rem; }

.watch-card { border: 2px solid var(--line); border-radius: var(--radius); padding: .9rem; margin: .55rem 0; background: var(--white); }
.watch-card.overnight { border-color: var(--navy-700); }
.watch-card.needs-ack { border-color: #d48a00; }
.watch-card.changed { background: #fffaf0; }
.wc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.wc-station { font-size: 1.15rem; font-weight: 800; color: var(--navy); }
.wc-chips { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.wc-time { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .4rem; margin: .7rem 0 .3rem; background: var(--navy-50); border-radius: 12px; padding: .6rem .7rem; }
.t-block { text-align: center; }
.t-label { font-size: .68rem; font-weight: 800; letter-spacing: .1em; color: var(--muted); }
.t-time { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.t-date { font-size: .88rem; font-weight: 700; color: var(--navy-700); }
.t-date.next { color: var(--white); background: var(--navy); border-radius: 6px; padding: 0 .35rem; display: inline-block; }
.t-arrow { font-size: 1.4rem; color: var(--navy-500); }
.wc-allday { margin: .7rem 0 .3rem; background: var(--navy-50); border-radius: 12px; padding: .7rem .8rem; }
.wc-allday .big { font-size: 1.3rem; font-weight: 800; color: var(--navy); }
.wc-meta { font-size: .9rem; color: var(--muted); }
.wc-notes { font-size: .92rem; margin-top: .3rem; }
.wc-prev { font-size: .88rem; color: var(--warn); margin-top: .35rem; }
.wc-ack { margin-top: .7rem; }
.acked { display: flex; align-items: center; gap: .5rem; color: var(--ok); font-weight: 700; min-height: 44px; }
.acked .tick { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; background: var(--ok); color: var(--white); align-items: center; justify-content: center; }

/* ---------- full watchbill rows ---------- */
.wb-row { display: grid; grid-template-columns: 6.6rem 1fr; gap: .2rem .8rem; padding: .7rem .4rem; border-bottom: 1px solid var(--line); }
.wb-row:last-child { border-bottom: 0; }
.wb-row.mine { background: #fff7d9; border-radius: 10px; border-bottom-color: transparent; box-shadow: inset 4px 0 0 #f2b705; }
.wb-time { font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.wb-time .d { display: block; font-size: .76rem; font-weight: 700; color: var(--muted); }
.wb-station { font-weight: 700; }
.wb-name { color: var(--ink); }
.wb-name.none { color: var(--muted); font-style: italic; }
.wb-extra { grid-column: 2; display: flex; gap: .3rem; flex-wrap: wrap; }

/* ---------- notifications ---------- */
.notif { position: relative; }
.notif.unread { border-left: 5px solid var(--navy-500); }
.notif-title { font-weight: 800; color: var(--navy); }
.notif-body { white-space: pre-wrap; font-size: .95rem; margin: .4rem 0; }

/* ---------- coordinator ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin: .75rem 0; }
.tile { display: flex; flex-direction: column; justify-content: center; gap: .2rem; min-height: 96px; padding: .9rem; border-radius: var(--radius); background: var(--white); border: 2px solid var(--line); text-decoration: none; color: var(--navy); font-weight: 800; box-shadow: var(--shadow); }
.tile.primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.tile .tile-icon { font-size: 1.5rem; }
.tile .tile-sub { font-weight: 500; font-size: .82rem; opacity: .8; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.stat { background: var(--navy-50); border: 1px solid var(--line); border-radius: 12px; padding: .45rem .7rem; min-width: 84px; }
.stat b { display: block; font-size: 1.3rem; color: var(--navy); font-variant-numeric: tabular-nums; }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 700; }
.stat.warn { background: var(--warn-bg); border-color: #f0d08a; }
.stat.bad { background: var(--bad-bg); border-color: #f2b9bf; }
.stat.ok { background: var(--ok-bg); border-color: #b4dfc2; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: .7rem 0; }
.list > li:last-child { border-bottom: 0; }
.issue { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; padding: .3rem 0; }
.review-row { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; }
.review-row .line1 { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.review-row .time { font-weight: 800; color: var(--navy); min-width: 6.2rem; }
.review-row .issues { margin-top: .25rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.fix-box { background: var(--warn-bg); border-radius: 12px; padding: .8rem; margin: .5rem 0; }
.diff-add { color: var(--ok); }
.diff-rem { color: var(--bad); }
.diff-chg { color: var(--warn); }
.actions-bar { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: rgba(243, 246, 251, .96); padding: .7rem 0; display: flex; gap: .5rem; flex-wrap: wrap; z-index: 5; }
.actions-bar .btn { flex: 1 1 140px; }
table.simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.simple th, table.simple td { text-align: left; padding: .45rem .35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll-x { overflow-x: auto; }
details > summary { cursor: pointer; font-weight: 700; color: var(--navy); min-height: 44px; display: flex; align-items: center; }
.user-card .name { font-weight: 800; color: var(--navy); }
.station-block { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.station-block:last-child { border-bottom: 0; }
.station-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; color: var(--navy); }
.station-block .review-row { border-bottom: 0; padding: .3rem 0 .3rem .6rem; border-left: 3px solid var(--navy-100); margin-left: .1rem; }
select.type-select { width: auto; min-height: 40px; padding: .3rem .5rem; font-size: .85rem; border-width: 1px; }

/* ---------- offline ---------- */
.offline-banner {
  position: sticky; top: calc(env(safe-area-inset-top) + 54px); z-index: 9;
  background: #fff3d6; color: #5c3b00; border-bottom: 2px solid #d48a00;
  padding: .6rem 1rem; font-size: .9rem; font-weight: 600; text-align: center;
}
.chip.queued { background: #fff3d6; color: #8a5300; border: 1px dashed #d48a00; }

/* ---------- next duty day ---------- */
.next-duty { background: var(--white); border: 2px solid var(--navy); border-radius: var(--radius); padding: 1rem; margin: .75rem 0; box-shadow: var(--shadow); }
.nd-label { font-size: .75rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--navy-500); }
.nd-date { font-size: 1.5rem; font-weight: 800; color: var(--navy); margin-top: .15rem; }
.nd-when { font-weight: 700; color: var(--navy-700); }
.nd-status { margin-top: .6rem; padding: .55rem .75rem; border-radius: 10px; font-weight: 600; font-size: .95rem; }
.nd-status.ok { background: var(--ok-bg); color: var(--ok); }
.nd-status.wait { background: var(--navy-50); color: var(--navy-700); border: 1px dashed var(--navy-500); }
.recent { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.recent-title { font-weight: 700; color: var(--navy); font-size: .95rem; }
.recent ul { list-style: none; margin: .35rem 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px dotted var(--line); }
.nd-following { margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.form-errors { background: var(--bad-bg); border: 2px solid var(--bad); color: var(--bad); border-radius: 12px; padding: .7rem .9rem; margin-bottom: .5rem; }
.form-errors ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.env-banner { background: #5b2a86; color: #fff; text-align: center; font-weight: 800; font-size: .85rem; padding: .45rem 1rem; letter-spacing: .02em; }
.support { text-align: center; font-size: .9rem; color: var(--muted); margin: 1rem 0; }
.support a { font-weight: 700; }
.team { list-style: none; margin: .4rem 0; padding: 0; }
.team li { padding: .35rem 0; border-bottom: 1px dotted var(--line); font-weight: 600; }
