/* =====================================================================
   Smalledger — modern design system
   A light, refined fintech aesthetic layered on top of Bootstrap 5.
   Inspired by QuickBooks, FreshBooks, Xero, Wave, Stripe & Mercury:
   a deep-ink sidebar, an emerald "ledger" accent, soft cards, and
   calm, legible typography. Styling is centralised here so every
   Thymeleaf template inherits the new look with no markup churn.
   ===================================================================== */

:root {
    /* Brand — emerald "money/ledger" accent */
    --brand:        #059669;
    --brand-600:    #047857;
    --brand-700:    #036249;
    --brand-soft:   #ecfdf5;
    --brand-ring:   rgba(5, 150, 105, 0.25);

    /* Ink / sidebar */
    --ink:          #0b1220;
    --ink-2:        #111a2b;
    --ink-border:   rgba(255, 255, 255, 0.08);
    --ink-text:     #aeb9cc;
    --ink-text-dim: #7c8aa3;

    /* Neutrals */
    --bg:           #f5f7fa;
    --surface:      #ffffff;
    --border:       #e7eaef;
    --border-soft:  #eef1f5;
    --text:         #1a2233;
    --text-muted:   #6b7688;
    --heading:      #0f1729;

    /* Feedback */
    --pos:          #0f9d58;
    --neg:          #d63b3b;
    --warn:         #b06f1a;

    /* Shape & depth */
    --radius:       14px;
    --radius-sm:    10px;
    --radius-pill:  999px;
    --shadow-sm:    0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow:       0 1px 3px rgba(16, 24, 40, 0.06), 0 8px 24px -12px rgba(16, 24, 40, 0.12);
    --shadow-lg:    0 12px 40px -12px rgba(16, 24, 40, 0.22);

    --sidebar-w:    256px;
    --topbar-h:     58px;

    /* Bootstrap variable overrides that DO take effect globally */
    --bs-primary:        var(--brand);
    --bs-primary-rgb:    5, 150, 105;
    --bs-link-color:     var(--brand-600);
    --bs-link-color-rgb: 4, 120, 87;
    --bs-link-hover-color: var(--brand-700);
    --bs-border-color:   var(--border);
    --bs-body-color:     var(--text);
    --bs-body-bg:        var(--bg);
    --bs-font-sans-serif: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------------------------------------------------------------- base */
body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--bs-font-sans-serif);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.005em;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--heading);
    font-weight: 650;
    letter-spacing: -0.02em;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Only pages that render the sidebar get the content offset — auth
   screens (which omit it) stay full-width. Uses :has(), widely supported. */
body:has(.app-sidebar) {
    padding-left: var(--sidebar-w);
}
body:has(.app-sidebar) > main.container,
body:has(.app-sidebar) > main {
    padding-top: 2rem;
    padding-bottom: 4rem;
    max-width: 1200px;
}

/* ============================================================ SIDEBAR */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--ink);
    background-image: linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 100%);
    border-right: 1px solid var(--ink-border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.24s ease;
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.15rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.18rem;
    letter-spacing: -0.02em;
}
.app-sidebar__brand:hover { color: #fff; text-decoration: none; }
.app-sidebar__brand .logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand) 0%, #34d399 100%);
    box-shadow: 0 4px 12px -2px var(--brand-ring);
    font-size: 1rem;
}

.app-sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0.5rem 0.75rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.app-sidebar__nav::-webkit-scrollbar { width: 6px; }
.app-sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 3px; }

.app-nav-section {
    padding: 0.9rem 0.75rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-text-dim);
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.55rem 0.75rem;
    margin: 0.1rem 0;
    border-radius: var(--radius-sm);
    color: var(--ink-text);
    font-size: 0.925rem;
    font-weight: 500;
    line-height: 1.2;
    transition: background 0.15s ease, color 0.15s ease;
}
.app-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f3f6fb;
    text-decoration: none;
}
.app-nav-link.active {
    background: linear-gradient(90deg, rgba(5,150,105,0.22), rgba(5,150,105,0.08));
    color: #fff;
    box-shadow: inset 2px 0 0 var(--brand);
}
.app-nav-link .nav-ico {
    width: 20px;
    text-align: center;
    font-size: 1.02rem;
    flex-shrink: 0;
    opacity: 0.95;
}

