/* ==========================================================================
   Immocierge – Dark Premium Theme
   ========================================================================== */

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:          #0b0d14;
    --bg-sidebar:  #13161f;
    --bg-card:     #1a1d29;
    --bg-card-hi:  #20243226;
    --bg-input:    #232637;
    --bg-hover:    #2a2e42;
    --text:        #edeef3;
    --text-muted:  #8a8fa8;
    --accent:      #d4b05a;
    --accent-hover:#e6c171;
    --accent-soft: rgba(212,176,90,0.12);
    --pos:         #5cc28f;
    --neg:         #ed6b6b;
    --border:      #262a3d;
    --border-soft: rgba(255,255,255,0.06);
    --radius:      14px;
    --radius-sm:   10px;
    --radius-xs:   6px;
    --shadow-sm:   0 1px 2px rgba(0,0,0,0.25);
    --shadow-md:   0 4px 14px rgba(0,0,0,0.28), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-lg:   0 10px 30px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.3);
    --sidebar-w:   260px;
    --tap:         44px;
    --font:        'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }

/* ---- Typography ---- */
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem;  font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 0.8rem;  font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
p  { margin-bottom: 0.75rem; }
small { font-size: 0.85rem; color: var(--text-muted); }
hgroup { margin-bottom: 0.5rem; }
hgroup p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

/* ---- Buttons ---- */
button, .btn, a[role="button"] {
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font); font-size: 0.9rem; font-weight: 600;
    padding: 0.65rem 1.4rem; border-radius: var(--radius-sm);
    border: 1px solid transparent; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s,
                box-shadow 0.15s, transform 0.08s;
    text-decoration: none; line-height: 1.4;
    min-height: var(--tap);
    box-shadow: var(--shadow-sm);
}
button, .btn-primary, a[role="button"] {
    background: var(--accent); color: var(--bg); border-color: var(--accent);
}
button:hover, .btn-primary:hover, a[role="button"]:hover {
    background: var(--accent-hover); border-color: var(--accent-hover);
    box-shadow: var(--shadow-md);
}
button:active, .btn-primary:active, a[role="button"]:active {
    transform: translateY(1px);
    box-shadow: var(--shadow-sm);
}
.secondary, button.secondary, a[role="button"].secondary {
    background: transparent; color: var(--accent); border-color: var(--accent);
    box-shadow: none;
}
.secondary:hover, button.secondary:hover, a[role="button"].secondary:hover {
    background: var(--accent-soft);
    box-shadow: var(--shadow-sm);
}
.outline, button.outline {
    background: transparent; border-color: var(--border); color: var(--text-muted);
    box-shadow: none;
}
.outline:hover, button.outline:hover {
    border-color: var(--text-muted); color: var(--text);
    box-shadow: var(--shadow-sm);
}
button.secondary.outline {
    background: transparent; border-color: var(--border); color: var(--text-muted);
    box-shadow: none;
}
button.secondary.outline:hover {
    border-color: var(--neg); color: var(--neg);
    box-shadow: var(--shadow-sm);
}

/* ---- Forms ---- */
label {
    display: block; font-size: 0.85rem; font-weight: 500;
    color: var(--text-muted); margin-bottom: 1rem;
}
/* The author `label { display: block }` rule above overrides the UA
   default for the `hidden` attribute, which would otherwise apply
   `display: none`. Restore that so elements with `hidden` actually
   disappear (used by the Buchhaltung period filter, the IMAP funnel,
   etc.). */
[hidden] { display: none !important; }
input, select, textarea {
    display: block; width: 100%; margin-top: 0.3rem;
    font-family: var(--font); font-size: 1rem;
    padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    min-height: var(--tap);
}
input:hover, select:hover, textarea:hover {
    border-color: var(--bg-hover);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="date"] { color-scheme: dark; }
