:root {
  --bg: #09111d;
  --surface: rgba(13, 25, 40, 0.96);
  --surface-solid: #0c1726;
  --surface-soft: rgba(18, 32, 50, 0.92);
  --line: rgba(132, 164, 190, 0.18);
  --line-strong: rgba(72, 192, 232, 0.34);
  --text: #e8f2fb;
  --muted: #8fa2b7;
  --brand: #38c8ef;
  --brand-strong: #1aa6d1;
  --red: #ff4f6d;
  --risk-accent: #ff6f91;
  --signal: #6576ff;
  --blue: #3d8bff;
  --green: #31d6a0;
  --purple: #8b7cff;
  --shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(145deg, #09111d 0%, #0c1828 52%, #10162a 100%);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(56, 200, 239, 0.42);
  outline-offset: 2px;
}

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

.auth-root {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(56, 200, 239, 0.1), transparent 34%),
    linear-gradient(320deg, rgba(101, 118, 255, 0.1), transparent 42%),
    var(--bg);
}

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

.login-brand {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

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

.login-brand p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.login-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 16, 30, 0.78);
  color: var(--text);
  outline: 0;
}

.login-form input:focus,
.search-box input:focus,
.ai-input input:focus,
.field input:focus,
.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 211, 255, 0.12);
}

.login-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 79, 109, 0.13);
  color: var(--red);
  font-size: 13px;
}

.login-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px 14px;
  background:
    linear-gradient(180deg, rgba(10, 22, 36, 0.99), rgba(8, 14, 24, 0.99)),
    var(--surface-solid);
  border-right: 1px solid rgba(132, 164, 190, 0.16);
  color: #e8f7ff;
}

.brand-block {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 54px;
  margin-bottom: 20px;
}

.brand-logo {
  display: block;
  width: 44px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(56, 200, 239, 0.22));
}

.login-brand .brand-logo {
  width: 60px;
  height: 44px;
}

.brand-name {
  font-size: 15px;
  font-weight: 760;
  line-height: 1.3;
  min-width: 0;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #aac1d5;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  border-color: rgba(56, 200, 239, 0.24);
  background: rgba(56, 200, 239, 0.1);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--brand);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(132, 164, 190, 0.16);
  border-radius: 8px;
  background: rgba(132, 164, 190, 0.06);
  color: #bcd3e5;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(49, 214, 160, 0.14);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 82px;
  padding: 18px 28px;
  background: rgba(9, 17, 29, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 40vw);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.search-box span {
  flex: 0 0 auto;
  white-space: nowrap;
}

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

.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(41, 211, 255, 0.12);
}

.user-badge {
  display: grid;
  justify-content: end;
  min-width: 116px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}

.user-badge span {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(56, 200, 239, 0.28);
  border-radius: 8px;
  background: var(--brand);
  color: #021220;
  font-weight: 680;
  text-decoration: none;
  box-shadow: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.button-ghost {
  background: rgba(16, 32, 52, 0.72);
  color: var(--text);
  border-color: var(--line);
  box-shadow: none;
}

.button-danger {
  background: var(--red);
  color: white;
}

.view-root {
  padding: 22px 28px 34px;
}

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

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

.grid.two {
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
}

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

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

.panel {
  padding: 20px;
}

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

.panel-title {
  margin: 0;
  font-size: 16px;
  color: #f2fbff;
}

.metric-card {
  min-height: 110px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(56, 200, 239, 0.34);
  content: "";
  pointer-events: none;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 800;
  color: #f5fbff;
  overflow-wrap: anywhere;
}

.metric-value-compact {
  font-size: 22px;
  line-height: 1.2;
}

.metric-delta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(132, 164, 190, 0.2);
  background: rgba(132, 164, 190, 0.1);
  color: #bfd3e5;
  font-size: 12px;
  font-weight: 680;
}

.chip.hot {
  border-color: rgba(255, 111, 145, 0.22);
  background: rgba(255, 111, 145, 0.1);
  color: #f5a2b4;
}

.severity {
  display: inline-flex;
  justify-content: center;
  min-width: 38px;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.severity.P0 {
  background: var(--red);
}

.severity.P1 {
  background: var(--risk-accent);
}

.severity.P2 {
  background: var(--signal);
}

.severity.P3 {
  background: var(--blue);
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(49, 214, 160, 0.18);
  background: rgba(49, 214, 160, 0.12);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.warn {
  border-color: rgba(167, 119, 255, 0.22);
  background: rgba(167, 119, 255, 0.13);
  color: #c7adff;
}

.status-pill.danger {
  border-color: rgba(255, 79, 109, 0.24);
  background: rgba(255, 79, 109, 0.13);
  color: var(--red);
}

.table-wrap {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 760;
}

td {
  line-height: 1.45;
}

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

.main-cell {
  display: grid;
  gap: 5px;
}

.main-cell strong {
  overflow-wrap: anywhere;
}

.muted {
  color: var(--muted);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(130, 168, 190, 0.16);
  overflow: hidden;
}

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

.trend {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  height: 170px;
  gap: 12px;
  padding-top: 16px;
}

.trend-col {
  display: grid;
  align-items: end;
  gap: 8px;
  height: 100%;
}

.trend-bar {
  min-height: 18px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--signal));
}

.trend-label {
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.ai-box {
  display: grid;
  gap: 12px;
}

.ai-answer {
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  line-height: 1.7;
}

.ai-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.ai-input input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(6, 16, 30, 0.78);
  color: var(--text);
  outline: 0;
}

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

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

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

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

.field input,
.field select {
  min-height: 42px;
  width: 100%;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 18, 30, 0.74);
  color: var(--text);
  outline: 0;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}

.notice {
  padding: 12px;
  border: 1px solid rgba(72, 192, 232, 0.16);
  border-radius: 8px;
  background: rgba(56, 200, 239, 0.06);
  color: #b9d8e6;
  font-size: 13px;
  line-height: 1.6;
}

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

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 25, 40, 0.68);
  color: var(--muted);
}

.step-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(56, 200, 239, 0.11);
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.step-item strong {
  color: var(--text);
  font-size: 14px;
}

.model-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.selected-provider-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(72, 192, 232, 0.2);
  border-radius: 8px;
  background: rgba(18, 36, 56, 0.78);
  color: var(--text);
  box-shadow: inset 3px 0 0 rgba(56, 200, 239, 0.72);
}

.selected-provider-detail strong,
.selected-provider-detail span,
.selected-provider-detail small {
  display: block;
}

.selected-provider-detail span,
.selected-provider-detail small,
.model-row span,
.model-row small {
  color: var(--muted);
  font-size: 12px;
}

.selected-provider-detail small {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.selected-provider-detail.wide {
  grid-column: 1 / -1;
}

.model-list-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 32, 50, 0.72);
}

.model-row small {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.empty-state {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

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

  .step-flow {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    min-height: auto;
  }

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

  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

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

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

  .form-grid {
    grid-template-columns: 1fr;
  }

  .selected-provider-detail,
  .model-row {
    grid-template-columns: 1fr;
  }

  th:nth-child(n + 4),
  td:nth-child(n + 4) {
    display: none;
  }
}
