:root {
  color-scheme: light;
  --ink: #1d232b;
  --muted: #707983;
  --soft: #f5f7f9;
  --line: #dde2e7;
  --accent: #0a70d1;
  --accent-soft: #eaf3ff;
  --danger: #b7473e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: #f6f7f9; color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid #9ac9f4; outline-offset: 2px; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; background: radial-gradient(circle at top, #fff 0, #f5f7f9 62%); }
.auth-card { width: min(100%, 470px); padding: 42px 42px 34px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 20px 60px #17253610; }
.brand-lockup, .sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .01em; }
.brand-mark { display: inline-grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: #1f2933; color: #fff; font-size: 16px; }
.brand-mark img { width: 18px; height: 18px; filter: brightness(0) invert(1); }
.eyebrow { margin: 0 0 8px; color: #7d8792; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.auth-card h1 { margin: 27px 0 8px; font-size: 28px; letter-spacing: -.02em; }
.auth-intro { margin: 0 0 15px; color: var(--muted); }
.auth-modes { display: flex; gap: 3px; padding: 3px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); }
.mode-button { flex: 1; padding: 8px 9px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-weight: 650; }
.mode-button.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px #17253616; }
.field { display: grid; gap: 7px; margin-bottom: 16px; color: #58616b; font-size: 12px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 40px; padding: 0 11px; border: 1px solid #cbd2d9; border-radius: 6px; background: #fff; color: var(--ink); outline: none; }
.field input:hover, .field select:hover { border-color: #aab4bf; }
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #cbe4fb; }
.remember-row { display: flex; flex-wrap: wrap; gap: 18px; margin: 2px 0 9px; }
.check-label { display: inline-flex; align-items: center; gap: 7px; color: #505a64; font-size: 12px; cursor: pointer; }
.check-label input { width: 16px; height: 16px; accent-color: var(--accent); }
.security-note { margin: 0 0 17px; color: #7a838c; font-size: 11px; line-height: 1.5; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; font-weight: 650; }
.button img { width: 15px; height: 15px; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: #075faa; }
.button-secondary { border-color: #cbd2d9; background: #fff; color: #48515a; }
.button-secondary:hover { background: #f3f5f7; }
.button-danger { border-color: #e2b5b0; background: #fff; color: var(--danger); }
.button-wide { width: 100%; }
.link-button { display: block; margin: 15px auto 0; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 12px; }
.form-feedback { min-height: 22px; margin: 17px 0 0; color: #59636d; font-size: 12px; line-height: 1.5; }
.form-feedback[data-kind="error"] { color: var(--danger); }

.shell { display: grid; min-height: 100vh; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-width: 0; padding: 25px 14px 17px; border-right: 1px solid #d7dce1; background: #fbfcfd; }
.sidebar-brand { padding: 0 10px 32px; line-height: 1.12; }
.sidebar-brand strong { font-size: 12px; }
.navigation { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: #59636c; text-align: left; font-size: 13px; }
.nav-item img { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: #edf2f6; color: var(--ink); }
.nav-item.is-active { background: var(--accent-soft); color: #075faa; font-weight: 700; }
.nav-item.is-active img { filter: sepia(100%) saturate(1300%) hue-rotate(170deg); }
.sidebar-footer { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--line); color: #7b848e; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #27a063; }
.content { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 106px; padding: 24px 42px; border-bottom: 1px solid var(--line); background: #fff; }
.topbar h1 { margin: 0 0 5px; font-size: 23px; letter-spacing: -.02em; }
.topbar p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.view-container { padding: 31px 42px 50px; }
.view-panel { max-width: 1160px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 17px; }
.toolbar .field { flex: 1 1 190px; max-width: 320px; margin: 0; }
.bulk-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 12px; margin: -4px 0 14px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfd; }
.bulk-toolbar .status-line { flex: 1 1 auto; min-width: 130px; margin: 0; }
.bulk-toolbar select { min-height: 36px; padding: 0 10px; border: 1px solid #cbd2d9; border-radius: 6px; background: #fff; color: var(--ink); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf0f2; text-align: left; vertical-align: middle; }
th { color: #7a838c; font-size: 11px; font-weight: 700; }
td { color: #3f4851; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { display: grid; place-items: center; min-height: 160px; padding: 25px; color: #808994; font-size: 12px; }
.split-panel { display: grid; grid-template-columns: minmax(230px, 36%) minmax(0, 1fr); min-height: 510px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.list-pane { overflow: auto; border-right: 1px solid #e8ebee; }
.detail-pane { min-width: 0; overflow: auto; padding: 23px 27px; }
.list-button { display: grid; width: 100%; gap: 5px; padding: 14px 15px; border: 0; border-bottom: 1px solid #edf0f2; background: #fff; color: #3d4650; text-align: left; }
.list-button:hover { background: #f5f8fb; }
.list-button.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.list-button strong, .list-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-button strong { font-size: 12px; }
.list-button span { color: #7a838c; font-size: 11px; }
.detail-pane h2 { margin: 0 0 15px; font-size: 17px; overflow-wrap: anywhere; }
.detail-meta { padding: 0 0 16px; margin-bottom: 17px; border-bottom: 1px solid #e7eaed; color: #707983; font-size: 11px; line-height: 1.6; }
.detail-meta p { margin: 3px 0; }
.detail-code { display: flex; align-items: center; gap: 13px; padding: 11px 0 17px; }
.detail-code strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.mail-body { margin: 0; color: #323b44; font: inherit; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.status-line { min-height: 21px; margin: 13px 0 0; color: #74808b; font-size: 12px; }
.status-line[data-kind="error"] { color: var(--danger); }
.setup-checklist { display: grid; gap: 8px; padding: 14px 18px 14px 34px; margin: 0 0 20px; border: 1px solid #d9e5f1; border-radius: 7px; background: #f7fbff; color: #536576; font-size: 12px; line-height: 1.55; }
.setup-checklist li::marker { color: var(--accent); font-weight: 700; }
.mailbox-health { align-items: flex-start; }
.mailbox-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 11px 13px; margin: 0 0 15px; border: 1px solid #e6c8a4; border-radius: 7px; background: #fffaf3; color: #765a38; font-size: 12px; }
.mailbox-notice .button { min-height: 31px; padding: 0 10px; font-size: 11px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 9px; padding: 0 0 22px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.inline-form .field { flex: 1 1 180px; margin: 0; }
.card-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.card-row strong { display: block; overflow-wrap: anywhere; font-size: 13px; }
.card-row small { display: block; margin-top: 4px; color: #7b848e; font-size: 11px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.row-actions .button { min-height: 31px; padding: 0 10px; font-size: 11px; }
.grant-address-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; max-height: 270px; overflow: auto; padding: 12px 0; margin: 8px 0 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.grant-address-list .check-label { min-width: 0; overflow-wrap: anywhere; }
.grant-address-list .check-label span { min-width: 0; overflow-wrap: anywhere; }
.admin-inventory { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; margin-top: 26px; }
.inventory-card { min-width: 0; }
.inventory-card .card-row { overflow-wrap: anywhere; }
.issued-code { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 16px; margin: 16px 0 20px; border: 1px solid #b8d1ef; border-radius: 7px; background: #f2f7fd; }
.issued-code span { display: block; font-size: 11px; color: #5e6e7e; }
.issued-code strong { display: block; margin-top: 4px; font-size: 22px; font-variant-numeric: tabular-nums; }
.batch-code-output { padding: 15px 16px; margin: 0 0 20px; border: 1px solid #b8d1ef; border-radius: 7px; background: #f2f7fd; }
.batch-code-output p { margin: 0 0 10px; color: #5e6e7e; font-size: 12px; }
.batch-code-output textarea { display: block; width: 100%; min-height: 145px; margin-bottom: 10px; padding: 10px; resize: vertical; border: 1px solid #cbd2d9; border-radius: 6px; background: #fff; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; line-height: 1.6; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(410px, calc(100vw - 40px)); padding: 11px 14px; border-radius: 7px; background: #252b32; color: #fff; box-shadow: 0 10px 30px #1725362b; font-size: 12px; }
dialog { max-width: min(430px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 10px; background: #fff; color: var(--ink); box-shadow: 0 24px 80px #17253635; }
dialog::backdrop { background: #17253666; }
.dialog-card { min-width: min(430px, calc(100vw - 28px)); padding: 26px; }
.dialog-card h2 { margin: 0 0 10px; font-size: 17px; }
.dialog-card p { margin: 0 0 13px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 19px; }
.one-time-key { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 14px 15px; margin: 4px 0 15px; border: 1px solid #b8d1ef; border-radius: 7px; background: #f2f7fd; }
.one-time-key span { color: #5e6e7e; font-size: 11px; }
.one-time-key strong { flex: 1 1 250px; color: var(--ink); font-size: 14px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.download-info { display: grid; grid-template-columns: minmax(70px, max-content) minmax(0, 1fr); gap: 11px 16px; padding: 17px; margin: 17px 0; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.download-info dt { color: #7a838c; font-size: 11px; }
.download-info dd { min-width: 0; margin: 0; color: #3f4851; font-size: 12px; overflow-wrap: anywhere; }
.download-instructions { max-width: 700px; padding-left: 20px; color: #5b6670; font-size: 12px; line-height: 1.7; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 70px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 19px 8px; }
  .sidebar-brand span:last-child, .sidebar-footer span:last-child, .nav-item span { display: none; }
  .sidebar-brand { padding: 0 0 30px; }
  .nav-item { justify-content: center; padding: 0; }
  .sidebar-footer { padding: 15px 0 0; }
  .topbar, .view-container { padding-left: 27px; padding-right: 27px; }
}
@media (max-width: 650px) {
  .auth-card { padding: 31px 24px 27px; }
  .shell { display: flex; flex-direction: column; }
  .content { order: 1; min-height: calc(100vh - 64px); }
  .sidebar { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: block; height: 64px; padding: 5px 8px; border-top: 1px solid var(--line); border-right: 0; }
  .sidebar-brand, .sidebar-footer { display: none; }
  .navigation { display: flex; gap: 3px; overflow-x: auto; }
  .nav-item { flex: 0 0 76px; min-height: 53px; flex-direction: column; gap: 3px; font-size: 10px; }
  .nav-item span { display: inline; }
  .topbar { min-height: 92px; padding: 19px 17px 16px; }
  .topbar h1 { font-size: 20px; }
  .topbar .button { min-height: 33px; padding: 0 10px; font-size: 11px; }
  .view-container { padding: 21px 17px 90px; }
  .split-panel { grid-template-columns: 1fr; }
  .list-pane { max-height: 300px; border-right: 0; border-bottom: 1px solid #e8ebee; }
  .detail-pane { min-height: 250px; }
  .section-heading { align-items: start; flex-direction: column; }
  .grant-address-list, .admin-inventory { grid-template-columns: 1fr; }
}
