/* ============================================================
   ExpenseFlow — Design System
   "Clean minimal light" — white surfaces, hairline borders,
   near-black ink, one restrained accent. Elegant + calm.
   Brand: Blendko.
   ============================================================ */

:root {
    /* Surfaces */
    --bg: #fbfbfa;
    --surface: #ffffff;
    --surface-2: #f7f7f6;
    --surface-3: #f2f2f0;

    /* Hairlines */
    --border: #ececeb;
    --border-2: #e2e2e0;
    --border-strong: #d6d6d3;

    /* Ink / text */
    --ink: #17171a;
    --text: #26262b;
    --text-2: #52525b;
    --muted: #86868c;
    --faint: #a8a8ad;

    /* Accent — used sparingly */
    --accent: #4f46e5;
    --accent-ink: #4338ca;
    --accent-soft: #eef0fe;

    /* Status */
    --green: #157347;   --green-soft: #e9f6ee;   --green-line: #bfe6cd;
    --amber: #9a6a00;   --amber-soft: #fbf2df;   --amber-line: #ecd9a8;
    --red:   #c02626;   --red-soft:   #fbebeb;   --red-line:   #eec6c6;
    --blue:  #1f6feb;   --blue-soft:  #e9f1fe;

    /* Chart palette */
    --c1: #4f46e5; --c2: #0ea5a4; --c3: #d97706; --c4: #db2777; --c5: #2563eb; --c6: #65a30d;

    /* Shape */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-xs: 0 1px 2px rgba(24, 24, 27, .05);
    --shadow-sm: 0 1px 3px rgba(24, 24, 27, .06), 0 1px 2px rgba(24, 24, 27, .04);
    --shadow: 0 4px 16px rgba(24, 24, 27, .08);
    --shadow-lg: 0 24px 60px rgba(24, 24, 27, .16);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-serif: 'Cormorant Garamond', 'Playfair Display', Georgia, 'Times New Roman', serif;
}

* { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
    background-color: var(--bg);
    font-family: var(--font-sans);
    color: var(--text);
    font-size: .95rem;
    letter-spacing: -0.008em;
}

h1, h2, h3, h4, h5, h6 { color: var(--ink); letter-spacing: -0.022em; font-weight: 650; }
.fw-bold { font-weight: 700 !important; }

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

.text-muted { color: var(--muted) !important; }
hr { border-color: var(--border-2); opacity: 1; }

/* ------------------------------------------------------------
   Brand lockup (Blendko)
   ------------------------------------------------------------ */
.brand-lockup { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink); line-height: 1; }
.brand-lockup.brand-stacked { flex-direction: column; gap: .3rem; }
.brand-ornament { display: block; flex: none; }
.brand-textwrap { display: inline-flex; flex-direction: column; }
.brand-word {
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: .01em;
    line-height: 1;
    color: inherit;
}
.brand-tagline {
    font-family: var(--font-sans);
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: .28rem;
}
a.brand-lockup:hover { text-decoration: none; color: var(--ink); }

/* ------------------------------------------------------------
   Navbar — white, hairline, quiet
   ------------------------------------------------------------ */
.app-navbar {
    background: rgba(255, 255, 255, .86);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: .5rem;
    padding-bottom: .5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-navbar .navbar-brand { padding: 0; margin-right: 1.25rem; }

.app-navbar .navbar-nav .nav-link {
    color: var(--text-2);
    font-weight: 500;
    font-size: .9rem;
    padding: .4rem .7rem;
    border-radius: 8px;
    transition: background-color .12s ease, color .12s ease;
}
.app-navbar .navbar-nav .nav-link:hover { color: var(--ink); background: var(--surface-2); }
.app-navbar .navbar-nav .nav-link.active { color: var(--ink); font-weight: 600; background: var(--surface-3); }

.app-navbar .dropdown-menu {
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: .35rem;
    margin-top: .5rem;
    font-size: .9rem;
}
.app-navbar .dropdown-item { border-radius: 7px; padding: .5rem .7rem; color: var(--text-2); }
.app-navbar .dropdown-item:hover { background: var(--surface-2); color: var(--ink); }
.app-navbar .dropdown-item.active { background: var(--accent-soft); color: var(--accent-ink); }

/* User chip */
.user-chip {
    display: inline-flex; align-items: center; gap: .45rem;
    color: var(--text) !important;
    background: var(--surface);
    border: 1px solid var(--border-2);
    padding: .3rem .6rem;
    border-radius: 999px;
    font-weight: 500; font-size: .85rem;
    transition: background-color .12s ease, border-color .12s ease;
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; border-color: var(--border-strong); }
.user-chip .role-tag {
    font-size: .6rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    background: var(--ink); color: #fff; padding: .12rem .4rem; border-radius: 999px;
}
.user-chip .avatar {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--ink); color: #fff;
    display: grid; place-items: center; font-size: .68rem; font-weight: 700;
    letter-spacing: 0;
}

