:root {
  --bg: #F2F5F7;
  --surface: #FFFFFF;
  --ink: #152027;
  --muted: #5C6B73;
  --line: #DCE4E8;
  --primary: #0E7C9B;
  --primary-ink: #095d75;
  --rude: #C0392B;
  --good: #2E8B57;
  --normal: #7A8A92;
  --alert-bg: #FCEFEC;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(21, 32, 39, .06);
  --mono: "IBM Plex Sans", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
/* The hidden attribute must always win over element display rules (e.g. .login's
   display:grid), otherwise toggling [hidden] in JS does not actually hide the node. */
[hidden] { display: none !important; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.login__title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.login__sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login__err { color: var(--rude); font-size: 14px; min-height: 20px; margin: 12px 0 0; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.input, .field input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
}
.input:focus, .field input:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 500;
  border-radius: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--ink);
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-ink); }
.btn--ghost { border-color: var(--line); background: var(--surface); }
.btn--ghost:hover { border-color: var(--muted); }
.btn--block { width: 100%; margin-top: 8px; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 60px;
  position: sticky; top: 0; z-index: 10;
}
.topbar__brand { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; margin-right: auto; height: 100%; }
.tab {
  font: inherit; font-weight: 500;
  border: none; background: none; cursor: pointer;
  color: var(--muted);
  padding: 0 14px; height: 100%;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--primary); }
.tab__count {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--rude); color: #fff;
  font-size: 11px; font-weight: 600; vertical-align: middle;
}

.view { max-width: 1040px; margin: 0 auto; padding: 24px; }

/* ---------- Summary strip ---------- */
.summary { display: flex; gap: 32px; margin-bottom: 20px; }
.summary__item { display: flex; align-items: baseline; gap: 8px; }
.summary__num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.summary__lbl { color: var(--muted); font-size: 14px; }
.summary__item--alert .summary__num { color: var(--rude); }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters .input { width: auto; flex: 0 1 auto; }
#fQ { flex: 1 1 180px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }

/* ---------- Table ---------- */
.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: grid;
  grid-template-columns: 1.4fr .8fr 1.2fr 1fr auto;
  gap: 16px; align-items: center;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.row:first-child { border-top: none; }
.row:hover { background: #F7FAFB; }
.row__driver { font-weight: 500; }
.row__meta { color: var(--muted); font-size: 14px; }
.row__num { font-variant-numeric: tabular-nums; }
.row__time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.dir { font-size: 13px; color: var(--muted); }
.dir--in::before { content: "\2193 "; color: var(--good); }
.dir--out::before { content: "\2191 "; color: var(--primary); }

.pill {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface);
}
.pill--rude { color: #fff; background: var(--rude); border-color: var(--rude); }
.pill--good { color: #fff; background: var(--good); border-color: var(--good); }
.pill--normal { color: var(--ink); background: #EEF1F3; border-color: var(--line); }
.pill--none { color: var(--muted); }
.flag-dot { color: var(--rude); margin-left: 6px; }

/* ---------- Row expand ---------- */
.detail { padding: 16px 18px 20px; border-top: 1px solid var(--line); background: #FBFCFD; }
.detail audio { width: 100%; margin-bottom: 14px; }
.rate { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.rate__label { color: var(--muted); font-size: 14px; margin-right: 4px; }
.rbtn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 13px; }
.rbtn.is-on[data-r="rude"] { background: var(--rude); color: #fff; border-color: var(--rude); }
.rbtn.is-on[data-r="good"] { background: var(--good); color: #fff; border-color: var(--good); }
.rbtn.is-on[data-r="normal"] { background: #EEF1F3; }
.rbtn--flag.is-on { background: var(--alert-bg); border-color: var(--rude); color: var(--rude); }
.note-row { display: flex; gap: 8px; align-items: flex-start; }
.note-row textarea { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 8px 11px; resize: vertical; min-height: 40px; }

.hint { color: var(--muted); font-size: 14px; max-width: 70ch; margin: 0 0 16px; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.token { font-family: ui-monospace, "IBM Plex Sans", monospace; background: #EEF1F3; padding: 2px 7px; border-radius: 4px; font-size: 13px; }

@media (max-width: 680px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .topbar__brand { display: none; }
  .view { padding: 16px; }
  .row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .row__time { text-align: left; }
}