select { appearance: auto; }
input[type="radio"], input[type="checkbox"] {
    display: inline-block; width: auto; margin-top: 0;
    padding: 0; min-height: 0;
    appearance: auto; -webkit-appearance: auto;
    accent-color: var(--accent);
}
textarea { resize: vertical; min-height: 5rem; }

/* ---- Grid ---- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-md);
}
.card h3 { margin-bottom: 0.75rem; }
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--accent); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; margin: -0.5rem; padding: 0.5rem; }
table {
    width: 100%; border-collapse: collapse;
    font-size: 0.9rem;
}
thead th {
    text-align: left; font-weight: 600; font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); padding: 0.7rem 0.75rem;
    border-bottom: 2px solid var(--border);
}
tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-hover); }
table .right { text-align: right; }
td.actions { display: flex; gap: 0.4rem; align-items: center; }
td.actions form { display: inline; margin: 0; }
td.actions button { padding: 0.35rem 0.7rem; font-size: 0.85rem; min-height: 34px; }
td.actions a {
    padding: 0.35rem 0.7rem; font-size: 0.85rem; min-height: 34px;
    border: 1px solid var(--border); border-radius: var(--radius-xs);
    color: var(--text-muted); display: inline-flex; align-items: center;
    transition: border-color 0.15s, color 0.15s;
}
td.actions a:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Layout (sidebar + content) ---- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-soft);
    padding: 1.5rem 1rem;
    position: sticky; top: 0; align-self: start;
    max-height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
    box-shadow: 1px 0 8px rgba(0,0,0,0.15);
}
.sidebar header { margin-bottom: 1.75rem; }
.sidebar .brand {
    font-weight: 700; font-size: 1.3rem;
    color: var(--accent); text-decoration: none;
    letter-spacing: -0.02em;
}
.sidebar header small { display: block; margin-top: 0.2rem; color: var(--text-muted); font-size: 0.8rem; }
.sidebar nav { flex: 1; }
.sidebar section { margin-bottom: 1.5rem; }
.sidebar h4 { margin: 0 0 0.4rem 0.5rem; }
.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 0.15rem; }
.sidebar li a {
    display: block; padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 0.9rem; transition: background 0.12s;
    border-left: 3px solid transparent;
}
.sidebar li a:hover { background: var(--bg-hover); }
.sidebar li.active a {
    background: var(--accent-soft);
    border-left-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}
.sidebar li a strong { display: block; font-weight: 500; }
.sidebar li a small { display: block; color: var(--text-muted); font-size: 0.8rem; }
.sidebar .add-menu { margin-top: 0.5rem; }
.sidebar .add-menu details summary {
    font-size: 0.9rem; padding: 0.5rem 0.75rem;
    cursor: pointer; list-style: none;
    color: var(--accent); font-weight: 600;
    border: 1px solid var(--accent); border-radius: var(--radius-sm);
    text-align: center; transition: background 0.15s;
}
.sidebar .add-menu details summary:hover { background: var(--accent-soft); box-shadow: var(--shadow-sm); }
.sidebar .add-menu details summary::-webkit-details-marker { display: none; }
.sidebar .add-menu details[open] summary { margin-bottom: 0.5rem; }
.sidebar .add-menu details ul { padding-left: 0; }
.sidebar .add-menu details li a { padding: 0.4rem 0.75rem; }
.sidebar footer {
    margin-top: auto; padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}
.sidebar footer button {
    width: 100%; font-size: 0.85rem; padding: 0.45rem;
}

.content {
    padding: 2rem 2.5rem;
    min-width: 0;
}

.menu-toggle {
    display: none; position: fixed;
    top: 0.75rem; left: 0.75rem; z-index: 100;
    min-width: var(--tap); min-height: var(--tap);
    padding: 0.5rem 0.85rem; border-radius: var(--radius-sm);
    background: var(--bg-sidebar); border: 1px solid var(--border);
    color: var(--text); font-size: 1.2rem;
    box-shadow: var(--shadow-md);
}

/* Backdrop when sidebar is open on mobile */
.nav-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 85; opacity: 0;
    transition: opacity 0.2s;
}
body.nav-open .nav-backdrop {
    display: block; opacity: 1;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        width: 85%; max-width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 90;
        box-shadow: 4px 0 30px rgba(0,0,0,0.5);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .content { padding: 3.75rem 1rem 1.25rem; }
    .card { padding: 1.1rem; border-radius: var(--radius-sm); }
    .summary-row { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1.05rem; }
    .page-header { margin-bottom: 1.25rem; }
    .sidebar li a { padding: 0.75rem 0.9rem; min-height: var(--tap); display: flex; align-items: center; }
}

