/* ==========================================================================
   CurrencyXcng — light, calm, dense.
   Rewritten as one coherent sheet rather than layers of additions.
   ========================================================================== */

:root {
    /* surfaces */
    --cx-bg: #f4f7fb;
    --cx-surface: #ffffff;
    --cx-rail: #ffffff;
    --cx-line: #e6ecf4;
    --cx-line-soft: #eef3f9;

    /* ink */
    --cx-ink: #1f2c3d;
    --cx-muted: #6b7c93;
    --cx-faint: #94a3b8;

    /* accents */
    --cx-accent: #3b6ef5;
    --cx-accent-soft: #eef3ff;
    --cx-accent-ink: #2b4fc4;

    /* meaning */
    --cx-profit: #0f7a52;
    --cx-profit-soft: #e8f7f0;
    --cx-loss: #c92a4a;
    --cx-loss-soft: #fdeef1;
    --cx-warn-soft: #fff5e6;
    --cx-sky-soft: #eaf5ff;

    --cx-rail-w: 220px;
}

html, body { height: 100%; }

body {
    background: var(--cx-bg);
    color: var(--cx-ink);
    font-size: .92rem;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Shell
   ========================================================================== */

.portal {
    display: flex;
    min-height: 100vh;
    align-items: flex-start;
}

/* The rail stays put while the page scrolls. */
.sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex: 0 0 var(--cx-rail-w);
    width: var(--cx-rail-w);
    background: var(--cx-rail);
    border-right: 1px solid var(--cx-line);
    padding-bottom: 1.5rem;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #dde5ef; border-radius: 3px; }

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .95rem 1rem;
    border-bottom: 1px solid var(--cx-line);
    margin-bottom: .45rem;
    text-decoration: none;
}

.brand:hover { background: var(--cx-accent-soft); }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #4f7dff, #3b6ef5);
    color: #fff;
    font-weight: 700;
    font-size: .8rem;
    box-shadow: 0 2px 6px rgba(59, 110, 245, .3);
}

.brand-text {
    color: var(--cx-ink);
    font-weight: 650;
    letter-spacing: .01em;
    font-size: .95rem;
}

.sidebar .nav-section {
    padding: .9rem 1rem .3rem;
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--cx-faint);
    font-weight: 600;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .1rem .5rem;
    padding: .45rem .6rem;
    border-radius: 8px;
    color: #4a5b71;
    font-size: .88rem;
    font-weight: 500;
}

.sidebar .nav-link:hover {
    background: var(--cx-line-soft);
    color: var(--cx-ink);
}

.sidebar .nav-link.active {
    background: var(--cx-accent-soft);
    color: var(--cx-accent-ink);
    font-weight: 650;
}

.sidebar .nav-link .icon { opacity: .7; }
.sidebar .nav-link.active .icon { opacity: 1; }

.nav-key {
    margin-left: auto;
    font-size: .62rem;
    background: var(--cx-line-soft);
    color: var(--cx-faint);
    border: 0;
    padding: .08rem .3rem;
    border-radius: 4px;
    font-weight: 600;
}

.nav-link.active .nav-key {
    background: #fff;
    color: var(--cx-accent-ink);
}

.nav-more {
    display: flex;
    align-items: center;
    gap: .6rem;
    width: calc(100% - 1rem);
    margin: .6rem .5rem 0;
    padding: .7rem .6rem .45rem;
    background: none;
    border: 0;
    border-top: 1px solid var(--cx-line);
    color: var(--cx-muted);
    font-size: .82rem;
    text-align: left;
}

.nav-more:hover { color: var(--cx-ink); }
.more-caret { margin-left: auto; transition: transform .15s ease; }
.nav-more.open .more-caret { transform: rotate(90deg); }

.nav-secondary .nav-link { font-size: .84rem; color: var(--cx-muted); }

.content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: .6rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--cx-line);
    padding: .6rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 20;
}

.page-title { font-size: 1rem; font-weight: 650; margin: 0; }

.main { padding: 1.1rem 1.25rem; flex: 1 1 auto; }

.footer {
    padding: .7rem 1.25rem;
    color: var(--cx-faint);
    font-size: .78rem;
    border-top: 1px solid var(--cx-line);
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        left: calc(var(--cx-rail-w) * -1);
        transition: left .2s ease;
        z-index: 1040;
        box-shadow: 0 0 30px rgba(16, 30, 54, .18);
    }

    .sidebar.open { left: 0; }
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
    border: 1px solid var(--cx-line);
    border-radius: 12px;
    background: var(--cx-surface);
    box-shadow: 0 1px 2px rgba(20, 40, 70, .04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--cx-line-soft);
    font-weight: 650;
    font-size: .88rem;
    padding: .6rem .9rem;
    border-radius: 12px 12px 0 0;
}

