/* ==========================================================================
   Taj Flour Mill — application stylesheet (no build step)
   ========================================================================== */
:root {
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e4e8ee;
    --border-strong: #cbd2dc;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #8391a5;
    --primary: #0f766e;
    --primary-600: #0d655e;
    --primary-50: #e6f4f2;
    --primary-100: #ccebe6;
    --pos: #15803d;
    --pos-bg: #ecfdf3;
    --neg: #b91c1c;
    --neg-bg: #fef2f2;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --sidebar-bg: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-active: rgba(255,255,255,.08);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
    --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
    --sidebar-w: 256px;
    --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text);
    background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .5rem; }
.muted { color: var(--text-2); }
.small { font-size: .82rem; }
.strong { font-weight: 600; color: var(--text); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline { display: inline; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 600; color: var(--text-3); margin-bottom: .2rem; }
.req { color: var(--neg); }
.link { display: inline-flex; align-items: center; gap: .25rem; font-weight: 500; }
.link.back { color: var(--text-2); font-size: .85rem; margin-bottom: .35rem; }
.link.back:hover { color: var(--primary); }
.show-sm { display: none; }

/* Layout ------------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; z-index: 40; transition: transform .25s ease; overflow: hidden;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 12px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none !important; }
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.15rem; flex: none;
    box-shadow: 0 4px 12px rgba(20,184,166,.35);
}
.brand-mark-lg { width: 56px; height: 56px; font-size: 1.6rem; border-radius: 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: .98rem; }
.brand-text small { font-size: .72rem; color: #94a3b8; }
.sidebar .sidebar-close { display: none; color: #94a3b8; }
.sidebar .sidebar-cta { display: flex; width: auto; margin: 6px 16px 14px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 12px; }
.nav-heading { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #64748b; padding: 16px 12px 6px; font-weight: 600; }
.nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500;
    text-decoration: none !important; transition: background .15s, color .15s; margin-bottom: 2px;
}
.nav-link .icon { width: 19px; height: 19px; opacity: .8; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(15,118,110,.4); }
.nav-link.active .icon { opacity: 1; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.user-meta { flex: 1; min-width: 0; line-height: 1.2; }
.user-meta strong { display: block; color: #fff; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: #94a3b8; font-size: .75rem; }
.sidebar-footer .icon-btn { color: #94a3b8; }
.sidebar-footer .icon-btn:hover { color: #fff; background: var(--sidebar-active); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 39; backdrop-filter: blur(2px); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 28px;
    background: rgba(243,245,247,.85); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .topbar-menu { display: none; }
.topbar-title h1 { font-size: 1.05rem; font-weight: 600; color: var(--text-2); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.topbar .topbar-cta { display: none; }
.content { padding: 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Page head --------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .muted { margin: .2rem 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }

/* Cards ------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { display: inline-flex; align-items: center; gap: 8px; }
.card.note p { margin: .3rem 0 0; color: var(--text-2); white-space: pre-line; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.chart-wrap { position: relative; height: 260px; }

/* Stats ------------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.compact { margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat-hero { background: linear-gradient(135deg, #0f766e 0%, #115e59 100%); color: #fff; border: none; box-shadow: 0 10px 30px rgba(15,118,110,.3); }
.stat-hero .stat-label, .stat-hero .muted { color: rgba(255,255,255,.75); }
.stat-hero .stat-value { color: #fff; }
.stat-hero .stat-value.neg { color: #fecaca; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; word-break: break-word; }
.stat-value-sm { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 6px; font-size: .82rem; margin-top: auto; padding-top: 4px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.15); }
.delta.up { background: rgba(134,239,172,.25); }
.delta.down { background: rgba(252,165,165,.3); }

/* Buttons ----------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.2; transition: all .15s;
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(15,118,110,.3); }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: #b3bcc9; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(15,23,42,.05); color: var(--text); }
.btn-danger { background: var(--neg); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .84rem; }
.btn-lg { padding: 12px 18px; font-size: 1rem; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; border: none; background: transparent; color: var(--text-2); cursor: pointer; transition: all .15s; padding: 0; font: inherit; }
.icon-btn:hover { background: rgba(15,23,42,.06); color: var(--text); text-decoration: none; }
.icon-btn.danger:hover { background: var(--neg-bg); color: var(--neg); }
.actions { opacity: .55; transition: opacity .15s; }
tr:hover .actions { opacity: 1; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font: inherit; font-size: .8rem; font-weight: 500; color: var(--text-2); cursor: pointer; transition: all .15s; }
.chip:hover, .chip.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms ------------------------------------------------------------------- */
.form .field { margin-bottom: 18px; }
.form-narrow { max-width: 720px; }
.field label, .field-inline label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 6px; color: var(--text); }
.field-inline { display: flex; flex-direction: column; }
.field-inline label { font-size: .75rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: var(--text);
    transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.15); }
