:root {
  --bg: #071019;
  --surface: #0d1824;
  --surface-raised: #122131;
  --surface-soft: #17283a;
  --line: #24384b;
  --line-bright: #365169;
  --text: #e9f1f7;
  --muted: #8fa4b7;
  --cyan: #53d4c8;
  --cyan-soft: rgba(83, 212, 200, .14);
  --blue: #6da8ff;
  --violet: #a58bfa;
  --amber: #f0b35b;
  --red: #f27878;
  --green: #6ed39d;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background:
  radial-gradient(circle at 85% -20%, rgba(83, 212, 200, .11), transparent 38rem),
  radial-gradient(circle at -10% 35%, rgba(109, 168, 255, .08), transparent 32rem), var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
code { color: var(--cyan); }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 60px; }
.topbar { min-height: 104px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(54, 81, 105, .55); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 1.15rem; letter-spacing: -.02em; }
h3 { font-size: .98rem; }
.eyebrow { margin-bottom: 6px; color: var(--cyan); font-size: .68rem; font-weight: 750; letter-spacing: .19em; }
.connection { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .86rem; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(143, 164, 183, .08); }
.connection-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(110, 211, 157, .1); }
.connection-dot.error { background: var(--red); box-shadow: 0 0 0 5px rgba(242, 120, 120, .1); }

.auth-panel { margin: 12vh auto 0; width: min(780px, 100%); padding: clamp(28px, 5vw, 52px); display: grid; grid-template-columns: 1.05fr .95fr; gap: 42px; align-items: center; background: linear-gradient(135deg, rgba(18, 33, 49, .96), rgba(13, 24, 36, .96)); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-panel p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.auth-form label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.input-row { display: flex; gap: 8px; }
input, select { min-height: 40px; color: var(--text); background: rgba(7, 16, 25, .68); border: 1px solid var(--line); border-radius: 8px; outline: 0; transition: border-color .15s, box-shadow .15s; }
input { width: 100%; padding: 0 12px; }
select { padding: 0 34px 0 12px; }
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(83, 212, 200, .12); }
.form-error { min-height: 20px; margin: 8px 0 0 !important; color: var(--red) !important; font-size: .77rem; }

