:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --brand: #6366f1;
  --brand-2: #818cf8;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 10px;
  color-scheme: dark; /* tell the browser this is a dark UI (fixes form controls / high-contrast) */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1em; margin: 6px 0 0; }
a { color: var(--brand-2); }

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { color: var(--red); border-color: transparent; background: transparent; }
.btn.danger:hover { border-color: var(--red); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  background: var(--panel); padding: 32px; border-radius: 14px;
  width: 340px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 10px; border-radius: 8px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { height: 0; }
.tabs button {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
  white-space: nowrap; flex: 0 0 auto;
}
.tabs button:hover { color: var(--text); background: var(--panel-2); }
.tabs button.active { color: #fff; background: var(--brand); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Timer bar */
.timerbar {
  display: flex; flex-direction: column; gap: 12px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); background: var(--brand); }
.timer-project { min-width: 200px; }
.timer-task { min-width: 150px; }
.timer-desc { width: 100%; resize: vertical; min-height: 52px; font-family: inherit; }
.timer-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
/* task multi-select checklist in the project modal */
.task-checklist { display: flex; flex-wrap: wrap; gap: 8px 14px; max-height: 160px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.task-checklist label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; white-space: nowrap; }
.task-checklist .empty { color: var(--muted); }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; min-width: 96px; text-align: right; }
.clock.running { color: var(--green); }
.clock.paused { color: var(--amber); }
.clock.idle { color: var(--muted); }

/* Live timers — five fixed slots, each may run at once */
.timers-wrap { display: flex; flex-direction: column; gap: 10px; }
.timer-slot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
}
.timer-slot.is-running { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.timer-slot.is-paused  { border-color: var(--amber); box-shadow: inset 3px 0 0 var(--amber); }
.slot-num { color: var(--muted); font-weight: 700; min-width: 26px; }
.timer-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.timer-controls .timer-desc-in { flex: 1; min-width: 150px; }
.timer-info { flex: 1; min-width: 160px; }
.timer-title { font-weight: 600; }
.timer-note { font-size: 13px; margin-top: 2px; word-break: break-word; }
.timer-add { margin-top: 2px; }
.timer-add .btn { border-style: dashed; color: var(--muted); }
.timer-add .btn:hover { color: var(--text); }
.btn.link-btn { background: transparent; border: none; color: var(--muted); padding: 5px 6px; text-decoration: underline; }
.btn.link-btn:hover { color: var(--text); }
.nav-arrows { display: inline-flex; gap: 4px; }
.nav-group { display: inline-flex; gap: 6px; align-items: center; }
tr.total-row td { border-top: 2px solid var(--line); }
.inline-err { color: var(--red); font-size: 13px; font-weight: 600; align-self: center; }
.inline-err[hidden] { display: none !important; }
.inline-err.row-err { display: block; max-width: 240px; margin: 4px 0 0 auto; white-space: normal; text-align: right; line-height: 1.3; }
.btn.small.arrow { padding: 5px 9px; font-weight: 700; line-height: 1; }
.btn.arrow:disabled { opacity: .4; cursor: default; }
.viewing-note { margin: 0 0 10px; font-size: 13px; }

/* Main / layout */
.main { padding: 24px; max-width: 1200px; margin: 0 auto; }
h2.section { margin: 0 0 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

/* Cards / grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .v { font-size: 26px; font-weight: 700; margin-top: 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: var(--panel-2); }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable.active { color: var(--brand-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Bar chart */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; }
.bar-label { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--panel-2); border-radius: 6px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.bill { background: rgba(16,185,129,.15); color: var(--green); }
.badge.nonbill { background: rgba(148,163,184,.15); color: var(--muted); }
.badge.role { background: rgba(99,102,241,.18); color: var(--brand-2); }
.badge.warn { background: rgba(245,158,11,.18); color: var(--amber); }
tr.flagged td { background: rgba(245,158,11,.07); }
tr.flagged:hover td { background: rgba(245,158,11,.13); }

/* Running indicator in the entries list — yellow, blinking */
.running-flash { color: var(--amber); font-weight: 600; animation: blink 1s ease-in-out infinite; }
/* Paused indicator in the entries list — orange */
.paused-ind { color: #f97316; font-weight: 600; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }

/* Stale-timer banner */
.stale-banner { border-color: var(--amber); background: rgba(245,158,11,.06); }
.stale-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.stale-row:last-child { padding-bottom: 0; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 420px; max-width: 92vw; max-height: 90vh; overflow-y: auto; }
.modal.modal-wide { width: 780px; }

/* Two-list task picker (project dialog) */
.task-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .task-picker { grid-template-columns: 1fr; } }
.task-col { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); display: flex; flex-direction: column; min-width: 0; }
.task-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--line); }
.task-filter { display: block; width: calc(100% - 20px); margin: 8px 10px 0; background: var(--panel); color: var(--text); }
.task-col-list { max-height: 320px; overflow-y: auto; padding: 6px; background: var(--panel-2); }
.task-pick { display: block; color: var(--text); background: transparent; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-pick:hover { background: var(--brand); color: #fff; }
.task-pick-x { color: var(--red); font-weight: 700; }
.task-pick-plus { color: var(--green); font-weight: 700; }
.task-pick:hover .task-pick-x, .task-pick:hover .task-pick-plus { color: #fff; }
.task-col-empty { padding: 12px 10px; color: var(--muted); font-size: 13px; }
.modal h3 { margin: 0 0 16px; }
.modal .row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.modal .row label { color: var(--muted); font-size: 13px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); padding: 12px 20px; border-radius: 10px;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

.actions-inline { display: flex; gap: 6px; }
input.inline-mins { width: 70px; }

/* Searchable combobox (client / project pickers) */
.combo { position: relative; display: inline-block; }
.combo > input { width: 100%; padding-right: 26px; }
.combo-caret { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; pointer-events: auto; cursor: pointer; }
.combo-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.45);
}
.combo-opt { padding: 8px 10px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-opt:hover, .combo-opt.active { background: var(--brand); color: #fff; }
.combo-empty { padding: 8px 10px; color: var(--muted); }
.combo-client { min-width: 170px; }
.combo-project { min-width: 200px; }
