@font-face { font-family: Manrope; src: url("/manrope.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/dm-sans.ttf") format("truetype"); font-weight: 100 1000; font-display: swap; }

:root {
    color-scheme: light;
    --ink: #10142f;
    --text: #2e3656;
    --muted: #525d77;
    --faint: #727d96;
    --line: #dee3f0;
    --surface: #fff;
    --canvas: #f5f6f9;
    --navy: #0b102a;
    --periwinkle: #9aa6ff;
    --cyan: #58d4ff;
    --signal: #5768ff;
    --primary: #3948ce;
    --primary-dark: #2936a9;
    --primary-bg: #eef0ff;
    --radius: 16px;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 16px;
    color: var(--ink);
    background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .68; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .brand strong { font-family: Manrope, "DM Sans", system-ui, sans-serif; }
svg { display: block; width: 1.15em; height: 1.15em; flex: 0 0 auto; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: white; border-right: 1px solid #262e52; padding: 26px 17px 17px; display: flex; flex-direction: column; gap: 38px; }
.brand { display: flex; align-items: center; gap: 11px; padding-inline: 8px; width: fit-content; }
.brand strong { display: block; font-size: 21px; letter-spacing: -.045em; line-height: 1.05; }
.brand small, .workspace-label small { color: #a9b4d5; display: block; margin-top: 4px; font-size: .78rem; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-link { display: flex; gap: 11px; align-items: center; color: #bdc8e5; padding: 12px 13px; font-size: .9rem; font-weight: 650; border-radius: 9px; }
.nav-link:hover, .nav-link[aria-current="page"] { background: #242e55; color: white; }
.nav-link[aria-current="page"] svg { color: var(--cyan); }
.nav-link > span { flex: 1; }
.nav-count { font-size: .73rem; padding: 2px 6px; border-radius: 6px; color: var(--periwinkle); background: #303a64; font-weight: 700; }
.workspace-label { margin-top: auto; border-top: 1px solid #303953; padding: 17px 5px 3px; display: flex; align-items: center; gap: 10px; }
.workspace-label strong { display: block; font-size: .84rem; font-weight: 650; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #262f55; color: var(--periwinkle); font-size: .89rem; font-weight: 750; }

.topbar { position: sticky; z-index: 2; top: 0; height: 75px; padding: 0 36px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-actions { display: flex; gap: 8px; }
.button.danger { color: #9c2437; margin-right: auto; }
.breadcrumb { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: .9rem; }
.breadcrumb strong { color: var(--ink); }
.crumb-divider { color: #a8a1b5; }
.button { border: 1px solid var(--line); border-radius: 8px; padding: 9px 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; background: var(--surface); font-size: .88rem; font-weight: 650; white-space: nowrap; }
.button:hover { border-color: #c9bddf; background: #fbfaff; }
.primary { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 4px #6841e125; }
.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.quiet { color: var(--primary-dark); border-color: transparent; background: transparent; box-shadow: none; }
.button.quiet:hover { background: var(--primary-bg); }
.button.icon-only { width: 39px; padding: 0; }
.page { padding: 36px; max-width: 1530px; margin-inline: auto; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 24px; }
.page-header h1 { font-size: clamp(2rem, 3.1vw, 2.7rem); letter-spacing: -.065em; line-height: 1.1; }
.page-header p { color: var(--muted); margin-top: 8px; line-height: 1.55; }
.overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); display: flex; min-height: 98px; align-items: center; gap: 15px; padding: 17px; text-align: left; }
.metric:hover, .folder-card:hover, .rule-card:hover { border-color: #c8b8f4; }
.metric strong { font-size: 1.7rem; line-height: 1; letter-spacing: -.05em; display: block; }
.metric small { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: 5px; }
.tone { color: var(--tone); background: var(--tint); }
.purple { --tone: #3442aa; --tint: #eef0ff; }
.blue { --tone: #1a5a85; --tint: #e1f6ff; }
.green { --tone: #197653; --tint: #e4f6ed; }
.amber { --tone: #8b510a; --tint: #fff1da; }
.pink { --tone: #aa3e77; --tint: #fde9f5; }
.square { width: 43px; height: 43px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; }
.square.small { width: 34px; height: 34px; border-radius: 9px; }
.columns { display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(255px, 1fr); gap: 20px; align-items: start; }
.panel { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 17px 19px; }
.panel-heading h2 { font-size: 1.12rem; letter-spacing: -.03em; }
.tabs { display: flex; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 5px 1px 10px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: .85rem; font-weight: 650; white-space: nowrap; }
.tab[aria-pressed="true"] { border-bottom-color: var(--primary); color: var(--primary-dark); }
.mail-table { padding: 0 8px; }
.mail-row { width: 100%; display: grid; grid-template-columns: 53px minmax(0, 1fr) auto 52px 18px; gap: 11px; align-items: center; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 10px; min-height: 77px; }
.mail-row:last-child { border-bottom: 0; }
.mail-row:hover { background: #faf8ff; border-radius: 8px; }
.mail-row > svg { color: var(--faint); }
.mail-title strong { display: block; font-size: .9rem; line-height: 1.35; overflow-wrap: anywhere; }
.mail-title small { display: block; color: var(--muted); font-size: .81rem; line-height: 1.4; margin-top: 3px; }
.day { color: var(--muted); font-size: .79rem; text-align: right; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 6px; padding: 4px 8px; font-size: .74rem; font-weight: 700; white-space: nowrap; max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
.thumb, .sample-paper { position: relative; width: 53px; height: 46px; border-radius: 7px; background: var(--tint); overflow: hidden; display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.envelope { position: relative; width: 72%; height: 62%; background: #fffdfa; border: 1px solid #fff; border-radius: 2px; box-shadow: 0 2px 5px #2917352d; transform: rotate(-7deg); }
.envelope::before { position: absolute; content: ""; width: 19%; height: 30%; border: 1px solid #7353b566; background: #bdabd766; top: 13%; right: 8%; }
.envelope::after { position: absolute; content: ""; height: 23%; width: 47%; top: 46%; left: 27%; background: repeating-linear-gradient(to bottom,#7f7195 0 12%, transparent 12% 40%); opacity: .61; }
.sample-paper.blue .envelope { transform: rotate(8deg); }
.sample-paper.green .envelope { transform: rotate(-2deg); }
.sample-paper.large { height: min(44vh, 280px); width: 100%; border-radius: 11px; }
.panel-rules { padding: 0 13px 8px; }
.panel-rules .panel-heading { padding-inline: 6px; }
.rule-mini { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; align-items: center; text-align: left; gap: 10px; padding: 12px 5px; }
.rule-mini:last-child { border-bottom: 0; }
.rule-mini:hover { background: #faf8ff; border-radius: 8px; }
.rule-mini strong { display: block; font-size: .85rem; }
.rule-mini small { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }
.rule-mini > svg { color: var(--faint); }
.summary-footer { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .79rem; padding: 12px 6px 6px; }
.empty { padding: 33px 20px; text-align: center; color: var(--muted); line-height: 1.6; }
.empty .button { margin-top: 12px; }
.grid-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 255px), 1fr)); gap: 16px; }
.folder-card, .rule-card { text-align: left; padding: 17px; }
.folder-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: center; }
.folder-card > [data-open-folder] { grid-column: 2 / -1; justify-self: start; }
.folder-card h2, .rule-card h2 { font-size: 1.02rem; letter-spacing: -.02em; overflow-wrap: anywhere; }
.folder-card p, .rule-card p { color: var(--muted); font-size: .88rem; line-height: 1.5; margin-top: 5px; overflow-wrap: anywhere; }
.rule-card { display: grid; gap: 12px; align-content: start; }
.rule-card header { display: flex; align-items: center; gap: 10px; }
.rule-card .badge { width: fit-content; }
.action-list { padding-inline: 16px; }
.action-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 11px; padding-block: 13px; border-bottom: 1px solid var(--line); }
.action-row:last-child { border-bottom: 0; }
.action-row small { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; }
.info-strip { background: var(--primary-bg); color: #323c77; border-radius: 9px; padding: 13px 15px; margin-top: 15px; font-size: .88rem; line-height: 1.55; }
.startup { width: min(100% - 36px, 380px); margin: 14vh auto 0; text-align: center; }
.startup h1 { margin-top: 8px; }
.startup p { color: var(--muted); margin: 9px 0 12px; }
.startup label { text-align: left; }
.startup button { margin-top: 13px; }

dialog { position: fixed; width: min(calc(100% - 30px), 590px); max-height: calc(100dvh - 30px); border: 1px solid var(--line); padding: 0; color: var(--ink); border-radius: 16px; box-shadow: 0 22px 80px #20173b44; }
dialog::backdrop { background: #21193280; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; background: var(--surface); padding: 19px 21px; position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 1.26rem; letter-spacing: -.03em; }
.dialog-head p { color: var(--muted); font-size: .88rem; line-height: 1.45; margin-top: 4px; }
.dialog-body { padding: 18px 21px 21px; }
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.form-grid { display: grid; gap: 12px; }
.form-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 5px; font-size: .87rem; font-weight: 650; }
label span.help { font-weight: 400; color: var(--muted); font-size: .79rem; line-height: 1.45; }
input, select, textarea { width: 100%; border: 1px solid #dcd7e7; color: var(--ink); border-radius: 7px; padding: 9px 10px; background: white; line-height: 1.4; }
select { appearance: none; background: linear-gradient(45deg,transparent 50%,var(--muted) 50%) right 14px center / 5px 5px no-repeat, linear-gradient(135deg,var(--muted) 50%,transparent 50%) right 9px center / 5px 5px no-repeat, white; padding-right: 26px; }
textarea { resize: vertical; min-height: 76px; }
.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; }
.check input { width: 15px; height: 15px; margin: 3px 0; accent-color: var(--primary); flex: 0 0 auto; }
.form-error { color: #a12740; font-size: .85rem; line-height: 1.5; }
.search-form { display: flex; align-items: center; gap: 8px; padding: 0 18px 13px; }
.search-form label { flex: 1; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.page-selector { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.page-selector [aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-dark); }
.batch-letters { list-style: none; padding: 0; margin-top: 8px; }
.batch-letters > li { padding: 8px 0; }
.batch-progress { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.batch-progress span { color: var(--muted); font-size: .81rem; }
.batch-progress .grouping-warning { display: block; margin-top: 3px; color: #865316; font-weight: 650; }
.batch-letters strong { display: block; overflow-wrap: anywhere; }
.batch-letters > li + li { border-top: 1px solid var(--line); }
.batch-letters .button { min-height: 44px; }
.group-join { margin-top: 4px; }
.integration-panel { padding: 20px; margin-bottom: 16px; }
.integration-panel h2 { font-size: 1.1rem; }
.integration-panel p { margin: 8px 0 12px; color: var(--muted); }
.integration-routes dt { margin-top: 12px; overflow-wrap: anywhere; }
.integration-routes dd { margin: 3px 0 0; color: var(--muted); font-size: .88rem; }
.delivery-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.delivery-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.delivery-row small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.delivery-list { margin-bottom: 13px; }
.scan-dialog { width: min(100% - 28px, 610px); }
.scan-guidance { margin-bottom: 8px; }
.scan-dialog .button { min-height: 44px; }
.scan-dialog .dialog-head .icon-only { width: 44px; }
.camera-stage { position: relative; display: grid; place-items: center; height: clamp(180px, 47svh, 390px); overflow: hidden; isolation: isolate; border-radius: 12px; background: var(--navy); color: #fff; }
.camera-stage video, .camera-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.camera-overlay { pointer-events: none; }
.camera-overlay path, .camera-overlay polygon { stroke-width: 2.5px; stroke-linecap: round; }
.camera-overlay path { fill: none; stroke: #fff; filter: drop-shadow(0 0 2px var(--navy)); }
.camera-overlay polygon { fill: #58d4ff1a; stroke: var(--cyan); filter: drop-shadow(0 0 1.5px var(--navy)); }
.camera-placeholder { position: relative; display: grid; justify-items: center; gap: 14px; max-width: 27ch; padding: 12px; text-align: center; font-size: .9rem; line-height: 1.45; }
.camera-placeholder svg { width: 38px; height: 38px; color: var(--periwinkle); }
.camera-caption { position: absolute; inset: auto 9px 9px; display: flex; flex-wrap: wrap; gap: 5px; justify-content: space-between; pointer-events: none; }
.camera-caption span { border-radius: 6px; padding: 4px 7px; background: #0b102aeb; color: #fff; font-size: .75rem; }
.capture-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.capture-shutter { grid-column: 1 / -1; min-height: 54px !important; font-size: 1rem; }
.capture-secondary { min-width: 0; white-space: normal; }
.capture-secondary:last-child:nth-child(2) { grid-column: 1 / -1; }
.camera-retry { margin-top: 4px; }
.scan-pages-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 12px; font-size: .87rem; }
.scan-pages-heading span { color: var(--muted); font-size: .78rem; }
.scan-thumbnails { display: flex; gap: 7px; padding: 5px 3px; margin: 4px 0 0; overflow-x: auto; list-style: none; }
.scan-thumbnails button { display: grid; justify-items: center; gap: 3px; width: 67px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); font-size: .73rem; }
.scan-thumbnails img { width: 54px; height: 40px; object-fit: contain; border-radius: 4px; background: var(--primary-bg); }
.scan-session-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.scan-session-actions button { flex: 1 0 auto; }
.crop-frame { position: relative; margin: 10px auto 15px; touch-action: none; max-width: 100%; }
.crop-frame canvas { display: block; width: 100%; border-radius: 6px; }
.frame-outline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.corner { position: absolute; width: 44px; height: 44px; margin: -22px; border-radius: 100%; border: 0; background: transparent; cursor: grab; touch-action: none; }
.corner::after { content: ""; position: absolute; inset: 15px; background: #fff; border: 3px solid var(--signal); border-radius: 50%; box-shadow: 0 0 0 2px #fff5; }
.corner:active { cursor: grabbing; }
.photo-preview { display: grid; place-items: center; background: #f1edf9; border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.photo-preview img { display: block; max-width: 100%; max-height: 290px; object-fit: contain; }
.photo-preview.square-view { width: min(100%, 290px); aspect-ratio: 1; margin-inline: auto; }
.photo-preview.square-view img { width: 100%; height: 100%; }
.scan-note, .mail-text { font-size: .87rem; line-height: 1.5; color: var(--muted); }
.mail-text { max-height: 145px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.file-source { display: none; }
.toast { position: fixed; z-index: 4; bottom: 22px; right: 22px; max-width: calc(100% - 44px); padding: 12px 16px; border-radius: 9px; color: white; background: #241a3f; box-shadow: 0 5px 24px #241a3f38; font-size: .88rem; }

@media (min-width: 1350px) {
    .shell { grid-template-columns: 240px minmax(0, 1fr); }
    .page { padding: 42px 44px; }
    .topbar { padding-inline: 44px; }
}

@media (max-width: 1050px) {
    .columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .scan-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
    .scan-dialog .dialog-head { padding: 10px 13px; align-items: center; }
    .scan-dialog .dialog-body { padding: 10px 13px 14px; }
    .camera-stage { height: clamp(162px, 41svh, 340px); }
    .camera-stage.has-pages { height: clamp(140px, calc(100svh - 423px), 340px); }
    .shell { display: block; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
    .sidebar { position: fixed; top: auto; z-index: 3; bottom: 0; inset-inline: 0; height: auto; padding: 5px 7px calc(5px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
    .sidebar .brand, .workspace-label { display: none; }
    .nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
    .nav-link { min-height: 51px; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 2px; font-size: .7rem; }
    .nav-link > span { flex: initial; }
    .nav-count { display: none; }
    .topbar { height: 62px; padding-inline: 17px; }
    .breadcrumb::before { content: ""; background: url("/corevar-symbol-light.svg") center / contain; width: 27px; height: 27px; }
    .desktop-crumb, .crumb-divider { display: none; }
    .page { padding: 22px 15px; }
    .page-header { margin-bottom: 17px; }
    .overview { gap: 7px; margin-bottom: 15px; }
    .metric { min-height: 90px; gap: 7px; padding: 9px; align-items: flex-start; flex-direction: column; }
    .metric .square { width: 28px; height: 28px; border-radius: 6px; font-size: .78rem; }
    .metric strong { font-size: 1.28rem; display: inline; }
    .metric small { font-size: .73rem; line-height: 1.2; margin-top: 2px; }
    .panel-heading { padding: 12px 13px; }
    .mail-row { grid-template-columns: 41px minmax(0, 1fr) auto 13px; gap: 7px; padding: 9px 4px; min-height: 68px; }
    .thumb, .sample-paper { width: 41px; height: 40px; }
    .mail-row .day { display: none; }
    .mail-row .badge { max-width: 91px; }
    .action-row { grid-template-columns: auto minmax(0, 1fr) auto; }
    .action-row .button { grid-column: 2 / -1; justify-self: start; }
    .toast { bottom: calc(71px + env(safe-area-inset-bottom)); }
    input, select, textarea { font-size: 1rem; }
}

@media (max-width: 380px) {
    .form-pair { grid-template-columns: 1fr; }
    .page-header { align-items: flex-start; flex-direction: column; }
}