.button, .icon-button { border: 1px solid transparent; border-radius: 8px; color: var(--text); background: var(--surface-soft); transition: transform .12s, border-color .12s, background .12s; }
.button { min-height: 38px; padding: 0 15px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.button:hover, .icon-button:hover { transform: translateY(-1px); border-color: var(--line-bright); }
.button.primary { color: #061512; background: var(--cyan); }
.button.primary:hover { background: #72e2d8; }
.button.subtle { border-color: var(--line); background: transparent; }
.button:disabled { cursor: wait; opacity: .6; transform: none; }

.dashboard { padding-top: 28px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric-card { min-height: 132px; padding: 19px 20px; display: flex; flex-direction: column; background: linear-gradient(150deg, var(--surface-raised), var(--surface)); border: 1px solid var(--line); border-radius: 12px; }
.metric-card > span { color: var(--muted); font-size: .76rem; font-weight: 650; }
.metric-card strong { margin: auto 0 4px; font-size: clamp(1.65rem, 3vw, 2.35rem); font-weight: 680; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.metric-card strong i { color: var(--line-bright); font-style: normal; font-weight: 400; }
.metric-card small { color: var(--muted); font-size: .7rem; }

.panel { margin-top: 14px; padding: 22px; background: rgba(13, 24, 36, .9); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.audit-summary { margin-top: 6px; color: var(--muted); font-size: .7rem; }

.request-heading { align-items: end; }
.filters { display: flex; gap: 8px; width: min(480px, 48%); }
.filters input { min-width: 180px; }
.table-wrap { position: relative; margin: 18px -22px -22px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th { padding: 10px 17px; color: var(--muted); background: rgba(7, 16, 25, .6); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .66rem; text-align: left; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 14px 17px; border-bottom: 1px solid rgba(36, 56, 75, .55); color: #c8d5df; font-size: .76rem; vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(83, 212, 200, .035); }
tbody tr:last-child td { border-bottom: 0; }
.request-link { padding: 0; color: var(--cyan); background: transparent; border: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .73rem; }
.request-link:hover { text-decoration: underline; }
.cell-main { display: block; color: var(--text); font-weight: 620; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: .68rem; }
.truncation-badge { color: var(--amber); font-weight: 620; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid; border-radius: 999px; font-size: .67rem; font-weight: 700; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.processing { color: var(--blue); border-color: rgba(109, 168, 255, .28); background: rgba(109, 168, 255, .08); }
.status.succeeded { color: var(--green); border-color: rgba(110, 211, 157, .26); background: rgba(110, 211, 157, .07); }
.status.failed, .status.cancelled { color: var(--red); border-color: rgba(242, 120, 120, .26); background: rgba(242, 120, 120, .07); }
.empty-state { padding: 58px 20px; color: var(--muted); text-align: center; font-size: .8rem; }
.added-cell { min-width: 108px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.added-grid { display: flex; flex-direction: column; gap: 1px; line-height: 1.38; color: #c8d5df; }
.added-total { color: var(--text); font-weight: 720; }
.added-pair { display: flex; gap: 10px; color: var(--muted); }
.added-pair span { min-width: 0; }
.added-grid .num { color: var(--text); }
.estimate-badge { margin-left: 5px; padding: 1px 3px; color: var(--amber); border: 1px solid rgba(240, 179, 91, .3); border-radius: 3px; font: 600 .55rem/1 ui-sans-serif, sans-serif; }
.detail-added-grid .added-grid { max-width: 240px; font-size: .86rem; }

.detail-dialog { width: min(1120px, calc(100% - 32px)); height: min(88vh, 920px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line-bright); border-radius: 15px; box-shadow: var(--shadow); }
.detail-dialog::backdrop { background: rgba(2, 8, 13, .78); backdrop-filter: blur(5px); }
.dialog-shell { min-height: 100%; display: flex; flex-direction: column; }
.dialog-header { padding: 21px 24px 17px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.detail-meta { margin: 6px 0 0; color: var(--muted); font-size: .73rem; }
.icon-button { width: 34px; height: 34px; font-size: 1.4rem; line-height: 1; }
.copy-actions { padding: 10px 24px; display: flex; justify-content: flex-end; gap: 8px; border-bottom: 1px solid var(--line); background: rgba(7, 16, 25, .45); }
.detail-content { padding: 22px 24px 34px; overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.detail-stat { padding: 13px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 8px; }
.detail-stat span { display: block; color: var(--muted); font-size: .66rem; }
.detail-stat strong { display: block; margin-top: 5px; font-size: 1rem; overflow-wrap: anywhere; }
.detail-section { margin-top: 24px; }
.detail-section h3 { margin-bottom: 10px; }
.detail-section-count { color: var(--muted); font-weight: 500; }
.detail-list { display: grid; gap: 8px; }
.detail-entry { padding: 12px 14px; background: rgba(7, 16, 25, .55); border: 1px solid var(--line); border-radius: 8px; }
.detail-entry-head { display: flex; justify-content: space-between; gap: 16px; font-size: .72rem; }
.detail-entry-head strong { color: var(--text); }
.detail-entry-head time { color: var(--muted); }
.detail-entry p { margin: 7px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.detail-entry pre, .payload-preview { margin: 9px 0 0; padding: 10px; max-height: 210px; overflow: auto; color: #bad0df; background: #050b11; border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; font: .69rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.timeline { position: relative; display: grid; gap: 0; }
.timeline-entry { position: relative; padding: 0 0 17px 24px; }
.timeline-entry::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: -7px; width: 1px; background: var(--line); }
.timeline-entry:last-child::before { display: none; }
.timeline-entry::after { content: ""; position: absolute; left: 1px; top: 5px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); }
.timeline-entry.error::after { background: var(--red); }
.timeline-entry.warn::after { background: var(--amber); }
.timeline-entry header { display: flex; gap: 8px; align-items: baseline; }
.timeline-entry code { font-size: .7rem; }
.timeline-entry time { color: var(--muted); font-size: .65rem; }
.timeline-entry p { margin: 4px 0 0; color: #b9c8d3; font-size: .72rem; }
.empty-inline { color: var(--muted); font-size: .75rem; }
.models-panel { margin-top: 14px; }
.models-list { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; color: var(--text); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 999px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .73rem; }
.model-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.models-empty { color: var(--muted); font-size: .8rem; }

.copy-fallback { position: fixed; opacity: 0; pointer-events: none; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 18px); padding: 10px 15px; color: var(--text); background: var(--surface-soft); border: 1px solid var(--line-bright); border-radius: 8px; box-shadow: var(--shadow); font-size: .75rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 22px, 1480px); }
  .topbar { min-height: 86px; }
  .auth-panel { margin-top: 7vh; grid-template-columns: 1fr; gap: 24px; padding: 25px; }
  .input-row { flex-direction: column; }
  .metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 114px; }
  .panel { padding: 17px; }
  .request-heading { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; flex-direction: column; }
  .filters input { min-width: 0; }
  .table-wrap { margin-left: -17px; margin-right: -17px; }
  .copy-actions { padding: 10px 16px; justify-content: stretch; flex-wrap: wrap; }
  .copy-actions .button { flex: 1; }
  .dialog-header, .detail-content { padding-left: 16px; padding-right: 16px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}
