:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --ok: #1e8e3e;
  --warn: #b7791f;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
header.top {
  background: #15233a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
header.top h1 { font-size: 18px; margin: 0; font-weight: 600; }
header.top .sub { font-size: 13px; opacity: .8; }
header.top a, header.top button.link { color: #cfe0ff; font-size: 14px; background: none; border: 0; cursor: pointer; }
header.top .langs { display: inline-flex; border: 1px solid #4a5f85; border-radius: 999px; overflow: hidden; }
header.top button.lang { color: #cfe0ff; background: none; border: 0; padding: 4px 10px; font-size: 13px; border-radius: 0; cursor: pointer; }
header.top button.lang.on { background: #cfe0ff; color: #15233a; font-weight: 700; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 640px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card h3 { margin: 14px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }
.right { margin-left: auto; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc0ff; border-color: var(--accent); }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
button.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
button.sm { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.block { width: 100%; margin-top: 10px; }
button.icon { padding: 6px 8px; line-height: 0; vertical-align: middle; }
button.trash { color: var(--danger); border-color: var(--danger); background: #fff; }
button.trash:hover { background: var(--danger); color: #fff; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 12px; }
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choices label {
  margin: 0; padding: 12px 8px; text-align: center; border: 2px solid var(--line);
  border-radius: 8px; cursor: pointer; font-weight: 600;
}
.choices input { display: none; }
.choices input:checked + span { color: var(--accent); }
.choices label:has(input:checked) { border-color: var(--accent); background: #eef4ff; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #e6e9ee; color: #333; white-space: nowrap;
}
.badge.s-open { background: #fdecea; color: #a12a1f; }
.badge.s-queued { background: #e8f0fe; color: #1a4fb0; }
.badge.s-in_progress { background: #fff3cd; color: #7a5a00; }
.badge.s-on_hold { background: #f3e8ff; color: #6b21a8; }
.badge.s-resolved { background: #e3f6e8; color: #166534; }
.badge.s-closed { background: #e6e9ee; color: #444; }
.badge.s-cancelled { background: #eee; color: #777; text-decoration: line-through; }
.badge.urgent { background: var(--danger); color: #fff; }
.badge.state-working { background: #fff3cd; color: #7a5a00; }
.badge.state-idle { background: #e3f6e8; color: #166534; }
.badge.state-inactive { background: #eee; color: #777; }

.alert { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-size: 14px; }
.alert.error { background: #fdecea; color: #a12a1f; }
.alert.ok { background: #e3f6e8; color: #166534; }

.big-number { font-size: 28px; font-weight: 700; letter-spacing: .02em; font-family: ui-monospace, Menlo, monospace; }

.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 10px 14px; position: relative; font-size: 14px; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 9px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff;
}
.timeline .when { color: var(--muted); font-size: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.list li:first-child { border-top: 0; }
.list li:hover { background: #f8fafc; }
.list .title { font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f8fafc; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat .n { font-size: 24px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }

.worker-card .where { font-size: 15px; margin: 6px 0; }
.worker-card .where strong { font-size: 18px; }
.queue-mini { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; z-index: 10; }
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: #fff; z-index: 11;
  box-shadow: -4px 0 20px rgba(0,0,0,.15); overflow: auto; padding: 16px; transform: translateX(100%);
  transition: transform .15s ease;
}
.drawer.open { transform: translateX(0); }
.hidden { display: none !important; }
.current-job { border: 2px solid var(--warn); background: #fffaf0; }

/* ---- voice notes ---- */
audio.clip { display: block; width: 100%; max-width: 380px; height: 40px; margin: 6px 0 2px; }
.rec { margin: 6px 0; }
.rec .rec-btn { font-size: 16px; padding: 12px 16px; }
.rec .rec-stop { font-size: 16px; padding: 12px 16px; }
.rec-timer { font-family: ui-monospace, Menlo, monospace; }
.error-text { color: var(--danger); }
.ok-text { color: var(--ok); font-weight: 600; }
.badge.voice { background: #fff3cd; color: #7a5a00; }
.voice-box { background: #fffaf0; border: 1px solid #f3dca0; border-radius: 8px; padding: 10px 12px; margin: 8px 0; }
.voice-box .lbl { font-size: 13px; font-weight: 600; color: #7a5a00; }
button.listen { font-size: 15px; padding: 10px 14px; }
.stars button { font-size: 22px; padding: 4px 6px; border: 0; background: none; color: #bbb; }
.stars button.on { color: #f5a623; }
@media (max-width: 600px) {
  .choices { grid-template-columns: 1fr; }
  th.opt, td.opt { display: none; }
}