/* Notification bell */
.notif-btn {
    position: relative; width: 38px; height: 38px; border-radius: 10px;
    display: inline-grid; place-items: center;
    border: 1px solid var(--border-2); background: var(--surface);
    color: var(--text-2); font-size: 1.05rem; transition: background-color .12s ease;
}
.notif-btn:hover { background: var(--surface-2); color: var(--ink); }
.notif-badge {
    position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 999px; background: var(--red); color: #fff;
    font-size: .64rem; font-weight: 700; display: grid; place-items: center;
    border: 2px solid var(--surface);
}
.notif-menu { width: 340px; max-width: 90vw; padding: 0; overflow: hidden; }
.notif-menu .notif-head { padding: .7rem .9rem; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.notif-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: #e6e9fd; }
.notif-item .ni-icon { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: .9rem; }
.notif-item .ni-body { min-width: 0; }
.notif-item .ni-title { font-size: .84rem; font-weight: 550; line-height: 1.3; }
.notif-item .ni-time { font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); font-size: .85rem; }

.app-navbar .btn-logout {
    border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface);
    color: var(--text-2); font-weight: 500; font-size: .85rem; padding: .34rem .7rem;
}
.app-navbar .btn-logout:hover { background: var(--surface-2); color: var(--ink); }
.navbar-toggler { border: 1px solid var(--border-2); }

/* ------------------------------------------------------------
   Page header
   ------------------------------------------------------------ */
.page-head h3 { font-weight: 700; margin-bottom: .1rem; }
.page-head p { color: var(--muted); font-size: .9rem; }

