:root {
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #172033;
  background: #f4f6fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 12% 0, #ece9ff 0, transparent 32%), #f4f6fb;
}
.shell { max-width: 1440px; margin: auto; padding: 34px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.eyebrow { margin: 0; color: #6c55e8; font-size: 12px; letter-spacing: .22em; font-weight: 800; }
.topbar h1 { font-size: 30px; margin: 5px 0 4px; }
.sub, .section-title p, .login-card p, .generated p { margin: 0; color: #6d7890; font-size: 13px; }
.header-actions, .filters, .generated-head { display: flex; gap: 10px; align-items: center; }
.pill { padding: 9px 14px; border-radius: 99px; background: #eef0f7; color: #606b80; font-size: 13px; }
.pill.ok { background: #e8fbf3; color: #087b50; }
.hidden { display: none !important; }
.login-card, .card { background: #fff; border: 1px solid #e3e7f0; border-radius: 18px; box-shadow: 0 14px 40px rgba(41,52,83,.07); }
.login-card { max-width: 440px; margin: 80px auto; padding: 36px; }
.login-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: linear-gradient(135deg,#7057ed,#9a6af5); color: #fff; font-size: 24px; font-weight: 800; }
.login-card h2 { margin: 20px 0 6px; }
.login-card form { margin-top: 24px; }
.stats { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid #e3e7f0; border-radius: 14px; padding: 16px; }
.stat span { display: block; color: #788398; font-size: 12px; }
.stat strong { display: block; margin-top: 7px; font-size: 25px; }
.grid { display: grid; grid-template-columns: 360px minmax(0,1fr); gap: 16px; }
.card { padding: 20px; }
.section-title { margin-bottom: 17px; }
.section-title h2 { margin: 0 0 4px; font-size: 18px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.selection-summary { color: #657086; font-size: 12px; white-space: nowrap; }
.bulk-action { padding: 8px 10px; font-size: 12px; }
.select-col { width: 38px; text-align: center; }
.select-col input { width: 16px; height: 16px; accent-color: #6650e8; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span-2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 7px; color: #4f5a70; font-size: 13px; font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid #d9dfeb; border-radius: 10px; background: #fff; color: #172033; padding: 11px 12px; font: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #7961ef; box-shadow: 0 0 0 3px rgba(121,97,239,.12); }
button { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; cursor: pointer; }
.primary { background: linear-gradient(135deg,#6650e8,#9566f2); color: #fff; }
.danger { background: #fff0f1; color: #c73144; }
.warn { background: #fff4de; color: #9a5e00; }
.ghost { background: #fff; border: 1px solid #dbe1ec; color: #344058; }
.wide { width: 100%; margin-top: 14px; }
.generated { margin-top: 17px; border: 1px solid #d8d0ff; background: #f7f4ff; border-radius: 12px; padding: 13px; }
.generated textarea { height: 150px; margin-top: 10px; font-family: Consolas,monospace; font-size: 12px; }
.generated p { margin-top: 8px; }
.table-card { min-width: 0; }
.table-wrap { overflow: auto; max-height: 590px; border: 1px solid #edf0f5; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 13px; }
th { position: sticky; top: 0; background: #f7f8fb; color: #657086; text-align: left; padding: 11px; z-index: 1; }
td { padding: 12px 11px; border-top: 1px solid #edf0f5; vertical-align: top; }
.key-hint { font-family: Consolas,monospace; font-weight: 700; }
.badge { display: inline-block; border-radius: 99px; padding: 4px 9px; font-size: 12px; font-weight: 700; }
.badge.unused { background: #eef1f6; color: #667085; }
.badge.active { background: #e8fbf3; color: #087b50; }
.badge.expired { background: #fff0f1; color: #c73144; }
.badge.disabled { background: #fff4de; color: #9a5e00; }
.badge.revoked { background: #fff0f1; color: #c73144; }
.muted { color: #7c8799; font-size: 12px; }
.remaining { margin-top: 5px; color: #087b50; font-size: 12px; font-weight: 800; }
.remaining.expired { color: #c73144; }
.credit { margin-top: 5px; color: #087b50; font-size: 12px; font-weight: 700; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { padding: 7px 9px; font-size: 12px; }
.device-card { margin-top: 16px; }
.model-card { margin-top: 16px; }
.models { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.model { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 14px; border: 1px solid #edf0f5; border-radius: 12px; padding: 13px; }
.devices { display: grid; gap: 9px; }
.device { display: grid; grid-template-columns: 1fr 1fr 1fr auto; align-items: center; gap: 14px; border: 1px solid #edf0f5; border-radius: 12px; padding: 13px; }
.toast { position: fixed; right: 28px; bottom: 28px; max-width: 420px; padding: 13px 17px; border-radius: 12px; background: #182033; color: #fff; box-shadow: 0 12px 36px rgba(0,0,0,.2); }
.error { min-height: 20px; color: #c73144 !important; margin-top: 12px !important; }

.domain-tabs { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.domain-tab { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "number title" "number detail" "number mode"; column-gap: 14px; text-align: left; padding: 19px; border: 2px solid #e2e6ef; border-radius: 16px; background: #fff; color: #344058; box-shadow: 0 8px 25px rgba(41,52,83,.05); }
.domain-tab:hover { border-color: #bdb2fb; }
.domain-tab.active { border-color: #6d56e9; background: linear-gradient(135deg,#f5f2ff,#fff); box-shadow: 0 10px 28px rgba(102,80,232,.13); }
.domain-tab .domain-number { grid-area: number; align-self: center; padding: 7px 10px; border-radius: 9px; color: #6c55e8; background: #ece8ff; font-size: 12px; font-weight: 800; }
.domain-tab strong { grid-area: title; font-size: 17px; }
.domain-tab small { grid-area: detail; margin-top: 5px; color: #6d7890; }
.domain-tab em { grid-area: mode; margin-top: 8px; color: #087b50; font-size: 12px; font-style: normal; font-weight: 800; }
.domain-banner { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; padding: 18px 20px; border: 1px solid #ded8ff; border-radius: 16px; background: #f8f6ff; }
.domain-banner h2 { margin: 7px 0 4px; font-size: 20px; }
.domain-banner p { margin: 0; color: #616d83; font-size: 13px; }
.domain-badge { display: inline-block; padding: 4px 9px; border-radius: 99px; background: #6c55e8; color: #fff; font-size: 11px; font-weight: 800; }
.isolation-note { min-width: 210px; padding: 11px 14px; border-radius: 12px; background: #fff; color: #6d7890; text-align: right; font-size: 12px; }
.isolation-note strong { color: #087b50; }
#dashboard[data-domain="local"] .platform-only { display: none !important; }
#dashboard[data-domain="local"] .domain-banner { border-color: #bfe8d7; background: #f1fbf7; }
#dashboard[data-domain="local"] .domain-badge { background: #087b50; }

@media (max-width: 980px) {
  .shell { padding: 20px; }
  .stats { grid-template-columns: repeat(2,1fr); }
  .grid { grid-template-columns: 1fr; }
  .device { grid-template-columns: 1fr; }
  .models { grid-template-columns: 1fr; }
  .topbar { gap: 18px; }
  .sub { max-width: 620px; }
  .domain-tabs { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .shell { padding: 14px; }
  .topbar, .toolbar { flex-direction: column; align-items: stretch; }
  .stats { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .login-card { margin: 35px auto; padding: 24px; }
  .domain-banner { flex-direction: column; align-items: stretch; }
  .isolation-note { min-width: 0; text-align: left; }
}
