:root {
  --bg0: #eef3f8;
  --bg1: #f7fafc;
  --ink: #1a2b3c;
  --muted: #5b6b7c;
  --line: #d5dee8;
  --accent: #0b6e99;
  --accent-soft: #d7eef7;
  --free: #1f8a5b;
  --free-bg: #e6f6ee;
  --busy: #c45c26;
  --busy-bg: #fceee6;
  --ring: #b08900;
  --ring-bg: #fff6d6;
  --card: #ffffff;
  --shadow: 0 10px 30px rgba(26, 43, 60, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d9ecf6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e7f2ea 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

body.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 28px 24px;
}
.login-brand { margin-bottom: 18px; }
.login-card h1 {
  margin: 0 0 6px;
  font-family: "Source Serif 4", serif;
  font-size: 1.55rem;
  font-weight: 600;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}
.login-form input,
.login-form select {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.login-form .btn-primary {
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}
.login-form .btn-primary:hover { filter: brightness(1.05); }
.login-error {
  margin: 0;
  color: var(--busy);
  font-size: 0.9rem;
}
.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
}
.nav-link.logout { color: var(--busy); }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.86);
  position: sticky;
  top: 0;
  z-index: 20;
}

body.alert-incoming .live-bar {
  animation: pulse-alert 0.9s ease-in-out 4;
  outline: 3px solid #c45c26;
}
@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 92, 38, 0.35); }
  50% { box-shadow: 0 0 0 10px rgba(196, 92, 38, 0); }
}

.live-bar {
  position: sticky;
  top: 68px;
  z-index: 15;
  margin: 0;
  padding: 12px 28px 14px;
  background: linear-gradient(180deg, #f3f8fc 0%, #eaf3f9 100%);
  border-bottom: 1px solid var(--line);
}
.live-bar.has-calls {
  background: linear-gradient(180deg, #fff8e8 0%, #fff3d6 100%);
  box-shadow: 0 8px 24px rgba(176, 137, 0, 0.12);
}
.live-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.live-bar-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.live-bar-head h2 {
  margin: 0;
  font-family: "Source Serif 4", serif;
  font-size: 1.15rem;
  font-weight: 600;
}
.live-hint { color: var(--muted); font-size: 0.8rem; }
.live-bar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.live-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.btn-collapse {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
  color: var(--ink);
}
.btn-collapse:hover { background: #f4f8fb; }
.live-bar.collapsed #incoming { display: none; }
.live-bar.collapsed { padding-bottom: 10px; }
.live-bar.collapsed.has-calls {
  outline: 2px solid #e8d48a;
}

.phone-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.call-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--busy);
  background: #fff1e8;
  padding: 2px 10px;
  border-radius: 999px;
  min-width: 3.2rem;
  text-align: center;
}
.flow-hint {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
.kv-hint {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}

.emp-call {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff4ec;
  border: 1px solid #f0c2a8;
  font-size: 0.86rem;
}
.emp-call-esti {
  font-weight: 700;
  color: var(--accent);
}
.emp-call-esti.muted {
  color: var(--muted);
  font-weight: 600;
}
.who .tiny {
  display: block;
  margin-top: 2px;
  line-height: 1.35;
}
.emp-call-ring {
  background: #fff9e6;
  border-color: #e8d48a;
  color: var(--ring);
  font-weight: 650;
}
.emp-call-connect {
  background: #f3eefc;
  border-color: #c9b6e8;
}
.emp-call-connect .emp-call-label {
  color: #6b4ea3;
}
.emp-call-peer.muted {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}
.emp-call-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--busy);
}
.emp-call-peer {
  font-weight: 650;
  color: var(--ink);
  flex: 1;
  min-width: 120px;
}
.emp-timer {
  font-size: 0.9rem !important;
  padding: 1px 8px !important;
}
.incoming-live {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 1400px;
  margin: 0 auto;
}
.live-empty { padding: 10px 0 !important; }
.live-card { max-width: 1400px; }
.contact-line {
  margin-top: 2px;
  font-size: 0.9rem;
  font-weight: 650;
}
.contact-line.ok { color: var(--accent); }
.contact-line.warn { color: #8a6a00; }
.live-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.free-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.free-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 4px;
}
.btn-auto {
  background: linear-gradient(145deg, #b08900, #c45c26) !important;
}
.btn-soft {
  background: #1a5f7a !important;
  font-size: 0.78rem !important;
  padding: 8px 10px !important;
}

.brand { display: flex; gap: 12px; align-items: center; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0b6e99, #148f7a);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
}

.brand-name {
  font-family: "Source Serif 4", serif;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.1;
}

.brand-sub { color: var(--muted); font-size: 0.85rem; }

.top-meta { display: flex; gap: 12px; align-items: center; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; }

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
}
a.pill:hover { filter: brightness(0.97); }
.pill-on { background: var(--free-bg); color: var(--free); }
.pill-off { background: #eee; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
  padding: 24px 28px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

.panel-wide { grid-column: 1 / -1; }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .panel-wide { grid-column: auto; }
}

