:root {
  color-scheme: light dark;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #14181f;
  --muted: #5b6270;
  --accent: #0aa8a3;
  --accent-text: #ffffff;
  --accent-2: #ff6b4a;
  --danger: #d64545;
  --warn-bg: #fff7e6;
  --warn-border: #b8860b;
  --border: #dee2e8;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e13;
    --card: #12161d;
    --text: #e7eaf0;
    --muted: #8b92a3;
    --accent: #2dd4cb;
    --accent-text: #08201e;
    --accent-2: #ff8566;
    --danger: #f0685f;
    --warn-bg: #2a2210;
    --warn-border: #e0a93c;
    --border: #232936;
  }
}

/* Manual light/dark toggle (theme.js) overrides the OS preference above,
   in either direction, once the visitor picks one explicitly. */
:root[data-theme="dark"] {
  --bg: #0b0e13;
  --card: #12161d;
  --text: #e7eaf0;
  --muted: #8b92a3;
  --accent: #2dd4cb;
  --accent-text: #08201e;
  --accent-2: #ff8566;
  --danger: #f0685f;
  --warn-bg: #2a2210;
  --warn-border: #e0a93c;
  --border: #232936;
}

:root[data-theme="light"] {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #14181f;
  --muted: #5b6270;
  --accent: #0aa8a3;
  --accent-text: #ffffff;
  --accent-2: #ff6b4a;
  --danger: #d64545;
  --warn-bg: #fff7e6;
  --warn-border: #b8860b;
  --border: #dee2e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
}

.wrap {
  width: 100%;
  max-width: 480px;
  /* body is a flex container; without this, a flex item holding a CSS grid
     with minmax() tracks (the lead board) reports its intrinsic content
     width as the default min-width instead of shrinking, forcing the page
     wider than the viewport and causing horizontal scroll. */
  min-width: 0;
}

.wrap.wide {
  max-width: 1200px;
}

.wrap.extra-wide {
  max-width: 1600px;
}

.status-pill.sent {
  background: #dbeafe;
  color: #1e40af;
}
@media (prefers-color-scheme: dark) {
  .status-pill.sent { background: #1e2f4d; color: #60a5fa; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}

button {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 400;
  margin-top: 8px;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -6px 0 12px;
}

.status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pill.in {
  background: #dcfce7;
  color: #166534;
}
.status-pill.out {
  background: #f1f2f4;
  color: var(--muted);
}
@media (prefers-color-scheme: dark) {
  .status-pill.in { background: #14351f; color: #4ade80; }
  .status-pill.out { background: #2a2d33; color: var(--muted); }
}

.elapsed {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 20px;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history li:last-child { border-bottom: none; }

.muted { color: var(--muted); }

.reminder-banner {
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: none;
}

.reminder-banner.show { display: block; }

.reminder-banner strong { display: block; margin-bottom: 4px; }

.top-link {
  text-align: center;
  margin-top: 8px;
  font-size: 0.85rem;
}

.top-link a { color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.tiles {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.tile {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.15s;
}

.tile:hover {
  border-color: var(--accent);
}

.tile-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.tile-desc {
  font-size: 0.85rem;
  color: var(--muted);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.inline-form input,
.inline-form select {
  width: auto;
  flex: 1 1 140px;
  margin-bottom: 0;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.small-btn {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

.small-btn.danger {
  background: var(--danger);
}

.table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.table-scroll table {
  width: 100%;
}

.table-scroll td,
.table-scroll th {
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-edit-input {
  width: auto;
  margin-bottom: 0;
  padding: 4px 6px;
  font-size: 0.82rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
  padding: 10px 6px;
  font-size: 0.85rem;
  background: var(--bg);
}

.detail-grid a {
  color: var(--accent);
  word-break: break-all;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--bg);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 2px;
}

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.week-nav .small-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  margin-top: 0;
}

.week-range-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.week-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 20px;
}

.day-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 2px;
  text-align: center;
}

.day-cell.today {
  border: 2px solid var(--accent);
}

.day-label {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.day-date {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.day-hours {
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legal-note {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 20px;
  line-height: 1.4;
}

/* ---- Nexxus brand: logo lockup + page footer, shared by every screen ---- */

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.brand-mark { flex: none; display: block; }

.brand-word {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.3rem;
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 6px;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.brand-header .brand-word { font-size: 0.95rem; }

.app-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.7;
  line-height: 1.7;
  margin-top: 24px;
}

/* Light/dark toggle — injected by theme.js, present on every screen */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }

.idle-warning-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 16px;
}

.idle-warning-box {
  background: var(--card);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 22px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.idle-warning-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.idle-warning-text {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.idle-warning-countdown {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--warn-border);
}

.idle-warning-btn {
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
