:root {
  --bg-app: #f3f5f8;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sidebar: #101828;
  --bg-sidebar-active: #1d2939;
  --text-primary: #17202e;
  --text-secondary: #667085;
  --text-tertiary: #98a2b3;
  --border-default: #e4e7ec;
  --border-strong: #d0d5dd;
  --accent-primary: #155eef;
  --accent-soft: #eff4ff;
  --status-success: #067647;
  --status-success-bg: #ecfdf3;
  --status-danger: #b42318;
  --status-danger-bg: #fef3f2;
  --status-warning: #b54708;
  --status-warning-bg: #fffaeb;
  --status-info: #175cd3;
  --status-info-bg: #eff8ff;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(16,24,40,.04), 0 3px 10px rgba(16,24,40,.03);
  --shadow-menu: 0 16px 40px rgba(16,24,40,.14);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --font-xs: 12px;
  --font-sm: 13px;
  --font-md: 14px;
  --font-lg: 18px;
  --font-xl: 24px;
  --font-2xl: 30px;
  --control-height: 40px;
  --table-row-height: 48px;
}

* { box-sizing: border-box; }
html { min-width: 1024px; background: var(--bg-app); }
body { margin: 0; color: var(--text-primary); background: var(--bg-app); font: 14px/1.5 Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 3px rgba(21,94,239,.18); }
.muted { color: var(--text-secondary); }
.eyebrow { margin: 0 0 4px; color: var(--text-secondary); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.field-error, .error { color: var(--status-danger); }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 47%) minmax(460px, 53%); background: var(--bg-card); }
.login-intro { position: relative; display: flex; flex-direction: column; justify-content: center; padding: clamp(56px,8vw,140px); overflow: hidden; color: #fff; background: linear-gradient(145deg,#101828 0%,#1d2939 55%,#163b76 130%); }
.login-intro::before, .login-intro::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; }
.login-intro::before { width: 520px; height: 520px; right: -230px; top: -170px; }
.login-intro::after { width: 330px; height: 330px; right: -80px; bottom: -160px; }
.brand-mark { width: 36px; height: 36px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: #fff; background: linear-gradient(145deg,#528bff,#155eef); font-size: 18px; font-weight: 800; box-shadow: 0 7px 16px rgba(21,94,239,.25); }
.login-intro > .brand-mark { width: 48px; height: 48px; margin-bottom: 56px; border-radius: 13px; font-size: 24px; }
.login-intro .eyebrow { color: #84adff; }
.login-intro h2 { max-width: 540px; margin: 10px 0 20px; font-size: clamp(34px,3.3vw,55px); line-height: 1.18; letter-spacing: -.035em; }
.login-intro > p:not(.eyebrow) { max-width: 430px; color: #b9c5d6; font-size: 16px; }
.login-status { margin-top: 64px; color: #b9c5d6; font-size: 13px; }
.login-status span, .side-dot, .environment > span { width: 8px; height: 8px; display: inline-block; margin-right: 7px; border-radius: 50%; background: #32d583; box-shadow: 0 0 0 4px rgba(50,213,131,.11); }
.login-panel { width: min(420px,calc(100% - 72px)); margin: auto; padding: 36px 0; }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 58px; font-size: 21px; }
.login-panel h1 { margin: 4px 0 6px; font-size: 30px; letter-spacing: -.025em; }
.login-panel form { margin-top: 28px; }
.login-panel button { width: 100%; margin-top: 8px; }
.login-foot { margin-top: 44px; color: var(--text-tertiary); font-size: 12px; text-align: center; }

/* Controls */
label { display: block; margin: 0 0 6px; color: #344054; font-size: var(--font-sm); font-weight: 600; }
input:not([type="checkbox"]), select, textarea { width: 100%; height: var(--control-height); padding: 8px 11px; margin: 0 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-primary); background: #fff; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 88px; resize: vertical; }
input:not([type="checkbox"]):hover, select:hover, textarea:hover { border-color: #98a2b3; }
input:not([type="checkbox"]):focus, select:focus, textarea:focus { border-color: var(--accent-primary); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0 7px 0 0; vertical-align: -3px; accent-color: var(--accent-primary); }
button, .button { min-height: var(--control-height); display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border: 1px solid transparent; border-radius: var(--radius-sm); color: #fff; background: var(--accent-primary); font-weight: 650; cursor: pointer; text-decoration: none; transition: filter .15s, transform .15s, box-shadow .15s; }
button:hover, .button:hover { filter: brightness(.95); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary, .secondary { color: #344054; border-color: var(--border-strong); background: #fff; }
button.danger, .danger { color: #fff; border-color: var(--status-danger); background: var(--status-danger); }
button.ghost, .ghost { min-height: 34px; padding: 6px 9px; color: #475467; background: transparent; }
button.small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.danger-zone { border-color: #fecdca !important; background: linear-gradient(180deg,#fff,#fffafa); }
.danger-zone .section-title { color: #912018; }

/* App shell */
.layout { min-height: 100vh; }
.side { width: 224px; position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; flex-direction: column; padding: 24px 16px 20px; color: #fff; background: var(--bg-sidebar); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 30px; font-size: 18px; }
.brand small { display: block; margin-top: -2px; color: #7f8da3; font-size: 9px; font-weight: 700; letter-spacing: .16em; }
.nav-label { padding: 0 12px 9px; color: #667085; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.nav { display: grid; gap: 5px; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 10px 12px; border-radius: 8px; color: #aeb9c9; font-weight: 550; text-decoration: none; transition: color .15s, background .15s; }
.nav-icon { width: 20px; color: #7f8da3; font-size: 16px; text-align: center; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav a.active { color: #fff; background: var(--bg-sidebar-active); box-shadow: inset 3px 0 0 #528bff; }
.nav a.active .nav-icon { color: #84adff; }
.side-foot { display: flex; align-items: center; gap: 3px; margin-top: auto; padding: 16px 10px 0; border-top: 1px solid #263244; color: #98a2b3; font-size: 12px; }
.side-foot small { display: block; color: #667085; font-size: 8px; letter-spacing: .11em; }
.main { min-height: 100vh; margin-left: 224px; padding: 0 28px 48px; }
.top { max-width: 1580px; height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 auto 24px; border-bottom: 1px solid var(--border-default); }
.page-heading h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.environment { height: 43px; display: flex; align-items: center; gap: 3px; padding: 5px 12px; border: 1px solid #fedf89; border-radius: 9px; color: #93370d; background: #fffaeb; }
.environment > span { width: 7px; height: 7px; margin-right: 6px; background: #f79009; box-shadow: 0 0 0 3px rgba(247,144,9,.12); }
.environment strong, .environment small { display: block; line-height: 1.2; }
.environment strong { font-size: 12px; letter-spacing: .04em; }
.environment small { color: #b54708; font-size: 10px; }
.environment-live { color: #912018; border-color: #fecdca; background: #fef3f2; }
.environment-live > span { background: #f04438; box-shadow: 0 0 0 3px rgba(240,68,56,.12); }
.environment-live small { color: #b42318; }
.environment-real { color: #175cd3; border-color: #b2ccff; background: #eff8ff; }
.environment-real > span { background: #2e90fa; box-shadow: 0 0 0 3px rgba(46,144,250,.12); }
.environment-real small { color: #1570ef; }
.content { max-width: 1580px; margin: 0 auto; }

/* User menu */
.user-menu { position: relative; }
#user-button { min-width: 150px; height: 43px; justify-content: flex-start; padding: 5px 10px 5px 6px; color: #344054; border-color: var(--border-default); background: #fff; box-shadow: var(--shadow-card); }
#user-button::after { content: "⌄"; margin-left: auto; color: var(--text-secondary); font-size: 15px; }
.avatar { width: 30px; height: 30px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 8px; color: #1849a9; background: #d1e0ff; font-size: 12px; font-weight: 800; }
.user-button-copy { overflow: hidden; text-align: left; }
.user-button-copy strong, .user-button-copy small { display: block; overflow: hidden; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.user-button-copy strong { color: var(--text-primary); font-size: 12px; }
.user-button-copy small { color: var(--text-secondary); font-size: 9px; }
.user-menu-panel { width: 230px; position: absolute; right: 0; top: 50px; z-index: 50; padding: 7px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: #fff; box-shadow: var(--shadow-menu); }
.user-menu-head { display: flex; align-items: center; gap: 10px; padding: 9px 9px 12px; margin-bottom: 5px; border-bottom: 1px solid var(--border-default); }
.user-menu-head strong, .user-menu-head small { display: block; }
.user-menu-head small { color: var(--text-secondary); font-size: 10px; }
.user-menu-panel a, .user-menu-panel > button { width: 100%; min-height: 37px; display: flex; justify-content: flex-start; padding: 8px 10px; border: 0; border-radius: 6px; color: #344054; background: #fff; font-weight: 500; text-align: left; text-decoration: none; }
.user-menu-panel a:hover, .user-menu-panel > button:hover { background: var(--bg-subtle); }
.user-menu-panel > button:last-child { margin-top: 4px; color: var(--status-danger); border-top: 1px solid var(--border-default); border-radius: 0 0 6px 6px; }

/* Content primitives */
.feedback { position: fixed; right: 28px; top: 94px; z-index: 80; max-width: 420px; padding: 12px 16px; border: 1px solid #abefc6; border-radius: 9px; color: var(--status-success); background: var(--status-success-bg); box-shadow: var(--shadow-menu); font-weight: 600; }
.feedback.error { color: var(--status-danger); border-color: #fecdca; background: var(--status-danger-bg); }
.loading-state { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--text-secondary); }
.loading-state span { width: 24px; height: 24px; border: 2px solid #d1e0ff; border-top-color: var(--accent-primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 26px 0 12px; }
.section-heading:first-child { margin-top: 0; }
.section-heading h2, .section-title { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.section-heading p { margin: 3px 0 0; color: var(--text-secondary); font-size: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 14px; }
.metric-grid { grid-template-columns: repeat(5,minmax(150px,1fr)); }
.status-grid { grid-template-columns: repeat(3,minmax(180px,1fr)); }
.card { min-width: 0; padding: 18px; margin: 0 0 14px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-card); box-shadow: var(--shadow-card); }
.metric-card { min-height: 128px; position: relative; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.metric-card::after { content: ""; width: 48px; height: 48px; position: absolute; right: -18px; bottom: -18px; border: 10px solid var(--accent-soft); border-radius: 50%; }
.metric-label { color: var(--text-secondary); font-size: 12px; font-weight: 600; }
.metric-value { margin-top: 18px; font-size: clamp(22px,2vw,29px); font-weight: 750; line-height: 1.12; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.metric-value small { margin-left: 4px; color: var(--text-secondary); font-size: 11px; font-weight: 650; letter-spacing: 0; }
.metric-time { display: block; overflow-wrap: anywhere; font-size: 15px; letter-spacing: -.01em; }
.value-positive { color: var(--status-success); }
.value-negative { color: var(--status-danger); }
.value-neutral { color: var(--text-primary); }
.status-card { min-height: 96px; display: flex; align-items: center; gap: 13px; }
.status-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 10px; color: var(--status-info); background: var(--status-info-bg); font-size: 17px; }
.status-card .metric-value { margin: 3px 0 0; font-size: 16px; letter-spacing: -.01em; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 9px; border-radius: 999px; color: #344054; background: #f2f4f7; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #98a2b3; }
.status-success { color: var(--status-success); background: var(--status-success-bg); }
.status-success::before { background: #12b76a; }
.status-danger { color: var(--status-danger); background: var(--status-danger-bg); }
.status-danger::before { background: #f04438; }
.status-warning { color: var(--status-warning); background: var(--status-warning-bg); }
.status-warning::before { background: #f79009; }
.status-info { color: var(--status-info); background: var(--status-info-bg); }
.status-info::before { background: #2e90fa; }
.read-only { display: inline-flex; padding: 3px 8px; border: 1px solid var(--border-default); border-radius: 6px; color: var(--text-secondary); background: var(--bg-subtle); font-size: 11px; font-weight: 700; }

/* Tabs, tables and forms */
.tabs { display: flex; gap: 2px; overflow-x: auto; margin: 0 0 20px; padding: 4px; border: 1px solid var(--border-default); border-radius: 10px; background: #eaecf0; scrollbar-width: thin; }
.tabs a { min-width: max-content; padding: 8px 13px; border-radius: 7px; color: #475467; font-size: 12px; font-weight: 650; text-decoration: none; }
.tabs a:hover { color: var(--text-primary); background: rgba(255,255,255,.56); }
.tabs a.active { color: #1849a9; background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.table-card { padding: 0; overflow: hidden; }
.table-toolbar { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-default); }
.table-toolbar h2 { margin: 0; font-size: 14px; }
.table-toolbar p { margin: 1px 0 0; color: var(--text-secondary); font-size: 11px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; background: #fff; font-size: 12px; }
th, td { height: var(--table-row-height); padding: 10px 14px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: middle; }
th { height: 42px; color: #667085; background: var(--bg-subtle); font-size: 10px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f9fbff; }
tbody tr:last-child td { border-bottom: 0; }
td.numeric, .numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td code, .address { max-width: 170px; display: inline-block; overflow: hidden; color: #475467; font: 11px ui-monospace,SFMono-Regular,Consolas,monospace; text-overflow: ellipsis; vertical-align: middle; white-space: nowrap; }
.copy-button { min-height: 28px; margin-left: 5px; padding: 3px 7px; color: #475467; border-color: var(--border-default); background: #fff; font-size: 10px; }
.empty-state { min-height: 220px; display: grid; place-items: center; align-content: center; gap: 6px; padding: 32px; color: var(--text-secondary); text-align: center; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 12px; color: #528bff; background: var(--accent-soft); font-size: 20px; }
.empty-state strong { color: #344054; font-size: 14px; }
.empty-state p { max-width: 360px; margin: 0; font-size: 12px; }
.form-card { padding: 20px; }
.form-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 15px; margin-bottom: 17px; border-bottom: 1px solid var(--border-default); }
.form-card-head h2 { margin: 0; font-size: 15px; }
.form-card-head p { margin: 3px 0 0; color: var(--text-secondary); font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(190px,1fr)); gap: 4px 14px; align-items: end; }
.form-grid > h2 { grid-column: 1/-1; }
.form-grid > button { align-self: center; margin-bottom: 14px; }
.form-grid label:has(input[type="checkbox"]) { min-height: var(--control-height); display: flex; align-items: center; margin-bottom: 14px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); background: var(--bg-subtle); }
.form-sections { display: grid; grid-template-columns: repeat(2,minmax(300px,1fr)); gap: 14px; }
.form-section { padding: 17px; border: 1px solid var(--border-default); border-radius: 9px; background: var(--bg-subtle); }
.form-section h3 { margin: 0 0 14px; font-size: 13px; }
.unit-field { position: relative; }
.unit-field input { padding-right: 62px; }
.unit { position: absolute; right: 11px; top: 11px; color: var(--text-secondary); font-size: 11px; font-weight: 700; }

/* Charts and special layouts */
.chart-card { min-height: 300px; padding: 0; overflow: hidden; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px 10px; }
.chart-head h2 { margin: 0; font-size: 15px; }
.chart-head p { margin: 2px 0 0; color: var(--text-secondary); font-size: 11px; }
.range-switch { display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: #f2f4f7; }
.range-switch span { padding: 4px 8px; border-radius: 5px; color: var(--text-secondary); font-size: 10px; font-weight: 700; }
.range-switch span.active { color: #1849a9; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.chart-wrap { height: 230px; padding: 8px 14px 16px; }
.chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: #eaecf0; stroke-width: 1; }
.chart-area { fill: url(#chart-gradient); }
.chart-line { fill: none; stroke: var(--accent-primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: #fff; stroke: var(--accent-primary); stroke-width: 2; }
.chart-label { fill: #98a2b3; font-size: 9px; }
.strategy-card { position: relative; padding: 22px; border-left: 4px solid var(--accent-primary); }
.strategy-card h2 { margin: 0 0 4px; font-size: 18px; }
.strategy-meta { display: flex; flex-wrap: wrap; gap: 18px 28px; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border-default); }
.strategy-meta div { min-width: 100px; }
.strategy-meta small, .strategy-meta strong { display: block; }
.strategy-meta small { color: var(--text-secondary); font-size: 10px; }
.strategy-meta strong { margin-top: 4px; font-size: 13px; }
.filter-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.filter-chip { min-height: 32px; padding: 5px 11px; color: #475467; border-color: var(--border-default); background: #fff; font-size: 11px; }
.filter-chip.active { color: #1849a9; border-color: #b2ccff; background: var(--accent-soft); }
.callout { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid #b2ddff; border-radius: 8px; color: #175cd3; background: var(--status-info-bg); font-size: 12px; }
.permission-card { display: grid; grid-template-columns: 190px 1fr; gap: 20px; }
.permission-card h2 { margin: 0; font-size: 16px; }
.permission-list { display: flex; flex-wrap: wrap; gap: 6px; }
.permission-list span { padding: 4px 8px; border-radius: 6px; color: #475467; background: #f2f4f7; font-size: 10px; }

@media (max-width: 1500px) {
  .metric-grid { grid-template-columns: repeat(3,minmax(180px,1fr)); }
  .main { padding-inline: 22px; }
  .form-grid { grid-template-columns: repeat(2,minmax(190px,1fr)); }
}
@media (max-width: 1200px) {
  .side { width: 205px; }
  .main { margin-left: 205px; padding-inline: 18px; }
  .metric-grid, .status-grid { grid-template-columns: repeat(2,minmax(180px,1fr)); }
  .form-sections { grid-template-columns: 1fr; }
  .login { grid-template-columns: 42% 58%; }
  .login-intro { padding: 48px; }
}
@media (max-height: 800px) {
  .top { height: 70px; margin-bottom: 18px; }
  .side { padding-top: 18px; }
  .brand { padding-bottom: 22px; }
  .metric-card { min-height: 112px; }
  .metric-value { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
