:root {
  --bg: #000;
  --panel: #0a0a0a;
  --panel-2: #111;
  --line: #1e1e1e;
  --line-hi: #333;
  --text: #f2f2f2;
  --dim: #8c8c8c;
  --faint: #555;
  --bar: #f2f2f2;
  --bar-2: #6b6b6b;
  --bad: #ff5d5d;
  --warn: #ffb547;
  --good: #7dffa3;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.good { color: var(--good); }
.nowrap { white-space: nowrap; }

/* -- login ---------------------------------------------------------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
}
.login-card {
  width: 100%; max-width: 360px; border: 1px solid var(--line); border-radius: 14px;
  padding: 32px 28px; background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: .02em; font-size: 18px; }
.brand span { color: var(--dim); font-weight: 500; }
.login-card .brand { margin-bottom: 4px; }
.login-card p { margin: 0 0 22px; color: var(--dim); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line-hi); border-radius: 8px;
  padding: 9px 11px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--text); }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: .4em; text-align: center; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-hi); background: transparent; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
a.btn { text-decoration: none; }
.btn.primary { background: var(--text); color: #000; border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--bad); border-color: #4a1f1f; }
.btn.danger:hover { border-color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: default; }
.wide { width: 100%; }
.error { color: var(--bad); min-height: 20px; margin-top: 10px; font-size: 13px; }

/* -- shell ---------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 5; background: rgba(0, 0, 0, .92);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a {
  text-decoration: none; color: var(--dim); padding: 6px 10px; border-radius: 7px;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); background: var(--panel-2); }
.page { max-width: 1200px; margin: 0 auto; padding: 22px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 13px; margin: 0 0 12px; font-weight: 600; color: var(--dim);
     text-transform: uppercase; letter-spacing: .09em; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
        flex-wrap: wrap; margin-bottom: 18px; }
.head p { margin: 0; color: var(--dim); }

.grid { display: grid; gap: 14px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .cols-4, .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.stat .label { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.section { margin-top: 14px; }

.seg { display: inline-flex; border: 1px solid var(--line-hi); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 6px 12px; cursor: pointer; color: var(--dim); }
.seg button.on { background: var(--text); color: #000; }

/* charts */
.chart { width: 100%; height: 150px; display: block; }
.chart rect.b { fill: var(--bar); }
.chart rect.b.alt { fill: var(--bar-2); }
.chart rect.b:hover { fill: #fff; }
.chart text { fill: var(--faint); font: 10px var(--mono); }
.chart line { stroke: var(--line); }
.legend { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-top: 6px; }

.rows { display: grid; gap: 8px; }
.row-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 13px; }
.row-bar .track { grid-column: 1 / -1; height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; }
.row-bar .fill { height: 100%; background: var(--bar); }

.meter { display: grid; gap: 4px; min-width: 120px; }
.meter .track { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--bar); }
.meter .fill.warn { background: var(--warn); }
.meter .fill.bad { background: var(--bad); }
.meter .cap { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
     background: var(--panel); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel); }
.tag { display: inline-block; border: 1px solid var(--line-hi); border-radius: 999px; padding: 1px 8px;
       font-size: 11px; color: var(--dim); }
.tag.bad { color: var(--bad); border-color: #4a1f1f; }
.tag.good { color: var(--good); border-color: #1f4a2c; }
.tag.warn { color: var(--warn); border-color: #4a3a1f; }

/* dictations */
.dict { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--panel); }
.dict + .dict { margin-top: 8px; }
.dict-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.dict-text { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dict-text.clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 200px; flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions input, .actions select { width: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.codes { font-family: var(--mono); font-size: 18px; display: grid; gap: 6px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #000;
  padding: 8px 16px; border-radius: 8px; font-weight: 600; z-index: 20;
}
.empty { color: var(--dim); padding: 22px; text-align: center; }
.plan-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }

/* -- confirm dialog: "yes" wakes up after 3 seconds ------------------------------ */
.modal-back {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .74); animation: fade-in .12s ease-out;
}
.modal {
  width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line-hi);
  border-radius: 14px; padding: 22px 22px 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, .7);
}
.modal h3 { margin: 0 0 12px; font-size: 17px; font-weight: 650; line-height: 1.35; }
.modal p { margin: 0 0 20px; color: #bdbdbd; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.fuse { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.fuse > div { height: 100%; background: var(--text); transform-origin: left center;
              animation: fuse 3s linear forwards; }
.modal.danger .fuse > div { background: var(--bad); }
.btn.danger-fill { background: var(--bad); color: #000; border-color: var(--bad); font-weight: 600; }
.btn.danger-fill[disabled], .btn.primary[disabled] { opacity: .5; }
@keyframes fuse { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .fuse > div, .modal-back { animation: none; } }

/* -- user page: who, with the note next to it ---------------------------------------- */
.user-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 14px; align-items: stretch; }
@media (max-width: 800px) { .user-head { grid-template-columns: 1fr; } }
.who h1 { margin-bottom: 4px; overflow-wrap: anywhere; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.note-card { display: flex; flex-direction: column; }
.note-input {
  flex: 1; min-height: 120px; resize: vertical; background: #050505; border-color: var(--line);
  font-size: 15px; line-height: 1.6; padding: 12px 14px; color: var(--text); white-space: pre-wrap;
}
.note-input::placeholder { color: var(--faint); }
.note-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: 12px; }
.note-foot .btn { margin-left: auto; }
.note-state { color: var(--dim); }
.note-state.warn { color: var(--warn); }
.note-state.bad { color: var(--bad); }

/* management, one row per kind of action */
.mgmt { display: grid; gap: 12px; }
.mgmt-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: center; }
.mgmt-label { color: var(--dim); font-size: 13px; }
@media (max-width: 600px) { .mgmt-row { grid-template-columns: 1fr; gap: 6px; } }

/* folding the dictations */
.collapse-toggle {
  display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 4px 0;
  cursor: pointer; font-size: 13px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text);
}
.collapse-toggle:hover { color: #fff; }
.collapse-toggle .chev { display: inline-block; transition: transform .15s ease; color: var(--dim); }
.collapse-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }

/* users table: the note column */
.note-cell { max-width: 280px; }
.note-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
             white-space: pre-wrap; color: #cfcfcf; line-height: 1.45; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