/* ------------------------------------------------------------
   Cards
   ------------------------------------------------------------ */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    background: var(--surface);
}
.card .card-title { font-weight: 650; color: var(--ink); font-size: 1rem; letter-spacing: -0.02em; }
.card-header { background: var(--surface); border-bottom: 1px solid var(--border); font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ------------------------------------------------------------
   Stat cards — bordered, minimal, ink numerals
   ------------------------------------------------------------ */
.stat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    height: 100%;
    box-shadow: var(--shadow-xs);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-card small {
    display: flex; align-items: center; gap: .4rem;
    color: var(--muted); font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem;
}
.stat-card h3 { font-size: 1.7rem; font-weight: 700; line-height: 1.1; margin-bottom: 0; color: var(--ink); letter-spacing: -0.03em; }
.stat-card .stat-ico {
    width: 20px; height: 20px; border-radius: 6px; display: inline-grid; place-items: center;
    font-size: .8rem; color: #fff; flex: none;
}
.stat-card .stat-sub { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
/* accent dots on the label icon */
.si-blue   { background: var(--c5); } .si-green { background: var(--green); }
.si-amber  { background: var(--c3); } .si-red   { background: var(--red); }
.si-violet { background: var(--accent); } .si-ink { background: var(--ink); }

/* keep legacy gradient class names harmless if still referenced */
.bg-grad-blue, .bg-grad-green, .bg-grad-orange, .bg-grad-red, .bg-grad-purple { color: inherit; }

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table { color: var(--text); margin-bottom: 0; --bs-table-bg: transparent; }
.table thead th {
    background: transparent;
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
    color: var(--muted);
    border-bottom: 1px solid var(--border-2);
    padding: .55rem .75rem; white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--border); vertical-align: middle; padding: .7rem .75rem; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover > tbody > tr { transition: background-color .1s ease; }
.table-hover > tbody > tr:hover > * { background-color: var(--surface-2); }

/* ------------------------------------------------------------
   Badges / status pills
   ------------------------------------------------------------ */
.badge { font-weight: 600; letter-spacing: .01em; padding: .4em .7em; border-radius: 999px; }

.badge-status-pending, .badge-status-approved, .badge-status-rejected,
.pill { display: inline-flex; align-items: center; gap: .4em; font-size: .74rem; font-weight: 600;
        padding: .28em .6em; border-radius: 999px; border: 1px solid transparent; }
.badge-status-pending  { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.badge-status-approved { background: var(--green-soft); color: var(--green); border-color: var(--green-line); }
.badge-status-rejected { background: var(--red-soft);   color: var(--red);   border-color: var(--red-line); }
.badge-status-pending::before, .badge-status-approved::before, .badge-status-rejected::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block;
}
.pill-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border-2); }
.pill-accent  { background: var(--accent-soft); color: var(--accent-ink); border-color: #d9dcfb; }

/* ------------------------------------------------------------
   Buttons — ink primary, quiet secondaries
   ------------------------------------------------------------ */
.btn { border-radius: 9px; font-weight: 500; font-size: .9rem; letter-spacing: -0.005em;
       padding: .5rem .95rem; transition: transform .05s ease, background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
.btn:active { transform: translateY(.5px); }
.btn i.bi { font-size: .95em; }

.btn-primary {
    --bs-btn-bg: var(--ink); --bs-btn-border-color: var(--ink);
    --bs-btn-hover-bg: #000; --bs-btn-hover-border-color: #000;
    --bs-btn-active-bg: #000; --bs-btn-active-border-color: #000;
    --bs-btn-disabled-bg: #9b9b9f; --bs-btn-disabled-border-color: #9b9b9f;
    box-shadow: var(--shadow-xs);
}
.btn-accent {
    --bs-btn-color: #fff; --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--accent-ink); --bs-btn-hover-border-color: var(--accent-ink);
    color: #fff;
}
.btn-outline-primary {
    --bs-btn-color: var(--ink); --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: var(--border-strong);
}
.btn-outline-secondary {
    --bs-btn-color: var(--text-2); --bs-btn-border-color: var(--border-2);
    --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: var(--surface-3); --bs-btn-active-color: var(--ink);
}
.btn-success {
    --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green);
    --bs-btn-hover-bg: #10603a; --bs-btn-hover-border-color: #10603a; --bs-btn-active-bg: #10603a;
}
.btn-outline-danger { --bs-btn-color: var(--red); --bs-btn-border-color: var(--red-line);
    --bs-btn-hover-bg: var(--red); --bs-btn-hover-border-color: var(--red); }
.btn-outline-light { --bs-btn-color: var(--text-2); --bs-btn-border-color: var(--border-2); }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; font-size: .82rem; }
.btn-lg { border-radius: 11px; padding: .7rem 1.2rem; font-size: 1rem; }

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-label { font-weight: 550; font-size: .84rem; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: 9px; border: 1px solid var(--border-strong);
    padding: .5rem .75rem; background-color: var(--surface); color: var(--ink); font-size: .9rem;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--faint); }
.form-control-sm, .form-select-sm { font-size: .84rem; border-radius: 8px; }
.form-text { color: var(--muted); font-size: .8rem; }
.input-group-text { border-radius: 9px; background: var(--surface-2); border-color: var(--border-strong); color: var(--muted); }

/* ------------------------------------------------------------
   Alerts
   ------------------------------------------------------------ */
