* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --surface: #121417;
  --surface-2: #171a1f;
  --surface-3: #1d2128;
  --line: #2a3038;
  --line-soft: #20252c;
  --text: #edf1f6;
  --muted: #98a2ad;
  --subtle: #6f7a86;
  --accent: #34d399;
  --accent-2: #38bdf8;
  --warn: #f59e0b;
  --danger: #ef4444;
  --button: #242a32;
  --button-hover: #2d3540;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

html {
  scroll-behavior: smooth;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  display: grid;
  align-items: center;
  gap: 18px;
  grid-template-columns: minmax(210px, 280px) minmax(0, 1fr) auto;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 20, 23, 0.96);
  backdrop-filter: blur(14px);
}

.topbar > *,
.main > *,
.hero-grid,
.workspace-grid,
.primary-column,
.side-column,
.split-grid,
.records-panel,
.table-wrap {
  min-width: 0;
}

.brand {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-kicker,
.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand strong {
  overflow: hidden;
  color: var(--text);
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span:not(.brand-kicker),
.muted {
  color: var(--muted);
}

.nav {
  justify-self: center;
  width: 100%;
  max-width: 420px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #0f1115;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  min-width: 64px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: #c9d2dc;
  font-size: 14px;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  background: var(--surface-3);
}

.top-actions,
.button-group,
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.status-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid rgba(52, 211, 153, 0.22);
  border-radius: 8px;
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.09);
  white-space: nowrap;
}

.status-chip i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

.secondary-button,
.primary-button {
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  background: var(--button);
  white-space: nowrap;
}

.primary-button {
  color: #06110c;
  background: var(--accent);
  font-weight: 700;
}

.secondary-button {
  border-color: var(--line);
}

.primary-button:hover {
  background: #5ee6b2;
}

.secondary-button:hover {
  background: var(--button-hover);
}

.full-button {
  width: 100%;
}

.main {
  width: 100%;
  max-width: 1380px;
  overflow: hidden;
  margin: 0 auto;
  padding: 20px;
}

.hero-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  align-items: stretch;
  margin-bottom: 16px;
}

.hero-copy {
  min-height: 190px;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(52, 211, 153, 0.13), transparent 38%),
    linear-gradient(90deg, #14170f, #101418 60%, #111417);
  box-shadow: var(--shadow);
}

