/* Dark only: there is no light theme to switch to, so no theming layer.

   A cool neutral base with one accent. Status is carried by a tinted row and
   a dot rather than a saturated block, so a screen of entries reads as a list
   first and a traffic light second. */
:root {
  --bg: #0c0e12;
  --surface: #14171d;
  --surface-hi: #1a1e26;
  --surface-hover: #1f242d;
  --border: #242932;
  --border-hi: #323a47;

  --text: #e8eaee;
  --text-dim: #98a1b0;
  --text-faint: #6b7483;

  --accent: #5b8def;
  --accent-hi: #7aa5ff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --accent-ring: rgba(91, 141, 239, 0.28);

  --ok: #40b27f;
  --ok-soft: rgba(64, 178, 127, 0.10);
  --warn: #e0674f;
  --warn-soft: rgba(224, 103, 79, 0.10);
  --danger: #b34a44;

  /* Native controls — the select popup, the date picker, scrollbars — are
     drawn by the browser, not the page. This is the only thing that makes
     them dark; styling the element does not reach them. */
  color-scheme: dark;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* --- top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.menu { position: relative; }
.menu summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ⌄"; }
.menu summary:hover { background: var(--surface-hi); color: var(--text); }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 200px; padding: 5px;
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.menu-items button {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; cursor: pointer;
}
.menu-items button:hover { background: var(--surface-hover); }

main { padding: 20px; }

/* --- flashes --- */
.flashes { list-style: none; margin: 0 0 16px; padding: 0; }
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid transparent;
}
.flash.error { background: var(--warn-soft); border-color: var(--warn); color: #ffd9d0; }
.flash.ok { background: var(--ok-soft); border-color: var(--ok); color: #cdf0e0; }

/* --- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card-head {
  display: flex;
  align-items: center;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.card-body { padding: 14px 16px; }
.hint { color: var(--text-dim); margin: 0 0 12px; font-size: 13px; }
.empty { color: var(--text-faint); margin: 0; }
.back { margin: 0 0 14px; font-size: 13px; }

/* --- form controls --- */
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface-hi);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color .12s, box-shadow .12s, background-color .12s;
}
input::placeholder { color: var(--text-faint); }
select option { background: var(--surface-hi); color: var(--text); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
input[type=checkbox] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  cursor: pointer;
}
label { display: block; margin-bottom: 12px; color: var(--text-dim); font-size: 13px; }
label input { margin-top: 5px; color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-hi); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.subtle { background: transparent; }
.btn.danger { background: transparent; border-color: transparent; color: var(--warn); }
.btn.danger:hover { background: var(--warn-soft); border-color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* Work / Lunch / End: three peers, so one control rather than three buttons. */
.segmented { display: inline-flex; }
.segmented button {
  padding: 7px 15px;
  border: 1px solid var(--border-hi);
  border-right-width: 0;
  background: var(--surface-hi);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s;
}
.segmented button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segmented button:last-child { border-right-width: 1px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.segmented button:hover { background: var(--surface-hover); }
.segmented button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); position: relative; }

