/* ==========================================================================
   Moto Parts — Design System
   A warm industrial identity: graphite surfaces, amber accent, tabular numbers.
   Built for a factory office: large targets, high contrast, calm hierarchy.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Roboto+Mono:wght@500;600&display=swap');

:root {
    /* Brand */
    --amber: #f59e0b;
    --amber-deep: #d97706;
    --amber-soft: #fffbeb;
    --amber-line: #fde68a;

    /* Ink & surface */
    --ink: #18181b;
    --ink-2: #3f3f46;
    --muted: #71717a;
    --faint: #a1a1aa;
    --line: #e4e4e7;
    --line-soft: #f4f4f5;
    --surface: #ffffff;
    --bg: #fafaf9;
    --raised: #ffffff;

    /* Sidebar */
    --nav-bg: #1c1917;
    --nav-bg-2: #292524;
    --nav-text: #d6d3d1;
    --nav-muted: #78716c;

    /* Semantic */
    --good: #15803d;
    --good-soft: #f0fdf4;
    --good-line: #bbf7d0;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --warn-line: #fde68a;
    --bad: #b91c1c;
    --bad-soft: #fef2f2;
    --bad-line: #fecaca;
    --info: #1d4ed8;
    --info-soft: #eff6ff;

    /* Form */
    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, .04), 0 1px 1px rgba(24, 24, 27, .03);
    --shadow: 0 1px 3px rgba(24, 24, 27, .06), 0 1px 2px rgba(24, 24, 27, .04);
    --shadow-md: 0 6px 16px -4px rgba(24, 24, 27, .10), 0 2px 6px -2px rgba(24, 24, 27, .06);
    --shadow-lg: 0 18px 40px -12px rgba(24, 24, 27, .22), 0 4px 12px -4px rgba(24, 24, 27, .10);
    --shadow-hero: 0 20px 48px -16px rgba(28, 25, 23, .45), 0 4px 14px -4px rgba(28, 25, 23, .25);
    --ring: 0 0 0 3px rgba(245, 158, 11, .18);

    --sidebar-w: 252px;
    --topbar-h: 60px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: var(--info); }
a:hover { text-decoration: underline; }

/* Numbers always align in columns and never wrap mid-figure. */
.num, .tabular, .stat-value, .money {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

/* ==========================================================================
   Shell
   ========================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--nav-bg);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    transition: transform .24s cubic-bezier(.4, 0, .2, 1);
}

.main {
    flex: 1 1 auto;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Brand
   ========================================================================== */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 17px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    flex: 0 0 auto;
}

.brand-mark {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(145deg, var(--amber) 0%, var(--amber-deep) 100%);
    display: grid; place-items: center;
    color: #1c1917;
    font-size: 21px;
    flex: 0 0 40px;
    box-shadow: 0 2px 8px rgba(245, 158, 11, .3);
}

.brand-text { min-width: 0; line-height: 1.25; }
.brand-text strong {
    display: block; color: #fafaf9; font-size: 14.5px; font-weight: 700;
    letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text span {
    display: block; font-size: 11px; color: var(--nav-muted);
    text-transform: uppercase; letter-spacing: .1em; font-weight: 600;
}

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav-list { padding: 14px 11px 28px; overflow-y: auto; flex: 1 1 auto; }

.nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--nav-muted);
    margin: 18px 10px 7px;
    font-weight: 700;
}
.nav-list > .nav-label:first-child { margin-top: 2px; }

.nav-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--nav-text);
    font-size: 14.5px;
    font-weight: 500;
    margin-bottom: 1px;
    position: relative;
    transition: background .14s, color .14s;
}
.nav-list a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }

.nav-list a i {
    font-size: 17px; width: 20px; text-align: center; flex: 0 0 20px;
    color: var(--nav-muted);
    transition: color .14s;
}
.nav-list a:hover i { color: var(--nav-text); }

/* Active row: amber rail + tinted ground, so position is obvious at a glance. */
.nav-list a.active {
    background: rgba(245, 158, 11, .13);
    color: #fff;
    font-weight: 600;
}
.nav-list a.active i { color: var(--amber); }
.nav-list a.active::before {
    content: '';
    position: absolute; left: -11px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    background: var(--amber);
    border-radius: 0 3px 3px 0;
}

