/* Supplied brand colors live in /new-design/colors.css. These semantic tokens
   keep the app, authentication and dialogs on the same warm visual system. */
:root {
  --ink: var(--cofer-navy); --muted: #626b78; --navy: var(--cofer-navy); --accent: var(--cofer-orange);
  --line: #e7e2d9; --canvas: #faf8f4; --surface: #fff; --surface-soft: #fffaf3;
  --brand-gradient: linear-gradient(120deg, var(--cofer-gold), var(--cofer-orange));
  --brand-gradient-hover: linear-gradient(120deg, var(--cofer-orange), var(--cofer-gold));
  --navy-gradient: linear-gradient(155deg, #123d70, var(--cofer-navy) 55%, #061c3d);
  --warm-gradient: linear-gradient(135deg, var(--cofer-sand), var(--surface-soft));
  --warm-border: var(--cofer-peach); --focus: var(--cofer-navy); --focus-halo: #ff8a0026;
  --on-dark: #fff6e9; --muted-on-dark: #cbd7e7; --link: var(--cofer-navy);
  --success: #2f7059; --success-soft: #f0f7f2; --danger: #a13d35; --danger-soft: #fff3ef;
  --warning: #815000; --warning-soft: var(--cofer-sand);
  --radius: 16px; --shadow: 0 6px 24px #0a2b5b06;
}
body, .kufam, .profileWrap { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); }
body { background: var(--canvas); font-size: 14px; line-height: 1.55; }
/* Keep the page in place until the last native dialog or custom lightbox closes. */
html { scrollbar-gutter: stable; }
html:has(dialog[open], .lightbox.is-open), body:has(dialog[open], .lightbox.is-open) { overflow: hidden; overscroll-behavior: none; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a, button, [role="button"] { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 3vw, 40px); line-height: 1.18; letter-spacing: -1.4px; font-weight: 650; margin-bottom: 14px; }
h2 { font-size: 21px; line-height: 1.35; letter-spacing: -.5px; font-weight: 650; margin-bottom: 0; }
h3 { font-size: 18px; font-weight: 600; }
.ui-icon { width: 22px; height: 22px; flex-shrink: 0; vertical-align: middle; }
.brand { display: inline-flex; align-items: center; max-width: 100%; min-width: 0; color: inherit; }
.brand-logo { display: block; width: 180px; max-width: 100%; height: auto; }
.sidebar { width: 248px; position: fixed; inset: 0 auto 0 0; background: var(--navy-gradient); color: var(--on-dark); display: flex; flex-direction: column; padding: 28px 18px 18px; z-index: 100; }
.sidebar > .brand { margin: 0 14px 32px; max-width: calc(100% - 28px); }
.sidebar .brand-logo { width: 164px; }
.nav-caption { margin: 0 16px 14px; color: var(--muted-on-dark); font-size: 10px; letter-spacing: 1.8px; font-weight: 600; }
#app-menu { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
#app-menu .item { border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--muted-on-dark); display: flex; align-items: center; gap: 13px; text-align: left; padding: 13px 16px; min-height: 48px; font-weight: 500; }
#app-menu .item:hover { color: var(--on-dark); background: #ffffff0d; }
#app-menu .item.active { color: var(--navy); background: var(--brand-gradient); border-color: var(--cofer-gold); box-shadow: 0 4px 16px #061c3d30; }
#app-menu .item.active .ui-icon { color: var(--navy); }
.sidebar :focus-visible { outline-color: var(--cofer-gold); }
#app-menu .item[data-page="add"] { margin-bottom: 25px; }
.sidebar-note { margin: auto 14px 28px; padding-top: 40px; }
.sidebar-note p { font-size: 19px; line-height: 1.5; font-weight: 500; color: var(--on-dark); }
.sidebar-note > span:last-child { display: block; color: var(--muted-on-dark); font-size: 11px; max-width: 160px; }
.sidebar-account { display: flex; align-items: center; gap: 10px; border-top: 1px solid #ffffff12; padding: 20px 8px 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-gradient); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; border: 1px solid var(--cofer-gold); flex-shrink: 0; }
.sidebar-account > div { flex: 1; min-width: 0; }
.sidebar-account strong, .sidebar-account span:not(.avatar) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 12px; font-weight: 500; }
.sidebar-account span:not(.avatar) { font-size: 10px; color: var(--muted-on-dark); margin-top: 3px; }
.sidebar-account a { color: var(--muted-on-dark); padding: 6px; }
.workspace-bar { margin-left: 248px; height: 78px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 42px; background: #fff; }
.workspace-label { color: var(--muted); font-size: 12px; }
.workspace-label > span { color: #bbc7ce; margin: 0 14px; }
.workspace-label strong { color: var(--ink); font-weight: 500; }
.workspace-account { display: flex; gap: 12px; align-items: center; font-size: 12px; }
.mobile-brand, .mobile-logout { display: none; }
.authenticated #main-content { margin-left: 248px; }
.appPages { width: 100%; height: auto; overflow: visible; position: static; max-width: 1400px; margin: auto; padding: 40px 42px; }
.appPages > .page { display: none; position: static; width: auto; height: auto; background: none; overflow: visible; padding: 0; transition: none; }
.appPages > .page.active { display: block; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 32px; }
.page-heading p { color: var(--muted); font-size: 14px; margin-bottom: 0; max-width: 540px; }
.page-heading > .button { flex-shrink: 0; }
.button, .submitButton { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; padding: 12px 20px; border-radius: 10px; font-weight: 600; font-size: 13px; cursor: pointer; transition: background .15s, box-shadow .15s; text-decoration: none; }
.blueButton, .submitButton { background: var(--brand-gradient); border: 1px solid var(--cofer-orange); color: var(--navy); }
.blueButton:hover, .submitButton:hover { background: var(--brand-gradient-hover); color: var(--navy); box-shadow: 0 4px 14px #ff8a0026; }
.whiteButton { color: var(--ink); border: 1px solid var(--line); background: var(--surface); }
.whiteButton:hover { border-color: var(--warm-border); background: var(--surface-soft); }
.button .iconWrap { margin: 0; }
.submitButton .icon { width: 19px; }
.text-button { display: inline-flex; align-items: center; gap: 10px; padding: 7px 0; border: 0; background: transparent; color: var(--link); font-size: 12px; font-weight: 600; }
.text-button:hover { text-decoration: underline; }
.text-button .ui-icon { width: 17px; height: 17px; }
.stat-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 18px; margin-bottom: 30px; }
.stat-card { display: flex; position: relative; align-items: flex-start; gap: 15px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-icon { padding: 10px; background: var(--cofer-sand); border-radius: 10px; color: var(--navy); }
.stat-card > div > span { color: var(--muted); font-size: 11px; }
.stat-card strong { display: block; font-size: 32px; line-height: 1.3; margin: 8px 0 21px; font-weight: 600; letter-spacing: -1px; }
.stat-detail { position: absolute; bottom: 18px; left: 24px; font-size: 10px; color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(260px,1fr); gap: 24px; }
.surface { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 25px 26px; border-bottom: 1px solid var(--line); }
.section-heading h2 { font-size: 19px; }
.recent-list { padding: 8px 24px; }
.recent-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 18px 0; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; }
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: var(--surface-soft); }
.document-symbol { background: var(--cofer-sand); border: 1px solid var(--warm-border); color: var(--navy); padding: 10px; border-radius: 9px; }
.recent-info { flex: 1; min-width: 0; }
.recent-info strong { display: block; font-size: 13px; font-weight: 550; overflow-wrap: anywhere; }
.recent-info > span { display: block; color: var(--muted); font-size: 11px; margin-top: 3px; }
.recent-row > .ui-icon { color: #8a9ba7; width: 17px; }
.guide-card { background: var(--warm-gradient); border: 1px solid var(--warm-border); border-radius: var(--radius); padding: 28px; }
.guide-card h2 { font-size: 26px; line-height: 1.25; margin-bottom: 16px; }
.guide-card p { font-size: 12px; line-height: 1.8; color: var(--navy); }
.guide-card ol { list-style: none; padding: 8px 0; margin: 0; }
.guide-card li { font-size: 11px; display: flex; align-items: center; gap: 12px; margin-bottom: 17px; }
.guide-card li span { color: var(--navy); font-size: 14px; font-weight:700;border-bottom: 1px solid var(--warm-border); padding-bottom: 3px; }
.workspace-footnote { display: flex; align-items: center; justify-content: center; gap: 9px; font-size: 11px; color: var(--muted); margin: 30px 0 4px; }
.workspace-footnote .ui-icon { width: 16px; height: 16px; }
.empty-panel { text-align: center; padding: 42px 24px; }
.empty-panel p { max-width: 350px; margin: 10px auto 20px; font-size: 13px; color: var(--muted); line-height: 1.8; }
.empty-icon { display: inline-flex; padding: 18px; color: var(--navy); background: var(--cofer-sand); border-radius: 16px; margin-bottom: 20px; }
.empty-icon .ui-icon { width: 30px; height: 30px; }
.empty-panel h3 { margin-bottom: 0; }
.notification-empty { padding: 65px 24px; }
.notification-empty p { max-width: 420px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
#notifications { max-width: 1040px; margin: 0 auto; }
.notification-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0 0 26px; }
.notification-summary > div { min-width: 0; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.notification-summary dt { font-size: 12px; font-weight: 600; }
.notification-summary dd { margin: 0; }
.notification-summary strong { display: block; font-size: 30px; line-height: 1.3; font-weight: 600; margin: 6px 0; }
.notification-summary dd span { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; }
.notification-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.notification-filters button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 13px; font-weight: 600; }
.notification-filters button[aria-pressed="true"] { color: var(--link); border-color: var(--warm-border); background: var(--cofer-sand); }
.notification-filter-count { font-size: 11px; font-weight: 500; }
.notification-group { margin-bottom: 26px; }
.notification-group-title { display: flex; align-items: center; gap: 10px; font-size: 16px; margin: 0 0 12px; }
.notification-group-count { color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.notification-items { padding: 0 22px; margin: 0; list-style: none; }
.notification-item + .notification-item { border-top: 1px solid var(--line); }
.notification-row { display: flex; align-items: center; gap: 16px; width: 100%; min-width: 0; border: 0; border-radius: 8px; padding: 22px 0; background: transparent; color: var(--ink); text-align: left; }
.notification-row:hover { background: var(--surface-soft); }
.notification-symbol { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 11px; color: var(--link); background: var(--cofer-sand); }
.notification-symbol-expiry { color: #8b611d; background: #fbf4e6; }
.notification-content { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notification-row-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.notification-title { font-size: 14px; font-weight: 600; }
.notification-timing { flex-shrink: 0; font-size: 11px; padding: 3px 9px; border-radius: 5px; background: var(--surface-soft); color: var(--muted); }
.notification-timing-due { color: #a13b36; background: #fff0ed; }
.notification-timing-today { color: #876019; background: #fcf3de; }
.notification-date, .notification-context { display: block; font-size: 12px; margin-top: 6px; }
.notification-context { color: var(--muted); font-size: 11px; margin-top: 3px; }
.notification-arrow { color: #8192a1; flex-shrink: 0; }
.notification-arrow .ui-icon { width: 18px; height: 18px; }
.notification-help { color: var(--muted); font-size: 12px; line-height: 1.7; max-width: 640px; margin: 22px 0 0; }
@media(max-width:760px) {
  .notification-summary { gap: 8px; margin-bottom: 20px; }
  .notification-summary > div { padding: 14px 10px; border-radius: 10px; }
  .notification-summary dt { font-size: 11px; }
  .notification-summary strong { font-size: 26px; }
  .notification-summary dd span { font-size: 10px; }
  .notification-filters { gap: 6px; margin-bottom: 24px; }
  .notification-filters button { flex: 1; padding: 10px 8px; gap: 5px; font-size: 12px; }
  .notification-items { padding: 0 14px; }
  .notification-row { padding: 18px 0; gap: 10px; align-items: flex-start; }
  .notification-symbol { width: 34px; height: 34px; border-radius: 9px; }
  .notification-symbol .ui-icon { width: 19px; height: 19px; }
  .notification-row-heading { display: block; }
  .notification-title { display: block; font-size: 13px; }
  .notification-timing { display: inline-block; margin-top: 6px; }
  .notification-arrow { display: none; }
  .notification-empty { padding: 36px 18px; }
}
.status-pill { display: inline-block; color: var(--navy); background: var(--cofer-sand); border: 1px solid var(--warm-border); padding: 6px 12px; border-radius: 20px; font-size: 11px; }
.appPageTitle { background: none; padding: 0; color: var(--ink); font-size: 30px; font-weight: 600; letter-spacing: -.7px; line-height: 1.3; margin: 0 0 10px; }
.appPageDescription { margin: 0 0 28px; color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 640px; }
.buttonsList { background: transparent; padding: 16px 0; }
.buttonsList .list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-bottom: 8px; }
.buttonsList .listWrap .listItem { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 0; box-shadow: var(--shadow); cursor: pointer; min-width: 0; }
.buttonsList .listWrap .listItem:hover { border-color: var(--warm-border); background: #fbfdfc; }
.buttonsList .listWrap .listItem .iconWrap { width: 42px; border-radius: 10px; }
.buttonsList .listWrap .listItem .iconWrap img { width: 24px; }
.buttonsList .listWrap .listItem .iconWrap .iconBackground { opacity: .08; }
.buttonsList .listWrap .listItem .textWrap { padding-left: 3px; }
.buttonsList .listWrap .listItem .textWrap .text { font-size: 14px; font-weight: 550; }
.buttonsList .listWrap .listItem .textWrap .note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.buttonsList .listWrap .listItem .arrow { width: 13px; opacity: .5; }
.structoryWrap .mainAreas { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; gap: 14px; margin: 24px 0 8px; }
.structoryWrap .mainAreas .area + .area { border-left: 1px solid var(--line); }
.structoryWrap .area .name { font-size: 11px; color: var(--muted); }
.structoryWrap .area .text { color: var(--muted); font-size: 11px; }
.structoryPage .back { padding: 10px 0 0; }
.structoryPage .back img { width: 30px; padding: 7px; border: 1px solid var(--line); border-radius: 8px; background: white; cursor: pointer; }
.structoryWrap .documentRow { border-color: var(--line); border-radius: 10px; padding: 18px; cursor: pointer; }
.structoryWrap .documentRow:hover { border-color: var(--warm-border); }
.structoryWrap .documentRow .infoWrap { min-width: 0; overflow-wrap: anywhere; }
.structoryWrap .documentRow .infoWrap .tags .tag { background: var(--surface-soft); border: 0; color: var(--muted); padding: 5px 9px; border-radius: 5px; }
.addDocuments { max-width: 920px; margin: auto; }
.addDocuments .padded { padding: 26px; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.document-form-section { min-width: 0; }
.document-section-heading { margin: 0 0 16px; font-size: 18px; line-height: 1.4; letter-spacing: -.3px; }
.document-section-heading, .addDocuments #document-title-field, .addDocuments .taxonomy-heading, .document-form-section :is(input, select, textarea, button) { scroll-margin-top: calc(var(--app-safe-top, 0px) + 16px); }
.addDocuments .scannerActions { margin-top: 0; }
.addDocuments .scannerActions .button { flex: initial; }
.addDocuments .inputTitle { display: block; font-size: 13px; margin-bottom: 9px; }
.addDocuments .inputWrap { margin-top: 22px; }
.addDocuments .inputWrap textarea { min-height: 110px; resize: vertical; }
.original-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; cursor: pointer; font-size: 13px; font-weight: 600; }
.addDocuments .original-switch input[role="switch"] { appearance: none; -webkit-appearance: none; box-sizing: border-box; position: relative; flex-shrink: 0; width: 48px; height: 28px; padding: 0; margin: 0; border: 1px solid #b7c5d3; border-radius: 999px; background: #cbd5e1; cursor: pointer; transition: background-color .18s, border-color .18s; }
.addDocuments .original-switch input[role="switch"]::before { content: ''; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px #182d3f30; transition: transform .18s; }
.addDocuments .original-switch input[role="switch"]:checked { background: var(--navy); border-color: var(--navy); }
.addDocuments .original-switch input[role="switch"]:checked::before { transform: translateX(20px); }
.original-location-field { margin-top: 12px; }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.reminder-presets { margin-top: 12px; }
.choice-button { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; max-width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--ink); font-size: 12px; font-weight: 500; transition: background-color .15s, border-color .15s, box-shadow .15s; }
.choice-button:hover { border-color: var(--warm-border); background: var(--cofer-sand); }
.choice-button[aria-pressed="true"] { background: var(--cofer-sand); border-color: var(--navy); color: var(--link); box-shadow: inset 0 0 0 1px var(--navy); }
.choice-check { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 16px; height: 16px; border: 1px solid #b7c5d3; border-radius: 50%; background: #fff; }
.choice-check .ui-icon { width: 12px; height: 12px; opacity: 0; }
.choice-button[aria-pressed="true"] .choice-check { background: var(--navy); border-color: var(--navy); color: #fff; }
.choice-button[aria-pressed="true"] .choice-check .ui-icon { opacity: 1; }
.retention-options .choice-button { flex: 1 1 96px; }
.structoryWrapAdd { border-color: var(--line); border-radius: 10px; }
.structoryWrapAdd .buttonsList { padding: 12px; }
.structoryWrapAdd .mainAreas { border: 0; border-bottom: 1px solid var(--line); margin: 0; border-radius: 0; }
.structoryWrapAdd .listItem { padding: 12px !important; }
.structory2Chosen .structoryPages { margin-top: 0; }
.structory2Chosen #structory-pages2 .buttonsList { overflow: hidden; }
.structoryWrapAdd .back { padding-left: 12px; }
.addDocuments .submitButton { width: 100%; margin-top: 28px; }
.document-save-dialog { box-sizing: border-box; position: fixed; inset: var(--app-safe-top, 0px) 0 env(safe-area-inset-bottom, 0px); width: min(460px, calc(100% - 32px)); max-width: 100%; max-height: calc(100dvh - var(--app-safe-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px); margin: auto; padding: 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px #0a2b5b26; overflow-y: auto; text-align: center; overscroll-behavior: contain; }
.document-save-dialog::backdrop { background: #061c3d80; }
.document-save-dialog *, .document-save-dialog *::before, .document-save-dialog *::after { box-sizing: border-box; }
.document-save-symbol { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%; background: var(--cofer-sand); color: var(--navy); }
.document-save-spinner { width: 30px; height: 30px; border: 3px solid var(--warm-border); border-top-color: var(--navy); border-radius: 50%; animation: document-save-spin .85s linear infinite; }
.document-save-check { display: none; }
.document-save-check .ui-icon { width: 32px; height: 32px; }
.document-save-dialog:is([data-state="success"], [data-state="partial"]) .document-save-symbol { color: var(--success); background: var(--success-soft); }
.document-save-dialog:is([data-state="success"], [data-state="partial"]) .document-save-spinner { display: none; }
.document-save-dialog:is([data-state="success"], [data-state="partial"]) .document-save-check { display: inline-flex; }
.document-save-dialog h2 { margin: 0 0 10px; font-size: 24px; line-height: 1.3; overflow-wrap: anywhere; }
#document-save-message { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
#document-save-name { margin: 18px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--ink); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
#document-save-name:empty { display: none; }
.document-save-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.document-save-actions .button { min-width: 0; padding: 12px 14px; }
.document-save-warning { margin-top: 20px; padding: 14px; border: 1px solid #eadfc6; border-radius: 10px; background: #fcf8ee; color: #775c31; font-size: 13px; overflow-wrap: anywhere; }
.document-save-warning p { margin: 0 0 14px; }
.document-save-recovery { display: grid; gap: 12px; }
@keyframes document-save-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .document-save-spinner { animation: none; } }
@media (max-width: 520px) {
  .document-save-dialog { width: calc(100% - 24px); padding: 26px 20px; border-radius: 16px; }
  .document-save-dialog h2 { font-size: 21px; }
}
.document-delete-trigger { color: #a33f3f; border: 1px solid #dfbdbd; background: #fff; }
.document-delete-trigger:hover { color: #8c3131; border-color: #cf9c9c; background: #fff5f3; }
.document-delete-trigger .ui-icon { width: 18px; height: 18px; }
.document-delete-dialog { box-sizing: border-box; position: fixed; inset: var(--app-safe-top, 0px) 0 env(safe-area-inset-bottom, 0px); width: min(480px, calc(100% - 32px)); max-width: 100%; max-height: calc(100dvh - var(--app-safe-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px); margin: auto; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px #0a2b5b26; overflow-y: auto; overscroll-behavior: contain; }
.document-delete-dialog::backdrop { background: #061c3d80; }
.document-delete-dialog *, .document-delete-dialog *::before, .document-delete-dialog *::after { box-sizing: border-box; }
.document-delete-symbol { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: 18px; border-radius: 12px; background: #fff0ed; color: #a33f3f; }
.document-delete-symbol .ui-icon { width: 26px; height: 26px; }
.document-delete-dialog h2 { margin: 0 0 16px; font-size: 23px; line-height: 1.3; overflow-wrap: anywhere; }
#document-delete-name { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
#document-delete-name:empty { display: none; }
#document-delete-description { margin: 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
#document-delete-error { margin: 18px 0 0; overflow-wrap: anywhere; }
.document-delete-status { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.document-delete-spinner { display: none; flex: 0 0 18px; width: 18px; height: 18px; border: 2px solid #d7e1e8; border-top-color: #536d80; border-radius: 50%; animation: document-delete-spin .85s linear infinite; }
.document-delete-dialog[data-state="loading"] .document-delete-spinner { display: inline-block; }
.document-delete-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 24px; }
.document-delete-actions .button { min-width: 0; padding: 12px; }
.document-delete-confirm { color: #fff; border: 1px solid #a33f3f; background: #a33f3f; }
.document-delete-confirm:hover { color: #fff; border-color: #8c3131; background: #8c3131; }
.document-delete-dialog button:disabled { cursor: wait; opacity: .65; }
.document-delete-notice { margin: 0 0 22px; padding: 14px 16px; border: 1px solid #c4dcd2; border-radius: 10px; color: #315e53; background: #f1f8f4; font-size: 13px; overflow-wrap: anywhere; }
@keyframes document-delete-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .document-delete-spinner { animation: none; } }
@media (max-width: 520px) {
  .document-delete-dialog { width: calc(100% - 24px); padding: 24px 20px; border-radius: 16px; }
  .document-delete-dialog h2 { font-size: 21px; }
  .document-delete-actions { grid-template-columns: minmax(0, 1fr); }
}
.upload-intro { display: flex; align-items: center; gap: 16px; padding: 22px; margin-bottom: 20px; border: 1px dashed var(--warm-border); border-radius: 12px; background: var(--warm-gradient); }
.upload-intro > .ui-icon { color: var(--navy); width: 30px; height: 30px; }
.upload-intro strong { font-size: 14px; font-weight: 600; }
.upload-intro p { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
#pagesWrap:not(:empty) { margin-bottom: 24px; }
.profileWrap .profilePage { padding: 0; }
.profileWrap .profileSubtitle { color: var(--muted); font-size: 14px; }
.profileWrap .profileHeader { margin-bottom: 28px; }
.profileWrap .profileGrid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; }
.profileWrap .profileCard { padding: 25px; border-radius: var(--radius); border-color: var(--line); box-shadow: var(--shadow); }
.profileWrap .cardHeader > div { min-width: 0; overflow-wrap: anywhere; }
.profileWrap .cardTitle { font-size: 16px; }
.profileWrap .cardSubtitle { color: var(--muted); font-size: 12px; }
.profileWrap .cardIcon { background: var(--cofer-sand); color: var(--navy); }
.profileWrap .profileTag { background: var(--surface-soft); border-color: var(--line); color: var(--ink); }
.profileWrap .addWrap button { background: var(--brand-gradient); color: var(--navy); min-height: 46px; border: 1px solid var(--cofer-orange); }
.profileWrap .addWrap button:hover { background: var(--brand-gradient-hover); }
.profileWrap .submitButton { margin-top: 26px; min-width: 185px; }
.profile-empty { font-size: 12px; color: var(--muted); padding: 6px 0; }
.lightbox { z-index: 5000; background: #061c3d80; backdrop-filter: blur(5px); }
.lightbox.is-open { display: block; }
.lightbox .lightboxContent { min-width: 0; width: min(90vw,680px); max-width: 90vw; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 100px #0a2b5b26; overflow-y: auto; overscroll-behavior: contain; }
.lightboxContent > img { max-height: 120px; margin-top: 20px; }
.modal-scroll { scroll-padding-top: calc(var(--modal-header-height, 72px) + 12px); }
dialog.modal-scroll { padding: 0; }
.modal-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px var(--modal-padding-x, 26px); border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.modal-header h2 { min-width: 0; margin: 0; font-size: 21px; line-height: 1.35; overflow-wrap: anywhere; }
.modal-body { padding: 20px var(--modal-padding-x, 26px) 26px; }
.modal-close { box-sizing: border-box; display: inline-flex; flex: 0 0 36px; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); color: var(--muted); transition: background .15s, color .15s; }
.modal-close:hover { background: #e9eff3; color: var(--ink); }
.modal-close:disabled { cursor: wait; opacity: .65; }
.modal-close .ui-icon { width: 20px; height: 20px; }
.document-save-header h2 { flex: 1; }
.document-save-dialog[data-state="success"] .document-save-header { text-align: left; }
@media (max-width: 520px) {
  .modal-scroll { --modal-padding-x: 14px; }
  .modal-header { gap: 10px; padding-top: 14px; padding-bottom: 14px; }
  .modal-header h2 { font-size: 18px; }
  .modal-body { padding-top: 18px; padding-bottom: 20px; }
}
#document-view-lightbox .imageWrap { padding: 18px; }
#document-view-lightbox .image { border-radius: 6px; }
.loading-content { width: 240px !important; padding: 30px; text-align: center; }
.loading-content .loading-logo { display: block; width: 56px; height: 56px; margin: 0 auto 18px; }
.loading-content p { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.loading-spinner { display: block; margin: auto; width: 28px; height: 28px; border: 2px solid #dce6e2; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skip-link { position: fixed; left: 15px; top: -70px; z-index: 6000; background: white; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.skip-link:focus { top: 15px; }
/* Login */
.auth-layout { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-story { background: var(--navy); color: #fff; padding: 42px 60px 30px; display: flex; flex-direction: column; overflow: hidden; }
.auth-story .brand-logo { width: 208px; }
.auth-story-content { max-width: 480px; margin: auto; padding-top: 56px; width: 100%; }
.auth-story h1 { font-size: clamp(38px,4vw,58px); font-weight: 550; line-height: 1.13; letter-spacing: -2px; }
.auth-story h1 > span { color: rgba(254,168,0,1); }
.auth-story-content > p { max-width: 360px; color: #b0c0cb; font-size: 14px; line-height: 1.9; }
.auth-story-footer { font-size: 9px; letter-spacing: 1.9px; color: #8ca6b4; margin-top: 30px; }
.archive-illustration { position: relative; height: 245px; width: 290px; margin: 38px auto 0; }
.archive-sheet { position: absolute; width: 168px; height: 208px; border: 1px solid #ffffff28; border-radius: 12px; }
.sheet-back { background: var(--accent); transform: rotate(-12deg); top: 4px; left: 33px; }
.sheet-front { background: #f5f7f5; transform: rotate(7deg); left: 76px; padding: 22px; color: #416b63; }
.sheet-symbol .ui-icon { width: 29px; height: 29px; margin-bottom: 20px; }
.sheet-line { display: block; height: 5px; width: 100%; background: #d1dcd7; border-radius: 3px; margin: 9px 0; }
.sheet-line.short { width: 65%; }
.sheet-divider { height: 1px; background: #e0e7e3; margin: 18px 0; }
.sheet-check { display: flex; position: absolute; bottom: -10px; right: -12px; padding: 10px; background: #73a58f; border: 5px solid var(--navy); border-radius: 50%; color: white; }
.archive-caption { position: absolute; bottom: 4px; left: 0; display: flex; gap: 10px; align-items: center; font-size: 11px; background: #203c4d; border: 1px solid #ffffff17; border-radius: 8px; padding: 14px 20px; box-shadow: 0 12px 24px #00000012; }
.archive-caption .ui-icon { width: 17px; height: 17px; color: #96bfb2; }
.auth-form-section { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 70px 48px 32px; background: #fbfcfc; }
.auth-form-wrap { width: 100%; max-width: 370px; margin: auto; }
.auth-form-wrap h2 { font-size: 29px; letter-spacing: -1px; margin-bottom: 12px; }
.auth-intro { color: var(--muted); font-size: 13px; margin-bottom: 36px; }
.auth-form-wrap label { display: block; font-size: 12px; font-weight: 600; margin: 22px 0 9px; }
.password-field { position: relative; }
.password-field input { padding-right: 80px !important; }
.password-field button { position: absolute; right: 5px; top: 5px; min-height: 40px; padding: 0 12px; background: transparent; color: #637983; font-size: 11px; border: 0; border-radius: 5px; }
#login-submit { width: 100%; justify-content: space-between; margin-top: 28px; min-height: 50px; }
#login-submit:disabled { opacity: .6; cursor: wait; }
.auth-note { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); padding-top: 26px; margin-top: 32px; color: #748c85; }
.auth-note p { margin: 0; font-size: 11px; line-height: 1.8; color: var(--muted); }
.registration-note { color: var(--muted); font-size: 11px; text-align: center; line-height: 1.8; margin: 30px 0 0; }
.auth-copyright { font-size: 10px; color: #84929c; margin-top: 50px; }
.form-error { background: #fff1f0; color: #a33d38; padding: 12px; border: 1px solid #f2d5d1; border-radius: 8px; font-size: 12px; margin: 18px 0 0; }
@media (min-width: 1500px) { .auth-story { padding-left: 100px; padding-right: 100px; } }
@media (max-width: 1150px) {
  .sidebar { width: 218px; }
  .workspace-bar, .authenticated #main-content { margin-left: 218px; }
  .appPages { padding: 30px 26px; }
  .workspace-bar { padding: 0 26px; }
  .stat-card { padding: 20px 16px; gap: 10px; }
  .stat-icon { padding: 8px; }
  .stat-detail { left: 16px; }
  .dashboard-grid { grid-template-columns: minmax(0,1fr); }
  .guide-card ol { display: flex; flex-wrap: wrap; gap: 12px 24px; }
  .profileWrap .profileGrid { grid-template-columns: minmax(0,1fr); }
  .auth-story { padding: 36px; }
}
@media (max-width: 760px) {
  .sidebar { inset: auto 0 0; width: 100%; padding: 7px 8px max(7px,env(safe-area-inset-bottom)); background: var(--navy-gradient); border-top: 1px solid #ffffff1f; box-shadow: 0 -6px 24px #061c3d18; z-index: 3000; }
  .sidebar > .brand, .nav-caption, .sidebar-note, .sidebar-account { display: none; }
  #app-menu { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 3px; }
  #app-menu .item { flex-direction: column; padding: 8px 2px; gap: 5px; color: var(--muted-on-dark); font-size: 9px; line-height: 1.3; min-width: 0; border: 0; border-radius: 8px; }
  #app-menu .item .ui-icon { width: 21px; height: 21px; }
  #app-menu .item[data-page="add"] { margin-bottom: 0; }
  #app-menu .item.active { background: #ffffff12; color: var(--on-dark); box-shadow: inset 0 2px var(--cofer-gold); }
  #app-menu .item.active .ui-icon { color: var(--cofer-gold); }
  #app-menu .item:not(.active):hover { color: var(--on-dark); background: #ffffff0d; }
  .sidebar :focus-visible { outline-color: var(--cofer-gold); outline-offset: -2px; }
  .workspace-bar, .authenticated #main-content { margin-left: 0; }
  .workspace-bar { padding: 0 22px; height: 70px; }
  .mobile-brand { display: inline-flex; }
  .mobile-brand .brand-logo { width: 132px; }
  .mobile-logout { display: block; color: var(--muted); padding: 7px; }
  .mobile-logout .ui-icon { width: 18px; height: 18px; }
  .workspace-label, .account-label { display: none; }
  .workspace-account { gap: 6px; }
  .appPages { padding: 28px 20px calc(108px + env(safe-area-inset-bottom)); }
  .page-heading { align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
  .page-heading .appPageTitle { font-size: 24px; }
  .page-heading p { font-size: 13px; }
  .page-heading > .button { min-height: 43px; font-size: 12px; }
  .stat-grid { gap: 8px; margin-bottom: 22px; }
  .stat-card { display: block; padding: 14px 11px; }
  .stat-icon { display: inline-flex; padding: 7px; margin-bottom: 10px; }
  .stat-icon .ui-icon { width: 18px; height: 18px; }
  .stat-card > div > span { display: block; font-size: 10px; min-height: 32px; }
  .stat-card strong { font-size: 27px; margin: 6px 0 0; }
  .stat-detail { display: none; }
  .section-heading { padding: 20px; gap: 10px; }
  .section-heading h2 { font-size: 18px; }
  .section-heading .text-button { font-size: 10px; gap: 5px; }
  .recent-list { padding: 5px 18px; }
  .guide-card { padding: 24px; }
  .guide-card ol { display: block; }
  .workspace-footnote { align-items: flex-start; font-size: 10px; text-align: center; }
  .buttonsList .list { grid-template-columns: 1fr; gap: 9px; }
  .buttonsList .listWrap .listItem { padding: 16px; }
  .appPageTitle { font-size: 24px; font-weight: 550; letter-spacing: -.4px; margin-bottom: 8px; }
  .appPageDescription { font-size: 13px; line-height: 1.6; margin-bottom: 22px; }
  .addDocuments .padded { padding: 18px; }
  .upload-intro { padding: 16px; }
  .upload-intro p { font-size: 11px; }
  .addDocuments .scannerActions .button { width: 100%; }
  .profileWrap .profileCard { padding: 20px; }
  .profileWrap .submitButton { width: 100%; }
  .structoryWrap .mainAreas { padding: 12px 8px; gap: 8px; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { padding: 26px; }
  .auth-story-content { padding-top: 35px; max-width: none; }
  .auth-story h1 { font-size: 36px; letter-spacing: -1.4px; }
  .auth-story-content > p { font-size: 12px; margin-bottom: 0; }
  .archive-illustration, .auth-story-footer { display: none; }
  .auth-form-section { padding: 36px 26px 24px; }
  .auth-form-wrap { max-width: 440px; }
  .auth-form-wrap h2 { font-size: 27px; }
  .auth-intro { margin-bottom: 26px; }
  .auth-copyright { margin-top: 35px; }
}
/* Keep login focused and within normal phone/laptop viewports. Content may
   grow naturally for zoom, a software keyboard, or unusually long errors. */
@media (min-width: 761px) and (max-height: 850px) {
  .auth-story { padding-top: 28px; padding-bottom: 24px; }
  .auth-story-content { padding-top: 24px; }
  .auth-story h1 { font-size: clamp(32px, 3.6vw, 48px); }
  .archive-illustration { height: 195px; margin-top: 20px; transform: scale(.8); transform-origin: top center; margin-bottom: -30px; }
  .auth-story-footer { margin-top: 16px; }
  .auth-form-section { padding: 28px 36px 20px; }
  .auth-intro { margin-bottom: 22px; }
  .auth-note { margin-top: 22px; padding-top: 18px; }
  .registration-note { margin-top: 18px; }
  .auth-copyright { margin-top: 24px; }
}
@media (min-width: 761px) and (max-height: 650px) {
  .archive-illustration, .auth-note { display: none; }
  .auth-story-content { padding-top: 16px; }
  .auth-form-wrap label { margin-top: 14px; }
  .auth-copyright { margin-top: 16px; }
}
@media (max-width: 760px) {
  .public-page { background: var(--navy); }
  .auth-layout { background: var(--navy); grid-template-rows: auto 1fr; padding-bottom: env(safe-area-inset-bottom); }
  .auth-story { padding: max(22px, env(safe-area-inset-top)) 26px 22px; align-items: center; }
  .auth-story-content { display: none; }
  .auth-story .brand-logo { width: 164px; }
  .auth-form-section { align-self: center; margin: 0 20px 24px; padding: 30px 26px 20px; border: 1px solid #ffffff12; border-radius: 20px; box-shadow: 0 20px 60px #09192326; }
  .auth-form-wrap { max-width: 370px; }
  .auth-form-wrap h2 { font-size: clamp(23px, 6vw, 29px); }
  .auth-intro { margin-bottom: 24px; }
  .auth-note { display: none; }
  .registration-note { margin-top: 22px; font-size: 10px; }
  .auth-copyright { margin-top: 20px; font-size: 9px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .auth-story { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: 14px; }
  .auth-form-section { padding: 22px 20px 18px; margin: 0 16px 16px; border-radius: 16px; }
  .auth-form-wrap h2 { margin-bottom: 8px; }
  .auth-intro { margin-bottom: 16px; font-size: 12px; }
  .auth-form-wrap label { margin: 14px 0 6px; }
  #login-submit { min-height: 46px; margin-top: 20px; }
  .registration-note { margin-top: 16px; }
  .auth-copyright { display: none; }
  .auth-form-wrap .form-error { padding: 8px 10px; margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }

/* Documents can be scanned pages, uploaded files, saved links, or text notes. */
[hidden] { display: none !important; }
.source-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 24px; }
.source-option { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 18px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; text-align: left; }
.source-option strong { font-size: 14px; }
.source-option span { font-size: 11px; color: var(--muted); }
.source-option.active { border-color: var(--accent); background: var(--warm-gradient); box-shadow: 0 0 0 1px var(--accent); }
.source-option .ui-icon { color: var(--accent); }
.source-panel { margin-bottom: 20px; }
.source-hint { display: block; color: var(--muted); font-size: 12px; line-height: 1.7; margin: 12px 0; }
#add-url { margin-top: 8px; }
#add-note-text { min-height: 170px; margin-top: 8px; line-height: 1.7; }
.addDocuments .scannerActions { flex-wrap: wrap; gap: 10px; }
.attachment-name, .saved-url { overflow-wrap: anywhere; }
.attachment-name { display: block; font-size: 12px; }
.attachment-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.remove-attachment { color: #a44842; }
.file-format { display: flex; align-items: center; justify-content: center; min-height: 120px; background: var(--warm-gradient); color: var(--navy); font-weight: 700; letter-spacing: 1px; }
.lightbox .document-view-content { width: min(94vw,1000px); max-width: 94vw; max-height: 90dvh; overflow-y: auto; }
.viewer-header { display: grid; grid-template-columns: minmax(0,1fr) auto 36px; grid-template-areas: "title actions close"; align-items: start; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.viewer-header h2 { grid-area: title; align-self: center; overflow-wrap: anywhere; min-width: 0; margin: 0; font-size: 20px; }
.viewer-header h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.viewer-actions { grid-area: actions; display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.viewer-actions:not(:has(> button:not([hidden]))) { display: none; }
.viewer-header:not(:has(.viewer-action:not([hidden]))) { grid-template-columns: minmax(0,1fr) 36px; grid-template-areas: "title close"; }
.viewer-actions .viewer-action { box-sizing: border-box; min-height: 36px; padding: 7px 11px; gap: 6px; font-size: 13px; line-height: 20px; border-radius: 8px; }
.viewer-action .ui-icon { width: 17px; height: 17px; }
.viewer-close { grid-area: close; }
.document-form-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.document-form-heading .appPageTitle { margin-bottom: 0; }
.existing-document-content { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.existing-document-content h2 { font-size: 16px; }
.existing-document-content ul { margin: 12px 0 0; padding-left: 20px; }
.existing-document-content li { overflow-wrap: anywhere; margin-top: 6px; font-size: 13px; }
.document-view-content > .images { padding: 22px; }
.viewer-attachment + .viewer-attachment { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px; }
.viewer-attachment h3 { overflow-wrap: anywhere; margin-bottom: 12px; }
.viewer-attachment .image { margin-top: 18px; }
.pdf-preview { display: block; width: 100%; height: 65vh; border: 1px solid var(--line); border-radius: 8px; margin-top: 12px; background: var(--surface-soft); }
.document-note { white-space: pre-wrap; overflow-wrap: anywhere; border-top: 1px solid var(--line); margin: 22px 0 0; padding-top: 18px; }
@media(max-width:760px) {
  .source-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .viewer-header { grid-template-columns: minmax(0,1fr) 36px; grid-template-areas: "title close" "actions actions"; }
}
@media(max-width:520px) {
  .source-options { gap: 8px; }
  .source-option { padding: 12px 8px; }
  .source-option strong { font-size: 12px; }
  .source-option span { font-size: 10px; }
  .viewer-header, .document-view-content > .images { padding: 16px; }
  .viewer-header h2 { font-size: 16px; }
  .viewer-actions .viewer-action { padding: 7px; gap: 5px; font-size: 12px; }
  .viewer-action .ui-icon { width: 16px; height: 16px; }
}

.profileField + .profileField { margin-top: 18px; }
.profileField label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.profileField p { font-size: 11px; color: var(--muted); margin: 8px 0 0; }

/* Two-level taxonomy: solid area accents, configurable translucent topic tiles. */
.classification-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.classification-section h2 { font-size: 18px; letter-spacing: -.3px; }
.document-form-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.document-form-tools .button { min-width: 0; padding: 12px; }
.document-form-tools .button span { min-width: 0; overflow-wrap: anywhere; }
.document-options-dialog { box-sizing: border-box; color: var(--ink); background: var(--surface); position: fixed; inset: var(--app-safe-top, 0px) 0 env(safe-area-inset-bottom, 0px); width: min(720px, calc(100% - 32px)); max-width: 100%; max-height: calc(100dvh - var(--app-safe-top, 0px) - env(safe-area-inset-bottom, 0px) - 32px); margin: auto; padding: 26px; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 80px #0a2b5b26; overflow-y: auto; overscroll-behavior: contain; text-align: left; }
.document-options-dialog::backdrop { background: #061c3d80; }
.document-options-dialog *, .document-options-dialog *::before, .document-options-dialog *::after { box-sizing: border-box; }
#document-options-description { margin: 0 0 20px; }
.document-options-footer { display: flex; justify-content: flex-end; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.document-options-dialog .classification-section { border: 0; margin-top: 20px; padding-top: 0; }
.document-options-dialog :is(input, select, textarea, button, h2, .form-error) { scroll-margin-top: 16px; }
@media (max-width: 520px) {
  .document-options-dialog { width: calc(100% - 16px); padding: 18px 14px; border-radius: 14px; }
  .document-options-footer .button { width: 100%; }
  .document-form-tools .button { font-size: 12px; gap: 6px; padding: 12px 8px; }
  .document-form-tools .ui-icon { width: 18px; }
}
.taxonomy-heading { margin: 0 0 12px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.taxonomy-columns { display: grid; grid-template-columns: minmax(0,1fr); gap: 20px; align-items: start; }
.taxonomy-picker.has-area > .taxonomy-columns { grid-template-columns: minmax(150px,.36fr) minmax(0,1fr); }
.taxonomy-areas, .taxonomy-main, .taxonomy-topics { min-width: 0; }
.taxonomy-areas { padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; }
/* Show every area/topic in the page flow; the page owns scrolling. */
.taxonomy-list { display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.taxonomy-entry { display: flex; align-items: center; gap: 12px; min-height: 64px; flex-shrink: 0; min-width: 0; width: 100%; padding: 10px 12px; text-align: left; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink); }
.taxonomy-entry:hover { background: rgba(var(--area-rgb),.07); }
.taxonomy-entry.selected { border-color: rgba(var(--area-rgb),.45); background: rgba(var(--area-rgb),.12); box-shadow: inset 3px 0 var(--area-color); }
.taxonomy-entry:focus-visible { outline: 2px solid var(--area-color); outline-offset: 1px; }
.taxonomy-entry-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; background: rgba(var(--area-rgb),.12); }
.taxonomy-symbol { width: 23px; height: 23px; display: block; background: var(--area-color); mask-repeat: no-repeat; mask-position: center; mask-size: contain; -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain; }
.taxonomy-entry-text { flex: 1; min-width: 0; }
.taxonomy-entry strong { display: block; font-size: 13px; line-height: 1.45; font-weight: 600; overflow-wrap: anywhere; }
.taxonomy-entry-note { display: block; font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 3px; overflow-wrap: anywhere; }
.taxonomy-entry-arrow { color: var(--area-color); font-size: 22px; line-height: 1; flex-shrink: 0; }
.taxonomy-topic-list .taxonomy-entry { background: rgba(var(--area-rgb),var(--topic-opacity)); border-color: rgba(var(--area-rgb),.18); }
.taxonomy-topic-list .taxonomy-entry.selected { border-color: var(--area-color); }
.taxonomy-topic-list .taxonomy-entry-icon { background: transparent; }
.taxonomy-topic-list .taxonomy-entry-note { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.taxonomy-overview, .taxonomy-all-topics { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-size: 12px; font-weight: 500; margin-bottom: 12px; }
.taxonomy-overview::before { content: '←'; margin-right: 8px; }
.taxonomy-all-topics { margin-right: 8px; }
.taxonomy-all-topics[aria-pressed="true"] { color: var(--link); border-color: var(--warm-border); background: var(--cofer-sand); }
.taxonomy-choice { margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid var(--area-color); border-radius: 4px; background: rgba(var(--area-rgb),.07); font-size: 12px; overflow-wrap: anywhere; }
.taxonomy-empty { text-align: center; padding: 24px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 13px; }
.classification-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; margin-top: 18px; }
.classification-field { min-width: 0; }
.classification-multiple { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.classification-multiple legend { padding: 0; font-size: 12px; font-weight: 600; }
.tag-choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.classification-field .tag-choice { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); cursor: pointer; }
.tag-choice span { overflow-wrap: anywhere; }
.classification-field .tag-choice input { appearance: auto; width: 17px; height: 17px; min-width: 17px; padding: 0; margin: 0; accent-color: var(--navy); }
.classification-field .tag-choice:has(input:checked) { background: var(--cofer-sand); border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
.tag-custom-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.tag-custom-row input { flex: 1; min-width: 0; margin-top: 0; }
.tag-custom-row button { flex-shrink: 0; min-height: 48px; }
.document-saved-actions { padding: 18px; margin-bottom: 20px; border: 1px solid #bfd8ce; border-radius: 12px; background: #f1f8f4; }
.document-saved-actions h3 { margin: 0 0 8px; font-size: 18px; }
.document-saved-actions p { margin: 0 0 14px; font-size: 13px; line-height: 1.6; }
.saved-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.legacy-reminder-info { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.classification-field label, .filter-field { display: block; font-size: 12px; font-weight: 600; color: var(--ink); }
.classification-field select, .classification-field input, .filter-field select { margin-top: 8px; }
.document-extra-fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,220px),1fr)); gap: 0 18px; }
.document-extra-fields .inputTitle { display: block; }
.archive-taxonomy { padding: 0; }
.archive-documents-title { font-size: 18px; margin-top: 24px; }
.archive-documents-title, #document-title-field { scroll-margin-top: calc(var(--app-safe-top, 0px) + 16px); }
.archive-toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px 20px; margin: 16px 0; }
.archive-toolbar label { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; }
.archive-toolbar input { display: block; margin-top: 8px; font-weight: 400; }
.archive-toolbar button { flex-shrink: 0; min-height: 44px; }
#document-filter-panel { border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 16px; }
#document-filter-panel summary { cursor: pointer; font-size: 13px; font-weight: 500; }
#document-tag-filters { grid-template-columns: repeat(auto-fit,minmax(min(100%,160px),1fr)); }
.classified-document { --area-color: #687887; --area-rgb: 104,120,135; --topic-opacity: .08; width: 100%; display: flex; align-items: center; text-align: left; gap: 16px; background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--area-color); border-radius: 10px; padding: 18px; margin-bottom: 12px; }
.classified-document:hover { border-color: var(--area-color); }
.document-format { display: inline-flex; justify-content: center; align-items: center; min-width: 44px; height: 44px; border-radius: 8px; background: rgba(var(--area-rgb),var(--topic-opacity)); color: var(--ink); font-size: 9px; font-weight: 600; }
.classified-document-info { flex: 1; min-width: 0; }
.classified-document-info > strong { display: block; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.document-path { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.classified-document-date { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.document-tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.document-tag-chips:empty { display: none; }
.document-tag-chips > span { padding: 3px 8px; background: rgba(var(--area-rgb),.08); border: 1px solid rgba(var(--area-rgb),.15); border-radius: 6px; font-size: 10px; overflow-wrap: anywhere; }
.document-metadata { padding: 16px; margin-bottom: 22px; background: rgba(var(--area-rgb,104,120,135),.06); border: 1px solid var(--line); border-radius: 10px; }
.document-location { margin: 0; font-size: 13px; font-weight: 600; }
.metadata-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin: 16px 0 0; }
.metadata-grid dt { font-size: 11px; color: var(--muted); }
.metadata-grid dd { margin: 4px 0 0; font-size: 13px; overflow-wrap: anywhere; }
@media(max-width:760px) {
  .taxonomy-columns { gap: 12px; }
  .taxonomy-picker.has-area > .taxonomy-columns { grid-template-columns: minmax(100px,.38fr) minmax(0,1fr); }
  .taxonomy-areas { padding: 12px 8px; }
  .taxonomy-entry { gap: 8px; padding: 10px 8px; }
  .taxonomy-entry-icon { width: 32px; height: 32px; }
  .taxonomy-entry strong { font-size: 12px; }
  .taxonomy-entry-note { font-size: 10px; }
  .taxonomy-symbol { width: 20px; height: 20px; }
  .classification-section h2 { font-size: 16px; }
  .classification-fields { gap: 16px; grid-template-columns: 1fr; }
  .archive-toolbar { gap: 12px; }
  .classified-document { gap: 10px; padding: 14px; flex-wrap: wrap; }
  .classified-document-date { flex-basis: 100%; padding-left: 54px; }
  .metadata-grid { grid-template-columns: 1fr; }
}
@media(max-width:520px) {
  .taxonomy-picker.has-area > .taxonomy-columns { grid-template-columns: 88px minmax(0,1fr); gap: 10px; }
  .taxonomy-picker.has-area .taxonomy-areas { padding: 12px 3px; }
  .taxonomy-picker.has-area .taxonomy-areas .taxonomy-heading { text-align: center; font-size: 12px; }
  .taxonomy-picker.has-area .taxonomy-area-list .taxonomy-entry { flex-direction: column; gap: 6px; padding: 10px 3px; text-align: center; }
  .taxonomy-picker.has-area .taxonomy-area-list .taxonomy-entry strong { font-size: 10px; }
  .taxonomy-picker.has-area .taxonomy-area-list .taxonomy-entry-note, .taxonomy-picker.has-area .taxonomy-area-list .taxonomy-entry-arrow { display: none; }
  .taxonomy-topic-list .taxonomy-entry-icon { display: none; }
  .taxonomy-topic-list .taxonomy-entry { padding: 10px; }
  .taxonomy-heading { font-size: 13px; }
}

/* Apply the top safe area once, outside every page. Native wrappers can supply
   --native-top-inset in CSS pixels; set it to 0px if the WebView is already inset. */
:root {
  --app-safe-top: var(--native-top-inset, env(safe-area-inset-top, 0px));
}
body { padding-top: var(--app-safe-top); }
.auth-layout {
  min-height: calc(100vh - var(--app-safe-top));
  min-height: calc(100dvh - var(--app-safe-top));
}
@media (min-width: 761px) {
  .sidebar { top: var(--app-safe-top); }
}
/* The page wrapper owns the inset; login only adds its normal visual spacing. */
@media (max-width: 760px) {
  .auth-story { padding-top: 22px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .auth-story { padding-top: 14px; }
}
.lightbox .lightboxContent {
  top: calc(50% + var(--app-safe-top) / 2);
  max-height: min(80%, calc(100dvh - var(--app-safe-top) - 32px));
}
.lightbox .document-view-content {
  max-height: min(90dvh, calc(100dvh - var(--app-safe-top) - 32px));
}
.skip-link:focus { top: calc(15px + var(--app-safe-top)); }

/* Shared controls: explicit sizing also applies inside collapsed details and
   overrides the legacy content-box reset on search inputs. */
:is(.appPages, .auth-form-wrap) :is(input:not([type="hidden"], [type="file"], [type="checkbox"], [type="radio"]), select, textarea) {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: var(--control-height, 48px);
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--surface-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  box-shadow: 0 1px 2px #182d3f04;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
:is(.appPages, .auth-form-wrap) :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:is(.appPages, .auth-form-wrap) :is(input:not([type="checkbox"], [type="radio"]), select, textarea):hover:not(:disabled) { border-color: #b5aa99; }
:is(.appPages, .auth-form-wrap) :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus,
.profileWrap .addWrap input:focus {
  border-color: var(--navy);
  background-color: #fff;
  outline: 2px solid var(--navy);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--focus-halo);
}
:is(.appPages, .auth-form-wrap) :is(input, select, textarea):disabled { background-color: #f0ede7; color: var(--muted); cursor: not-allowed; }
.appPages input:is([type="checkbox"], [type="radio"]):focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
.appPages textarea { resize: vertical; }
.appPages input[type="search"] {
  appearance: none;
  padding-left: 44px;
  background-image: url('/images/searchGrey.svg');
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 18px;
}
.appPages select:not([multiple]) {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23647582' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  text-overflow: ellipsis;
}
.appPages select option { background: #fff; color: var(--ink); }
.appPages input::-webkit-datetime-edit { padding: 0; min-width: 0; }
.appPages input::-webkit-date-and-time-value { min-width: 0; text-align: left; }
.appPages input::-webkit-calendar-picker-indicator { flex-shrink: 0; margin: 0; opacity: .65; }
.appPages :is(.inputWrap, .inputWrapper, .profileCard, .profileField, .filter-field, .document-details-content) { min-width: 0; }
.profileWrap .addWrap { align-items: stretch; gap: 10px; }
.profileWrap .addWrap input:not(:focus) { background-color: var(--surface-soft); border-color: var(--line); }
.profileWrap .addWrap button { height: auto; min-height: 48px; border-radius: 10px; }
.auth-form-wrap { --control-height: 50px; }
@media(max-width:760px) {
  :is(.appPages, .auth-form-wrap) :is(input:not([type="hidden"], [type="file"], [type="checkbox"], [type="radio"]), select, textarea) { font-size: 16px; }
  .document-extra-fields { grid-template-columns: minmax(0,1fr); }
  .archive-toolbar { flex-wrap: wrap; gap: 8px; }
  .archive-toolbar label { flex-basis: 100%; }
  .archive-toolbar > button { margin-left: auto; }
}
@media(max-width:760px) and (max-height:700px) {
  .auth-form-wrap { --control-height: 46px; }
  .auth-form-wrap input:not([type="hidden"]) { padding-top: 10px; padding-bottom: 10px; }
}
@media(max-width:520px) {
  .document-section-heading { font-size: 17px; margin-bottom: 14px; }
}
