:root {
    --bg: #f4f6f8;
    --card: #fff;
    --border: #e5e7eb;
    --text: #1e293b;
    --muted: #94a3b8;
    --faint: #c3cad3;
    --purple: #7c5cff;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 520px;
    margin: 0 auto;
}

.app-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: calc(20px + env(safe-area-inset-top)) 20px 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.header-actions form {
    margin: 0;
}

.btn-logout {
    all: unset;
    cursor: pointer;
    padding: 7px 12px;
    border-radius: 9px;
    background: #fdecf1;
    color: #e0507a;
    font-size: 11px;
    font-weight: 600;
}

.btn-logout:focus-visible {
    outline: 2px solid var(--purple);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 34px;
    height: 34px;
}

.brand-title {
    font-size: 20px;
    font-weight: 600;
}

.brand-sub {
    margin-left: 4px;
    font-size: 10.5px;
    font-weight: 400;
    color: var(--faint);
}

.brand-company {
    font-size: 13px;
    color: var(--muted);
}

.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 0 16px 16px;
}

.card {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
}

.total {
    text-align: center;
}

.total-count {
    font-size: 28px;
    font-weight: 700;
}

.total-label {
    margin-top: 2px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--muted);
}

.section-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: var(--muted);
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.status {
    padding: 12px;
    border-radius: 12px;
}

.status-count {
    font-size: 18px;
    font-weight: 700;
}

.status-label {
    font-size: 11px;
    font-weight: 500;
}

