:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --bg-soft: #eef1f7;
  --surface: rgba(15, 23, 42, 0.035);
  --surface-2: rgba(15, 23, 42, 0.06);
  --card: #ffffff;
  --border: rgba(15, 23, 42, 0.13);
  --border-soft: rgba(15, 23, 42, 0.08);
  --text: #171923;
  --muted: #475467;
  --muted-2: #667085;
  --brand: #5b46d9;
  --brand-2: #6c55ee;
  --brand-soft: rgba(91, 70, 217, 0.1);
  --green: #198754;
  --green-soft: #e8f6ef;
  --amber: #b76e00;
  --amber-soft: #fff4d9;
  --red: #c2413a;
  --red-soft: #fdeceb;
  --radius: 16px;
  --shadow: 0 16px 40px rgba(37, 45, 72, 0.06);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted-2); }

.login-screen { min-height: 100vh; padding: 34px 42px; background: radial-gradient(circle at 50% 35%, rgba(108,85,238,.22), transparent 34%), linear-gradient(135deg, #f8f9ff 0%, #eef0ff 52%, #f7f8fc 100%); }
.login-brand { display: flex; align-items: center; gap: 13px; }
.login-logo { width: 18px; height: 18px; border: 5px solid var(--brand-2); border-radius: 50%; }
.login-brand strong { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.login-badge { padding: 5px 10px; border: 1px solid rgba(108,85,238,.35); border-radius: 999px; color: var(--brand-2); background: rgba(108,85,238,.08); font-size: 11px; font-weight: 700; }
.login-card { width: min(420px, calc(100vw - 32px)); margin: clamp(90px, 14vh, 150px) auto 0; padding: 40px 34px 30px; border: 1px solid rgba(15,23,42,.14); border-radius: 22px; background: rgba(255,255,255,.88); box-shadow: 0 28px 70px rgba(44,48,82,.16); backdrop-filter: blur(10px); }
.login-heading { margin-bottom: 28px; text-align: center; }
.login-heading h1 { font-size: 27px; }
.login-heading p { margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.login-card label { margin-top: 17px; font-size: 12px; }
.login-card input { width: 100%; height: 46px; padding: 0 14px; background: #f4f6ff; }
.login-error { margin: 12px 0 0; padding: 9px 11px; border-radius: 9px; color: var(--red); background: var(--red-soft); font-size: 11px; }
.login-button { width: 100%; height: 46px; margin-top: 24px; font-size: 14px; }
.login-note { margin: 18px 0 0; color: var(--muted-2); text-align: center; font-size: 10px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 234px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 12px 18px; background: var(--bg-soft); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 14px; padding: 8px 10px 30px; }
.brand-mark { width: 18px; height: 18px; flex: 0 0 18px; border: 5px solid var(--brand-2); border-radius: 50%; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 18px; line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.brand span { margin-top: 4px; color: var(--muted-2); font-size: 11px; }
nav { display: grid; gap: 7px; }
.nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px; color: var(--muted); background: transparent; text-align: left; font-size: 13px; font-weight: 650; }
.nav-item span { width: 18px; color: var(--muted-2); text-align: center; font-size: 15px; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.5); }
.nav-item.active { color: #33248f; background: var(--brand-soft); border-color: rgba(108,85,238,.32); box-shadow: inset 0 0 0 1px rgba(108,85,238,.05); }
.nav-item.active span { color: var(--brand-2); }
.sidebar-foot { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; }
.sidebar-foot strong, .sidebar-foot span { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot span { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.status-dot { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #29b879; box-shadow: 0 0 0 4px rgba(41,184,121,.12); }
.logout-button { grid-column: 1 / -1; margin-top: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; color: var(--muted); background: rgba(255,255,255,.55); font-size: 11px; font-weight: 650; }
.logout-button:hover { color: var(--brand); border-color: rgba(108,85,238,.34); }

main { min-width: 0; padding: 0 32px 48px; }
.topbar { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--brand-2); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -.03em; }
h2 { margin-bottom: 0; font-size: 18px; font-weight: 750; letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.button { min-height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 999px; font-size: 12px; font-weight: 750; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .52; transform: none; }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 8px 18px rgba(91,70,217,.18); }
.button.secondary { color: var(--text); background: rgba(255,255,255,.8); border-color: var(--border); }
.loading-card, .alert { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.alert.critical { color: var(--red); background: var(--red-soft); }

.hero-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.hero-card, .panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, var(--surface-2), var(--surface)); }
.hero-card { min-height: 150px; padding: 20px; transition: border-color .18s ease, transform .18s ease; }
.hero-card:hover { border-color: rgba(108,85,238,.45); transform: translateY(-1px); }
.schedule-card { border-color: rgba(108,85,238,.32); background: linear-gradient(145deg, rgba(108,85,238,.13), rgba(91,70,217,.05)); }
.card-heading { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 650; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; color: var(--brand); background: var(--brand-soft); font-size: 9px; font-style: normal; font-weight: 800; white-space: nowrap; }
.pill.success { color: var(--green); background: var(--green-soft); }
.pill.warning { color: var(--amber); background: var(--amber-soft); }
.pill.critical { color: var(--red); background: var(--red-soft); }
.hero-value { display: block; margin-top: 20px; font-size: clamp(25px, 2vw, 32px); line-height: 1; font-weight: 800; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.hero-value.small { font-size: 22px; }
.hero-card p { margin: 12px 0 0; color: var(--muted-2); font-size: 11px; line-height: 1.5; }

.progress-panel { margin-top: 14px; padding: 20px 22px; border-color: rgba(108,85,238,.3); background: linear-gradient(120deg, rgba(108,85,238,.12), rgba(255,255,255,.42)); box-shadow: var(--shadow); }
.progress-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.progress-title-line { display: flex; align-items: center; gap: 10px; }
.progress-detail { margin: 8px 0 0; font-size: 11px; }
.progress-percent { color: var(--brand); font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.progress-track { height: 9px; margin: 18px 0 16px; overflow: hidden; border-radius: 99px; background: rgba(91,70,217,.12); }
.progress-bar { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #836fff); transition: width .45s ease; position: relative; }
.progress-bar::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: shimmer 1.6s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.progress-metrics { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.progress-metrics span { padding-right: 12px; border-right: 1px solid var(--border-soft); }
.progress-metrics span:last-child { border: 0; }
.progress-metrics small, .progress-metrics strong { display: block; }
.progress-metrics small { color: var(--muted-2); font-size: 9px; }
.progress-metrics strong { margin-top: 4px; font-size: 12px; font-variant-numeric: tabular-nums; }

.content-grid { margin-top: 14px; display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr); gap: 14px; }
.panel { padding: 20px; background-color: rgba(255,255,255,.34); }
.span-2 { grid-column: 1; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.panel-note { max-width: 680px; margin: 7px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.5; }
.legend { display: flex; gap: 14px; color: var(--muted-2); font-size: 10px; white-space: nowrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; background: var(--muted-2); }
.dot.success { background: var(--green); }
.dot.warning { background: #d08700; }
.dot.critical { background: var(--red); }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 10px; border-bottom: 1px solid var(--border); color: var(--muted-2); font-size: 9px; letter-spacing: .04em; text-align: left; white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(91,70,217,.025); }
tr:last-child td { border-bottom: 0; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
.table-name strong, .table-name span { display: block; }
.table-name span { margin-top: 3px; color: var(--muted-2); font-size: 9px; }
.state { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 9px; font-weight: 800; white-space: nowrap; }
.state.warning { color: var(--amber); background: var(--amber-soft); }
.state.critical { color: var(--red); background: var(--red-soft); }
.count-badge { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-size: 11px; font-weight: 800; }
.anomaly-panel { grid-column: 2; grid-row: 1; }
.anomaly-list { display: grid; gap: 9px; }
.anomaly-item { padding: 12px; border-left: 3px solid var(--brand); border-radius: 5px 11px 11px 5px; background: rgba(91,70,217,.07); }
.anomaly-item.warning { border-color: #d08700; background: var(--amber-soft); }
.anomaly-item.critical { border-color: var(--red); background: var(--red-soft); }
.anomaly-item strong { display: block; font-size: 11px; }
.anomaly-item p { margin: 5px 0 0; color: var(--muted-2); font-size: 10px; line-height: 1.5; }
.storage-panel { grid-column: 2; grid-row: 2; }
.storage-chart { display: grid; place-items: center; padding: 4px 0 16px; }
.ring { width: 116px; height: 116px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--brand-2) 0%, var(--brand-2) var(--usage), rgba(91,70,217,.1) var(--usage), rgba(91,70,217,.1) 100%); position: relative; }
.ring::after { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: #f4f5f9; }
.ring span { position: relative; z-index: 1; font-size: 21px; font-weight: 800; }
.metric-list { margin: 0; display: grid; gap: 10px; }
.metric-list div { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.metric-list div:last-child { border: 0; }
.metric-list dt { color: var(--muted-2); font-size: 10px; }
.metric-list dd { margin: 0; font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; }
.log-button { border: 0; color: var(--brand); background: transparent; font-size: 10px; font-weight: 800; }

.data-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.data-toolbar h2 { margin-bottom: 6px; }
.data-toolbar p:last-child { margin: 0; font-size: 11px; }
.filters { display: flex; align-items: end; gap: 9px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 650; }
input, select, textarea { border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: rgba(255,255,255,.72); outline: none; }
input, select { height: 38px; padding: 0 11px; }
textarea { width: 100%; padding: 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(91,70,217,.1); }
.data-summary { margin: 18px 0 10px; padding: 11px 13px; border-radius: 10px; color: var(--muted-2); background: rgba(91,70,217,.055); font-size: 11px; }
.document-list { display: grid; gap: 9px; }
.document { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: rgba(255,255,255,.58); }
.document > summary { padding: 13px 15px; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 11px; }
.document > summary::-webkit-details-marker { display: none; }
.document > summary::before { content: "+"; color: var(--brand); font-weight: 800; font-size: 15px; }
.document[open] > summary::before { content: "−"; }
.document-title { flex: 1; font-weight: 750; }
.document-meta { color: var(--muted-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.readable-record { padding: 16px; border-top: 1px solid var(--border-soft); background: rgba(255,255,255,.58); }
.field-section + .field-section { margin-top: 16px; }
.field-section h4 { margin: 0 0 9px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.field-grid { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.field { min-width: 0; padding: 10px 11px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--bg); }
.field.wide { grid-column: 1 / -1; }
.field dt { margin-bottom: 5px; color: var(--muted-2); font-size: 9px; }
.field dd { margin: 0; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.field a { color: var(--brand); }
.nested-record { margin-top: 8px; border: 1px solid var(--border-soft); border-radius: 10px; background: rgba(247,248,252,.8); }
.nested-record > summary { padding: 10px 12px; cursor: pointer; color: var(--muted); font-size: 10px; font-weight: 750; }
.nested-record > .field-grid { padding: 0 10px 10px; }
.array-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.array-chip { display: inline-flex; padding: 4px 7px; border-radius: 7px; color: var(--muted); background: rgba(91,70,217,.08); font-size: 10px; }
.raw-json { margin-top: 14px; }
.raw-json > summary { cursor: pointer; color: var(--muted-2); font-size: 10px; }
.raw-json pre, dialog pre { margin: 9px 0 0; padding: 14px; overflow: auto; color: #e5e7eb; background: #202235; font: 10px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 10px; }
.pagination { margin-top: 15px; display: flex; justify-content: center; align-items: center; gap: 12px; color: var(--muted-2); font-size: 11px; }

.credential-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 14px; }
.credential-card h2, .credential-status h2 { margin-bottom: 10px; }
.credential-card > .muted { max-width: 720px; line-height: 1.7; font-size: 12px; }
.credential-card form { margin-top: 25px; }
.form-actions { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.metric-list.large { margin-top: 22px; }
.metric-list.large div { padding: 9px 0 13px; }
.metric-list.large dt, .metric-list.large dd { font-size: 12px; }
.security-note { margin-top: 22px; padding: 14px; border-radius: 11px; color: #3c2bac; background: var(--brand-soft); }
.security-note strong { font-size: 11px; }
.security-note p { margin: 5px 0 0; font-size: 10px; line-height: 1.55; }

dialog { width: min(900px, calc(100vw - 48px)); max-height: 78vh; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); box-shadow: 0 30px 80px rgba(28,31,53,.3); }
dialog::backdrop { background: rgba(28,31,53,.5); backdrop-filter: blur(2px); }
.dialog-head { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 50%; color: var(--muted); background: var(--bg-soft); font-size: 20px; }
dialog pre { max-height: calc(78vh - 86px); border-radius: 0; }
#toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: 380px; padding: 12px 15px; border-radius: 11px; color: #fff; background: #27223f; box-shadow: 0 12px 30px rgba(28,31,53,.25); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 12px; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: var(--red); }

@media (max-width: 1200px) {
  .hero-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .span-2, .anomaly-panel, .storage-panel { grid-column: 1; grid-row: auto; }
}
@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 6px 8px 14px; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .nav-item { justify-content: center; padding: 0 8px; }
  .sidebar-foot { display: none; }
  main { padding: 0 16px 32px; }
  .topbar { min-height: 134px; align-items: flex-start; flex-direction: column; padding: 20px 0; }
  .top-actions, .filters { width: 100%; flex-wrap: wrap; }
  .top-actions .muted { width: 100%; }
  .data-toolbar { align-items: flex-start; flex-direction: column; }
  .filters label { flex: 1; min-width: 150px; }
  .progress-metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .field-grid { grid-template-columns: 1fr; }
  .field.wide { grid-column: auto; }
}
@media (max-width: 560px) {
  .login-screen { padding: 22px 18px; }
  .login-card { margin-top: 80px; padding: 32px 24px 26px; }
  .hero-grid, .credential-grid { grid-template-columns: 1fr; }
  nav { grid-template-columns: 1fr; }
  .top-actions .button { flex: 1; }
  .progress-head { flex-direction: column; gap: 10px; }
  .progress-metrics { grid-template-columns: 1fr; }
  .document-meta { white-space: normal; text-align: right; }
}
