/* Decade Hours. One stylesheet; tokens first. Dark only, copper accent, phone first. */
:root {
  color-scheme: dark;
  --bg: #121315;
  --surface: #1a1c1f;
  --surface-2: #22252a;
  --border: #2e3237;
  --border-strong: #454a51;
  --text: #ececec;
  --text-2: #b3b7bd;
  --accent: #c67b3c;
  --accent-hover: #d68b4c;
  --accent-ink: #160d04;
  --accent-text: #e0a06a;
  --ok: #5cc98a;
  --danger: #ff7b72;
  --r-1: 6px;
  --r-2: 10px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --topbar: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  min-height: 100dvh;
}
[hidden] { display: none !important; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 var(--s-3); font-weight: 600; }
h2 { font-size: 1.15rem; line-height: 1.3; margin: 0 0 var(--s-2); font-weight: 600; }
h1:focus { outline: none; }
p { margin: 0 0 var(--s-4); }
a { color: var(--accent-text); }
.muted { color: var(--text-2); }
.small { font-size: 0.875rem; }
.error { color: var(--danger); }
.error:empty { display: none; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; font-weight: 600; color: var(--accent-text); margin-bottom: var(--s-2); }
.pad { padding: var(--s-5) var(--s-4); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-4); z-index: 100; }
.skip:focus { left: var(--s-2); top: var(--s-2); }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--s-4);
  min-height: var(--topbar);
  padding: var(--s-2) max(var(--s-4), env(safe-area-inset-right)) var(--s-2) max(var(--s-4), env(safe-area-inset-left));
  padding-top: max(var(--s-2), env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { color: var(--text); text-decoration: none; font-weight: 600; letter-spacing: 0.01em; }
.brand span { color: var(--accent-text); }
.topbar nav { display: flex; gap: var(--s-1); flex: 1; }
.topbar nav a { color: var(--text-2); text-decoration: none; padding: var(--s-2) var(--s-3); border-radius: var(--r-1); min-height: 40px; display: inline-flex; align-items: center; }
.topbar nav a:hover { color: var(--text); background: var(--surface-2); }
.topbar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.who { display: flex; align-items: center; gap: var(--s-3); margin-left: auto; }
.who-name { color: var(--text-2); font-size: 0.9rem; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Page */
main { max-width: 960px; margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7); }
main:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-2); padding: var(--s-5); margin-bottom: var(--s-4); }
.card.flush { padding: 0; overflow: hidden; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-2); }
.page-head h1 { margin-bottom: var(--s-1); }
.page-head p { margin: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s-2); }
.stack > label { margin-top: var(--s-2); font-size: 0.9rem; font-weight: 500; }
.row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: var(--s-3); }

