/* Shared product UI: customer portal, passkey screens and administration. */
:root {
    color-scheme: light;
    --navy: #152b47;
    --blue: #245edb;
    --blue-dark: #194bb5;
    --sky: #edf3ff;
    --ink: #263750;
    --muted: #66758a;
    --line: #e0e6ef;
    --paper: #fff;
    --canvas: #f5f7fb;
    --danger: #b42318;
    --success: #087443;
    font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
    font-size: 14px;
}
* { box-sizing: border-box; }
[hidden], .hidden { display: none !important; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; color: var(--ink); background: var(--canvas); line-height: 1.65; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button { touch-action: manipulation; }
a { color: var(--blue-dark); text-underline-offset: 3px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--navy); line-height: 1.4; }
h1 { margin-bottom: .55rem; font-size: clamp(1.8rem, 3vw, 2.3rem); letter-spacing: -.04em; }
h2 { margin-bottom: 1rem; font-size: 1.2rem; }
h3 { margin-bottom: .7rem; font-size: 1rem; }
p { margin-bottom: 1rem; }
button:disabled { cursor: not-allowed; opacity: .52; }
:focus-visible { outline: 3px solid #8eaff2; outline-offset: 3px; }
input, select, textarea { min-width: 0; width: 100%; min-height: 44px; padding: .7rem .85rem; color: var(--ink); background: var(--paper); border: 1px solid #c6d0df; border-radius: 8px; }
input::placeholder, textarea::placeholder { color: #788699; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #e1eaff; }
input:disabled, select:disabled { color: var(--muted); background: #f0f3f8; }
textarea { min-height: 96px; resize: vertical; }
label { display: grid; gap: .5rem; font-size: .92rem; font-weight: 600; }
code, .mono { font-family: Consolas, "SFMono-Regular", monospace; overflow-wrap: anywhere; }
.muted, .hint { color: var(--muted); }
.hint { margin: 0; font-size: .86rem; font-weight: 400; line-height: 1.6; }
.eyebrow { margin: 0 0 .5rem; color: var(--blue); font-size: .74rem; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.primary, .secondary, .ghost, .nav-button { min-height: 42px; border-radius: 8px; padding: .65rem 1.15rem; border: 1px solid transparent; font-weight: 600; line-height: 1.45; }
.primary { color: #fff; background: var(--blue); }
.primary:hover:not(:disabled) { background: var(--blue-dark); }
.secondary { color: var(--blue-dark); background: var(--sky); border-color: #d6e2fc; }
.secondary:hover:not(:disabled) { background: #dfeaff; }
.ghost { color: var(--ink); background: #fff; border-color: var(--line); }
.ghost:hover:not(:disabled) { background: #f0f4fa; border-color: #bfccdd; }
.danger { color: var(--danger); border-color: #f0b9b5; background: #fff7f6; }
.danger:hover:not(:disabled) { background: #fee4e2; }
.wide { width: 100%; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.test-banner { padding: .5rem 1rem; color: #713b12; background: #ffefc6; text-align: center; font-weight: 700; }
.site-footer { margin-top: auto; padding: 1.5rem 1rem; text-align: center; color: var(--muted); font-size: .82rem; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.skip-link { position: absolute; top: -100px; left: 1rem; z-index: 20; padding: .7rem 1rem; background: #fff; }
.skip-link:focus { top: 1rem; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; color: #fff; background: var(--blue); border-radius: 10px; font-size: 1rem; font-weight: 800; letter-spacing: -.05em; }
.center-shell { flex: 1; display: grid; place-items: center; padding: 3rem 1.25rem; }
.auth-card, .card, .result-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; }
.auth-card { width: min(100%, 440px); padding: clamp(1.7rem, 5vw, 2.6rem); box-shadow: 0 12px 50px #152b4707; }
.auth-card > .brand-mark { margin-bottom: 1.75rem; }
.auth-card h1 { font-size: 1.8rem; }
.auth-card .muted { margin-bottom: 1.7rem; }
.auth-card form, .stack-form { display: grid; gap: 1.25rem; }
.auth-card form .wide { margin-top: .3rem; }
.auth-note { padding-top: 1.4rem; margin-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }
.subtle-link { display: inline-block; margin-top: 1.25rem; font-size: .88rem; }
.status { margin: 1rem 0; padding: .85rem 1rem; color: var(--danger); background: #fff2f0; border: 1px solid #f4cdc9; border-radius: 9px; overflow-wrap: anywhere; }
.status:empty { display: none; }
.status.success { color: var(--success); background: #edf9f2; border-color: #c4e8d2; }
.status.info { color: var(--blue-dark); background: var(--sky); border-color: #d6e2fc; }
.topbar { padding: 0 clamp(1rem, 4vw, 3.5rem); background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-heading { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .85rem; }
.brand strong { color: var(--navy); font-size: 1.05rem; }
.brand small { display: block; color: var(--muted); font-size: .76rem; }
.topbar nav { display: flex; gap: .65rem; overflow-x: auto; scrollbar-width: thin; padding: 0 0 .7rem; }
.nav-button { white-space: nowrap; flex: 0 0 auto; color: var(--muted); padding: .6rem 1.1rem; background: transparent; }
.nav-button.active { color: var(--blue-dark); background: var(--sky); }
.nav-button:hover { color: var(--blue-dark); background: #f3f6fc; }
.app-shell { flex: 1; width: min(1320px, calc(100% - 4rem)); margin: 2.5rem auto; min-width: 0; }
.app-shell > .status { margin-top: 0; }
.panel { min-width: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.8rem; }
.section-heading h1 { margin-bottom: .4rem; }
.section-heading .muted { margin: 0; }
.section-heading > button { flex: 0 0 auto; }
.card { padding: clamp(1.3rem, 3vw, 2rem); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.3rem 1.5rem; margin-bottom: 1.5rem; }
.form-grid h2, .form-grid p { margin: 0; }
.form-grid h2, .span-all { grid-column: 1 / -1; }
.form-grid .actions { padding-top: .5rem; }
.form-grid details label { margin-top: 1rem; }
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 1rem; align-items: end; padding: 1.25rem; margin: 0 0 1.25rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.filters label { font-size: .83rem; }
.filters .actions { flex-wrap: nowrap; }
.filters-devices { grid-template-columns: repeat(4, minmax(0, 1fr)) auto; }
.filters-audit { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.filters-audit .actions { grid-column: 1 / -1; justify-content: flex-end; }
.table-wrap { width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.accounts-table { min-width: 920px; }
.keys-table { min-width: 840px; }
.activations-table { min-width: 1080px; }
.audit-table { min-width: 1180px; }
th, td { padding: 1.1rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { color: #66758a; background: #f9fafc; font-size: .8rem; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcff; }
td { max-width: 260px; }
td strong { display: block; color: var(--navy); font-weight: 600; }
.cell-secondary { margin-top: .3rem; color: var(--muted); font-size: .78rem; }
.cell-id { max-width: 19rem; margin-top: .4rem; color: var(--muted); font-size: .76rem; }
.cell-actions { display: flex; flex-wrap: wrap; gap: .4rem; min-width: 186px; }
.cell-actions button { min-height: 34px; padding: .4rem .65rem; font-size: .8rem; }
.badge { display: inline-block; padding: .2rem .65rem; border-radius: 5px; background: #eaf7ef; color: var(--success); font-size: .77rem; font-weight: 600; white-space: nowrap; }
.badge.off { color: var(--danger); background: #fff0ee; }
.badge.neutral { color: #596b82; background: #edf1f6; }
.empty-cell { padding: 3.5rem 1.5rem; text-align: center; color: var(--muted); }
.empty-cell strong { margin-bottom: .4rem; font-size: 1rem; }
.pagination { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .75rem; margin-top: 1.2rem; color: var(--muted); font-size: .86rem; }
.pagination:empty { display: none; }
.pagination .page-total { margin-right: auto; }
.pagination button { min-height: 36px; padding: .4rem .85rem; font-size: .84rem; }
.secret-box { display: grid; gap: .9rem; margin: 0 0 1.5rem; padding: 1.4rem; color: #713f12; background: #fff9e9; border: 1px solid #eed49a; border-radius: 12px; }
.secret-box p { margin: 0; }
.secret-box code { display: block; padding: 1rem; background: #fff; border: 1px solid #eed49a; border-radius: 8px; user-select: all; font-size: 1rem; }
.customer-shell { flex: 1; width: min(900px, calc(100% - 3rem)); margin: 3rem auto 2rem; }
.customer-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: 1.8rem; margin-bottom: 2rem; border-bottom: 1px solid var(--line); }
.customer-header .brand-mark { width: 44px; height: 44px; }
.customer-header h1 { font-size: 1.7rem; margin: 0; }
.customer-header .eyebrow { margin-bottom: .15rem; }
.customer-intro { margin-bottom: 1.75rem; }
.customer-intro h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.customer-intro p { margin-bottom: 0; }
.customer-entry { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 2.5rem; }
.customer-entry .card { min-width: 0; }
.customer-guide { padding-top: 1rem; }
.customer-guide h3 { margin-bottom: .85rem; }
.customer-guide ol { margin: 0; padding-left: 1.3rem; color: var(--muted); }
.customer-guide li { padding-left: .25rem; margin-bottom: 1.2rem; }
.customer-guide li strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: .25rem; }
.customer-guide p { font-size: .86rem; }
#key-form { margin-top: 1.5rem; }
#key-form .primary { margin-top: .15rem; }
.metric-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.metric { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.metric span { color: var(--muted); font-size: .85rem; }
.metric strong { display: block; margin-top: .55rem; color: var(--navy); font-size: 1.65rem; line-height: 1.4; overflow-wrap: anywhere; }
.metric.emphasis { background: var(--navy); border-color: var(--navy); }
.metric.emphasis span { color: #c9d8ee; }
.metric.emphasis strong { color: #fff; }
#activation-form h2 { margin: 0; }
#activation-form .primary { justify-self: start; }
.result-card { margin-top: 1.5rem; padding: 1.5rem; border-color: #b6dbc4; }
.result-label { color: var(--success); font-size: .9rem; font-weight: 600; }
.result-card code { display: block; margin: .85rem 0; padding: 1rem; color: var(--navy); background: #f1f8f4; border-radius: 8px; font-size: clamp(1.1rem, 3.6vw, 1.6rem); font-weight: 600; letter-spacing: .04em; user-select: all; }
.activation-progress { display: grid; gap: .5rem; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.activation-progress p { margin: 0; color: var(--muted); }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.status-tile { padding: 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.status-tile h2 { margin-bottom: .8rem; color: var(--muted); font-size: .85rem; font-weight: 500; }
.status-value { margin-bottom: .6rem; color: var(--navy); font-size: 1.4rem; font-weight: 650; overflow-wrap: anywhere; }
.status-tile p { margin: .3rem 0 0; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.system-warning { margin-bottom: 1.25rem; padding: 1.15rem 1.4rem; background: #fff7e5; border: 1px solid #efd6a0; border-radius: 10px; }
.system-warning ul { margin: .5rem 0 0; padding-left: 1.4rem; }
.system-meta { margin-top: 1.25rem; }
.status-card, .audit-details { padding: 1rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Consolas, monospace; font-size: .8rem; background: #f7f9fc; border-radius: 8px; }
.audit-details { max-width: 28rem; max-height: 16rem; margin: .75rem 0 0; color: var(--muted); }
details summary { color: var(--blue-dark); cursor: pointer; font-size: .85rem; }
.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: 1000px) {
    .filters, .filters-devices, .filters-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters .actions { grid-column: 1 / -1; justify-content: flex-end; }
    .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-shell { width: calc(100% - 2.5rem); }
}
@media (max-width: 600px) {
    :root { font-size: 14px; }
    .topbar { padding: 0 1rem; }
    .topbar-heading { min-height: 70px; }
    .brand strong { font-size: 1rem; }
    .topbar nav { gap: .35rem; }
    .nav-button { padding: .6rem .8rem; }
    .app-shell, .customer-shell { width: calc(100% - 2rem); margin: 1.5rem auto; }
    .section-heading { align-items: flex-start; gap: 1rem; flex-direction: column; margin-bottom: 1.3rem; }
    .section-heading h1 { font-size: 1.75rem; }
    .section-heading > button { align-self: flex-start; }
    .form-grid, .filters, .filters-devices, .filters-audit, .status-grid { grid-template-columns: 1fr; }
    .filters { padding: 1rem; gap: .85rem; }
    .filters .actions > button { flex: 1; }
    .customer-header { padding-bottom: 1.25rem; margin-bottom: 1.5rem; }
    .customer-header h1 { font-size: 1.4rem; }
    .customer-entry { grid-template-columns: 1fr; gap: 1.5rem; }
    .customer-guide { padding: 0 .25rem; }
    .customer-guide li { margin-bottom: .8rem; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
    .metric:first-child { grid-column: 1 / -1; }
    .metric { padding: 1rem; }
    .metric strong { font-size: 1.5rem; }
    .result-card { padding: 1.2rem; }
    .result-card .actions { align-items: stretch; flex-direction: column; }
    .center-shell { padding: 1.5rem 1rem; }
    .auth-card { padding: 1.6rem; }
    .pagination { gap: .5rem; }
    .pagination .page-total { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
    button, input, select, textarea { transition: background-color .15s, border-color .15s; }
}

.passkey-hint { margin-top: 1rem; }

.empty-table { min-width: 0; }
@media (max-width: 600px) {
    .empty-table thead { display: none; }
    .empty-table .empty-cell { padding: 2.5rem 1rem; }
}

.empty-cell button { margin-top: 1rem; }