/* ---- headline figures ---- */

.stat-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 1.6rem;
    align-items: baseline;
    background: var(--cx-surface);
    border: 1px solid var(--cx-line);
    border-radius: 12px;
    padding: .7rem 1rem;
    margin-bottom: 1rem;
}

.stat-strip .s-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--cx-faint);
    display: block;
    font-weight: 600;
}

.stat-strip .s-value {
    font-size: 1.1rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.stat-card {
    border: 1px solid var(--cx-line);
    background: var(--cx-surface);
}

.stat-card .card-body { padding: .8rem .9rem; }

.stat-card .label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--cx-faint);
    font-weight: 600;
}

.stat-card .value {
    font-size: 1.35rem;
    font-weight: 650;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
}

.stat-card .hint { font-size: .74rem; color: var(--cx-muted); }

/* A soft wash so a row of figures reads as a set, not a wall of white. */
.row > [class*="col"]:nth-child(4n+1) .stat-card { background: var(--cx-accent-soft); border-color: #dde6ff; }
.row > [class*="col"]:nth-child(4n+2) .stat-card { background: var(--cx-profit-soft); border-color: #d5efe4; }
.row > [class*="col"]:nth-child(4n+3) .stat-card { background: var(--cx-warn-soft); border-color: #f5e6cc; }
.row > [class*="col"]:nth-child(4n+4) .stat-card { background: var(--cx-sky-soft); border-color: #d6e9fb; }

/* ==========================================================================
   Tables — dense, striped, quiet
   ========================================================================== */

.table {
    font-size: .84rem;
    margin-bottom: 0;
    --bs-table-bg: transparent;
}

.table > thead th {
    background: #f7fafd;
    border-bottom: 1px solid var(--cx-line);
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #7286a0;
    font-weight: 650;
    white-space: nowrap;
    padding: .4rem .55rem;
}

.table > tbody > tr > td {
    padding: .34rem .55rem;
    border-bottom: 1px solid var(--cx-line-soft);
    vertical-align: middle;
}

.table > tbody > tr:nth-child(even) > td { background: #fafcfe; }
.table > tbody > tr:hover > td { background: var(--cx-accent-soft); }

.table tfoot td {
    background: #f7fafd;
    border-top: 1px solid var(--cx-line);
    font-variant-numeric: tabular-nums;
}

.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.profit-pos { color: var(--cx-profit); font-weight: 650; }
.profit-neg { color: var(--cx-loss); font-weight: 650; }

.naam { color: var(--cx-loss); }
.jama { color: var(--cx-accent-ink); }

.table-scroll { overflow-x: auto; border-radius: 0 0 12px 12px; }

.table-search-holder { margin-left: auto; min-width: 13rem; }
.table-search { font-size: .8rem; }

[data-filter-count] {
    font-size: .74rem;
    color: var(--cx-faint);
    font-weight: 400;
}

/* Row actions stay out of the way until you look at the row. */
.row-actions {
    display: flex;
    gap: .2rem;
    justify-content: flex-end;
    align-items: center;
}

.row-actions form { display: inline; }
.row-actions .btn { opacity: .45; transition: opacity .12s ease; }
.table > tbody > tr:hover .row-actions .btn,
.row-actions .btn:focus { opacity: 1; }

/* ==========================================================================
   Badges — soft, not shouty
   ========================================================================== */

.badge { font-weight: 600; letter-spacing: .01em; padding: .26em .55em; }

.badge.text-bg-success { background: var(--cx-profit-soft) !important; color: var(--cx-profit) !important; }
.badge.text-bg-primary { background: var(--cx-accent-soft) !important; color: var(--cx-accent-ink) !important; }
.badge.text-bg-warning { background: var(--cx-warn-soft) !important; color: #9a6212 !important; }
.badge.text-bg-danger  { background: var(--cx-loss-soft) !important; color: var(--cx-loss) !important; }
.badge.text-bg-info    { background: var(--cx-sky-soft) !important; color: #1b6aa8 !important; }
.badge.text-bg-secondary { background: #eef1f6 !important; color: #64748b !important; }
.badge.text-bg-dark    { background: #e6ebf3 !important; color: #33455c !important; }
.badge.text-bg-light   { background: #f6f8fb !important; color: #64748b !important; }

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
    font-weight: 550;
    font-size: .78rem;
    margin-bottom: .2rem;
    color: #52657d;
}

.form-control, .form-select { border-color: #dbe3ee; }

.form-control:focus, .form-select:focus {
    border-color: #a9c0ff;
    box-shadow: 0 0 0 .18rem rgba(59, 110, 245, .12);
}

.required::after { content: " *"; color: var(--cx-loss); }

.filter-bar {
    background: var(--cx-surface);
    border: 1px solid var(--cx-line);
    border-radius: 12px;
    padding: .7rem .9rem;
    margin-bottom: 1rem;
}

.filter-bar .form-label { font-size: .72rem; margin-bottom: .15rem; }

.validation-summary-valid { display: none; }

.btn { font-weight: 550; }
.btn-sm { font-size: .8rem; }

.share-readout { font-variant-numeric: tabular-nums; font-weight: 650; }

.permission-module {
    border: 1px solid var(--cx-line);
    border-radius: 10px;
    padding: .65rem .85rem;
    height: 100%;
    background: #fcfdff;
}

.permission-module h6 {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--cx-faint);
    margin-bottom: .5rem;
}

kbd {
    background: #eef2f8;
    color: #51617a;
    border: 1px solid #dde5ef;
    border-radius: 4px;
    padding: .08rem .3rem;
    font-size: .72rem;
}

/* ==========================================================================
   Icons
   ========================================================================== */

.icon {
    width: 1.05em;
    height: 1.05em;
    vertical-align: -0.16em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.btn .icon { margin-right: .22rem; }
.btn-icon { padding: .16rem .36rem; line-height: 1; }
.btn-icon .icon { margin: 0; width: 1.05em; height: 1.05em; }

/* ==========================================================================
   Entry form — one dense line
   ========================================================================== */

.entry-line {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
    align-items: flex-end;
}

.entry-line-2 {
    margin-top: .7rem;
    padding-top: .7rem;
    border-top: 1px dashed var(--cx-line);
}

.entry-line .f { flex: 0 0 auto; }

.entry-line .f .form-label {
    margin-bottom: .12rem;
    font-size: .72rem;
    white-space: nowrap;
}

.f-date { width: 8.4rem; }
.f-party { width: 13rem; }
.f-ccy { width: 10.5rem; }
.f-num { width: 7.4rem; }
.f-save { width: 6.4rem; }
.f-note { flex: 1 1 16rem; min-width: 12rem; }
.f-live { flex: 1 1 auto; }
.commission-block { width: 11rem; }

/* The two account legs a settlement will post, spelled out while it is being typed. */
.split-figure {
    font-weight: 600;
    color: var(--cx-accent);
}

.entry-form .form-control,
.entry-form .form-select { font-size: .9rem; }

.btn-link-plain {
    background: none;
    border: 0;
    padding: 0;
    color: var(--cx-accent);
    font-size: .7rem;
    font-weight: 650;
}

.btn-link-plain:hover { text-decoration: underline; }

.live-strip {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    padding: .42rem .75rem;
    background: var(--cx-accent-soft);
    border: 1px solid #dde6ff;
    border-radius: 9px;
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    color: #46587a;
}

.live-strip b { font-weight: 650; color: var(--cx-ink); }

@media (max-width: 991.98px) {
    .entry-line .f { flex: 1 1 45%; width: auto; }
    .f-save { flex: 1 1 100%; }
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-body {
    background: linear-gradient(155deg, #eef3ff 0%, #f7fafd 45%, #eaf5ff 100%);
    min-height: 100vh;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 370px;
    background: #fff;
    border-radius: 16px;
    padding: 1.9rem 1.75rem;
    border: 1px solid var(--cx-line);
    box-shadow: 0 16px 40px rgba(35, 60, 110, .10);
}

.login-card .brand-mark { width: 42px; height: 42px; font-size: 1rem; }

/* ==========================================================================
   Print
   ========================================================================== */

.print-only { display: none; }

@media print {
    @page { size: A4 landscape; margin: 12mm; }

    /* Screen chrome has no place on paper. */
    .sidebar,
    .topbar,
    .footer,
    .filter-bar,
    .alert,
    .btn,
    .no-print,
    .table-search-holder,
    .row-actions,
    .nav-key {
        display: none !important;
    }

    .print-only { display: flex !important; }

    body { background: #fff; font-size: 10pt; }
    .portal { display: block; min-height: 0; }
    .main { padding: 0; }
    .card { border: 0; box-shadow: none; }

    .print-header {
        align-items: baseline;
        gap: .6rem;
        border-bottom: 1.5px solid #333;
        padding-bottom: .35rem;
        margin-bottom: .75rem;
    }

    .print-brand { font-weight: 700; letter-spacing: .02em; }
    .print-title { font-size: 1.2rem; font-weight: 600; }
    .print-stamp { margin-left: auto; font-size: .8rem; color: #555; }

    .table > tbody > tr:nth-child(even) > td { background: #f6f6f6 !important; }
}
