:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #e8f0eb;
  background: #0d1713;
  --ink: #e8f0eb;
  --muted: #9caaa2;
  --line: #2b4036;
  --surface: #15231e;
  --surface-soft: #1a2a24;
  --brand: #31956f;
  --brand-dark: #25785a;
  --brand-soft: #19372c;
  --accent: #d5a64d;
  --danger: #cf505a;
  --danger-soft: #3a2025;
  --success: #50bd88;
  --warning: #e0a84b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
  letter-spacing: 0;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; background: #0d1713; }
[hidden] { display: none !important; }
button, input, select, dialog { font: inherit; letter-spacing: 0; }
button { border: 1px solid #3a5146; background: #1a2a24; color: var(--ink); border-radius: 9px; padding: 9px 13px; cursor: pointer; font-weight: 650; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
button:hover { border-color: #6c907e; background: #21352d; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #80262c; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(183, 134, 45, .42); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 200; left: 12px; top: -80px; color: #fff; background: var(--brand-dark); padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.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; }
.environment-banner { position: fixed; inset: 0 0 auto 0; z-index: 100; padding: 6px 12px; background: #84341d; color: #fff; font-size: 12px; font-weight: 800; text-align: center; letter-spacing: .12em; }
.environment-banner:not([hidden]) ~ .login-shell,
.environment-banner:not([hidden]) ~ .app-shell { padding-top: 28px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 40px 24px; background: radial-gradient(circle at 18% 8%, #1b3a2e 0, transparent 34%), linear-gradient(135deg, #0d1713 0%, #111f1a 100%); }
.login-panel { width: min(440px, 100%); background: rgba(21,35,30,.98); border: 1px solid #30483d; border-radius: 18px; padding: 34px; box-shadow: var(--shadow); }
.owner-onboarding-panel { width: min(500px, 100%); }
.brand-lockup, .brand-block { display: flex; align-items: center; gap: 12px; }
.brand-lockup strong, .brand-block strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.brand-lockup span, .brand-block span { display: block; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; color: #fff; background: linear-gradient(145deg, #256a50, #123f2e); font-size: 13px; font-weight: 850; letter-spacing: .04em; box-shadow: 0 7px 16px rgba(23,79,59,.22); }
.login-panel h1 { font-size: clamp(24px, 5vw, 30px); line-height: 1.12; margin: 6px 0 12px; letter-spacing: -.025em; }
.auth-step, .page-eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.auth-step { margin: 28px 0 8px; }
.form-note { color: var(--muted); font-size: 13px; line-height: 1.55; }
.provisioning-job-log { white-space: pre-wrap; max-height: 320px; overflow: auto; }
.login-panel label { display: grid; gap: 7px; margin: 16px 0; color: #c9d5ce; font-size: 13px; font-weight: 700; }
.login-panel input, .confirmation-panel input, .confirmation-panel select { width: 100%; border: 1px solid #456054; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #0f1b16; }
.login-panel button.primary { width: 100%; min-height: 44px; margin-top: 8px; }
.field-help, .security-note { color: var(--muted); font-size: 11px; line-height: 1.45; }
.field-help { margin: -10px 0 8px; }
.security-note { text-align: center; margin: 16px 0 0; }
.error { min-height: 20px; color: var(--danger); font-size: 13px; line-height: 1.45; }
#owner-onboarding-mfa-qr { display: block; max-width: 100%; height: auto; margin: 18px auto; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.recovery-codes { padding: 14px; border: 1px solid #40594d; border-radius: 9px; background: var(--surface-soft); white-space: pre-wrap; user-select: all; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: linear-gradient(180deg, #09150f 0%, #10221a 100%); color: #eef4f0; padding: 22px 14px; border-right: 1px solid #22372d; }
.brand-block { padding: 0 8px 20px; border-bottom: 1px solid rgba(255,255,255,.11); }
.brand-block span { color: #aebbb4; }
nav { display: grid; gap: 3px; margin-top: 16px; }
nav button { border: 0; color: #dbe6e0; background: transparent; text-align: left; padding: 9px 11px; font-weight: 560; }
nav button:hover, nav button.active { background: rgba(255,255,255,.10); color: #fff; }
nav button.active { box-shadow: inset 3px 0 0 #d3a64c; }
main { min-width: 0; padding: 0 clamp(18px, 3vw, 38px) 36px; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.page-eyebrow { margin: 0 0 4px; }
.topbar h1 { font-size: clamp(23px, 3vw, 30px); margin: 0; letter-spacing: -.025em; }
.topbar p:not(.page-eyebrow) { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.admin-session { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 13px; }
.admin-name { padding: 7px 10px; color: #d6e0da; background: #1c3028; border: 1px solid #2d463a; border-radius: 999px; font-weight: 650; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 22px 0; }
.metric { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 17px 18px; box-shadow: 0 3px 14px rgba(0,0,0,.16); }
.metric::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--brand); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 7px; font-size: 27px; letter-spacing: -.025em; }
.toolbar { display: flex; align-items: end; gap: 12px; margin: 20px 0 12px; padding: 14px; background: #14251e; border: 1px solid var(--line); border-radius: 12px; }
.toolbar label { display: grid; gap: 5px; font-size: 12px; color: #b5c2bb; font-weight: 650; }
.toolbar select, .toolbar input, .action-form input, .action-form select { min-width: 180px; border: 1px solid #3d584b; border-radius: 8px; padding: 9px 10px; background: #0f1b16; color: var(--ink); }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.organization-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.organization-tabs button { color: var(--ink); border: 1px solid var(--line); }
.organization-tabs button.active { color: #fff; background: var(--brand); border-color: var(--brand); }
.action-surface { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 3px 14px rgba(0,0,0,.16); }
.action-heading { min-height: 68px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.action-heading h2 { margin: 0; font-size: 16px; }
.action-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.action-form { border-top: 1px solid var(--line); padding: 16px; display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 13px; }
.action-form label { display: grid; gap: 6px; color: #bdc9c2; font-size: 12px; font-weight: 700; }
.action-form input, .action-form select { min-width: 0; width: 100%; }
.action-form .action-submit { align-self: end; min-height: 39px; }
.data-surface { position: relative; min-height: 240px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 3px 14px rgba(0,0,0,.18); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { background: #1b3027; color: #b8c6be; text-align: left; padding: 11px 10px; border-bottom: 1px solid #385044; white-space: nowrap; font-size: 11px; letter-spacing: .025em; text-transform: uppercase; }
td { padding: 11px 10px; border-bottom: 1px solid #263b31; max-width: 320px; overflow-wrap: anywhere; vertical-align: middle; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; min-width: 150px; }
.row-actions button { padding: 6px 8px; font-size: 11px; white-space: nowrap; }
tr:hover td { background: #1a2c24; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; color: #c3cec8; background: #24382f; font-size: 11px; font-weight: 750; white-space: nowrap; }
.state-active, .state-online, .state-completed, .state-valid { color: #8de0b5; background: #173c2b; }
.state-suspended, .state-revoked, .state-failed, .state-overage, .state-invalid { color: #ff9da5; background: #43242a; }
.state-pending, .state-grace_period, .state-expiring { color: #f2c979; background: #3d301b; }
.technical-id { color: #9caaa2; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.empty, .loading { min-height: 230px; padding: 54px 20px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.empty strong { color: #d4ddd7; font-size: 15px; }
.empty span { font-size: 12px; }
.spinner { width: 28px; height: 28px; border: 3px solid #d4ded8; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#alerts .notice, #owner-transfer-banner { margin-top: 14px; border: 1px solid #70562d; border-left: 4px solid var(--warning); border-radius: 10px; background: #332919; padding: 12px 14px; font-size: 13px; }
#alerts .notice p, #owner-transfer-banner p { margin: 0 0 7px; }
.notice-success { border-color: #2f6a4d !important; border-left-color: var(--success) !important; background: #173426 !important; }
.notice-error { border-color: #754048 !important; border-left-color: var(--danger) !important; background: var(--danger-soft) !important; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 13px; font-size: 12px; }
dialog { width: min(560px, calc(100% - 32px)); max-height: min(82vh, 780px); overflow: auto; border: 1px solid #3c5549; border-radius: 14px; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(9, 25, 18, .64); backdrop-filter: blur(2px); }
.confirmation-panel { padding: 24px; display: grid; gap: 15px; }
.confirmation-panel h2, .confirmation-panel p { margin: 0; }
.confirmation-panel label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.confirmation-actions, .dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.confirmation-actions { justify-content: flex-end; }
.dialog-heading .auth-step { margin: 0 0 5px; }
.detail-list { display: grid; grid-template-columns: minmax(130px, .7fr) minmax(0, 1.3fr); gap: 0; margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.detail-list dt, .detail-list dd { margin: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.detail-list dt { color: #aebcb4; background: #1b3027; font-size: 11px; font-weight: 750; text-transform: uppercase; }
.detail-list dd { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.navigation-group { display: grid; gap: 3px; margin-top: 14px; }
.navigation-group:first-child { margin-top: 0; }
.navigation-group-label { margin: 0 11px 5px; color: #7f9388; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.navigation-group details { border-top: 1px solid rgba(255,255,255,.07); padding-top: 7px; }
.navigation-group summary { cursor: pointer; padding: 9px 11px; color: #dbe6e0; font-size: 13px; font-weight: 650; list-style: none; }
.navigation-group summary::-webkit-details-marker { display: none; }
.navigation-group summary::after { content: "▾"; float: right; color: #86a095; }
.navigation-group details:not([open]) summary::after { content: "▸"; }
.navigation-group details button { width: calc(100% - 12px); margin-left: 12px; color: #b7c7bf; font-size: 12px; }
.organization-context { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(135deg, #162a22, #12221c); }
.organization-context strong { display: block; font-size: 18px; }
.organization-context span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.organization-context-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wide-dialog { width: min(820px, calc(100% - 32px)); }
.wizard-panel { gap: 20px; }
.wizard-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; list-style: none; }
.wizard-progress li { padding: 9px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #102019; text-align: center; font-size: 11px; font-weight: 750; }
.wizard-progress li.active { color: #f2f7f4; border-color: #438d6d; background: #1b4b38; }
.wizard-progress li.complete { color: #8ddbb3; border-color: #315f4b; background: #173426; }
.wizard-step h3 { margin: 0 0 5px; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label { display: grid; gap: 6px; color: #c4d0c9; font-size: 12px; font-weight: 700; }
.form-grid input, .form-grid select { width: 100%; min-width: 0; border: 1px solid #456054; border-radius: 9px; padding: 11px 12px; color: var(--ink); background: #0f1b16; }
.optional { color: var(--muted); font-weight: 500; }
.selection-summary { padding: 12px 14px; border: 1px solid #324b3f; border-radius: 10px; color: #b9c7bf; background: #102019; font-size: 12px; line-height: 1.55; }
.confirmation-check { display: flex !important; grid-template-columns: auto 1fr; align-items: start; gap: 10px !important; }
.confirmation-check input { width: auto; margin-top: 3px; }
.wizard-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 9px; align-items: center; padding-top: 4px; border-top: 1px solid var(--line); }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; overflow: visible; }
  #navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  main { padding: 0 14px 24px; }
  .topbar { align-items: flex-start; padding: 18px 0; }
  .action-form { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
}
@media (max-width: 680px) {
  .login-shell { padding: 24px 14px; }
  .login-panel { padding: 24px 20px; border-radius: 14px; }
  #navigation { display: flex; overflow-x: auto; gap: 5px; padding-bottom: 4px; }
  #navigation button { flex: 0 0 auto; }
  .topbar, .admin-session, .toolbar { align-items: stretch; flex-direction: column; }
  .admin-session { width: 100%; }
  .admin-name { text-align: center; }
  .toolbar select, .toolbar input { min-width: 0; width: 100%; }
  .toolbar-actions { margin-left: 0; }
  .toolbar-actions button { flex: 1; }
  .action-form { grid-template-columns: 1fr; }
  .form-grid, .wizard-progress { grid-template-columns: 1fr; }
  .wizard-actions { grid-template-columns: 1fr; }
  .wizard-actions span { display: none; }
  .organization-context { align-items: stretch; flex-direction: column; }
  .table-wrap { overflow: visible; padding: 9px; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  tbody { display: grid; gap: 10px; }
  tr { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
  td { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr); gap: 10px; max-width: none; border-bottom: 1px solid var(--line); }
  td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
  .row-actions { display: flex; min-width: 0; }
  .row-actions::before { flex-basis: 100%; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
