:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #17202a;
  --muted: #667085;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 6px 12px;
}
a.button-link:hover { background: var(--accent-dark); text-decoration: none; }
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.container { max-width: 1180px; margin: 24px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
h1 { font-size: 26px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
section { margin-bottom: 24px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef2f6; font-weight: 650; }
button {
  min-height: 34px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button:disabled { cursor: not-allowed; opacity: .55; }
button.secondary { background: white; color: var(--text); border-color: var(--line); }
button.secondary:hover { background: #eef2f6; }
button.danger { background: var(--danger); border-color: var(--danger); }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font: inherit;
}
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font: inherit;
}
label { display: grid; gap: 5px; color: var(--muted); }
.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 16px;
}
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid section, .item, .auth-box, .status-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.status-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.status-line { margin: 0 0 12px; font-weight: 700; }
.status-line.ok { color: var(--accent-dark); }
.status-line.warn { color: var(--danger); }
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 14px;
  margin: 0;
}
.status-grid dt { color: var(--muted); font-size: 12px; }
.status-grid dd { margin: 3px 0 0; font-weight: 650; }
.lead-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}
.lead-summary > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}
.timeline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  position: relative;
  padding: 8px 0 8px 14px;
  border-bottom: 1px solid var(--line);
  line-height: 1.25;
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-item time {
  color: var(--muted);
  font-size: 11px;
}
.timeline-item strong {
  display: block;
  margin-top: 1px;
  font-size: 13px;
  font-weight: 600;
}
.timeline-author {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}
.timeline-item p {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 13px;
}
.company-box .muted { margin: 2px 0 8px; }
.compact-list {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px 10px;
  margin: 6px 0 0;
}
.compact-list dt {
  color: var(--muted);
  font-size: 12px;
}
.compact-list dd {
  margin: 0;
  font-size: 13px;
}
.history-warning {
  margin: -4px 0 10px;
  color: var(--danger);
  font-size: 12px;
}
.stack { display: grid; gap: 12px; }
.narrow { max-width: 520px; }
.inline-form { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.error { color: var(--danger); }
.auth-page { min-height: 100vh; display: grid; place-items: center; }
.auth-box { width: min(380px, calc(100vw - 32px)); }
.secondary-link { display: inline-block; margin-top: 14px; }
.webphone {
  position: sticky;
  bottom: 14px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, .12);
}
.webphone[hidden] { display: none; }
.webphone-main, .webphone-actions { display: flex; align-items: center; gap: 10px; }
.webphone-main strong, .webphone-main span { display: block; }
.webphone-indicator { width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; }
.webphone-indicator[data-state="ready"] { background: #12b76a; }
.webphone-indicator[data-state="calling"] { background: #f79009; }
.webphone-indicator[data-state="active"] { background: #2e90fa; }
.webphone-indicator[data-state="error"] { background: var(--danger); }
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .filters, .grid.two, .lead-summary, .timeline-item { grid-template-columns: 1fr; }
  .status-panel { display: grid; }
  .status-grid { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .webphone { align-items: stretch; flex-direction: column; }
  .webphone-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
