:root {
  color-scheme: light;
  --ink: #173e36;
  --ink-2: #27574c;
  --cream: #f7f3ea;
  --paper: #fffdf9;
  --line: #ddd5c7;
  --muted: #6d716d;
  --gold: #c39a4b;
  --coral: #d66d52;
  --green: #2c7463;
  --shadow: 0 14px 40px rgba(28, 49, 43, .10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: #20302c; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.mode-banner {
  position: fixed; inset: 0 0 auto 0; z-index: 20; height: 30px; display: grid; place-items: center;
  background: #f3d577; color: #443514; font-size: 11px; font-weight: 800; letter-spacing: .12em;
}
.mode-banner.live { background: #cce8dc; color: #164638; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 245px 1fr; padding-top: 30px; }
.sidebar {
  position: fixed; left: 0; top: 30px; bottom: 0; width: 245px; display: flex; flex-direction: column;
  padding: 28px 18px; background: var(--ink); color: white;
}
.brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; padding: 0 8px 28px; }
.brand img { width: 44px; height: 44px; object-fit: contain; background: white; border-radius: 50%; padding: 3px; }
.brand span { display: grid; }
.brand strong { font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.brand small { color: #c8d6d2; letter-spacing: .06em; }
nav { display: grid; gap: 7px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 13px; border: 0;
  border-radius: 9px; background: transparent; color: #dfe9e6; text-align: left;
}
.nav-item span { width: 20px; font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.11); color: white; }
.back-link { margin-top: auto; padding: 14px 10px; color: #dfe9e6; text-decoration: none; font-size: 14px; }
main { grid-column: 2; min-width: 0; padding: 34px clamp(24px, 5vw, 72px) 70px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; color: var(--ink); font-family: Georgia, serif; font-weight: 500; }
h1 { font-size: clamp(30px, 4vw, 44px); }
h2 { font-size: 25px; }
h3 { font-size: 18px; }
.connection { display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 13px; font-weight: 700; }
.connection span { width: 8px; height: 8px; border-radius: 50%; background: #36a47f; box-shadow: 0 0 0 4px #d9eee7; }
.connection.offline { color: #9b422f; }
.connection.offline span { background: var(--coral); box-shadow: 0 0 0 4px #f4ddd8; }
.loading, .empty { padding: 50px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(145px, 1fr)); gap: 15px; }
.metric { min-height: 128px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: 0 3px 12px rgba(28,49,43,.04); }
.metric small { display: block; color: var(--muted); font-weight: 700; }
.metric strong { display: block; margin: 12px 0 3px; color: var(--ink); font-family: Georgia, serif; font-size: 36px; font-weight: 500; }
.metric em { color: var(--muted); font-size: 12px; font-style: normal; }
.metric.attention { border-color: #e9bf78; background: #fffaf0; }
.metric.urgent { border-color: #e9afa2; background: #fff7f5; }

.section { margin-top: 28px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 13px; }
.section-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 15px; color: var(--muted); background: #faf7f0; font-size: 11px; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
td { padding: 15px; border-top: 1px solid #eee8dc; font-size: 13px; vertical-align: top; }
tbody tr:hover { background: #fbf9f4; }
.caller { display: grid; gap: 3px; }
.caller small { color: var(--muted); }
.chip { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #e8f2ef; color: var(--ink-2); font-size: 11px; font-weight: 800; text-transform: capitalize; }
.chip.high, .chip.urgent, .chip.failed { background: #f9e2dc; color: #8b3f2d; }
.chip.open, .chip.follow_up_created { background: #fff0ca; color: #745414; }
.chip.transferred, .chip.resolved, .chip.completed { background: #dcefe7; color: #1d604f; }
.link-button { padding: 0; border: 0; background: none; color: var(--ink-2); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.button { border: 1px solid var(--ink); border-radius: 8px; padding: 9px 13px; background: var(--ink); color: white; font-weight: 750; }
.button.secondary { background: white; color: var(--ink); }
.button.small { padding: 6px 9px; font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.toolbar input, .toolbar select { min-height: 40px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.toolbar input { flex: 1; min-width: 220px; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 14px; }
.card { padding: 19px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.card p { color: #495550; line-height: 1.5; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.task-bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; background: #fffaf0; }
.task-bulk-bar label, .task-select { display: flex; grid-template-columns: none; align-items: center; gap: 8px; }
.task-bulk-bar input, .task-select input { width: 19px; height: 19px; margin: 0; accent-color: var(--green); }
.task-card-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 9px; }
.task-select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: #faf7f0; cursor: pointer; }
.decision-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 16px; }
.decision-grid textarea { min-height: 68px; }

.form-card { max-width: 760px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 800; }
label.wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #cbc4b7; border-radius: 8px; padding: 10px 11px; background: white; color: #20302c; }
textarea { min-height: 105px; resize: vertical; }

dialog { width: min(900px, calc(100vw - 30px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 30px 100px rgba(15,36,31,.28); }
dialog::backdrop { background: rgba(18,41,35,.55); backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); background: var(--paper); }
.icon { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eee9df; color: var(--ink); font-size: 22px; }
#call-dialog-content { padding: 23px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
.detail { padding: 13px; border-radius: 10px; background: #f7f3ea; }
.detail small { display: block; color: var(--muted); }
.detail strong { display: block; margin-top: 5px; color: var(--ink); }
.transcript { display: grid; gap: 10px; margin-top: 12px; }
.turn { max-width: 80%; padding: 12px 14px; border-radius: 13px 13px 13px 3px; background: #e9f2ef; line-height: 1.45; }
.turn.grace { justify-self: end; border-radius: 13px 13px 3px 13px; background: #f4ead4; }
.turn strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: 11px; text-transform: uppercase; }
.event-list { display: grid; gap: 7px; margin-top: 12px; }
.event { display: flex; justify-content: space-between; gap: 20px; padding: 9px 0; border-bottom: 1px solid #eee8dc; font-size: 12px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 40; max-width: 380px; padding: 12px 16px; border-radius: 9px; background: var(--ink); color: white; opacity: 0; transform: translateY(12px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; width: auto; padding: 16px; }
  .brand { padding-bottom: 14px; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item { justify-content: center; padding: 9px; font-size: 0; }
  .nav-item span { font-size: 20px; }
  .back-link { display: block; padding: 14px 9px 3px; }
  main { padding: 24px 15px 55px; }
  .topbar { align-items: end; }
  .cards, .form-grid { grid-template-columns: 1fr; }
  .task-bulk-bar { position: sticky; top: 8px; z-index: 5; box-shadow: 0 5px 16px rgba(28,49,43,.10); }
  .turn { max-width: 94%; }
}
