:root {
  color-scheme: dark;
  --canvas: #11171c;
  --sidebar: #0d1419;
  --surface: #192229;
  --surface-raised: #1d2931;
  --surface-soft: #141d23;
  --line: #2a3a43;
  --line-strong: #38505a;
  --text: #edf6f5;
  --muted: #9eb0ba;
  --subtle: #70848f;
  --accent: #66dbcc;
  --accent-strong: #38cdbc;
  --accent-soft: rgba(102, 219, 204, .12);
  --success: #47d89a;
  --warning: #ffc85c;
  --danger: #ff727f;
  --sidebar-width: 228px;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body { min-height: 100vh; margin: 0; color: var(--text); background: radial-gradient(circle at 65% -15%, rgba(55, 105, 112, .12), transparent 38%), var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #9cf0e5; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(30px, 3vw, 42px); line-height: 1.15; letter-spacing: -.03em; }
h2 { margin-bottom: 8px; font-size: 17px; }
h3 { font-size: 15px; }
p { color: var(--muted); line-height: 1.65; }
small { color: var(--subtle); }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid #243139; background: linear-gradient(180deg, #0c1318, #10191e); }
.brand { height: 82px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; padding: 0 31px; border-bottom: 1px solid #243139; color: var(--accent); font-size: 27px; font-weight: 760; letter-spacing: -.04em; }
.brand:hover { color: var(--accent); }
.brand b { color: #fff; }
.brand small { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .15em; white-space: nowrap; }
.sidebar-nav { display: grid; gap: 3px; padding: 25px 0; }
.nav-item { position: relative; min-height: 58px; display: flex; align-items: center; gap: 16px; padding: 0 31px; color: #9eb0bd; font-size: 15px; transition: color .15s, background .15s; }
.nav-item:hover { color: var(--text); background: rgba(102, 219, 204, .05); }
.nav-item.active { color: var(--accent); background: linear-gradient(90deg, rgba(102, 219, 204, .16), rgba(102, 219, 204, .05)); }
.nav-item.active::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); box-shadow: 0 0 18px rgba(102, 219, 204, .5); }
.nav-icon { display: grid; place-items: center; width: 24px; }
.nav-icon svg { width: 23px; height: 23px; }
.sidebar-foot { margin-top: auto; padding: 20px 25px; border-top: 1px solid #243139; }
.sidebar-foot form { margin: 0 0 14px; }
.sidebar-foot small { font-size: 10px; }
.logout-button { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 8px; border: 0; color: #91a4af; background: transparent; }
.logout-button:hover { color: var(--danger); background: rgba(255, 114, 127, .06); }
.sidebar-shade { display: none; }

.workspace { min-width: 0; min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 20; top: 0; height: 82px; display: flex; align-items: center; gap: 20px; padding: 0 34px; border-bottom: 1px solid #243139; background: rgba(15, 22, 27, .94); backdrop-filter: blur(14px); }
.menu-button { display: none; padding: 0; border: 0; color: var(--muted); background: transparent; }
.search-box { width: min(430px, 38vw); display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 15px; border: 1px solid var(--line); border-radius: 9px; color: #8197a3; background: #121b21; }
.search-box input { width: 100%; min-height: 0; padding: 0; border: 0; box-shadow: none; background: transparent; }
.list-toolbar { display: flex; align-items: center; gap: 14px; padding: 0 22px 18px; }.list-toolbar .search-box { width: min(620px, 100%); }
.status-filter { width: 190px; margin-left: auto; }.refresh-button { white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; color: #b5c5ce; }
.shanghai-clock { font-variant-numeric: tabular-nums; white-space: nowrap; }
.timezone-label { padding-right: 24px; color: var(--muted); }
.account { display: flex; align-items: center; gap: 10px; padding-left: 24px; border-left: 1px solid #39464d; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--accent); background: var(--surface); font-weight: 750; }
.account strong, .account small { display: block; }
.account small { margin-top: 2px; }

.page { width: 100%; max-width: 1540px; margin: 0 auto; padding: 28px 30px 50px; }
.v3-content { width: 100%; }
.page-head, .section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.page-head { margin-bottom: 24px; }
.page-head p, .section-head p { margin-bottom: 0; }
.eyebrow { display: block; margin-bottom: 10px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.summary { display: flex; align-items: stretch; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(135deg, #19242b, #151e24); }
.summary span { min-width: 120px; display: grid; gap: 3px; padding: 14px 22px; color: var(--muted); }
.summary span + span { border-left: 1px solid var(--line); }
.summary strong { color: var(--text); font-size: 25px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(135deg, #1a252c, #151f25); }
.metric { min-height: 108px; display: grid; align-content: center; gap: 6px; padding: 18px 28px; border-left: 1px solid var(--line); }
.metric:first-child { border-left: 0; }
.metric span { color: var(--muted); }
.metric strong { color: var(--text); font-size: 30px; }
.metric.good strong { color: var(--success); }.metric.wait strong { color: var(--warning); }.metric.muted strong { color: #9eb0ba; }
.page-primary { align-self: center; min-height: 52px; padding: 0 24px; font-size: 15px; }

.card { padding: 22px; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(145deg, rgba(29, 41, 49, .96), rgba(23, 33, 40, .96)); box-shadow: 0 15px 45px rgba(0, 0, 0, .08); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid > .card { margin: 0; }
.grid:not(.setup-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.feature-card { position: relative; min-height: 150px; color: inherit; transition: transform .15s, border-color .15s, box-shadow .15s; }
.feature-card::after { content: "→"; position: absolute; right: 22px; bottom: 18px; color: var(--accent); font-size: 22px; }
.feature-card:hover { transform: translateY(-2px); border-color: rgba(102, 219, 204, .55); box-shadow: 0 18px 45px rgba(0, 0, 0, .18); }
.feature-card p { margin-bottom: 0; }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin-bottom: 5px; }
.section-head > a { white-space: nowrap; }

label { display: grid; gap: 7px; margin: 13px 0; color: #b8c8cf; font-size: 13px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; color: var(--text); background: #111a20; }
textarea { min-height: 100px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #60737d; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(102, 219, 204, .12); }
select { color-scheme: dark; }
button, .button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 8px; color: #071514; background: var(--accent); font-weight: 750; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:hover, .button:hover { color: #071514; background: #8ceadd; border-color: #8ceadd; }
button.secondary, .button.secondary { color: var(--accent); background: transparent; }
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); }
button.danger, .button.danger { color: var(--danger); border-color: rgba(255, 114, 127, .5); background: rgba(255, 114, 127, .07); }
button.danger:hover, .button.danger:hover { border-color: var(--danger); background: rgba(255, 114, 127, .14); }
button:disabled, input[type="submit"]:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.field-pair, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
.inline-form { display: flex; align-items: center; gap: 7px; }
.inline-form select { min-width: 130px; max-width: 180px; margin: 0; }
.inline-form button { min-height: 36px; }

.table-card { padding: 0; overflow: hidden; }
.table-heading { padding: 20px 22px 0; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { color: #9eb1bc; background: #162028; font-size: 12px; font-weight: 650; letter-spacing: .02em; }
td { color: #d4e0e4; font-size: 13px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(102, 219, 204, .035); }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; }
.message-cell { min-width: 260px; max-width: 540px; white-space: normal; line-height: 1.5; }
.empty { padding: 42px 20px !important; color: var(--subtle) !important; text-align: center !important; }
.empty strong, .empty span { display: block; }
.empty strong { margin-bottom: 5px; color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border: 1px solid transparent; border-radius: 999px; color: #b6c6cd; background: rgba(158, 176, 186, .1); font-size: 12px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 9px currentColor; }
.status.good { color: var(--success); border-color: rgba(71, 216, 154, .18); background: rgba(71, 216, 154, .1); }
.status.bad { color: var(--danger); border-color: rgba(255, 114, 127, .18); background: rgba(255, 114, 127, .1); }
.status.wait { color: var(--warning); border-color: rgba(255, 200, 92, .18); background: rgba(255, 200, 92, .1); }
.code-inline, code { color: #a9c8cf; font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }

.record-grid, .draft-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.record { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.record-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.customer-delete-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.draft { display: grid; gap: 5px; padding: 16px; text-align: left; color: #f0d08a; border-color: rgba(255, 200, 92, .35); background: rgba(255, 200, 92, .07); }
.draft:hover { color: #f0d08a; border-color: var(--warning); background: rgba(255, 200, 92, .12); }
.draft span { color: #d7af63; font-weight: 400; }
.count { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 50%; color: #10201e; background: var(--accent); font-weight: 800; }

.notice, .flash { margin-bottom: 16px; padding: 13px 15px; border: 1px solid rgba(102, 219, 204, .28); border-radius: 8px; color: #bdece6; background: rgba(102, 219, 204, .08); }
.notice.error, .flash.error { color: #ffc3c8; border-color: rgba(255, 114, 127, .35); background: rgba(255, 114, 127, .09); }
.notice.success { color: #a9f0ce; border-color: rgba(71, 216, 154, .3); background: rgba(71, 216, 154, .08); }
.back { display: inline-block; margin-bottom: 14px; color: var(--accent); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(290px, .8fr); gap: 16px; }
.code, .code-large { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.55; }
.code-large { min-height: 52vh; }
.test-history { display: grid; gap: 8px; margin-top: 16px; }
.history-row { display: grid; gap: 6px; padding: 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #141e24; }
.history-row:hover { border-color: var(--accent); }
.log { max-height: 430px; overflow: auto; padding: 17px; border: 1px solid #293a42; border-radius: 8px; color: #cae7e4; background: #0b1115; font: 12px/1.65 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.totals { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.totals > div { display: grid; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #131d23; }
.totals strong { color: var(--accent); font-size: 24px; }
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.detail-row strong { max-width: 65%; color: var(--text); text-align: right; overflow-wrap: anywhere; }
.modal-section { margin-bottom: 22px; }
.test-summary { display: flex; justify-content: space-between; gap: 15px; }
.secret-value { margin: 14px 0; }

.admin-dialog { width: min(1000px, 94vw); max-height: 90vh; margin: auto; padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 26px 90px rgba(0, 0, 0, .65); }
.admin-dialog::backdrop, .form-dialog::backdrop { background: rgba(3, 8, 11, .78); backdrop-filter: blur(3px); }
.form-dialog { width: min(560px, 94vw); max-height: 90vh; margin: auto; padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text); background: var(--surface); box-shadow: 0 26px 90px rgba(0, 0, 0, .65); }.form-dialog > form, .dialog-body { padding: 20px; }.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.modal-head { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--line); background: #182229; }
.modal-head h2 { margin: 0; }
.icon-button { min-width: 38px; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 22px; }
.icon-button:hover { color: var(--text); background: transparent; }
#modal-content { padding: 20px; }
.management-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }.management-grid > form, .management-action { min-height: 138px; display: flex; flex-direction: column; justify-content: space-between; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: #141e24; }.management-grid > form label { margin-top: 0; }.management-action p { margin: 5px 0 14px; }.management-action form { margin: 0; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 15%, rgba(102, 219, 204, .12), transparent 32%), #0d1419; }
.platform-auth .v3-content { display: grid; place-items: center; }
.login-card { width: min(430px, 100%); margin: 0 auto; padding: 38px; border-color: #31454e; box-shadow: 0 26px 80px rgba(0, 0, 0, .35); }
.login-brand { margin-bottom: 26px; color: var(--accent); font-size: 32px; font-weight: 800; text-align: center; letter-spacing: -.04em; }.login-brand b { color: #fff; }
.login-card h1, .login-card > p { text-align: center; }
.login-card .stack { display: grid; gap: 14px; }
.login-foot { display: block; margin-top: 22px; text-align: center; }
.muted { color: var(--muted); }
.firmware-current { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: center; }
.firmware-panel + .firmware-panel { margin-top: 18px; }
.badge { display: inline-flex; align-items: center; padding: 4px 9px; border: 1px solid var(--line); border-radius: 20px; font-size: 12px; white-space: nowrap; }
.badge.success { color: #9aeacb; background: rgba(71,216,154,.08); border-color: rgba(71,216,154,.3); }
.badge.pending { color: #f0d896; background: rgba(230,187,82,.08); border-color: rgba(230,187,82,.3); }
.badge.failed { color: var(--muted); }
.install-facts { margin: 16px 0; }
.install-facts > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.install-facts dt { color: var(--muted); flex-shrink: 0; }
.install-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.install-command { padding: 18px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.file-digest { display: block; margin: 12px 0; overflow-wrap: anywhere; }
.file-name { overflow-wrap: anywhere; }
.firmware-record > form { margin-top: 18px; }
.request-number { display: grid; gap: 6px; margin: 12px 0; }
.request-number strong { font-family: monospace; font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.install-actions { display: flex; gap: 12px; margin-top: 18px; }
@media(max-width:680px) { .firmware-current { grid-template-columns: 1fr; gap: 12px; } }

@media (max-width: 1100px) {
  .grid, .grid:not(.setup-grid), .editor-layout { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }.metric:nth-child(4) { border-top: 1px solid var(--line); }
  .timezone-label { display: none; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .brand small { display: none; }
  .app-shell.sidebar-open .sidebar { transform: none; }
  .sidebar-shade { position: fixed; z-index: 25; inset: 0; border: 0; border-radius: 0; background: rgba(3, 8, 11, .72); }
  .app-shell.sidebar-open .sidebar-shade { display: block; }
  .workspace { margin-left: 0; }
  .topbar { height: 66px; padding: 0 16px; }
  .menu-button { display: grid; place-items: center; }
  .page { padding: 22px 16px 38px; }
}
@media (max-width: 680px) {
  .page-head, .section-head { display: grid; }
  .summary { width: 100%; }
  .summary span { min-width: 0; flex: 1; padding: 12px; }
  .field-pair, .detail-grid, .totals { grid-template-columns: 1fr; }
  .management-grid { grid-template-columns: 1fr; }
  .list-toolbar { align-items: stretch; flex-direction: column; }.status-filter { width: 100%; margin-left: 0; }
  .account > span:last-child, .shanghai-clock { display: none; }
  .record-grid { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .actions { min-width: 170px; }
  h1 { font-size: 30px; }
}
