/* EazyApply Finance - admin console
   Dense, keyboard friendly, built to be read all day. */

:root {
    --brand: #1553d6;
    --brand-dark: #0f3fa8;
    --brand-soft: #e8effd;
    --ink: #131c2b;
    --muted: #6b7684;
    --line: #e1e6ec;
    --bg: #f3f5f8;
    --card: #fff;
    --green: #0e8a4d;
    --green-soft: #e4f5ec;
    --amber: #b7791f;
    --amber-soft: #fdf3e0;
    --red: #c73c2e;
    --red-soft: #fceceb;
    --sidebar: #16233a;
}

* { box-sizing: border-box; }

body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side { width: 210px; background: var(--sidebar); flex-shrink: 0; padding: 18px 0; }
.side .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 0 20px 18px; }
.side .brand span { color: #6f9dff; }
.side a {
    display: block; padding: 10px 20px; color: #a8b4c8; font-size: 14px;
    border-left: 3px solid transparent;
}
.side a:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.side a.on { background: rgba(255,255,255,.07); color: #fff; border-left-color: #6f9dff; font-weight: 600; }
.side .sep { border-top: 1px solid rgba(255,255,255,.09); margin: 14px 20px; }

/* ---------------- language switch ---------------- */
.side .langs {
    display: flex; gap: 6px; margin: 18px 20px 0;
}
.side .langs a {
    flex: 1; text-align: center; padding: 6px 4px; font-size: 12px; font-weight: 700;
    border: 1px solid rgba(255,255,255,.16); border-left-width: 1px; border-radius: 6px;
}
.side .langs a.on {
    background: var(--brand); color: #fff; border-color: var(--brand); border-left-color: var(--brand);
}

/* the login page has no sidebar to put it in, so it sits in the corner */
.langs-float {
    position: absolute; top: 18px; right: 22px; display: flex; gap: 6px;
}
.langs-float a {
    padding: 6px 11px; font-size: 12px; font-weight: 700; color: var(--muted);
    border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
.langs-float a:hover { text-decoration: none; }
.langs-float a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.main { flex: 1; min-width: 0; }
.bar {
    background: var(--card); border-bottom: 1px solid var(--line);
    padding: 12px 22px; display: flex; align-items: center; gap: 14px;
}
.bar h1 { font-size: 17px; margin: 0; flex: 1; }
.bar .who { color: var(--muted); font-size: 13px; }
.body { padding: 22px; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .side { width: 100%; padding: 12px 0; }
    .side a { display: inline-block; border-left: 0; border-bottom: 3px solid transparent; }
    .side a.on { border-left: 0; border-bottom-color: #6f9dff; }
    .side .sep { display: none; }

    /* the sidebar is a strip now, so the language switch sits in the strip
       rather than stretching across it */
    .side .langs {
        display: inline-flex; width: auto; margin: 4px 0 0 14px; vertical-align: middle;
    }
    .side .langs a { flex: 0 0 auto; padding: 5px 11px; border-bottom-width: 1px; }
    .side .langs a.on { border-bottom-color: var(--brand); }
}

/* ---------- cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; padding: 18px; margin-bottom: 16px;
}
.card h2 {
    font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin: 0 0 14px; font-weight: 600;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }

/* ---------- forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 7px; font-size: 14px; background: #fff; color: var(--ink);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 120px; }
.row > div.narrow { flex: 0 0 auto; }

button, .btn {
    background: var(--brand); color: #fff; border: 0; border-radius: 7px;
    padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--brand-dark); color: #fff; text-decoration: none; }
.btn-ghost, button.ghost { background: #eef1f5; color: var(--ink); }
.btn-ghost:hover, button.ghost:hover { background: #e2e7ee; color: var(--ink); }
.btn-danger, button.danger { background: var(--red); }
.btn-danger:hover, button.danger:hover { background: #a83226; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th.l, td.l { text-align: left; }
tbody tr:hover { background: #fafbfc; }
tbody tr.void td { color: #9aa4b0; text-decoration: line-through; }

/* The "more details" cell exists only for phones, where the middle of each card
   folds away. display:none takes a table cell out of the table model entirely,
   so on a wide screen the row still has exactly as many columns as the header.
   This has to sit BEFORE the phone block below, which turns it back on. */
table.stack td.more-toggle { display: none; }

/* ---------- settings ---------- */
/* Not a table: a setting is a name, an explanation and one box, and that reads
   the same whether the screen is 1400px or 360px wide. */
.settings { display: flex; flex-direction: column; }
.setting {
    display: flex; gap: 20px; align-items: flex-start;
    padding: 14px 0; border-bottom: 1px solid var(--line);
}
.setting:first-child { padding-top: 0; }
.setting:last-child { padding-bottom: 0; border-bottom: 0; }
.setting-main { flex: 1; min-width: 0; }
.setting-name { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 3px; display: block; }
.setting-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }
.setting-key {
    display: inline-block; margin-top: 5px; font-size: 11px; color: #9aa4b0;
    background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px;
}
.setting-value { flex: 0 0 190px; }
.setting-value input { text-align: right; }
.setting-readonly {
    display: block; padding: 8px 10px; font-size: 13px; color: var(--muted);
    background: var(--bg); border: 1px dashed var(--line); border-radius: 7px;
    text-align: right; word-break: break-all;
}

.save-bar {
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
    margin: 0 0 16px;
}

/* ---------- tabs / filters ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
    padding: 7px 13px; border-radius: 7px; background: var(--card);
    border: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tabs a .n { opacity: .7; margin-left: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.Paid, .badge.Settled { background: var(--green-soft); color: var(--green); }
.badge.Partial, .badge.Pending { background: var(--amber-soft); color: var(--amber); }
.badge.Overdue, .badge.Rejected { background: var(--red-soft); color: var(--red); }
.badge.Running { background: var(--brand-soft); color: var(--brand); }
.badge.Void { background: #eef1f5; color: var(--muted); }

/* ---------- repayment health ----------
   Scanned down a long list, so it has to read at a glance:
   blue = nothing due yet, green = paying, red = chase them. */
.health {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
}
.health-notyet  { background: var(--brand-soft); color: var(--brand); }
.health-ontime  { background: var(--green-soft); color: var(--green); }
.health-settled { background: var(--green-soft); color: var(--green); }
.health-overdue { background: var(--red-soft);   color: var(--red); }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.v.green { color: var(--green); } .v.amber { color: var(--amber); } .v.red { color: var(--red); }

/* ---------- alerts ---------- */
.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: var(--red-soft); border: 1px solid #f0c8c3; color: var(--red); }
.alert-ok { background: var(--green-soft); border: 1px solid #c2e6d2; color: var(--green); }
.alert-warn { background: var(--amber-soft); border: 1px solid #f0dcb4; color: var(--amber); }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv .k { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; margin-top: 8px; }
/* ---------------- document tiles ---------------- */
/* both of these fill the same 190x130 box an uploaded photo would */
.doc-missing {
    width: 190px; height: 130px; border: 1px dashed #d5dbe3; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #9aa4b0; font-size: 13px;
}
.doc-pdf {
    width: 190px; height: 130px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--bg); display: flex; flex-direction: column; gap: 6px;
    align-items: center; justify-content: center; font-size: 13px; font-weight: 600;
}
.doc-pdf:hover { background: var(--brand-soft); text-decoration: none; }

.login-wrap { max-width: 360px; margin: 90px auto; }

/* ---------------- sign in: picture code and security code ----------------
   The picture code sits beside its box rather than above it, so the reader's
   eye travels sideways from the letters into the field instead of back up the
   page. The SVG is inline, so the border and radius go on the span. */
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row .captcha-img {
    flex-shrink: 0; line-height: 0; border: 1px solid var(--line);
    border-radius: 8px; overflow: hidden; background: #f7f9fc;
}
.captcha-row input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 2px; }
.captcha-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* The /Auth/Check self test. A label and a value per line, the label narrow and
   fixed so the values line up under one another and nothing scrolls sideways.
   Below 560px the label sits above its value instead. */
.facts { margin: 0; display: grid; grid-template-columns: 210px 1fr; gap: 1px 16px; }
.facts dt {
    font-size: 12px; color: var(--muted); font-weight: 600;
    padding: 7px 0; border-top: 1px solid var(--line);
}
.facts dd {
    margin: 0; padding: 7px 0; border-top: 1px solid var(--line);
    word-break: break-word;
}
.facts dd .muted { display: block; font-size: 12px; color: var(--muted); }
.facts dd.yes { color: var(--green); font-weight: 700; }
.facts dd.no { color: var(--red); font-weight: 700; }

@media (max-width: 560px) {
    .facts { grid-template-columns: 1fr; }
    .facts dd { padding-top: 0; border-top: 0; }
}

/* One box per digit asked for. Wide and monospaced, because a single character
   in a full width field looks like a field somebody forgot to finish. */
.digit-row { display: flex; gap: 12px; margin-bottom: 18px; }
.digit { flex: 1; }
.digit label { text-align: center; white-space: nowrap; }
.digit input {
    text-align: center; font-size: 22px; font-weight: 700; padding: 10px 4px;
    font-family: "Segoe UI Mono", Consolas, monospace;
}

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; font-size: 13px; padding: 6px 0; }

/* ==========================================================================
   Phones
   ==========================================================================
   A wide table on a phone used to scroll sideways, which meant the columns
   past the edge were simply never seen: nothing on screen said there was
   more. Below 760px every table marked .stack turns into one card per row,
   each cell carrying its own column heading, so nothing is off screen and
   nothing has to be discovered by swiping.
   ========================================================================== */
@media (max-width: 760px) {

    .body { padding: 14px; }
    .card { padding: 14px; border-radius: 12px; }

    /* A stacked table is never wider than its box, so sideways scrolling has
       nothing left to do. The capped-height lists (contacts, SMS, calls) keep
       their own vertical scroll: those can run to hundreds of rows. */
    .table-scroll { overflow-x: visible; }

    table.stack,
    table.stack tbody,
    table.stack tr,
    table.stack td { display: block; width: 100%; }

    table.stack thead { display: none; }

    table.stack tr {
        border: 1px solid var(--line); border-radius: 10px;
        padding: 10px 13px; margin-bottom: 10px; background: var(--card);
    }
    table.stack tr:hover { background: var(--card); }
    table.stack tr:last-child { margin-bottom: 0; }

    table.stack td {
        border: 0; padding: 6px 0; text-align: right; white-space: normal;
        display: flex; gap: 14px; align-items: baseline; justify-content: space-between;
    }
    table.stack td + td { border-top: 1px dashed var(--line); }

    /* the column heading, carried on the cell itself */
    table.stack td::before {
        content: attr(data-label);
        flex: 0 0 auto; text-align: left;
        font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
        color: var(--muted); font-weight: 600;
    }
    /* a cell with nothing to label, such as the row's buttons, spans the width */
    table.stack td:not([data-label]),
    table.stack td[data-label=""] {
        display: block; text-align: left; padding-top: 10px;
    }
    table.stack td:not([data-label])::before,
    table.stack td[data-label=""]::before { content: none; }

    /* ---- the fold ----
       A card that lists every column is too tall to scan: you scroll past one
       row to reach the next. So the middle of each card is folded away behind
       a button, leaving who the row is about at the top and what to do about
       it at the bottom. Opening one closes the others, so the list never grows
       under the reader. */
    table.stack td.more { display: none; }
    table.stack tr.is-open td.more {
        display: flex; gap: 14px; align-items: baseline; justify-content: space-between;
    }

    table.stack td.more-toggle {
        display: block; text-align: left; padding: 8px 0 2px; border-top: 0;
    }
    table.stack td.more-toggle::before { content: none; }
    .more-btn {
        width: 100%; background: var(--bg); color: var(--brand);
        border: 1px dashed #cfd6e0; border-radius: 8px;
        padding: 7px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
    }
    .more-btn:hover { background: var(--brand-soft); }
    table.stack tr.is-open .more-btn { border-style: solid; }

    /* a row whose first cell is the thing itself, not a value */
    table.stack td.rowhead {
        display: block; text-align: left; font-weight: 700; font-size: 15px;
        padding: 0 0 8px; border-top: 0;
    }
    table.stack td.rowhead::before { content: none; }

    table.stack tr.void td { text-decoration: none; }
    table.stack tr.void td.rowhead { text-decoration: line-through; }

    /* stacked rows lose the strike-through, so say it in words instead */
    table.stack td .badge, table.stack td .health { white-space: nowrap; }

    /* ---- settings ---- */
    .setting { flex-direction: column; gap: 8px; }
    .setting-value { flex: 1 1 auto; width: 100%; }
    .setting-value input { text-align: left; }
    .setting-readonly { text-align: left; }

    /* ---- key / value blocks ---- */
    .kv { grid-template-columns: 1fr; gap: 0; }
    .kv .k {
        font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
        font-weight: 600; margin-top: 10px;
    }
    .kv > div:not(.k) { margin-bottom: 2px; word-break: break-word; }

    /* ---- documents ---- */
    .doc-missing, .doc-pdf { width: 150px; height: 108px; }

    .bar { padding: 10px 14px; }
    .bar h1 { font-size: 16px; }

    /* ---- forms and actions ---- */
    .row > div { min-width: 0; flex: 1 1 100%; }
    .row > div.narrow { flex: 1 1 auto; }
    .save-bar button { width: 100%; }
}

/* very small phones: stop the tile row squeezing to two unreadable columns */
@media (max-width: 420px) {
    .tiles { grid-template-columns: 1fr 1fr; }
    .tabs a { padding: 6px 10px; font-size: 13px; }
}

/* ---------- pager ---------- */
.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px;
    border-top: 1px solid var(--line);
}
.pager-count { color: var(--muted); font-size: 13px; }
.pager-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-at { color: var(--muted); font-size: 13px; padding: 0 6px; white-space: nowrap; }
/* a step that would go off the end: shown, so the row does not jump about */
.pager .is-off { opacity: .4; cursor: default; }
.pager .is-off:hover { background: #eef1f5; }

@media (max-width: 760px) {
    .pager { flex-direction: column; align-items: stretch; gap: 10px; }
    .pager-count { text-align: center; }
    .pager-nav { justify-content: center; }
}

/* the tab for work that needs doing, rather than a state something is in */
.tabs a.tab-alert { border-color: #f0c8c3; color: var(--red); }
.tabs a.tab-alert:hover { color: var(--red); }
.tabs a.tab-alert.on { background: var(--red); border-color: var(--red); color: #fff; }

/* the payout account on the loan page: money leaves the company on the strength
   of this line, so it reads as a statement rather than a footnote */
.note.payout {
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 12px; margin-top: 10px; font-size: 13px; color: var(--ink);
}

/* ---------- payment receipts ---------- */
/* the flag on the loans list: something arrived that nobody has read */
.badge.receipt-flag {
    background: var(--amber-soft); color: var(--amber);
    margin-left: 6px; white-space: nowrap;
}
.badge.receipt-flag:hover { background: #f8e6c4; color: var(--amber); text-decoration: none; }

/* a receipt already read fades back, so the unread ones above it stand out */
tr.receipt-done td { color: var(--muted); }
tr.receipt-done td.rowhead { font-weight: 600; }

/* Due today: work to do, but nobody is late yet, so amber rather than red.
   Same colours as the matching badge in the Repayment column, so the tab and
   the column agree at a glance. */
.tabs a.tab-due { border-color: #f0dcb4; color: var(--amber); }
.tabs a.tab-due:hover { color: var(--amber); }
.tabs a.tab-due.on { background: var(--amber); border-color: var(--amber); color: #fff; }

.health-duetoday { background: var(--amber-soft); color: var(--amber); }

/* The last day of a roll is the one charged a full interest rather than the
   daily share, so it is worth being able to pick out of a column of identical
   rows at a glance. */
tbody tr.rolling-lastday td { background: var(--red-soft); font-weight: 600; }
