:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #60707f;
  --line: #d7e0e8;
  --brand: #0b6e99;
  --brand-dark: #084e6d;
  --ok: #1f7a4d;
  --danger: #b42318;
  --warn: #9a6700;
  --shadow: 0 10px 30px rgba(21, 32, 43, 0.08);
  --radius: 16px;
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #d9eef8, transparent 35%),
    linear-gradient(180deg, #eef4f8, var(--bg));
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  background: #0f2430;
  color: #e8f3f8;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.brand { display: flex; gap: .8rem; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #19a0d4, #0b6e99);
  font-weight: 700;
}
.brand small { display: block; color: #9db6c4; }
.sidebar nav { display: grid; gap: .4rem; }
.sidebar nav a {
  color: #d7e8f0;
  padding: .7rem .85rem;
  border-radius: 10px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.logout-form button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: .7rem;
  background: rgba(255,255,255,.08);
  color: #fff;
  cursor: pointer;
}

.content { flex: 1; padding: 1.5rem; }
.content-full { max-width: 960px; margin: 0 auto; }

.page-head, .panel-head, .actions {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.page-head { margin-bottom: 1.25rem; }
.page-head h1, .panel h2, .hero-home h1 { margin: 0 0 .35rem; }
.page-head p, .lead, .muted { color: var(--muted); }

.panel, .stat-card, .login-card, .hero-home, .node-card, .node-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel, .login-card, .hero-home { padding: 1.25rem; margin-bottom: 1rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.stat-card { padding: 1rem 1.2rem; }
.stat-card span { color: var(--muted); font-size: .9rem; }
.stat-card strong { display: block; font-size: 2rem; margin-top: .2rem; }

.grid-2, .grid-3 { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stack { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; font-size: .92rem; font-weight: 600; }
input, textarea, select, button, .btn {
  font: inherit;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  background: #fff;
}
.checkbox {
  display: flex; align-items: center; gap: .6rem;
  margin-top: 1.7rem; font-weight: 600;
}
.checkbox input { width: auto; }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; padding: .7rem 1.1rem;
  cursor: pointer; text-decoration: none; font-weight: 600;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); text-decoration: none; }
.btn-ghost { background: #e8eef3; color: var(--ink); }
.btn-danger { background: #f8e4e2; color: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .85rem; font-weight: 600; }
.row-actions { display: flex; gap: .75rem; }

.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-active, .badge-completed { background: #dff7ea; color: var(--ok); }
.badge-transferred { background: #e3f0ff; color: #185fa5; }
.badge-abandoned, .badge-error { background: #fde8e6; color: var(--danger); }

.flash {
  padding: .85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.flash-success { background: #dff7ea; color: var(--ok); }
.flash-error { background: #fde8e6; color: var(--danger); }

.hero-home { margin-top: 4rem; }
.eyebrow {
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--brand);
  font-size: .8rem;
  font-weight: 700;
}
.login-card { max-width: 420px; margin: 4rem auto; }

.meta-list { display: grid; gap: .7rem; margin: 0; }
.meta-list > div { display: grid; grid-template-columns: 120px 1fr; gap: .5rem; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }

.node-card, .node-editor { padding: 1rem; margin-top: 1rem; }
.node-card header, .node-editor-head {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem;
}
.option-list { padding-left: 1.1rem; }
.option-list li { margin: .25rem 0; }
kbd, code {
  background: #eef3f7;
  border-radius: 6px;
  padding: .1rem .35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .86em;
}

.option-row {
  display: grid;
  grid-template-columns: 60px 1.2fr 1fr 1fr 1fr 1fr auto;
  gap: .4rem;
  margin-bottom: .5rem;
  align-items: center;
}
.options-block { margin-top: 1rem; padding-top: .8rem; border-top: 1px dashed var(--line); }

.phone {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 1rem;
  margin-top: 1rem;
}
.phone-screen {
  min-height: 220px;
  background: linear-gradient(160deg, #0f2430, #18485f);
  color: #e9f6fb;
  border-radius: 18px;
  padding: 1rem;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}
.key {
  border: 0;
  border-radius: 14px;
  padding: 1rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  background: #e8eef3;
  cursor: pointer;
}
.key:disabled { opacity: .45; cursor: not-allowed; }
.sim-log {
  margin-top: 1rem;
  background: #0f2430;
  color: #b7e3f4;
  border-radius: 12px;
  padding: 1rem;
  min-height: 120px;
  overflow: auto;
}

.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.timeline li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: .8rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line);
}
.timeline time { color: var(--muted); font-size: .85rem; }
.simple-list { padding-left: 1.1rem; }
.empty-state { text-align: center; margin-top: 4rem; }

.inline-form { display: inline; }
.inline-form button { margin: 0; }
label small.muted { font-weight: 400; }

.settings-toc {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin: 0 0 1.25rem;
}
.settings-toc a {
  padding: .45rem .85rem;
  border-radius: 999px;
  background: #e8eef3;
  color: var(--ink);
  text-decoration: none;
  font-size: .9rem;
}
.settings-toc a:hover { background: #d7e4ee; text-decoration: none; }
.panel.stack > h2 { scroll-margin-top: 1rem; }

.voice-list {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #d7e0e8;
  border-radius: 10px;
  padding: .35rem;
  background: #f7fafc;
}
.voice-group { margin-bottom: .45rem; }
.voice-group:last-child { margin-bottom: 0; }
.voice-group-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #5a6b7a;
  padding: .4rem .55rem .2rem;
  font-weight: 600;
}
.voice-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: .55rem;
  width: 100%;
  box-sizing: border-box;
  padding: .4rem .55rem;
  border-radius: 8px;
  margin: 0;
}
.voice-row:hover { background: #eef4f8; }
.voice-row.is-selected {
  background: #e2eef8;
  outline: 1px solid #9bb8d0;
}
.voice-row .voice-radio {
  flex: 0 0 auto;
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: #2a6f97;
}
/* Override global `label { display: grid }` */
.voice-list label.voice-pick {
  display: flex !important;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: .45rem;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
  font-weight: 500;
  font-size: .92rem;
  line-height: 1.25;
}
.voice-tag {
  flex: 0 0 auto;
  font-size: .68rem;
  font-weight: 600;
  padding: .12rem .45rem;
  border-radius: 999px;
  background: #dce7f0;
  color: #334;
  white-space: nowrap;
}
.voice-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.voice-play {
  flex: 0 0 auto;
  min-width: 3.4rem;
}
.voice-row.is-locked {
  opacity: .72;
}
.voice-row.is-locked .voice-name { font-weight: 400; }
.voice-tag-warn {
  background: #f8e5c8;
  color: #7a4b00;
}

.table-wrap { overflow-x: auto; }
.logs-table { width: 100%; font-size: .9rem; }
.logs-table th, .logs-table td { vertical-align: top; }
.logs-table .nowrap { white-space: nowrap; }
.logs-table tr.log-fail { background: #fff5f4; }
.badge-error { background: #fde8e6; color: var(--danger); }
.log-meta {
  background: #f3f6f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .75rem 1rem;
  overflow: auto;
  max-height: 320px;
  font-size: .85rem;
}
.check-row {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  font-weight: 500;
  margin: 0;
}
.check-row input { width: auto; margin: 0; }

/* —— Softphone call modal —— */
.call-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.call-modal[hidden] { display: none !important; }
.call-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 36, 48, 0.55);
  backdrop-filter: blur(2px);
}
.call-modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 36, 48, 0.28);
  padding: 1.25rem 1.35rem 1.15rem;
  display: grid;
  gap: 1rem;
}
.call-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.call-modal-eyebrow {
  margin: 0;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}
.call-modal-head h2 { margin: .15rem 0 .25rem; font-size: 1.35rem; }
.call-modal-phase { margin: 0; color: var(--brand-dark); font-weight: 600; }
.call-modal-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 4.5rem;
  text-align: right;
}
.call-modal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem .85rem;
  padding: .85rem;
  background: #f3f7fa;
  border-radius: 12px;
  border: 1px solid #e2ebf1;
}
.call-modal-meta span { display: block; font-size: .75rem; margin-bottom: .15rem; }
.call-modal-meta strong { font-size: .95rem; word-break: break-word; }
.call-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .45rem;
}
.call-steps li {
  display: grid;
  grid-template-columns: 1.4rem 1fr;
  gap: .55rem;
  align-items: start;
  padding: .45rem .55rem;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: .92rem;
}
.call-steps li .dot {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  border: 2px solid #c5d2dc;
  margin-top: .15rem;
  box-sizing: border-box;
}
.call-steps li.is-done { color: var(--ok); }
.call-steps li.is-done .dot {
  background: var(--ok);
  border-color: var(--ok);
  box-shadow: inset 0 0 0 3px #fff;
}
.call-steps li.is-active {
  color: var(--ink);
  background: #e8f4fb;
  border-color: #b7d7ea;
  font-weight: 600;
}
.call-steps li.is-active .dot {
  border-color: var(--brand);
  background: #fff;
  animation: call-pulse 1.2s ease-in-out infinite;
}
.call-steps li.is-error { color: var(--danger); background: #fff5f4; }
.call-steps li.is-error .dot { border-color: var(--danger); background: var(--danger); }
@keyframes call-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(11, 110, 153, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(11, 110, 153, 0); }
}
.call-feed-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .65rem .75rem;
  background: #fafcfd;
  max-height: 180px;
  overflow: auto;
}
.call-feed-title { margin: 0 0 .45rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.call-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .35rem;
}
.call-feed li {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: .45rem;
  font-size: .86rem;
  line-height: 1.35;
}
.call-feed time { color: var(--muted); font-variant-numeric: tabular-nums; }
.call-feed .ev-error { color: var(--danger); }
.call-feed .ev-ok { color: var(--ok); }
.call-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: flex-end;
}
.call-modal-actions .btn-danger { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .stats-grid, .grid-2, .grid-3, .phone, .option-row, .meta-list > div, .timeline li {
    grid-template-columns: 1fr;
  }
}
