:root {
    --bg: #f3f4f8;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e6e8ef;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --danger: #dc2626;
    --warning: #c2410c;
    --success-bg: #ecfdf3;
    --success-text: #047857;
    --warning-bg: #fff4e5;
    --error-bg: #fef2f2;
    --error-text: #b91c1c;
    --info-bg: #eef2ff;
    --info-text: #3730a3;
    --track: #eef0f5;
    --bar: #c7cbf5;
    --radius: 18px;
    --radius-small: 11px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .04);
    --sidebar: 248px;
    --hero-from: #4f46e5;
    --hero-to: #7c3aed;
}

:root,
:root[data-theme="light"] {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b0d12;
    --surface: #141820;
    --surface-2: #10131a;
    --border: #232937;
    --text: #eef1f6;
    --muted: #8b95a8;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #1d2142;
    --warning: #fb923c;
    --success-bg: #0b2a1c;
    --success-text: #6ee7b7;
    --warning-bg: #33200d;
    --error-bg: #351313;
    --error-text: #fca5a5;
    --info-bg: #1b1f3d;
    --info-text: #c7d2fe;
    --track: #1d2230;
    --bar: #353c66;
    --shadow: none;
    --hero-from: #3730a3;
    --hero-to: #6d28d9;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0b0d12;
        --surface: #141820;
        --surface-2: #10131a;
        --border: #232937;
        --text: #eef1f6;
        --muted: #8b95a8;
        --primary: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-soft: #1d2142;
        --warning: #fb923c;
        --success-bg: #0b2a1c;
        --success-text: #6ee7b7;
        --warning-bg: #33200d;
        --error-bg: #351313;
        --error-text: #fca5a5;
        --info-bg: #1b1f3d;
        --info-text: #c7d2fe;
        --track: #1d2230;
        --bar: #353c66;
        --shadow: none;
        --hero-from: #3730a3;
        --hero-to: #6d28d9;
    }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -.025em; display: flex; align-items: center; gap: 4px; }
h2 { font-size: 16px; letter-spacing: -.01em; }
code { font-size: 12.5px; background: var(--track); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success-text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.icon { width: 18px; height: 18px; flex: none; }

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; color: var(--text); letter-spacing: -.01em; padding: 0 8px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: linear-gradient(135deg, var(--hero-from), var(--hero-to)); color: #fff; font-size: 16px; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.brand-large { font-size: 22px; justify-content: center; margin-bottom: 8px; }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; display: block; flex-shrink: 0; object-fit: contain; }
.brand-logo-horizontal { height: 54px; width: auto; max-width: 100%; display: block; object-fit: contain; }

.nav { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--muted); font-weight: 600; transition: background .15s, color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--primary-soft); color: var(--primary); }

.sidebar-upload { width: 100%; }
.sidebar-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.sidebar-user form { margin: 0 0 0 auto; }
.sidebar-user-text { display: grid; min-width: 0; font-size: 13px; line-height: 1.35; }
.sidebar-user-text span, .sidebar-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }

.shell { min-width: 0; }
.main { max-width: 1320px; margin: 0 auto; padding: 32px 32px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }

.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.page-head > div:first-child { display: grid; gap: 6px; }
.page-head p { margin: 0; }
.eyebrow-muted { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 600; color: var(--muted); }
.back:hover { color: var(--text); }
.back .icon { width: 16px; height: 16px; }

