/* ==========================================================================
   DevAdmin — house standard `professional-page-design`, "Light Control-Tower" mode.
   One token block, one accent, everything else grayscale. Swap the block to re-theme.
   No web fonts, no external requests: the sign-in page must render instantly and
   fetch nothing that describes it.
   ========================================================================== */

:root {
    /* ---- the ONE accent (dark enough to carry text on white) ---- */
    --brand: #1F5D7A;
    --brand-bright: #2E7FA3;
    --brand-glow: #17627F;

    /* ---- surfaces: light page, WHITE cards, never pure white behind everything ---- */
    --page: #F3F6F8;
    --card: #FFFFFF;
    --card-hover: #F8FAFB;
    --elevated: #F5F7F9;          /* input fields and quiet panels, on white cards */
    --line: rgba(16, 34, 48, .09);
    --line-strong: rgba(16, 34, 48, .16);

    /* ---- text: darkest is #2A2A2A, never #000 ---- */
    --text: #2A2A2A;
    --text-2: #56606D;
    --text-muted: #6B7480;

    /* ---- status, darkened for a light ground ---- */
    --ok: #1E8A62;
    --warn: #A87211;
    --bad: #C0433D;
    --info: #2C6CB8;

    /* ---- metrics: in light mode shadows do the work, at =8% ---- */
    --radius: 16px;
    --radius-sm: 9px;
    --shadow-card: 0 1px 3px rgba(16, 34, 48, .05);
    --shadow-hover: 0 2px 4px rgba(16, 34, 48, .08);

    /* ---- type ---- */
    --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--page);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- ambient layer: rendered once, behind everything, CSS only ---------- */

.ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.ambient i {
    position: absolute;
    display: block;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .38;
}

.ambient i:nth-child(1) {
    width: 46vw; height: 46vw; top: -14vw; left: -10vw;
    background: radial-gradient(circle, #BFD9E6 0%, transparent 70%);
    animation: drift-a 78s ease-in-out infinite;
}

.ambient i:nth-child(2) {
    width: 38vw; height: 38vw; bottom: -14vw; right: -8vw;
    background: radial-gradient(circle, #CFDDE8 0%, transparent 70%);
    animation: drift-b 92s ease-in-out infinite;
}

.ambient i:nth-child(3) {
    width: 28vw; height: 28vw; top: 38%; left: 52%;
    background: radial-gradient(circle, #C8E0E6 0%, transparent 70%);
    opacity: .26;
    animation: drift-a 86s ease-in-out infinite reverse;
}

@keyframes drift-a {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(6vw, 5vh); }
}

@keyframes drift-b {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-5vw, -6vh); }
}

/* ---------- topbar ---------- */

.topbar {
    position: relative;
    z-index: 2;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-card);
}

.topbar-inner {
    max-width: 1360px;
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.mark {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.mark span { color: var(--brand-glow); }

.topnav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
}

.topnav a {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: color .1s ease-out, background .1s ease-out;
}

.topnav a:hover { color: var(--text); background: rgba(16, 34, 48, .045); }

.topnav a.active { color: var(--brand-glow); background: rgba(46, 127, 163, .11); font-weight: 600; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    white-space: nowrap;
}

.who { text-align: right; line-height: 1.25; }
.who b { display: block; font-size: 13px; font-weight: 600; }
.who small { display: block; font-size: 10px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); }

/* ---------- page frame ---------- */

.page {
    position: relative;
    z-index: 1;
    max-width: 1360px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.page-head { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }

.page-title {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    margin: 0 0 8px;
}

.page-title:only-child { margin-bottom: 0; }

.page-sub { margin: 0; color: var(--text-2); font-size: 15px; }

.section { margin-bottom: 24px; }

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    margin: 0;
}

/* ---------- cards ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.card + .card { margin-top: 24px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.card-note { color: var(--text-2); font-size: 13px; margin: 4px 0 0; }

.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------- KPI tiles ---------- */