.app-sidebar__footer {
    border-top: 1px solid var(--ink-border);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.app-sidebar__footer .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand) 0%, #34d399 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.app-sidebar__footer .avatar.avatar--logo {
    background: #fff;
    overflow: hidden;
    padding: 3px;
}
.app-sidebar__footer .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 50%;
}
.app-sidebar__footer .who {
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.15;
    overflow: hidden;
}
.app-sidebar__footer .who .name {
    display: block;               /* block is required for ellipsis to apply */
    max-width: 100%;
    color: #e8edf4;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-sidebar__footer .who .role {
    color: var(--ink-text-dim);
    font-size: 0.72rem;
}
/* The form is the footer's flex child — hold it (and the avatar) at their
   natural width so the email in .who truncates instead of colliding. */
.app-sidebar__footer > form {
    flex: 0 0 auto;
    margin: 0;
}
.app-sidebar__footer .btn-signout {
    --bs-btn-color: var(--ink-text);
    --bs-btn-border-color: var(--ink-border);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255,255,255,0.08);
    --bs-btn-hover-border-color: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Mobile topbar + backdrop */
.app-topbar {
    display: none;
    position: sticky;
    top: 0;
    height: var(--topbar-h);
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    background: rgba(255,255,255,0.92);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
    z-index: 1030;
}
.app-topbar__brand {
    font-weight: 700;
    color: var(--heading);
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.app-topbar__toggle {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 9px;
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--text);
}
.app-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(9, 14, 24, 0.5);
    z-index: 1035;
    opacity: 0;
    transition: opacity 0.24s ease;
}

@media (max-width: 991.98px) {
    body:has(.app-sidebar) { padding-left: 0; }
    body:has(.app-sidebar) > main { padding-top: 1.25rem; }
    .app-topbar { display: flex; }
    .app-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .app-backdrop { display: block; opacity: 1; }
}

/* ============================================================== CARDS */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1rem; }
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-soft);
    padding: 0.9rem 1.25rem;
    font-weight: 600;
    color: var(--heading);
}
.card-body { padding: 1.35rem; }
.card-body.p-0 { padding: 0; }

/* Stat tiles */
.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card .text-uppercase {
    font-size: 0.7rem !important;
    letter-spacing: 0.06em;
    font-weight: 600;
}
.stat-card .stat-value,
.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--heading);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.amount-positive { color: var(--pos) !important; }
.amount-negative { color: var(--neg) !important; }

/* Dashboard panels */
.dashboard-panel { overflow: hidden; }
.dashboard-panel .card-header {
    background: linear-gradient(180deg, #fbfcfe 0%, #ffffff 100%);
}
/* Panel figures are more restrained than the big list-page stat cards, so the
   numbers don't overpower their labels. */
.dashboard-panel .stat-value {
    font-size: 1.3rem;
    font-weight: 650;
}
.panel-drag { cursor: grab; opacity: 0.5; transition: opacity 0.15s; }
.panel-drag:hover { opacity: 1; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: var(--shadow-lg) !important; }

/* ============================================================ BUTTONS */
.btn {
    --bs-btn-border-radius: 10px;
    --bs-btn-font-weight: 550;
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-padding-x: 1rem;
    font-size: 0.925rem;
    letter-spacing: -0.01em;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(0.5px); }
.btn-sm {
    --bs-btn-border-radius: 8px;
    --bs-btn-padding-y: 0.3rem;
    --bs-btn-padding-x: 0.65rem;
    font-size: 0.82rem;
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 1px 2px rgba(5,150,105,0.25), 0 6px 16px -8px rgba(5,150,105,0.5);
}
.btn-success {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700);
}