.input::placeholder { color: var(--text-3); }
textarea.input { resize: vertical; min-height: 70px; }
.select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 38px; }
.amount-input { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem; }
.amount-preview { font-size: .82rem; color: var(--text-2); margin-top: 5px; font-variant-numeric: tabular-nums; }
.hint { font-size: .8rem; color: var(--text-3); margin: 5px 0 0; }
.has-error .input { border-color: var(--neg); }
.field-error { color: var(--neg); font-size: .82rem; margin: 5px 0 0; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; flex-wrap: wrap; }
.form-inline-fields { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.form-inline-fields .field { flex: 1 1 200px; margin: 0; }
.form-inline-fields .form-actions { padding: 0; margin-top: 27px; }
.form-inline-fields .form-actions .btn { min-height: 42px; }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; }
.filters .grow { flex: 1 1 220px; min-width: 200px; }
.filters .select { width: auto; min-width: 150px; }
.filters .field-inline .input { width: auto; }
.filters-wrap .combobox { min-width: 220px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.segmented .seg { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; text-align: center; margin: 0 !important; font-weight: 500 !important; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 1rem; }
.seg small { color: var(--text-3); font-size: .76rem; font-weight: 400; }
.seg-debit:has(input:checked) { border-color: var(--neg); background: var(--neg-bg); color: var(--neg); }
.seg-credit:has(input:checked) { border-color: var(--pos); background: var(--pos-bg); color: var(--pos); }
.seg:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(15,118,110,.2); }

.account-balance { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: .88rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; font-variant-numeric: tabular-nums; }

/* Combobox ---------------------------------------------------------------- */
.combobox { position: relative; }
.combobox-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--text-3); cursor: pointer; padding: 6px; border-radius: 6px; display: none; }
.combobox-clear:hover { color: var(--text); background: rgba(15,23,42,.06); }
.combobox.has-value .combobox-clear { display: inline-flex; }
.combobox.has-value .input { padding-right: 36px; font-weight: 600; }
.combobox-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50; margin: 0; padding: 6px; list-style: none; max-height: 300px; overflow-y: auto;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
}
.combobox-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.combobox-list li:hover, .combobox-list li.active { background: var(--primary-50); }
.combobox-list li .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-list li .sub { font-size: .76rem; color: var(--text-3); display: block; font-weight: 400; }
.combobox-list li .bal { font-size: .82rem; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.combobox-list .empty { color: var(--text-3); cursor: default; justify-content: center; }
.combobox-list .empty:hover { background: transparent; }
.combobox-list mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }

/* Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 11px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table tfoot th { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border-strong); border-bottom: none; }
.table tr.highlight { background: #fefce8; animation: fade-hl 3s ease forwards; }
@keyframes fade-hl { from { background: #fef08a; } to { background: #fefce8; } }
.table tr.row-opening td { background: var(--surface-2); font-style: italic; color: var(--text-2); }
.table-ledger td, .table-ledger th { padding: 9px 12px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: none; }
.list li a { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs -------------------------------------------------------------------- */
.tab-list { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 8px; margin-bottom: 10px; }
.tab { flex: 1; padding: 6px 10px; border: none; background: transparent; border-radius: 6px; font: inherit; font-weight: 600; font-size: .84rem; color: var(--text-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Pagination -------------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; flex-wrap: wrap; }
.pagination-info { color: var(--text-2); font-size: .85rem; }
.pagination-links { display: flex; gap: 4px; align-items: center; }
.page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 500; font-size: .86rem; text-decoration: none !important; }
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }
.page-gap { color: var(--text-3); padding: 0 4px; }