.kpi {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.kpi-value { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }

.num {
    font-size: 30px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.unit { font-size: 15px; font-weight: 500; color: var(--text-muted); }

.kpi-note { margin: 10px 0 0; font-size: 11px; font-weight: 500; letter-spacing: .05em; color: var(--text-muted); }

.kpi.accent .num { color: var(--brand-glow); }
.kpi.good   .num { color: var(--ok); }
.kpi.warn   .num { color: var(--warn); }
.kpi.bad    .num { color: var(--bad); }

/* ---------- tables ---------- */

/* Caption for a table inside a card. Quieter than the card's own title so the density gradient
   keeps falling; the rule above it is a divider WITHIN a card, which is where dividers belong. */
.table-title {
    margin: 0 0 14px;
    padding-top: 24px;
    border-top: 1px solid var(--line);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-2);
}

.table-wrap { overflow-x: auto; margin: 0 -24px -24px; padding: 0 24px 24px; }

/* An instalment row opens to show the receipts behind it. */
tr.row-open { cursor: pointer; }
tr.row-open.is-open { background: rgba(46, 127, 163, .05); }
tr.row-open.is-open td { border-bottom-color: transparent; }

.caret {
    display: inline-block;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    transition: transform .2s ease-out, color .1s ease-out;
}

tr.row-open:hover .caret { color: var(--text-2); }
.caret.is-open { transform: rotate(90deg); }

tr.row-detail > td {
    padding: 4px 0 18px 0;
    background: rgba(46, 127, 163, .05);
}

/* The receipts themselves: quieter than the instalments they belong to. */
table.data.sub { width: auto; min-width: 380px; margin-left: 24px; }
table.data.sub th { padding-bottom: 6px; border-bottom-color: var(--line); }
table.data.sub td { padding: 7px 14px 7px 0; border-bottom: 0; font-size: 13px; }
table.data.sub th:last-child, table.data.sub td:last-child { padding-right: 0; }
table.data.sub tbody tr:hover { background: transparent; }

/* The receipts editor sits inside the schedule card, set apart from the table it belongs to. */
.receipts-panel {
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--brand-bright);
    border-radius: var(--radius-sm);
    background: var(--elevated);
}

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }

table.data th {
    text-align: left;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 14px 10px 0;
    border-bottom: 1px solid var(--line-strong);
    white-space: nowrap;
}

table.data td {
    padding: 12px 14px 12px 0;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.data tr:last-child td { border-bottom: 0; }

table.data tbody tr { transition: background .1s ease-out; }
table.data tbody tr:hover { background: rgba(16, 34, 48, .026); }

table.data th.r, table.data td.r { text-align: right; }
table.data td.r { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Only the LAST column loses its right padding. Zeroing it on every right-aligned cell butts the
   figure straight against the next heading — "REMAININGSTATUS". */
table.data th:last-child, table.data td:last-child { padding-right: 0; }

/* Links inside tables stay grayscale: the accent is spent on the active nav and one KPI, and a
   table full of blue rows would drown both. */
table.data a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--text-muted);
    text-underline-offset: 3px;
    transition: text-decoration-color .1s ease-out;
}

table.data a:hover { text-decoration-color: var(--brand-glow); }

table.data td.strong { font-weight: 600; }
.muted { color: var(--text-2); }
.micro { font-size: 11px; font-weight: 500; letter-spacing: .05em; color: var(--text-muted); }

/* money pairs render 2:1 and never wrap */
.money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.money .u { font-size: .62em; font-weight: 500; color: var(--text-muted); margin-left: 4px; }

/* ---------- status: dot + word, never colour alone ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--text-2);
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge.paid    { color: var(--ok); }
.badge.partial { color: var(--info); }
.badge.duesoon { color: var(--warn); }
.badge.overdue { color: var(--bad); }
.badge.pending { color: var(--text-muted); }

/* ---------- progress ---------- */

