:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #e2e2dc;
  --accent: #1f5fbf;
  --ok: #1d7a46;
  --bad: #b3261e;
  --warn: #8a5a00;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --panel: #1f1f1d;
    --text: #ececea;
    --muted: #a0a09a;
    --line: #34342f;
    --accent: #7aa7ff;
    --ok: #5cc98a;
    --bad: #ff8a80;
    --warn: #f0b84a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
header {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.title { font-weight: 600; }
.sub { color: var(--muted); font-weight: 400; margin-left: 8px; }
#who { color: var(--muted); display: flex; gap: 12px; align-items: center; }
.badge { padding: 2px 8px; border-radius: 10px; background: var(--accent); color: var(--panel); font-size: 13px; }
.badge.none { background: var(--bad); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
h1 { font-size: 20px; margin: 0 0 8px; }
.note { color: var(--muted); margin: 4px 0 14px; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
button {
  font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--panel); cursor: pointer;
}
button.secondary, button.tab, button.link { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.small { padding: 2px 8px; font-size: 13px; }
nav { display: flex; gap: 6px; margin-bottom: 12px; }
button.tab.active { background: var(--accent); color: var(--panel); }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.tok { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 6px; margin-top: 4px; }
form { display: flex; flex-wrap: wrap; gap: 8px; }
input, select, textarea {
  font: inherit; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
input { min-width: 260px; flex: 1; }
.result { margin-top: 14px; font-weight: 600; }
.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.editor { margin: 4px 0 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
td .editor { margin: 0; }
.editor input { min-width: 180px; }
.msg { flex-basis: 100%; font-size: 13px; }
.editor > input[name=name], .editor > input[name=subject] { flex-basis: 100%; }
.editor textarea { flex-basis: 100%; resize: vertical; }
.crows { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; }
.crow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.crow select { flex: 0 0 auto; }
.crow input[name=value] { flex: 2; }
.editor input.label-in { flex: 0 1 140px; min-width: 100px; }
.crow-tok { flex: 2; min-width: 180px; }
.chan { color: var(--muted); font-size: 13px; width: 44px; }
.prim { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 4px; }
.prim input { min-width: 0; flex: none; }
.crow.removed .crow-tok, .crow.removed .chan { text-decoration: line-through; opacity: 0.5; }
.crow.removed input, .crow.removed .prim { opacity: 0.4; pointer-events: none; }
.editor > .actions { flex-basis: 100%; }
.contacts { display: flex; flex-direction: column; gap: 10px; }
.label { margin-left: 8px; padding: 0 6px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); }
.label.primary { border-color: var(--accent); color: var(--accent); }
.msg.bad { color: var(--bad); }
.msg.ok { color: var(--ok); }
.in_service { color: var(--ok); }
.not_in_service { color: var(--bad); }
.mistyped { color: var(--warn); }
#callbar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); max-width: calc(100% - 32px);
}
#callbar-status { color: var(--muted); }
@media (max-width: 640px) {
  header { flex-direction: column; align-items: flex-start; }
  input { min-width: 0; }
}