/* ---- Page header / tabs ---- */
.page-header { margin-bottom: 1.75rem; }
.tabs {
    display: flex; gap: 0; margin-top: 0.75rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
    padding: 0.7rem 1.25rem; color: var(--text-muted);
    border-bottom: 2px solid transparent;
    font-size: 0.9rem; font-weight: 500;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
    min-height: var(--tap);
    display: inline-flex; align-items: center;
}
.tabs a:hover { color: var(--text); background: var(--bg-card-hi); }
.tabs a.active {
    color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}

/* ---- Flash messages ---- */
.flash {
    padding: 0.9rem 1.1rem; border-radius: var(--radius-sm);
    margin-bottom: 1.25rem; font-size: 0.9rem;
    border: 1px solid;
    box-shadow: var(--shadow-sm);
}
.flash-success {
    color: var(--pos); border-color: rgba(92,194,143,0.35);
    background: rgba(92,194,143,0.08);
}
.flash-error {
    color: var(--neg); border-color: rgba(237,107,107,0.35);
    background: rgba(237,107,107,0.08);
}
.flash-info {
    color: var(--accent); border-color: rgba(90,136,231,0.35);
    background: rgba(90,136,231,0.08);
}

/* ---- Summary row ---- */
.summary-row {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1rem; align-items: start;
}
.summary-row div {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-soft);
}
.summary-row div small { color: var(--text-muted); display: block; margin-bottom: 0.2rem; font-size: 0.8rem; }
.summary-row div strong { font-size: 1.15rem; }

/* ---- Tags ---- */
.tag {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 999px; font-size: 0.75rem;
    font-weight: 600; border: 1px solid;
}
.tag.pos { color: var(--pos); border-color: rgba(92,194,143,0.35); background: rgba(92,194,143,0.08); }
.tag.neg { color: var(--neg); border-color: rgba(237,107,107,0.35); background: rgba(237,107,107,0.08); }

/* ---- Utility ---- */
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--text-muted); font-style: italic; font-size: 0.9rem; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }

/* ---- Inline checkbox label ---- */
label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}
label.checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
}

/* ---- Auth pages ---- */
.auth-container {
    max-width: 440px; margin: 0 auto;
    padding: 6rem 1.5rem 2rem;
    display: flex; flex-direction: column; align-items: center;
    min-height: 100vh; justify-content: center;
}
.auth-brand {
    font-size: 1.8rem; font-weight: 700; color: var(--accent);
    margin-bottom: 2rem; letter-spacing: -0.02em;
}
.auth-card {
    background: var(--bg-card); border: 1px solid var(--border-soft);
    border-radius: var(--radius); padding: 2.25rem; width: 100%;
    box-shadow: var(--shadow-lg);
}
.auth-card hgroup { margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.4rem; }
.auth-card button { width: 100%; margin-top: 0.75rem; }
.auth-card p { text-align: center; margin-top: 1rem; }

/* ---- OCR status tags ---- */
.tag.ocr-done    { color: var(--pos); border-color: rgba(92,194,143,0.35); background: rgba(92,194,143,0.08); }
.tag.ocr-failed  { color: var(--neg); border-color: rgba(237,107,107,0.35); background: rgba(237,107,107,0.08); }
.tag.ocr-pending { color: var(--accent); border-color: rgba(212,176,90,0.35); background: var(--accent-soft); }

