/* Four Rivers Media — Team Time. Same brand: cyan, ink, paper. */
:root {
  --cyan: #3fa0bd;
  --cyan-deep: #2d7f98;
  --cyan-wash: #e6f2f5;
  --ink: #10191c;
  --ink-2: #1b272b;
  --paper: #f7f7f4;
  --white: #ffffff;
  --line: #d6dddc;
  --muted: #617074;
  --danger: #b4452f;
  --ok: #2f8f6b;
  --radius: 6px;
  --sans: 'DM Sans', system-ui, sans-serif;
  --display: 'Manrope', system-ui, sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.04em; line-height: 1.08; margin: 0; }
p { margin: 0; }
em.serif, h1 em, h2 em { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; font-style: italic; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 40px; text-align: center; }

/* Boot */
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--ink); }
.boot-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); animation: pulse 1.4s ease-in-out infinite; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 42px; padding: 10px 18px;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font-weight: 600; font-size: 14px; letter-spacing: .01em;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--white); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-cyan { background: var(--cyan); border-color: var(--cyan); color: var(--ink); }
.btn-cyan:hover { background: var(--ink); border-color: var(--ink); color: var(--white); }
.btn-light { border-color: #ffffff60; color: var(--white); }
.btn-light:hover { background: var(--cyan); border-color: var(--cyan); color: var(--ink); }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-ghost { border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { border-color: #e3c2ba; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: var(--white); }
.link-btn { background: none; border: 0; padding: 0; color: var(--cyan-deep); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.arrow { width: 18px; height: 18px; flex: none; }

/* Signed-out */
.gate {
  position: relative; min-height: 100vh; display: grid; align-content: space-between;
  padding: clamp(24px, 5vw, 56px); color: var(--white); background: var(--ink); overflow: hidden;
}
.gate::before {
  content: ''; position: absolute; inset: 0;
  background: url('/assets/river-hero.jpg') center / cover no-repeat;
  opacity: .32; transform: scale(1.04); animation: drift 26s ease-in-out infinite alternate;
}
.gate::after { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, #10191cf2 30%, #10191c99 70%, #10191c66); }
.gate > * { position: relative; z-index: 1; }
.gate-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.gate-top img { width: 190px; }
.gate-top a { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; text-decoration: none; opacity: .75; }
.gate-top a:hover { opacity: 1; color: var(--cyan); }
.gate-body { max-width: 760px; padding: 9vh 0 6vh; }
.eyebrow { display: inline-flex; align-items: center; gap: 12px; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); }
.eyebrow::before { content: ''; width: 34px; height: 1px; background: currentColor; }
.gate h1 { font-size: clamp(44px, 7.4vw, 96px); font-weight: 650; margin: 22px 0 22px; }
.gate h1 em { color: var(--cyan); }
.gate p.lead { max-width: 520px; color: #ffffffc4; font-size: 17px; margin-bottom: 34px; }
.gate-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.gate-note { font-size: 13px; color: #ffffff90; }
.notice {
  margin-top: 26px; max-width: 560px; padding: 14px 16px; border-left: 3px solid var(--cyan);
  background: #ffffff12; color: #ffffffe0; font-size: 14px; border-radius: 0 var(--radius) var(--radius) 0;
}
.notice.warn { border-color: #e3a14b; }
.gate-foot { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: #ffffff70; }

/* App shell */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  min-height: 68px; padding: 0 clamp(16px, 3.4vw, 40px);
  background: #10191cf7; color: var(--white); border-bottom: 1px solid #ffffff14;
  backdrop-filter: blur(14px);
}
.topbar .brand img { width: 150px; }
.topbar .brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand-tag { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--cyan); border-left: 1px solid #ffffff30; padding-left: 14px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tab {
  position: relative; background: none; border: 0; color: #ffffffa8; padding: 22px 12px;
  font-size: 14px; font-weight: 600; letter-spacing: .01em;
}
.tab:hover { color: var(--white); }
.tab[aria-current="page"] { color: var(--white); }
.tab[aria-current="page"]::after { content: ''; position: absolute; left: 12px; right: 12px; bottom: 14px; height: 2px; background: var(--cyan); }
.tab .live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); margin-left: 6px; vertical-align: 2px; animation: pulse 1.6s ease-in-out infinite; }
.me { display: flex; align-items: center; gap: 12px; padding-left: 18px; border-left: 1px solid #ffffff22; }
.me-name { font-size: 13px; line-height: 1.2; text-align: right; }
.me-name small { display: block; color: #ffffff80; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--cyan); color: var(--ink); font-weight: 700; font-size: 13px; flex: none; }

main.view { max-width: 1180px; margin: 0 auto; padding: clamp(22px, 4vw, 48px) clamp(16px, 3.4vw, 40px) 80px; }
.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 26px; }
.view-head h2 { font-size: clamp(32px, 4.2vw, 52px); font-weight: 650; }
.view-head p { color: var(--muted); margin-top: 8px; max-width: 560px; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 10px; }
.panel-pad { padding: clamp(18px, 2.6vw, 28px); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 38px 0 14px; }
.section-title h3 { font-size: 20px; font-weight: 700; }
.section-title span { color: var(--muted); font-size: 13px; }

/* Timer */
.timer {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 26px; align-items: center;
  padding: clamp(20px, 3vw, 34px); background: var(--ink); color: var(--white); border-radius: 12px;
  position: relative; overflow: hidden;
}
.timer::before {
  content: ''; position: absolute; inset: 0; background: url('/assets/river-hero.jpg') center 60% / cover; opacity: 0;
  transition: opacity .8s;
}
.timer.is-running::before { opacity: .18; animation: drift 30s ease-in-out infinite alternate; }
.timer > * { position: relative; }
.timer-fields { display: grid; gap: 16px; min-width: 0; }
.timer-input {
  width: 100%; background: transparent; border: 0; border-bottom: 1px solid #ffffff38; color: var(--white);
  font-size: clamp(18px, 2.2vw, 24px); padding: 6px 0 10px; outline: none; border-radius: 0;
}
.timer-input::placeholder { color: #ffffff70; }
.timer-input:focus { border-color: var(--cyan); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid #ffffff2e; background: transparent; color: #ffffffcc; font-size: 13px; font-weight: 500;
  transition: background .2s, border-color .2s, color .2s;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--cyan)); }
.pill:hover { border-color: #ffffff70; color: var(--white); }
.pill[aria-pressed="true"] { background: var(--white); color: var(--ink); border-color: var(--white); }
.timer-side { display: grid; justify-items: end; gap: 12px; text-align: right; }
.clock { font-family: var(--display); font-weight: 700; font-size: clamp(46px, 6vw, 76px); letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.timer.is-running .clock { color: var(--cyan); }
.timer-meta { font-size: 13px; color: #ffffff9e; min-height: 20px; }
.timer-meta .link-btn { color: var(--cyan); }
.start-btn {
  min-width: 168px; min-height: 56px; font-size: 16px; border-radius: var(--radius);
  background: var(--cyan); border: 1px solid var(--cyan); color: var(--ink); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  transition: background .2s, color .2s, transform .15s, box-shadow .3s;
}
.start-btn:hover { background: var(--white); border-color: var(--white); }
.start-btn:active { transform: scale(.98); }
.start-btn.stop { background: var(--white); border-color: var(--white); color: var(--ink); }
.start-btn.stop:hover { background: #ffe9e4; }
.start-btn .glyph { width: 14px; height: 14px; }
.start-btn.stop .glyph { border-radius: 2px; background: var(--danger); }
.start-btn:not(.stop) .glyph { width: 0; height: 0; border-left: 13px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.save-state { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #ffffff80; transition: color .3s; }
.save-state.saved { color: var(--cyan); }
.save-state.error { color: #ff9c87; }
.long-warning { grid-column: 1 / -1; padding: 10px 14px; border-radius: var(--radius); background: #e3a14b26; color: #ffd8a1; font-size: 13px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); overflow: hidden; }
.stat { padding: 18px 20px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat small { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.stat strong { display: block; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat span { font-size: 12px; color: var(--muted); }

/* Entry list */
.day-group { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; border-bottom: 1px solid var(--line); }
.day-head h4 { margin: 0; font-family: var(--display); font-size: 14px; font-weight: 700; letter-spacing: -.01em; }
.day-head span { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.entry {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: 12px 4px; border-bottom: 1px solid #e9eeed; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; transition: background .15s;
}
.entry:hover { background: #f1f5f4; }
.entry .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--line)); }
.entry-main { min-width: 0; }
.entry-main strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-main span { font-size: 13px; color: var(--muted); }
.entry-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-dur { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.entry.running .entry-dur { color: var(--cyan-deep); }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

/* Forms */
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--white); outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px #3fa0bd2b; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; align-items: end; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Toolbar / filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding: 16px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; }
.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: 0; background: var(--white); padding: 9px 13px; font-size: 13px; font-weight: 600; border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.toolbar .spacer { flex: 1; }

/* Reports */
.report-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; }
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) 70px; gap: 12px; align-items: center; font-size: 14px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; border-radius: 999px; background: #edf1f0; overflow: hidden; }
.bar b { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--cyan)); width: 0; transition: width .7s cubic-bezier(.2, .7, .2, 1); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.days-chart { display: flex; align-items: end; gap: 6px; height: 150px; padding-top: 10px; }
.days-chart .col { flex: 1; min-width: 6px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.days-chart .col .track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.days-chart .col b { width: 100%; max-width: 34px; background: var(--cyan); border-radius: 4px 4px 0 0; height: 0; transition: height .7s cubic-bezier(.2, .7, .2, 1); }
.days-chart .col small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid #e9eeed; vertical-align: middle; }
th { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: #fbfbf9; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
tfoot td { font-weight: 700; background: #fbfbf9; }
.cat-chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.cat-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--line)); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: #edf1f0; color: var(--muted); }
.badge.admin { background: var(--cyan-wash); color: var(--cyan-deep); }
.badge.off { background: #f6e6e2; color: var(--danger); }
.badge.live { background: var(--ink); color: var(--cyan); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
td .row-actions { flex-wrap: nowrap; }
tr.inactive td { color: var(--muted); }

/* Live board */
.live-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.live-card { padding: 16px; border-radius: 10px; background: var(--ink); color: var(--white); display: grid; gap: 6px; }
.live-card .who { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 600; }
.live-card .clock-sm { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--cyan); font-variant-numeric: tabular-nums; }
.live-card .what { font-size: 13px; color: #ffffffb0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Categories admin */
.cat-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #e9eeed; }
.cat-row:last-child { border-bottom: 0; }
.cat-row input[type="color"] { width: 38px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.cat-row.archived { opacity: .55; }

/* Dialog */
dialog {
  width: min(560px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 12px; background: var(--white); color: var(--ink);
  box-shadow: 0 30px 80px #10191c55;
}
dialog::backdrop { background: #10191c99; backdrop-filter: blur(3px); }
dialog[open] { animation: rise .25s ease-out; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { font-size: 20px; }
.dialog-body { padding: 20px 22px; display: grid; gap: 14px; }
.dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px 20px; flex-wrap: wrap; }
.icon-btn { background: none; border: 0; width: 34px; height: 34px; border-radius: var(--radius); display: grid; place-items: center; }
.icon-btn:hover { background: #edf1f0; }
.hint { font-size: 12px; color: var(--muted); }
.saved-flag { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ok); opacity: 0; transition: opacity .3s; }
.saved-flag.show { opacity: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  padding: 12px 18px; border-radius: var(--radius); background: var(--ink); color: var(--white); font-size: 14px;
  box-shadow: 0 16px 40px #10191c40; transition: opacity .25s, transform .25s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

.fade-in { animation: rise .35s ease-out both; }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.82); } }
@keyframes drift { from { transform: scale(1.04) translateX(0); } to { transform: scale(1.1) translateX(-2%); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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

@media (max-width: 900px) {
  .report-grid { grid-template-columns: 1fr; }
  .brand-tag { display: none; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; padding-top: 10px; }
  .topbar .brand img { width: 126px; }
  .me { margin-left: auto; border-left: 0; padding-left: 0; }
  .me-name { display: none; }
  .tabs { order: 3; width: 100%; margin: 0 -8px; overflow-x: auto; }
  .tab { padding: 14px 10px 16px; }
  .tab[aria-current="page"]::after { bottom: 8px; }
  .timer { grid-template-columns: 1fr; }
  .timer-side { justify-items: stretch; text-align: left; grid-template-columns: 1fr auto; align-items: center; }
  .timer-side .clock { grid-column: 1 / -1; }
  .start-btn { min-width: 0; width: 100%; grid-column: 1 / -1; }
  .entry { grid-template-columns: 10px minmax(0, 1fr) auto; }
  .entry-time { grid-column: 2; grid-row: 2; }
  .entry-dur { grid-column: 3; grid-row: 1 / span 2; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .bar-row { grid-template-columns: minmax(80px, 110px) minmax(0, 1fr) 60px; }
  .gate h1 { text-wrap: balance; }
}