.pill-warn { background: #fff1e0; color: #b86a00; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0 16px;
}
@media (max-width: 900px) {
  .about-grid { grid-template-columns: 1fr; }
}
.about-card {
  background: #f4f8fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.about-card h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}
.about-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--muted);
  margin: 0 0 12px;
}
.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot.free { background: var(--free); }
.dot.ring { background: var(--ring); }
.dot.busy { background: var(--busy); }
.dot.c-ok { background: #2a7de1; }
.dot.c-busy { background: #8a6bb8; }
.dot.c-na { background: #9aa6b2; }

.meta-line {
  display: block;
  clear: both;
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}
.status-c-available { background: #e7f1fc; color: #1d6fc2; }
.status-c-busy { background: #f0eaf8; color: #6b4f9a; }
.status-c-none, .status-c-unknown { background: #eef1f4; color: #6a7684; }

.contact.muted { background: #f0f2f5; color: #5b6b7c; }
.tiny { font-size: 0.75rem; opacity: 0.75; word-break: break-all; }

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 12px 28px 28px;
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 1400px;
  margin: 0 auto;
}
.foot code, .lead code, .meta-line code {
  font-size: 0.85em;
  background: #e8eef4;
  padding: 1px 6px;
  border-radius: 4px;
}

.conv-list, .incoming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.conv-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #f0c2a8;
  background: linear-gradient(180deg, #fff8f4, #fff);
}

.conv-arrow {
  font-size: 1.4rem;
  color: var(--busy);
  font-weight: 700;
}

.conv-role {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.conv-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.incoming-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fff;
}

.incoming-card.phase-ringing,
.incoming-card.phase-ivr {
  border-color: #e8d48a;
  background: #fffdf5;
}

.incoming-card.phase-talking {
  border-color: #f0c2a8;
  background: #fff8f4;
}

.incoming-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.phase-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--ink);
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 14px;
}
@media (max-width: 700px) {
  .kv-grid { grid-template-columns: 1fr; }
  .conv-card { grid-template-columns: 1fr; text-align: center; }
}

.kv span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 2px;
}
.kv b { font-size: 0.95rem; font-weight: 650; }
.kv b.ok { color: var(--accent); }
.kv b.warn { color: #8a6a00; }

.attempts {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.attempts ul {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.help-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
}
.help-list b { color: var(--ink); }

.layout-single {
  grid-template-columns: 1fr;
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
}
.nav-link:hover { text-decoration: underline; }

.filters { margin-bottom: 12px; }
.filters input {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.table-wrap { overflow-x: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.grid th, table.grid td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.grid th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f4f7fa;
  position: sticky;
  top: 0;
}
table.grid tr:hover td { background: #fafcfd; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, monospace; font-size: 0.86rem; }
.small { font-size: 0.82rem; color: var(--muted); }
b.ok, .ok { color: var(--accent); }
b.warn, .warn { color: #8a6a00; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px 12px;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-family: "Source Serif 4", serif;
  font-size: 1.45rem;
  font-weight: 600;
}

.lead {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: 36px 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #f4f7fa;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
}

.row-unified {
  grid-template-columns: 36px 44px 1fr auto auto;
}

.badge-both {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: #d7eef7;
  color: var(--accent);
  vertical-align: middle;
  font-weight: 700;
}

.btn-transfer {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(145deg, #0b6e99, #148f7a);
  color: #fff;
  white-space: nowrap;
}
.btn-transfer:hover { filter: brightness(1.05); }
.btn-transfer.disabled,
.btn-transfer:disabled {
  background: #c5ced6;
  color: #fff;
  cursor: not-allowed;
  filter: none;
}

.toast {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}
.toast.hidden { display: none; }
.toast-ok { background: var(--free-bg); color: var(--free); }
.toast-err { background: #fde8e8; color: #b42318; }

.actions { justify-self: end; }

.row.is-busy { border-color: #f0c2a8; background: #fff8f4; }
.row.is-ring { border-color: #e8d48a; background: #fffdf2; }
.row.is-dim { opacity: 0.72; }

.idx {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.idx-ready {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(145deg, #1f8a5b, #148f7a);
  border: none;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(31, 138, 91, 0.25);
  animation: ready-pulse 1.6s ease-in-out infinite;
}
@keyframes ready-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(31, 138, 91, 0.2); }
  50% { box-shadow: 0 0 0 7px rgba(31, 138, 91, 0.05); }
}
.row.is-ready {
  border-color: #8fd4b0;
  background: linear-gradient(90deg, #e8f7ef 0%, #f4f7fa 28%);
}
.badge-ready {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: #1f8a5b;
  color: #fff;
  vertical-align: middle;
  font-weight: 700;
}
.badge-hidden {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: #ece4f5;
  color: #6b4f9a;
  vertical-align: middle;
  font-weight: 700;
}
.btn-ready {
  box-shadow: 0 0 0 2px rgba(31, 138, 91, 0.35);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin-top: 12px;
}
.settings-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  border: none;
  padding: 0;
}
.settings-form .field > span,
.settings-form legend {
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--ink);
}
.settings-form input[type="text"],
.settings-form input[type="url"] {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
.settings-form .radio {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 6px 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.code-block {
  margin: 8px 0;
  padding: 12px 14px;
  background: #eef3f8;
  border-radius: 10px;
  font-size: 0.85rem;
  overflow-x: auto;
}

.icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #e8eef4;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 1.05rem;
}

.who .name {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.who .num {
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  min-width: 72px;
  justify-content: flex-end;
}

.status {
  min-width: 96px;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-free { background: var(--free-bg); color: var(--free); }
.status-talking { background: var(--busy-bg); color: var(--busy); }
.status-ringing { background: var(--ring-bg); color: var(--ring); }

.sessions { display: flex; flex-direction: column; gap: 10px; min-height: 120px; }

.session {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #fff, #f8fbfd);
}

.session .phone {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.session .meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  display: grid;
  gap: 4px;
}

.session .contact {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.empty {
  color: var(--muted);
  padding: 24px 8px;
  text-align: center;
}

.badge-handset {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: #e8eef4;
  color: var(--muted);
  vertical-align: middle;
}