/* ---- Upload area / Drop zone ---- */
.upload-area, .drop-zone {
    border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 1.5rem; text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.upload-area:hover, .drop-zone:hover { border-color: var(--accent); }
.upload-area .btn, .drop-zone .btn { cursor: pointer; }
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(99,162,255,0.06);
}

/* ---- Document preview ---- */
.doc-preview-card { }
.doc-preview img {
    max-width: 100%; max-height: 500px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.doc-preview iframe {
    width: 100%; height: 500px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: #fff;
}

/* ---- OCR pre-fill banner ---- */
.ocr-banner {
    background: rgba(200,164,78,0.08);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--accent);
}

/* ---- Booking form: section titles ---- */
.section-title {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.section-title:first-of-type { margin-top: 0; }

/* ---- Booking form: segmented switch (Brutto/Netto) ---- */
.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem;
    background: var(--bg-input);
    margin-bottom: 1rem;
}
.segmented label {
    margin: 0;
    cursor: pointer;
    padding: 0;
}
.segmented label input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}
.segmented label span {
    display: inline-flex;
    align-items: center; justify-content: center;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: 999px;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    min-height: 36px;
}
.segmented label input:checked + span {
    background: var(--accent);
    color: var(--bg);
    box-shadow: var(--shadow-sm);
}
.upload-segmented { display: flex; width: 100%; }
.upload-segmented label { flex: 1; }
.upload-segmented label span { width: 100%; }

/* ---- Booking form: items table ---- */
.items-table {
    margin-top: 0.25rem;
}
.items-table thead th {
    padding: 0.5rem 0.75rem;
}
.items-table tbody td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
}
.items-table input, .items-table select {
    margin-top: 0;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}
.items-table input.right { text-align: right; }
.items-table .item-remove {
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
    line-height: 1;
}
.items-table tfoot td {
    border-bottom: none;
    padding-top: 0.5rem;
    padding-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.items-table tfoot tr.totals-row.strong td {
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border);
}

/* ---- Booking list: document-type tags ---- */
.tag.doctype-income        { color: var(--pos); border-color: var(--pos); }
.tag.doctype-expense       { color: var(--neg); border-color: var(--neg); }
.tag.doctype-income-red    { color: var(--neg); border-color: var(--neg);
                             background: rgba(224,85,85,0.08); }
.tag.doctype-expense-red   { color: var(--pos); border-color: var(--pos);
                             background: rgba(76,175,122,0.08); }
.tag.doctype-transfer      { color: var(--muted); border-color: var(--muted);
                             background: rgba(160,160,160,0.08); }

/* ---- Review status tags ---- */
.tag.review-auto         { color: var(--pos); border-color: rgba(92,194,143,0.35); background: rgba(92,194,143,0.08); }
.tag.review-plausible    { color: var(--accent); border-color: rgba(212,176,90,0.35); background: var(--accent-soft); }
.tag.review-needs-review { color: var(--neg); border-color: rgba(237,107,107,0.35); background: rgba(237,107,107,0.08); }
.tag.review-verified     { color: var(--pos); border-color: var(--pos); background: rgba(92,194,143,0.15); }

.review-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.review-filter .tag { text-decoration: none; cursor: pointer; opacity: 0.6; }
.review-filter .tag.active { opacity: 1; font-weight: 600; }
.review-filter .tag:hover { opacity: 0.9; }

