/* ============================================================================
   BizManager — design system
   Concept: a modern dashboard built like a well-kept ledger book.
   Navy + brass palette, a serif display face for structure, and tabular
   monospace numerals for every figure that matters (amounts, invoice
   numbers, quantities) so financial data always lines up like a ledger.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600;6..72,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
    /* Palette */
    --navy:          #12233D;
    --navy-light:    #1D3559;
    --navy-lighter:  #2A4570;
    --brass:         #B8892B;
    --brass-light:   #D8A94F;
    --teal:          #0F5C5C;

    --bg:            #F3F5F8;
    --surface:       #FFFFFF;
    --paper:         #FCFAF4;
    --border:        #E3E7EE;
    --border-strong: #C9D0DC;

    --text:          #171B24;
    --text-muted:    #667085;
    --text-inverse:  #F4F6FA;

    --success:       #1E7145;
    --success-bg:    #E7F4EC;
    --danger:        #B3261E;
    --danger-bg:     #FBEAE9;
    --warning:       #B8892B;
    --warning-bg:    #FBF2E2;
    --info:          #2B6CB0;
    --info-bg:       #E8F0FA;
    --rjbg:          #2e2c2a;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(18, 35, 61, 0.06);
    --shadow-md: 0 4px 16px rgba(18, 35, 61, 0.08);
    --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: 'Newsreader', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
a { color: inherit; text-decoration: none; }

/* Tabular numerals: the signature detail. Every amount, invoice #, qty
   and stat figure renders in this class so columns of numbers line up
   the way they would in a physical ledger. */
.num, .figure, table td.num {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------------- */
/* Layout                                                                   */
/* ---------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--rjbg), var(--rjbg));
    display: flex; align-items: center; justify-content: center;
    font-family: 'Newsreader', serif; font-weight: 700; color: var(--navy);
    flex-shrink: 0;
}
.sidebar-brand .name { font-family: 'Newsreader', serif; font-size: 18px; font-weight: 600; }

.nav-section-label {
    padding: 18px 20px 6px;
    font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
    color: rgba(244,246,250,0.4);
}
.nav-list { list-style: none; margin: 0; padding: 0 10px; }
.nav-list li a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: rgba(244,246,250,0.78);
    font-size: 13.5px; font-weight: 500;
    border-left: 3px solid transparent;
}
.nav-list li a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-list li a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-list li a.active {
    background: rgba(184,137,43,0.16);
    border-left: 3px solid var(--brass);
    color: #fff;
}

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

.hamburger-btn {
    display: none;
    background: none; border: none; cursor: pointer;
    padding: 6px; margin-right: 4px; color: var(--text);
    align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
}
.hamburger-btn:hover { background: var(--paper); }
.hamburger-btn svg { width: 22px; height: 22px; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(18,35,61,0.45);
    z-index: 35;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 40;
        box-shadow: 0 0 40px rgba(0,0,0,0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger-btn { display: inline-flex; }
    .topbar { padding: 0 16px; gap: 10px; }
    .topbar .switcher span { display: none; }
    .content { padding: 16px; }
    .user-chip .meta { display: none; }
}

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 26px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .switcher {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; color: var(--text-muted);
}
.topbar select {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 10px; font-family: inherit; font-size: 13px; background: var(--surface); color: var(--text);
}
.topbar-right { display: flex; align-items: center; gap: 18px; }
.bell { position: relative; width: 20px; height: 20px; color: var(--text-muted); }
.bell .dot {
    position: absolute; top: -3px; right: -3px; width: 8px; height: 8px;
    background: var(--danger); border-radius: 50%; border: 2px solid var(--surface);
}
.user-chip { display: flex; align-items: center; gap: 9px; }
.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--navy); color: var(--text-inverse);
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 600; font-family: 'Newsreader', serif;
}
.user-chip .meta .role { font-size: 11.5px; color: var(--text-muted); }

.content { padding: 26px; max-width: 1400px; width: 100%; margin: 0 auto; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }

/* ---------------------------------------------------------------------- */
/* Cards / stat widgets                                                     */
/* ---------------------------------------------------------------------- */
.grid { display: grid; gap: 18px; }
.grid.stats { grid-template-columns: repeat(4, 1fr); }
.grid.charts-2 { grid-template-columns: 1.4fr 1fr; }
.grid.charts-1 { grid-template-columns: 1fr; }
@media (max-width: 1100px) { .grid.stats { grid-template-columns: repeat(2, 1fr); } .grid.charts-2 { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .grid.stats { grid-template-columns: 1fr; } }

/* Column-count utilities — used instead of inline grid-template-columns so
   the mobile breakpoint below can never be silently overridden by a page's
   own inline style (inline styles otherwise beat stylesheet rules), and
   defined as compound selectors so they also beat .grid.stats's specificity
   when both classes are present together. */
.stats-2, .grid.stats-2 { grid-template-columns: repeat(2, 1fr); }
.stats-3, .grid.stats-3 { grid-template-columns: repeat(3, 1fr); }
.stats-4, .grid.stats-4 { grid-template-columns: repeat(4, 1fr); }
.form-row-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-row-3 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) {
    .stats-2, .stats-3, .stats-4,
    .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr !important; }
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}
canvas { max-width: 100%; }
.card .card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 0;
}
.card .card-head h3 { font-size: 15.5px; }
.card .card-body { padding: 16px 20px 20px; overflow-x: auto; }