.nav-count {
    margin-left: auto;
    background: var(--bad);
    color: #fff;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    line-height: 1.6;
}

/* ==========================================================================
   Topbar
   ========================================================================== */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 0 22px;
}

.icon-btn {
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--r-sm);
    display: grid; place-items: center;
    color: var(--ink-2); font-size: 17px;
    cursor: pointer;
    flex: 0 0 38px;
    transition: background .14s, border-color .14s;
}
.icon-btn:hover { background: var(--line-soft); border-color: var(--faint); }

.topbar-search { position: relative; flex: 1 1 auto; max-width: 420px; }
.topbar-search i {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--faint); font-size: 15px; pointer-events: none;
}
.topbar-search input {
    width: 100%; height: 38px;
    border: 1px solid var(--line);
    background: var(--line-soft);
    border-radius: var(--r-sm);
    padding: 0 12px 0 36px;
    font-size: 14px; font-family: inherit;
    color: var(--ink);
    outline: none;
    transition: background .14s, border-color .14s, box-shadow .14s;
}
.topbar-search input::placeholder { color: var(--faint); }
.topbar-search input:focus {
    background: var(--surface);
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.topbar-date {
    color: var(--muted); font-size: 13.5px; font-weight: 500;
    padding-right: 10px; border-right: 1px solid var(--line);
}

.user-btn {
    display: flex; align-items: center; gap: 9px;
    background: none; border: 0; padding: 4px 6px 4px 4px;
    border-radius: var(--r-sm); cursor: pointer;
    color: var(--ink); font-size: 14px; font-weight: 550; font-family: inherit;
    transition: background .14s;
}
.user-btn:hover { background: var(--line-soft); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(145deg, var(--nav-bg-2), var(--nav-bg));
    color: var(--amber);
    display: grid; place-items: center;
    font-size: 13px; font-weight: 700;
    flex: 0 0 32px;
}

/* ==========================================================================
   Page structure
   ========================================================================== */
.content { padding: 24px 22px 40px; flex: 1 1 auto; width: 100%; }

.page-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 {
    font-size: 24px; font-weight: 700; margin: 0 0 3px;
    letter-spacing: -.02em; color: var(--ink);
}
.page-head .sub { font-size: 14px; color: var(--muted); margin: 0; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
    font-weight: 650; font-size: 15px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    color: var(--ink);
}
.card-header .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.card-header i { color: var(--amber-deep); }

.card-body { padding: 18px; }
.card-body.tight { padding: 12px 18px; }

/* ==========================================================================
   Hero figures — the two questions the owner asks first
   ========================================================================== */
.hero-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 16px; }