/* ---- Booking form: SKR03 category helper ---- */
.category-help {
    margin: 0.75rem 0 1.25rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
}
.category-help summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.9rem;
    list-style: none;
    user-select: none;
}
.category-help summary::-webkit-details-marker { display: none; }
.category-help[open] summary { margin-bottom: 0.6rem; }
.category-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.category-list li { line-height: 1.5; }
.category-list code {
    display: inline-block;
    min-width: 3em;
    margin-right: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.82rem;
    color: var(--accent);
    background: rgba(200,164,78,0.12);
}
@media (max-width: 720px) {
    .category-list { grid-template-columns: 1fr; }
}

/* ---- IMAP accounts ---- */
.imap-table th,
.imap-table td { vertical-align: middle; }
.imap-table .actions { white-space: nowrap; }
.imap-table .actions button { margin-left: 0.25rem; }
details.imap-add {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
}
details.imap-add summary {
    cursor: pointer;
    color: var(--accent);
    list-style: none;
    user-select: none;
}
details.imap-add summary::-webkit-details-marker { display: none; }
details.imap-add[open] summary { margin-bottom: 0.85rem; }
details.imap-add label.checkbox { margin-top: 0.5rem; }

/* IMAP funnel: preview message + step containers */
#imap-preview-msg {
    margin: 0.75rem 0 0;
    padding: 0.5rem 0.85rem;
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-size: 0.9rem;
    background: rgba(200, 164, 78, 0.08);
}
#imap-preview-msg.error {
    border-left-color: #c45a5a;
    background: rgba(196, 90, 90, 0.12);
    color: #f3c2c2;
}
#imap-preview-msg.ok {
    border-left-color: #6ab26a;
    background: rgba(106, 178, 106, 0.12);
    color: #c8e6c8;
}
[data-imap-step="2"] #imap-folder-select {
    width: 100%;
}
[data-imap-step="2"] .form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ================================================================
   Upload tabs (Datei / Kamera)
   ================================================================ */
.upload-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}
.upload-tab-btn {
    background: none;
    border: none;
    color: var(--muted);
    padding: 0.35rem 0.9rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}
.upload-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ================================================================
   Camera tab: page thumbnails
   ================================================================ */
.page-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    min-height: 1rem;
}
.page-thumb {
    position: relative;
    width: 72px;
}
.page-thumb img {
    width: 72px;
    height: 96px;
    object-fit: cover;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: block;
}
.page-thumb-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    border: none;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}
.page-thumb-label {
    display: block;
    text-align: center;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.2rem;
}
.camera-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

/* ================================================================
   Crop modal
   ================================================================ */
.crop-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.crop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    max-width: 100%;
}
.crop-canvas {
    max-width: 92vw;
    max-height: 68vh;
    cursor: crosshair;
    border: 1px solid var(--border);
    touch-action: none;
}
.crop-buttons {
    display: flex;
    gap: 0.75rem;
}

/* ================================================================
   Bank transactions table
   ================================================================ */
