/* ShiftBoard — harbor ink, chart paper, kelp and buoy signals. */
:root {
  --ink: #13324B;          /* harbor ink: nav, headings */
  --ink-2: #1E4A6B;
  --paper: #F5F8F9;        /* cool chart paper background */
  --surface: #FFFFFF;
  --line: #D6E0E5;
  --line-2: #E8EEF1;
  --text: #17242E;
  --muted: #5B6F7C;
  --kelp: #2E7D6A;         /* on the clock / positive */
  --kelp-soft: #E2F2EC;
  --buoy: #F2B63D;         /* breaks / warnings */
  --buoy-soft: #FDF3DC;
  --alert: #B83A2E;        /* violations / destructive */
  --alert-soft: #F8E4E1;
  --focus: #3A86C8;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-d: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E1A23; --surface: #15242F; --line: #2A3E4C; --line-2: #1F313D;
    --text: #E6EEF2; --muted: #93A8B5; --ink: #0A1A27; --ink-2: #183850;
    --kelp: #4FB394; --kelp-soft: #173A31; --buoy: #F2B63D; --buoy-soft: #3B3017;
    --alert: #E06A5C; --alert-soft: #3C1F1C; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 16px/1.5 var(--font); color: var(--text); background: var(--paper);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-d); line-height: 1.15; margin: 0; color: var(--text); }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--ink-2); }
@media (prefers-color-scheme: dark) { a { color: #8CC3EA; } }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-family: var(--font-d); font-variant-numeric: tabular-nums; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--ink); color: #DCE7EE; padding: calc(18px + var(--safe-t)) 14px 18px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand b { font-family: var(--font-d); font-size: 1.15rem; color: #fff; letter-spacing: .01em; }
.brand small { display: block; color: #9FB8C8; font-size: .75rem; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s);
  color: #C7D7E1; text-decoration: none; font-weight: 500;
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }
.nav .badge { margin-left: auto; }
.side .grow { flex: 1; }
.side .me { border-top: 1px solid rgba(255,255,255,.12); padding: 12px 8px 0; font-size: .9rem; }
.side .me button { background: none; border: 0; color: #9FB8C8; padding: 0; cursor: pointer; text-decoration: underline; }
.side select { width: 100%; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.15); }
.side select option { color: #000; }

main { min-width: 0; }
.topbar { display: none; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 28px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    background: var(--ink); color: #fff; padding: calc(10px + var(--safe-t)) 14px 10px;
  }
  .topbar b { font-family: var(--font-d); font-size: 1.1rem; flex: 1; }
  .topbar select { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; max-width: 46vw; padding: 6px 8px; }
  .topbar select option { color: #000; }
  .topbar .icon-btn { color: #fff; }
  .page { padding: 18px 14px calc(96px + var(--safe-b)); }
  h1 { font-size: 1.5rem; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7rem; color: var(--muted); text-decoration: none; padding: 4px 0; position: relative; }
  .tabbar a svg { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"] { color: var(--ink-2); font-weight: 600; }
  @media (prefers-color-scheme: dark) { .tabbar a[aria-current="page"] { color: #8CC3EA; } }
  .tabbar .clock-tab span.dot { position: absolute; top: 2px; right: calc(50% - 16px); width: 9px; height: 9px; border-radius: 50%; background: var(--kelp); border: 2px solid var(--surface); }
  .tabbar .badge { position: absolute; top: 0; right: calc(50% - 20px); }
}

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn.primary:hover { background: var(--ink); }
.btn.go { background: var(--kelp); border-color: var(--kelp); color: #fff; }
.btn.warn { background: var(--buoy); border-color: var(--buoy); color: #2B2005; }
.btn.danger { color: var(--alert); }
.btn.danger.solid { background: var(--alert); border-color: var(--alert); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 32px; padding: 0 10px; font-size: .875rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 6px; cursor: pointer; color: var(--muted); border-radius: 6px; display: inline-grid; place-items: center; position: relative; }
.icon-btn svg { width: 22px; height: 22px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], input[type=time],
input[type=datetime-local], input[type=number], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink-2); flex: none; }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.err { color: var(--alert); font-size: .9rem; min-height: 1.2em; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink-2); color: #fff; }

.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--alert); color: #fff; font-size: .7rem; font-weight: 700; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 4px; font-size: .78rem; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.tag.kelp { background: var(--kelp-soft); color: var(--kelp); }
.tag.buoy { background: var(--buoy-soft); color: #8A6100; }
@media (prefers-color-scheme: dark) { .tag.buoy { color: var(--buoy); } }
.tag.alert { background: var(--alert-soft); color: var(--alert); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- content blocks */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.panel > .body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line-2); }
.list > li:first-child { border-top: 0; }
.list > li { flex-wrap: wrap; }
.list .main { flex: 1 1 220px; min-width: 0; }
.list .title { font-weight: 600; }
.list .meta { color: var(--muted); font-size: .875rem; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }

.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat b { display: block; font-family: var(--font-d); font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat span { color: var(--muted); font-size: .875rem; }
.stat a { text-decoration: none; color: inherit; }

.shift-chip { border-left: 4px solid var(--c, var(--ink-2)); padding: 8px 12px; background: var(--surface); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.day-label { font-family: var(--font-d); font-weight: 600; color: var(--muted); font-size: .95rem; margin: 18px 0 6px; }
.day-label.today { color: var(--kelp); }

/* ---------- schedule grid */
.sched-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); }
table.sched { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 940px; table-layout: fixed; }
.sched th, .sched td { border-bottom: 1px solid var(--line-2); border-left: 1px solid var(--line-2); vertical-align: top; }
.sched thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; padding: 8px; text-align: left; font-family: var(--font-d); font-weight: 600; }
.sched thead th small { display: block; font-family: var(--font); font-weight: 400; color: var(--muted); font-size: .78rem; }
.sched thead th.today { box-shadow: inset 0 -3px 0 var(--kelp); }
.sched th.who { width: 180px; position: sticky; left: 0; background: var(--surface); z-index: 3; border-left: 0; text-align: left; padding: 8px 10px; font-weight: 500; }
.sched tbody th.who { font-family: var(--font); }
.sched th.who .hrs { display: block; color: var(--muted); font-size: .78rem; font-weight: 400; }
.sched th.who .hrs.over { color: var(--alert); font-weight: 600; }
.sched td { padding: 4px; height: 64px; cursor: pointer; position: relative; }
.sched td:hover { background: var(--paper); }
.sched td.unavail { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--line-2) 6px 8px); }
.sched td.off { background: var(--buoy-soft); }
.sched td .cell-note { font-size: .7rem; color: var(--muted); padding: 2px 4px; display: block; }
.sched td.drop { outline: 2px dashed var(--focus); outline-offset: -3px; }
.sched tr.open-row th.who { color: var(--kelp); font-weight: 600; }
.chip {
  display: block; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface));
  border-radius: 3px 5px 5px 3px; padding: 4px 6px; font-size: .8rem; line-height: 1.25; margin-bottom: 3px; cursor: grab;
}
.chip b { font-weight: 600; display: block; font-variant-numeric: tabular-nums; }
.chip.draft { border-left-style: dashed; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 10%, var(--surface)) 0 6px, var(--surface) 6px 12px); }
.chip.warn { box-shadow: inset 0 0 0 1.5px var(--alert); }
.chip .w { color: var(--alert); font-weight: 600; }
.sched tfoot td { cursor: default; height: auto; padding: 6px 8px; font-size: .8rem; color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: 10px; align-items: center; }
.legend i { display: inline-block; width: 22px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-right: 6px; border: 1px solid var(--line); }