.alert { border: 1px solid transparent; border-radius: 11px; font-size: .9rem; padding: .7rem .9rem; }
.alert-success { background: var(--green-soft); color: #0f5c37; border-color: var(--green-line); }
.alert-danger  { background: var(--red-soft);   color: #971d1d; border-color: var(--red-line); }
.alert-warning { background: var(--amber-soft); color: #7a5400; border-color: var(--amber-line); }
.alert-info    { background: var(--blue-soft);  color: #14508f; border-color: #c9def9; }

/* ------------------------------------------------------------
   Filter bar
   ------------------------------------------------------------ */
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.filter-bar .fb-field { display: flex; flex-direction: column; }
.filter-bar label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: .25rem; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: .32rem .7rem; border-radius: 7px; font-size: .82rem; font-weight: 500; color: var(--text-2); text-decoration: none; }
.seg a:hover { color: var(--ink); text-decoration: none; }
.seg a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }
.seg a .seg-count { color: var(--muted); font-weight: 600; margin-left: .3rem; font-size: .78em; }
.seg a.active .seg-count { color: var(--accent-ink); }

/* ------------------------------------------------------------
   Pagination
   ------------------------------------------------------------ */
.pagination { gap: .25rem; margin: 0; }
.page-link { border-radius: 8px !important; border: 1px solid var(--border-2); color: var(--text-2); font-size: .85rem; padding: .35rem .65rem; }
.page-link:hover { background: var(--surface-2); color: var(--ink); }
.page-item.active .page-link { background: var(--ink); border-color: var(--ink); color: #fff; }
.page-item.disabled .page-link { color: var(--faint); }

/* ------------------------------------------------------------
   Charts (dependency-free, server rendered)
   ------------------------------------------------------------ */
.chart-legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .8rem; color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.bars { display: flex; flex-direction: column; gap: .85rem; }
.bar-row .bar-top { display: flex; justify-content: space-between; align-items: baseline; font-size: .85rem; margin-bottom: .3rem; }
.bar-row .bar-label { color: var(--text); font-weight: 500; }
.bar-row .bar-val { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; }
.bar-track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }

.spark-wrap { width: 100%; }
.donut-num { font-size: 1.35rem; font-weight: 700; fill: var(--ink); }
.donut-lbl { font-size: .62rem; fill: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.mini-metric { display: flex; align-items: baseline; gap: .5rem; }
.mini-metric .mm-val { font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.trend-up { color: var(--green); font-size: .8rem; font-weight: 600; }
.trend-down { color: var(--red); font-size: .8rem; font-weight: 600; }

/* ------------------------------------------------------------
   Auth pages
   ------------------------------------------------------------ */
.auth-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
    background:
        radial-gradient(60rem 30rem at 50% -10%, #f3f3f1, transparent 70%),
        var(--bg);
}
.auth-card {
    max-width: 400px; width: 100%;
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); background: var(--surface);
}
.auth-logo { display: flex; justify-content: center; margin-bottom: 1.25rem; color: var(--ink); }

/* ------------------------------------------------------------
   Empty states, misc
   ------------------------------------------------------------ */
.empty-state { text-align: center; padding: 2.75rem 1rem; color: var(--muted); }
.empty-state .bi { font-size: 1.9rem; opacity: .4; display: block; margin-bottom: .6rem; }
.empty-state .es-title { color: var(--text); font-weight: 600; margin-bottom: .15rem; }

.section-link { display: inline-flex; align-items: center; gap: .3rem; font-weight: 550; font-size: .85rem; }
.section-link:hover { text-decoration: none; }

.data-def dt { color: var(--muted); font-weight: 600; font-size: .8rem; }
.data-def dd { color: var(--ink); }

.avatar-lg { width: 56px; height: 56px; border-radius: 50%; background: var(--ink); color: #fff;
    display: grid; place-items: center; font-size: 1.3rem; font-weight: 700; }

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
.app-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2.5rem 0;
    margin-top: 1.5rem; border-top: 1px solid var(--border); }
.app-footer .brand-word { font-size: .95rem; }
.app-footer .dot { opacity: .45; margin: 0 .45rem; }

/* ------------------------------------------------------------
   Print
   ------------------------------------------------------------ */
@media print {
    .no-print, .app-navbar, .app-footer { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; }
}

@media (max-width: 575.98px) {
    .stat-card h3 { font-size: 1.4rem; }
    .card-body { padding: 1rem; }
}
