:root {
  color-scheme: dark;
  --canvas: #0b1118;
  --nav: #101923;
  --surface: #15212d;
  --surface-raised: #1b2a38;
  --border: #2a3d4d;
  --text: #f1f5f7;
  --muted: #aab9c4;
  --primary: #45b7a4;
  --primary-hover: #5bc8b6;
  --success: #43c59e;
  --warning: #f2b84b;
  --danger: #f06a73;
  --info: #5aa7e8;
  --radius: 12px;
  --shadow: 0 16px 40px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--canvas);
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }
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(69, 183, 164, .45);
}
.skip-link {
  position: fixed; left: 16px; top: 16px; z-index: 1000;
  padding: 10px 14px; background: var(--primary); color: #07110f;
  white-space: nowrap; transform: translateY(-220%);
}
.skip-link:focus { transform: translateY(0); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px;
  display: flex; flex-direction: column; background: var(--nav);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; }
.brand strong { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.brand-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 10px;
  color: #07110f; background: var(--primary); font-weight: 800;
}
.brand-mark.large { width: 50px; height: 50px; font-size: 22px; }
.nav-list { display: grid; gap: 6px; }
.nav-list a {
  min-height: 44px; display: flex; align-items: center;
  padding: 10px 13px; border-radius: 9px; color: var(--muted); font-weight: 600;
}
.nav-list a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-list a.active { color: var(--text); background: var(--surface-raised); border-left: 3px solid var(--primary); }
.sidebar-footer {
  margin-top: auto; display: grid; gap: 8px; padding: 18px 8px 0;
  color: var(--muted); border-top: 1px solid var(--border);
}
.link-button {
  appearance: none; padding: 0; border: 0; background: none;
  color: var(--primary-hover); cursor: pointer;
}
.main { min-width: 0; }
.content { width: min(100%, 1600px); margin: 0 auto; padding: 36px 40px 64px; }
.mobile-header { display: none; }
.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 24px; margin-bottom: 28px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 30px); line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 18px; }
.page-header p:last-child, .section-heading p { color: var(--muted); }
.eyebrow {
  margin-bottom: 6px; color: var(--primary) !important;
  font-size: 12px; font-weight: 800; letter-spacing: .11em;
}
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric-grid-wide { grid-template-columns: repeat(3, 1fr); }
.metric-card, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.metric-card { padding: 20px; }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 6px 0; font-size: 34px; font-variant-numeric: tabular-nums; }
.panel { padding: 22px; margin-bottom: 20px; }
.panel.narrow { max-width: 620px; }
.section-heading {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.section-heading .eyebrow { margin-bottom: 2px; }
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.detail-grid .panel { margin-bottom: 0; }
.strategy-list, .compact-list, .management-list { display: grid; gap: 10px; }
.strategy-list article, .management-list article, .compact-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 58px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 9px; background: rgba(255,255,255,.018);
}
.compact-list a { color: var(--text); }
.compact-list a:hover { background: var(--surface-raised); text-decoration: none; }
.strategy-list code, .management-list code, td code, .detail-list code {
  display: block; margin-top: 3px; color: var(--muted);
}
.strategy-count { text-align: right; }
.strategy-count strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.strategy-count span { color: var(--muted); font-size: 12px; }
.right-align { text-align: right; }
.right-align small { display: block; margin-top: 4px; color: var(--muted); }
.badge, .strategy-badge {
  display: inline-flex; align-items: center; min-height: 28px;
  padding: 4px 9px; border-radius: 999px; font-weight: 700; font-size: 12px;
  color: var(--text); background: var(--surface-raised); border: 1px solid var(--border);
}
.badge.large { min-height: 36px; padding: 7px 13px; font-size: 14px; }
.badge.warning, .state-pending { color: #ffe2a8; border-color: #71582a; background: #382d18; }
.state-active { color: #a9f1db; border-color: #286651; background: #173a30; }
.state-expired, .state-suspended { color: #ffd49a; border-color: #715125; background: #382a17; }
.state-revoked { color: #ffc0c5; border-color: #7b343b; background: #3e1e22; }
.filter-bar {
  display: grid; grid-template-columns: 1.5fr repeat(3, 1fr) auto;
  align-items: end; gap: 12px; margin-bottom: 16px;
}
label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  color: var(--text); background: #0f1922; border: 1px solid var(--border);
  border-radius: 8px;
}
textarea { resize: vertical; }
.stack-form { display: grid; gap: 16px; }
.stack-form > small { color: var(--muted); margin-top: -10px; }
.button {
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); background: var(--surface-raised);
  font-weight: 750; cursor: pointer; transition: background-color .16s ease, border-color .16s ease;
}
.button:hover { text-decoration: none; background: #243747; }
.button.primary { color: #07110f; border-color: var(--primary); background: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { background: transparent; }
.button.warning { color: #171006; border-color: var(--warning); background: var(--warning); }
.button.danger { color: #1b090b; border-color: var(--danger); background: var(--danger); }
.button.small { min-height: 36px; padding: 6px 11px; font-size: 13px; }
.button.full { width: 100%; }
.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); background: #111c26; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.tabular, .countdown, code { font-variant-numeric: tabular-nums; }
.countdown { color: var(--primary-hover); }
.countdown.large { min-height: 28px; font-size: 18px; font-weight: 800; }
.expired-text { color: var(--warning); }
.empty-state { margin: 12px 0; color: var(--muted); text-align: center; }
.expiry-display {
  padding: 18px; margin-bottom: 18px; border-radius: 10px;
  background: #0f1922; border: 1px solid var(--border);
}
.expiry-display span, .expiry-display strong { display: block; }
.expiry-display span { color: var(--muted); }
.expiry-display strong { margin: 6px 0 4px; font-size: 24px; font-variant-numeric: tabular-nums; }
.duration-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.custom-expiry { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-top: 14px; }
.detail-list { margin: 0; display: grid; }
.detail-list > div { display: grid; grid-template-columns: 100px 1fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; min-width: 0; }
.wrap-code { overflow-wrap: anywhere; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.danger-panel { border-color: #603139; }
.back-link { display: inline-block; margin-bottom: 14px; }
.flash-region { margin-bottom: 12px; }
.flash { padding: 12px 14px; margin-bottom: 10px; border-radius: 8px; border: 1px solid var(--border); }
.flash-success { color: #b7f5e1; background: #15382f; border-color: #2b6b58; }
.flash-error { color: #ffd0d3; background: #3d1e22; border-color: #7c353d; }
.auth-main { grid-column: 1 / -1; min-height: 100vh; display: grid; place-items: center; }
.auth-main .content { width: min(100%, 520px); padding: 24px; }
.auth-card {
  padding: 32px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow);
}
.auth-brand { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 26px; }
.auth-brand p:last-child { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    min-height: 64px; padding: 10px 20px; background: var(--nav); border-bottom: 1px solid var(--border);
  }
  .mobile-header nav { display: flex; flex-wrap: wrap; gap: 12px; }
  .content { padding: 28px 20px 48px; }
  .split-grid, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .page-header { align-items: stretch; flex-direction: column; }
  .metric-grid, .filter-bar, .duration-grid, .custom-expiry { grid-template-columns: 1fr; }
  .metric-card strong { font-size: 28px; }
  .panel { padding: 16px; }
  .table-panel { padding: 8px 14px; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  tbody tr:last-child { border-bottom: 0; }
  td { display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 10px; padding: 8px 0; border: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  td:not([data-label]) { display: block; }
  .detail-list > div { grid-template-columns: 84px 1fr; }
  .strategy-list article { align-items: flex-start; flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
