:root {
  color-scheme: light dark;
  --bg: #f5f4f8;
  --surface: rgba(255,255,255,.82);
  --surface-solid: #fff;
  --surface-soft: rgba(247,246,250,.8);
  --text: #201b22;
  --muted: #716974;
  --line: rgba(69,43,59,.12);
  --accent: #bd1646;
  --accent-strong: #99103a;
  --accent-soft: rgba(189,22,70,.1);
  --good: #16865c;
  --warn: #bb7611;
  --bad: #c53742;
  --shadow: 0 24px 70px rgba(64,31,45,.12);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 8% 0%, rgba(201,42,92,.09), transparent 30%), radial-gradient(circle at 95% 92%, rgba(101,79,180,.08), transparent 34%), var(--bg); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.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; }
.skip-link { position: fixed; z-index: 99; left: 16px; top: -80px; padding: 12px 18px; border-radius: 12px; color: white; background: var(--accent); transition: top .2s ease; }
.skip-link:focus { top: 16px; }
.ambient { position: fixed; z-index: -1; width: 34vw; height: 34vw; border-radius: 50%; filter: blur(80px); opacity: .2; pointer-events: none; }
.ambient-one { top: -18vw; right: -9vw; background: #d72d61; }
.ambient-two { bottom: -19vw; left: -12vw; background: #8a77de; }
.login-stage { display: grid; place-items: center; min-height: 100vh; padding: 30px 18px; }
.login-card { width: min(100%, 470px); padding: 44px; border: 1px solid rgba(255,255,255,.7); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(28px) saturate(130%); }
.brand-mark { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 26px; border-radius: 21px; color: white; background: linear-gradient(145deg, #dd245b, #9e103b 72%); box-shadow: 0 14px 28px rgba(169,17,60,.28), inset 0 1px rgba(255,255,255,.42); }
.brand-mark span { font-size: 34px; font-weight: 800; line-height: 1; transform: translateY(-1px); }
.brand-mark.small { width: 44px; height: 44px; margin: 0; border-radius: 14px; box-shadow: 0 8px 18px rgba(169,17,60,.22); }
.brand-mark.small span { font-size: 22px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(29px, 4vw, 42px); line-height: 1.12; letter-spacing: -.035em; }
h2 { margin-bottom: 4px; font-size: 21px; letter-spacing: -.02em; }
.lead { margin-bottom: 30px; color: var(--muted); line-height: 1.7; }
.stack { display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface-solid); outline: none; transition: border-color .18s ease, box-shadow .18s ease; }
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: rgba(189,22,70,.7); box-shadow: 0 0 0 4px var(--accent-soft); }
label small { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.5; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 17px; border: 1px solid transparent; border-radius: 13px; font-weight: 800; transition: transform .18s ease, opacity .18s ease, background .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { color: white; background: linear-gradient(135deg, #d62258, #a20d3c); box-shadow: 0 10px 22px rgba(174,19,62,.2); }
.button.secondary { color: var(--accent); border-color: rgba(189,22,70,.18); background: var(--accent-soft); }
.button.ghost { color: var(--text); border-color: var(--line); background: var(--surface); }
.button.danger { color: var(--bad); border-color: rgba(197,55,66,.2); background: rgba(197,55,66,.08); }
.button.compact { min-height: 38px; padding: 7px 12px; border-radius: 11px; font-size: 13px; }
.button.wide { width: 100%; min-height: 50px; }
.form-message { min-height: 21px; margin: 14px 0 0; color: var(--bad); font-size: 13px; }
.security-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; padding: 12px max(22px, calc((100vw - 1280px) / 2)); border-bottom: 1px solid var(--line); background: rgba(247,246,249,.78); backdrop-filter: blur(24px) saturate(140%); }
.brand, .account-chip { display: flex; align-items: center; gap: 12px; }
.brand strong, .brand small, .account-chip strong, .account-chip small { display: block; }
.brand strong { font-size: 16px; }
.brand small, .account-chip small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.account-chip { padding: 5px 6px 5px 11px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.account-chip strong { max-width: 160px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #21a771; box-shadow: 0 0 0 4px rgba(33,167,113,.12); }
.section-nav { position: sticky; z-index: 19; top: 76px; display: flex; gap: 5px; max-width: 1280px; margin: 18px auto 0; padding: 5px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: 0 12px 30px rgba(64,31,45,.06); backdrop-filter: blur(18px); }
.nav-button { min-width: 92px; min-height: 44px; padding: 9px 18px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font-weight: 800; }
.nav-button.active { color: white; background: linear-gradient(135deg, #c71a4d, #9d103b); box-shadow: 0 8px 18px rgba(174,19,62,.18); }
.workspace { width: min(calc(100% - 44px), 1280px); margin: 30px auto 70px; outline: none; }
.page { animation: page-in .25s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 0 2px 24px; }
.page-heading h1 { margin-bottom: 7px; font-size: clamp(28px, 4vw, 40px); }
.page-heading p:not(.eyebrow) { margin-bottom: 0; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card, .panel, .plan-card { border: 1px solid rgba(255,255,255,.7); background: var(--surface); box-shadow: 0 16px 42px rgba(64,31,45,.07); backdrop-filter: blur(20px) saturate(130%); }
.metric-card { position: relative; overflow: hidden; min-height: 168px; padding: 24px; border-radius: var(--radius-lg); }
.metric-card::after { content: ""; position: absolute; right: -38px; bottom: -58px; width: 118px; height: 118px; border-radius: 50%; background: var(--accent-soft); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 13px; font-weight: 800; }
.metric-card strong { display: block; margin: 19px 0 5px; font-size: clamp(26px, 3.2vw, 40px); letter-spacing: -.04em; }
.metric-card small { font-size: 12px; }
.warning-banner { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 13px 17px; border: 1px solid rgba(187,118,17,.22); border-radius: 15px; color: var(--warn); background: rgba(187,118,17,.08); }
.warning-banner strong { white-space: nowrap; }
.warning-banner span { color: var(--text); font-size: 13px; }
.mini-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.mini-stat-grid article { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px 12px; min-height: 72px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.mini-stat-grid span, .mini-stat-grid small { color: var(--muted); font-size: 11px; }
.mini-stat-grid strong { font-size: 20px; letter-spacing: -.03em; }
.mini-stat-grid small { grid-column: 1 / -1; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 18px; margin-top: 18px; }
.panel { overflow: hidden; border-radius: var(--radius-lg); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 23px 24px 17px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; }
.platform-list { display: grid; gap: 17px; padding: 24px; }
.platform-item { display: grid; grid-template-columns: 90px minmax(100px, 1fr) 48px; align-items: center; gap: 14px; }
.platform-item strong { font-size: 13px; text-transform: capitalize; }
.platform-item span { color: var(--muted); text-align: right; font-size: 13px; }
progress { width: 100%; height: 9px; border: 0; border-radius: 9px; overflow: hidden; background: var(--surface-soft); }
progress::-webkit-progress-bar { border-radius: 9px; background: var(--surface-soft); }
progress::-webkit-progress-value { border-radius: 9px; background: linear-gradient(90deg, #d62559, #a50f3d); }
progress::-moz-progress-bar { border-radius: 9px; background: linear-gradient(90deg, #d62559, #a50f3d); }
.notice-list { display: grid; gap: 4px; margin: 0; padding: 14px; list-style: none; }
.notice-list li { display: flex; gap: 14px; padding: 14px; border-radius: 15px; }
.notice-list li:hover { background: var(--surface-soft); }
.notice-icon { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); font-size: 11px; font-weight: 900; }
.notice-list strong { font-size: 14px; }
.notice-list p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.table-panel { min-height: 350px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.search-field { width: min(100%, 420px); }
.search-field input { min-height: 42px; }
.count-pill, .status-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.count-pill { padding: 7px 11px; color: var(--muted); background: var(--surface-soft); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.data-table td { font-size: 13px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(255,255,255,.38); }
.user-cell strong, .user-cell small { display: block; }
.user-cell strong { margin-bottom: 4px; }
.user-cell small { max-width: 250px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.status-pill { padding: 5px 9px; }
.status-pill.active, .status-pill.online { color: var(--good); background: rgba(22,134,92,.1); }
.status-pill.disabled, .status-pill.revoked { color: var(--bad); background: rgba(197,55,66,.1); }
.status-pill.offline { color: var(--muted); background: var(--surface-soft); }
.load-more { display: flex; justify-content: center; padding: 16px; border-top: 1px solid var(--line); }
.empty-state, .empty { color: var(--muted); text-align: center; }
.empty-state { padding: 60px 20px; }
.empty-state strong { color: var(--text); }
.empty-state p { margin: 7px 0 0; font-size: 13px; }
.empty { margin: 28px 0; font-size: 13px; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.plan-card { padding: 24px; border-radius: var(--radius-lg); }
.plan-card-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.plan-card h2 { margin: 4px 0; }
.plan-key { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.plan-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.plan-stats div, .readout { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.plan-stats span, .readout span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.plan-stats strong { font-size: 15px; }
.feature-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 30px; margin: 0 0 20px; padding: 0; list-style: none; }
.feature-list li { padding: 6px 9px; border-radius: 9px; color: var(--muted); background: var(--surface-soft); font-size: 11px; }
.timeline { display: grid; padding: 10px 22px 18px; }
.timeline-item { position: relative; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 13px; align-items: start; padding: 16px 2px; border-bottom: 1px solid var(--line); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item small, .timeline-time { color: var(--muted); font-size: 11px; }
.timeline-item small { margin-top: 5px; overflow-wrap: anywhere; }
.timeline.compact { padding: 0; }
.settings-panel { max-width: 860px; }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; padding: 24px; }
.settings-form label:first-child { grid-column: 1 / -1; }
.dialog { width: min(calc(100% - 28px), 620px); max-height: min(90vh, 840px); padding: 0; overflow: auto; border: 1px solid rgba(255,255,255,.7); border-radius: 26px; color: var(--text); background: rgba(250,249,251,.96); box-shadow: 0 30px 90px rgba(38,19,29,.3); }
.dialog.wide-dialog { width: min(calc(100% - 28px), 820px); }
.dialog::backdrop { background: rgba(28,18,24,.46); backdrop-filter: blur(9px); }
.dialog-head { position: sticky; z-index: 3; top: 0; display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); background: rgba(250,249,251,.9); backdrop-filter: blur(18px); }
.dialog-head h2 { margin-bottom: 3px; font-size: 24px; }
.dialog-head p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface); font-size: 24px; }
.dialog-tabs { position: sticky; z-index: 2; top: 83px; display: flex; gap: 5px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: rgba(250,249,251,.92); backdrop-filter: blur(18px); }
.dialog-tab { min-height: 40px; padding: 8px 13px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-weight: 800; }
.dialog-tab.active { color: var(--accent); background: var(--accent-soft); }
.dialog-section { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; grid-column: 1 / -1; margin-top: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.check-row input { flex: 0 0 18px; width: 18px; min-height: 18px; margin: 0; accent-color: var(--accent); }
.check-row span { color: var(--text); font-size: 13px; }
.device-list { display: grid; gap: 11px; }
.device-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.device-card h3 { margin: 0 0 5px; font-size: 15px; }
.device-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(calc(100% - 36px), 380px); }
.toast { padding: 14px 16px; border: 1px solid rgba(255,255,255,.6); border-radius: 15px; color: white; background: rgba(35,27,32,.92); box-shadow: 0 18px 44px rgba(31,20,25,.22); backdrop-filter: blur(16px); animation: toast-in .22s ease both; }
.toast.error { background: rgba(143,25,40,.94); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 980px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .mini-stat-grid { grid-template-columns: 1fr 1fr; }
  .overview-grid { grid-template-columns: 1fr; }
  .plan-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .topbar { min-height: 68px; padding: 10px 15px; }
  .brand > span:last-child, .account-chip > span:nth-child(2) { display: none; }
  .section-nav { top: 68px; gap: 3px; margin: 10px 12px 0; overflow-x: auto; border-radius: 15px; }
  .nav-button { flex: 1 0 auto; min-width: 74px; padding-inline: 12px; }
  .workspace { width: min(calc(100% - 24px), 1280px); margin-top: 24px; }
  .page-heading { align-items: start; }
  .page-heading > .button { flex: 0 0 auto; }
  .metric-card { min-height: 146px; padding: 19px; }
  .plan-grid { grid-template-columns: 1fr; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tbody { padding: 9px; }
  .data-table tr { margin-bottom: 9px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table td { display: grid; grid-template-columns: minmax(92px, .45fr) minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 2px; border: 0; text-align: right; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; text-align: left; }
  .data-table td:first-child { display: block; padding: 6px 2px 13px; border-bottom: 1px solid var(--line); text-align: left; }
  .data-table td:first-child::before { display: none; }
  .data-table td:last-child { display: flex; justify-content: flex-end; padding-top: 12px; }
  .data-table td:last-child::before { display: none; }
  .user-cell small { max-width: none; }
  .dialog-tabs { top: 82px; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .settings-form label:first-child { grid-column: 1; }
  .form-actions { grid-column: 1; }
}
@media (max-width: 470px) {
  .login-card { padding: 30px 22px; border-radius: 25px; }
  .login-card .brand-mark { width: 58px; height: 58px; margin-bottom: 22px; border-radius: 18px; }
  .login-card .brand-mark span { font-size: 30px; }
  .page-heading { display: grid; gap: 14px; }
  .page-heading > .button { justify-self: start; }
  .metric-grid { gap: 10px; }
  .mini-stat-grid { grid-template-columns: 1fr 1fr; }
  .mini-stat-grid article { display: block; min-height: 78px; padding: 13px; }
  .mini-stat-grid strong, .mini-stat-grid span, .mini-stat-grid small { display: block; }
  .mini-stat-grid strong { margin-top: 7px; }
  .mini-stat-grid small { margin-top: 3px; }
  .warning-banner { align-items: flex-start; flex-direction: column; gap: 4px; }
  .metric-card { min-height: 134px; padding: 17px 15px; }
  .metric-card strong { margin-top: 15px; font-size: 26px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .count-pill { align-self: flex-start; }
  .platform-item { grid-template-columns: 72px minmax(70px,1fr) 40px; gap: 9px; }
  .dialog { width: calc(100% - 16px); border-radius: 22px; }
  .dialog-head, .dialog-section { padding-left: 18px; padding-right: 18px; }
  .dialog-tabs { padding-left: 18px; padding-right: 18px; }
  .device-card { grid-template-columns: 1fr; }
  .device-card .button { justify-self: start; }
  .timeline-item { grid-template-columns: 10px minmax(0,1fr); }
  .timeline-time { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171417; --surface: rgba(34,29,34,.84); --surface-solid: #272228; --surface-soft: rgba(255,255,255,.045); --text: #f5edf1; --muted: #b6aab1; --line: rgba(255,255,255,.1); --accent: #f05a83; --accent-strong: #ff7b9d; --accent-soft: rgba(240,90,131,.13); --shadow: 0 24px 70px rgba(0,0,0,.24); }
  body { background: radial-gradient(circle at 8% 0%, rgba(201,42,92,.12), transparent 30%), radial-gradient(circle at 95% 92%, rgba(101,79,180,.1), transparent 34%), var(--bg); }
  .topbar { background: rgba(23,20,23,.78); }
  .dialog, .dialog-head, .dialog-tabs { background-color: rgba(35,30,35,.96); }
  .metric-card, .panel, .plan-card, .login-card { border-color: rgba(255,255,255,.08); }
}