/* --- dashboard --- */
.dashboard {
  display: grid;
  /* The left column takes the width the page used to leave empty either
     side of it, up to a quarter of a wide window. */
  grid-template-columns: minmax(310px, 25%) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.side { display: grid; gap: 18px; }
.stack { display: grid; gap: 18px; }
@media (max-width: 980px) {
  .dashboard { grid-template-columns: 1fr; }
}

/* --- colleagues --- */
.colleagues { list-style: none; margin: 0; padding: 6px; }
.colleague {
  display: grid;
  grid-template-columns: auto 5.5em 3.6em minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.colleague .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.colleague.working { background: var(--ok-soft); }
.colleague.working .dot { background: var(--ok); }
.colleague.away { background: var(--warn-soft); }
.colleague.away .dot { background: var(--warn); }
.colleague .who { font-weight: 500; }
.colleague .when { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.colleague .what,
.colleague .case { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.colleague .case { justify-self: end; color: var(--text-dim); font-size: 12px; }

/* --- today --- */
.head-total {
  margin-left: auto;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.totals { display: grid; gap: 2px; }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 0; }
.total span:first-child { color: var(--text-dim); font-size: 13px; }
.total span:last-child { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 500; }

/* --- day overview --- */
.overview-case {
  display: grid;
  grid-template-columns: minmax(0, 10.5em) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.overview-case:first-child { padding-top: 0; }
.overview-case:last-child { border-bottom: 0; padding-bottom: 0; }
.overview-case-head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.case-link { font-weight: 500; font-size: 13px; }
.overview-lines { list-style: none; margin: 0; padding: 0; }
.overview-lines li { margin: 0 0 2px; }
.line-time {
  display: inline-block;
  min-width: 3.6em;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.copy {
  padding: 1px 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 3px;
  transition: color .12s;
}
.copy:hover { color: var(--accent-hi); }
.copy:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.copy.total { font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.copy.case-name { color: var(--text-dim); font-size: 12px; }
.copy.copied, .copy.copied:hover { color: var(--ok); }

.links { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- the entry grid --- */
.day-nav { gap: 14px; }
.day-steps { display: flex; gap: 2px; }
.day-nav .step {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
}
.day-nav .step:hover { background: var(--surface-hi); color: var(--text); text-decoration: none; }
.day-nav .day-label {
  flex: 1;
  display: flex; align-items: center; gap: 9px;
  font-size: 15px;
}
.badge {
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent-hi);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.day-jump { display: flex; align-items: center; gap: 8px; }
.day-jump .day-picker { margin: 0; }
.day-jump input[type=date] { width: auto; padding: 5px 8px; font-size: 13px; }

.grid-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }

table.entries { width: 100%; border-collapse: collapse; }
table.entries th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}
table.entries td { padding: 3px 8px; vertical-align: middle; }
table.entries tbody tr { border-radius: var(--radius-sm); }
table.entries tbody tr:hover td { background: var(--surface-hi); }
table.entries tbody tr:hover td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
table.entries tbody tr:hover td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.col-case { width: 25em; }
.col-start { width: 7em; }
.col-work { width: 4.2em; text-align: center; }
.col-cont { width: 7em; text-align: center; }
.col-del { width: 5.5em; text-align: center; }
.col-case input.case-number { width: 9.5em; display: inline-block; margin-right: 7px; }
.col-case select.case-picker { width: 13.5em; display: inline-block; }

/* The case picker, once JavaScript has replaced the native select with a
   grid. A native popup is one column drawn by the browser; a long case list
   in one column is a lot of scrolling. */
/* Must out-specify `.col-case select.case-picker`, which sets display:
   inline-block — otherwise the native select stays visible beside the
   replacement and every row shows two dropdowns. */
.col-case select.case-picker.enhanced { display: none; }
.case-combo { position: relative; display: inline-block; width: 13.5em; vertical-align: middle; }
.case-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.entry-row:hover .case-trigger { border-color: var(--border); background: var(--surface-hi); }
.case-trigger:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.case-trigger-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-caret { color: var(--text-faint); flex: none; }

.case-menu {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  width: max(100%, 46em);
  max-width: 80vw;
  padding: 9px;
  background: var(--surface-hi);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.case-menu[hidden] { display: none; }
.case-filter { margin-bottom: 8px; }
.case-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13em, 1fr));
  gap: 2px;
  max-height: 42vh;
  overflow-y: auto;
}
.case-option {
  display: block;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.case-option[hidden] { display: none; }
.case-option:hover, .case-option.active { background: var(--accent-soft); color: var(--accent-hi); }
.case-option-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-option-number {
  display: block;
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Inline editing: fields stay quiet until you reach for them. */
.entry-row input[type=text] {
  background: transparent;
  border-color: transparent;
}
.entry-row:hover input[type=text] { border-color: var(--border); }
.entry-row input[type=text]:focus { background: var(--surface-hi); border-color: var(--accent); }
.entry-row select.case-picker { background: transparent; border-color: transparent; color: var(--text); }
.entry-row:hover select.case-picker { border-color: var(--border); background: var(--surface-hi); }
.entry-row select.case-picker:focus { background: var(--surface-hi); border-color: var(--accent); }
.entry-row .start { font-variant-numeric: tabular-nums; }

.entry-row.draft td { background: var(--accent-soft); }
.entry-row.draft td:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  box-shadow: inset 2px 0 0 var(--accent);
}
.entry-row.draft td:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.entry-row.draft:hover td { background: var(--accent-soft); }

.continue {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .12s, background-color .12s, border-color .12s;
}
.entry-row:hover .continue { color: var(--text-dim); border-color: var(--border); }
.continue:hover { background: var(--accent-soft); color: var(--accent-hi); border-color: var(--accent); }
.continue:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }

/* --- tables on the cases and users pages --- */
table.cases, table.users { width: 100%; border-collapse: collapse; }
table.cases th, table.users th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}
table.cases td, table.users td { padding: 4px 8px; }
table.cases tbody tr:hover td, table.users tbody tr:hover td { background: var(--surface-hi); }
.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.inline { display: inline; margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.centre { text-align: center; }
tr.inactive td { opacity: .5; }
tr.new-row td { padding-top: 12px; }
tr.new-row input { border-style: dashed; }

/* --- dialogs --- */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-width: 340px;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 6, 9, .6); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 16px; font-size: 16px; }
.hours-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 7px;
}
.hours-row input { width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-actions button {
  padding: 7px 14px;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface-hi);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.dialog-actions button:hover { background: var(--surface-hover); }
.dialog-actions button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.dialog-actions button.primary:hover { background: var(--accent-hi); }

/* --- login and setup --- */
.login { max-width: 380px; margin: 10vh auto 0; }
.login .card { box-shadow: var(--shadow); }
.login .card-body { padding: 18px 20px 20px; }
.login .btn { width: 100%; justify-content: center; margin-top: 4px; }

/* Off-screen helper for the clipboard fallback on plain HTTP. */
.clipboard-shuttle { position: fixed; top: -1000px; left: -1000px; }