.status.pending { background: #fff4e0; color: #c78a1e; }
.status.submitted { background: #eafaf8; color: #22b8a3; }
.status.approved { background: #e8f0fe; color: #2f6fed; }
.status.rejected { background: #fdeaf0; color: #e0507a; }

.login-page {
    gap: 22px;
    padding: calc(28px + env(safe-area-inset-top)) 20px 24px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 9px;
}

.login-logo {
    width: 28px;
    height: 28px;
}

.login-wordmark {
    font-size: 15px;
    font-weight: 700;
}

.login-wordmark span {
    font-weight: 400;
}

.login-heading {
    text-align: center;
}

.login-title {
    margin-bottom: 4px;
    font-size: 19px;
    font-weight: 600;
}

.login-subtitle {
    font-size: 12.5px;
    color: var(--muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--muted);
}

.field-input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font: 500 13px 'Poppins', system-ui, sans-serif;
}

.field-input:focus {
    outline: none;
    border-color: var(--purple);
}

.company-picker {
    position: relative;
}

.company-current,
.company-option {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.company-current {
    width: 100%;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}

.company-picker.open .company-current,
.company-current:focus-visible {
    border-color: var(--purple);
}

.company-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
}

.company-avatar.small {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    font-size: 9.5px;
}

.company-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
}

.company-chevron {
    font-size: 12px;
    color: var(--muted);
    transition: transform .15s;
}

.company-picker.open .company-chevron {
    transform: rotate(180deg);
}

.company-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    box-shadow: 0 12px 28px rgba(20, 25, 40, .14);
}

.company-menu[hidden] {
    display: none;
}

.company-option {
    gap: 9px;
    padding: 9px 8px;
    border-radius: 8px;
}

.company-option .company-name {
    font-size: 12px;
}

.company-option[aria-selected="true"],
.company-option:hover,
.company-option:focus-visible {
    background: var(--bg);
}

.btn-signin {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 0;
    border: 0;
    border-radius: 11px;
    background: var(--purple);
    color: #fff;
    font: 600 14px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

.btn-signin:disabled {
    background: #a99dfa;
}

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.login-error {
    padding: 10px 12px;
    border-radius: 9px;
    background: #fdecf1;
    color: #e0507a;
    font-size: 12px;
    font-weight: 500;
}

.message-page {
    justify-content: center;
    padding: 24px 16px;
}

.message-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.message-title {
    font-size: 16px;
    font-weight: 600;
}

.message-text {
    font-size: 13px;
    color: var(--muted);
}

.btn-primary {
    margin-top: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    background: var(--purple);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.action-bar {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--card);
}

.action {
    all: unset;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 2px;
}

.action:focus-visible {
    outline: 2px solid var(--purple);
    border-radius: 10px;
}

.action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    font-size: 17px;
}

.action-icon.teal { background: #eafaf8; }
.action-icon.purple { background: #f4f0ff; }
.action-icon.orange { background: #fff4e8; }
.action-icon.gray { background: #eef0f3; }

.action-label {
    font-size: 10px;
    font-weight: 600;
    text-align: center;
}

/* Quick Scan options: a sheet that slides up from the bottom */
.sheet {
    width: 100%;
    max-width: 520px;
    margin: auto auto 0;
    padding: 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    background: var(--card);
    color: var(--text);
}

.sheet[open] {
    animation: sheet-up .2s ease-out;
}

.sheet::backdrop {
    background: rgba(15, 23, 42, .45);
}

.sheet[open]::backdrop {
    animation: fade-in .2s ease-out;
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
}

@keyframes fade-in {
    from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sheet[open],
    .sheet[open]::backdrop {
        animation: none;
    }
}

/* Fills the whole sheet, so a tap that lands on the sheet itself was on the dimmed page */
.sheet-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
}

.sheet-handle {
    width: 36px;
    height: 4px;
    margin: 0 auto 6px;
    border-radius: 2px;
    background: var(--border);
}

.sheet-title {
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}

.sheet-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 12px;
    background: #f8f9fb;
    color: inherit;
    text-decoration: none;
}

.sheet-option:active {
    background: #eef0f3;
}

.sheet-option:focus-visible,
.sheet-cancel:focus-visible {
    outline: 2px solid var(--purple);
}

.sheet-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    font-size: 18px;
}

.sheet-icon.teal { background: #eafaf8; }
.sheet-icon.purple { background: #f4f0ff; }

.sheet-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sheet-option-title {
    font-size: 13px;
    font-weight: 600;
}

.sheet-option-sub {
    font-size: 11.5px;
    color: var(--muted);
}

.sheet-cancel {
    margin-top: 4px;
    padding: 12px 0;
    border: 0;
    border-radius: 11px;
    background: #eef0f3;
    color: #64748b;
    font: 600 12.5px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(90px + env(safe-area-inset-bottom));
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--text);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.toast.show {
    opacity: 1;
}

/* Hidden always wins, also over the display set by the classes below */
[hidden] {
    display: none !important;
}

/* Amount charts of the home page, as in the prototype; only for looking. Text a little larger for older eyes */

.pie-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px;
}

.pie {
    position: relative;
    flex: 0 0 auto;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #eef0f3;
}

.pie-hole {
    position: absolute;
    inset: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--card);
    font-size: 13px;
    font-weight: 700;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
}

.legend-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-right: 2px;
    border-radius: 3px;
}

.legend-dot.submitted { background: #22b8a3; }
.legend-dot.approved { background: #2f6fed; }

.legend-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.legend-amount {
    flex: 0 0 auto;
    white-space: nowrap;
}

.bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
}

.bar-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-amount {
    flex: 0 0 auto;
    font-weight: 600;
}

.bar-track {
    height: 8px;
    overflow: hidden;
    border-radius: 5px;
    background: #eef0f3;
}

.bar {
    height: 100%;
    border-radius: 5px;
}

.bar.category { background: var(--purple); }
.bar.contact { background: #22b8a3; }
.bar.analysis { background: #2f6fed; }

.chart-empty,
.chart-note {
    font-size: 12px;
    color: var(--muted);
}

/* Date filter of the home page and My Documents, as in the prototype; text a little larger for older eyes */

.date-filter {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0 16px 12px;
}

.date-presets {
    display: flex;
    gap: 8px;
}

.date-preset {
    flex: 1;
    padding: 8px 0;
    border-radius: 9px;
    background: #eef0f3;
    color: #64748b;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.date-preset.active {
    background: #f4f0ff;
    color: var(--purple);
}

.date-preset:focus-visible {
    outline: 2px solid var(--purple);
}

.date-range {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Height set so an empty date (iPhone shows nothing in it) keeps its size */
.date-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--card);
    color: var(--text);
    font: 500 13px 'Poppins', system-ui, sans-serif;
}

.date-input:focus {
    outline: none;
    border-color: var(--purple);
}

.date-to {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

/* Documents: list, upload form, details */

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(20px + env(safe-area-inset-top)) 20px 12px;
}

.page-heading {
    flex: 1;
    min-width: 0;
}

.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    font-size: 16px;
    text-decoration: none;
}

button.btn-back {
    padding: 0;
    font-family: inherit;
    cursor: pointer;
}

.page-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    font-weight: 600;
}

.page-subtitle {
    font-size: 12px;
    color: var(--muted);
}

.btn-new {
    flex: 0 0 auto;
    padding: 7px 12px;
    border-radius: 9px;
    background: #f4f0ff;
    color: var(--purple);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

.doc-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field-hint {
    font-size: 11px;
    color: var(--muted);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

textarea.field-input {
    min-height: 60px;
    resize: vertical;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
}

.chip input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.chip.selected {
    border-color: var(--purple);
    background: #f4f0ff;
    color: var(--purple);
    font-weight: 600;
}

.chip:focus-within {
    outline: 2px solid var(--purple);
    outline-offset: 1px;
}

.btn-file {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1px dashed #c9cfd8;
    border-radius: 10px;
    background: var(--bg);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.btn-file:focus-within {
    outline: 2px solid var(--purple);
}

/* Read with AI on the edit page, under the pages */
.btn-read {
    color: var(--purple);
    font-family: inherit;
}

.btn-read:disabled {
    color: var(--muted);
}

/* Kept in the page (not display none) so tapping the label opens the camera on every phone */
.file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.pages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}

.pages.large {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.page-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    text-decoration: none;
}

/* The top of a receipt shows the shop's name */
.page-thumb img,
.doc-thumb img {
    object-position: top;
}

.page-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.page-pdf {
    font-size: 12px;
    font-weight: 700;
    color: #e0507a;
}

/* A PDF's file name under its label, so a batch of PDFs can be told apart */
.page-name {
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 5px;
    overflow: hidden;
    font-size: 9.5px;
    color: var(--muted);
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: rgba(30, 41, 59, .75);
    color: #fff;
    font-size: 15px;
    line-height: 24px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-actions form {
    margin: 0;
}

a.btn-signin {
    text-decoration: none;
}

.btn-secondary,
.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 0;
    border-radius: 11px;
    font: 600 13px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

.btn-secondary {
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
}

.btn-danger {
    border: 0;
    background: #fdecf1;
    color: #e0507a;
}

.btn-secondary:disabled {
    color: var(--muted);
}

.spinner.dark {
    border-color: rgba(30, 41, 59, .2);
    border-top-color: var(--text);
}

.run-status {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.notice {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.notice.success { background: #eafaf8; color: #13846f; }
.notice.info { background: #e8f0fe; color: #2f6fed; }
.notice.warning { background: #fff4e0; color: #a86b0c; }
.notice.rejected { background: #fdecf1; color: #c0365e; }

.tabs {
    display: flex;
    gap: 6px;
    margin: 0 -16px;
    padding: 0 16px 2px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab {
    flex: 0 0 auto;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.tab.active {
    border-color: var(--text);
    background: var(--text);
    color: #fff;
}

.tab-count {
    margin-left: 5px;
    opacity: .65;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.doc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: inherit;
    text-decoration: none;
}

.doc-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 56px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.doc-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.doc-title,
.doc-reason {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-title {
    font-size: 13px;
    font-weight: 600;
}

.doc-meta {
    font-size: 11px;
    color: var(--muted);
}

.doc-reason {
    font-size: 11px;
    color: #e0507a;
}

.doc-todo {
    font-size: 11px;
    color: #c78a1e;
}

.doc-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 0 0 auto;
}

.doc-amount {
    font-size: 13px;
    font-weight: 700;
}

.doc-status {
    display: inline-block;
    flex: 0 0 auto;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.doc-status-draft { background: #fff4e0; color: #c78a1e; }
.doc-status-submitted { background: #eafaf8; color: #22b8a3; }
.doc-status-approved { background: #e8f0fe; color: #2f6fed; }
.doc-status-rejected { background: #fdeaf0; color: #e0507a; }

.detail-list {
    display: flex;
    flex-direction: column;
    margin: 0;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.detail-list div:last-child {
    border-bottom: 0;
}

.detail-list dt {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    font-size: 12.5px;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

.history {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
}

.history-meta,
.history-remark {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

/* Pages in steps (new document: the pages, then Review Details; Bulk Capture: setup, then the receipts), and Review Batch */

.page-step {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.setup-intro {
    margin: 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--muted);
}

/* Opens the camera or the file picker */
.capture-box {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 14px;
    border: 2px dashed #d9dee5;
    border-radius: 14px;
    background: #fafbfc;
    text-align: center;
    cursor: pointer;
}

.capture-box:focus-within {
    outline: 2px solid var(--purple);
}

.capture-icon {
    font-size: 22px;
}

.capture-title {
    font-size: 12.5px;
    font-weight: 600;
}

.capture-hint {
    font-size: 11px;
    color: var(--muted);
}

/* The page's main button stays at the bottom of the screen, like the home page's action bar */
.sticky-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: auto -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--card);
}

.sticky-actions form {
    margin: 0;
}

/* Quick Scan, as in the prototype: Reading document…, Review Details, Posting Account, done */

.reading-step {
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
}

.reading-spinner {
    width: 40px;
    height: 40px;
    margin-bottom: 4px;
    border: 4px solid #eafaf8;
    border-top-color: #22d3c5;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.reading-title {
    font-size: 15px;
    font-weight: 600;
}

.reading-hint {
    font-size: 13px;
    color: var(--muted);
}

/* The steps are in one form, which fills the screen so each step's buttons sit at the bottom */
.review-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.review-body {
    gap: 14px;
}

/* The uploaded photo, whole; opens it full size */
.review-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 140px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #eef0f3, #eef0f3 8px, #f6f7f9 8px, #f6f7f9 16px);
    color: inherit;
    text-decoration: none;
}

.review-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.review-thumb-name {
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--muted);
}

.review-type-label {
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.type-toggle {
    display: flex;
    gap: 8px;
}

.type-option {
    position: relative;
    flex: 1;
    min-width: 0;
    padding: 10px 4px;
    border-radius: 9px;
    background: #f4f6f8;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
}

.type-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.type-option:focus-within {
    outline: 2px solid var(--purple);
}

.type-option.receipt.selected { background: #eafaf8; color: #22b8a3; }
.type-option.invoice.selected { background: #f4f0ff; color: var(--purple); }
.type-option.sales.selected { background: #fff4e8; color: #d97706; }

/* Vendor: the TheApps contacts found as the staff type, under the box */
.contact-picker {
    position: relative;
}

.contact-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 15;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .12);
}

.contact-list[hidden] {
    display: none;
}

.contact-option {
    all: unset;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 6px;
    border-radius: 7px;
    cursor: pointer;
}

.contact-option:hover,
.contact-option:focus-visible {
    background: #f4f0ff;
}

.contact-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
}

.contact-code {
    font-size: 11px;
    color: var(--muted);
}

.contact-empty {
    padding: 8px 6px;
    font-size: 12px;
    color: var(--muted);
}

.contact-hint.picked {
    color: #13846f;
}

/* Pending and Continue side by side */
.review-actions {
    flex-direction: row;
    gap: 10px;
}

.review-actions > button {
    flex: 1;
}

.btn-pending {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 0;
    border: 1.5px solid #c78a1e;
    border-radius: 11px;
    background: var(--card);
    color: #c78a1e;
    font: 600 14px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

#postButton:disabled {
    background: #c9cfd6;
}

.choice-hint {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

.choice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* A posting account to pick, with the prototype's round dot */
.choice-card {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--card);
    cursor: pointer;
}

.choice-card input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.choice-card:focus-within {
    outline: 2px solid var(--purple);
}

.choice-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.choice-name {
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.choice-code {
    font-size: 12px;
    color: var(--muted);
}

.choice-dot {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    border: 2px solid #d9dee5;
    border-radius: 50%;
}

.choice-card.posting.selected { border: 2px solid var(--purple); }
.choice-card.posting.selected .choice-dot { border-color: var(--purple); background: var(--purple); }

/* Left out by the account search; the chosen one always stays */
.choice-card.filtered-out {
    display: none;
}

/* A company has many accounts: the list scrolls in its own box, so Analysis 1 and 2 stay in reach below it */
.choice-list.scroll {
    max-height: 50vh;
    margin: -2px;
    padding: 2px;
    overflow-y: auto;
}

/* My Documents, as in the prototype: folders, then a folder's documents with filters, sections, the viewer and Bulk Post.
   Text a little larger than the prototype's for older eyes. */

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.folder-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: inherit;
    text-decoration: none;
}

.folder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 18px;
}

.folder-icon.folder-1 { background: #eafaf8; }
.folder-icon.folder-2 { background: #f4f0ff; }
.folder-icon.folder-3 { background: #fff4e8; }
.folder-icon.folder-4 { background: #e8f0fe; }

.folder-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.folder-name {
    font-size: 14px;
    font-weight: 600;
}

.folder-meta {
    font-size: 12px;
    color: var(--muted);
}

.folder-chevron {
    font-size: 18px;
    color: var(--faint);
}

.view-toggle {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    padding: 2px;
    border-radius: 8px;
    background: #eef0f3;
}

.view-toggle button {
    padding: 5px 9px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

.view-toggle button[aria-pressed="true"] {
    background: var(--card);
}

.folder-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 16px 12px;
}

.folder-search {
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: #eef0f3;
    color: var(--text);
    font: 400 13px 'Poppins', system-ui, sans-serif;
}

.folder-search:focus {
    outline: 2px solid var(--purple);
}

.filter-row {
    display: flex;
    gap: 8px;
}

.filter-row > * {
    flex: 1;
    min-width: 0;
}

.filter-select {
    width: 100%;
    height: 38px;
    padding: 0 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--card);
    color: var(--text);
    font: 500 13px 'Poppins', system-ui, sans-serif;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

button.filter-select {
    cursor: pointer;
}

/* The contact filter: tick any number of them */
.multi-filter {
    position: relative;
}

.multi-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 15;
    max-height: 240px;
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    box-shadow: 0 8px 20px rgba(15, 23, 42, .12);
}

.multi-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 6px;
    border-radius: 7px;
    cursor: pointer;
}

.multi-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.multi-box {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 1.5px solid #c9cfd6;
    border-radius: 4px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.multi-option input:checked + .multi-box {
    border-color: var(--purple);
    background: var(--purple);
}

.multi-option input:checked + .multi-box::after {
    content: "✓";
}

.multi-option input:focus-visible + .multi-box {
    outline: 2px solid var(--purple);
}

.multi-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
}

.multi-empty {
    padding: 8px 6px;
    font-size: 12px;
    color: var(--muted);
}

.multi-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.multi-actions button {
    flex: 1;
    padding: 8px 6px;
    border: 0;
    border-radius: 7px;
    font: 600 12px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

.multi-clear { background: transparent; color: #e0507a; }
.multi-done { background: var(--purple); color: #fff; }

.folder-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.folder-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.folder-section-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.folder-section-title.pending { color: #c78a1e; }
.folder-section-title.rejected { color: #e0507a; }
.folder-section-title.posted { color: #22b8a3; }
.folder-section-title.approved { color: #2f6fed; }

.link-button {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--purple);
    font: 600 12px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

.folder-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* List view: one row each */
.folder-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}

.folder-item.selected {
    border-color: #22b8a3;
}

.item-check {
    position: relative;
    flex: 0 0 auto;
    cursor: pointer;
}

.item-check input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.item-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1.5px solid #c9cfd6;
    border-radius: 6px;
    background: var(--card);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.item-check input:checked + .item-box {
    border-color: #22b8a3;
    background: #22b8a3;
}

.item-check input:checked + .item-box::after {
    content: "✓";
}

.item-check input:focus-visible + .item-box {
    outline: 2px solid var(--purple);
}

.item-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border-radius: 8px;
    background: repeating-linear-gradient(45deg, #eef0f3, #eef0f3 6px, #f6f7f9 6px, #f6f7f9 12px);
}

.item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.item-thumb-status {
    display: none;
}

.item-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 2px;
    min-width: 0;
}

.item-name {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.item-meta {
    font-size: 12px;
    color: var(--muted);
}

.item-tag {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--purple);
}

.item-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    flex: 0 0 auto;
}

.item-figures {
    display: flex;
    align-items: center;
    gap: 6px;
}

.item-amount {
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #22b8a3;
    cursor: pointer;
}

.icon-button:active {
    background: #eafaf8;
}

.icon-button:focus-visible {
    outline: 2px solid var(--purple);
}

/* Icon view: two cards a row, the picture large with the tick and the status on it */
.icon-view .folder-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.icon-view .folder-item {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px;
}

.icon-view .item-check {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 1;
}

.icon-view .item-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1.2;
    border-radius: 10px;
}

.icon-view .item-thumb-status {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-block;
}

.icon-view .item-name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.icon-view .item-contact,
.icon-view .item-figures .doc-status {
    display: none;
}

.icon-view .item-side {
    align-items: center;
}

.icon-view .item-figures {
    align-self: flex-start;
}

/* The prototype's bar once pending documents are ticked */
.select-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--card);
}

.select-count {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
}

.btn-post-selected {
    padding: 11px 18px;
    border: 0;
    border-radius: 10px;
    background: #22b8a3;
    color: #fff;
    font: 600 14px 'Poppins', system-ui, sans-serif;
    cursor: pointer;
}

/* The prototype's document viewer */
.viewer {
    width: calc(100% - 48px);
    max-width: 420px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: var(--card);
    color: var(--text);
}

.viewer::backdrop {
    background: rgba(15, 23, 42, .5);
}

.viewer-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.viewer-thumb {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1.2;
    max-height: 50vh;
    overflow: hidden;
    border-radius: 10px;
    background: repeating-linear-gradient(45deg, #eef0f3, #eef0f3 8px, #f6f7f9 8px, #f6f7f9 16px);
}

.viewer-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.viewer-status {
    position: absolute;
    top: 8px;
    right: 8px;
}

.viewer-name {
    font-size: 14px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.viewer-meta {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
}

.viewer-amount {
    margin-top: 6px;
    font-size: 14px;
    font-weight: 600;
}

.btn-viewer-post,
.btn-viewer-close {
    display: block;
    padding: 12px 0;
    border: 0;
    border-radius: 10px;
    font: 600 14px 'Poppins', system-ui, sans-serif;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-viewer-post { background: #22b8a3; color: #fff; }
.btn-viewer-close { background: var(--purple); color: #fff; }
.btn-viewer-close.muted { background: #eef0f3; color: #475569; }

.viewer-note {
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
}

/* Bulk Post: what is being posted */
.bulk-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 140px;
    overflow: auto;
}

.bulk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    background: #f8f9fb;
    font-size: 13px;
}

.bulk-contact {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.bulk-amount {
    flex: 0 0 auto;
    font-weight: 600;
}

.payable-note {
    padding: 14px;
    border: 1px solid #e6ddff;
    border-radius: 11px;
    background: #f4f0ff;
}

.payable-title {
    margin-bottom: 2px;
    font-size: 13px;
    font-weight: 600;
    color: var(--purple);
}

.payable-text {
    font-size: 13px;
    line-height: 1.6;
    color: #64748b;
}

.done-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 0 8px;
    text-align: center;
}

.done-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 26px;
}

.done-icon.pending { background: #fff4e0; color: #c78a1e; }
.done-icon.posted { background: #eafaf8; color: #22d3c5; }

.done-title {
    font-size: 16px;
    font-weight: 600;
}

.done-detail {
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.btn-done {
    margin-top: 8px;
    padding: 12px 28px;
    border-radius: 11px;
    background: var(--purple);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

/* Review Batch: the row opens the receipt, the bin deletes it */
.batch-row.editable {
    padding-right: 4px;
}

.batch-link {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

.batch-row form {
    margin: 0;
}

.btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #e0507a;
    cursor: pointer;
}

.btn-remove:active {
    background: #fdecf1;
}

.btn-remove:focus-visible {
    outline: 2px solid var(--purple);
}