.period-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.period-label { display: inline-flex; align-items: center; gap: 8px; min-width: 150px; justify-content: center; height: 38px; padding: 0 14px; border-radius: 11px; background: var(--surface); border: 1px solid var(--border); font-weight: 650; }
.period-label .icon { width: 16px; height: 16px; color: var(--muted); }
.segmented { display: inline-flex; padding: 3px; margin-left: 6px; border-radius: 12px; background: var(--track); }
.segmented a { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 600; }
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; padding: 0; transition: background .15s, border-color .15s; }
.icon-button:hover { background: var(--surface-2); border-color: var(--muted); }
.icon-button .icon { width: 17px; height: 17px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.card-head-pad { padding: 22px 22px 0; }
.card-sub { margin: 3px 0 0; font-size: 13px; }
.card-figure { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.link-more { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; }
.link-more .icon { width: 15px; height: 15px; transition: transform .15s; }
.link-more:hover .icon { transform: translateX(2px); }

.stack { display: grid; gap: 22px; align-content: start; }
.grid, .layout-main { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
.layout-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.grid-receipt { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.kpi { position: relative; display: grid; gap: 2px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; transition: border-color .15s, transform .15s; }
.kpi-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.kpi-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; margin-bottom: 12px; }
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-icon-blue { background: #e0e7ff; color: #4338ca; }
.kpi-icon-violet { background: #f3e8ff; color: #7e22ce; }
.kpi-icon-green { background: #dcfce7; color: #15803d; }
.kpi-icon-amber { background: #ffedd5; color: #c2410c; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 28px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; font-size: 13px; color: var(--muted); }

:root[data-theme="dark"] .kpi-icon-blue { background: #1e2350; color: #a5b4fc; }
:root[data-theme="dark"] .kpi-icon-violet { background: #2e1a47; color: #d8b4fe; }
:root[data-theme="dark"] .kpi-icon-green { background: #0f2e1d; color: #86efac; }
:root[data-theme="dark"] .kpi-icon-amber { background: #3a220e; color: #fdba74; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .kpi-icon-blue { background: #1e2350; color: #a5b4fc; }
    :root:not([data-theme="light"]) .kpi-icon-violet { background: #2e1a47; color: #d8b4fe; }
    :root:not([data-theme="light"]) .kpi-icon-green { background: #0f2e1d; color: #86efac; }
    :root:not([data-theme="light"]) .kpi-icon-amber { background: #3a220e; color: #fdba74; }
}

.trend-chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trend-chip.is-up { background: var(--error-bg); color: var(--error-text); }
.trend-chip.is-down { background: var(--success-bg); color: var(--success-text); }

.chart { position: relative; height: 230px; padding-top: 22px; }
.chart-compact { height: 190px; }
.chart-grid { position: absolute; inset: 22px 0 26px; pointer-events: none; border-bottom: 1px solid var(--border); background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--track) calc(25% - 1px), var(--track) 25%); }
.chart-max { position: absolute; top: -20px; left: 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-overlay { position: absolute; inset: 22px 0 26px; z-index: 2; pointer-events: none; }
.chart-average { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--primary); opacity: .55; }
.chart-average em { position: absolute; right: 0; top: -19px; font-style: normal; font-size: 11px; font-weight: 600; color: var(--primary); background: var(--surface); padding: 0 4px; }
.chart-columns { position: relative; display: flex; align-items: stretch; gap: 6px; height: 100%; }
.chart-compact .chart-columns { gap: 3px; }
.chart-column { position: relative; flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 1fr 26px; color: var(--muted); }
.chart-track { position: relative; min-height: 0; }
.chart-bar { position: absolute; bottom: 0; left: 0; right: 0; margin: 0 auto; max-width: 38px; border-radius: 7px 7px 3px 3px; background: var(--bar); transition: background .15s, transform .15s; transform-origin: bottom; animation: grow .5s ease-out both; }
.chart-compact .chart-bar { border-radius: 4px 4px 2px 2px; }
.chart-column.is-active .chart-bar { background: linear-gradient(180deg, var(--hero-to), var(--hero-from)); }
.chart-column:hover .chart-bar { background: var(--primary); }
.chart-label { align-self: end; justify-self: center; text-align: center; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chart-column.is-active .chart-label { color: var(--primary); }
.chart-compact .chart-column:nth-child(odd):not(.is-active) .chart-label { visibility: hidden; }
.chart-column[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% - 18px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--text);
    color: var(--surface);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}
.chart-column:first-child:hover::after, .chart-column:nth-child(2):hover::after { left: 0; transform: none; }
.chart-column:last-child:hover::after, .chart-column:nth-last-child(2):hover::after { left: auto; right: 0; transform: none; }
.chart-empty { display: grid; place-items: center; min-height: 160px; padding: 20px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border); color: var(--muted); text-align: center; font-size: 14px; }

@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.donut-wrap { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; align-items: center; }
.donut { position: relative; width: 180px; height: 180px; }
.donut svg { width: 100%; height: 100%; transform: rotate(0deg); }
.donut-track { stroke: var(--track); }
.donut-segment { transition: stroke-width .15s; cursor: default; }
.donut-segment:hover { stroke-width: 7; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.25; }
.donut-center strong { font-size: 19px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: 12px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 550; }
a.legend-name:hover { color: var(--primary); }
.legend-share { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.legend-amount { font-variant-numeric: tabular-nums; font-size: 14px; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; font-size: 14px; }
.bar-head a { color: var(--text); }
.bar-head a:hover { color: var(--primary); }
.bar-amount { font-variant-numeric: tabular-nums; }
.bar-track { height: 8px; border-radius: 99px; background: var(--track); margin: 7px 0 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; animation: slide .6s ease-out both; transform-origin: left; }
.bar-meta { font-size: 12.5px; }

@keyframes slide { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.store { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot-large { width: 14px; height: 14px; margin-right: 8px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--track); color: var(--muted); font-size: 12px; }

.upload-card { padding: 0; overflow: hidden; scroll-margin-top: 24px; }
.upload-hero { padding: 22px; color: #fff; background: radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .18), transparent 50%), linear-gradient(135deg, var(--hero-from), var(--hero-to)); }
.upload-hero-head { display: flex; justify-content: space-between; gap: 10px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .85; }
.upload-total { display: block; margin-top: 8px; font-size: 34px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.upload-change { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; opacity: .92; }
.upload-hero .trend-chip { background: rgba(255, 255, 255, .2); color: #fff; }
.month-progress { height: 6px; margin: 16px 0 14px; border-radius: 99px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.month-progress span { display: block; height: 100%; border-radius: 99px; background: #fff; }
.upload-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.upload-facts div { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .13); }
.upload-facts dt { font-size: 11.5px; opacity: .8; }
.upload-facts dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.upload-form { padding: 18px 22px 6px; }
.upload-foot { margin: 10px 0 8px; text-align: center; font-size: 12.5px; }
.upload-mail { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.upload-mail form { margin: 0 0 0 auto; }
.upload-mail-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--track); color: var(--muted); }
.upload-mail-icon .icon { width: 16px; height: 16px; }
.upload-mail > .muted { flex: 1 1 auto; }

.dropzone { position: relative; display: grid; gap: 4px; place-items: center; text-align: center; padding: 24px 16px; margin-bottom: 12px; border: 1.5px dashed var(--border); border-radius: 14px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.dropzone .muted { font-size: 13px; }
.file-queue { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; max-height: 170px; overflow: auto; }
.file-queue li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.file-queue span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.file-list { list-style: none; margin: 0 -22px -22px; padding: 0; }
.file-list li + li { border-top: 1px solid var(--border); }
.file-row { display: flex; align-items: center; gap: 14px; padding: 13px 22px; color: inherit; transition: background .12s; }
.file-row:hover { background: var(--surface-2); }
.file-cell { display: flex; align-items: center; gap: 12px; color: inherit; min-width: 240px; max-width: 360px; }
.file-cell:hover .file-name { color: var(--primary); }
.file-main { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; overflow: hidden; white-space: nowrap; }
.file-meta .dot { width: 8px; height: 8px; }
.file-amount { font-variant-numeric: tabular-nums; min-width: 84px; text-align: right; }
.file-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; }
.file-icon-image { background: #e0f2fe; color: #0369a1; }
.file-icon-pdf { background: #fee2e2; color: #b91c1c; }
.file-icon-document { background: #ede9fe; color: #6d28d9; }

:root[data-theme="dark"] .file-icon-image { background: #0c2a3d; color: #7dd3fc; }
:root[data-theme="dark"] .file-icon-pdf { background: #3b1414; color: #fca5a5; }
:root[data-theme="dark"] .file-icon-document { background: #251a45; color: #c4b5fd; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .file-icon-image { background: #0c2a3d; color: #7dd3fc; }
    :root:not([data-theme="light"]) .file-icon-pdf { background: #3b1414; color: #fca5a5; }
    :root:not([data-theme="light"]) .file-icon-document { background: #251a45; color: #c4b5fd; }
}

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-bg); color: var(--success-text); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-danger { background: var(--error-bg); color: var(--error-text); }
.pill-neutral { background: var(--track); color: var(--muted); }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.rank li { display: flex; align-items: center; gap: 12px; }
.rank-number { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 9px; background: var(--track); color: var(--muted); font-size: 13px; font-weight: 700; }
.rank li:first-child .rank-number { background: var(--primary-soft); color: var(--primary); }
.rank-body { display: grid; flex: 1; min-width: 0; line-height: 1.35; }
.rank-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.rank-meta .dot { width: 8px; height: 8px; }
.rank-amount { font-variant-numeric: tabular-nums; font-size: 14px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.filters select, .search-field input { height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.search-field { position: relative; flex: 1 1 260px; display: flex; align-items: center; }
.search-field .icon { position: absolute; left: 12px; color: var(--muted); width: 17px; height: 17px; }
.search-field input { width: 100%; padding-left: 38px; }
.filters select:focus, .filters input:focus, .field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

.table-wrap { position: relative; overflow-x: auto; }
.card:not(.card-flush) > .table-wrap { margin: 0 -22px -22px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 22px; border-top: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; border-top: 0; background: var(--surface-2); }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.product { white-space: normal !important; min-width: 220px; max-width: 420px; }
.row-actions { display: inline-flex; gap: 6px; }
.row-actions .icon-button { width: 34px; height: 34px; }

.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); font-size: 14px; }
.pager-links { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; }

.empty-state { display: grid; justify-items: center; gap: 6px; padding: 48px 20px; text-align: center; }
.empty-state .empty-icon { width: 40px; height: 40px; color: var(--muted); margin-bottom: 6px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid transparent; font: inherit; font-size: 14px; font-weight: 650; cursor: pointer; color: var(--text); background: transparent; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.button .icon { width: 17px; height: 17px; }
.button-small { height: 34px; padding: 0 12px; font-size: 13px; }
.button-block { width: 100%; }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .28); }
.button-primary:hover { background: var(--primary-hover); }
.button-ghost { border-color: var(--border); background: var(--surface); }
.button-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.button-danger { background: var(--error-bg); color: var(--error-text); }
.button[disabled], .is-disabled { opacity: .45; pointer-events: none; }

:root[data-theme="dark"] .button-primary { color: #0b0d12; box-shadow: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .button-primary { color: #0b0d12; box-shadow: none; }
}

.field { display: grid; gap: 6px; margin-bottom: 16px; font-size: 13.5px; font-weight: 600; }
.field input, .field select { height: 42px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 400; }

.flash-stack { display: grid; gap: 8px; }
.flash { padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 550; }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-info { background: var(--info-bg); color: var(--info-text); }

.empty { color: var(--muted); margin: 0; }
.hint { margin: 0 0 16px; }
.hint-pad { margin: 0; padding: 16px 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions form { margin: 0; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

.inline-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.inline-form select { height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; max-width: 190px; }
.inline-form select.is-empty { border-color: var(--warning); color: var(--warning); }
.source { font-size: 12px; white-space: nowrap; }

.preview { padding: 12px; display: grid; place-items: center; }
.preview img { max-width: 100%; max-height: 80vh; border-radius: 10px; }
.preview iframe { width: 100%; height: 75vh; border: 0; border-radius: 10px; background: #fff; }
.raw summary { cursor: pointer; font-weight: 650; }
.raw pre { white-space: pre-wrap; font-size: 12.5px; max-height: 420px; overflow: auto; margin: 14px 0 0; color: var(--muted); }

.guest { display: block; background: radial-gradient(80% 60% at 50% 0%, var(--primary-soft), var(--bg)); }
.guest-main { min-height: 100vh; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 24px 16px; }
.guest-main .flash-stack { width: 100%; max-width: 400px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card h1 { font-size: 22px; }
.auth-card > .muted { margin: 4px 0 22px; }
.error-card { text-align: center; display: grid; gap: 8px; justify-items: center; }
.error-code { font-size: 44px; font-weight: 800; margin: 0; color: var(--primary); }

@media (max-width: 1180px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .layout-main, .grid { grid-template-columns: minmax(0, 1fr); }
    .layout-main > .stack { display: contents; }
    .layout-main .upload-card { order: -1; }
}

@media (max-width: 900px) {
    .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; align-content: center; gap: 10px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
    .brand span:last-child { display: none; }
    .nav { order: 3; display: flex; width: 100%; overflow-x: auto; gap: 4px; }
    .nav-link { padding: 8px 12px; white-space: nowrap; }
    .sidebar-upload { width: auto; margin-left: auto; }
    .sidebar-upload span { display: none; }
    .sidebar-user { margin: 0; padding: 0; border: 0; }
    .sidebar-user-text { display: none; }
    .main { padding: 22px 16px 40px; gap: 18px; }
    .layout-halves, .grid-receipt { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
    h1 { font-size: 24px; }
    .kpis { gap: 12px; }
    .kpi { padding: 16px; }
    .kpi-value { font-size: 22px; }
    .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
    .legend { width: 100%; }
    .segmented { margin-left: 0; }
    .period-label { min-width: 0; }
    .file-row .pill { display: none; }
    .table th, .table td { padding: 10px 14px; }
    .chart-label { font-size: 10px; }
    .chart-column:nth-child(even):not(.is-active) .chart-label { visibility: hidden; }
}

.pill-info { background: var(--info-bg); color: var(--info-text); }
a.pill:hover { filter: brightness(.96); }
.small { font-size: 12.5px; }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--surface); font-size: 14px; font-weight: 550; box-shadow: 0 10px 30px rgba(15, 23, 42, .25); animation: toast-in .2s ease-out both; }
.toast.is-error { background: var(--danger); color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.inline-form.is-saving select { opacity: .55; }
.inline-form.is-saved .source { color: var(--success-text); }
tr.is-updated { animation: flash-row 1.2s ease-out; }
@keyframes flash-row { from { background: var(--primary-soft); } to { background: transparent; } }

.settings-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-card { display: grid; gap: 4px; }
.settings-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.settings-head .kpi-icon { margin: 0; flex: none; }
.settings-head > div { flex: 1; }
.settings-card .button-primary { justify-self: start; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-row-3 { grid-template-columns: minmax(0, 2fr) minmax(0, .8fr) minmax(0, 1.4fr); }
.hint-box { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; border-radius: 12px; background: var(--info-bg); color: var(--info-text); font-size: 13.5px; }
.hint-box .icon { margin-top: 1px; }
.advanced { margin: 0 0 16px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.advanced summary { cursor: pointer; font-weight: 650; font-size: 14px; }
.advanced[open] summary { margin-bottom: 12px; }
.advanced .field { margin-bottom: 10px; }
.advanced p { margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 18px -22px -22px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.settings-mail .flash { margin: 0 0 14px; }

.scan-form { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-form select { height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 11px; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; border: 1px solid transparent; }
.tab:hover { background: var(--surface); color: var(--text); }
.tab.is-active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow); }
.tab-count { min-width: 22px; padding: 0 7px; border-radius: 99px; background: var(--track); font-size: 12px; text-align: center; }
.tab.is-active .tab-count { background: var(--primary-soft); color: var(--primary); }

.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.bulk-actions { display: inline-flex; gap: 8px; margin-left: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.check input, .mail-check { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.mail-list { list-style: none; margin: 0; padding: 0; }
.mail-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 16px 22px; border-top: 1px solid var(--border); }
.mail-list li:first-child { border-top: 0; }
.mail-row:hover { background: var(--surface-2); }
.mail-row.is-ignored, .mail-row.is-imported { opacity: .8; }
.mail-check { margin-top: 12px; }
.mail-main { display: grid; gap: 3px; min-width: 0; }
.mail-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.mail-sender { font-size: 14.5px; }
.mail-subject { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.attachment { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .icon { width: 13px; height: 13px; }
.mail-preview { margin-top: 6px; }
.mail-preview summary { cursor: pointer; font-size: 13px; color: var(--primary); font-weight: 600; }
.mail-preview pre { white-space: pre-wrap; font-size: 12.5px; max-height: 300px; overflow: auto; margin: 8px 0 0; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.mail-side { display: grid; justify-items: end; gap: 8px; }
.mail-amount { font-size: 16px; font-variant-numeric: tabular-nums; }
.mail-actions { display: inline-flex; gap: 6px; }
.mail-actions form { margin: 0; }
.mail-actions .icon-button { width: 34px; height: 34px; }

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

@media (max-width: 560px) {
    .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
    .mail-row { grid-template-columns: auto minmax(0, 1fr); padding: 14px 16px; }
    .mail-row .file-icon { display: none; }
    .mail-side { grid-column: 2; justify-items: start; grid-auto-flow: column; align-items: center; }
    .bulk-bar { padding: 12px 16px; }
    .bulk-actions { margin-left: 0; }
}

.scan-overlay { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 16px; background: rgba(15, 23, 42, .65); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: scan-fade .2s ease-out both; }
.scan-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 2; opacity: .92; }
.scan-beam { z-index: 3; }
.scan-badge { z-index: 4; }
.scan-overlay[hidden] { display: none; }
.scan-card { width: min(400px, 100%); padding: 26px 24px 20px; border-radius: 22px; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: 0 30px 80px rgba(15, 23, 42, .35); text-align: center; animation: scan-rise .3s cubic-bezier(.2, .8, .2, 1) both; }
.scan-visual { position: relative; width: 120px; height: 166px; margin: 0 auto 18px; }
.scan-paper { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 7px; padding: 16px 14px 0; border-radius: 10px 10px 0 0; background: #fff; box-shadow: 0 10px 30px rgba(79, 70, 229, .18), 0 0 0 1px rgba(15, 23, 42, .06); overflow: hidden; -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle at 6px 100%, transparent 4.5px, #000 5px) bottom / 12px 8px repeat-x; mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle at 6px 100%, transparent 4.5px, #000 5px) bottom / 12px 8px repeat-x; }
.scan-logo { width: 40px; height: 8px; margin: 0 auto 4px; border-radius: 4px; background: #cbd5e1; }
.scan-line { position: relative; height: 5px; border-radius: 3px; background: #e2e8f0; overflow: hidden; }
.scan-line::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8b5cf6); transform: scaleX(0); transform-origin: left; animation: scan-fill 2.4s ease-in-out infinite; }
.scan-line:nth-of-type(2) { width: 88%; }
.scan-line:nth-of-type(3) { width: 70%; }
.scan-line:nth-of-type(4) { width: 94%; }
.scan-line:nth-of-type(5) { width: 62%; }
.scan-line:nth-of-type(6) { width: 80%; }
.scan-line:nth-of-type(7) { width: 54%; }
.scan-line:nth-of-type(3)::after { animation-delay: .15s; }
.scan-line:nth-of-type(4)::after { animation-delay: .3s; }
.scan-line:nth-of-type(5)::after { animation-delay: .45s; }
.scan-line:nth-of-type(6)::after { animation-delay: .6s; }
.scan-line:nth-of-type(7)::after { animation-delay: .75s; }
.scan-rule { height: 0; margin: 3px 0; border-top: 1.5px dashed #cbd5e1; }
.scan-sum { align-self: flex-end; width: 44px; height: 9px; border-radius: 4px; background: #94a3b8; animation: scan-pulse 2.4s ease-in-out infinite 1s; }
.scan-tags { display: flex; gap: 4px; margin-top: 4px; }
.scan-tags i { display: block; width: 18px; height: 6px; border-radius: 3px; opacity: .25; transform: scale(.6); animation: scan-tag 2.4s ease-in-out infinite; }
.scan-tags i:nth-child(1) { background: #10b981; animation-delay: 1.1s; }
.scan-tags i:nth-child(2) { background: #f59e0b; animation-delay: 1.25s; }
.scan-tags i:nth-child(3) { background: #ef4444; animation-delay: 1.4s; }
.scan-beam { position: absolute; left: -10px; right: -10px; top: 0; height: 26px; border-radius: 6px; background: linear-gradient(180deg, transparent, rgba(99, 102, 241, .28) 70%, rgba(99, 102, 241, .9) 92%, transparent); filter: drop-shadow(0 0 8px rgba(99, 102, 241, .7)); animation: scan-sweep 2.4s ease-in-out infinite; }
.scan-badge { position: absolute; right: -14px; bottom: -6px; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--success-text); color: #fff; box-shadow: 0 8px 20px rgba(4, 120, 87, .35); transform: scale(0); transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.scan-badge .icon { width: 20px; height: 20px; }
.scan-title { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.scan-file { margin: 4px 0 16px; font-size: 13px; min-height: 1.4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-progress { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.scan-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #8b5cf6); transition: width .5s ease; }
.scan-steps { list-style: none; display: grid; gap: 9px; margin: 18px 0 0; padding: 0; text-align: left; font-size: 14px; }
.scan-steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); transition: color .2s; }
.scan-steps li.is-active { color: var(--text); font-weight: 600; }
.scan-steps li.is-done { color: var(--text); }
.scan-step-mark { position: relative; flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); transition: background .2s, border-color .2s; }
.is-active > .scan-step-mark { border-color: var(--primary-soft); border-top-color: var(--primary); animation: scan-spin .8s linear infinite; }
.is-done > .scan-step-mark { border-color: var(--success-text); background: var(--success-text); }
.is-done > .scan-step-mark::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.scan-error { margin: 16px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(220, 38, 38, .1); color: var(--danger); font-size: 13.5px; text-align: left; }
.scan-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; }
.scan-clock { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--muted); }
.scan-card [data-scan-close] { margin-top: 14px; }
.scan-overlay.is-done .scan-beam, .scan-overlay.is-failed .scan-beam { opacity: 0; transition: opacity .3s; }
.scan-overlay.is-done .scan-line::after { animation: none; transform: scaleX(1); }
.scan-overlay.is-done .scan-badge { transform: scale(1); }
.scan-overlay.is-failed .scan-line::after, .scan-overlay.is-failed .scan-sum, .scan-overlay.is-failed .scan-tags i { animation-play-state: paused; }
@keyframes scan-sweep { 0% { transform: translateY(-20px); } 50% { transform: translateY(146px); } 100% { transform: translateY(-20px); } }
@keyframes scan-fill { 0%, 10% { transform: scaleX(0); } 45%, 80% { transform: scaleX(1); } 100% { transform: scaleX(0); opacity: 0; } }
@keyframes scan-pulse { 0%, 30% { background: #94a3b8; } 50%, 80% { background: var(--primary); } 100% { background: #94a3b8; } }
@keyframes scan-tag { 0%, 30% { opacity: .25; transform: scale(.6); } 50%, 80% { opacity: 1; transform: scale(1); } 100% { opacity: .25; transform: scale(.6); } }
@keyframes scan-spin { to { transform: rotate(360deg); } }
@keyframes scan-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes scan-rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .scan-paper { background: #e9edf5; }
}
@media (prefers-reduced-motion: reduce) {
    .scan-beam, .scan-line::after, .scan-sum, .scan-tags i, .is-active > .scan-step-mark { animation-duration: 6s; }
    .scan-overlay, .scan-card { animation: none; }
}

.share-intro { align-items: center; margin-bottom: 22px; }
.share-intro span { flex: 1; }
.share-help { margin: 4px 0 16px; }
.share-list { list-style: none; margin: 0; padding: 0; }
.share-row { display: grid; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }
.share-receipt { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.share-receipt:hover strong { color: var(--primary); }
.share-receipt-text { display: grid; min-width: 0; }
.share-receipt-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.share-total { margin-left: auto; padding-left: 8px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.share-control { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0; }
.share-presets { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border-radius: 12px; background: var(--track); }
.share-preset { height: 30px; min-width: 46px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; transition: background .15s, color .15s; }
.share-preset:hover { color: var(--text); }
.share-preset.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.share-custom { display: inline-flex; align-items: center; gap: 2px; height: 30px; padding: 0 8px 0 4px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.share-custom:focus-within { border-color: var(--primary); }
.share-custom input { width: 44px; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 650; text-align: right; outline: none; }
.share-result { display: inline-flex; align-items: baseline; gap: 8px; margin-left: auto; }
.share-amount { font-variant-numeric: tabular-nums; font-size: 15px; transition: color .2s; }
.share-source { font-size: 12px; color: var(--muted); }
.share-source.is-custom { color: var(--primary); font-weight: 650; }
.share-reset { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
.share-reset:hover { color: var(--text); }
.share-control.is-saving { opacity: .6; pointer-events: none; }
.share-control.is-saved .share-amount { color: var(--success-text); }
.input-suffix { position: relative; display: block; }
.input-suffix input { width: 100%; padding-right: 34px; }
.input-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; }
.kpi-balance.is-owed { border-color: rgba(234, 88, 12, .45); }
.kpi-balance.is-settled { border-color: rgba(21, 128, 61, .35); }
.payment-list { list-style: none; display: grid; gap: 8px; margin: 0; padding: 0; }
.payment-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.payment-text { display: grid; flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.payment-text .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.payment-list form { margin: 0; }
.share-empty { margin: 0; font-size: 14px; }
@media (max-width: 640px) {
    .share-row { padding: 14px 16px; }
    .share-result { margin-left: 0; }
}
.share-items { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 9px; border: 1px dashed var(--border); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; font-variant-numeric: tabular-nums; transition: background .15s, border-color .15s, color .15s; }
.share-items .icon { width: 15px; height: 15px; }
.share-items:hover { border-color: var(--muted); color: var(--text); }
.share-items.is-active { border-style: solid; border-color: rgba(234, 88, 12, .4); background: var(--warning-bg); color: var(--warning); }
.share-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(15, 23, 42, .35); overflow: hidden; }
.share-dialog[open] { display: flex; animation: scan-rise .25s cubic-bezier(.2, .8, .2, 1) both; }
.share-dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.share-dialog-form { display: flex; flex-direction: column; width: 100%; min-height: 0; margin: 0; }
.share-dialog-form.is-saving { opacity: .7; }
.share-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 0; }
.share-dialog-head h2 { margin: 0; font-size: 19px; }
.share-dialog-head p { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.share-dialog-hint { margin: 10px 22px 0; font-size: 13.5px; }
.share-dialog-tools { display: flex; gap: 8px; align-items: center; padding: 14px 22px 0; }
.share-dialog-tools[hidden] { display: none; }
.share-dialog-search { position: relative; flex: 1; display: flex; align-items: center; }
.share-dialog-search .icon { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.share-dialog-search input { width: 100%; height: 34px; padding: 0 12px 0 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; outline: none; }
.share-dialog-search input:focus { border-color: var(--primary); }
.share-dialog-toggle { display: inline-flex; gap: 6px; }
.share-dialog-body { flex: 1; min-height: 120px; overflow-y: auto; padding: 12px 14px; overscroll-behavior: contain; }
.share-dialog-state { margin: 0; padding: 26px 8px; text-align: center; font-size: 14px; }
.share-dialog-state[hidden] { display: none; }
.share-item-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.share-item-list li[hidden] { display: none; }
.share-item { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 11px; cursor: pointer; transition: background .15s; }
.share-item:hover { background: var(--surface-2); }
.share-item input { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--primary); cursor: pointer; }
.share-item-text { display: grid; flex: 1; min-width: 0; }
.share-item-text strong { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.share-item-meta { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.share-item-meta .dot { width: 8px; height: 8px; }
.share-item-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.share-item-list li.is-excluded .share-item-text strong, .share-item-list li.is-excluded .share-item-amount { color: var(--muted); text-decoration: line-through; }
.share-dialog-foot { display: grid; gap: 14px; padding: 14px 22px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.share-dialog-sums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.share-dialog-sums div { display: grid; gap: 2px; min-width: 0; }
.share-dialog-sums dt { font-size: 12px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-dialog-sums dd { margin: 0; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.share-dialog-sums .is-owed dd { color: var(--primary); }
.share-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 640px) {
    .share-dialog { width: min(540px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 32px); inset: 0; margin: auto; border-radius: 20px; }
    .share-dialog-head, .share-dialog-foot { padding-left: 16px; padding-right: 16px; }
    .share-dialog-hint { margin-left: 16px; margin-right: 16px; }
    .share-dialog-tools { padding-left: 16px; padding-right: 16px; }
    .share-dialog-body { padding: 10px 8px; }
    .share-dialog-actions .button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .share-dialog[open] { animation: none; }
}
.date-picker { position: relative; min-width: 0; }
.date-trigger { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.date-trigger:hover { border-color: var(--muted); }
.date-trigger:focus-visible, .date-trigger[aria-expanded="true"] { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.date-trigger .icon { width: 17px; height: 17px; color: var(--muted); }
.date-trigger[aria-expanded="true"] .icon { color: var(--primary); }
.card.is-raised { position: relative; z-index: 30; }
.date-trigger-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.date-trigger.is-empty .date-trigger-text { color: var(--muted); }
.date-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: 292px; padding: 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 18px 48px rgba(15, 23, 42, .18); animation: date-in .16s ease-out both; }
.date-picker.is-flipped .date-panel { left: auto; right: 0; }
.date-panel[hidden] { display: none; }
@keyframes date-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.date-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.date-title { font-size: 14.5px; font-weight: 700; }
.date-nav { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 9px; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.date-nav:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.date-nav:disabled { opacity: .3; cursor: default; }
.date-nav .icon { width: 17px; height: 17px; }
.date-weekdays, .date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.date-weekdays span { padding: 4px 0; text-align: center; font-size: 11.5px; font-weight: 650; color: var(--muted); }
.date-day { height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 550; font-variant-numeric: tabular-nums; cursor: pointer; transition: background .12s, color .12s; }
.date-day:hover:not(:disabled) { background: var(--surface-2); }
.date-day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.date-day.is-outside { color: var(--muted); opacity: .55; }
.date-day.is-today { color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); font-weight: 700; }
.date-day.is-selected, .date-day.is-selected:hover { background: var(--primary); color: #fff; box-shadow: none; opacity: 1; font-weight: 700; }
.date-day:disabled { opacity: .25; cursor: not-allowed; }
.date-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.date-link { padding: 4px 6px; border: 0; border-radius: 7px; background: none; color: var(--primary); font: inherit; font-size: 13px; font-weight: 650; cursor: pointer; }
.date-link:hover:not(:disabled) { background: var(--primary-soft); }
.date-link:disabled { opacity: .4; cursor: default; }
.date-link-muted { color: var(--muted); }
.date-link-muted:hover { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .date-panel { box-shadow: 0 18px 48px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .date-day.is-selected,
:root[data-theme="dark"] .date-day.is-selected:hover { color: #0b0d12; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .date-panel { box-shadow: 0 18px 48px rgba(0, 0, 0, .5); }
    :root:not([data-theme="light"]) .date-day.is-selected,
    :root:not([data-theme="light"]) .date-day.is-selected:hover { color: #0b0d12; }
}
@media (max-width: 640px) {
    .date-panel { width: min(320px, calc(100vw - 32px)); }
}
@media (prefers-reduced-motion: reduce) {
    .date-panel { animation: none; }
}
.combo { position: relative; min-width: 0; }
.combo-trigger { display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; text-align: left; cursor: pointer; transition: border-color .15s; }
.combo-trigger:hover { border-color: var(--muted); }
.combo-trigger:focus-visible, .combo-trigger[aria-expanded="true"] { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.combo-trigger .icon { width: 15px; height: 15px; margin-left: auto; color: var(--muted); transition: transform .2s; }
.combo-trigger[aria-expanded="true"] .icon { transform: rotate(180deg); }
.combo-trigger .dot[hidden] { display: none; }
.combo-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-badge { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700; vertical-align: 1px; }
.filters .combo { flex: 0 1 200px; }
.filters .combo-trigger { height: 40px; font-size: 14px; font-weight: 400; }
.combo-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; width: max(100%, 270px); padding: 8px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); box-shadow: 0 18px 48px rgba(15, 23, 42, .18); animation: date-in .16s ease-out both; }
.combo.is-flipped .combo-panel { left: auto; right: 0; }
.combo-panel[hidden] { display: none; }
.combo-search { position: relative; display: flex; align-items: center; margin-bottom: 6px; }
.combo-search .icon { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.combo-panel .combo-search input { width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 400; outline: none; }
.combo-panel .combo-search input:focus { outline: none; border-color: var(--primary); }
.combo-list { list-style: none; max-height: 272px; margin: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; }
.combo-option { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border-radius: 9px; font-size: 14px; font-weight: 500; cursor: pointer; }
.combo-option.is-active { background: var(--surface-2); }
.combo-option.is-selected { color: var(--primary); font-weight: 650; }
.combo-option .icon { width: 16px; height: 16px; margin-left: auto; color: var(--primary); }
.combo-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-create { margin-top: 4px; border-top: 1px dashed var(--border); border-radius: 0 0 9px 9px; color: var(--primary); }
.combo-create .icon { order: -1; margin-left: 0; }
.combo-create strong { font-weight: 700; }
.combo-create.is-active { background: var(--primary-soft); }
.combo-empty { margin: 0; padding: 14px 10px; color: var(--muted); font-size: 13.5px; text-align: center; }
.combo-empty[hidden] { display: none; }
:root[data-theme="dark"] .combo-panel { box-shadow: 0 18px 48px rgba(0, 0, 0, .5); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .combo-panel { box-shadow: 0 18px 48px rgba(0, 0, 0, .5); }
}
@media (max-width: 640px) {
    .filters .combo { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
    .combo-panel { animation: none; }
}
.card > h2 + .field { margin-top: 14px; }

/* === Mobile-First PWA Bottom Navigation, Mail Server Archive & Preview Modal === */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.block { display: block; }
.stack-sm { display: grid; gap: 12px; margin-top: 12px; }
.auth-pin-form { display: grid; gap: 12px; margin-bottom: 14px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.auth-email-details summary { cursor: pointer; padding: 4px 0; font-weight: 500; }

.mail-archive-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 14px 18px; border-left: 4px solid var(--success, #16a34a); flex-wrap: wrap; }
.mail-archive-info { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 auto; }
.mail-archive-copy { display: grid; gap: 4px; min-width: 0; }
.mail-archive-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14.5px; line-height: 1.4; }
.mail-archive-title strong { display: inline; font-size: 14.5px; font-weight: 700; margin: 0; }
.mail-archive-info p { margin: 0; line-height: 1.45; }
.mail-archive-info p strong { display: inline; font-size: inherit; margin: 0; }
.mail-address-code { font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.mail-sender-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(99, 102, 241, 0.22); }
.mail-archive-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.mail-banner-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.pill-xs::before { display: none; }
.mail-file-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.pill-xs { padding: 2px 8px; font-size: 11.5px; }
.settings-check-box { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin: 12px 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.settings-check-box input { margin-top: 3px; }

.mobile-bottom-nav { display: none; }

.preview-dialog { width: min(860px, calc(100vw - 24px)); max-width: none; height: min(86vh, 860px); max-height: none; margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(15, 23, 42, .32); }
.preview-dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); }
.preview-dialog[open] { display: flex; flex-direction: column; }
.preview-dialog-box { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; }
.preview-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.preview-dialog-head strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55vw; }
.preview-dialog-actions { display: flex; align-items: center; gap: 8px; }
.preview-dialog-body { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--surface-2); padding: 12px; }
.preview-dialog-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, .12); }
.preview-dialog-frame { width: 100%; height: 100%; border: 0; border-radius: 10px; background: #fff; }

@media (max-width: 680px) {
    .shell { padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        gap: 2px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 24px rgba(15, 23, 42, .08);
    }
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        border-radius: 10px;
        color: var(--muted);
        text-decoration: none;
        font-size: 11px;
        font-weight: 600;
    }
    .mobile-nav-item .icon { width: 20px; height: 20px; }
    .mobile-nav-item.is-active { color: var(--primary); background: var(--primary-soft); }
    .mobile-nav-fab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        height: 48px;
        margin: -10px 4px 0;
        padding: 0 8px;
        border: 0;
        border-radius: 14px;
        background: var(--primary);
        color: #fff;
        font: inherit;
        font-size: 11px;
        font-weight: 700;
        box-shadow: 0 6px 16px rgba(201, 86, 60, .35);
        cursor: pointer;
    }
    .mobile-nav-fab .icon { width: 20px; height: 20px; }
    .mail-archive-banner { flex-direction: column; align-items: flex-start; }
    .mail-archive-actions { width: 100%; }
    .mail-archive-actions .button, .mail-archive-actions form { flex: 1; }
    .preview-dialog { width: min(860px, calc(100vw - 24px)); max-width: calc(100vw - 24px); height: min(84dvh, 780px); inset: 0; margin: auto; border-radius: 20px; }
}

/* === Auth2 (2FA TOTP) Login Tabs, QR Setup & Multi-User Sender Recognition === */
.hidden { display: none !important; }
.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    margin: 14px 0 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.auth-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.auth-tab .icon { width: 16px; height: 16px; }
.auth-tab.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}
.totp-code-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    letter-spacing: 0.24em;
    text-align: center;
}
.auth-recognition-note {
    margin-top: 16px;
    padding: 11px 13px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12.8px;
    line-height: 1.45;
    display: grid;
    gap: 3px;
}
.auth-footer {
    margin: 14px 0 0;
    text-align: center;
}
.totp-setup-box {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px;
    margin: 10px 0 14px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.totp-qr-wrap {
    flex-shrink: 0;
    padding: 8px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
    line-height: 0;
}
.totp-qr-wrap svg {
    display: block;
    width: 176px;
    height: 176px;
}
.totp-details {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 10px;
}
.totp-details p { margin: 0; }
.totp-secret-box {
    padding: 8px 11px;
    border-radius: 9px;
    background: var(--surface);
    border: 1px dashed var(--border);
}
.totp-secret-code {
    display: block;
    margin-top: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--primary);
    word-break: break-all;
}
@media (max-width: 640px) {
    .totp-setup-box { flex-direction: column; text-align: center; }
    .auth-tabs { grid-template-columns: 1fr; }
}

/* === Modern Layout, Topbar, Language Switcher, Auth Tabs & Harmonious Form Spacing (v16) === */
:root[data-theme="dark"] {
    --bg: #0b0d12;
    --surface: #141820;
    --surface-2: #10131a;
    --border: #232937;
    --text: #eef1f6;
    --muted: #8b95a8;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #1d2142;
    --warning: #fb923c;
    --success-bg: #0b2a1c;
    --success-text: #6ee7b7;
    --warning-bg: #33200d;
    --error-bg: #351313;
    --error-text: #fca5a5;
    --info-bg: #1b1f3d;
    --info-text: #c7d2fe;
    --track: #1d2230;
    --bar: #353c66;
    --shadow: none;
    --hero-from: #3730a3;
    --hero-to: #6d28d9;
}

[hidden],
.auth-form[hidden],
.hidden {
    display: none !important;
}

/* Language Switcher Pill (LT | EN) */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--track);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.lang-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.lang-pill:hover {
    color: var(--text);
}
.lang-pill.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .1);
}

/* Theme toggle button icons */
.theme-toggle .theme-sun { display: none; }
.theme-toggle .theme-moon { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .theme-sun { display: inline-flex; }
:root[data-theme="dark"] .theme-toggle .theme-moon { display: none; }

/* Topbar & Main Page Shell */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .03);
}
.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 10px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.topbar .brand {
    padding: 0;
    flex-shrink: 0;
}
.topbar .brand-logo-horizontal {
    height: 44px;
    width: auto;
    display: block;
    object-fit: contain;
}
.topbar .nav {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
}
.topbar .nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 13px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.topbar .nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}
.topbar .nav a.is-active {
    background: var(--primary-soft);
    color: var(--primary);
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.topbar-user form {
    margin: 0;
}
.user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px 28px 64px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* Guest / Auth Screen */
.guest-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 28px 16px;
    background: radial-gradient(90% 60% at 50% 0%, var(--primary-soft), var(--bg));
}
.guest-shell {
    width: 100%;
    max-width: 440px;
    min-height: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
}
.guest-shell .flash-stack {
    max-width: none;
}
.guest-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 4px;
}
.guest-brand {
    display: inline-flex;
    align-items: center;
}
.guest-brand .brand-logo-horizontal {
    height: 48px;
    width: auto;
    display: block;
    object-fit: contain;
}
.guest-card,
.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 32px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 12px 36px -8px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .04);
    display: flex;
    flex-direction: column;
    gap: 0;
}
.auth-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}
.auth-header h1 {
    font-size: 24px;
    font-weight: 750;
    letter-spacing: -0.025em;
    margin: 0;
}
.auth-header p {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--muted);
}

/* 3-Tab Segmented Control (Password | Auth2 | Register) */
.auth-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
    margin: 0 0 24px;
    border-radius: 12px;
    background: var(--track);
    border: 1px solid var(--border);
}
.auth-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 8px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.auth-tab:hover {
    color: var(--text);
}
.auth-tab.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(15, 23, 42, .08);
}

/* Harmonious Form & Field Spacing Across the Entire App */
.auth-form,
.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}
.stack-form > h2 {
    margin: 0 0 2px;
}
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.field > span {
    line-height: 1.35;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-weight: 400;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea {
    height: auto;
    min-height: 76px;
    padding: 10px 14px;
    resize: vertical;
    line-height: 1.45;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.field input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
}
.field-color input[type="color"] {
    padding: 4px 6px;
    cursor: pointer;
}
.field-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}
.field-row:has(.field-color) {
    grid-template-columns: minmax(0, 1fr) 96px;
}
.auth-form > .button,
.stack-form > .button {
    height: 46px;
    margin-top: 4px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 650;
}
.totp-input,
.code-input {
    height: 52px !important;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    letter-spacing: 0.28em;
    text-align: center;
}
.auth-verify-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.auth-verify-actions form {
    margin: 0;
}
.auth-foot {
    margin: 18px 0 0;
    text-align: center;
    font-size: 13.5px;
}

/* Settings Cards, TOTP Setup, Rules & Learned Products */
.settings-card {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.settings-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 0;
}
.totp-enabled {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.totp-enabled p {
    margin: 0;
    font-size: 13.5px;
}
.totp-setup {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    padding: 18px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.totp-qr {
    display: block;
    padding: 10px;
    border-radius: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    line-height: 0;
    box-shadow: var(--shadow);
}
.totp-qr svg {
    width: 168px;
    height: 168px;
    display: block;
}
.totp-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
.totp-steps p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.45;
}
.secret-code {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 9px;
    background: var(--surface);
    border: 1px dashed var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--primary);
    word-break: break-all;
}
.rule-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.rule-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    overflow: hidden;
}
.rule-item summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    font-size: 14px;
}
.rule-item summary .muted {
    margin-left: auto;
    font-size: 12.5px;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rule-item > form {
    padding: 14px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.learned-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}
.learned-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13.5px;
}
.learned-list li span:last-child {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    white-space: nowrap;
}

/* Sharing View, Quick Split Pills & Custom Split Modal */
.kpis-share .kpi-featured {
    border-color: var(--primary);
    background: linear-gradient(180deg, var(--primary-soft), var(--surface) 65%);
}
.kpi-partner-form {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
}
.partner-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.partner-row input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
}
.share-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.share-toolbar .segmented {
    margin-left: 0;
}
.share-toolbar form {
    margin: 0;
}
.share-receipt-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}
.share-preview {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}
.share-quick {
    margin: 0;
}
.share-pills {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border-radius: 11px;
    background: var(--track);
}
.share-pill {
    height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 650;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, color .15s, box-shadow .15s;
}
.share-pill:hover {
    color: var(--text);
}
.share-pill.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow);
}
.share-amount.is-shared {
    color: var(--primary);
}
.share-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.share-card .card-head {
    margin-bottom: 0;
}

/* Receipt Preview & Custom Share Modals */
.receipt-modal,
.share-modal {
    width: min(760px, calc(100vw - 24px));
    max-width: none;
    margin: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 64px rgba(15, 23, 42, .32);
}
.share-modal {
    width: min(440px, calc(100vw - 24px));
}
.receipt-modal::backdrop,
.share-modal::backdrop {
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(4px);
}
.receipt-modal-inner {
    display: flex;
    flex-direction: column;
    max-height: 86vh;
}
.receipt-modal-head,
.share-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.receipt-modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.receipt-modal-body {
    flex: 1;
    min-height: 260px;
    overflow: auto;
    padding: 16px;
    background: var(--surface-2);
    display: grid;
    place-items: center;
}
.receipt-modal-body img {
    max-width: 100%;
    max-height: 74vh;
    border-radius: 10px;
}
.receipt-modal-body iframe {
    width: 100%;
    height: 72vh;
    border: 0;
    border-radius: 10px;
    background: #fff;
}
.share-modal-inner {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
}
.share-modal-inner .share-modal-head {
    padding: 0 0 12px;
}
.share-modal-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.share-modal-summary > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.share-modal-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.share-modal-split > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.share-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

/* Mail Filters & Checkboxes */
.filters-mail {
    justify-content: space-between;
}
.filters-mail .segmented {
    margin-left: 0;
}
.mail-since {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.check-col {
    width: 42px;
    padding-right: 0 !important;
}
.check-col input[type="checkbox"],
.check-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
}
.bar-row {
    list-style: none;
}

/* Mobile Bottom Nav & Responsive Adjustments */
.bottom-nav {
    display: none;
}

@media (max-width: 900px) {
    .topbar-inner {
        padding: 10px 16px;
        gap: 12px;
    }
    .topbar .nav {
        display: none;
    }
    .user-name {
        display: none;
    }
    .page {
        padding: 20px 16px calc(88px + env(safe-area-inset-bottom, 0px));
    }
    .bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 50;
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        gap: 2px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, .06);
    }
    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        border-radius: 10px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 600;
        text-decoration: none;
    }
    .bottom-nav a.is-active {
        color: var(--primary);
        background: var(--primary-soft);
    }
    .bottom-nav .bottom-upload {
        width: 46px;
        height: 46px;
        margin: -12px auto 0;
        border-radius: 14px;
        background: var(--primary);
        color: #fff;
        box-shadow: 0 6px 16px rgba(79, 70, 229, .32);
    }
}

@media (max-width: 640px) {
    .guest-card,
    .auth-card {
        padding: 24px 20px;
    }
    .auth-tabs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .auth-tab {
        font-size: 12px;
        padding: 0 4px;
    }
    .totp-setup {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        text-align: center;
    }
    .field-row,
    .field-row:has(.field-color) {
        grid-template-columns: minmax(0, 1fr);
    }
}
.share-table td { vertical-align: middle; } .share-table tr.is-shared { background: rgba(79, 70, 229, 0.025); }
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 4px;
}
.sidebar-top .brand {
    padding: 0;
    min-width: 0;
}
.sidebar-top .brand-logo-horizontal {
    height: 40px;
    width: auto;
    max-width: 134px;
    object-fit: contain;
}
/* Center guest login shell and refine settings card spacing */
body.guest {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 28px 16px;
    background: radial-gradient(90% 60% at 50% 0%, var(--primary-soft), var(--bg));
}
.guest-shell {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}
.settings-card .button-primary {
    justify-self: stretch;
}

/* === Dual-theme brand logo, 3-way Theme Switcher & 6-box Progressive OTP (v17) === */
.brand-logo-dark { display: none !important; }
:root[data-theme="dark"] .brand-logo-light { display: none !important; }
:root[data-theme="dark"] .brand-logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand-logo-light { display: none !important; }
    :root:not([data-theme="light"]) .brand-logo-dark { display: block !important; }
}

.guest-shell,
.guest-card,
.auth-card {
    max-width: 476px;
}
.guest-topbar {
    gap: 10px;
    flex-wrap: nowrap;
}
.guest-brand .brand-logo-horizontal {
    height: 36px;
}
.topbar-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
.sidebar-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 999px;
    background: var(--track);
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.theme-pill {
    appearance: none;
    border: 0;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 27px;
    padding: 0 9px;
    border-radius: 999px;
    font: inherit;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: 0.01em;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
}
.theme-pill .icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.theme-pill:hover {
    color: var(--text);
}
.theme-pill.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}
.theme-switch-sidebar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: 11px;
    padding: 3px;
}
.theme-switch-sidebar .theme-pill {
    border-radius: 8px;
    padding: 0 6px;
    font-size: 11.5px;
}
.theme-switch-large {
    border-radius: 12px;
    padding: 4px;
}
.theme-switch-large .theme-pill {
    height: 34px;
    border-radius: 9px;
    padding: 0 14px;
    font-size: 13px;
    gap: 6px;
}
.theme-switch-large .theme-pill .icon {
    width: 15px;
    height: 15px;
}
.theme-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.theme-setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* 6-Box Progressive Left-to-Right OTP Component */
.otp-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.otp-boxes {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    direction: ltr;
}
.field .otp-boxes input.otp-digit,
.otp-boxes input.otp-digit {
    width: 100%;
    height: 54px;
    padding: 0;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    caret-color: var(--primary);
    transition: border-color .12s ease, box-shadow .12s ease, transform .1s ease;
}
.field .otp-boxes input.otp-digit::placeholder,
.otp-boxes input.otp-digit::placeholder {
    color: var(--muted);
    opacity: .35;
    font-weight: 500;
}
.field .otp-boxes input.otp-digit:hover,
.otp-boxes input.otp-digit:hover {
    border-color: var(--muted);
}
.field .otp-boxes input.otp-digit:focus,
.otp-boxes input.otp-digit:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    background: var(--surface);
    transform: translateY(-1px);
}
.field .otp-boxes input.otp-digit.is-filled,
.otp-boxes input.otp-digit.is-filled {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}
.otp-hint {
    margin: 0;
}

/* Compact icon-only Theme Switcher ("spwap") & Password Eye Toggle (v20) */
.theme-switch-icons .theme-pill {
    width: 30px;
    height: 27px;
    padding: 0;
    gap: 0;
}
.theme-switch-icons .theme-pill .icon {
    width: 15px;
    height: 15px;
}
.theme-switch-sidebar.theme-switch-icons .theme-pill {
    width: 100%;
    height: 28px;
    padding: 0;
}
.theme-switch-large.theme-switch-icons .theme-pill {
    width: 42px;
    height: 34px;
    padding: 0;
}
.theme-switch-large.theme-switch-icons .theme-pill .icon {
    width: 16px;
    height: 16px;
}

/* Password input wrapper with Show/Hide Eye toggle button */
.password-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}
.field .password-input-wrap input[type="password"],
.field .password-input-wrap input[type="text"],
.password-input-wrap input {
    width: 100%;
    padding-right: 42px !important;
}
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: color .14s ease, background-color .14s ease;
    z-index: 2;
}
.password-toggle:hover {
    color: var(--text);
    background: var(--surface-soft);
}
.password-toggle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    color: var(--primary);
}
.password-toggle .icon {
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.password-toggle .icon-eye-off {
    display: none;
}
.password-toggle.is-visible {
    color: var(--primary);
}
.password-toggle.is-visible .icon-eye {
    display: none;
}
.password-toggle.is-visible .icon-eye-off {
    display: block;
}

@media (max-width: 520px) {
    .guest-topbar {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 8px;
    }
    .guest-brand .brand-logo-horizontal {
        height: 30px;
        max-width: 148px;
    }
    .topbar-controls {
        width: auto;
        justify-content: flex-end;
        gap: 5px;
    }
    .theme-switch-icons .theme-pill {
        width: 27px;
        height: 25px;
    }
    .theme-switch-icons .theme-pill .icon {
        width: 14px;
        height: 14px;
    }
    .otp-boxes {
        gap: 6px;
    }
    .field .otp-boxes input.otp-digit,
    .otp-boxes input.otp-digit {
        height: 48px;
        font-size: 19px;
        border-radius: 10px;
    }
}


/* === v22: Slide-in Collapsible Sidebar, 4-Tab Settings, Super Admin Users & Audit === */
:root {
    --sidebar: 248px;
}
:root[data-sidebar="collapsed"] {
    --sidebar: 76px;
}

.app {
    transition: grid-template-columns 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar {
    width: var(--sidebar);
    transition: width 0.24s cubic-bezier(0.22, 1, 0.36, 1), padding 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: visible;
    z-index: 40;
}
.sidebar-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-x: hidden;
}
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-height: 44px;
}
.sidebar-top .brand {
    padding: 0 4px;
    min-width: 0;
    flex: 1 1 auto;
}
.sidebar-top .brand-logo-horizontal {
    height: 38px;
    width: auto;
    max-width: 168px;
    object-fit: contain;
}
.brand-logo-mark {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    object-fit: contain;
    flex-shrink: 0;
}

/* Protruding "Gumbas" Sidebar Ear Tab — seamlessly merged into .sidebar right border */
.sidebar-toggle {
    appearance: none;
    position: absolute;
    top: 23px;
    left: calc(100% - 1px);
    width: 22px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
    border-left: none;
    border-radius: 0 11px 11px 0;
    cursor: pointer;
    padding: 0 2px 0 0;
    z-index: 45;
    box-shadow: 5px 0 12px -4px rgba(15, 23, 42, 0.08);
    transition: color 0.16s ease, box-shadow 0.16s ease;
}
.sidebar-toggle:hover {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--border);
    box-shadow: 6px 0 14px -3px rgba(79, 70, 229, 0.16);
}
.sidebar-toggle .sidebar-ear-chevron {
    width: 14px;
    height: 14px;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.sidebar-toggle:hover .sidebar-ear-chevron {
    transform: translateX(-1px);
}
:root[data-sidebar="collapsed"] .sidebar-toggle:hover .sidebar-ear-chevron {
    transform: rotate(180deg) translateX(-1px);
}
@media (max-width: 860px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* Collapsed ("slide-in") sidebar state */
@media (min-width: 861px) {
    :root[data-sidebar="collapsed"] .sidebar {
        padding: 18px 10px;
        align-items: center;
        gap: 16px;
    }
    :root[data-sidebar="collapsed"] .sidebar-head {
        width: 100%;
        align-items: center;
    }
    :root[data-sidebar="collapsed"] .sidebar-top {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        width: 100%;
    }
    :root[data-sidebar="collapsed"] .sidebar-top .brand {
        padding: 0;
        justify-content: center;
        flex: 0 0 auto;
    }
    :root[data-sidebar="collapsed"] .sidebar-top .brand-logo-horizontal {
        display: none !important;
    }
    :root[data-sidebar="collapsed"] .brand-logo-mark {
        display: block !important;
    }
    :root[data-sidebar="collapsed"] .sidebar-toggle .sidebar-ear-chevron {
        transform: rotate(180deg);
    }
    :root[data-sidebar="collapsed"] .nav {
        width: 100%;
        justify-items: center;
        gap: 6px;
    }
    :root[data-sidebar="collapsed"] .nav-link {
        width: 46px;
        height: 46px;
        padding: 0;
        justify-content: center;
        border-radius: 12px;
    }
    :root[data-sidebar="collapsed"] .nav-link span {
        display: none;
    }
    :root[data-sidebar="collapsed"] .sidebar-upload {
        width: 46px;
        height: 46px;
        min-width: 46px;
        padding: 0;
        justify-content: center;
        border-radius: 12px;
    }
    :root[data-sidebar="collapsed"] .sidebar-upload span {
        display: none;
    }
    :root[data-sidebar="collapsed"] .sidebar-user {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px 0 0;
        width: 100%;
    }
    :root[data-sidebar="collapsed"] .sidebar-user-text {
        display: none;
    }
    :root[data-sidebar="collapsed"] .sidebar-user form {
        margin: 0;
    }
}

/* Settings Tabs & Panels */
.pill-superadmin {
    font-size: 12px;
    padding: 3px 10px;
    margin-left: 8px;
    vertical-align: middle;
}
.settings-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.settings-tabs .tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 650;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.settings-tabs .tab .icon {
    width: 17px;
    height: 17px;
}
.settings-tabs .tab:hover {
    color: var(--text);
    background: var(--surface-2);
}
.settings-tabs .tab.is-active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.22);
}
.tab-badge-admin {
    display: inline-flex;
    align-items: center;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(79, 70, 229, 0.14);
    color: var(--primary);
}
.tab-count-success {
    background: var(--success-bg) !important;
    color: var(--success-text) !important;
}

.settings-panel {
    display: grid;
    gap: 22px;
    animation: settingsFadeIn 0.18s ease-out;
}
@keyframes settingsFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Profile & Defaults Preference Box */
.settings-pref-box {
    display: grid;
    gap: 14px;
    padding: 16px 18px;
    margin-bottom: 18px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.settings-pref-divider {
    height: 1px;
    background: var(--border);
}
.lang-switch-settings {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: var(--track);
    border: 1px solid var(--border);
}
.lang-switch-settings .lang-pill {
    appearance: none;
    border: 0;
    background: transparent;
    padding: 6px 12px;
    border-radius: 8px;
    font: inherit;
    font-size: 12.5px;
    font-weight: 650;
    color: var(--muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.lang-switch-settings .lang-pill:hover {
    color: var(--text);
}
.lang-switch-settings .lang-pill.is-active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}
.theme-switch-settings {
    padding: 4px;
    border-radius: 11px;
}
.theme-switch-settings .theme-pill {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 12.5px;
    gap: 6px;
}

.sender-chips-box {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
}
.sender-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.store-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}
.store-add-row input {
    flex: 1 1 auto;
}
.provider-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}
.provider-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s ease, transform 0.12s ease;
}
.provider-chip:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}
.provider-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.settings-card-narrow {
    max-width: 820px;
}
.card-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.totp-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.button-danger-text {
    color: var(--danger) !important;
}

/* Users & Audit Tab */
.settings-kpis {
    margin-bottom: 4px;
}
.create-user-panel {
    padding: 18px;
    margin-bottom: 18px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.form-row-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.field-end {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
}

.user-cell {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.user-cell-info {
    display: grid;
    gap: 2px;
}
.user-sender-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}
.status-pills-col {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}
.user-row-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}
.user-row-actions form {
    margin: 0;
}

.audit-time {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.audit-user {
    display: grid;
    gap: 1px;
}
.audit-ip {
    font-size: 12px;
}

@media (max-width: 960px) {
    .form-row-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 640px) {
    .form-row-4 {
        grid-template-columns: 1fr;
    }
    .store-add-row {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ==================== MULTI-EMAIL VERIFICATION & TEMPLATE PREVIEW ==================== */
.tab-count-warning {
    background: rgba(245, 158, 11, 0.16);
    color: var(--amber);
    border-color: rgba(245, 158, 11, 0.35);
}

.linked-emails-list {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.linked-email-item {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--surface-2);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.linked-email-item.is-verified {
    border-color: rgba(16, 185, 129, 0.25);
}

.linked-email-item.is-pending {
    border-color: rgba(245, 158, 11, 0.48);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.06), var(--surface-2));
    box-shadow: 0 6px 20px -10px rgba(245, 158, 11, 0.22);
}

.linked-email-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.linked-email-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.linked-email-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 16px;
    flex-shrink: 0;
}

.linked-email-addr-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.linked-email-code {
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--ink);
    background: var(--surface);
    padding: 3px 9px;
    border-radius: 7px;
    border: 1px solid var(--border);
}

.linked-email-verify-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    display: grid;
    gap: 10px;
}

.linked-email-otp-form {
    display: grid;
    gap: 12px;
}

.linked-email-verify-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.linked-email-resend-form {
    margin: 0;
}

.linked-email-add-form {
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.email-template-preview-bar {
    margin-top: 16px;
    padding: 13px 15px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px dashed var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.email-template-preview-info {
    display: grid;
    gap: 2px;
}

.email-template-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.email-template-preview-frame-wrap {
    margin-top: 12px;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #f1f5f9;
}

.email-template-iframe {
    width: 100%;
    height: 760px;
    border: 0;
    display: block;
}

.admin-create-user-box {
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.user-cell-main {
    display: grid;
    gap: 3px;
}

.user-cell-senders {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}

.status-badges-col {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.user-admin-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.user-admin-actions form {
    margin: 0;
}

/* ==================== V25: RECEIPT COPY PILL & AUTH2 CONNECTED STATE ==================== */
.receipt-inbox-copy-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: 13px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.07), rgba(124, 58, 237, 0.05));
    border: 1px solid rgba(79, 70, 229, 0.22);
}

.receipt-inbox-copy-info {
    display: grid;
    gap: 4px;
    min-width: 0;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.receipt-inbox-copy-label {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text);
}

.copy-email-pill {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 7px 5px 11px;
    border-radius: 10px;
    border: 1px solid rgba(79, 70, 229, 0.32);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}

.copy-email-pill:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
    transform: translateY(-1px);
}

.copy-email-pill:active {
    transform: translateY(0);
}

.copy-email-pill .copy-email-code {
    background: transparent;
    padding: 0;
    font-size: 13.5px;
    font-weight: 750;
    color: var(--primary);
}

.copy-email-pill .copy-email-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-soft);
    color: var(--primary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.copy-email-pill.is-copied {
    border-color: rgba(16, 185, 129, 0.55);
}

.copy-email-pill.is-copied .copy-email-badge {
    background: var(--success-bg);
    color: var(--success-text);
}

/* Auth2 Connected State Card */
.totp-connected-card {
    display: grid;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.06), var(--surface-2));
    border: 1px solid rgba(16, 185, 129, 0.32);
}

.totp-connected-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.totp-connected-badge-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--success-bg);
    border: 1px solid rgba(16, 185, 129, 0.28);
    font-size: 20px;
    flex-shrink: 0;
}

.totp-connected-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.totp-connected-desc {
    margin: 0;
    line-height: 1.5;
}

.totp-connected-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    padding: 12px 14px;
    border-radius: 11px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.totp-connected-meta-item {
    display: grid;
    gap: 4px;
}

.totp-method-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.totp-connected-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.totp-connected-actions form {
    margin: 0;
}


/* ==================== V27: TWO-STEP AUTH2 (2FA), PASSWORD EYE & EMAIL PREVIEW ==================== */
.auth-tabs.auth-tabs-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.password-input-wrap {
    position: relative !important;
    display: block !important;
    width: 100%;
}

.field .password-input-wrap input[type="password"],
.field .password-input-wrap input[type="text"],
.password-input-wrap input {
    width: 100%;
    padding-right: 44px !important;
    box-sizing: border-box;
}

.password-toggle,
.password-toggle-btn {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 32px !important;
    height: 32px !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--muted) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    z-index: 2;
}

.password-toggle:hover,
.password-toggle-btn:hover {
    color: var(--text) !important;
    background: var(--surface-2) !important;
}

.password-toggle .icon,
.password-toggle-btn .icon {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.password-toggle .icon-eye-off,
.password-toggle-btn .icon-eye-off,
.password-toggle .eye-closed,
.password-toggle-btn .eye-closed {
    display: none;
}

.password-toggle.is-visible,
.password-toggle-btn.is-visible {
    color: var(--primary) !important;
}

.password-toggle.is-visible .icon-eye,
.password-toggle-btn.is-visible .icon-eye,
.password-toggle.is-visible .eye-open,
.password-toggle-btn.is-visible .eye-open {
    display: none !important;
}

.password-toggle.is-visible .icon-eye-off,
.password-toggle-btn.is-visible .icon-eye-off,
.password-toggle.is-visible .eye-closed,
.password-toggle-btn.is-visible .eye-closed {
    display: block !important;
}

.auth-account-pill {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    margin-bottom: 18px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.auth-account-pill-user {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.auth-account-pill-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.16);
    color: #10b981;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.auth-account-pill-email {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-account-pill-change {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.auth-account-pill-change:hover {
    text-decoration: underline;
}

.email-template-preview-actions .button.is-active {
    background: color-mix(in srgb, var(--primary, #4f46e5) 14%, transparent);
    border-color: color-mix(in srgb, var(--primary, #4f46e5) 40%, transparent);
    color: var(--primary, #4f46e5);
    font-weight: 700;
}

/* ==================== V28: MOBILE & PWA HEADER, BOTTOM NAV & RESPONSIVE POLISH ==================== */

/* Desktop defaults for mobile-settings-btn and avatar-link */
.mobile-settings-btn {
    display: none;
}

.avatar-link {
    text-decoration: none;
    color: var(--primary);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.avatar-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 0 2px var(--primary-soft);
}

.avatar-link.is-active {
    box-shadow: 0 0 0 2px var(--primary);
}

/* Fix mobile-nav-fab Indigo shadow & crisp dark-mode contrast */
.mobile-nav-fab {
    background: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 6px 18px rgba(79, 70, 229, .38) !important;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .mobile-nav-fab {
        background: #6366f1 !important;
        color: #ffffff !important;
        box-shadow: 0 6px 20px rgba(99, 102, 241, .42) !important;
    }
}

:root[data-theme="dark"] .mobile-nav-fab {
    background: #6366f1 !important;
    color: #ffffff !important;
    box-shadow: 0 6px 20px rgba(99, 102, 241, .42) !important;
}

/* Full-width sleek mobile & tablet header + fixed bottom nav (<= 920px) */
@media (max-width: 920px) {
    .app,
    :root[data-sidebar="collapsed"] .app {
        display: flex !important;
        flex-direction: column !important;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* Reset .sidebar so desktop width/collapsed rules NEVER shrink it to 248px or 76px on mobile */
    .sidebar,
    :root[data-sidebar="collapsed"] .sidebar,
    body.sidebar-collapsed .sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 60 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px 16px !important;
        border-right: 0 !important;
        border-bottom: 1px solid var(--border) !important;
        background: color-mix(in srgb, var(--surface) 92%, transparent) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        overflow: visible !important;
    }

    /* Hide desktop-only sidebar elements on mobile (bottom nav already handles main navigation + upload) */
    .sidebar-toggle,
    .sidebar .nav,
    .sidebar .sidebar-upload,
    .sidebar-user-text,
    :root[data-sidebar="collapsed"] .sidebar .nav,
    :root[data-sidebar="collapsed"] .sidebar .sidebar-upload {
        display: none !important;
    }

    /* Clean horizontal brand logo on the left of the mobile top bar */
    .sidebar-head,
    :root[data-sidebar="collapsed"] .sidebar-head {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        margin: 0 !important;
        padding: 0 !important;
        min-width: 0;
        flex-shrink: 0;
    }

    .sidebar-top,
    :root[data-sidebar="collapsed"] .sidebar-top {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    .sidebar-top .brand,
    :root[data-sidebar="collapsed"] .sidebar-top .brand {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
    }

    /* Always show horizontal logo on mobile, even if desktop sidebar was collapsed */
    .sidebar-top .brand-logo-mark,
    :root[data-sidebar="collapsed"] .sidebar-top .brand-logo-mark {
        display: none !important;
    }

    .sidebar-top .brand-logo-horizontal {
        height: 30px !important;
        max-width: 142px !important;
        width: auto !important;
    }

    :root:not([data-theme="dark"]) .sidebar-top .brand-logo-light,
    :root[data-theme="light"] .sidebar-top .brand-logo-light {
        display: block !important;
    }

    :root[data-theme="dark"] .sidebar-top .brand-logo-dark {
        display: block !important;
    }

    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) .sidebar-top .brand-logo-light {
            display: none !important;
        }
        :root:not([data-theme="light"]) .sidebar-top .brand-logo-dark {
            display: block !important;
        }
    }

    /* Compact action group on the right: Settings icon + Avatar pill + Logout */
    .sidebar-user,
    :root[data-sidebar="collapsed"] .sidebar-user {
        margin: 0 0 0 auto !important;
        padding: 0 !important;
        border: 0 !important;
        width: auto !important;
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        flex-shrink: 0;
    }

    .sidebar-user .sidebar-logout-desktop {
        display: none !important;
    }

    .mobile-settings-btn {
        display: inline-flex !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
        border: 1px solid var(--border) !important;
        background: var(--surface-2) !important;
        color: var(--muted) !important;
    }

    .mobile-settings-btn.is-active {
        color: var(--primary) !important;
        background: var(--primary-soft) !important;
        border-color: color-mix(in srgb, var(--primary) 35%, var(--border)) !important;
    }

    .sidebar-user .avatar {
        width: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
        font-size: 13px !important;
    }

    .sidebar-user .icon-button {
        width: 36px !important;
        height: 36px !important;
        border-radius: 10px !important;
        border: 1px solid var(--border) !important;
        background: var(--surface-2) !important;
    }

    /* Main content area & safe bottom clearance for fixed bottom nav */
    .shell {
        flex: 1 1 auto;
        width: 100%;
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .main {
        padding: 18px 14px 28px !important;
        gap: 16px !important;
        max-width: 100%;
    }

    /* Fixed bottom navigation bar across all mobile/tablet widths <= 920px */
    .mobile-bottom-nav {
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: center;
        gap: 2px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 70;
        padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)) !important;
        background: color-mix(in srgb, var(--surface) 94%, transparent) !important;
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 24px rgba(0, 0, 0, .14);
    }

    .mobile-nav-item {
        min-height: 48px;
        padding: 5px 2px;
        font-size: 11px;
        border-radius: 10px;
    }

    .mobile-nav-fab {
        min-height: 46px;
        margin: -6px 2px 0;
        border-radius: 14px;
        font-size: 11px;
    }
}

/* Phone viewport refinements (<= 640px, e.g. 390x844 iPhone PWA) */
@media (max-width: 640px) {
    /* Page header compact layout */
    .page-head {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .page-head h1 {
        font-size: 22px;
        line-height: 1.2;
    }

    .page-head .actions,
    .period-bar {
        width: 100%;
        justify-content: space-between;
    }

    .period-bar .segmented {
        flex: 1;
        justify-content: center;
    }

    .period-bar .segmented a {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    /* 2x2 KPI cards on mobile so all 4 fit cleanly above the fold */
    .kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .kpi {
        padding: 14px !important;
        gap: 4px !important;
        border-radius: 14px !important;
    }

    .kpi-icon {
        width: 32px !important;
        height: 32px !important;
        border-radius: 9px !important;
        margin-bottom: 2px !important;
    }

    .kpi-label {
        font-size: 12px !important;
    }

    .kpi-value {
        font-size: 20px !important;
        line-height: 1.15 !important;
    }

    .kpi-foot {
        font-size: 11.5px !important;
        line-height: 1.3 !important;
    }

    /* Settings 4 tabs: clean 2x2 grid on phones with zero truncation */
    .settings-tabs {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
        padding: 6px !important;
        border-radius: 14px !important;
        overflow: visible !important;
    }

    .settings-tabs .tab {
        width: 100% !important;
        min-height: 44px !important;
        padding: 8px 9px !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 6px !important;
        white-space: normal !important;
        overflow: visible !important;
    }

    .settings-tabs .tab .icon {
        width: 15px !important;
        height: 15px !important;
        flex-shrink: 0 !important;
    }

    .settings-tabs .tab span:not(.tab-count):not(.tab-badge-admin) {
        flex: 1 1 auto;
        min-width: 0;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    .settings-tabs .tab .tab-count,
    .settings-tabs .tab .tab-badge-admin {
        margin-left: auto !important;
        padding: 1px 6px !important;
        font-size: 10px !important;
        flex-shrink: 0 !important;
    }

    /* Settings cards & preference rows on mobile */
    .settings-card {
        padding: 16px !important;
    }

    .settings-head {
        flex-wrap: wrap;
        gap: 10px;
    }

    .settings-head > div {
        min-width: calc(100% - 52px);
    }

    .theme-setting-row {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .lang-switch-settings,
    .theme-switch-settings {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .theme-switch-settings {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }

    .lang-switch-settings .lang-pill,
    .theme-switch-settings .theme-pill {
        justify-content: center;
        width: 100%;
    }

    .store-add-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .store-add-row .button {
        width: 100% !important;
        justify-content: center;
    }

    .receipt-inbox-copy-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 12px !important;
        gap: 10px !important;
    }

    .copy-email-pill {
        width: 100%;
        justify-content: space-between !important;
    }

    .linked-email-top {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .linked-email-addr-row {
        flex-wrap: wrap;
        gap: 6px;
    }

    .linked-email-code {
        word-break: break-all;
    }

    /* 6-Box OTP inputs on mobile: fit comfortably inside 390px viewport without overflow */
    .otp-boxes {
        gap: 6px !important;
    }

    .field .otp-boxes input.otp-digit,
    .otp-boxes input.otp-digit {
        height: 46px !important;
        font-size: 19px !important;
        border-radius: 10px !important;
    }

    /* Mail page mobile polish */
    .scan-form {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .scan-form select {
        flex: 1;
        min-width: 0;
    }

    .mail-archive-banner {
        flex-direction: column;
        align-items: stretch !important;
        padding: 14px !important;
        gap: 12px !important;
    }

    .mail-archive-info {
        flex-direction: column;
        gap: 10px !important;
    }

    .mail-archive-title {
        flex-wrap: wrap;
        gap: 6px !important;
    }

    .mail-archive-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .mail-archive-actions .button {
        flex: 1;
        justify-content: center;
    }

    /* Mail filter tabs horizontal scroll on mobile */
    .tabs:not(.settings-tabs) {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 4px;
        padding: 4px;
    }

    .tabs:not(.settings-tabs)::-webkit-scrollbar {
        display: none;
    }

    .tabs:not(.settings-tabs) .tab {
        flex-shrink: 0;
        padding: 7px 11px;
        font-size: 12.5px;
    }

    .bulk-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
    }

    .bulk-actions {
        width: 100%;
        display: flex;
        gap: 6px;
    }

    .bulk-actions .button {
        flex: 1;
        justify-content: center;
    }
}

/* ============================================================================
   v29: COMPLETE MOBILE & PWA UI FIXES (5 SCREENSHOT ISSUES + FULL AUDIT)
   ============================================================================ */

/* 1. User Avatar Slide-Down Dropdown Menu ("A" button in header/sidebar) */
.sidebar-user {
    position: relative;
}

.user-avatar-trigger {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px 3px 3px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.12s ease;
}

.user-avatar-trigger:hover {
    border-color: color-mix(in srgb, var(--primary) 50%, var(--border));
    background: var(--surface);
}

.user-avatar-trigger.is-open,
.user-avatar-trigger.is-active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 26%, transparent);
}

.user-avatar-trigger .avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: 13px;
}

.user-avatar-chevron {
    width: 14px;
    height: 14px;
    color: var(--muted);
    transition: transform 0.18s ease, color 0.18s ease;
    flex-shrink: 0;
}

.user-avatar-trigger.is-open .user-avatar-chevron {
    transform: rotate(180deg);
    color: var(--primary);
}

.user-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    width: 280px;
    z-index: 250;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 20px 44px -10px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.user-dropdown-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.user-dropdown-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
}

.user-dropdown-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 11px !important;
    font-size: 14px !important;
    flex-shrink: 0;
}

.user-dropdown-meta {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.user-dropdown-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.user-dropdown-name-row strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.user-dropdown-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.user-dropdown-nav {
    display: grid;
    gap: 3px;
}

.user-dropdown-item {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.user-dropdown-item .icon {
    width: 17px;
    height: 17px;
    color: var(--muted);
    flex-shrink: 0;
}

.user-dropdown-item span:not(.pill):not(.tab-badge-admin) {
    flex: 1;
    min-width: 0;
}

.user-dropdown-item:hover {
    background: var(--surface-2);
    border-color: var(--border);
}

.user-dropdown-item:hover .icon {
    color: var(--primary);
}

.user-dropdown-item.is-active {
    background: color-mix(in srgb, var(--primary) 15%, var(--surface));
    border-color: color-mix(in srgb, var(--primary) 42%, var(--border));
    color: var(--text);
}

.user-dropdown-item.is-active .icon {
    color: var(--primary);
}

.user-dropdown-logout-form {
    margin: 0;
}

.user-dropdown-logout {
    color: var(--danger) !important;
}

.user-dropdown-logout .icon {
    color: var(--danger) !important;
}

.user-dropdown-logout:hover {
    background: var(--danger-bg) !important;
    border-color: color-mix(in srgb, var(--danger) 35%, transparent) !important;
}

/* 2. Tactile Settings Tabs (clearly look like clickable buttons/tabs even when inactive) */
.settings-tabs {
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    padding: 6px !important;
    gap: 8px !important;
}

.settings-tabs .tab {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 11px !important;
    padding: 10px 14px !important;
    font-weight: 650 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12) !important;
    opacity: 0.88;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.12s ease !important;
}

.settings-tabs .tab .icon {
    color: var(--muted);
    transition: color 0.15s ease;
}

.settings-tabs .tab:hover {
    opacity: 1;
    border-color: color-mix(in srgb, var(--primary) 48%, var(--border)) !important;
}

.settings-tabs .tab:hover .icon {
    color: var(--primary);
}

.settings-tabs .tab.is-active {
    opacity: 1;
    background: color-mix(in srgb, var(--primary) 18%, var(--surface)) !important;
    border: 1.5px solid var(--primary) !important;
    color: var(--text) !important;
    box-shadow: 0 4px 14px -2px color-mix(in srgb, var(--primary) 34%, transparent) !important;
}

.settings-tabs .tab.is-active .icon {
    color: var(--primary) !important;
}

/* 3. Fix receipt-inbox-copy-bar vertical height & table-wrap negative margins */
.receipt-inbox-copy-bar {
    height: auto !important;
    min-height: 0 !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px !important;
}

.receipt-inbox-copy-info {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
}

.settings-panel,
.settings-panel > .stack,
.settings-card,
.table-wrap {
    min-width: 0 !important;
    max-width: 100% !important;
}

.settings-card > .table-wrap {
    margin: 0 !important;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.user-mobile-id {
    display: none;
}

.user-cell-top-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 4. Mail Info Trigger & Pop-Up Modal ([data-mail-info-dialog]) */
.mail-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.mail-info-trigger {
    border-color: color-mix(in srgb, var(--primary) 38%, var(--border)) !important;
    background: color-mix(in srgb, var(--primary) 10%, var(--surface)) !important;
    font-weight: 650 !important;
}

.mail-info-trigger:hover {
    border-color: var(--primary) !important;
    background: color-mix(in srgb, var(--primary) 16%, var(--surface)) !important;
}

.mail-info-dialog {
    max-width: 520px;
    width: calc(100vw - 24px);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 56px -12px rgba(0, 0, 0, 0.55);
}

.mail-info-dialog::backdrop {
    background: rgba(8, 10, 16, 0.68);
    backdrop-filter: blur(4px);
}

.mail-info-modal-card {
    display: grid;
    gap: 0;
}

.mail-info-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.mail-info-modal-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.mail-info-modal-title .kpi-icon {
    margin: 0;
    flex-shrink: 0;
}

.mail-info-modal-title h2 {
    margin: 0 0 2px;
    font-size: 16.5px;
    line-height: 1.3;
}

.mail-info-modal-title p {
    margin: 0;
}

.mail-info-modal-body {
    padding: 16px 20px;
    display: grid;
    gap: 16px;
}

.mail-info-section {
    display: grid;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.mail-info-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.mail-info-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.mail-info-senders {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.copy-email-pill-lg {
    width: 100%;
    justify-content: space-between;
    padding: 8px 10px 8px 13px;
}

.mail-info-modal-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 13px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 18px 18px;
}

/* 5. Mobile & Tablet Responsive Layout (<= 920px & <= 768px) */
@media (max-width: 920px) {
    .sidebar-logout-desktop,
    .sidebar-user .sidebar-logout-desktop {
        display: none !important;
    }

    .user-dropdown-menu {
        top: calc(100% + 10px);
        bottom: auto;
        right: 0;
        left: auto;
        width: min(300px, calc(100vw - 24px));
        transform: translateY(-6px) scale(0.98);
    }

    .user-dropdown-menu.is-open {
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    /* Fix negative margin on all table-wraps inside cards */
    .card:not(.card-flush) > .table-wrap,
    .settings-card > .table-wrap {
        margin: 0 !important;
        border: 0 !important;
        overflow-x: visible !important;
    }

    /* Fix receipt-inbox-copy-bar on mobile so there is zero empty vertical space */
    .receipt-inbox-copy-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        height: auto !important;
        min-height: 0 !important;
        gap: 10px !important;
        padding: 13px !important;
    }

    .receipt-inbox-copy-info {
        flex: 0 0 auto !important;
        height: auto !important;
        min-height: 0 !important;
        width: 100% !important;
    }

    /* Settings 2x2 tactile tab buttons on mobile */
    .settings-tabs {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        padding: 7px !important;
    }

    .settings-tabs .tab {
        padding: 10px 10px !important;
        font-size: 12.5px !important;
        min-height: 44px;
        justify-content: flex-start !important;
    }

    /* Mail header actions on mobile */
    .mail-head-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .mail-info-trigger {
        width: 100%;
        justify-content: center;
    }

    /* Responsive Mobile Card Tables: Users, Audit Log, Receipts, Category Items, Receipt Items */
    .users-admin-table,
    .audit-log-table,
    .receipts-table,
    .category-items-table,
    .receipt-items-table {
        display: block !important;
        width: 100% !important;
    }

    .users-admin-table thead,
    .audit-log-table thead,
    .receipts-table thead,
    .category-items-table thead,
    .receipt-items-table thead {
        display: none !important;
    }

    .users-admin-table tbody,
    .audit-log-table tbody,
    .receipts-table tbody,
    .category-items-table tbody,
    .receipt-items-table tbody {
        display: grid !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .card-flush > .table-wrap {
        padding: 12px !important;
        overflow-x: visible !important;
    }

    .users-admin-table tbody tr,
    .audit-log-table tbody tr,
    .receipts-table tbody tr,
    .category-items-table tbody tr,
    .receipt-items-table tbody tr {
        display: grid !important;
        gap: 8px !important;
        padding: 13px 14px !important;
        border: 1px solid var(--border) !important;
        border-radius: 13px !important;
        background: var(--surface-2) !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .users-admin-table tbody td,
    .audit-log-table tbody td,
    .receipts-table tbody td,
    .category-items-table tbody td,
    .receipt-items-table tbody td {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 10px !important;
        padding: 0 !important;
        border: 0 !important;
        text-align: right !important;
        white-space: normal !important;
        min-width: 0 !important;
        max-width: 100% !important;
        flex-wrap: wrap !important;
    }

    .users-admin-table tbody td[data-label]::before,
    .audit-log-table tbody td[data-label]::before,
    .receipts-table tbody td[data-label]::before,
    .category-items-table tbody td[data-label]::before,
    .receipt-items-table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: 11.5px;
        font-weight: 650;
        color: var(--muted);
        text-align: left;
        margin-right: auto;
        flex-shrink: 0;
    }

    /* Users table mobile card specifics */
    .users-admin-table td.user-col-id {
        display: none !important;
    }

    .user-mobile-id {
        display: inline !important;
    }

    .users-admin-table td.user-col-info {
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        padding-bottom: 9px !important;
        border-bottom: 1px solid var(--border) !important;
    }

    .users-admin-table td.user-col-info::before {
        display: none !important;
    }

    .user-cell-main {
        width: 100%;
        display: grid;
        gap: 4px;
    }

    .user-primary-email {
        word-break: break-all;
    }

    .user-cell-senders {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-top: 2px;
    }

    .user-cell-senders .mail-sender-pill {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-badges-col {
        display: inline-flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        justify-content: flex-end !important;
    }

    .user-login-meta {
        text-align: right;
    }

    .users-admin-table td.user-col-actions {
        padding-top: 8px !important;
        border-top: 1px solid var(--border) !important;
    }

    .user-admin-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-end;
    }

    /* Audit log mobile card specifics */
    .audit-log-table td.audit-col-details {
        word-break: break-word;
    }

    /* Receipts table mobile card specifics */
    .receipts-table td.receipt-col-file {
        flex-direction: column !important;
        align-items: stretch !important;
        text-align: left !important;
        padding-bottom: 9px !important;
        border-bottom: 1px solid var(--border) !important;
    }

    .receipts-table td.receipt-col-file::before {
        display: none !important;
    }

    /* Category & Receipt items mobile card specifics */
    .category-items-table td.product,
    .receipt-items-table td.product {
        font-weight: 650;
        text-align: left !important;
        padding-bottom: 6px !important;
        border-bottom: 1px solid var(--border) !important;
    }

    .category-items-table td.cat-col-select,
    .receipt-items-table td.cat-col-select {
        padding-top: 6px !important;
        border-top: 1px solid var(--border) !important;
    }
}

.copy-email-pill {
    flex-wrap: nowrap !important;
}

.copy-email-code {
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-email-badge {
    white-space: nowrap !important;
    flex-shrink: 0;
}

/* Weekly period navigation label & subtitle */
.period-label-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.period-sub {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.01em;
}

/* Receipt items header & inline item editing + learned rules (v33) */
.receipt-items-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.receipt-items-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.item-product-cell {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.item-name-btn {
    appearance: none;
    background: transparent;
    border: none;
    padding: 2px 4px;
    margin: -2px -4px;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.item-name-btn:hover,
.item-name-btn:focus-visible {
    background: var(--surface-alt, rgba(59, 130, 246, 0.08));
    color: var(--primary, #2563eb);
    outline: none;
}

.item-inline-edit-icon {
    width: 14px;
    height: 14px;
    opacity: 0.45;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.item-name-btn:hover .item-inline-edit-icon {
    opacity: 0.95;
}

.item-learned-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.14);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.28);
    white-space: nowrap;
}

.item-learned-badge svg {
    width: 12px;
    height: 12px;
}

.item-raw-sub {
    display: block;
    font-size: 0.76rem;
    margin-top: 2px;
}

.learned-rules-card summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
}

.learned-rules-summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.learned-rules-hint {
    font-size: 0.82rem;
    font-weight: 400;
}

.learned-rules-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.learned-rule-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-alt, rgba(148, 163, 184, 0.08));
    border: 1px solid var(--border);
}

.learned-rule-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
}

.learned-rule-arrow {
    color: var(--muted);
}

.learned-rule-cat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.learned-rule-hits {
    font-size: 0.76rem;
}

/* Universal Modal & Dialog Polish (v34) */
dialog.preview-dialog,
dialog.share-dialog,
dialog.item-edit-dialog,
dialog.mail-info-dialog {
    position: fixed !important;
    inset: 0 !important;
    margin: auto !important;
    padding: 0 !important;
    border: 1px solid var(--border-2, var(--border)) !important;
    border-radius: 20px !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65) !important;
    overflow: hidden !important;
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)) !important;
}

dialog.preview-dialog[open],
dialog.share-dialog[open],
dialog.item-edit-dialog[open],
dialog.mail-info-dialog[open] {
    display: flex !important;
    flex-direction: column !important;
}

dialog.preview-dialog::backdrop,
dialog.share-dialog::backdrop,
dialog.item-edit-dialog::backdrop,
dialog.mail-info-dialog::backdrop {
    background: rgba(8, 12, 22, 0.72) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
}

dialog.item-edit-dialog,
dialog.mail-info-dialog {
    width: min(500px, calc(100vw - 24px)) !important;
    height: fit-content !important;
}

dialog.share-dialog:not(.item-edit-dialog) {
    width: min(540px, calc(100vw - 24px)) !important;
    height: fit-content !important;
}

dialog.preview-dialog:not(.item-edit-dialog):not(.mail-info-dialog) {
    width: min(860px, calc(100vw - 24px)) !important;
    height: min(84dvh, 780px) !important;
}

/* Item Edit / Add Modal */
.item-dialog-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 0;
    margin: 0;
}

.item-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.item-dialog-head .dialog-head-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.item-dialog-head .eyebrow-muted {
    margin: 0;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--primary);
}

.item-dialog-head h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.item-raw-pill {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 4px 0 0;
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--muted);
    width: fit-content;
    max-width: 100%;
}

.item-raw-pill[hidden] {
    display: none !important;
}

.item-raw-pill strong {
    color: var(--text);
    font-weight: 650;
}

.dialog-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
}

.item-dialog-body {
    padding: 16px 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
}

.item-dialog-body .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    min-width: 0;
}

