:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --text: #172126;
  --muted: #64727a;
  --line: #dce3e7;
  --line-strong: #c6d0d5;
  --primary: #087f72;
  --primary-dark: #06675e;
  --primary-soft: #e2f4f1;
  --blue: #2867b2;
  --blue-soft: #e8f0fa;
  --danger: #c73843;
  --danger-soft: #fbeaec;
  --warning: #a16207;
  --warning-soft: #fff4d6;
  --success: #247a46;
  --success-soft: #e8f5ed;
  --sidebar: #182126;
  --sidebar-muted: #9dabb2;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 31, 36, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 232px; flex-direction: column; background: var(--sidebar); color: white; }
.brand { display: flex; align-items: center; gap: 11px; min-height: 72px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; flex: 0 0 auto; border-radius: 6px; background: #18a393; color: white; font-weight: 800; }
.brand-mark.large { width: 46px; height: 46px; font-size: 17px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--sidebar-muted); font-size: 11px; }
.sidebar nav { display: grid; gap: 4px; padding: 16px 10px; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 8px 11px; border-radius: 5px; color: var(--sidebar-muted); font-weight: 600; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: white; text-decoration: none; }
.sidebar nav a.active { background: #26353a; color: #71d4c7; }
.sidebar-footer { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; gap: 9px; margin-top: auto; padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #34474e; color: #a9eee5; font-weight: 700; }
.identity strong, .identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: var(--sidebar-muted); font-size: 11px; }
.sidebar .icon-button { color: var(--sidebar-muted); }

.main-shell { min-height: 100vh; margin-left: 232px; }
.topbar { display: flex; min-height: 72px; align-items: center; gap: 16px; padding: 13px 26px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; margin-left: auto; }
.content { padding: 22px 26px 36px; }
.mobile-menu { display: none !important; }

.button { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.button:hover { text-decoration: none; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line-strong); background: var(--surface); color: var(--text); }
.button.success { border-color: #add5ba; background: var(--success-soft); color: var(--success); }
.button.warning { border-color: #efd592; background: var(--warning-soft); color: var(--warning); }
.button.danger { border-color: #efb7bc; background: var(--danger-soft); color: var(--danger); }
.button.full { width: 100%; }
.button:disabled { cursor: default; opacity: .5; }
.icon-button { display: inline-grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--surface-muted); color: var(--text); }
.danger-icon { color: var(--danger); }

.alert { display: flex; align-items: center; gap: 8px; margin: 18px 26px 0; padding: 10px 13px; border: 1px solid #b7dbc7; border-radius: var(--radius); background: var(--success-soft); color: var(--success); }
.alert.error { border-color: #efb7bc; background: var(--danger-soft); color: var(--danger); }

.stats-grid { display: grid; grid-template-columns: repeat(6, minmax(135px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats-grid article { position: relative; min-height: 112px; padding: 17px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stats-grid span { color: var(--muted); font-size: 12px; }
.stats-grid strong { display: block; margin-top: 8px; font-size: 26px; line-height: 1; }
.stats-grid svg { position: absolute; right: 15px; bottom: 15px; width: 23px; height: 23px; color: var(--primary); }
.security-policies { grid-template-columns: repeat(4, minmax(170px, 1fr)); }
.security-policies small { display: block; max-width: calc(100% - 28px); margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 18px; }
.detail-layout { align-items: start; margin-bottom: 18px; }
.activation-note { margin: 0 0 18px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-heading { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 17px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.padded { padding: 18px; }
.table-panel { overflow: hidden; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 40px; padding: 9px 13px; background: var(--surface-muted); color: var(--muted); font-size: 11px; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { min-height: 48px; padding: 11px 13px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fbfcfc; }
.empty { padding: 40px 16px !important; color: var(--muted); text-align: center; }
.block { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { display: inline-block; max-width: 260px; overflow: hidden; color: #3d515a; font-family: "Cascadia Mono", Consolas, monospace; font-size: 12px; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.machine-key { max-width: 230px; }
.module-summary { min-width: 230px; color: #45545b; }
.module-summary span:not(.muted-copy):not(:last-child)::after { margin: 0 6px; color: var(--line-strong); content: "·"; }
.notice-preview { max-width: 460px; overflow: hidden; color: #45545b; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: 11px; font-weight: 700; }
.badge.active, .badge.unused { background: var(--success-soft); color: var(--success); }
.badge.frozen { background: var(--warning-soft); color: var(--warning); }
.badge.revoked { background: var(--danger-soft); color: var(--danger); }
.badge.redeemed { background: var(--blue-soft); color: var(--blue); }

.activity-list { margin: 0; padding: 4px 17px 12px; list-style: none; }
.activity-list li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity-list li:last-child { border-bottom: 0; }
.activity-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.activity-icon svg { width: 14px; height: 14px; }
.activity-list strong, .activity-list small { display: block; }
.activity-list small { color: var(--muted); font-size: 11px; }

.filters { display: flex; gap: 9px; margin-bottom: 14px; }
.search { position: relative; flex: 1; max-width: 420px; }
.search svg { position: absolute; top: 9px; left: 10px; width: 17px; color: var(--muted); }
.search input { padding-left: 34px; }
input, select, textarea { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 5px; outline: none; background: white; color: var(--text); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(8,127,114,.12); }
label { display: grid; gap: 5px; color: #45545b; font-size: 12px; font-weight: 650; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.option-group { display: flex; gap: 18px; margin: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 5px; }
.option-group legend { padding: 0 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.option-group label { display: flex; grid-auto-flow: column; align-items: center; gap: 7px; }
.option-group input { width: 16px; min-height: 16px; margin: 0; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; }
.stack-form { display: grid; gap: 15px; }
.row-actions { display: flex; align-items: center; gap: 3px; }
.status-actions { display: grid; gap: 10px; }
.status-actions form { display: flex; gap: 8px; }
.status-actions input { flex: 1; }

.account-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.account-header h2 { margin: 7px 0 0; font-size: 22px; }
.account-header p { margin: 2px 0 0; color: var(--muted); }
.account-header dl { display: flex; gap: 34px; margin: 0; }
.account-header dl div { min-width: 100px; }
.account-header dt { color: var(--muted); font-size: 11px; }
.account-header dd { margin: 3px 0 0; font-weight: 700; }

.modal { width: min(620px, calc(100% - 28px)); padding: 0; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); box-shadow: 0 18px 55px rgba(15,25,30,.25); }
.modal::backdrop { background: rgba(13, 24, 29, .55); }
.modal-content { display: grid; gap: 18px; padding: 18px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { margin: 0; font-size: 17px; }
.modal-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

.issued-panel { overflow: hidden; }
.issued-codes { width: calc(100% - 34px); min-height: 420px; margin: 17px; padding: 15px; background: #10181c; color: #d7f5ef; font-family: "Cascadia Mono", Consolas, monospace; line-height: 1.8; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-section { overflow: hidden; }
.settings-list { margin: 0; padding: 8px 17px 16px; }
.settings-list div { display: grid; grid-template-columns: 120px 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
.settings-list dt { color: var(--muted); }
.settings-list dd { margin: 0; font-family: "Cascadia Mono", Consolas, monospace; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.status-dot::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.status-dot.ok { color: var(--success); }
.public-key { min-height: 160px; margin: 17px; width: calc(100% - 34px); font-family: "Cascadia Mono", Consolas, monospace; font-size: 11px; }
.settings-section > .button { margin: 0 17px 17px; }
details summary { cursor: pointer; color: var(--primary-dark); }
details pre { max-width: 420px; overflow: auto; padding: 8px; background: var(--surface-muted); font-size: 11px; white-space: pre-wrap; }

.auth-body { background: #eef2f3; }
.auth-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.auth-panel { width: min(420px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 12px 34px rgba(24,33,38,.1); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 26px; }
.auth-brand h1 { margin: 0; font-size: 19px; }
.auth-brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.auth-panel .alert { margin: 0 0 17px; }
.auth-panel footer { margin-top: 22px; color: var(--muted); font-size: 11px; text-align: center; }
.error-state { padding: 90px 20px; text-align: center; }
.error-state span { color: var(--line-strong); font-size: 72px; font-weight: 800; }
.error-state h2 { margin: 0 0 20px; }

.setup-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 60px; }
.setup-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.setup-header h1 { margin: 1px 0 2px; font-size: 26px; }
.setup-header p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.setup-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; gap: 20px; }
.setup-checks { position: sticky; top: 20px; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.setup-checks h2 { margin: 0 0 12px; font-size: 14px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.check-row svg { flex: 0 0 auto; color: var(--success); }
.check-row strong, .check-row small { display: block; }
.check-row small { overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.setup-note { margin-top: 14px; padding: 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); }
.setup-note p { margin: 3px 0 0; color: #38544f; font-size: 11px; }
.setup-form { overflow: hidden; }
.setup-form > section { padding: 19px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-title > span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-weight: 800; }
.section-title h2 { margin: 0; font-size: 15px; }
.section-title p { margin: 1px 0 0; color: var(--muted); font-size: 11px; }
.check-label { display: flex; grid-auto-flow: column; grid-template-columns: 18px 1fr; align-items: center; justify-content: start; }
.check-label input { width: 16px; min-height: 16px; margin: 0; }
.setup-submit { width: calc(100% - 38px); margin: 19px; }
.setup-alert { margin: 0 0 18px; }
.setup-complete { width: min(520px, 100%); text-align: center; }
.completion-icon { display: grid; width: 54px; height: 54px; margin: 0 auto 12px; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.completion-icon svg { width: 28px; height: 28px; }
.setup-complete h1 { margin: 0 0 5px; }
.setup-complete > p { margin: 0 0 18px; color: var(--muted); }
.credential-list { margin: 0 0 18px; text-align: left; }
.credential-list div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.credential-list dt { color: var(--muted); }
.credential-list dd { margin: 0; overflow-wrap: anywhere; }
.product-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.product-panel { overflow: hidden; }
.policy-switches { display: grid; gap: 7px; }
.toggle-row { display: grid; grid-template-columns: 18px 1fr; align-items: start; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); }
.toggle-row input { width: 16px; min-height: 16px; margin: 2px 0 0; }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { color: var(--muted); font-size: 10px; font-weight: 400; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.diagnostic-item { display: flex; min-height: 72px; align-items: flex-start; gap: 10px; padding: 13px; border: 1px solid #b7dbc7; border-radius: var(--radius); background: var(--success-soft); }
.diagnostic-item.failed { border-color: #efb7bc; background: var(--danger-soft); }
.diagnostic-item svg { flex: 0 0 auto; color: var(--success); }
.diagnostic-item.failed svg { color: var(--danger); }
.diagnostic-item strong, .diagnostic-item small { display: block; }
.diagnostic-item small { overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.maintenance-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(290px, .5fr); gap: 18px; margin-bottom: 18px; }
.update-panel { overflow: hidden; }
.compact-heading { margin: 0; font-size: 15px; }
.muted-copy { margin: 3px 0 0; color: var(--muted); font-size: 11px; }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .diagnostic-grid { grid-template-columns: repeat(2, 1fr); }
  .maintenance-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-shell { margin-left: 0; }
  .mobile-menu { display: inline-grid !important; }
  .topbar { padding: 11px 14px; }
  .topbar h1 { font-size: 17px; }
  .topbar-actions .button { width: 36px; padding: 0; }
  .topbar-actions .button:not(.secondary) { font-size: 0; }
  .topbar-actions .button svg { width: 18px; }
  .content { padding: 14px; }
  .alert { margin: 12px 14px 0; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .stats-grid article { min-height: 98px; padding: 13px; }
  .account-header { align-items: flex-start; flex-direction: column; }
  .account-header dl { width: 100%; gap: 14px; overflow-x: auto; }
  .form-grid, .settings-grid { grid-template-columns: 1fr; }
  .product-grid, .diagnostic-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filters { align-items: stretch; flex-direction: column; }
  .search { max-width: none; }
  .auth-panel { padding: 21px; }
  .setup-layout { grid-template-columns: 1fr; }
  .setup-checks { position: static; }
  .setup-shell { width: min(100% - 24px, 1120px); padding-top: 20px; }
}
