:root {
  color-scheme: dark;
  --bg: #101614;
  --surface: #171e1b;
  --surface-soft: #1d2621;
  --surface-hover: #26312b;
  --border: #2b3730;
  --text: #ecf1ed;
  --muted: #a2b0a7;
  --subtle: #77867d;
  --accent: #a5e6be;
  --accent-strong: #72d599;
  --accent-ink: #112d1d;
  --error: #ffaaaa;
  --warning: #e7c48b;
  --radius: 16px;
  --font: Tahoma, "Segoe UI", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 26px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; line-height: 1.7; min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 4px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent-strong); }
::selection { background: #3f7255; color: #fff; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.5; letter-spacing: -.6px; }
h2 { font-size: 16px; line-height: 1.6; font-weight: 700; }
h3 { font-size: 14px; line-height: 1.6; }
.icon { display: inline-block; width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -70px; right: 20px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 10px 20px; border-radius: 8px; }
.skip-link:focus { top: 10px; }
.muted { color: var(--muted); }
.mono, .code-input { font-family: var(--mono); letter-spacing: .4px; }
.section-label, .eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .15px; display: block; margin-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; line-height: 1.6; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 41px; height: 41px; background: #20372b; color: var(--accent); border: 1px solid #365340; border-radius: 11px; flex-shrink: 0; }
.brand-mark .icon { width: 25px; height: 25px; }
.brand small { display: block; font-family: var(--mono); font-size: 9px; color: var(--subtle); letter-spacing: 2.1px; font-weight: 400; text-align: right; }
.button { border: 1px solid transparent; border-radius: 9px; min-height: 43px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; transition: background .16s ease, border-color .16s ease, color .16s ease; white-space: nowrap; }
.button .icon { width: 18px; height: 18px; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover:not(:disabled) { background: #bff2d1; }
.button.secondary { background: var(--surface-soft); border-color: #35463b; color: var(--text); }
.button.secondary:hover:not(:disabled) { background: #2c3b31; border-color: #526c5c; }
.button.subtle { background: transparent; color: var(--muted); border-color: var(--border); }
.button.subtle:hover:not(:disabled) { color: var(--text); background: var(--surface-soft); }
.button.small { min-height: 35px; padding: 6px 12px; font-size: 11px; }
.button.danger { background: #4c2c2d; border-color: #875154; color: #ffd7d7; }
.button.danger:hover:not(:disabled) { background: #623638; }
.button.full { width: 100%; }
.text-link { color: var(--accent); font-size: 12px; display: inline-block; margin-top: 20px; }
.text-link:hover { text-decoration: underline; }
.field { min-width: 0; }
.field label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.field small { color: var(--subtle); display: block; font-size: 10px; line-height: 1.8; margin-top: 6px; }
input:not([type="file"]), textarea, select { display: block; width: 100%; min-height: 45px; border: 1px solid #36433b; background: #111814; color: var(--text); border-radius: 8px; padding: 11px 13px; transition: border-color .15s; }
input::placeholder, textarea::placeholder { color: #75857a; opacity: 1; font-family: var(--font); font-size: 12px; }
input:disabled, textarea:disabled { opacity: .6; }
input[type="number"] { font-family: var(--mono); direction: ltr; text-align: right; }
textarea { resize: vertical; min-height: 76px; max-height: 260px; }
select { padding-inline-end: 28px; }
.password-wrap { position: relative; }
.password-wrap input { padding-inline-end: 70px; direction: ltr; text-align: left; padding-right: 70px; padding-left: 13px; }
.reveal-button { position: absolute; top: 7px; right: 7px; bottom: 7px; padding: 0 9px; border: 0; border-radius: 5px; color: var(--muted); background: #253127; font-size: 10px; min-width: 49px; }
.reveal-button:hover { color: var(--accent); }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.message { font-size: 12px; padding: 10px 12px; border-radius: 8px; background: #1f3227; color: #b7dec4; border: 1px solid #38503f; overflow-wrap: anywhere; }
.message.error { color: var(--error); background: #302021; border-color: #5c383a; }
.message.warning, .notice.warning { color: var(--warning); background: #302b21; border-color: #5b4b33; }
.notice { background: #203126; border: 1px solid #3e5546; color: #bbd0c2; border-radius: 9px; padding: 13px 15px; font-size: 12px; }
.optional { color: var(--subtle); font-size: 10px; font-weight: 400; margin-inline-start: 5px; }
.boot-screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 30px; color: var(--muted); }
.boot-screen .brand-mark { width: 58px; height: 58px; }
.boot-screen .message { max-width: 420px; }
.loader { display: inline-block; height: 19px; width: 19px; border: 2px solid #43594b; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Private-access entrance */
.auth-view { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-story { background: #17261d; padding: 44px 10%; display: flex; flex-direction: column; justify-content: space-between; border-inline-end: 1px solid #304534; }
.auth-story-content { max-width: 420px; padding: 65px 0; }
.auth-story h1 { font-size: clamp(32px, 3.3vw, 48px); line-height: 1.65; letter-spacing: -1px; margin: 16px 0 24px; }
.auth-story h1 span { color: var(--accent); }
.auth-story-content > p { color: #a5b9ac; line-height: 2; font-size: 13px; max-width: 345px; }
.auth-features { display: flex; flex-direction: column; gap: 17px; margin-top: 44px; color: #b7c8bd; font-size: 12px; }
.auth-features > div { display: flex; gap: 12px; align-items: center; }
.auth-features .icon { color: #6f9a7f; width: 18px; }
.auth-bottom { color: #7f9988; font-size: 10px; }
.auth-panel { padding: 50px 9% 22px; display: flex; flex-direction: column; justify-content: center; }
.auth-form-wrap { width: 100%; max-width: 375px; margin: auto; padding: 30px 0; }
.auth-form-wrap h2 { font-size: 28px; margin-bottom: 10px; }
.auth-form-wrap > .muted { font-size: 12px; margin-bottom: 30px; }
.auth-form-wrap .button { min-height: 46px; }
.auth-help { display: flex; gap: 10px; color: var(--subtle); padding-top: 24px; margin-top: 25px; border-top: 1px solid var(--border); font-size: 11px; }
.auth-help .icon { width: 16px; margin-top: 3px; }
.auth-footer { color: var(--subtle); font-size: 10px; text-align: center; padding-top: 30px; }
#auth-notice { margin-top: 18px; }

/* Workspace shell */
.workspace { display: flex; min-height: 100dvh; }
.rail { width: 226px; flex-shrink: 0; padding: 30px 20px 25px; border-inline-end: 1px solid var(--border); background: #131b17; display: flex; flex-direction: column; position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 20; }
.rail .brand { font-size: 16px; gap: 10px; margin: 0 5px; }
.rail .brand small { letter-spacing: 2.2px; }
.rail-label { color: var(--subtle); font-size: 10px; margin: 55px 14px 14px; }
.main-nav { display: flex; flex-direction: column; gap: 7px; }
.main-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 9px; color: var(--muted); font-size: 12px; border: 1px solid transparent; }
.main-nav a:hover { color: var(--text); background: #1c2820; }
.main-nav a.active { background: #243a2b; color: #bae9ca; border-color: #34513d; }
.main-nav .icon { width: 18px; height: 18px; }
.rail-bottom { margin-top: auto; padding: 30px 10px 0; }
.rail-private { display: flex; gap: 8px; align-items: center; color: #afc8b7; font-size: 11px; }
.rail-private .icon { width: 15px; }
.rail-bottom p { color: var(--subtle); font-size: 10px; margin: 12px 0 25px; line-height: 1.9; }
.version { font-family: var(--mono); font-size: 8px; letter-spacing: 1px; color: #617468; }
.workspace-body { width: calc(100% - 226px); margin-inline-start: 226px; min-width: 0; }
.topbar { min-height: 83px; padding: 17px 38px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.breadcrumb { display: flex; gap: 14px; align-items: center; font-size: 11px; color: var(--subtle); }
.breadcrumb strong { color: #cbd6ce; font-weight: 400; }
.breadcrumb-slash { color: #4d6054; }
.account-actions { display: flex; align-items: center; gap: 15px; }
.breadcrumb, .account-actions, .account-button, .account-text { min-width: 0; }
.header-admin-link { display: inline-flex; align-items: center; gap: 6px; color: #a9c5b2; font-size: 10px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; }
.header-admin-link:hover { background: var(--surface-soft); color: var(--accent); }
.header-admin-link .icon { width: 15px; height: 15px; }
.account-button { display: flex; align-items: center; gap: 10px; border: 0; padding: 0; background: transparent; text-align: right; color: var(--text); }
.avatar { background: #2f4335; border: 1px solid #4a604f; color: var(--accent); height: 35px; width: 35px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.account-text strong { display: block; font-size: 11px; line-height: 1.6; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { font-size: 9px; color: var(--subtle); }
.topbar-divider { width: 1px; height: 23px; background: var(--border); }
.icon-button { display: inline-flex; gap: 6px; align-items: center; justify-content: center; background: transparent; border: 0; color: var(--muted); padding: 8px 5px; font-size: 11px; border-radius: 6px; }
.icon-button:hover { color: var(--text); background: var(--surface-soft); }
.icon-button .icon { width: 17px; height: 17px; }
main { padding: 35px 38px 30px; max-width: 1320px; margin-inline: auto; outline: none; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 30px; }
.page-heading h1 { margin-bottom: 8px; }
.page-heading .muted { font-size: 12px; }
.private-badge { display: inline-flex; align-items: center; gap: 7px; background: #1b2820; color: #a9c5b2; border: 1px solid #324838; padding: 7px 12px; border-radius: 30px; font-size: 10px; white-space: nowrap; }
.private-badge .icon { width: 13px; height: 13px; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 23px; align-items: start; }
/* Let content shrink within its grid/flex track instead of widening the workspace. */
.work-grid > *, .side-stack > *, .credit-card > *, .stat-card { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.card-heading p { color: var(--subtle); font-size: 11px; margin-top: 5px; }
.step-tag { font-family: var(--mono); color: #81958a; letter-spacing: .6px; font-size: 9px; white-space: nowrap; }
.generator-card { padding: 25px; }
.tabs { margin: 23px 0 20px; background: #101813; padding: 5px; border-radius: 10px; border: 1px solid #29382e; display: flex; gap: 5px; }
.tabs button { display: flex; flex: 1; align-items: center; justify-content: center; gap: 8px; padding: 11px 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--subtle); font-size: 11px; font-weight: 700; }
.tabs button[aria-selected="true"] { color: var(--text); background: #27372c; border-color: #3a4d40; box-shadow: 0 2px 5px #0002; }
.tabs .icon { width: 17px; height: 17px; }
.scan-zone { border: 1px dashed #425b4b; background: #15221a; border-radius: 11px; text-align: center; padding: 25px 18px 19px; }
.scan-symbol { height: 50px; width: 50px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; color: #86ba98; border: 1px solid #395140; background: #24362a; border-radius: 12px; }
.scan-symbol .icon { width: 29px; height: 29px; stroke-width: 1.3; }
.scan-zone h3 { font-size: 14px; margin-bottom: 6px; }
.scan-zone > p { color: var(--subtle); font-size: 10px; }
.scan-actions { display: flex; justify-content: center; gap: 10px; margin-top: 23px; }
.scan-actions .button { font-size: 11px; padding: 9px 13px; }
.local-note { display: inline-flex; gap: 5px; align-items: center; color: #83a38d; font-size: 9px; margin-top: 17px; }
.local-note .icon { width: 11px; height: 11px; }
.preview-wrap { padding: 14px; margin-top: 13px; border: 1px solid var(--border); border-radius: 10px; text-align: center; background: #101713; }
.preview-wrap img { display: block; margin: 0 auto 10px; max-height: 175px; max-width: 100%; object-fit: contain; border-radius: 6px; }
#scan-status { margin-top: 13px; }
.paste-box { padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: #131c16; }
.paste-box .button { margin-top: 13px; }
#parse-status { margin-top: 12px; }
.input-heading { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 14px; }
.input-heading h3 { font-size: 12px; }
.input-heading span { font-size: 9px; }
.code-input { font-size: 15px; }
.usage-note { display: flex; gap: 9px; margin: 20px 0; font-size: 10px; color: #8fa896; align-items: flex-start; line-height: 1.9; }
.usage-note .icon { height: 15px; width: 15px; margin-top: 3px; }
.usage-note strong { color: #bed2c4; font-weight: 400; }
#generate-error, #retry-note { margin-bottom: 14px; }
.generate-button { min-height: 47px; }
.generate-button .icon { margin-inline-start: auto; }
.generate-button #generate-label { margin-inline-start: auto; }
.generation-note { font-size: 10px; margin-top: 10px; overflow-wrap: anywhere; }
.side-stack { display: flex; flex-direction: column; gap: 20px; }
.credit-card { background: #234430; border: 1px solid #3c664b; border-radius: var(--radius); color: #d7ecd9; padding: 23px; position: relative; }
.credit-top { display: flex; align-items: center; justify-content: space-between; }
.credit-top h2 { font-size: 13px; font-weight: 400; color: #c1dbc6; }
.credit-top .icon { width: 17px; height: 17px; color: #82b68f; }
.balance { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 12px; margin: 10px 0 15px; }
.balance strong { min-width: 0; max-width: 100%; overflow-wrap: anywhere; font-family: var(--mono); font-size: 53px; line-height: 1.25; letter-spacing: -2px; font-weight: 500; color: #e0f8e5; }
.balance strong.wide-number { font-size: 36px; letter-spacing: -1px; }
.balance strong.very-wide-number { font-size: 28px; }
.balance span { font-size: 11px; color: #a9cdb1; }
.credit-track { height: 4px; border-radius: 5px; background: #163423; overflow: hidden; }
.credit-track span { display: block; height: 100%; background: #b6e8c2; width: 0; transition: width .3s ease; border-radius: inherit; }
.credit-meta { display: flex; flex-wrap: wrap; gap: 7px 10px; justify-content: space-between; padding-top: 17px; }
.credit-meta > div { display: flex; min-width: 0; flex-wrap: wrap; gap: 3px 10px; align-items: center; font-size: 9px; color: #9abbA3; }
.credit-meta strong { min-width: 0; max-width: 100%; overflow-wrap: anywhere; color: #d0e7d5; font-size: 12px; font-family: var(--mono); font-weight: 400; }
.credit-card > p { color: #96bb9f; font-size: 9px; border-top: 1px solid #3b5f45; margin-top: 18px; padding-top: 13px; line-height: 1.9; }
.credit-card.exhausted { background: #322d20; border-color: #665637; }
.credit-card.exhausted .balance strong { color: #e7c48b; }
.credit-card.exhausted > p { color: #dbc098; border-color: #51452f; }
.credit-refresh { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0; color: #a9d3b3; font-size: 9px; padding: 9px 0 0; }
.credit-refresh .icon { width: 12px; height: 12px; }
.result-card { padding: 22px; }
.result-card .card-heading h2 { font-size: 14px; }
.result-empty { padding: 31px 12px; text-align: center; }
.result-empty > .icon { color: #657d6e; width: 31px; height: 31px; margin-bottom: 18px; }
.result-empty h3 { font-size: 12px; color: #bacbbf; margin-bottom: 8px; }
.result-empty p { font-size: 10px; color: #81988b; line-height: 1.9; }
.success-label { display: flex; gap: 6px; align-items: center; color: #92c7a3; font-size: 10px; margin-top: 20px; }
.success-label .icon { width: 15px; height: 15px; }
.answer-code { display: block; font-family: var(--mono); color: #caeccf; font-size: clamp(23px, 2.8vw, 34px); text-align: center; letter-spacing: 5px; border: 1px solid #354d3e; background: #101b13; border-radius: 9px; padding: 16px 4px; margin: 15px 0; user-select: all; overflow-wrap: anywhere; }
.result-card .button { font-size: 11px; min-height: 39px; }
.result-details { margin: 17px 0 0; }
.result-details > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 10px; }
.result-details dt { color: var(--subtle); flex-shrink: 0; }
.result-details dd { margin: 0; text-align: left; color: #c3d2c8; font-size: 11px; overflow-wrap: anywhere; }
.result-footnote { font-size: 9px; color: var(--subtle); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.history-card { margin-top: 25px; }
.history-card > .card-heading, .admin-card > .card-heading { padding: 22px 25px; }
.history-card > .message, .admin-card > .message { margin: 0 20px 20px; }
/* Contain absolute accessibility labels as well as the wide table's scrolling. */
.table-wrap { position: relative; min-width: 0; max-width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: right; font-size: 11px; white-space: nowrap; }
caption { text-align: right; }
th { color: #83978a; font-size: 10px; font-weight: 400; background: #131c16; border-block: 1px solid var(--border); padding: 12px 20px; }
td { padding: 16px 20px; color: #b7c6bd; border-bottom: 1px solid #28352c; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1b2820; }
.table-code { font-family: var(--mono); direction: ltr; text-align: right; color: #bfd4c6; font-size: 12px; }
.table-answer { color: var(--accent); letter-spacing: 1.1px; }
.table-date { color: #7f9487; font-size: 10px; }
.table-actions { display: flex; gap: 6px; align-items: center; }
.table-actions .button { font-size: 10px; min-height: 31px; padding: 4px 9px; }
.loading-state { min-height: 160px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 12px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--subtle); }
.empty-state > .icon { width: 28px; height: 28px; margin-bottom: 13px; }
.empty-state h3 { color: #b5c6bb; font-size: 13px; margin-bottom: 8px; }
.empty-state p { font-size: 11px; }
.workspace-footer { display: flex; gap: 18px; justify-content: space-between; padding: 22px 38px 25px; color: #6d8375; font-size: 9px; border-top: 1px solid #253229; }

/* Administrator */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 25px; }
.stat-card { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 19px 21px; }
.stat-card span { display: block; font-size: 10px; color: var(--muted); }
.stat-card strong { display: block; overflow-wrap: anywhere; font-size: 28px; font-family: var(--mono); font-weight: 500; color: #dceade; margin-top: 12px; }
.stat-card strong.wide-stat { font-size: 19px; letter-spacing: -.3px; }
.stat-card strong.long-stat { font-size: 13px; }
.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 25px 21px; }
.search-wrap { position: relative; flex: 1; min-width: 0; max-width: 340px; }
.search-wrap .icon { position: absolute; right: 12px; top: 13px; color: var(--subtle); height: 18px; width: 18px; }
.search-wrap input { padding-inline-start: 38px; min-height: 42px; font-size: 11px; }
.admin-toolbar select { width: 155px; min-height: 42px; font-size: 11px; }
.user-cell strong { display: block; color: var(--text); font-size: 11px; max-width: 180px; text-overflow: ellipsis; overflow: hidden; }
.user-cell small { display: block; font-size: 10px; font-family: var(--mono); direction: ltr; text-align: right; color: var(--subtle); }
.user-role { color: #9acba9; font-size: 9px; margin-inline-start: 7px; }
.status-pill { display: inline-block; padding: 3px 9px; border-radius: 30px; font-size: 9px; border: 1px solid #365641; background: #223a2a; color: #afdcba; }
.status-pill.inactive { color: #d3b7b6; background: #362829; border-color: #574041; }
.users-table .table-actions { flex-wrap: wrap; min-width: 225px; max-width: 260px; }
.users-table td, .users-table th { padding-inline: 17px; }
.users-table .table-actions .button { font-weight: 400; }
.admin-footnote { color: var(--subtle); font-size: 10px; margin-top: 20px; display: flex; align-items: flex-start; gap: 8px; }
.admin-footnote .icon { height: 15px; width: 15px; margin-top: 2px; }

/* Accessible in-app confirmations */
.modal { max-width: min(480px, calc(100vw - 32px)); width: 480px; max-height: calc(100dvh - 40px); color: var(--text); border: 1px solid #415549; border-radius: 16px; background: #18231c; padding: 25px; overflow-y: auto; box-shadow: 0 25px 100px #0007; }
.modal::backdrop { background: #030b08c7; backdrop-filter: blur(4px); }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-heading h2 { font-size: 19px; }
.modal-heading .section-label { font-size: 10px; }
.modal .muted { font-size: 12px; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 10px; padding-top: 10px; }
.modal-actions .primary, .modal-actions .danger { flex: 1; }
.close-button { border: 1px solid var(--border); background: #222f26; color: var(--muted); border-radius: 8px; font-size: 24px; line-height: 1; width: 32px; height: 32px; flex-shrink: 0; }
.close-button:hover { color: var(--text); }
.toast-region { position: fixed; bottom: 25px; left: 25px; z-index: 100; display: flex; flex-direction: column; align-items: start; gap: 10px; pointer-events: none; max-width: min(440px, calc(100vw - 40px)); }
.toast { color: #d4ebdb; background: #263d2e; border: 1px solid #52765d; padding: 13px 18px; border-radius: 10px; box-shadow: 0 6px 30px #0004; font-size: 12px; animation: appear .18s ease-out; }
.toast.error { background: #39282a; color: #ffd0d0; border-color: #875657; }
@keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 1550px) { main { padding-top: 45px; } .work-grid { gap: 28px; } .generator-card { padding: 30px; } }
@media (max-width: 1180px) {
  .rail { width: 205px; padding-inline: 15px; }
  .workspace-body { width: calc(100% - 205px); margin-inline-start: 205px; }
  .topbar { padding-inline: 25px; }
  main { padding: 28px 25px; }
  .work-grid { grid-template-columns: minmax(0, 1.6fr) minmax(255px, 1fr); gap: 17px; }
  .generator-card { padding: 21px; }
  .credit-card, .result-card { padding: 20px; }
  .scan-actions { flex-wrap: wrap; gap: 8px; }
  .field-row { gap: 12px; }
  .stats-grid { gap: 11px; }
  .stat-card { padding: 16px; }
  .stat-card span { font-size: 9px; }
  td, th { padding-inline: 15px; }
  .workspace-footer { padding-inline: 25px; }
}
@media (max-width: 980px) and (min-width: 761px) {
  .rail { width: 185px; padding-inline: 12px; }
  .rail .brand { font-size: 14px; gap: 8px; }
  .rail .brand-mark { width: 33px; height: 33px; }
  .main-nav a { gap: 8px; padding-inline: 10px; font-size: 11px; }
  .workspace-body { width: calc(100% - 185px); margin-inline-start: 185px; }
  main { padding-inline: 20px; }
  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .side-stack { flex-direction: row; align-items: stretch; }
  .side-stack > section { flex: 1; min-width: 0; }
  .answer-code { font-size: 28px; }
  .breadcrumb { font-size: 10px; gap: 8px; }
  .account-text strong { max-width: 110px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 12px; }
  h1 { font-size: 24px; }
  html { scroll-padding-top: 20px; }
  .workspace { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .rail { position: fixed; inset-block-start: auto; inset-block-end: 0; inset-inline: 0; width: 100%; padding: 7px 12px calc(8px + env(safe-area-inset-bottom, 0px)); border-inline-end: 0; border-top: 1px solid #3a4b40; background: #17231bf5; backdrop-filter: blur(12px); }
  .rail > .brand, .rail-label, .rail-bottom { display: none; }
  .main-nav { flex-direction: row; gap: 6px; justify-content: center; }
  .main-nav a { flex: 1; justify-content: center; flex-direction: column; gap: 5px; padding: 8px 4px; font-size: 9px; border-radius: 7px; min-height: 54px; max-width: 230px; }
  .main-nav .icon { height: 19px; width: 19px; }
  .workspace-body { width: 100%; margin: 0; }
  .topbar { min-height: 72px; padding: 14px 20px; }
  .breadcrumb { gap: 7px; font-size: 10px; }
  .breadcrumb > span:first-child, .breadcrumb-slash { display: none; }
  .breadcrumb strong { font-weight: 700; color: #c6dacc; }
  .account-actions { gap: 10px; }
  .header-admin-link { padding: 7px; }
  .header-admin-link span { display: none; }
  .account-text strong { font-size: 10px; max-width: 120px; }
  .account-text small { font-size: 8px; }
  .avatar { width: 31px; height: 31px; font-size: 11px; }
  .account-button { gap: 7px; }
  .logout-label { display: none; }
  .icon-button { min-height: 34px; min-width: 30px; }
  main { padding: 26px 18px 25px; }
  .page-heading { flex-wrap: wrap; margin-bottom: 23px; gap: 12px; }
  .page-heading .section-label { font-size: 10px; }
  .page-heading .muted { font-size: 11px; }
  .private-badge { font-size: 9px; padding: 5px 9px; }
  .work-grid { display: flex; flex-direction: column; gap: 18px; }
  .generator-card { width: 100%; padding: 21px; order: 1; }
  .side-stack { width: 100%; display: contents; }
  .credit-card { order: 0; width: 100%; padding: 20px 22px; }
  .result-card { order: 2; width: 100%; padding: 22px; }
  .credit-card { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; column-gap: 22px; }
  .credit-top { grid-column: 1; align-self: start; }
  .credit-top .icon { display: none; }
  .balance { grid-column: 1; grid-row: 2 / 4; margin: 7px 0 0; gap: 8px; }
  .balance strong { font-size: 42px; }
  .balance strong.wide-number { font-size: 30px; }
  .balance strong.very-wide-number { font-size: 22px; }
  .balance span { font-size: 9px; }
  .credit-track { grid-column: 2; grid-row: 1; margin-top: 4px; }
  .credit-meta { grid-column: 2; grid-row: 2 / 4; flex-direction: column; gap: 7px; padding-top: 11px; }
  .credit-meta > div { justify-content: space-between; font-size: 9px; }
  .credit-card > p { grid-column: 1 / -1; margin-top: 15px; padding-top: 11px; }
  .credit-refresh { grid-column: 1 / -1; justify-self: start; padding-top: 7px; }
  .result-empty { padding: 20px 12px; }
  .answer-code { font-size: 33px; padding-block: 19px; }
  .result-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
  .result-details > div:last-child { grid-column: 1 / -1; }
  .history-card { margin-top: 20px; }
  .history-card > .card-heading, .admin-card > .card-heading { padding: 21px; }
  .history-card .card-heading p { max-width: 215px; font-size: 10px; }
  .workspace-footer { flex-direction: column; gap: 5px; padding: 18px 20px; font-size: 9px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
  .stat-card { padding: 16px 18px; }
  .stat-card span { font-size: 10px; }
  .stat-card strong { font-size: 27px; margin-top: 8px; }
  #new-user-button { font-size: 10px; padding-inline: 11px; }
  #new-user-button .icon { width: 15px; }
  .admin-toolbar { padding: 0 20px 20px; gap: 9px; }
  .search-wrap input { font-size: 10px; }
  .search-wrap input::placeholder { font-size: 10px; }
  .admin-toolbar select { width: 122px; font-size: 10px; }
  .users-table { white-space: normal; }
  .users-table thead { display: none; }
  .users-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 15px 20px; gap: 10px 20px; border-top: 1px solid var(--border); }
  .users-table td { min-width: 0; overflow-wrap: anywhere; padding: 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 7px; font-size: 11px; }
  .users-table td::before { content: attr(data-label); color: var(--subtle); font-size: 10px; }
  .users-table td:first-child { grid-column: 1 / -1; display: block; margin-bottom: 4px; }
  .users-table td:first-child::before, .users-table td:last-child::before { display: none; }
  .users-table td:nth-child(5), .users-table td:last-child { grid-column: 1 / -1; }
  .users-table td:last-child { padding-top: 6px; }
  .user-cell strong { max-width: 100%; overflow-wrap: anywhere; }
  .user-cell small { overflow-wrap: anywhere; }
  .users-table .table-actions { min-width: 0; max-width: none; width: 100%; }
  .users-table .table-actions .button { flex: 1; min-height: 37px; font-size: 10px; }
  .table-actions .button { min-height: 35px; }
  .auth-view { display: flex; flex-direction: column; }
  .auth-story { padding: 24px; border-inline-end: 0; border-bottom: 1px solid #304534; }
  .auth-story .brand { font-size: 16px; }
  .auth-story .brand small { font-size: 8px; }
  .auth-story-content { padding: 25px 0 0; max-width: none; }
  .auth-story h1 { font-size: 24px; margin: 0 0 8px; line-height: 1.6; }
  .auth-story h1 br { display: none; }
  .auth-story h1 span { display: block; }
  .auth-story .eyebrow, .auth-features, .auth-bottom { display: none; }
  .auth-story-content > p { font-size: 10px; max-width: none; }
  .auth-panel { padding: 20px 25px 25px; flex: 1; }
  .auth-form-wrap { padding: 18px 0; }
  .auth-form-wrap h2 { font-size: 25px; }
  .auth-form-wrap > .muted { margin-bottom: 25px; font-size: 11px; }
  .auth-footer { padding-top: 17px; }
  .toast-region { left: 18px; right: 18px; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); max-width: none; }
  .toast { width: 100%; font-size: 11px; }
  .modal { padding: 23px; }
}
@media (max-width: 400px) {
  .private-badge { display: none; }
  .topbar { padding-inline: 16px; }
  .account-text strong { max-width: 70px; }
  .account-actions { gap: 8px; }
  .breadcrumb strong { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
  .field-row { grid-template-columns: 1fr; gap: 14px; }
  .generator-card { padding: 18px; }
  .scan-zone { padding-inline: 13px; }
  .scan-actions { gap: 8px; }
  .scan-actions .button { font-size: 10px; padding-inline: 11px; flex: 1; }
  .card-heading .step-tag { font-size: 8px; }
  .admin-toolbar { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: none; }
  .admin-toolbar select { width: 100%; }
  .users-table .table-actions .button { flex-basis: calc(50% - 6px); }
  .modal-actions { flex-direction: column; }
  .balance strong { font-size: 37px; }
  .credit-card { column-gap: 13px; padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Language preferences are independent of account and generation state. */
.language-switch { min-height: 34px; padding: 6px 10px; border: 1px solid #405748; border-radius: 7px; background: #213128; color: var(--accent); font-size: 11px; font-weight: 700; flex-shrink: 0; }
.language-switch:hover { background: #2d4436; }
.auth-form-wrap > .language-switch { display: block; margin-inline-start: auto; margin-bottom: 20px; }
html[dir="ltr"] .brand small, html[dir="ltr"] .account-button, html[dir="ltr"] table, html[dir="ltr"] caption, html[dir="ltr"] .table-code, html[dir="ltr"] .user-cell small { text-align: left; }
html[dir="ltr"] input[type="number"] { text-align: left; }
html[dir="ltr"] .search-wrap .icon { right: auto; left: 12px; }
html[dir="ltr"] .generate-button > .icon, html[dir="ltr"] #login-submit > .icon { transform: scaleX(-1); }
html[dir="ltr"] .skip-link { right: auto; left: 20px; }
html[dir="ltr"] .brand { font-size: 16px; }
html[dir="ltr"] .auth-story h1 { line-height: 1.45; letter-spacing: -.8px; }
.page-heading > div, .card-heading > div { min-width: 0; }
.tabs button { min-width: 0; }
.generate-button { white-space: normal; }
@media (max-width: 760px) {
  .account-actions { min-width: 0; flex-wrap: wrap; }
  .language-switch { min-height: 32px; font-size: 10px; padding: 5px 8px; }
  html[dir="ltr"] .main-nav a { font-size: 9px; }
}
@media (max-width: 600px) {
  .topbar > .breadcrumb { display: none; }
  .topbar .account-actions { width: 100%; justify-content: space-between; gap: 7px; }
  .topbar .account-text strong { max-width: 95px; }
}
@media (max-width: 360px) {
  .topbar .account-text strong { max-width: 65px; }
  .scan-actions { flex-wrap: wrap; }
}

.auth-story h1 > span { color: inherit; }
.auth-story h1 > span:last-child { color: var(--accent); }
@media (max-width: 760px) {
  .auth-story h1 > span:not(:last-child) { display: inline; }
  .auth-story h1 > span:not(:last-child)::after { content: ' '; }
}

/* A minimal entrance: language control first, then the sign-in form only. */
.auth-view { display: flex; flex-direction: column; min-width: 0; }
.auth-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 76px; width: 100%; padding: 16px 24px; }
.auth-brand { display: flex; align-items: center; gap: 12px; min-width: 0; font-size: 18px; font-weight: 700; line-height: 1.5; }
.auth-brand > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.auth-brand .brand-mark { flex-shrink: 0; }
.auth-panel { flex: 1; min-width: 0; padding: 24px 20px 36px; align-items: center; justify-content: center; }
.auth-form-wrap { width: 100%; max-width: 380px; margin: 0 auto; padding: 30px 26px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.auth-form-wrap #auth-title { font-size: 26px; line-height: 1.5; letter-spacing: -.3px; margin: 0 0 28px; text-align: center; }
.auth-form-wrap .field { position: relative; }
.auth-form-wrap > .message, .auth-form-wrap > .notice { margin-top: 18px; }
.auth-contact { display: flex; align-items: center; justify-content: center; gap: 8px 12px; flex-wrap: wrap; padding: 20px 16px max(24px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 13px; text-align: center; }
.auth-contact a { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; overflow-wrap: anywhere; }
.auth-contact a:hover { color: var(--text); }
@media (max-width: 400px) {
  .auth-top { padding-inline: 18px; gap: 10px; }
  .auth-brand { gap: 9px; font-size: 14px; }
  .auth-brand .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .auth-panel { padding: 20px 16px 40px; }
  .auth-form-wrap { padding: 26px 20px; }
}
