:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #182026;
  --muted: #64727d;
  --line: #d9e0e5;
  --accent: #0f766e;
  --accent-2: #8b5e34;
  --danger: #b42318;
  --warn-bg: #fff4e5;
  --warn-line: #e08a1e;
  --soft: #eef3f4;
  --shadow: 0 1px 2px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(160px, 220px) 96px auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  width: 100%;
  padding: 0 10px;
}

button {
  padding: 0 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.status {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-2);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.quota-panel {
  margin: 18px 0 0;
}

.quota-panel .panel-heading h2 {
  font-size: 18px;
}

#quotaState.quota-warn-badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: #92590f;
  font-size: 12px;
  font-weight: 700;
}

.quota-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.quota-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.quota-card.warn {
  background: var(--warn-bg);
  border-color: var(--warn-line);
}

.quota-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.quota-card-top strong {
  display: block;
  font-size: 15px;
}

.quota-kind {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.quota-headroom {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.quota-card.warn .quota-headroom {
  color: var(--danger);
}

.quota-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.quota-fill {
  width: var(--width);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.quota-fill.danger {
  background: var(--danger);
}

.quota-fill.unknown {
  width: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--line),
    var(--line) 6px,
    transparent 6px,
    transparent 12px
  );
}

.quota-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.quota-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
}

.metric span,
.metric small,
.panel-heading span,
.bar-meta,
td {
  color: var(--muted);
}

.metric span,
.panel-heading span,
.bar-meta {
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.metric small {
  align-self: end;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bars {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.bar-fill {
  width: var(--width);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}

.events-panel {
  grid-column: 1 / -1;
  margin-bottom: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--ink);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  min-width: 72px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.pill.error {
  background: #ffe8e4;
  color: var(--danger);
}

.empty {
  padding: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.lock-notice {
  margin: 18px 0 0;
  text-align: center;
  padding: 40px 16px;
}

.lock-notice h2 {
  font-size: 18px;
}

.lock-notice p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.clips-panel {
  margin-bottom: 24px;
}

.clip-row {
  cursor: pointer;
}

.clip-row:hover {
  background: var(--soft);
}

.clip-toggle {
  width: 28px;
  color: var(--muted);
}

.chevron {
  display: inline-block;
  font-size: 10px;
  transition: transform 0.15s ease;
}

.clip-row.open .chevron {
  transform: rotate(90deg);
}

.clip-label {
  font-weight: 700;
  color: var(--ink);
}

.clip-detail > td {
  padding: 0 8px 12px 36px;
  border-top: none;
}

.clip-calls {
  display: grid;
  gap: 6px;
  padding: 4px 0;
}

.clip-call {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 88px 88px;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--soft);
  font-size: 13px;
}

.clip-call-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 600;
}

.clip-call-latency,
.clip-call-cost {
  text-align: right;
  color: var(--muted);
  font-weight: 600;
}

.clip-calls-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.clip-calls-empty {
  padding: 8px 0;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls,
  .metrics,
  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .metric strong {
    font-size: 26px;
  }
}