.btn-outline-secondary {
    --bs-btn-color: #445;
    --bs-btn-border-color: var(--border);
    --bs-btn-bg: #fff;
    --bs-btn-hover-color: var(--heading);
    --bs-btn-hover-bg: #f4f6f9;
    --bs-btn-hover-border-color: #d3d9e2;
    --bs-btn-active-bg: #eef1f5;
    --bs-btn-active-color: var(--heading);
    --bs-btn-active-border-color: #cfd6e0;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-600);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-600);
}
.btn-outline-danger {
    --bs-btn-color: var(--neg);
    --bs-btn-border-color: #f0c5c5;
    --bs-btn-hover-bg: var(--neg);
    --bs-btn-hover-border-color: var(--neg);
}
.btn-link {
    --bs-btn-color: var(--brand-600);
    --bs-btn-hover-color: var(--brand-700);
    text-decoration: none;
    font-weight: 550;
}

/* =============================================================== FORMS */
.form-label {
    font-weight: 550;
    font-size: 0.86rem;
    color: #3a4353;
    margin-bottom: 0.35rem;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    color: var(--text);
    padding: 0.55rem 0.8rem;
    font-size: 0.925rem;
    background-color: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Keep clearance for the caret so a long selected label never runs under it. */
.form-select { padding-right: 2.5rem; }
.form-control::placeholder { color: #9aa4b2; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.form-control-sm, .form-select-sm {
    border-radius: 8px;
    font-size: 0.82rem;
    padding: 0.35rem 0.6rem;
}
.form-select-sm { padding-right: 2rem; }
.form-text { color: var(--text-muted); font-size: 0.8rem; }
.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-ring);
}
.input-group-text {
    background: #f4f6f9;
    border-color: var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}
.is-invalid ~ .invalid-feedback { font-size: 0.8rem; }

/* =============================================================== TABLES */
.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
    color: var(--text);
}
.table > thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 650;
    color: var(--text-muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 1rem;
    white-space: nowrap;
}
.table > tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
/* Match the body/head horizontal padding so a totals row (e.g. the invoice
   preview) lines up column-for-column with the rows above it. */
.table > tfoot td {
    padding: 0.8rem 1rem;
    vertical-align: middle;
    border-top: 2px solid var(--border);
}
.table td, .table th { vertical-align: middle; }
.table > tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * ,
.card .table > tbody > tr:hover > * {
    background-color: #f7fbf9;
}
.table td a { color: var(--brand-700); font-weight: 550; }
.table .fw-numeric, .table .text-end { font-variant-numeric: tabular-nums; }

/* =============================================================== BADGES */
.badge {
    --bs-badge-font-weight: 600;
    font-size: 0.72rem;
    padding: 0.4em 0.7em;
    border-radius: var(--radius-pill);
    letter-spacing: 0.01em;
}
/* Soft, legible status pills (override Bootstrap's saturated fills) */
.badge.bg-success {
    background-color: var(--brand-soft) !important;
    color: var(--brand-700) !important;
}
.badge.bg-info {
    background-color: #e0f2fe !important;
    color: #0369a1 !important;
}
.badge.bg-secondary {
    background-color: #eef1f5 !important;
    color: #4b5563 !important;
}
.badge.bg-warning {
    background-color: #fef3c7 !important;
    color: #92600a !important;
}
.badge.bg-danger {
    background-color: #fde8e8 !important;
    color: #b42318 !important;
}
/* "Unassigned" pill — reads as a label like a category, but visibly unset. */
.badge.badge-uncategorized {
    background-color: #fff;
    color: var(--text-muted);
    border: 1px dashed #cbd2dc;
    font-weight: 550;
}

/* =============================================================== ALERTS */
.alert {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0.85rem 1.1rem;
    font-size: 0.92rem;
}
.alert-success {
    background: var(--brand-soft);
    border-color: #b7e4cd;
    color: var(--brand-700);
}
.alert-danger {
    background: #fef2f2;
    border-color: #f6c9c9;
    color: #b42318;
}
.alert-info {
    background: #eff6ff;
    border-color: #c7ddfb;
    color: #1d4ed8;
}