/* ---------- clock dial (the signature element) */
.clock-hero { display: grid; justify-items: center; text-align: center; padding: 8px 0 16px; }
.dial { position: relative; width: min(78vw, 320px); aspect-ratio: 1; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial .center { position: absolute; inset: 0; display: grid; place-content: center; }
.dial .big { font-family: var(--font-d); font-weight: 700; font-size: clamp(2.6rem, 12vw, 3.6rem); line-height: 1; font-variant-numeric: tabular-nums; }
.dial .lbl { color: var(--muted); font-size: .95rem; margin-top: 6px; }
.dial .state { font-weight: 600; margin-top: 8px; }
.dial-legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: .82rem; margin: 6px 0 18px; }
.dial-legend span::before { content: ''; display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.clock-actions { display: grid; gap: 10px; width: min(100%, 380px); }
.clock-actions .btn { min-height: 56px; font-size: 1.1rem; border-radius: var(--radius-m); }
.clock-actions .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.notice { border-left: 4px solid var(--buoy); background: var(--buoy-soft); padding: 10px 14px; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 0 0 14px; text-align: left; }
.notice.alert { border-color: var(--alert); background: var(--alert-soft); }
.notice.kelp { border-color: var(--kelp); background: var(--kelp-soft); }

/* ---------- messages */
.chat { display: flex; flex-direction: column; height: min(68vh, 640px); }
.chat .log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; }
.msg .who { font-size: .78rem; color: var(--muted); margin-bottom: 2px; }
.msg .bubble { background: var(--line-2); padding: 8px 12px; border-radius: 4px 12px 12px 12px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; text-align: right; }
.msg.me .bubble { background: var(--ink-2); color: #fff; border-radius: 12px 4px 12px 12px; text-align: left; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line-2); }
.chat form textarea { min-height: 42px; height: 42px; }
.ann { padding: 16px; border-top: 1px solid var(--line-2); }
.ann:first-child { border-top: 0; }
.ann .body { white-space: pre-wrap; margin: 6px 0 10px; }
.ann.pinned { border-left: 4px solid var(--buoy); }

/* ---------- timesheet */
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data th, .data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-2); }
.data th { font-weight: 600; color: var(--muted); font-size: .82rem; }
.data td.n, .data th.n { text-align: right; font-variant-numeric: tabular-nums; }
.data tr.sub td { background: var(--paper); font-weight: 600; }
.data tr.clickable { cursor: pointer; }
.data tr.clickable:hover td { background: var(--paper); }
.table-scroll { overflow-x: auto; }

/* ---------- modal / sheet */
.backdrop { position: fixed; inset: 0; background: rgba(8, 22, 33, .5); z-index: 50; display: grid; place-items: center; padding: 20px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal > .body { padding: 8px 18px 4px; overflow-y: auto; }
.modal > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 18px; flex-wrap: wrap; }
.modal > footer .spacer { flex: 1; }
@media (max-width: 860px) {
  .backdrop { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 92vh; padding-bottom: var(--safe-b); animation: sheet .2s ease-out; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } }

#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + var(--safe-b)); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); }
@media (min-width: 861px) { #toasts { bottom: 24px; } }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); animation: sheet .2s ease-out; }
.toast.err { background: var(--alert); }

/* ---------- auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth .box { background: var(--surface); width: min(420px, 100%); border-radius: 16px; padding: 28px; }
.auth .brand { padding: 0 0 18px; }
.auth .brand b { color: var(--text); font-size: 1.4rem; }
.auth .brand small { color: var(--muted); }

/* ---------- availability */
.avail-row { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line-2); }
.avail-row:first-child { border-top: 0; }
.avail-row .times { display: flex; gap: 8px; margin-top: 8px; }
.avail-row .times input { max-width: 140px; }

/* notifications drawer */
.notif-list li.unread .title::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--focus); margin-right: 8px; vertical-align: middle; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
