:root {
  color-scheme: light;
  --ink: #17243b;
  --muted: #66748b;
  --line: #e2e8f1;
  --surface: #fff;
  --page: #f4f7fb;
  --blue: #2563eb;
  --blue-dark: #1747b6;
  --mint: #0e8a6d;
  --red: #b9414c;
  --shadow: 0 14px 40px rgba(28, 50, 88, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 12% 0%, #eaf1ff 0, transparent 34rem), var(--page); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: wait; opacity: .65; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 56px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 62px; margin-bottom: 34px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; color: white; font-size: 20px; font-weight: 800; background: linear-gradient(140deg, #4b8cff, #1d56cf); box-shadow: 0 8px 18px rgba(37, 99, 235, .22); }
.brand strong { display: block; font-size: 15px; letter-spacing: .01em; }
.brand small { display: block; margin-top: 3px; color: #8794a8; font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.connection { color: var(--muted); font-size: 12px; white-space: nowrap; }
.connection i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #a2adbd; }
.connection i.is-connected { background: #33b78b; }
.auth-layout { display: grid; gap: 24px; align-items: center; max-width: 920px; margin: clamp(26px, 8vh, 86px) auto 50px; }
.intro { padding: 4px 2px; }
.eyebrow { margin: 0 0 10px; color: #7b8ca8; font-size: 10px; font-weight: 800; letter-spacing: .17em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(28px, 5vw, 40px); line-height: 1.2; letter-spacing: -.04em; }
.intro-copy { max-width: 460px; margin-bottom: 23px; color: var(--muted); font-size: 15px; line-height: 1.8; }
.trust-note { display: flex; align-items: flex-start; gap: 10px; max-width: 500px; color: #728099; font-size: 12px; line-height: 1.65; }
.shield { flex: 0 0 auto; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 8px; color: #087c5f; background: #e1f5ee; font-weight: 800; }
.panel { border: 1px solid rgba(220, 228, 239, .9); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.auth-panel { padding: 22px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 22px; border-radius: 12px; background: #f0f3f8; }
.segment { min-height: 40px; border: 0; border-radius: 9px; color: #77859b; background: transparent; font-size: 13px; font-weight: 650; }
.segment.active { color: #1747b6; background: white; box-shadow: 0 2px 7px rgba(28, 50, 88, .09); }
.field { display: grid; gap: 8px; margin-bottom: 16px; color: #33435e; font-size: 12px; font-weight: 700; }
.field input, .field select, .inline-form input, .search-box input { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #d9e1ed; border-radius: 10px; outline: none; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #6c9cff !important; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input::placeholder { color: #a0aabd; }
.field small { color: #8996aa; font-size: 11px; font-weight: 400; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 750; transition: transform .12s, background .15s, border-color .15s; }
.button:hover, .button-small:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--blue); box-shadow: 0 5px 12px rgba(37, 99, 235, .18); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: #28436e; border-color: #d8e2f1; background: #f8faff; }
.button-secondary:hover, .button-quiet:hover { border-color: #b9cae3; background: #f1f5fb; }
.button-quiet { min-height: 36px; color: #66748b; border-color: #e1e7ef; background: #fff; }
.button-wide { width: 100%; min-height: 48px; margin-top: 5px; }
.fine-print { margin: 15px 1px 0; color: #8b97aa; font-size: 11px; line-height: 1.6; }
.notice { position: sticky; z-index: 3; top: 10px; padding: 13px 16px; margin: 0 0 18px; border: 1px solid #cddbf5; border-radius: 12px; color: #2b528a; background: #eff5ff; box-shadow: 0 8px 22px rgba(28, 50, 88, .08); font-size: 13px; line-height: 1.5; }
.notice.success { color: #126c53; border-color: #bce5d6; background: #eaf8f2; }
.notice.warning { color: #815d15; border-color: #f1ddb0; background: #fff8e7; }
.notice.error { color: #9c3440; border-color: #f1c9ce; background: #fff0f1; }
.hidden { display: none !important; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 34px 0 20px; }
.page-heading h1 { margin-bottom: 0; font-size: clamp(24px, 4vw, 33px); }
.page-heading h2 { margin-bottom: 0; font-size: 24px; }
.force-password-note { display: grid; gap: 5px; padding: 15px 17px; margin: 24px 0 16px; border: 1px solid #f0d3a6; border-radius: 13px; color: #795313; background: #fff8e9; font-size: 12px; line-height: 1.6; }
.force-password-note strong { font-size: 13px; }
.force-password-required .dashboard-grid > :not(.password-card) { display: none !important; }
.force-password-required .page-heading .badge { display: none; }
.badge { padding: 8px 12px; border-radius: 999px; color: #2755a1; background: #eaf1ff; font-size: 11px; font-weight: 750; }
.dashboard-grid { display: grid; gap: 14px; }
.dashboard-grid > .panel, .admin-grid > .panel { padding: 20px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-head h2, .section-head h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.section-head .eyebrow { margin-bottom: 7px; }
.entitlement-card { color: white; border-color: #2457bd; background: linear-gradient(135deg, #1e4fb3, #3078e6); }
.entitlement-card .eyebrow { color: #bad0ff; }
.entitlement-card h2 { color: white; }
.entitlement-card .muted { color: #d7e4ff; }
.status-badge { padding: 6px 9px; border-radius: 99px; color: #795b18; background: #fff2c9; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-badge.good { color: #075d47; background: #cff5e7; }
.status-badge.off { color: #754550; background: #ffe1e3; }
.expiry { display: flex; flex-direction: column; gap: 5px; padding-top: 14px; margin-top: 16px; border-top: 1px solid rgba(255,255,255,.2); }
.expiry span { color: #c5d8ff; font-size: 11px; }
.expiry strong { font-size: 20px; letter-spacing: -.02em; }
.lease-note { margin-top: 12px; color: #c5d8ff; font-size: 10px; line-height: 1.6; }
.muted { margin-bottom: 15px; color: var(--muted); font-size: 12px; line-height: 1.75; }
.icon-chip { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; color: #3163c0; background: #edf3ff; font-size: 18px; }
.inline-form { display: flex; flex-direction: column; gap: 9px; }
.inline-form input { min-width: 0; }
.stack-form { display: grid; gap: 2px; }
.stack-form .button { justify-self: start; }
.device-id { display: grid; gap: 7px; padding: 11px 12px; border-radius: 11px; background: #f5f7fb; }
.device-id span { color: #8290a5; font-size: 10px; }
.device-id code { overflow-wrap: anywhere; color: #485b78; font-size: 11px; }
.admin-area { margin-top: 46px; }
.admin-heading { align-items: flex-start; margin-bottom: 16px; }
.admin-heading .muted { max-width: 680px; margin: 8px 0 0; }
.admin-grid { display: grid; gap: 14px; }
.create-form { display: grid; gap: 10px; align-items: end; }
.create-form .field { margin: 0; }
.create-form .button { width: 100%; }
.generated-panel { margin-top: 14px; padding: 20px; border-color: #f0d89d; background: #fffdf6; }
.generated-panel textarea { display: block; width: 100%; min-height: 130px; padding: 13px; resize: vertical; border: 1px solid #ead9ad; border-radius: 10px; color: #29374f; background: white; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.7; }
.warning-copy { margin-bottom: 12px; color: #8a621a; font-size: 12px; line-height: 1.6; }
.action-row { display: flex; gap: 9px; margin-top: 11px; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.stat-box { display: grid; gap: 4px; padding: 12px; border-radius: 11px; background: #f5f7fb; }
.stat-box strong { font-size: 21px; }
.stat-box span { color: #77859b; font-size: 10px; }
.users-panel, .audit-panel { margin-top: 14px; padding: 20px; }
.search-box { width: min(260px, 52%); }
.search-box input { min-height: 38px; font-size: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 9px; color: #8794a8; font-size: 10px; font-weight: 750; white-space: nowrap; }
td { padding: 12px 9px; border-top: 1px solid #edf0f5; color: #43526a; font-size: 12px; vertical-align: middle; }
td:first-child { color: #24344e; font-weight: 700; }
.table-badge { display: inline-block; padding: 5px 7px; border-radius: 99px; color: #176c51; background: #e1f6ee; font-size: 10px; white-space: nowrap; }
.table-badge.off { color: #99434b; background: #ffeaec; }
.user-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 260px; }
.button-small { min-height: 30px; padding: 0 8px; border: 1px solid #dce4ef; border-radius: 8px; color: #4e607b; background: white; font-size: 10px; font-weight: 700; }
.button-small.button-danger { color: #9c4851; border-color: #f0d2d5; background: #fff9f9; }
.button-small.button-good { color: #12684f; border-color: #c9eadd; background: #f5fcf8; }
.empty-state { margin: 12px 0 2px; color: #97a1b0; font-size: 12px; text-align: center; }
.audit-list { display: grid; }
.audit-item { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; border-top: 1px solid #edf0f5; color: #52617a; font-size: 11px; line-height: 1.6; }
.audit-item time { flex: 0 0 auto; color: #97a1b0; font-size: 10px; }
.footer-note { margin: 26px 0 0; color: #98a3b3; font-size: 10px; line-height: 1.7; text-align: center; }
.busy-overlay { position: fixed; z-index: 10; inset: 0; display: flex; align-items: center; justify-content: center; gap: 11px; color: #2b4166; background: rgba(245, 248, 253, .55); backdrop-filter: blur(2px); font-size: 12px; }
.spinner { width: 18px; height: 18px; border: 2px solid #c8d8f3; border-top-color: #2865d7; border-radius: 50%; animation: spin .8s linear infinite; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  .shell { width: min(1120px, calc(100% - 56px)); padding-top: 28px; }
  .auth-layout { grid-template-columns: 1.1fr .9fr; gap: 56px; }
  .auth-panel { padding: 28px; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .dashboard-grid > .panel, .admin-grid > .panel { padding: 23px; }
  .inline-form { flex-direction: row; }
  .inline-form input { flex: 1; }
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .admin-summary { grid-column: 1 / -1; }
  .create-form { grid-template-columns: 1fr auto; }
  .create-form .button { width: auto; }
  #card-create-form { grid-template-columns: 1fr 1.35fr auto; }
}
@media (max-width: 480px) {
  .shell { width: calc(100% - 24px); padding-top: 12px; }
  .topbar { margin-bottom: 20px; }
  .brand-mark { width: 38px; height: 38px; }
  .connection { font-size: 0; }
  .connection i { margin-right: 0; }
  .auth-layout { margin-top: 28px; }
  .auth-panel { padding: 17px; }
  .page-heading { align-items: center; }
  .dashboard-grid > .panel, .admin-grid > .panel, .users-panel, .audit-panel { padding: 16px; }
  .section-head { gap: 8px; }
  .inline-form { gap: 8px; }
  .inline-form .button { width: 100%; }
  .users-panel .section-head { flex-wrap: wrap; }
  .search-box { width: 100%; }
  th, td { padding-right: 7px; padding-left: 7px; }
  .user-actions { min-width: 240px; }
  .audit-item { flex-direction: column; gap: 2px; }
}
