:root {
  color-scheme: dark;
  --background: #0d1219;
  --surface: #161f2a;
  --surface-2: #202c39;
  --text: #f5f7fa;
  --muted: #aebdcb;
  --accent: #67b4ff;
  --accent-contrast: #06111c;
  --success: #69d29a;
  --warning: #f7c863;
  --danger: #ff7c86;
  --border: #35485c;
  --font: system-ui, sans-serif;
  --font-size: 16px;
  --panel-radius: 14px;
  --control-radius: 8px;
  --cell-padding-y: 0.55rem;
}

:root[data-theme="light"] {
  color-scheme: light;
  --background: #eef3f8;
  --surface: #ffffff;
  --surface-2: #e8f0f7;
  --text: #17212b;
  --muted: #526477;
  --accent: #1769aa;
  --accent-contrast: #ffffff;
  --success: #147a46;
  --warning: #9a5b00;
  --danger: #b4232c;
  --border: #b9c7d4;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--background);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--font-size);
  line-height: 1.45;
}

body { margin: 0; }

button, input, select { font: inherit; }

button, select, input {
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: var(--surface-2);
  color: var(--text);
}

input, select { padding: 0.55rem 0.65rem; }

button, .button { cursor: pointer; }

[hidden] { display: none !important; }

.app-header,
main {
  width: min(1760px, calc(100% - 2rem));
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.6rem 0 1rem;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.8rem, 4vw, 3rem); }
h2 { margin-bottom: 0.35rem; }

.eyebrow {
  margin-bottom: 0.2rem;
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.identity { display: grid; justify-items: end; color: var(--muted); }
.identity strong { color: var(--text); }

main { padding-bottom: 5rem; }

.panel {
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.toolbar,
.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.8rem;
  padding: 1rem;
}

label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.86rem; }
.client-control { min-width: min(28rem, 100%); flex: 1; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.button.primary { background: var(--accent); color: var(--accent-contrast); }
.button.quiet { border-color: var(--border); }
.button:disabled { cursor: not-allowed; opacity: 0.5; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.summary { margin-top: 0.75rem; align-items: center; }
.summary > div { display: flex; gap: 0.35rem; align-items: baseline; }
.summary strong { font-size: 1.15rem; }
.save-state { margin-left: auto; color: var(--muted); }

.status-pill {
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.notice {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.notice.success { border-color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.progress-panel { display: grid; gap: 0.5rem; margin-top: 0.75rem; padding: 1rem; }
progress { width: 100%; accent-color: var(--accent); }
.empty { margin-top: 0.75rem; padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); }

.groups { display: grid; gap: 1rem; margin-top: 1rem; }
.group { min-width: 0; overflow: hidden; }
.group-header {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(15rem, 28rem) auto auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.group-path { overflow-wrap: anywhere; }
.group-total { white-space: nowrap; }
.group-total strong { color: var(--success); }
.icon-button { width: 2rem; height: 2rem; padding: 0; border-color: var(--border); font-size: 1.2rem; }

.grid-scroll { overflow-x: auto; }
table { width: 100%; min-width: 1180px; border-collapse: collapse; }
th, td { padding: var(--cell-padding-y) 0.6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 0.74rem; letter-spacing: 0.04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td.model-cell { min-width: 16rem; }
.model-name { display: block; font-weight: 750; }
.model-path { display: block; max-width: 28rem; overflow: hidden; color: var(--muted); font-size: 0.74rem; text-overflow: ellipsis; white-space: nowrap; }
.compact-input { width: 5.3rem; }
.port-select { min-width: 8rem; }
.hybrid-control, .limits-control { display: flex; align-items: center; gap: 0.35rem; }
.hybrid-control input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }
.raw-value { color: var(--muted); }
.billed-value { color: var(--success); font-weight: 800; }
.status-ready { color: var(--success); }
.status-missing_cache { color: var(--warning); }
.status-error { color: var(--danger); }
.status-missing_cache, .status-error { min-width: 9rem; }
.status-missing_cache > span, .status-error > span { display: block; margin-bottom: 0.35rem; }
.mini-button { min-height: 1.8rem; padding: 0.2rem 0.45rem; font-size: 0.72rem; }
.lyt-port { color: var(--accent); font-weight: 800; }
.lyt-source { color: var(--muted); }

.center-card {
  width: min(560px, calc(100% - 2rem));
  margin: 12vh auto;
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
}
.fine-print { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
.muted-copy { color: var(--muted); }

dialog {
  width: min(560px, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.settings-form { display: grid; gap: 1rem; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; }
.settings-form fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; border: 1px solid var(--border); border-radius: 10px; }
.settings-form input[type="color"] { width: 100%; min-height: 2.4rem; padding: 0.2rem; }
.settings-form .actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

@media (max-width: 900px) {
  .group-header { grid-template-columns: 1fr auto; }
  .group-header label { grid-column: 1 / -1; }
  .app-header { align-items: start; }
}

@media (max-width: 620px) {
  .app-header { display: grid; }
  .identity { justify-items: start; }
  .toolbar > *, .summary > * { width: 100%; }
  .save-state { margin-left: 0; }
  .settings-form fieldset { grid-template-columns: 1fr; }
}