/* Controls: at least 44px tall so they are easy to hit on a phone */
input, select {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-1);
  padding: 10px var(--s-3);
  min-height: 44px; width: 100%;
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
.check { display: flex; align-items: center; gap: var(--s-3); font-weight: 400; min-height: 44px; }
.btn {
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: var(--s-2) var(--s-4);
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-1);
}
.btn:hover { border-color: var(--text-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.quiet:hover { color: var(--text); background: var(--surface-2); }
.btn.small { min-height: 36px; padding: var(--s-1) var(--s-3); font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: default; }
.link { font: inherit; color: var(--accent-text); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.login .stack { margin-top: var(--s-4); }
.login .btn.primary { margin-top: var(--s-3); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody th { font-weight: 500; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tr.off th, tr.off td { color: var(--text-2); }
td.actions { text-align: right; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); }
.status.on::before { background: var(--ok); }

/* On a phone the people table becomes a list of cards. */
@media (max-width: 640px) {
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .table-wrap tr { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap th, .table-wrap td { padding: 2px 0; border: 0; }
  .table-wrap tbody th { font-size: 1.05rem; }
  .table-wrap td.actions { text-align: left; padding-top: var(--s-2); }
  .who-name { display: none; }
  .narrow { margin-top: var(--s-4); }
}

/* Dialog */
dialog {
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--r-2);
  padding: var(--s-5); width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

/* Toasts */
.toasts { position: fixed; left: 0; right: 0; bottom: max(var(--s-4), env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); pointer-events: none; z-index: 50; padding: 0 var(--s-4); }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--r-1); padding: var(--s-3) var(--s-4); max-width: 480px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }
.toast.error { border-color: var(--danger); }

@media (prefers-reduced-motion: no-preference) {
  .btn, .topbar nav a { transition: background-color 120ms, border-color 120ms, color 120ms; }
}

/* Layout helpers */
.split { display: grid; gap: var(--s-4); grid-template-columns: 1fr; align-items: start; }
@media (min-width: 860px) { .split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } }
.grid-2 { display: grid; gap: var(--s-3); grid-template-columns: 1fr 1fr; }
.grid-2 > .stack > label { margin-top: var(--s-2); }
.filters { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: var(--s-4); }
.filters .stack > label { margin-top: 0; }
textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--r-1); padding: 10px var(--s-3); width: 100%; resize: vertical; }
details { border-top: 1px solid var(--border); padding-top: var(--s-2); margin-top: var(--s-2); }
details > summary { cursor: pointer; color: var(--text-2); min-height: 36px; display: flex; align-items: center; }
details[open] > summary { color: var(--text); }
details > label { display: block; margin: var(--s-2) 0; font-size: 0.9rem; font-weight: 500; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); font-weight: 600; margin: 0; padding: var(--s-3) var(--s-4); background: var(--surface-2); }
.big { font-size: 2rem; font-weight: 600; line-height: 1.1; margin-bottom: var(--s-2); font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.warn { color: var(--accent-text); }
.plain { list-style: none; padding: 0; margin: 0 0 var(--s-3); color: var(--text-2); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(255, 123, 114, 0.12); }

/* A person's own entries, grouped by day */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-4); padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
.day:last-child .entry:last-child { border-bottom: 0; }
.entry-project { font-weight: 500; overflow-wrap: anywhere; }
.entry-notes { color: var(--text-2); font-size: 0.9rem; margin-top: var(--s-1); white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-amounts { text-align: right; font-variant-numeric: tabular-nums; }
.entry-hours { font-weight: 600; }
.entry-actions { grid-column: 1 / -1; display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-1); }

/* A small set of choices where one is on */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-1); overflow: hidden; }
.segmented button { font: inherit; color: var(--text-2); background: transparent; border: 0; padding: var(--s-2) var(--s-3); min-height: 40px; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.on { background: var(--surface-2); color: var(--text); }

@media (max-width: 640px) {
  /* On a phone each cell of a wide table says what it is. */
  .table-wrap td[data-label]::before { content: attr(data-label) ": "; color: var(--text-2); }
  .table-wrap td.num { text-align: left; }
  .grid-2 { grid-template-columns: 1fr; }
  .page-head .segmented { width: 100%; }
  .page-head .segmented button { flex: 1; }
}

/* More room for dialogs that hold a table */
dialog.wide-dialog { width: min(760px, calc(100vw - 32px)); }
tr.total th, tr.total td { border-top: 2px solid var(--border-strong); font-weight: 600; background: var(--surface-2); }
.label { font-size: 0.9rem; font-weight: 500; }
.topbar nav { overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; }
@media (max-width: 860px) {
  /* With every admin page in the bar, the links get a row of their own that scrolls sideways. */
  .topbar nav { order: 3; flex-basis: 100%; }
}

/* Shown until the old hours log has been imported and the team has moved over. */
.practice { margin: 0; padding: var(--s-2) var(--s-4); background: #3a2a14; color: #f3d2ae; border-bottom: 1px solid var(--accent); font-size: 0.9rem; text-align: center; }

/* On a touch screen even the small buttons are a full finger tall. */
@media (pointer: coarse) { .btn.small { min-height: 44px; } }
