/* ==========================================================================
   Fintune Loan360 — application stylesheet
   ==========================================================================
   Hand-written on purpose. No Vite, no Tailwind, no Node on the server.
   Edit this file, upload it, done — which matters more than utility classes
   on a single-developer build where every asset change otherwise costs a
   local build and a file transfer.

   Navy and gold to match the existing Fintune portals.
   ========================================================================== */

:root {
    --navy-900: #0b1c33;
    --navy-800: #0f2544;
    --navy-700: #13294b;
    --navy-600: #1c3a63;
    --navy-100: #e8edf4;
    --navy-050: #f4f7fb;

    --gold-600: #a8871d;
    --gold-500: #c9a227;
    --gold-400: #d4af37;
    --gold-100: #f7efd6;

    --ink: #1a2332;
    --ink-muted: #5b6b80;
    --ink-faint: #8b98a9;
    --line: #dde4ed;
    --surface: #ffffff;
    --canvas: #f6f8fb;

    --ok: #1a7f52;
    --ok-bg: #e6f4ed;
    --warn: #9a6700;
    --warn-bg: #fdf3d7;
    --crit: #b42318;
    --crit-bg: #fdeceb;
    --info: #1e5b9e;
    --info-bg: #e8f1fb;

    --radius: 6px;
    --shadow: 0 1px 2px rgba(15, 37, 68, .06), 0 2px 8px rgba(15, 37, 68, .04);
}

*, *::before, *::after { box-sizing: border-box; }

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

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

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

/* --- Numeric alignment ------------------------------------------------- */
/* Money and IDs read wrong in a proportional font. Tabular figures keep
   columns aligned and make a transposed digit visible. */
.mono, .amount, .app-no {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}
.amount { text-align: right; white-space: nowrap; }
.app-no { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; }

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

.sidebar {
    width: 220px;
    flex: 0 0 220px;
    background: var(--navy-800);
    color: #cdd8e6;
    display: flex;
    flex-direction: column;
}
.sidebar .brand {
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand strong { color: #fff; font-size: 1.05rem; display: block; letter-spacing: .01em; }
.sidebar .brand span { color: var(--gold-400); font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; }

.sidebar nav { padding: .75rem 0; flex: 1; }
.sidebar nav a {
    display: block;
    padding: .55rem 1.25rem;
    color: #cdd8e6;
    border-left: 3px solid transparent;
    font-size: .875rem;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.sidebar nav a.active {
    background: rgba(212, 175, 55, .1);
    border-left-color: var(--gold-400);
    color: #fff;
    font-weight: 500;
}
.sidebar .nav-group {
    padding: .9rem 1.25rem .3rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #7f92ab;
}
.sidebar .footer {
    padding: .9rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .75rem;
    color: #8fa1b8;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.topbar .who { font-size: .8125rem; color: var(--ink-muted); }
.topbar .who strong { color: var(--ink); }

.content { padding: 1.5rem; flex: 1; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head .sub { color: var(--ink-muted); font-size: .875rem; margin: 0; }

/* --- Cards -------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card > header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.card > header h2, .card > header h3 { margin: 0; font-size: .9375rem; }
.card .body { padding: 1rem; }
.card .body.flush { padding: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* --- Stats -------------------------------------------------------------- */
.stat { padding: 1rem; }
.stat .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-faint); }
.stat .value { font-size: 1.75rem; font-weight: 600; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.stat .note { font-size: .75rem; color: var(--ink-muted); }

/* --- Tables ------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-faint);
    font-weight: 600;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--line);
    background: var(--navy-050);
    white-space: nowrap;
}
tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--navy-050); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: .25rem; }

/* --- Badges ------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 100px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    background: var(--navy-100);
    color: var(--navy-700);
}
.badge.ok   { background: var(--ok-bg);   color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted{ background: #eef1f5;       color: var(--ink-muted); }
.badge.gold { background: var(--gold-100); color: var(--gold-600); }

/* --- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-block;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--navy-800);
    color: #fff;
    line-height: 1.4;
}
.btn:hover { background: var(--navy-700); text-decoration: none; color: #fff; }
.btn.secondary { background: var(--surface); color: var(--navy-700); border-color: var(--line); }
.btn.secondary:hover { background: var(--navy-050); color: var(--navy-800); }
.btn.gold { background: var(--gold-500); color: var(--navy-900); }
.btn.gold:hover { background: var(--gold-400); color: var(--navy-900); }
.btn.small { padding: .25rem .6rem; font-size: .75rem; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }

/* --- Forms -------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .8125rem; font-weight: 500; margin-bottom: .3rem; color: var(--ink); }
.field .hint { font-size: .75rem; color: var(--ink-muted); margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
    color: var(--ink);
    background: var(--surface);
}
input:focus, select:focus, textarea:focus {
    outline: 0;
    border-color: var(--navy-600);
    box-shadow: 0 0 0 3px rgba(28, 58, 99, .12);
}
.field.invalid input, .field.invalid select { border-color: var(--crit); }
.field .error { color: var(--crit); font-size: .75rem; margin-top: .25rem; }

/* --- Alerts ------------------------------------------------------------- */
.alert { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; border: 1px solid; }
.alert.ok   { background: var(--ok-bg);   border-color: #bfe3d0; color: var(--ok); }
.alert.warn { background: var(--warn-bg); border-color: #f0dda6; color: var(--warn); }
.alert.crit { background: var(--crit-bg); border-color: #f5c6c2; color: var(--crit); }
.alert.info { background: var(--info-bg); border-color: #c5dcf5; color: var(--info); }

/* --- Next actions ------------------------------------------------------- */
.action { display: flex; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.action:last-child { border-bottom: 0; }
.action .marker { width: 4px; border-radius: 2px; flex: 0 0 4px; background: var(--info); }
.action.warning  .marker { background: var(--warn); }
.action.critical .marker { background: var(--crit); }
.action .title { font-weight: 600; font-size: .875rem; }
.action .detail { font-size: .8125rem; color: var(--ink-muted); }

/* --- Timeline ----------------------------------------------------------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: ""; position: absolute; left: -6px; top: .3rem;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--gold-500);
}
.timeline .when { font-size: .75rem; color: var(--ink-faint); }

/* --- Definition lists --------------------------------------------------- */
.dl { display: grid; grid-template-columns: 165px 1fr; gap: .45rem .75rem; font-size: .875rem; }
.dl dt { color: var(--ink-muted); }
.dl dd { margin: 0; }
@media (max-width: 700px) { .dl { grid-template-columns: 1fr; gap: .1rem .75rem; } .dl dd { margin-bottom: .5rem; } }

/* --- Login -------------------------------------------------------------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--navy-900), var(--navy-700));
    padding: 1.5rem;
}
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 10px; padding: 2rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.login-card .brand { text-align: center; margin-bottom: 1.5rem; }
.login-card .brand strong { display: block; font-size: 1.3rem; color: var(--navy-800); }
.login-card .brand span { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-600); }

/* --- Utilities ---------------------------------------------------------- */
.muted { color: var(--ink-muted); }
.faint { color: var(--ink-faint); }
.small { font-size: .8125rem; }
.tiny  { font-size: .75rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: .5rem; } .mb-1 { margin-bottom: .5rem; }
.mt-2 { margin-top: 1rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; }
    .sidebar nav { display: flex; flex-wrap: wrap; padding: .5rem; }
    .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; }
    .sidebar nav a.active { border-left: 0; border-bottom-color: var(--gold-400); }
    .sidebar .nav-group, .sidebar .footer { display: none; }
    .content { padding: 1rem; }
}