.bank-tx-table .purpose-cell {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.amt-positive { color: #6ab26a; font-weight: 600; }
.amt-negative { color: #c45a5a; font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}
.pagination a {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border, #ddd);
    border-radius: 4px;
    text-decoration: none;
}
.pagination a:hover {
    background: var(--bg-hover, #f5f5f5);
}
.pagination span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ---- Sortable table headers ---- */
.sortable-table th[data-sort] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.sortable-table th[data-sort]::after {
    content: '⇅';
    margin-left: 0.35em;
    opacity: 0.3;
    font-size: 0.8em;
}
.sortable-table th[data-sort-active="asc"]::after {
    content: '↑';
    opacity: 0.8;
}
.sortable-table th[data-sort-active="desc"]::after {
    content: '↓';
    opacity: 0.8;
}

/* ---- Action-menu (three-dot dropdown) ---- */
.action-menu {
    position: relative;
    display: inline-block;
}
.action-menu-trigger {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    min-width: 0;
}
.action-menu-trigger:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}
.action-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    min-width: 160px;
    padding: 0.35rem 0;
}
.action-menu.open .action-menu-dropdown { display: block; }
.action-menu-dropdown a,
.action-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.action-menu-dropdown a:hover,
.action-menu-dropdown button:hover {
    background: var(--bg-input);
    color: var(--accent);
}
.action-menu-dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.25rem 0;
}

/* ================================================================
   Mobile enhancements
   ================================================================ */
@media (max-width: 600px) {
    .camera-actions button {
        flex: 1;
        padding: 0.75rem 0.5rem;
        font-size: 1rem;
    }
    #build-pdf-btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
    }
    .page-thumb {
        width: 60px;
    }
    .page-thumb img {
        width: 60px;
        height: 80px;
    }
    /* Tables: allow horizontal scroll + hint with soft fade */
    .table-wrap {
        margin-left: -1.1rem;
        margin-right: -1.1rem;
        padding-left: 1.1rem;
        padding-right: 1.1rem;
    }
    table { font-size: 0.85rem; }
    thead th { padding: 0.5rem 0.6rem; font-size: 0.7rem; }
    tbody td { padding: 0.6rem; }
    td.actions { flex-wrap: wrap; gap: 0.3rem; }
    td.actions button, td.actions a {
        padding: 0.45rem 0.7rem;
        font-size: 0.8rem;
        min-height: 36px;
    }
    .summary-row { grid-template-columns: 1fr; text-align: left; }
    .summary-row div strong { font-size: 1.05rem; }
    /* Forms stack full-width on mobile */
    form button, form .btn { width: 100%; }
    form button.inline, form .btn.inline { width: auto; }
    .card { padding: 1rem; margin-bottom: 1rem; }
}

/* ------------------------------------------------------------------ */
/* Bank-TX manual matching                                             */
/* ------------------------------------------------------------------ */
.bank-tx-detail {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 1rem;
    margin: 0;
}
.bank-tx-detail dt {
    color: var(--muted-color, #666);
    font-weight: 500;
}
.bank-tx-detail dd {
    margin: 0;
}
.bank-tx-detail .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
}

.bank-match-table {
    width: 100%;
    border-collapse: collapse;
}
.bank-match-table th,
.bank-match-table td {
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border-color, #e5e5e5);
    vertical-align: middle;
}
.bank-match-table tbody tr {
    cursor: pointer;
}
.bank-match-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.03);
}
.bank-match-table tbody tr.is-matched {
    opacity: 0.55;
}
.bank-match-table .right {
    text-align: right;
}
.bank-match-table .nowrap {
    white-space: nowrap;
}
.bank-match-table label {
    cursor: pointer;
    display: block;
}

.score-bar {
    position: relative;
    width: 90px;
    height: 6px;
    background: var(--border-color, #e5e5e5);
    border-radius: 3px;
    overflow: hidden;
    margin-left: auto;
}
.score-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #d9534f 0%, #f0ad4e 50%, #5cb85c 100%);
    transition: width 0.2s;
}

@media (max-width: 600px) {
    .bank-match-table {
        font-size: 0.85rem;
    }
    .bank-match-table th,
    .bank-match-table td {
        padding: 0.4rem 0.3rem;
    }
    .score-bar {
        width: 50px;
    }
}

/* ================================================================
   Property evaluations
   ================================================================ */
.eval-label-pos      { color: var(--pos); border-color: rgba(92,194,143,0.35); background: rgba(92,194,143,0.08); }
.eval-label-warn     { color: var(--accent); border-color: rgba(212,176,90,0.35); background: var(--accent-soft); }
.eval-label-neg      { color: var(--neg); border-color: rgba(237,107,107,0.35); background: rgba(237,107,107,0.08); }
.eval-label-neutral  { color: var(--text-muted); border-color: var(--border); background: rgba(255,255,255,0.03); }

.eval-row-pos:hover  { background: rgba(92,194,143,0.04) !important; }
.eval-row-neg:hover  { background: rgba(237,107,107,0.04) !important; }

.eval-computed {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-xs);
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-soft);
}
