:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #1b2430;
  --muted: #5d6b7a;
  --border: #d9e0e7;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --accent-soft: #e3eef6;
  --danger: #b3261e;
  --ok: #1e7a46;
  --mic: #c2410c;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #18202a;
    --text: #e6edf3;
    --muted: #93a1b0;
    --border: #2b3643;
    --accent: #5aa9de;
    --accent-text: #0b1620;
    --accent-soft: #1d3446;
    --danger: #f2827a;
    --ok: #6ccf95;
    --mic: #fb923c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
}
.top h1 { font-size: 1.15rem; margin: 0 0 8px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent;
  color: var(--muted); font: inherit; font-weight: 600; padding: 8px 10px; cursor: pointer;
}
.tabs button.active { color: var(--accent); border-color: var(--accent); }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
h2 { font-size: 1rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.lbl { font-weight: 600; display: block; margin-bottom: 6px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; width: 100%;
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.grid .wide { grid-column: 1 / -1; }
.say-row { display: flex; gap: 10px; align-items: stretch; }
.say-row textarea { flex: 1; }
.mic {
  flex: 0 0 64px; border-radius: 50%; width: 64px; height: 64px; align-self: center;
  border: 0; background: var(--mic); color: #fff; cursor: pointer;
  display: grid; place-items: center;
}
.mic.listening { animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--mic) 60%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
button, .button {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 10px 16px; min-height: 44px;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.primary { background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent); }
.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--border); }
.chips { display: flex; gap: 6px; margin-top: 4px; }
.chips button {
  min-height: 32px; padding: 4px 10px; font-size: .85rem;
  background: var(--accent-soft); color: var(--text); border: 0;
}
.hidden { display: none !important; }
.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.seg legend { font-size: .9rem; color: var(--muted); padding: 0; margin-bottom: 4px; }
.seg label { display: block; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-weight: 600; cursor: pointer;
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.via { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--text); }
.file-btn { position: relative; flex-direction: row; color: var(--accent-text); font-size: inherit; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#import-msg ul { margin: 6px 0 0; padding-left: 18px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.err { color: var(--danger); }
.okc { color: var(--ok); }
.pill { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 2px 10px; font-size: .85rem; font-weight: 600; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.entries li:last-child { border-bottom: 0; }
.entries .main { min-width: 0; flex: 1; }
.entries .t { font-weight: 600; overflow-wrap: anywhere; }
.entries .s { color: var(--muted); font-size: .85rem; }
.entries .h { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 6px; min-height: 36px; min-width: 36px; }
.icon-btn:hover { color: var(--danger); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.filters .row-actions, .filters p { grid-column: 1 / -1; margin: 0; }
.cust { margin-bottom: 14px; }
.cust-head { display: flex; justify-content: space-between; font-weight: 700; padding: 6px 0; border-bottom: 2px solid var(--border); }
.cust-task { display: flex; justify-content: space-between; padding: 4px 0 4px 12px; color: var(--muted); font-size: .92rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
.overlay { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); display: grid; place-items: center; padding: 16px; z-index: 20; }
.login { width: min(360px, 100%); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  transition: transform .25s; z-index: 30; max-width: calc(100% - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
@media (max-width: 560px) {
  .row-actions > button, .row-actions > .button { flex: 1 1 auto; }
  th:nth-child(7), td:nth-child(7) { display: none; }
}