.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card .icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
}
.stat-card .icon svg { width: 19px; height: 19px; }
.stat-card.sales .icon { background: var(--info-bg); color: var(--info); }
.stat-card.purchases .icon { background: var(--warning-bg); color: var(--brass); }
.stat-card.expenses .icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.profit .icon { background: var(--success-bg); color: var(--success); }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 25px; font-weight: 600; margin-top: 4px; }
.stat-card .delta { font-size: 12px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; }
.stat-card .delta.up { color: var(--success); background: var(--success-bg); }
.stat-card .delta.down { color: var(--danger); background: var(--danger-bg); }
.stat-card::after {
    content: ''; position: absolute; right: -10px; bottom: -18px;
    width: 90px; height: 90px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(184,137,43,0.06), transparent);
}

/* Ledger-style table: a thin brass rule under the header row */
table.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ledger thead th {
    text-align: left; font-weight: 600; color: var(--text-muted);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
    padding: 0 10px 10px; border-bottom: 2px solid var(--brass);
}
table.ledger tbody td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
table.ledger tbody tr:hover { background: var(--paper); }
table.ledger td.num, table.ledger th.num { text-align: right; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warning { background: var(--warning-bg); color: var(--brass); }
.badge.info { background: var(--info-bg); color: var(--info); }

.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 600; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-brass { background: var(--brass); color: #fff; }
.btn-brass:hover { background: var(--brass-light); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--paper); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state h4 { color: var(--text); margin-bottom: 6px; }

/* Login page */
.auth-shell {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--navy);
    background-image: radial-gradient(circle at 20% 20%, rgba(184,137,43,0.12), transparent 40%),
                       radial-gradient(circle at 80% 80%, rgba(184,137,43,0.08), transparent 40%);
    padding: 20px; box-sizing: border-box;
}
.auth-card {
    width: 380px; max-width: calc(100vw - 40px); box-sizing: border-box;
    background: var(--surface); border-radius: var(--radius-lg);
    padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.auth-card .mark { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, var(--rjbg), var(--rjbg)); display:flex; align-items:center; justify-content:center; font-family:'Newsreader',serif; font-weight:700; color: var(--navy); margin-bottom: 16px; }
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font-family: inherit; font-size: 13.5px;
}
.field input:focus { outline: 2px solid var(--brass); outline-offset: 1px; border-color: var(--brass); }
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert.danger { background: var(--danger-bg); color: var(--danger); }
.alert.success { background: var(--success-bg); color: var(--success); }

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
