:root {
  color-scheme: light;
  --canvas: #f2f6f3;
  --paper: #fff;
  --ink: #172721;
  --muted: #566561;
  --line: #e2e9e5;
  --green: #246b58;
  --green-deep: #1a5545;
  --mint: #dff1e9;
  --orange: #946619;
  --rust: #9e3e3d;
  --radius: 18px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
a { color: var(--green-deep); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #61a995; outline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
[hidden] { display: none !important; }
.sr-only, .svg-library { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }
.rail { background: #142e26; color: #f1fcf6; display: flex; flex-direction: column; gap: 37px; padding: 32px 17px 22px; position: sticky; top: 0; height: 100dvh; overflow: auto; }
.brand { display: flex; gap: 12px; align-items: center; padding-inline: 5px; }
.brand-icon { display: grid; place-items: center; width: 44px; height: 44px; background: #246b58; color: #e0fff2; border-radius: 12px; }
.brand-icon .icon { width: 22px; height: 22px; }
.brand strong { display: block; font-size: 1.32rem; font-weight: 700; letter-spacing: -.04em; line-height: 1.08; }
.brand small { display: block; margin-top: 4px; color: #b7c9c2; font-size: .78rem; }
.nav { display: grid; gap: 7px; }
.nav-item { width: 100%; display: flex; gap: 11px; align-items: center; padding: 11px 13px; border: 1px solid transparent; color: #c1d1ca; border-radius: 10px; background: transparent; text-align: left; font-weight: 600; font-size: .94rem; }
.nav-item:hover { background: #1f3931; color: #fff; }
.nav-item.is-active { color: #eafff4; background: #25493d; border-color: #32584c; }
.nav-item.is-active .icon { color: #a0e5c9; }
.rail-footer { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 13px 8px 4px; border-top: 1px solid #365048; }
.rail-footer > .icon { color: #a4bfb3; }
.rail-footer strong { display: block; font-size: .875rem; font-weight: 600; }
#db-state { display: flex; gap: 7px; align-items: center; margin-top: 4px; color: #bbcec5; font-size: .78rem; }
#db-state i { width: 7px; height: 7px; background: #d5aa69; border-radius: 50%; }
#db-state[data-state="online"] i { background: #91dbbd; }
#db-state[data-state="offline"] i { background: #e69287; }

.main { width: min(100%, 1544px); margin-inline: auto; padding: 34px clamp(20px, 3vw, 44px) 36px; min-width: 0; }
.page-header { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 25px; }
.page-header h1 { font-size: clamp(2rem, 4vw, 2.9rem); line-height: 1.07; font-weight: 720; letter-spacing: -.06em; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 45% 25%, #e1efe7, var(--canvas) 65%); }
.login-card { width: min(100%, 410px); padding: clamp(24px, 6vw, 40px); }
.login-card h1 { margin: 16px 0 24px; font-size: 1.65rem; letter-spacing: -.045em; }
.login-card form, .login-card label { display: grid; gap: 7px; }
.login-card form { gap: 15px; }
.login-card label { font-size: .875rem; font-weight: 600; }
.login-card input { width: 100%; min-height: 43px; padding: 8px 10px; border: 1px solid #c8d8d0; border-radius: 8px; color: var(--ink); background: #fff; }
.mode { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: .875rem; color: var(--muted); }
.mode span { width: 7px; height: 7px; border-radius: 50%; background: #ba893d; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 9px 13px; min-height: 42px; color: var(--ink); background: var(--paper); text-decoration: none; border: 1px solid #dce5e0; border-radius: 9px; font-size: .9rem; font-weight: 640; transition: background-color .12s, border-color .12s; }
.button:hover:not(:disabled) { background: #f1f7f4; border-color: #b6cfc3; }
.button.primary { background: var(--green); border-color: var(--green); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--green-deep); border-color: var(--green-deep); }
.page-header .button { padding-inline: 16px; min-height: 46px; white-space: nowrap; }
.button.small { min-height: 36px; padding: 6px 11px; }
.button .icon { width: 18px; height: 18px; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { min-width: 0; display: flex; align-items: center; gap: 15px; padding: 17px; text-align: left; color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.metric:hover { border-color: #aaccbd; }
.metric[aria-pressed="true"] { border-color: #75a994; box-shadow: inset 0 0 0 1px #75a994; }
.metric-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 11px; flex: none; }
.metric-total { background: #e9eeed; color: #45635a; }
.metric-open { background: #fbefd9; color: #895d16; }
.metric-done { background: var(--mint); color: var(--green-deep); }
.metric-copy { display: grid; gap: 3px; }
.metric-copy > span { color: var(--muted); font-size: .9rem; font-weight: 600; }
.metric-copy > strong { font-size: 1.65rem; line-height: 1.05; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 32%); gap: 18px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px #183a2b08; min-width: 0; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 20px 19px 16px; }
.panel-header h2 { font-size: 1.15rem; font-weight: 710; letter-spacing: -.025em; }
.result-count { display: block; margin-top: 3px; color: var(--muted); font-size: .875rem; }
.search { display: flex; align-items: center; gap: 8px; width: min(46%, 226px); padding: 0 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 9px; background: #f8faf9; }
.search:focus-within { border-color: #70a690; outline: 2px solid #b7ddcc; }
.search .icon { width: 17px; height: 17px; }
.search input { min-width: 0; width: 100%; height: 40px; border: 0; background: transparent; color: var(--ink); font-size: .875rem; outline: none; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 19px 15px; }
.filter { border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--muted); min-height: 36px; padding: 6px 11px; font-size: .875rem; font-weight: 600; }
.filter:hover { border-color: #b5cfc4; }
.filter.is-active { color: var(--green-deep); background: var(--mint); border-color: #cde9db; }
.table-wrap { overflow-x: auto; border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px); }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #f6f8f7; color: #53645e; }
th { padding: 10px 10px; font-weight: 650; font-size: .875rem; white-space: nowrap; }
td { padding: 12px 10px; font-size: .875rem; border-top: 1px solid #edf1ef; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 19px; }
th:last-child, td:last-child { padding-right: 16px; }
tr[data-id] { cursor: pointer; }
tr[data-id]:hover { background: #f4f8f6; }
tr.selected { background: #eaf5ef; }
tr.selected td:first-child { box-shadow: inset 3px 0 #3b8a70; }
.call-name { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 0; text-align: left; color: var(--ink); max-width: 100%; min-height: 38px; border-radius: 4px; }
.call-name .title { display: block; font-size: .92rem; font-weight: 700; overflow-wrap: anywhere; }
.row-secondary { display: block; font-size: .8125rem; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.compact-meta { display: none; }
.direction { width: 35px; height: 35px; display: inline-grid; place-items: center; flex: none; border-radius: 10px; background: #e4f1ea; color: #2c735b; }
.direction .icon { width: 18px; height: 18px; }
.direction.outgoing { background: #e7edf6; color: #426990; }
.direction.missed { background: #fae9e6; color: var(--rust); }
.when, .duration { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; gap: 6px; align-items: center; border-radius: 999px; padding: 4px 8px; white-space: nowrap; font-size: .875rem; font-weight: 680; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.open { background: #fbefd9; color: #785014; }
.status.done { background: #e3f2e9; color: #245b46; }
.audio-cell .icon { width: 18px; height: 18px; color: var(--green); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 19px; border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.pagination > div { display: flex; gap: 6px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); border-top: 1px solid var(--line); }
.detail-empty { border-top: 0; min-height: 170px; display: grid; justify-items: center; align-content: center; gap: 12px; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; background: #edf4f0; border-radius: 13px; color: var(--green); }

.detail .panel-header { border-bottom: 1px solid #edf1ef; }
.detail .panel-header h2:focus { outline: none; }
#detail-back { display: none; }
.contact-card { display: flex; align-items: center; gap: 12px; padding: 17px 15px; margin: 13px 19px 16px; border-radius: 13px; background: #f0f6f2; }
.contact-card .direction { width: 46px; height: 46px; border-radius: 13px; }
.contact-card .direction .icon { width: 23px; height: 23px; }
.contact-card h3 { font-size: 1.12rem; font-weight: 720; letter-spacing: -.02em; overflow-wrap: anywhere; }
.contact-card p { margin-top: 3px; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.details-grid { display: grid; gap: 12px; padding: 0 19px 17px; font-size: .875rem; }
.details-grid > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 20px; }
.details-grid dt { color: var(--muted); white-space: nowrap; }
.details-grid dd { text-align: right; font-weight: 610; }
.recording { border-top: 1px solid var(--line); padding: 16px 19px; }
.recording h3 { display: flex; gap: 7px; align-items: center; font-size: .98rem; }
.recording h3 .icon { width: 19px; color: var(--green); }
.recording p { color: var(--muted); font-size: .875rem; line-height: 1.45; margin: 8px 0 10px; }
.recording .button { width: 100%; min-height: 39px; }
.audio-action + .audio-action { margin-top: 7px; }
#record.is-recording { color: #9e3e3d; border-color: #ecd2ce; background: #fdf0ee; }
.audio-box { margin-top: 10px; padding: 9px 9px 7px; border-radius: 11px; background: #f2f6f4; }
.audio-box audio { display: block; width: 100%; height: 40px; }
.audio-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 4px 0 7px; font-size: .8125rem; color: var(--muted); }
.audio-meta a { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 7px; }
.audio-meta a:hover { background: #e1eee8; }
.detail-footer { padding: 0 19px 17px; }
.detail-footer .button { width: 100%; }
.recording .feedback, .feedback { color: var(--green-deep); font-size: .875rem; }
.recording .feedback.error, .feedback.error { color: #8e3636; }
.transcript p.text-content { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); background: #f6f8f7; padding: 12px; border-radius: 10px; border: 1px solid var(--line); line-height: 1.58; }
.transcript-turns { display: flex; flex-direction: column; gap: 8px; padding: 0; list-style: none; }
.transcript-turn { align-self: center; max-width: min(calc(100% - 26px), 500px); min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #f6f8f7; }
.transcript-turn.bubble-left { align-self: flex-start; background: #f1f5f8; border-color: #dfe8ef; border-radius: 13px 13px 13px 4px; }
.transcript-turn.bubble-right { align-self: flex-end; background: var(--mint); border-color: #cde7da; border-radius: 13px 13px 4px 13px; }
.transcript-turn header { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .83rem; }
.transcript-turn strong { color: var(--green-deep); }
.transcript-turn.bubble-left strong { color: #36576f; }
.transcript-turn p { margin: 5px 0 0; color: var(--ink); line-height: 1.5; overflow-wrap: anywhere; }
.turn-time { color: var(--muted); font-variant-numeric: tabular-nums; padding: 4px 2px; }
button.turn-time { color: var(--green-deep); background: none; border: 0; cursor: pointer; }
button.turn-time:hover { text-decoration: underline; }
.context-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }
.context-tag { display: inline-block; background: var(--mint); color: var(--green-deep); padding: 4px 8px; border-radius: 8px; font-size: .875rem; }
.sms-rows { display: grid; gap: 10px; margin: 0 19px 19px; }
.sms-rows:empty { display: none; }
.sms-rows article { border: 1px solid var(--line); border-radius: 11px; padding: 14px 16px; background: #f8faf9; }
.sms-header { color: var(--muted); font-size: .875rem; margin-bottom: 6px; }
.sms-header strong { color: var(--ink); }
.sms-body { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.45; max-width: 76ch; }
.notice { position: fixed; right: 20px; bottom: 20px; z-index: 2; max-width: min(90vw, 390px); padding: 11px 15px; border-radius: 10px; color: white; background: #253d34; box-shadow: 0 6px 16px #142c2640; }
.notice.error { background: #823939; }

dialog { width: min(485px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--paper); padding: 0; box-shadow: 0 20px 65px #10281e50; }
dialog::backdrop { background: #10241bc0; }
#call-form { display: grid; gap: 14px; padding: 21px; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; }
.dialog-header h2 { font-size: 1.35rem; letter-spacing: -.035em; }
.icon-button { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
.icon-button:hover { background: var(--canvas); }
#call-form label { display: block; min-width: 0; font-size: .92rem; font-weight: 630; }
#call-form input, #call-form select { display: block; width: 100%; min-width: 0; height: 43px; margin-top: 5px; padding: 0 11px; background: #f8faf9; border: 1px solid #dce6e1; border-radius: 8px; color: var(--ink); font-size: 1rem; }
.optional { font-weight: 400; color: var(--muted); }
.select-wrap { position: relative; display: block; }
.select-wrap select { appearance: none; padding-right: 34px !important; }
.select-wrap .icon { position: absolute; right: 9px; top: 11px; pointer-events: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

@media (max-width: 1160px) {
  .shell { grid-template-columns: 184px minmax(0, 1fr); }
  .main { padding-inline: 20px; }
  .audio-cell { display: none; }
}
@media (max-width: 1060px) {
  .shell { grid-template-columns: 154px minmax(0, 1fr); }
  .rail { padding-inline: 11px; }
  .brand { padding-inline: 1px; gap: 7px; }
  .brand-icon { width: 38px; height: 38px; }
  .rail-footer { padding-inline: 1px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace:not([data-detail-open="true"]) > .detail, .workspace[data-detail-open="true"] > .log { display: none; }
  .detail .panel-header { justify-content: flex-start; flex-wrap: wrap; }
  #detail-back { display: inline-flex; min-height: 42px; }
  .audio-cell { display: table-cell; }
}
@media (max-width: 680px) {
  .shell { display: block; }
  .rail { position: static; height: auto; display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 7px; overflow: visible; }
  .brand small, .rail-footer { display: none; }
  .nav { display: flex; gap: 3px; }
  .nav-item { min-height: 44px; padding: 7px 8px; font-size: .85rem; gap: 5px; }
  .nav-item .icon { width: 16px; height: 16px; }
  .main { padding: 23px 12px 24px; }
  .main:has(.workspace[data-detail-open="true"]:not([hidden])) :is(.page-header, .metrics) { display: none; }
  .page-header { margin-bottom: 15px; gap: 8px; }
  .page-header .button { min-height: 44px; padding-inline: 10px; }
  .metrics { gap: 7px; margin-bottom: 14px; }
  .metric { padding: 10px 8px; gap: 8px; flex-direction: column; align-items: flex-start; border-radius: 13px; }
  .metric-icon { width: 29px; height: 29px; border-radius: 7px; }
  .metric-icon .icon { width: 16px; height: 16px; }
  .metric-copy > span { font-size: .82rem; }
  .metric-copy > strong { font-size: 1.35rem; }
  .panel-header { padding: 14px 12px 11px; }
  .filters { padding: 0 12px 10px; }
  .workspace[data-view="calls"] .filters { display: none; }
  .search { width: 42%; min-width: 116px; }
  .filter { min-height: 40px; }
  td, th { padding: 9px 6px; }
  th:first-child, td:first-child { padding-left: 9px; }
  th:last-child, td:last-child { padding-right: 9px; }
  .when, .duration, .duration-head, .audio-cell { display: none; }
  .call-name { gap: 7px; min-height: 44px; }
  .compact-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .78rem; margin-top: 3px; }
  .compact-meta [role="img"] { display: flex; }
  .compact-meta .icon { width: 14px; height: 14px; color: var(--green); }
  .direction { width: 28px; height: 28px; border-radius: 7px; }
  .direction .icon { width: 15px; height: 15px; }
  .status { padding: 4px 5px; }
  .status::before { width: 5px; height: 5px; }
  .row-secondary { white-space: normal; }
  .sms-rows { margin-inline: 12px; }
}
@media (max-width: 400px) {
  .nav-item .icon { display: none; }
  .panel-header:has(.search) { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
}
@media (max-width: 324px) {
  .brand-icon { display: none; }
  #call-form { padding: 15px; }
  .form-row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .button { transition: none; } }