.item-dialog-body .field > span {
    font-size: 13px;
    font-weight: 650;
    line-height: 1.25;
    color: var(--text-2, var(--text));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-dialog-body .field input,
.item-dialog-body .field select {
    height: 42px;
    padding: 0 13px;
    border-radius: 11px;
    font-size: 15px;
    width: 100%;
    box-sizing: border-box;
}

.item-edit-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 12px !important;
    align-items: end !important;
    margin: 0 !important;
}

.item-check-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13.5px;
    line-height: 1.35;
    margin: 0;
}

.item-check-row input[type="checkbox"] {
    margin-top: 2px;
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.item-check-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.item-check-text strong {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 650;
    color: var(--text);
}

.item-check-text strong svg {
    width: 15px;
    height: 15px;
    color: #8b5cf6;
    flex-shrink: 0;
}

.item-check-text small {
    font-size: 12px;
    line-height: 1.35;
}

.item-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}

.item-dialog-actions .button {
    height: 40px;
    padding: 0 14px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 650;
    flex: 0 0 auto;
}

.item-dialog-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Mail Info Modal internal scroll & footer polish */
.mail-info-modal-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: 0;
}

.mail-info-modal-head {
    flex-shrink: 0;
}

.mail-info-modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
}

.mail-info-modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 720px) {
    .receipt-items-table td.item-col-actions {
        padding-top: 6px !important;
        border-top: 1px solid var(--border) !important;
    }

    .item-dialog-head {
        padding: 16px 16px 12px;
    }

    .item-dialog-body {
        padding: 14px 16px;
        gap: 12px;
    }

    .item-dialog-actions {
        padding: 12px 16px;
    }
}
