/* SoftTrack — one stylesheet, light and dark via prefers-color-scheme */
:root {
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f0f2f6; --text: #1d2330; --muted: #677087;
  --border: #dde1ea; --accent: #3b6cf6; --accent-text: #ffffff; --danger: #d6344a; --ok: #1f8f55; --warn: #b7791f;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c; --surface: #1b1f29; --surface-2: #242a36; --text: #e6e9f0; --muted: #98a1b5;
    --border: #2e3544; --accent: #6b93ff; --accent-text: #0d1220; --danger: #ff6b7f; --ok: #4cc88a; --warn: #e5b24f;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.container { max-width: 1040px; margin: 0 auto; padding: 1rem 16px 4rem; }

.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .6rem 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: .4rem; }
.logo { color: var(--accent); font-size: 1.3rem; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: .35rem .6rem; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--surface-2); }
.topbar nav form { margin-left: auto; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); border-radius: 8px; padding: .45rem .8rem; font: inherit;
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
.btn.icon { width: 2.6rem; height: 2.6rem; padding: 0; border-radius: 50%; font-size: 1rem; }
.btn.icon.small { width: 1.9rem; height: 1.9rem; font-size: .75rem; }
.btn.icon.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.danger-text { color: var(--danger); }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }
button.link:hover { color: var(--text); }
.btn:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], input[type=password], input[type=date], input[type=time], select, .token {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .6rem; min-width: 0; }
input[type=color] { width: 2.4rem; height: 2.2rem; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
label > input, label > select { color: var(--text); font-size: 15px; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .6rem; }
.grow { flex: 1; }
.token { width: 100%; font-family: ui-monospace, monospace; }
textarea { font: .8rem ui-monospace, monospace; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .45rem .6rem; width: 100%; resize: vertical; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .9rem .8rem; display: flex; flex-direction: column; gap: .7rem; min-width: 0; }
legend { padding: 0 .3rem; font-weight: 600; }
fieldset p { margin: 0; }
fieldset details summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
fieldset details[open] { display: flex; flex-direction: column; gap: .6rem; }
input[type=file] { font: inherit; color: var(--text); max-width: 100%; }
[hidden] { display: none !important; }

.flash { padding: .6rem .8rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.flash.error { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.flash.notice { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.flash p { margin: 0 0 .5rem; }

/* timer bar */
.timer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem;
  margin-bottom: 1rem; box-shadow: var(--shadow); display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; }
.timer.running { border-color: var(--accent); }
.timer.paused { flex-direction: column; align-items: stretch; }
.timer-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; flex: 1; width: 100%; }
.timer-form .ac { flex: 1 1 260px; }
.timer-info { flex: 1; min-width: 0; }
.timer-desc { font-weight: 600; overflow-wrap: anywhere; }
.timer-meta { color: var(--muted); font-size: .9rem; display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.elapsed { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 600; min-width: 6ch; text-align: right; }
.paused-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .2rem .2rem .6rem;
  border-bottom: 1px dashed var(--border); }
.paused-label { color: var(--warn); font-weight: 600; }

/* autocomplete */
.ac { position: relative; display: flex; }
.ac input { width: 100%; }
.suggest { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; }
.suggest ul { list-style: none; margin: 0; padding: .3rem 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 22rem; overflow: auto; }
.suggest ul:empty { display: none; }
.suggest.closed { display: none; }
.suggest-head { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .35rem .8rem .15rem; }
.suggest-head.err { color: var(--danger); text-transform: none; }
.suggest-item { display: flex; gap: .5rem; align-items: center; padding: .4rem .8rem; cursor: pointer; }
.suggest-item:hover, .suggest-item.active { background: var(--surface-2); }
.suggest-item .ref { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--accent); white-space: nowrap; }
.suggest-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .project { font-size: .85rem; color: var(--muted); white-space: nowrap; }

.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: .1rem .55rem; font-size: .8rem; color: var(--text); text-decoration: none;
  max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chip a { color: var(--accent); text-decoration: none; font-family: ui-monospace, monospace; }
.chip-clear { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0 0 0 .2rem; }
.issue-slot:empty { display: none; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }

/* entry list */
.week-nav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 1.2rem 0 .8rem; }
.week-total { margin-left: auto; color: var(--muted); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--border);
  padding-bottom: .4rem; margin-bottom: .2rem; }
.day-head h2 { margin: 0; }
.dur { font-variant-numeric: tabular-nums; white-space: nowrap; }
.task > summary { display: flex; gap: .6rem; align-items: center; padding: .45rem .1rem; cursor: pointer; list-style: none;
  border-bottom: 1px solid var(--surface-2); flex-wrap: wrap; }
.task > summary::-webkit-details-marker { display: none; }
.task .desc { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.task .project { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.count { font-size: .75rem; min-width: 1.5rem; height: 1.5rem; border-radius: 6px; background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.task-buttons { display: inline-flex; gap: .3rem; }
.task-entries { padding: .2rem 0 .5rem 2.1rem; }
.entry-row { display: flex; gap: .7rem; align-items: center; padding: .3rem 0; font-size: .92rem; flex-wrap: wrap; }
.entry-row .range { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 7.5rem; }
.entry-row .desc { flex: 1 1 160px; min-width: 0; }
.entry-row .actions { display: inline-flex; gap: .3rem; }
.entry-row.running .range { color: var(--accent); }
.entry-row.editing { flex-direction: column; align-items: stretch; background: var(--surface-2); padding: .7rem; border-radius: 8px; }
.entry-row.editing .row { margin: 0; }
.entry-row.editing .ac { flex: 1 1 240px; }
.badge { font-size: .72rem; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 0 .45rem; white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.err { color: var(--danger); border-color: var(--danger); }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.manual summary { cursor: pointer; color: var(--muted); }
.manual[open] summary { margin-bottom: .8rem; }
.manual .ac { flex: 1 1 260px; }

/* tables & reports */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.archived td { color: var(--muted); }
.table td.actions { white-space: nowrap; text-align: right; }
.table tfoot th { color: var(--text); font-size: .95rem; }
.report tr.level-0 td { font-weight: 600; }
.report .dim { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-right: .2rem; }
.report-head { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }
.report-head h2 { margin: 0; }
.downloads { margin-left: auto; display: flex; gap: .4rem; flex-wrap: wrap; }
.presets { display: flex; gap: .3rem; flex-wrap: wrap; align-self: flex-end; }
select[multiple] { min-width: 12rem; }

@media (max-width: 640px) {
  .elapsed { font-size: 1.15rem; }
  .task-entries { padding-left: .5rem; }
  .entry-row .range { min-width: 0; }
  .week-total { margin-left: 0; width: 100%; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}