.hero {
    position: relative;
    border-radius: var(--r-lg);
    padding: 22px 24px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex; flex-direction: column; gap: 10px;
}
.hero::after {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
}
.hero.in::after { background: linear-gradient(90deg, var(--good), #4ade80); }
.hero.out::after { background: linear-gradient(90deg, var(--bad), #f87171); }

.hero-label {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .1em; color: var(--muted);
    display: flex; align-items: center; gap: 8px;
}
.hero-label i { font-size: 15px; }
.hero.in .hero-label i { color: var(--good); }
.hero.out .hero-label i { color: var(--bad); }

.hero-value {
    font-size: 38px; font-weight: 800; letter-spacing: -.03em;
    line-height: 1.05; color: var(--ink);
}
.hero-value .cur { font-size: 19px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.hero-foot { font-size: 13.5px; color: var(--muted); margin-top: auto; }
.hero-foot a { color: var(--ink-2); font-weight: 550; }

/* ==========================================================================
   Stat tiles
   ========================================================================== */
.tiles { display: grid; gap: 14px; }
.tiles.c4 { grid-template-columns: repeat(4, 1fr); }
.tiles.c3 { grid-template-columns: repeat(3, 1fr); }
.tiles.c2 { grid-template-columns: repeat(2, 1fr); }

.tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px 17px;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 8px;
    min-width: 0;
    transition: border-color .14s, box-shadow .14s, transform .14s;
}
a.tile:hover {
    border-color: var(--amber-line);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
}

.tile-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-label {
    font-size: 12.5px; color: var(--muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
}

.tile-icon {
    width: 32px; height: 32px; border-radius: 9px;
    display: grid; place-items: center; font-size: 15px;
    background: var(--line-soft); color: var(--ink-2);
    flex: 0 0 32px;
}
.tile-icon.amber { background: var(--amber-soft); color: var(--amber-deep); }
.tile-icon.good { background: var(--good-soft); color: var(--good); }
.tile-icon.warn { background: var(--warn-soft); color: var(--warn); }
.tile-icon.bad { background: var(--bad-soft); color: var(--bad); }
.tile-icon.info { background: var(--info-soft); color: var(--info); }

.tile-value {
    font-size: 25px; font-weight: 700; letter-spacing: -.02em;
    line-height: 1.1; color: var(--ink); word-break: break-word;
}
.tile-value.sm { font-size: 20px; }
.tile-foot { font-size: 12.5px; color: var(--muted); margin-top: auto; }

/* ==========================================================================
   Attention strip
   ========================================================================== */
.attention {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--amber-soft);
    border: 1px solid var(--amber-line);
    border-radius: var(--r);
    padding: 13px 16px;
    margin-bottom: 16px;
}
.attention .att-icon {
    width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
    background: var(--amber); color: #1c1917;
    display: grid; place-items: center; font-size: 17px;
}
.attention .att-text { flex: 1 1 200px; min-width: 0; }
.attention .att-text strong { display: block; font-size: 14.5px; color: #78350f; }
.attention .att-text span { font-size: 13px; color: #92400e; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { margin: 0; font-size: 14px; width: 100%; border-collapse: collapse; }

.table > thead > tr > th {
    background: var(--line-soft);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    padding: 11px 14px;
    white-space: nowrap;
    text-align: left;
}
.table > thead > tr > th.num { text-align: right; }

.table > tbody > tr > td {
    padding: 13px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink-2);
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table > tbody > tr { transition: background .1s; }
.table > tbody > tr:hover { background: #fdfcfa; }

.table tfoot td {
    font-weight: 700;
    background: var(--line-soft);
    border-top: 2px solid var(--line);
    padding: 13px 14px;
    color: var(--ink);
}
.table tfoot td.num { text-align: right; }

.num { text-align: right; white-space: nowrap; }
.strong-num { font-weight: 650; color: var(--ink); }
.cell-title { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* Row actions stay quiet until the row is touched. */
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions .btn { opacity: .55; transition: opacity .14s; }
tr:hover .row-actions .btn, .row-actions .btn:focus { opacity: 1; }
@media (hover: none) { .row-actions .btn { opacity: 1; } }

/* ==========================================================================
   Pills
   ========================================================================== */
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px; font-weight: 650;
    white-space: nowrap;
    border: 1px solid transparent;
}
.pill-ok { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.pill-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.pill-info { background: var(--info-soft); color: var(--info); border-color: #bfdbfe; }
.pill-muted { background: var(--line-soft); color: var(--muted); border-color: var(--line); }

.text-ok { color: var(--good) !important; }
.text-bad { color: var(--bad) !important; }
.text-warn { color: var(--warn) !important; }
.text-muted-2 { color: var(--muted) !important; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-label {
    font-size: 13px; font-weight: 600; margin-bottom: 6px;
    color: var(--ink-2); display: block;
}
.form-label .req { color: var(--bad); }

.form-control, .form-select {
    font-size: 14.5px;
    font-family: inherit;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    color: var(--ink);
    background-color: var(--surface);
    width: 100%;
    transition: border-color .14s, box-shadow .14s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .15);
    outline: none;
}
.form-control[readonly] { background: var(--line-soft); color: var(--muted); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--bad); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }
.invalid-feedback { display: block; font-size: 12.5px; color: var(--bad); margin-top: 5px; }
.form-text { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.input-group { display: flex; }
.input-group > .form-control { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input-group-text {
    background: var(--line-soft);
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: var(--r-sm) 0 0 var(--r-sm);
    font-size: 13px; font-weight: 600; color: var(--muted);
    padding: 9px 12px;
    display: flex; align-items: center;
    white-space: nowrap;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    border-radius: var(--r-sm);
    font-size: 14px; font-weight: 600;
    font-family: inherit;
    padding: 9px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: background .14s, border-color .14s, box-shadow .14s, transform .08s;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--amber); border-color: var(--amber-deep); color: #1c1917;
    box-shadow: 0 1px 2px rgba(217, 119, 6, .25);
}
.btn-primary:hover { background: var(--amber-deep); border-color: #b45309; color: #fff; }

.btn-dark { background: var(--nav-bg); border-color: var(--nav-bg); color: #fafaf9; }
.btn-dark:hover { background: var(--nav-bg-2); color: #fff; }

.btn-light, .btn-outline {
    background: var(--surface); border-color: var(--line); color: var(--ink-2);
}
.btn-light:hover, .btn-outline:hover { background: var(--line-soft); border-color: var(--faint); color: var(--ink); }

.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #991b1b; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15.5px; }
.btn-icon { padding: 6px 9px; }
.btn-block { width: 100%; }
.btn i { font-size: 15px; }

/* ==========================================================================
   Filter bar
   ========================================================================== */
.filter-bar {
    display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    background: #fdfdfc;
}
.filter-bar .field { min-width: 145px; }
.filter-bar .form-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 5px; }
.filter-bar .form-control, .filter-bar .form-select { padding: 7px 11px; font-size: 13.5px; }
.filter-bar .actions { display: flex; gap: 8px; margin-left: auto; }

/* ==========================================================================
   Invoice builder
   ========================================================================== */
.item-row > td { padding: 8px 10px; vertical-align: top; }
.item-row .form-control, .item-row .form-select { padding: 8px 10px; font-size: 14px; }

.totals-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.totals-box .line {
    display: flex; justify-content: space-between; gap: 14px;
    padding: 7px 0; font-size: 14.5px; color: var(--ink-2);
}
.totals-box .line strong { color: var(--ink); font-weight: 650; }
.totals-box .line.grand {
    border-top: 2px solid var(--line);
    margin-top: 8px; padding-top: 13px;
    font-size: 16px;
}
.totals-box .line.grand strong { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.totals-box .line.due strong { color: var(--bad); }

/* ==========================================================================
   Lists (recent activity)
   ========================================================================== */
.list-line {
    display: flex; align-items: center; gap: 13px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line-soft);
}
.list-line:last-child { border-bottom: 0; }
.list-line:first-child { padding-top: 4px; }

.li-icon {
    width: 36px; height: 36px; border-radius: 10px; flex: 0 0 36px;
    display: grid; place-items: center; font-size: 15px;
    background: var(--line-soft); color: var(--ink-2);
}
.li-icon.good { background: var(--good-soft); color: var(--good); }
.li-icon.bad { background: var(--bad-soft); color: var(--bad); }
.li-icon.amber { background: var(--amber-soft); color: var(--amber-deep); }
.li-icon.info { background: var(--info-soft); color: var(--info); }

.li-main { min-width: 0; flex: 1 1 auto; }
.li-title {
    font-weight: 600; font-size: 14px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.li-title a { color: var(--ink); }
.li-title a:hover { color: var(--amber-deep); }
.li-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.li-right { text-align: right; flex: 0 0 auto; }

/* ==========================================================================
   Report tiles
   ========================================================================== */
.report-tile {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    height: 100%;
    box-shadow: var(--shadow-sm);
    transition: border-color .14s, box-shadow .14s, transform .14s;
}
.report-tile:hover {
    border-color: var(--amber);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none; color: var(--ink);
}
.report-tile .rt-icon {
    width: 42px; height: 42px; border-radius: 11px; flex: 0 0 42px;
    background: var(--amber-soft); color: var(--amber-deep);
    display: grid; place-items: center; font-size: 20px;
}
.report-tile strong { display: block; font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.report-tile span { font-size: 13px; color: var(--muted); line-height: 1.45; display: block; }

/* ==========================================================================
   Tabs
   ========================================================================== */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab-bar a {
    padding: 10px 16px;
    font-size: 14.5px; font-weight: 600;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: flex; align-items: center; gap: 7px;
}
.tab-bar a:hover { color: var(--ink); text-decoration: none; }
.tab-bar a.active { color: var(--amber-deep); border-bottom-color: var(--amber); }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    border-radius: var(--r);
    padding: 13px 16px;
    font-size: 14px;
    border: 1px solid transparent;
    display: flex; align-items: flex-start; gap: 11px;
    margin-bottom: 16px;
}
.alert i.lead-icon { font-size: 17px; flex: 0 0 auto; margin-top: 1px; }
.alert-success { background: var(--good-soft); border-color: var(--good-line); color: #14532d; }
.alert-danger { background: var(--bad-soft); border-color: var(--bad-line); color: #7f1d1d; }
.alert-warning { background: var(--warn-soft); border-color: var(--warn-line); color: #78350f; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert .btn-close { margin-left: auto; opacity: .5; }

/* Toast-style flash, so confirmations never push the page around. */
.flash-stack {
    position: fixed; top: 74px; right: 22px; z-index: 1080;
    width: min(400px, calc(100vw - 32px));
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.flash-stack .alert {
    pointer-events: auto;
    box-shadow: var(--shadow-lg);
    background: var(--surface);
    margin: 0;
    animation: flashIn .25s cubic-bezier(.4, 0, .2, 1);
}
.flash-stack .alert-success { border-color: var(--good-line); border-left: 4px solid var(--good); }
.flash-stack .alert-danger { border-color: var(--bad-line); border-left: 4px solid var(--bad); }
@keyframes flashIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   Empty states
   ========================================================================== */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state .es-icon {
    width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
    background: var(--line-soft); color: var(--faint);
    display: grid; place-items: center; font-size: 26px;
}
.empty-state h6 { color: var(--ink); font-weight: 650; margin: 0 0 5px; font-size: 15.5px; }
.empty-state p { font-size: 13.5px; margin: 0 auto 16px; max-width: 340px; line-height: 1.5; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-content { border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.confirm-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--bad-soft); color: var(--bad);
    display: grid; place-items: center; font-size: 26px; margin: 0 auto;
    border: 4px solid #fff1f2;
}

.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(24, 24, 27, .55);
    backdrop-filter: blur(2px);
    z-index: 1040;
}
.sidebar-backdrop.show { display: block; }

/* ==========================================================================
   Ledger helpers
   ========================================================================== */
.ledger-in { color: var(--good); }
.ledger-out { color: var(--bad); }

.progress { background: var(--line-soft); border-radius: 999px; overflow: hidden; height: 7px; }
.progress-bar { background: var(--amber); height: 100%; }

/* ==========================================================================
   Print — always paper-first, never a screenshot of the app
   ========================================================================== */
@media print {
    .sidebar, .topbar, .page-actions, .no-print, .sidebar-backdrop,
    .filter-bar, .flash-stack, .tab-bar, .row-actions { display: none !important; }
    .main { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff; font-size: 11.5pt; }
    .card { border: 0; box-shadow: none; }
    .card-header { padding-left: 0; padding-right: 0; }
    .table > thead > tr > th {
        background: #f4f4f5 !important;
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .hero, .tile { break-inside: avoid; box-shadow: none; }
    .table { font-size: 10.5pt; }
    a { color: #000 !important; text-decoration: none !important; }
    .print-only { display: block !important; }
    @page { margin: 14mm; }
}
.print-only { display: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1199.98px) {
    .tiles.c4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content { padding: 18px 16px 36px; }
    .page-head h1 { font-size: 21px; }
    .hero-value { font-size: 32px; }
    .topbar-date { display: none; }
}

@media (max-width: 767.98px) {
    .hero-grid { grid-template-columns: 1fr; gap: 12px; }
    .tiles.c4, .tiles.c3 { grid-template-columns: repeat(2, 1fr); }
    .content { padding: 15px 13px 32px; }
    .topbar { padding: 0 14px; gap: 9px; }
    .page-head { gap: 12px; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .hero { padding: 18px 18px; }
    .hero-value { font-size: 30px; }
    .filter-bar { padding: 13px 14px; }
    .filter-bar .field { min-width: 0; flex: 1 1 100%; }
    .filter-bar .actions { margin-left: 0; width: 100%; }
    .filter-bar .actions .btn { flex: 1 1 auto; }
    .flash-stack { top: auto; bottom: 14px; right: 14px; left: 14px; width: auto; }
}

@media (max-width: 479.98px) {
    .tiles.c4, .tiles.c3, .tiles.c2 { grid-template-columns: 1fr; }
    .tile-value { font-size: 22px; }
}
