:root {
  color-scheme: light;
  --ink: #121820;
  --muted: #697681;
  --line: #dce1e4;
  --soft: #eef1f2;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --accent: #0b7a67;
  --accent-soft: #dff1ec;
  --blue: #3a68c7;
  --red: #c74945;
  --amber: #b87518;
  --sidebar: #111820;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 232px; background: var(--sidebar); color: #d9dfe3; padding: 22px 14px 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; color: #fff; font-weight: 760; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: #fff; color: var(--sidebar); font-size: 16px; }
.sidebar nav { display: grid; gap: 3px; margin-top: 30px; }
.nav-item { border: 0; background: transparent; color: #99a4ac; height: 42px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 10px; padding: 0 10px; border-radius: 6px; text-align: left; cursor: pointer; }
.nav-item svg { width: 18px; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.105); }
.nav-item b { min-width: 20px; height: 20px; padding: 0 6px; display: none; place-items: center; border-radius: 10px; background: #d4f2e9; color: #0b5f52; font-size: 11px; }
.nav-item b.visible { display: grid; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding: 16px 10px 2px; display: flex; align-items: center; gap: 10px; }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; color: #e9edf0; }
.sidebar-foot small { margin-top: 2px; font-size: 10px; color: #78858e; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #46c49b; box-shadow: 0 0 0 4px rgba(70,196,155,.12); }
main { grid-column: 2; min-width: 0; }
.topbar { min-height: 92px; padding: 20px 30px; border-bottom: 1px solid var(--line); background: rgba(244,246,247,.92); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px); }
.topbar h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.1; font-weight: 720; }
.eyebrow { margin: 0; font-size: 10px; color: var(--muted); font-weight: 760; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.range-select, .search-box { height: 38px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.range-select svg, .search-box svg { width: 16px; color: var(--muted); }
.range-select select, .search-box input { border: 0; outline: 0; background: transparent; color: var(--ink); }
.icon-button, .mobile-menu { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.icon-button svg, .mobile-menu svg { width: 17px; }
.mobile-menu { display: none; }
.content { padding: 26px 30px 52px; max-width: 1600px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.metric { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 11px; font-weight: 680; }
.metric strong { display: block; margin-top: 7px; font-size: 25px; font-weight: 730; white-space: nowrap; }
.metric small { display: block; min-height: 17px; margin-top: 5px; color: var(--muted); font-size: 10px; }
.metric.positive strong { color: var(--accent); }
.metric.attention strong { color: var(--amber); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 18px; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.panel.span-2 { grid-column: span 2; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { min-height: 42px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.panel h2, .section-intro h2 { margin: 0; font-size: 15px; font-weight: 720; }
.panel-head p, .section-intro p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 700; display: flex; align-items: center; gap: 5px; cursor: pointer; }
.text-button svg { width: 14px; }
.chart { min-height: 270px; position: relative; }
.chart svg { width: 100%; height: 270px; overflow: visible; }
.chart .grid-line { stroke: #e8ebed; stroke-width: 1; }
.chart .axis-label { fill: #84909a; font-size: 9px; }
.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { opacity: .08; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.legend i { width: 7px; height: 7px; border-radius: 50%; }
.funnel { display: grid; gap: 12px; }
.funnel-step { display: grid; grid-template-columns: 124px 1fr 54px; align-items: center; gap: 10px; }
.funnel-step span { color: var(--muted); font-size: 11px; }
.funnel-step b { font-size: 11px; text-align: right; }
.funnel-track { height: 9px; background: var(--soft); overflow: hidden; border-radius: 3px; }
.funnel-track i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.active-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.active-breakdown div { background: #fff; padding: 21px 12px; text-align: center; }
.active-breakdown strong { display: block; font-size: 25px; }
.active-breakdown span { display: block; color: var(--muted); font-size: 10px; margin-top: 4px; }
.compact-table { display: grid; }
.compact-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; min-height: 42px; align-items: center; border-top: 1px solid var(--soft); font-size: 11px; }
.compact-row:first-child { border-top: 0; }
.compact-row strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compact-row span { color: var(--muted); }
.section-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 20px; }
.section-intro h2 { font-size: 19px; }
.definition { color: var(--muted); font-size: 10px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.bar-list { display: grid; gap: 15px; }
.bar-item { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr 46px; align-items: center; gap: 9px; font-size: 11px; }
.bar-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-item b { text-align: right; }
.bar-track { height: 7px; background: var(--soft); border-radius: 2px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--blue); }
.data-table { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { height: 38px; color: var(--muted); background: #fafbfb; font-weight: 680; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { height: 45px; border-bottom: 1px solid var(--soft); }
th, td { padding: 0 14px; }
tr:last-child td { border-bottom: 0; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; height: 22px; border-radius: 4px; padding: 0 7px; background: var(--soft); color: #55616b; font-size: 9px; font-weight: 720; text-transform: uppercase; }
.pill.green { background: var(--accent-soft); color: #096253; }
.pill.amber { background: #f8ebd8; color: #8a5510; }
.pill.red { background: #f7e0df; color: #9b3430; }
.toolbar-row, .support-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar-row .search-box, .support-toolbar .search-box { width: min(420px, 100%); }
.toolbar-row span { color: var(--muted); font-size: 11px; }
.support-toolbar { justify-content: flex-start; }
.support-toolbar select { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.support-layout { min-height: calc(100vh - 190px); display: grid; grid-template-columns: 360px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.ticket-list { border-right: 1px solid var(--line); overflow: auto; }
.ticket-item { width: 100%; border: 0; border-bottom: 1px solid var(--soft); background: #fff; padding: 14px; text-align: left; cursor: pointer; }
.ticket-item:hover, .ticket-item.active { background: #f7f9f9; }
.ticket-item.active { box-shadow: inset 3px 0 var(--accent); }
.ticket-item-head { display: flex; align-items: center; gap: 7px; }
.ticket-item-head strong { min-width: 0; flex: 1; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-item p { margin: 7px 0; color: #4d5963; font-size: 11px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.ticket-item small { color: var(--muted); font-size: 9px; }
.conversation { min-width: 0; display: flex; flex-direction: column; }
.conversation.empty { display: grid; place-items: center; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }
.empty-state svg { width: 28px; }
.empty-state h2 { color: var(--ink); margin: 12px 0 5px; font-size: 15px; }
.empty-state p { margin: 0; font-size: 11px; }
.conversation-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; }
.conversation-head h2 { margin: 0; font-size: 14px; }
.conversation-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.conversation-actions { display: flex; gap: 7px; }
.conversation-actions select, .conversation-actions button { height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 5px; padding: 0 8px; font-size: 10px; }
.conversation-actions button { cursor: pointer; }
.message-list { flex: 1; overflow: auto; padding: 20px; display: grid; align-content: start; gap: 12px; background: #fafbfb; }
.message { max-width: min(680px, 84%); padding: 11px 13px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.message.admin { margin-left: auto; background: #e7f3ef; border-color: #c5e2d9; }
.message p { margin: 0; font-size: 12px; white-space: pre-wrap; line-height: 1.5; }
.message small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; }
.reply-box { padding: 14px; border-top: 1px solid var(--line); background: #fff; }
.reply-box textarea { width: 100%; height: 74px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 10px; outline: 0; }
.reply-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.reply-actions a { color: var(--muted); font-size: 10px; text-decoration: none; }
.primary-button { height: 34px; border: 0; border-radius: 5px; padding: 0 14px; background: var(--ink); color: #fff; font-size: 11px; font-weight: 700; cursor: pointer; }
.quality-metrics { grid-template-columns: repeat(4, 1fr); }
#lag-summary { padding: 24px 0; }
#lag-summary strong { display: block; font-size: 32px; }
#lag-summary span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 60; transform: translateY(90px); opacity: 0; transition: .2s ease; background: var(--ink); color: #fff; border-radius: 6px; padding: 11px 14px; font-size: 11px; box-shadow: 0 12px 35px rgba(0,0,0,.18); }
.toast.visible { transform: translateY(0); opacity: 1; }
.empty-row { padding: 34px 14px; color: var(--muted); text-align: center; font-size: 11px; }
.loading { opacity: .52; pointer-events: none; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 18px 0 45px rgba(0,0,0,.16); }
  .sidebar.open { transform: translateX(0); }
  main { min-width: 0; }
  .mobile-menu { display: grid; float: left; margin-right: 11px; }
  .topbar { padding: 15px 18px; min-height: 76px; }
  .content { padding: 18px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .panel.span-2 { grid-column: auto; }
  .support-layout { grid-template-columns: 1fr; }
  .ticket-list { border-right: 0; max-height: 300px; }
  .conversation { min-height: 520px; border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .metric-grid, .quality-metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line); }
  .metric:nth-child(even) { border-right: 0 !important; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .range-select svg { display: none; }
  .range-select { padding: 0 5px; }
  .section-intro { align-items: flex-start; flex-direction: column; }
  .support-toolbar { align-items: stretch; flex-direction: column; }
  .support-toolbar .search-box { width: 100%; }
  .conversation-head { flex-direction: column; }
}
