:root {
  color-scheme: light;
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-soft: #f5f5f6;
  --text: #18181b;
  --muted: #71717a;
  --subtle: #a1a1aa;
  --line: rgba(24, 24, 27, 0.07);
  --line-strong: rgba(24, 24, 27, 0.11);
  --primary: #8b7cf6;
  --primary-soft: rgba(139, 124, 246, 0.12);
  --success: #2f8f5b;
  --warning: #b7791f;
  --danger: #c2410c;
  --radius-lg: 16px;
  --radius-md: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f10;
  --panel: #171719;
  --panel-soft: #202023;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --line: rgba(244, 244, 245, 0.08);
  --line-strong: rgba(244, 244, 245, 0.14);
  --primary-soft: rgba(139, 124, 246, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
}

.login-brand {
  padding: 0;
}

.login-submit {
  justify-content: center;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.upload-form,
.form-grid {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand,
.operator,
.topbar,
.topbar-actions,
.search-box,
.nav-item,
.primary-button,
.icon-button,
.row-between,
.status-pill {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand strong,
.operator strong {
  display: block;
  font-size: 14px;
  line-height: 1.2;
}

.brand span,
.operator span,
.eyebrow,
.muted,
.table-wrap td,
.card-note {
  color: var(--muted);
}

.brand span,
.operator span {
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item.is-active .material-symbols-rounded {
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
}

.operator {
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.main-panel {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 32px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.topbar-actions {
  gap: 10px;
}

.search-box {
  width: min(34vw, 360px);
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.icon-button,
.primary-button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 38px;
  justify-content: center;
}

.primary-button {
  gap: 7px;
  padding: 0 14px;
  background: var(--text);
  color: var(--bg);
}

.primary-button[hidden] {
  display: none;
}

.ghost-button {
  padding: 0 12px;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.ghost-button:disabled {
  color: var(--subtle);
  cursor: not-allowed;
  opacity: 0.72;
}

.content {
  padding: 32px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.two-col {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  margin-top: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.state-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.state-card p {
  margin-bottom: 0;
  line-height: 1.6;
}

.metric-card {
  min-height: 126px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.metric-value {
  margin: 14px 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
}

.delta {
  font-size: 12px;
  color: var(--success);
}

.delta.down {
  color: var(--warning);
}

.row-between {
  justify-content: space-between;
  gap: 16px;
}

.section-header {
  margin-bottom: 14px;
}

.section-header p,
.card-note {
  margin-bottom: 0;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

.empty-cell {
  padding: 28px 10px;
  color: var(--subtle);
  text-align: center;
}

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

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--subtle);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  width: fit-content;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.status-pill.primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.list-stack {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.list-item p {
  margin-bottom: 0;
}

.page-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}

.page-hint strong {
  color: var(--text);
  white-space: nowrap;
}

.detail-panel {
  align-self: start;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

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

.detail-label {
  display: block;
  margin-bottom: 5px;
  color: var(--subtle);
  font-size: 12px;
  font-weight: 600;
}

.detail-stack p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-metrics > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.summary-metrics strong {
  font-size: 18px;
}

.chart-bars {
  height: 240px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 28px;
}

.bar {
  flex: 1;
  min-width: 24px;
  border-radius: 12px 12px 4px 4px;
  background: var(--primary);
  opacity: 0.82;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

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

.field input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--bg);
  color: var(--text);
}

@media (max-width: 1100px) {
  .metrics-grid,
  .two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
  }

  .content {
    padding: 20px;
  }

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