/* ==========================================================================
   SACCO PRO - light blue classic theme
   No external fonts, no CDN. Everything renders from this one file.
   ========================================================================== */

:root {
    --blue-900: #0b2a5b;
    --blue-800: #10386f;
    --blue-700: #1d4ed8;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --blue-400: #60a5fa;
    --blue-300: #93c5fd;
    --blue-200: #bfdbfe;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;

    --ink:      #0f172a;
    --ink-2:    #334155;
    --muted:    #64748b;
    --line:     #dbe4f0;
    --line-2:   #eef2f8;
    --surface:  #ffffff;
    --canvas:   #f4f7fc;

    --ok:       #0f9d58;
    --ok-bg:    #e6f6ee;
    --warn:     #b45309;
    --warn-bg:  #fef3c7;
    --bad:      #b91c1c;
    --bad-bg:   #fee2e2;
    --info:     #1d4ed8;
    --info-bg:  #dbeafe;

    --radius:   12px;
    --radius-s: 8px;
    --shadow:   0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
    --shadow-s: 0 1px 2px rgba(15,23,42,.05);
    --sidebar:  248px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--ink-2);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { color: var(--ink); margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

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

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: linear-gradient(180deg, var(--blue-900) 0%, var(--blue-800) 100%);
    color: #cfe0f7;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
}

.brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.09);
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; flex: 0 0 38px;
    background: linear-gradient(135deg, var(--blue-400), var(--blue-600));
    display: grid; place-items: center;
    font-weight: 800; color: #fff; font-size: 18px;
    box-shadow: 0 4px 12px rgba(37,99,235,.4);
}
.brand-text strong { display: block; color: #fff; font-size: 15px; letter-spacing: .02em; }
.brand-text span { font-size: 11.5px; color: #93b4e0; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }
.nav-group { margin: 14px 0 6px; padding: 0 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6f96c9; font-weight: 700; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 1px 0;
    border-radius: var(--radius-s);
    color: #cfe0f7; font-size: 13.5px; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav a.on { background: var(--blue-600); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.35); }
.nav a .ico { width: 18px; text-align: center; opacity: .9; flex: 0 0 18px; }
.nav a.on .ico { opacity: 1; }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.09); font-size: 11.5px; color: #7ea3d4; }

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

.topbar {
    height: 60px; background: var(--surface); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
    position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 650; color: var(--ink); font-size: 15px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); }
.topbar .who strong { color: var(--ink); }

.content { padding: 22px 24px 48px; max-width: 1400px; width: 100%; }

/* --------------------------------------------------------------- layout */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 240px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-s);
    margin-bottom: 18px;
}
.card-head {
    padding: 14px 18px; border-bottom: 1px solid var(--line-2);
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; }
.card-head .grow { flex: 1; }
.card { min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-body { padding: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
/* grid items default to min-width:auto, which lets a wide table push the
   whole column wider than the viewport; allow tracks to shrink instead. */
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }

/* ------------------------------------------------------------ stat tiles */
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-s);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
    background: var(--blue-500);
}
.stat.blue::before { background: var(--blue-600); }
.stat.green::before { background: var(--ok); }
.stat.amber::before { background: #f59e0b; }
.stat.red::before   { background: var(--bad); }
.stat.violet::before{ background: #8b5cf6; }

.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; }
.stat .value { font-size: 26px; font-weight: 700; color: var(--ink); margin: 6px 0 2px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .spark { position: absolute; right: 16px; bottom: 14px; opacity: .85; }

.trend-up   { color: var(--ok);   font-weight: 650; }
.trend-down { color: var(--bad);  font-weight: 650; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data thead th {
    background: var(--blue-50);
    color: var(--blue-800);
    text-align: left;
    padding: 11px 14px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--blue-50); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; }
table.data .c { text-align: center; }
table.data .mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12.5px; }
table.data tfoot td { padding: 11px 14px; font-weight: 700; border-top: 2px solid var(--line); background: var(--blue-50); color: var(--blue-900); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* --------------------------------------------------------------- badges */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap;
}
.badge-ok    { background: var(--ok-bg);   color: var(--ok); }
.badge-warn  { background: var(--warn-bg); color: var(--warn); }
.badge-bad   { background: var(--bad-bg);  color: var(--bad); }
.badge-info  { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #eef2f8;        color: var(--muted); }

/* --------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-s);
    border: 1px solid var(--line); background: var(--surface); color: var(--ink);
    font-size: 13.5px; font-weight: 600; cursor: pointer;
    font-family: inherit;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--blue-50); border-color: var(--blue-300); text-decoration: none; }
.btn-primary { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-primary:hover { background: var(--blue-800); border-color: var(--blue-800); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-danger { color: var(--bad); border-color: #fecaca; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }

/* ----------------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: 11.5px; color: var(--muted); margin: 0 0 8px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--line); border-radius: var(--radius-s);
    font-size: 13.5px; font-family: inherit; color: var(--ink);
    background: #fff;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-row-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0,1fr)); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field label { font-size: 11.5px; }

/* ---------------------------------------------------------------- charts */
.chart { display: block; overflow: visible; }
.chart .grid { stroke: #e8eef7; stroke-width: 1; }
.chart .axis { fill: #94a3b8; font-size: 10.5px; font-family: inherit; }
.chart-empty {
    display: grid; place-items: center;
    border: 1px dashed var(--line); border-radius: var(--radius-s);
    color: var(--muted); font-size: 13px; background: #fafcff;
}
.sparkline { display: block; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------------------------------------------------------------- alerts */
.alerts { margin-bottom: 16px; }
.alert {
    padding: 11px 15px; border-radius: var(--radius-s);
    margin-bottom: 9px; font-size: 13.5px; border: 1px solid;
}
.alert-ok   { background: var(--ok-bg);   border-color: #b7e4cd; color: #0b6b40; }
.alert-bad  { background: var(--bad-bg);  border-color: #fecaca; color: #8f1d1d; }
.alert-warn { background: var(--warn-bg); border-color: #fde68a; color: #8a5206; }
.alert-info { background: var(--info-bg); border-color: #bfdbfe; color: #1e40af; }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; gap: 5px; padding: 14px 18px; flex-wrap: wrap; }
.pager a {
    padding: 6px 11px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 13px; color: var(--ink-2); background: #fff;
}
.pager a:hover { background: var(--blue-50); border-color: var(--blue-300); text-decoration: none; }
.pager a.on { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }

/* ----------------------------------------------------------------- login */
.login-page {
    min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
    background: var(--canvas);
}
.login-brand {
    background: linear-gradient(150deg, var(--blue-900) 0%, var(--blue-700) 55%, var(--blue-500) 100%);
    color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
.login-brand::after {
    content: ""; position: absolute; width: 420px; height: 420px; right: -140px; top: -120px;
    background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%);
    border-radius: 50%;
}
.login-brand h1 { color: #fff; font-size: 30px; margin-bottom: 10px; }
.login-brand p { color: #cfe0f7; font-size: 15px; max-width: 420px; line-height: 1.6; }
.login-brand .mark { width: 54px; height: 54px; border-radius: 14px; background: rgba(255,255,255,.16);
    display: grid; place-items: center; font-size: 26px; font-weight: 800; margin-bottom: 22px;
    border: 1px solid rgba(255,255,255,.25); }
.login-features { margin-top: 30px; display: grid; gap: 12px; }
.login-features div { display: flex; gap: 11px; align-items: flex-start; color: #dbeafe; font-size: 13.5px; }
.login-features .tick { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.18);
    display: grid; place-items: center; font-size: 11px; flex: 0 0 20px; }

.login-pane { display: grid; place-items: center; padding: 36px; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 23px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-foot { margin-top: 20px; font-size: 12px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------ misc utils */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.divider { height: 1px; background: var(--line-2); margin: 16px 0; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 650; }
.kv dd { margin: 0; color: var(--ink); }

.progress { height: 7px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--blue-600); border-radius: 99px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
    .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-brand { display: none; }
    .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    :root { --sidebar: 0px; }
    .sidebar { position: fixed; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .main { margin-left: 0; }
    .content { padding: 16px; }
    .g4, .g3, .g2 { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
}