.progress { height: 6px; border-radius: 3px; background: rgba(16, 34, 48, .09); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 3px; background: var(--brand-bright); transition: width .2s ease-out; }
.progress.money > i { background: var(--ok); }

/* ---------- buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .1s ease-out, border-color .1s ease-out, color .1s ease-out;
}

.btn:hover { background: rgba(16, 34, 48, .045); }

.btn-brand { background: var(--brand); border-color: var(--brand); color: #FFFFFF; }
.btn-brand:hover { background: var(--brand-bright); border-color: var(--brand-bright); }

.btn-danger { color: var(--bad); border-color: rgba(192, 67, 61, .38); }
.btn-danger:hover { background: rgba(192, 67, 61, .09); }

.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12px; font-weight: 500; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 16px; }

.field > label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.field input, .field select, .field textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    background: var(--elevated);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    transition: border-color .1s ease-out, background .1s ease-out;
}

.field textarea { min-height: 86px; resize: vertical; line-height: 1.5; }

.field input:hover, .field select:hover, .field textarea:hover { border-color: rgba(16, 34, 48, .28); }

.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    background: var(--card);
    border-color: var(--brand-bright);
    box-shadow: 0 0 0 3px rgba(46, 127, 163, .18);
}

.field-hint { margin: 6px 0 0; font-size: 11px; color: var(--text-muted); }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }

.validation-message { color: var(--bad); font-size: 12px; }

ul.validation-errors {
    margin: 0 0 20px;
    padding: 12px 16px 12px 34px;
    list-style: disc;
    border: 1px solid rgba(192, 67, 61, .32);
    border-left: 3px solid var(--bad);
    border-radius: var(--radius-sm);
    background: rgba(192, 67, 61, .05);
    color: var(--bad);
    font-size: 13px;
}

ul.validation-errors:empty { display: none; }

/* ---------- misc ---------- */

.empty { padding: 44px 24px; text-align: center; color: var(--text-muted); }
.empty p { margin: 0 0 6px; }

.notice {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand-bright);
    border-radius: var(--radius-sm);
    background: var(--elevated);
    font-size: 14px;
    margin-bottom: 24px;
}

.notice.bad { border-left-color: var(--bad); background: rgba(192, 67, 61, .05); border-color: rgba(192, 67, 61, .28); }

/* Optional-field marker inside an uppercase label. */
.field > label span { color: var(--text-muted); font-weight: 400; }

a { color: var(--brand-glow); }

.ext { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 13px; font-weight: 500; }
.ext:hover { text-decoration: underline; }

:focus-visible { outline: 3px solid var(--brand-bright); outline-offset: 2px; border-radius: 4px; }

/* Blazor's <FocusOnNavigate> parks keyboard focus on the page's <h1> after every navigation, giving
   it tabindex="-1" to do so. That is worth keeping — it is how a screen-reader user lands on the
   new page — but it made the ring box the page title on load, which reads as "the heading is
   selected". Suppress the ring ONLY on these programmatic, non-interactive targets. Anything a
   person can actually tab to keeps its ring; see the check below it. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible { outline: none; }

/* ==========================================================================
   Sign-in. Says nothing: no name, no logo, no wordmark, no hint of purpose.
   ========================================================================== */

.signin {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.signin-card {
    width: 100%;
    max-width: 372px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(16, 34, 48, .13);
    padding: 32px;
    animation: rise .2s ease-out;
}

@keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* The only ornament: a bare accent rule. It names nothing. */
.signin-rule { width: 34px; height: 3px; border-radius: 2px; background: var(--brand-bright); margin: 0 0 26px; }

.signin-card .field:last-of-type { margin-bottom: 24px; }

.signin-card .btn { width: 100%; }

.signin-error { margin: 0 0 20px; font-size: 13px; color: var(--bad); }

/* ---------- responsive ---------- */

@media (max-width: 700px) {
    .page { padding: 24px 16px 48px; }
    .page-title { font-size: 30px; }
    .topbar-inner { padding: 0 16px; gap: 16px; }
    .who { display: none; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