/* ========================================================== PAGINATION */
.pagination {
    --bs-pagination-color: var(--text-muted);
    --bs-pagination-hover-color: var(--brand-700);
    --bs-pagination-hover-bg: #f4f6f9;
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--brand-ring);
    --bs-pagination-active-bg: var(--brand);
    --bs-pagination-active-border-color: var(--brand);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-border-radius: 9px;
}
.page-link { font-size: 0.85rem; font-weight: 550; }

/* ========================================================== DROPDOWNS */
.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 0.35rem;
    font-size: 0.9rem;
}
.dropdown-item {
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    font-weight: 500;
}
.dropdown-item:active, .dropdown-item.active {
    background: var(--brand);
}
.dropdown-item:hover { background: #f4f6f9; }

/* ============================================================= INVOICE */
/* Invoice preview / email layout */
.invoice-paper {
    background: #fff;
    padding: 2.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}
.invoice-logo { max-height: 80px; max-width: 240px; }
.invoice-meta td { padding: 2px 0; }
.address-block { white-space: pre-line; }
/* Activity timeline: a vertical rail down the left with a coloured dot marking
   each event, and the status pill + timestamp to its right — a conventional
   event timeline. */
.invoice-activity li { position: relative; }
/* The rail line, centred in the narrow rail column, spanning the full row so
   consecutive segments join into one continuous line; trimmed to start at the
   first dot and end at the last (and gone entirely for a single entry). */
.invoice-activity li::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0.5rem;
    width: 2px;
    transform: translateX(-50%);
    background: var(--border);
    z-index: 0;
}
.invoice-activity li:first-child::before { top: 50%; }
.invoice-activity li:last-child::before { bottom: 50%; }
/* The rail column holds the dot; stretched to full row height so the dot can be
   centred on the row's midline. */
.invoice-activity__rail {
    flex: 0 0 1rem;
    align-self: stretch;
    position: relative;
}
/* The event dot, centred on the rail and above the line so its solid fill masks
   the line beneath it. */
.invoice-activity__dot {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 50%;
    z-index: 1;
}
/* Left-aligned pills so the timestamp column beside them never shifts. */
.invoice-activity__label {
    flex: 0 0 9rem;
    text-align: left;
}