/* Alerts & toasts --------------------------------------------------------- */
.alert { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; }
.alert-error { background: var(--neg-bg); color: var(--neg); border: 1px solid #fecaca; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--text); color: #fff; box-shadow: var(--shadow-lg); font-size: .9rem; animation: toast-in .25s ease; }
.toast .icon { margin-top: 2px; }
.toast span { flex: 1; }
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast-close { border: none; background: transparent; color: rgba(255,255,255,.7); cursor: pointer; padding: 0; margin-left: 4px; }
.toast-close:hover { color: #fff; }
.toast.hide { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Empty state ------------------------------------------------------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); margin-bottom: 12px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-state p { margin-bottom: 14px; }
.error-page { padding: 80px 20px; }
.error-page h2 { font-size: 3rem; color: var(--text-3); }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-color: #fecaca; background: #fff7f7; flex-wrap: wrap; }
.danger-zone p { margin: 2px 0 0; }

/* Auth -------------------------------------------------------------------- */
.auth-body { background: radial-gradient(1200px 600px at 20% -10%, #d8f3ef 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #e2e8f0 0%, transparent 60%), var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.auth-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 36px 32px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand h1 { font-size: 1.4rem; margin-top: 14px; }
.auth-brand p { color: var(--text-2); margin: 2px 0 0; }
.auth-foot { color: var(--text-3); font-size: .8rem; margin-top: 20px; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2-1 { grid-template-columns: 1fr; }
    .hide-md { display: none; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    body.sidebar-open { overflow: hidden; }
    .sidebar .sidebar-close { display: inline-flex; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; height: 56px; }
    .topbar .topbar-menu { display: inline-flex; }
    .topbar .topbar-cta { display: inline-flex; }
    .content { padding: 16px; }
    .grid-2 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .stats-3 { grid-template-columns: 1fr; }
    .hide-sm { display: none; }
    .show-sm { display: block; }
    .truncate { max-width: 160px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .card { padding: 16px; }
    .page-head { align-items: flex-start; flex-direction: column; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }
    .filters .select, .filters .field-inline, .filters .field-inline .input { width: 100%; }
    .filters .btn { flex: 1 1 auto; }
    .form-actions .btn { flex: 1 1 auto; }
    .toasts { right: 12px; left: 12px; bottom: 12px; max-width: none; }
}
@media (max-width: 520px) {
    .stats { grid-template-columns: 1fr; }
    .stat-value { font-size: 1.45rem; }
    h2 { font-size: 1.3rem; }
    .segmented { grid-template-columns: 1fr; }
}

/* Print ------------------------------------------------------------------- */
.print-head { display: none; }
@media print {
    @page { margin: 14mm; }
    body { background: #fff; font-size: 11pt; }
    .sidebar, .sidebar-backdrop, .topbar, .no-print, .toasts, .filters, .page-actions, .danger-zone, .actions, .link.back { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; max-width: none; }
    .card, .stat { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .stats { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .stat-hero { background: #fff !important; color: #000 !important; }
    .print-head { display: block; margin-bottom: 12px; border-bottom: 2px solid #000; padding-bottom: 8px; }
    .print-head h3 { font-size: 14pt; }
    .print-head p { margin: 0; color: #444; font-size: 10pt; }
    .table-wrap { overflow: visible; margin: 0; padding: 0; }
    .table thead th { position: static; background: #f0f0f0 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .table th, .table td { padding: 5px 8px; border-bottom: 1px solid #ddd; }
    .hide-sm, .hide-md { display: table-cell !important; }
    a { color: inherit; text-decoration: none; }
    .pos, .neg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
