/* iDEAL OCR review UI — supplements the copied iFinance design system.
   Holds the few component rules not in the shared CSS, plus light styling so
   the pre-existing bare-table pages (job detail, upload, login) stay readable. */

.text-ideal-teal { color: var(--ideal-teal) !important; }

/* ── Usage analytics: modern dashboard ─────────────────────────────────── */

/* Header band */
.usage-header {
    display: flex; align-items: flex-end; justify-content: space-between;
    flex-wrap: wrap; gap: 1rem;
    padding: 1.4rem 1.6rem; margin-bottom: 1.75rem;
    border-radius: 1rem;
    background: linear-gradient(120deg, rgba(92, 189, 189, 0.14), rgba(91, 108, 230, 0.10));
    border: 1px solid rgba(92, 189, 189, 0.25);
}
.usage-title { margin: 0; font-size: 1.6rem; font-weight: 700; color: #1d2a4d; letter-spacing: -0.02em; }
.usage-title i { color: var(--ideal-teal); margin-right: 0.45rem; }
.usage-subtitle { margin: 0.3rem 0 0; color: var(--ideal-text-muted); font-size: 0.88rem; }
.usage-month { display: flex; align-items: center; gap: 0.55rem; }
.usage-month label { margin: 0; font-size: 0.85rem; font-weight: 500; color: var(--ideal-text-dark); white-space: nowrap; }
.usage-month .form-select { border-radius: 0.6rem; }

/* Metric cards */
.metric-card {
    --accent: var(--ideal-teal);
    --accent-2: var(--ideal-teal-light);
    position: relative; height: 100%;
    background: #fff;
    border: 1px solid var(--ideal-gray-medium);
    border-radius: 0.9rem;
    padding: 1.2rem 1.25rem 1.1rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}
.metric-card::before {
    content: ""; position: absolute; top: 0; left: 0; bottom: 0;
    width: 3px; background: linear-gradient(var(--accent), var(--accent-2));
}
.metric-card:hover {
    box-shadow: 0 14px 26px -14px rgba(16, 24, 40, 0.28);
    transform: translateY(-3px); border-color: transparent;
}
.metric-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.metric-icon {
    width: 2.6rem; height: 2.6rem; border-radius: 0.7rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 7px 15px -7px var(--accent);
}
.metric-value { font-size: 1.9rem; font-weight: 700; color: #1d2a4d; line-height: 1.05; letter-spacing: -0.02em; }
.metric-label { color: var(--ideal-text-muted); font-size: 0.82rem; margin-top: 0.3rem; }
.metric-card.metric-sm { padding: 1rem 1.1rem; }
.metric-card.metric-sm .metric-icon { width: 2.2rem; height: 2.2rem; font-size: 1rem; border-radius: 0.6rem; }
.metric-card.metric-sm .metric-value { font-size: 1.5rem; }

/* Accent variants */
.metric-teal   { --accent: #5CBDBD; --accent-2: #7DD2D2; }
.metric-green  { --accent: #28a745; --accent-2: #5ed17f; }
.metric-amber  { --accent: #f0a726; --accent-2: #f7c66b; }
.metric-indigo { --accent: #5b6ce6; --accent-2: #8593f2; }
.metric-slate  { --accent: #94a3b8; --accent-2: #cbd5e1; }

/* Delta badge */
.delta-badge {
    display: inline-flex; align-items: center; gap: 0.15rem;
    font-size: 0.72rem; font-weight: 600; line-height: 1;
    padding: 0.3rem 0.5rem; border-radius: 999px;
    background: var(--ideal-gray-light); color: var(--ideal-text-muted);
}
.delta-badge i { font-size: 0.8rem; }
.delta-good { background: rgba(40, 167, 69, 0.12); color: #1f8a3b; }
.delta-bad  { background: rgba(220, 53, 69, 0.12); color: #d3384a; }
.delta-new  { background: rgba(92, 189, 189, 0.16); color: var(--ideal-teal-dark); }
.delta-flat { background: var(--ideal-gray-light); color: var(--ideal-text-muted); }

/* Chart panel */
.chart-panel {
    background: #fff; border: 1px solid var(--ideal-gray-medium);
    border-radius: 0.9rem; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    padding: 1.25rem 1.4rem 1.4rem;
}
.chart-panel-head {
    display: flex; align-items: baseline; justify-content: space-between;
    flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.9rem;
}
.chart-panel-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; color: #1d2a4d; }
.chart-panel-head .sub { font-size: 0.82rem; color: var(--ideal-text-muted); }

/* Teal badge for the "extracted" status (Bootstrap has no teal) */
.badge-teal { background: var(--ideal-teal); color: #fff; }

/* Login */
.login-wrap { max-width: 400px; margin: 6vh auto 0; }
.login-card {
    background: #fff;
    border: 1px solid var(--ideal-gray-medium);
    border-radius: var(--ideal-border-radius-lg);
    box-shadow: var(--ideal-shadow-md);
    padding: 2rem;
}
.login-brand { text-align: center; color: var(--ideal-teal); font-weight: 700; font-size: 1.4rem; }

/* Job detail layout */
.detail-grid { display: grid; grid-template-columns: var(--detail-left, 1fr) 1.5rem 1fr; gap: 0; align-items: start; }
.detail-divider { position: relative; cursor: col-resize; align-self: stretch; touch-action: none; }
.detail-divider::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; transform: translateX(-50%); background: var(--ideal-gray-medium); border-radius: 2px; transition: background .15s, width .15s; }
.detail-divider:hover::before, .detail-divider.dragging::before { background: var(--ideal-teal); width: 4px; }
@media (max-width: 991.98px) { .detail-grid { grid-template-columns: 1fr; } .detail-divider { display: none; } }
.doc-frame { border: 1px solid var(--ideal-gray-medium); border-radius: var(--ideal-border-radius-md); max-width: 100%; }

/* Processing overlay — blocks the content area while extraction runs */
.processing-overlay {
    position: fixed; top: 0; right: 0; bottom: 0; left: var(--sidebar-width);
    z-index: 1080;
    background: rgba(248, 249, 250, 0.8);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
}
@media (max-width: 991.98px) { .processing-overlay { left: 0; } }
@media (min-width: 992px) { body.sidebar-collapsed .processing-overlay { left: var(--sidebar-collapsed-width); } }
.processing-card {
    background: #fff;
    border: 1px solid var(--ideal-gray-medium);
    border-radius: var(--ideal-border-radius-lg);
    box-shadow: var(--ideal-shadow-lg);
    padding: 2.25rem 2.75rem;
    text-align: center;
    max-width: 360px;
}
.processing-card .spinner-border { width: 2.5rem; height: 2.5rem; }

/* Document viewer toolbar */
.doc-toolbar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.doc-toolbar .spacer { flex: 1 1 auto; }
.doc-toolbar input[type=range] { width: 110px; accent-color: var(--ideal-teal); }
.doc-toolbar .btn-sm { padding: 0.2rem 0.5rem; }

/* Scrollable document viewer so the highlighted box can be scrolled into view */
.doc-viewer { position: relative; max-height: 80vh; overflow: auto; border: 1px solid var(--ideal-gray-medium); border-radius: var(--ideal-border-radius-md); background: #f3f5fa; padding: 0.75rem; }
.doc-viewer .docpage { width: 100%; max-width: none; margin: 0 auto; transform-origin: center top; }
.doc-viewer .docpage img { display: block; width: 100%; box-shadow: var(--ideal-shadow-md); }

/* Field rows: only box-bearing rows are "locatable" (hover to highlight on the doc) */
.field-table td { vertical-align: middle; transition: background .12s ease; }
.field-table tbody tr:hover > td { background: rgba(92, 189, 189, 0.14); }
.field-table tr.locatable { cursor: pointer; }
.field-table tr.locatable:hover > td { background: rgba(92, 189, 189, 0.26); }
.field-table tr.locatable:hover > td:first-child { box-shadow: inset 4px 0 0 0 var(--ideal-teal); }
.locate-pin { color: var(--ideal-teal); font-size: 0.8rem; }

/* Line items: keep columns on one line and scroll horizontally instead of wrapping to mush */
.li-scroll { overflow-x: auto; }
.li-table { min-width: 760px; cursor: default; }
.li-table th, .li-table td { white-space: nowrap; }
.li-table th.li-desc, .li-table td.li-desc { white-space: normal; min-width: 240px; }
.li-table tbody tr.locatable { cursor: pointer; }
.li-table tbody tr:hover > td { background: rgba(92, 189, 189, 0.18); }
.li-table tbody tr.locatable:hover > td:first-child { box-shadow: inset 4px 0 0 0 var(--ideal-teal); }

/* Review aids: attention, dirty edits, arithmetic, pinning, reconciliation */
.field-table tr.attn > td:first-child { box-shadow: inset 4px 0 0 0 var(--ideal-danger); }
.field-table tr.attn > td { background: rgba(220, 53, 69, 0.06); }
.attn-flag {
  display: inline-block; font-size: .7rem; line-height: 1.2;
  padding: .05rem .35rem; margin-left: .35rem; border-radius: .4rem;
  background: rgba(220, 53, 69, 0.12); color: var(--ideal-danger); white-space: nowrap;
}
td.dirty input { border-color: var(--ideal-teal); box-shadow: 0 0 0 .15rem rgba(92, 189, 189, 0.25); }
.li-table tr.arith-bad td.li-total input { border-color: var(--ideal-danger); }
.li-table td.li-total.arith-bad { background: rgba(220, 53, 69, 0.12); }
/* per-row line-item attention + per-cell format flags (mirrors the field table) */
.li-table tr.attn > td:first-child { box-shadow: inset 4px 0 0 0 var(--ideal-danger); }
.li-table tr.attn > td { background: rgba(220, 53, 69, 0.06); }
.li-table td.cell-flag input { border-color: var(--ideal-danger); background: rgba(220, 53, 69, 0.08); }
/* a value we filled by derivation (not an error) — teal, so it reads as "check me", not "wrong" */
.li-table td.cell-inferred input { border-color: var(--ideal-teal); background: rgba(92, 189, 189, 0.12); }
.li-table tr.li-removed { opacity: .45; }
.li-table tr.li-removed td input { text-decoration: line-through; }
.ovl.pin { background: rgba(92, 189, 189, 0.18); border-color: var(--ideal-teal-dark) !important; box-shadow: 0 0 0 2px rgba(92, 189, 189, 0.4); }
.li-table tbody tr.pinned > td:first-child,
.field-table tbody tr.pinned > td:first-child { box-shadow: inset 4px 0 0 0 var(--ideal-teal-dark); }
#recon-readout.ok { color: var(--ideal-success); font-weight: var(--font-weight-semibold, 600); }
#recon-readout.bad { color: var(--ideal-danger); font-weight: var(--font-weight-semibold, 600); }

/* Chart panel */
.chart-container { position: relative; height: 340px; width: 100%; }

/* Monitoring table — filter toolbar, grounded header, cell gutters, teal pagination */
.table-toolbar {
    display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: flex-start;
    background: var(--ideal-gray-light);
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--ideal-gray-medium);
}
/* Keep Export/Upload grouped and pinned top-right while the filters wrap on the left. */
.toolbar-actions {
    display: flex; gap: 0.5rem; align-items: center;
    margin-left: auto; flex-shrink: 0; padding-top: 1.35rem;
}
/* Labelled filter fields — label stacked above each input, fields wrap and bottom-align. */
.filter-form {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 0.75rem;
    flex: 1 1 auto;
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-label {
    font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em;
    text-transform: uppercase; color: var(--ideal-text-muted);
    margin: 0; padding-left: 0.1rem;
}
.filter-actions { flex-direction: row; align-items: flex-end; gap: 0.5rem; }
.date-range { display: flex; align-items: center; gap: 0.4rem; }
.date-range .form-control { width: 150px; }
.date-range-sep { color: var(--ideal-text-muted); }
.monitor-table { margin-bottom: 0; }
.monitor-table thead th {
    background: var(--ideal-gray-light);
    border-bottom: 2px solid var(--ideal-gray-medium);
    color: #495057; font-weight: 600; white-space: nowrap;
}
.monitor-table td, .monitor-table th { padding-top: 0.7rem; padding-bottom: 0.7rem; }
.monitor-table > :not(caption) > * > *:first-child { padding-left: 1.25rem; }
.monitor-table > :not(caption) > * > *:last-child { padding-right: 1.25rem; }
.pagination .page-link { color: var(--ideal-teal-dark); }
.pagination .page-item.active > .page-link { background: var(--ideal-teal); border-color: var(--ideal-teal); color: #fff; }

/* File-name + id subtitle cell in the monitoring table */
.file-cell .file-name {
    color: var(--ideal-teal-dark); font-weight: 500;
    display: block; max-width: 480px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-cell .file-id { color: var(--ideal-text-muted); font-size: 0.78rem; font-family: var(--ideal-font-family-mono); }

/* File name + id chips under the job-detail heading */
.job-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.job-meta-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    background: var(--ideal-gray-light);
    border: 1px solid var(--ideal-gray-medium);
    border-radius: var(--ideal-border-radius-lg);
    font-size: 0.8rem; line-height: 1.4;
}
.job-meta-chip .bi { color: var(--ideal-teal-dark); }
.job-meta-chip .job-meta-value {
    color: var(--ideal-text-dark); font-weight: 500;
    max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-meta-chip .job-meta-value.mono { font-family: var(--ideal-font-family-mono); font-weight: 400; }
.job-meta-chip .job-meta-label {
    text-transform: uppercase; letter-spacing: 0.04em;
    font-size: 0.68rem; font-weight: 600; color: var(--ideal-text-muted);
}

/* Teal primary button — themed through Bootstrap's own button CSS variables so
   the colour holds across hover/focus/active/disabled (e.g. when a modal returns
   focus to its trigger). Setting plain `background` would lose to Bootstrap's
   more-specific :active/:focus rules. */
.btn {
    --bs-btn-bg: var(--ideal-teal);
    --bs-btn-color: #fff;
    --bs-btn-border-color: var(--ideal-teal);
    --bs-btn-hover-bg: var(--ideal-teal-dark);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-border-color: var(--ideal-teal-dark);
    --bs-btn-active-bg: var(--ideal-teal-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-border-color: var(--ideal-teal-dark);
    --bs-btn-disabled-bg: var(--ideal-teal);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-border-color: var(--ideal-teal);
    --bs-btn-focus-shadow-rgb: 92, 189, 189;
    font-weight: 500;
}

/* Secondary "ghost" button */
.btn-ghost {
    --bs-btn-bg: #fff;
    --bs-btn-color: var(--ideal-teal-dark);
    --bs-btn-border-color: var(--ideal-gray-medium);
    --bs-btn-hover-bg: var(--ideal-gray-light);
    --bs-btn-hover-color: var(--ideal-teal-dark);
    --bs-btn-hover-border-color: var(--ideal-gray-medium);
    --bs-btn-active-bg: var(--ideal-gray-light);
    --bs-btn-active-color: var(--ideal-teal-dark);
    --bs-btn-active-border-color: var(--ideal-gray-medium);
}

.conf-low { color: var(--ideal-danger); font-weight: 600; }
.status { padding: 0.1rem 0.5rem; border-radius: 0.5rem; font-size: 0.8rem; background: #eee; }

/* Keep the legacy bare-table pages (job detail) legible without Bootstrap's .table class */
.main-content table:not(.table) { border-collapse: collapse; width: 100%; }
.main-content table:not(.table) th,
.main-content table:not(.table) td {
    border: 1px solid #e3e6ee;
    padding: 0.4rem 0.6rem;
    text-align: left;
    font-size: 0.9rem;
}
.main-content table:not(.table) th { background: #f3f5fa; }
.main-content input[type=text]:not(.form-control) { width: 100%; box-sizing: border-box; padding: 0.3rem; }

/* Upload drag-and-drop */
.upload-card { max-width: 640px; margin: 0 auto; }
.dropzone {
    border: 2px dashed var(--ideal-gray-medium);
    border-radius: var(--ideal-border-radius-lg);
    background: var(--ideal-gray-light);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.dropzone:hover { border-color: var(--ideal-teal); }
.dropzone.dragover { border-color: var(--ideal-teal); background: rgba(92, 189, 189, 0.08); }
.dropzone .dz-icon { font-size: 2.75rem; color: var(--ideal-teal); line-height: 1; }
.dropzone .dz-title { font-weight: 600; margin-top: 0.6rem; }
.dropzone .dz-hint { color: var(--ideal-text-muted); font-size: 0.85rem; margin-top: 0.15rem; }
.dz-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.95rem;
    background: #fff;
    border: 1px solid var(--ideal-gray-medium);
    border-radius: var(--ideal-border-radius-md);
}
.dz-file .dz-file-name { font-weight: 500; word-break: break-all; }
.dz-file .dz-file-size { color: var(--ideal-text-muted); font-size: 0.8rem; }
.dz-remove { background: none; border: none; color: var(--ideal-danger); cursor: pointer; line-height: 1; }

/* ── Access management ─────────────────────────────────────────────────── */

/* Summary counters sitting at the right of the header band */
.access-summary { display: flex; gap: 0.6rem; }
.access-stat {
    display: flex; flex-direction: column; align-items: center;
    min-width: 84px; padding: 0.45rem 0.9rem;
    background: #fff; border: 1px solid var(--ideal-gray-medium);
    border-radius: 0.75rem; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.access-stat .num { font-size: 1.4rem; font-weight: 700; line-height: 1; color: #1d2a4d; }
.access-stat .lbl {
    margin-top: 0.25rem; font-size: 0.66rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--ideal-text-muted);
}
.access-stat.is-pending { border-color: rgba(255, 193, 7, 0.55); }
.access-stat.is-pending .num { color: #c99700; }

/* Table */
.access-table { margin-bottom: 0; }
.access-table thead th {
    background: var(--ideal-gray-light);
    border-bottom: 2px solid var(--ideal-gray-medium);
    color: #495057; font-weight: 600; white-space: nowrap;
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.access-table td, .access-table th { padding-top: 0.8rem; padding-bottom: 0.8rem; }
.access-table > :not(caption) > * > *:first-child { padding-left: 1.25rem; }
.access-table > :not(caption) > * > *:last-child { padding-right: 1.25rem; }

/* Pending rows carry an amber gutter so the admin's eye lands on the work to do */
.access-table tr.row-pending td { background: rgba(255, 193, 7, 0.06); }
.access-table tr.row-pending td:first-child { box-shadow: inset 3px 0 0 0 var(--ideal-warning); }

/* User identity cell */
.access-user { display: flex; align-items: center; gap: 0.7rem; }
.access-avatar {
    width: 2.3rem; height: 2.3rem; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 0.9rem;
    background: linear-gradient(135deg, var(--ideal-teal), var(--ideal-teal-light));
}
.access-avatar.is-admin { background: linear-gradient(135deg, #5b6ce6, #8b97f0); }
.access-name { font-weight: 600; color: #1d2a4d; line-height: 1.2; }
.access-username { color: var(--ideal-text-muted); font-size: 0.78rem; }
.access-email { color: var(--ideal-text-dark); }
.access-email.empty { color: var(--ideal-text-muted); }

/* Status pills */
.access-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.22rem 0.65rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.access-badge.approved { background: var(--ideal-success-light); color: #1a7431; }
.access-badge.pending { background: var(--ideal-warning-light); color: #8a6d00; }
.access-badge.admin { background: rgba(91, 108, 230, 0.12); color: #3a48b0; }

/* Grant provenance */
.access-grant { color: var(--ideal-text-muted); font-size: 0.82rem; line-height: 1.35; }
.access-grant .who { color: var(--ideal-text-dark); font-weight: 500; }
.access-grant.empty { color: var(--ideal-gray-medium); }
.access-always { color: var(--ideal-text-muted); font-size: 0.8rem; font-style: italic; }

/* ── Settings page ─────────────────────────────────────────────────────────── */
.setting-card {
    background: #fff; border: 1px solid #dee2e6;
    border-radius: 10px; padding: 1.25rem 1.4rem;
}
.setting-main {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1.5rem; flex-wrap: wrap;
}
.setting-text { flex: 1 1 22rem; min-width: 0; }
.setting-name {
    display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
    margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 600; color: #1d2a4d;
}
.setting-desc {
    margin: 0; max-width: 60ch;
    color: var(--ideal-text-muted); font-size: 0.87rem; line-height: 1.55;
}
.setting-desc strong { color: var(--ideal-text-dark); font-weight: 600; }
.setting-action { flex: 0 0 auto; }

/* Reuses the .access-badge pill shape */
.setting-badge {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.22rem 0.65rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.setting-badge.on { background: var(--ideal-success-light); color: #1a7431; }
.setting-badge.off { background: var(--ideal-warning-light); color: #8a6d00; }

.setting-meta {
    display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
    margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid #dee2e6;
    font-size: 0.82rem;
}
.setting-meta-label { color: var(--ideal-text-muted); }
.setting-meta-value { color: var(--ideal-text-dark); font-weight: 500; }
.setting-meta-value.empty { color: var(--ideal-gray-medium); font-weight: 400; font-style: italic; }

.setting-warning {
    display: flex; align-items: flex-start; gap: 0.6rem;
    margin-top: 0.9rem; padding: 0.75rem 0.9rem; border-radius: 8px;
    background: var(--ideal-warning-light); color: #8a6d00;
    font-size: 0.83rem; line-height: 1.5;
}
.setting-warning strong { font-weight: 600; }
.setting-warning i { flex: 0 0 auto; margin-top: 0.1rem; }