/* ================================================================ AUTH */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--surface);
}
.auth__aside {
    position: relative;
    color: #eafaf3;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    background: radial-gradient(1200px 600px at 15% 0%, #0f7a5a 0%, transparent 55%),
                linear-gradient(155deg, #064e3b 0%, #0b1220 100%);
}
.auth__aside::after {
    content: "";
    position: absolute;
    right: -140px;
    bottom: -140px;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(52,211,153,0.35) 0%, transparent 62%);
}
.auth__brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.auth__brand .logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand) 0%, #34d399 100%);
    box-shadow: 0 8px 22px -6px rgba(52,211,153,0.6);
    font-size: 1.35rem;
}
.auth__pitch { position: relative; z-index: 1; max-width: 30ch; }
.auth__pitch h2 {
    color: #fff;
    font-size: 2rem;
    line-height: 1.15;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.auth__pitch p { color: #b9d8cc; font-size: 1rem; margin-bottom: 1.5rem; }
.auth__points { list-style: none; padding: 0; margin: 0; }
.auth__points li {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #d6ede2;
    font-size: 0.95rem;
    padding: 0.3rem 0;
}
.auth__points li::before { content: "✓"; color: #34d399; font-weight: 700; }
.auth__legal { position: relative; z-index: 1; color: #7fa394; font-size: 0.8rem; }

.auth__main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}
.auth__card { width: 100%; max-width: 400px; }
.auth__card h1 { font-size: 1.6rem; margin-bottom: 0.25rem; }
.auth__card .lead-sub { color: var(--text-muted); margin-bottom: 1.75rem; }
.auth__card .btn-primary { padding-top: 0.62rem; padding-bottom: 0.62rem; font-weight: 600; }
.auth__mobile-brand { display: none; }

@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth__aside { display: none; }
    .auth__mobile-brand {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.55rem;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--heading);
        margin-bottom: 1.75rem;
    }
    .auth__mobile-brand .logo-mark {
        display: inline-flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; border-radius: 11px; font-size: 1.25rem;
        background: linear-gradient(135deg, var(--brand) 0%, #34d399 100%);
        box-shadow: 0 8px 22px -8px var(--brand-ring);
    }
}

/* ======================================================= LOGO UPLOAD */
.logo-preview {
    position: relative;
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.logo-preview.is-empty {
    border-style: dashed;
    background: #fafbfc;
}
.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 8px;
}
.logo-preview__placeholder {
    color: var(--text-muted);
    font-size: 0.75rem;
}
.logo-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 22px;
    height: 22px;
    padding: 0;
    line-height: 1;
    border: none;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}
.logo-remove:hover { background: var(--neg); }

/* ==================================================== PREVIEW ENVIRONMENT */
/* Slim, full-width strip across the top of the content column. Amber, so it
   reads as an advisory notice without alarming like a red error. */
.preview-banner {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #713f12;
    font-size: 0.9rem;
}
.preview-banner__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.preview-banner__icon { color: var(--warn); flex: none; }
.preview-banner__text { flex: 1 1 auto; line-height: 1.35; }
.preview-banner__cta {
    flex: none;
    font-weight: 650;
    color: var(--brand-700);
    text-decoration: none;
    white-space: nowrap;
}
.preview-banner__cta:hover { text-decoration: underline; }
.preview-banner__close {
    flex: none;
    border: none;
    background: transparent;
    color: #a16207;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 0.25rem;
    cursor: pointer;
}
.preview-banner__close:hover { color: #713f12; }

/* Founding-member pitch card (dashboard). Deep-ink to stand apart from the
   white data panels below it. */
.preview-card {
    position: relative;
    background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
}
.preview-card__title { font-size: 1.15rem; font-weight: 650; margin: 0 0 0.4rem; color: #fff; }
.preview-card__lead {
    color: var(--ink-text);
    margin: 0 0 1rem;
    max-width: 68ch;
    font-size: 0.95rem;
    line-height: 1.5;
}
.preview-card__close {
    position: absolute;
    top: 0.6rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    color: var(--ink-text-dim);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.preview-card__close:hover { color: #fff; }

/* "Waking up the demo" overlay shown while a cold-start demo-login is in flight. */
.wake-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(11, 18, 32, 0.72);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.wake-overlay[hidden] { display: none; }
.wake-overlay__box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem 2.25rem;
    max-width: 24rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.wake-overlay__spinner {
    width: 2.25rem;
    height: 2.25rem;
    margin: 0 auto 1rem;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: wake-spin 0.8s linear infinite;
}
@keyframes wake-spin { to { transform: rotate(360deg); } }
.wake-overlay__title { font-weight: 650; color: var(--heading); margin: 0 0 0.4rem; }
.wake-overlay__sub { color: var(--text-muted); font-size: 0.9rem; margin: 0; line-height: 1.5; }

/* =============================================================== MISC */
hr { border-color: var(--border); opacity: 1; }
.border-bottom { border-color: var(--border-soft) !important; }
::selection { background: var(--brand-ring); }

/* =============================================================== MARKETING / RESOURCES
   Public content pages (the /resources index and guide articles). Light theme,
   reader-optimized, and independent of the app chrome above. Brand greens match
   the landing page. */
body.marketing {
    background: #ffffff;
    color: #1f2937;
    font-family: Inter, system-ui, sans-serif;
}
body.marketing .logo-mark {
    display: inline-grid; place-items: center; width: 2rem; height: 2rem;
    border-radius: .6rem; color: #fff; font-size: 1rem;
    background: linear-gradient(135deg, #059669, #34d399);
}

.mkt-header {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 960px; margin: 0 auto; padding: 1.25rem 1.5rem;
}
.mkt-brand {
    display: inline-flex; align-items: center; gap: .55rem;
    font-weight: 700; font-size: 1.25rem; color: #0b1220; text-decoration: none;
}
.mkt-nav { display: flex; gap: 1.25rem; align-items: center; }
.mkt-nav a { color: #374151; text-decoration: none; font-weight: 500; font-size: .95rem; }
.mkt-nav a:hover { color: #059669; }
.mkt-nav__cta { color: #059669 !important; font-weight: 650 !important; }

.mkt-hero { max-width: 720px; margin: 0 auto; padding: 2.5rem 1.5rem 1rem; }
.mkt-eyebrow {
    text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 700;
    color: #059669; margin: 0 0 .6rem;
}
.mkt-hero h1 {
    font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 700; line-height: 1.1;
    letter-spacing: -.02em; color: #0b1220; margin: 0 0 1rem;
}
.mkt-lead { font-size: 1.15rem; color: #4b5563; margin: 0; max-width: 46ch; }

.mkt-list { max-width: 720px; margin: 0 auto; padding: 1.5rem 1.5rem 2rem; }
.mkt-item { border-top: 1px solid #e5e7eb; padding: 1.75rem 0; }
.mkt-item h2 { font-size: 1.4rem; font-weight: 700; margin: 0 0 .4rem; letter-spacing: -.01em; }
.mkt-item h2 a { color: #0b1220; text-decoration: none; }
.mkt-item h2 a:hover { color: #059669; }
.mkt-item__meta { color: #6b7280; font-size: .85rem; margin: 0 0 .6rem; display: flex; gap: .5rem; }
.mkt-item__blurb { color: #4b5563; margin: 0 0 .75rem; line-height: 1.6; }
.mkt-item__more { color: #059669; font-weight: 600; text-decoration: none; }
.mkt-item__more:hover { text-decoration: underline; }

.mkt-article { max-width: 680px; margin: 0 auto; padding: 2rem 1.5rem 1rem; }
.mkt-crumb { font-size: .85rem; color: #6b7280; margin: 0 0 1.5rem; }
.mkt-crumb a { color: #059669; text-decoration: none; }

.prose h1 {
    font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 700; line-height: 1.15;
    letter-spacing: -.02em; color: #0b1220; margin: 0 0 .75rem;
}
.prose h2 {
    font-size: 1.45rem; font-weight: 700; color: #0b1220; letter-spacing: -.01em;
    margin: 2.25rem 0 .75rem;
}
.prose p, .prose li { color: #374151; line-height: 1.75; font-size: 1.06rem; }
.prose p { margin: 0 0 1.15rem; }
.prose ul { margin: 0 0 1.15rem; padding-left: 1.3rem; }
.prose li { margin: 0 0 .5rem; }
.prose a { color: #059669; font-weight: 500; }
.prose strong { color: #1f2937; }

.mkt-band { background: #0b1220; color: #fff; margin-top: 2.5rem; }
.mkt-band__inner { max-width: 720px; margin: 0 auto; padding: 3rem 1.5rem; text-align: center; }
.mkt-band h2 { color: #fff; font-size: 1.7rem; font-weight: 700; margin: 0 0 .75rem; }
.mkt-band p { color: #94a3b8; max-width: 46ch; margin: 0 auto 1.5rem; font-size: 1.05rem; }
body.marketing .btn-brand {
    background: linear-gradient(135deg, #059669, #34d399); border: none; color: #fff;
    padding: .7rem 1.4rem; font-weight: 600; border-radius: .7rem;
}
body.marketing .btn-brand:hover { color: #fff; filter: brightness(1.05); }

.mkt-footer { border-top: 1px solid #e5e7eb; color: #6b7280; font-size: .9rem; }
.mkt-footer__inner {
    max-width: 960px; margin: 0 auto; padding: 1.75rem 1.5rem;
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.mkt-footer a { color: #374151; text-decoration: none; }
.mkt-footer a:hover { color: #059669; }

/* Sortable table-column headers (see fragments/common :: sortHeader). The whole
   heading is a link; the caret shows the current direction, or a faint neutral
   glyph on columns that are sortable but not the active sort. */
.sort-header {
    color: inherit; text-decoration: none;
    display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap;
}
.sort-header:hover { color: inherit; text-decoration: underline; }
.sort-caret { font-size: .75em; opacity: .3; line-height: 1; }
.sort-caret-active { opacity: .85; }