.hero-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.hero-copy p {
  max-width: 700px;
  margin: 0;
  color: #b5bdc8;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.panel,
.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel {
  padding: 16px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel h2,
.panel h3 {
  margin: 2px 0 0;
  font-size: 17px;
  line-height: 1.25;
}

.entitlement-panel {
  min-height: 190px;
  background: linear-gradient(180deg, #16191e, #111317);
}

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

.metric {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 14px;
  background: linear-gradient(180deg, #171a1f, #111317);
}

.metric span,
.metric small,
.detail-item span,
.chart-panel > span {
  color: var(--muted);
}

.metric strong {
  overflow: hidden;
  color: var(--text);
  font-size: 31px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-risk strong {
  color: var(--warn);
}

.workspace-grid {
  display: grid;
  align-items: start;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.primary-column,
.side-column {
  display: grid;
  gap: 16px;
}

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

.records-panel {
  margin-top: 16px;
}

.toolbar-form,
.stack-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 9px;
}

.stack-form {
  align-items: stretch;
  flex-direction: column;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.compact {
  width: min(160px, 100%);
}

.field.small-field {
  width: 104px;
}

.field.search-field {
  width: min(280px, 100%);
}

.field span,
.check-field span {
  color: #a8b2bd;
  font-size: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #343b45;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  background: #0d0f13;
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(56, 189, 248, 0.85);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.check-field {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d0f13;
}

.detail-box {
  display: grid;
  gap: 10px;
  overflow: auto;
  min-width: 0;
  max-width: 100%;
}

.detail-grid {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--line-soft);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-item {
  min-width: 0;
  padding: 11px;
  background: #101216;
}

.detail-item span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}

.prewrap {
  white-space: pre-wrap;
  word-break: break-word;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.compact-table {
  max-height: 280px;
  overflow-x: hidden;
}

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

.compact-table .table {
  min-width: 100%;
}

.table th,
.table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

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

.table th {
  position: sticky;
  z-index: 1;
  top: 0;
  color: #b4beca;
  background: #15181d;
  font-size: 12px;
  font-weight: 700;
}

.table td {
  color: #d9e0e8;
}

.side-column .table th,
.side-column .table td {
  padding: 8px 7px;
  font-size: 12px;
  white-space: normal;
}

.side-column .table .secondary-button {
  min-height: 30px;
  padding: 0 9px;
}

.table tbody tr:hover td {
  background: rgba(56, 189, 248, 0.05);
}

.alert-pill {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #cffafe;
  background: rgba(56, 189, 248, 0.2);
  font-size: 12px;
  white-space: nowrap;
}

.alert-pill.high {
  color: #fee2e2;
  background: rgba(239, 68, 68, 0.22);
}

.alert-pill.low {
  color: #d1fae5;
  background: rgba(52, 211, 153, 0.18);
}

.risk-panel {
  border-color: rgba(245, 158, 11, 0.28);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), var(--surface) 55%);
}

.risk-panel p {
  margin: 0;
  line-height: 1.7;
}

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

.login-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.error {
  min-height: 20px;
  margin: 10px 0;
  color: #fca5a5;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #1a1f26;
  box-shadow: var(--shadow);
}
.toast[hidden] {
  display: none;
}

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

.candidate-button {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101216;
  text-align: left;
}

.candidate-button strong {
  display: block;
  margin-bottom: 4px;
}

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

.chart-panel {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #101216;
}

.chart-panel > span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
}

.wide-chart {
  grid-column: 1 / -1;
}

.line-chart {
  width: 100%;
  height: 184px;
  color: var(--accent-2);
  border: 1px solid #26303a;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.10), rgba(52, 211, 153, 0.03)),
    #0b1115;
}

.chart-meta {
  display: grid;
  align-items: center;
  gap: 8px;
  grid-template-columns: 1fr auto 1fr;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chart-meta span:last-child {
  text-align: right;
}

.bar-row {
  display: grid;
  align-items: center;
  gap: 8px;
  grid-template-columns: minmax(52px, 92px) minmax(0, 1fr) minmax(28px, auto);
  min-height: 28px;
  color: #dbeafe;
}

.bar-row span,
.bar-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #262c34;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.chart-empty {
  min-height: 36px;
  display: grid;
  align-items: center;
}

.positive {
  color: #86efac;
}

.negative {
  color: #fca5a5;
}

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

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .nav {
    justify-self: stretch;
    max-width: 100%;
    overflow-x: auto;
  }

  .top-actions {
    justify-content: space-between;
  }

  .hero-grid,
  .workspace-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  .main {
    padding: 12px;
  }

  .topbar {
    padding: 10px 12px;
  }

  .hero-copy {
    min-height: 160px;
    padding: 18px;
  }

  .hero-copy h1 {
    font-size: 32px;
  }

  .metric-strip,
  .detail-grid,
  .chart-grid,
  .form-row {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 13px;
  }

  .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-form {
    align-items: stretch;
    flex-direction: column;
  }

  .field.compact,
  .field.small-field,
  .field.search-field,
  .toolbar-form .primary-button,
  .toolbar-form .secondary-button {
    width: 100%;
  }
}

/* Unified shell theme pass. */
:root,
:is(html[data-theme="dark"], html.theme-dark) {
  --scheme: dark;
  --bg: #0b0c0f;
  --surface: #121417;
  --surface-2: #171a1f;
  --surface-3: #1d2128;
  --line: #2a3038;
  --line-soft: #20252c;
  --text: #edf1f6;
  --muted: #98a2ad;
  --subtle: #6f7a86;
  --accent: #34d399;
  --accent-2: #38bdf8;
  --warn: #f59e0b;
  --danger: #ef4444;
  --button: #242a32;
  --button-hover: #2d3540;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --topbar-bg: rgba(18, 20, 23, 0.96);
  --nav-bg: #0f1115;
  --nav-text: #c9d2dc;
  --nav-active-bg: #1d2128;
  --hero-bg:
    linear-gradient(135deg, rgba(52, 211, 153, 0.13), transparent 38%),
    linear-gradient(90deg, #14170f, #101418 60%, #111417);
  --hero-copy: #b5bdc8;
  --panel-gradient: linear-gradient(180deg, #171a1f, #111317);
  --panel-gradient-soft: linear-gradient(180deg, #16191e, #111317);
  --field-label: #a8b2bd;
  --field-border: #343b45;
  --field-bg: #0d0f13;
  --focus-border: rgba(56, 189, 248, 0.85);
  --focus-ring: rgba(56, 189, 248, 0.12);
  --detail-bg: #101216;
  --table-head-bg: #15181d;
  --table-head-text: #b4beca;
  --table-cell-text: #d9e0e8;
  --table-hover-bg: rgba(56, 189, 248, 0.05);
  --info-text: #cffafe;
  --info-bg: rgba(56, 189, 248, 0.2);
  --danger-text: #fee2e2;
  --danger-bg: rgba(239, 68, 68, 0.22);
  --success-text: #d1fae5;
  --success-bg: rgba(52, 211, 153, 0.18);
  --primary-text: #06110c;
  --primary-hover: #5ee6b2;
  --risk-bg: linear-gradient(180deg, rgba(245, 158, 11, 0.08), var(--surface) 55%);
  --toast-bg: #1a1f26;
  --chart-bg: #101216;
  --chart-border: #26303a;
  --line-chart-bg:
    linear-gradient(180deg, rgba(56, 189, 248, 0.10), rgba(52, 211, 153, 0.03)),
    #0b1115;
  --bar-track: #262c34;
  --positive-text: #86efac;
  --negative-text: #fca5a5;
}

:is(html[data-theme="light"], html.theme-light) {
  --scheme: light;
  --bg: #eef5fc;
  --surface: #ffffff;
  --surface-2: #f7fbff;
  --surface-3: #e8f2ff;
  --line: #d7e4f2;
  --line-soft: #e4edf7;
  --text: #172337;
  --muted: #637990;
  --subtle: #8192a7;
  --accent: #0d9f68;
  --accent-2: #2477d8;
  --warn: #b87500;
  --danger: #d43b47;
  --button: #ffffff;
  --button-hover: #eef6ff;
  --shadow: 0 12px 30px rgba(30, 70, 115, 0.09);
  --topbar-bg: rgba(255, 255, 255, 0.96);
  --nav-bg: #f7fbff;
  --nav-text: #49637d;
  --nav-active-bg: #e8f2ff;
  --hero-bg:
    linear-gradient(135deg, rgba(13, 159, 104, 0.11), transparent 38%),
    linear-gradient(90deg, #ffffff, #f6fbff 62%, #eef6ff);
  --hero-copy: #5f748b;
  --panel-gradient: linear-gradient(180deg, #ffffff, #f7fbff);
  --panel-gradient-soft: linear-gradient(180deg, #ffffff, #f3f8ff);
  --field-label: #657b92;
  --field-border: #cbd9ea;
  --field-bg: #ffffff;
  --focus-border: rgba(36, 119, 216, 0.82);
  --focus-ring: rgba(36, 119, 216, 0.14);
  --detail-bg: #ffffff;
  --table-head-bg: #f2f7fd;
  --table-head-text: #52677e;
  --table-cell-text: #1d3048;
  --table-hover-bg: rgba(36, 119, 216, 0.06);
  --info-text: #075f78;
  --info-bg: rgba(36, 119, 216, 0.12);
  --danger-text: #b4232f;
  --danger-bg: rgba(212, 59, 71, 0.12);
  --success-text: #08734f;
  --success-bg: rgba(13, 159, 104, 0.12);
  --primary-text: #ffffff;
  --primary-hover: #12b981;
  --risk-bg: linear-gradient(180deg, rgba(184, 117, 0, 0.08), var(--surface) 55%);
  --toast-bg: #ffffff;
  --chart-bg: #ffffff;
  --chart-border: #d5e2f0;
  --line-chart-bg:
    linear-gradient(180deg, rgba(36, 119, 216, 0.09), rgba(13, 159, 104, 0.04)),
    #f8fbff;
  --bar-track: #dfe9f5;
  --positive-text: #0b8f55;
  --negative-text: #c93645;
}

:root {
  color-scheme: var(--scheme);
}

html,
body {
  background: var(--bg);
  color: var(--text);
}

.topbar {
  border-bottom-color: var(--line);
  background: var(--topbar-bg);
}

.brand strong,
.panel h2,
.panel h3,
.metric strong,
.detail-item,
.login-card h1,
.candidate-button strong {
  color: var(--text);
}

.brand span:not(.brand-kicker),
.muted,
.metric span,
.metric small,
.detail-item span,
.chart-panel > span,
.field span,
.check-field span {
  color: var(--muted);
}

.nav {
  border-color: var(--line-soft);
  background: var(--nav-bg);
}

.nav a,
.nav button {
  min-width: 64px;
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: var(--nav-text);
  background: transparent;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

.nav a:hover,
.nav a.active,
.nav button:hover,
.nav button.active {
  color: var(--text);
  background: var(--nav-active-bg);
}

.status-chip {
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--success-text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.primary-button {
  color: var(--primary-text);
  background: var(--accent);
}

.primary-button:hover {
  background: var(--primary-hover);
}

.secondary-button {
  border-color: var(--line);
  color: var(--text);
  background: var(--button);
}

.secondary-button:hover {
  background: var(--button-hover);
}

.hero-copy {
  border-color: var(--line);
  background: var(--hero-bg);
  box-shadow: var(--shadow);
}

.hero-copy p {
  color: var(--hero-copy);
}

.panel,
.metric,
.login-card {
  border-color: var(--line);
  background: var(--surface);
  box-shadow: none;
}

.entitlement-panel {
  background: var(--panel-gradient-soft);
}

.metric {
  background: var(--panel-gradient);
}

.field input,
.field select,
.field textarea,
.check-field {
  border-color: var(--field-border);
  color: var(--text);
  background: var(--field-bg);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.detail-grid {
  border-color: var(--line-soft);
  background: var(--line-soft);
}

.detail-item,
.candidate-button,
.chart-panel {
  border-color: var(--line);
  background: var(--detail-bg);
}

.table-wrap {
  border-color: var(--line-soft);
}

.table th {
  color: var(--table-head-text);
  background: var(--table-head-bg);
}

.table td {
  color: var(--table-cell-text);
}

.table th,
.table td {
  border-bottom-color: var(--line-soft);
}

.table tbody tr:hover td {
  background: var(--table-hover-bg);
}

.alert-pill {
  color: var(--info-text);
  background: var(--info-bg);
}

.alert-pill.high {
  color: var(--danger-text);
  background: var(--danger-bg);
}

.alert-pill.low {
  color: var(--success-text);
  background: var(--success-bg);
}

.risk-panel {
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
  background: var(--risk-bg);
}

.error {
  color: var(--negative-text);
}

.toast {
  border-color: var(--line);
  color: var(--text);
  background: var(--toast-bg);
}

.line-chart {
  border-color: var(--chart-border);
  background: var(--line-chart-bg);
}

.bar-row {
  color: var(--table-cell-text);
}

.bar-track {
  background: var(--bar-track);
}

.positive {
  color: var(--positive-text);
}

.negative {
  color: var(--negative-text);
}

/* Keep every scrollable area functional while hiding its scrollbar chrome. */
* {
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}

*::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
