:root {
  --ink: #17221f;
  --muted: #68736f;
  --line: #dce2de;
  --paper: #f4f6f2;
  --surface: #ffffff;
  --forest: #163f35;
  --forest-deep: #102e27;
  --mint: #c9f27b;
  --mint-soft: #ecf8d7;
  --amber: #a65f13;
  --amber-soft: #fff2d8;
  --red: #b3433e;
  --red-soft: #fee9e6;
  --blue: #32658d;
  --blue-soft: #e7f1fa;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: currentColor; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px 20px; background: var(--forest-deep); color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; padding: 0 8px 28px; }
.brand-mark, .login-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--mint); color: var(--forest-deep); font-weight: 900; font-size: 20px; }
.brand span:last-child { display: flex; flex-direction: column; line-height: 1.05; }
.brand b { font-size: 18px; letter-spacing: -0.03em; }
.brand small { margin-top: 5px; color: #99afa8; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.primary-nav { display: grid; gap: 6px; }
.nav-item { width: 100%; border: 0; border-radius: 10px; background: transparent; color: #afc2bc; text-decoration: none; display: flex; align-items: center; gap: 11px; padding: 11px 12px; font-size: 14px; text-align: left; }
.nav-item:hover, .nav-item:focus-visible { color: white; background: #1c443a; outline: none; }
.nav-item.is-active { color: var(--forest-deep); background: var(--mint); font-weight: 700; }
.nav-count { margin-left: auto; min-width: 24px; padding: 2px 7px; border-radius: 99px; color: white; background: #35574f; text-align: center; font-size: 11px; }
.nav-item.is-active .nav-count { color: var(--forest-deep); background: rgba(16,46,39,.15); }
.sidebar-note { margin-top: auto; padding: 14px 12px; display: flex; gap: 10px; border: 1px solid #2b4c44; border-radius: 12px; color: #c7d5d0; }
.sidebar-note div { display: grid; gap: 4px; }
.sidebar-note b { font-size: 12px; }
.sidebar-note small { font-size: 10px; line-height: 1.45; color: #819b93; }
.privacy-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(201,242,123,.1); }
.logout-button { margin-top: 10px; padding: 9px; border: 0; color: #8fa69f; background: transparent; font-size: 12px; }
.logout-button:hover { color: white; }

.main { width: 100%; max-width: 1660px; margin: 0 auto; padding: 32px 36px 56px; overflow: hidden; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow, .section-kicker { color: #789087; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 6px 0 5px; font-size: clamp(30px, 4vw, 42px); line-height: 1; letter-spacing: -.045em; }
.topbar p { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.period-switch { display: flex; padding: 4px; background: #e6ebe7; border-radius: 10px; }
.period-switch button { padding: 7px 11px; border: 0; border-radius: 7px; color: #60706b; background: transparent; font-size: 12px; white-space: nowrap; }
.period-switch button.is-active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(15,40,33,.1); font-weight: 700; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: #56635f; background: white; }
.icon-button:hover { color: var(--forest); border-color: #aab8b2; }
.icon-button.is-loading svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 148px; padding: 19px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; box-shadow: 0 8px 25px rgba(26,53,45,.035); }
.metric-card-accent { background: var(--forest); border-color: var(--forest); color: white; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-card-accent .metric-label, .metric-card-accent .metric-foot { color: #a9c0b9; }
.metric-value { margin-top: 14px; font-size: clamp(30px, 4vw, 42px); line-height: 1; font-weight: 780; letter-spacing: -.045em; }
.metric-value small { margin-left: 3px; font-size: 17px; font-weight: 700; color: #8a9894; }
.metric-foot { margin-top: auto; color: #8a9591; font-size: 11px; }
.metric-foot span { font-weight: 750; }
.metric-alert { color: var(--amber); }

.analytics-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, .8fr); gap: 14px; margin-top: 14px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 25px rgba(26,53,45,.03); }
.panel-heading { padding: 20px 22px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.02em; }
.live-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.live-label i { width: 7px; height: 7px; border-radius: 50%; background: #61a94b; box-shadow: 0 0 0 4px #eaf5e6; }
.chart-panel { min-height: 278px; }
.bar-chart { height: 202px; padding: 27px 22px 17px; display: flex; align-items: stretch; gap: 8px; }
.bar-column { min-width: 8px; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; position: relative; }
.bar-column b { min-height: 14px; color: #72807b; font-size: 9px; font-weight: 700; opacity: 0; transition: opacity .2s; }
.bar-column:hover b { opacity: 1; }
.bar { width: min(28px, 75%); min-height: 3px; border-radius: 5px 5px 2px 2px; background: var(--forest); transition: height .35s ease, background .2s; }
.bar-column:hover .bar { background: #2e6a59; }
.bar-column small { color: #93a09c; font-size: 9px; white-space: nowrap; }
.status-panel { padding-bottom: 18px; }
.status-breakdown { padding: 22px; display: grid; gap: 16px; }
.status-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; font-size: 12px; }
.status-row label { color: #65716d; display: flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #7b8a85; }
.status-dot.status-succeeded { background: #5aa26d; }
.status-dot.status-low_confidence { background: #d29a46; }
.status-dot.status-failed, .status-dot.status-cancelled { background: #d6726c; }
.status-dot.status-processing { background: #6e9fc2; }
.status-row strong { font-size: 12px; }
.status-track { grid-column: 1 / -1; height: 4px; border-radius: 99px; overflow: hidden; background: #edf0ee; }
.status-track i { display: block; height: 100%; border-radius: inherit; background: var(--forest); }

.interactions-panel { margin-top: 14px; overflow: hidden; }
.table-heading { align-items: end; padding-bottom: 16px; }
.result-count { color: var(--muted); font-size: 11px; }
.filters { padding: 0 22px 16px; display: grid; grid-template-columns: minmax(220px, 1fr) 180px 170px auto; gap: 9px; }
.filters input, .filters select { width: 100%; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: #fafbf9; color: var(--ink); outline: none; font-size: 12px; }
.filters input:focus, .filters select:focus { border-color: #7d9c92; box-shadow: 0 0 0 3px #edf3f0; }
.filters select { padding: 0 32px 0 11px; }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 11px; top: 9px; width: 18px; color: #8c9995; }
.search-field input { padding: 0 12px 0 37px; }
.review-toggle { height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; display: flex; align-items: center; gap: 8px; color: #5f6d68; background: #fafbf9; font-size: 11px; white-space: nowrap; }
.review-toggle input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.review-toggle span { width: 28px; height: 16px; padding: 2px; border-radius: 99px; background: #cdd4d0; }
.review-toggle span::after { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: white; transition: transform .2s; }
.review-toggle input:checked + span { background: var(--forest); }
.review-toggle input:checked + span::after { transform: translateX(12px); }
.table-wrap { border-top: 1px solid var(--line); min-height: 280px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: 11px 15px; color: #8a9692; background: #fafbf9; border-bottom: 1px solid var(--line); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-align: left; text-transform: uppercase; }
th:nth-child(1) { width: 13%; } th:nth-child(2) { width: 24%; } th:nth-child(3) { width: 31%; } th:nth-child(4) { width: 13%; } th:nth-child(5) { width: 8%; } th:nth-child(6) { width: 11%; }
td { padding: 14px 15px; border-bottom: 1px solid #e8ece9; color: #36423e; font-size: 11px; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: #f8faf7; }
tbody tr:focus-visible { outline: 2px solid #658b7e; outline-offset: -2px; }
.user-cell { display: flex; align-items: center; gap: 8px; color: #44514d; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.user-avatar { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border-radius: 9px; color: var(--forest); background: var(--mint-soft); font-family: Inter, sans-serif; font-weight: 800; }
.clamp { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.45; }
.answer-preview { color: #66716d; }
.status-pill, .detail-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; color: #53615c; background: #edf1ef; font-size: 9px; font-weight: 750; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-succeeded { color: #357347; background: #e8f5e9; }
.status-low_confidence { color: var(--amber); background: var(--amber-soft); }
.status-failed, .status-cancelled { color: var(--red); background: var(--red-soft); }
.status-processing { color: var(--blue); background: var(--blue-soft); }
.review-flag { margin-left: 5px; color: var(--amber); font-weight: 900; }
.time-cell { font-variant-numeric: tabular-nums; color: #56635f; }
.date-cell { color: #77847f; font-variant-numeric: tabular-nums; }
.empty-state { min-height: 280px; padding: 50px 20px; display: grid; place-items: center; text-align: center; align-content: center; }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px; border-radius: 50%; background: var(--mint-soft); color: var(--forest); font-weight: 900; }
.empty-state h3 { margin-bottom: 5px; font-size: 15px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }
.pagination { min-height: 54px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #7e8a86; font-size: 10px; }
.pagination div { display: flex; gap: 7px; }
.pagination button { padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; color: #56635f; background: white; font-size: 10px; }
.pagination button:disabled { opacity: .4; cursor: default; }

dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(8,26,21,.54); backdrop-filter: blur(3px); }
.login-dialog { width: min(420px, calc(100vw - 28px)); border-radius: 18px; box-shadow: 0 25px 80px rgba(5,25,19,.3); }
.login-dialog form { padding: 34px; }
.login-mark { margin-bottom: 30px; }
.login-dialog h2 { margin: 7px 0 8px; font-size: 25px; letter-spacing: -.035em; }
.login-dialog p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-dialog label { display: grid; gap: 7px; margin-top: 24px; color: #56635f; font-size: 11px; font-weight: 700; }
.login-dialog input { height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.login-dialog input:focus { border-color: #77998e; box-shadow: 0 0 0 3px #edf3f0; }
.primary-button { width: 100%; height: 44px; margin-top: 18px; border: 0; border-radius: 9px; color: white; background: var(--forest); font-weight: 750; }
.primary-button:hover { background: #205346; }
.form-error { min-height: 17px; margin-top: 7px; color: var(--red); font-size: 11px; }

.detail-dialog { height: 100%; max-height: 100%; width: min(640px, 94vw); margin: 0 0 0 auto; background: white; }
.detail-dialog[open] { animation: slide-in .2s ease-out; }
@keyframes slide-in { from { transform: translateX(30px); opacity: .6; } }
.detail-shell { min-height: 100%; padding: 28px; overflow-y: auto; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.detail-header h2 { margin: 5px 0 0; font-size: 23px; letter-spacing: -.03em; }
.detail-header .icon-button { font-size: 25px; font-weight: 300; }
.detail-meta { margin: 20px 0; display: flex; flex-wrap: wrap; gap: 7px; }
.message-block { margin-top: 14px; padding: 17px 18px; border-radius: 13px; }
.message-block > span { display: block; margin-bottom: 9px; color: #6d7b76; font-size: 9px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.message-block > div { white-space: pre-wrap; font-size: 13px; line-height: 1.65; }
.question-block { background: #f0f4f1; }
.answer-block { border: 1px solid #dce7d3; background: #fbfdf8; }
.technical-details { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.technical-details h3 { font-size: 13px; }
.technical-details dl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.technical-details dl div { min-width: 0; }
.technical-details dt { color: #8a9692; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.technical-details dd { margin: 4px 0 0; overflow-wrap: anywhere; color: #394641; font-size: 11px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 20; max-width: 330px; padding: 11px 14px; border-radius: 9px; color: white; background: var(--forest-deep); font-size: 11px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: minmax(220px, 1fr) 160px 150px; }
  .review-toggle { grid-column: 1 / -1; width: max-content; }
  th:nth-child(5), td:nth-child(5) { display: none; }
}
@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 14px 18px; flex-direction: row; align-items: center; gap: 12px; }
  .brand { padding: 0; }
  .brand small, .primary-nav, .sidebar-note { display: none; }
  .logout-button { margin: 0 0 0 auto; }
  .main { padding: 24px 18px 40px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; }
  .period-switch { flex: 1; overflow-x: auto; }
  .period-switch button { flex: 1; }
  .analytics-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .review-toggle { grid-column: 1 / -1; }
  th:nth-child(1), td:nth-child(1), th:nth-child(6), td:nth-child(6) { display: none; }
  th:nth-child(2) { width: 31%; } th:nth-child(3) { width: 44%; } th:nth-child(4) { width: 25%; }
}
@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric-card { min-height: 128px; padding: 15px; }
  .metric-value { font-size: 29px; }
  .filters { grid-template-columns: 1fr; }
  .search-field, .review-toggle { grid-column: auto; width: 100%; }
  .live-label { display: none; }
  .bar-chart { gap: 4px; padding-left: 13px; padding-right: 13px; }
  .bar-column small { transform: rotate(-45deg); margin-bottom: 5px; }
  th:nth-child(3), td:nth-child(3) { display: none; }
  th:nth-child(2) { width: 65%; } th:nth-child(4) { width: 35%; }
  .detail-shell { padding: 22px 18px; }
  .technical-details dl { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
