/*
 * MyForexCloud customer portal and admin area.
 *
 * One stylesheet, no build step, no framework. That is deliberate: on cPanel
 * there is no Node toolchain, and a portal that depends on `npm run build`
 * before it can be deployed is a portal that eventually gets deployed stale.
 *
 * Colours are declared once as custom properties so a rebrand is a change to
 * the :root block rather than a search and replace.
 */

:root {
    --brand:            #1b4dd8;
    --brand-dark:       #16309a;
    --brand-light:      #eaf0ff;

    --ink:              #0f1c33;
    --ink-soft:         #3c4a63;
    --ink-muted:        #6b7894;

    --surface:          #ffffff;
    --canvas:           #f4f7fc;
    --line:             #dde5f2;

    --success:          #0f7b4a;
    --success-bg:       #e7f7ef;
    --warning:          #92610a;
    --warning-bg:       #fdf3e0;
    --danger:           #b3261e;
    --danger-bg:        #fdeceb;
    --info:             #0a5f8f;
    --info-bg:          #e6f2fa;

    --radius:           12px;
    --radius-sm:        8px;
    --shadow:           0 1px 2px rgba(15, 28, 51, .06), 0 8px 24px rgba(15, 28, 51, .06);
    --shadow-sm:        0 1px 2px rgba(15, 28, 51, .08);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

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

.muted { color: var(--ink-muted); }
.small { font-size: .85rem; }
.mono  { font-family: var(--mono); font-size: .9em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------------------------------------------------------------- skip link */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: #fff;
    padding: 10px 16px;
    border-radius: 0 0 var(--radius-sm) 0;
    z-index: 100;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------- layout */

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

.sidebar {
    width: 248px;
    flex: 0 0 248px;
    background: var(--ink);
    color: #c9d4e8;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 22px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.02em;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand-mark {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), #4d7dff);
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 800; color: #fff;
}

/* White logo on the dark sidebar. The wordmark carries the company name, so
   no text sits beside it. The height also comes through as an inline style on
   the element, so a stale cached copy of this file cannot blow the layout up. */
.sidebar .brand-logo {
    height: 26px;
    width: auto;
    max-width: 100%;
    display: block;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    padding: 16px 10px 6px;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #7f8da5;
}
.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: #c9d4e8;
    font-size: .92rem;
    font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }

.nav .count {
    background: rgba(255, 255, 255, .16);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: .74rem;
    font-weight: 600;
}
.nav a.active .count { background: rgba(0, 0, 0, .25); }

.sidebar-foot { margin-top: auto; padding-top: 18px; font-size: .8rem; }
.sidebar-foot .who { padding: 0 10px 10px; color: #8d9ab4; word-break: break-all; }

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

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar h1 { margin: 0; font-size: 1.15rem; }

.content { padding: 24px 28px 48px; flex: 1; }
.content > * + * { margin-top: 18px; }

/* --------------------------------------------------------------- centred */

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 16px;
    background:
        radial-gradient(900px 400px at 50% -10%, #e4ecff 0%, transparent 70%),
        var(--canvas);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
}
.auth-card.wide { max-width: 620px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .brand-mark {
    width: 42px; height: 42px; margin: 0 auto 12px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), #4d7dff);
    display: grid; place-items: center;
    color: #fff; font-weight: 800;
}

/* Company logo on light backgrounds: sign-in, checkout, invoices. */
.auth-brand { display: inline-block; margin-bottom: 16px; }
.auth-brand:hover { text-decoration: none; }
.auth-head .brand-logo {
    height: 34px;
    width: auto;
    max-width: 220px;
    display: block;
    margin: 0 auto;
}
.auth-foot { margin-top: 20px; text-align: center; font-size: .9rem; color: var(--ink-muted); }

/* ---------------------------------------------------------------- surfaces */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 20px; }
.card-body > * + * { margin-top: 14px; }
.card-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: #fbfcfe;
    border-radius: 0 0 var(--radius) var(--radius);
}

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ------------------------------------------------------------------- stats */

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
}
.stat .label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-muted);
    font-weight: 600;
}
.stat .value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .value.sm { font-size: 1.25rem; }
.stat .note { font-size: .82rem; color: var(--ink-muted); }

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

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-muted);
    font-weight: 700;
    background: #fbfcfe;
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfe; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-muted); }
.empty .icon { font-size: 2rem; opacity: .35; display: block; margin-bottom: 8px; }

/* ------------------------------------------------------------------ badges */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 650;
    line-height: 1.5;
    white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: #eef1f6;           color: var(--ink-muted); }

/* ------------------------------------------------------------------ alerts */

.alert {
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .92rem;
}
.alert + .alert { margin-top: 10px; }
.alert-success { background: var(--success-bg); border-color: #b6e3cd; color: #0b5c37; }
.alert-danger  { background: var(--danger-bg);  border-color: #f3c4c1; color: #8c1d17; }
.alert-warning { background: var(--warning-bg); border-color: #f0dcb4; color: #7a5108; }
.alert-info    { background: var(--info-bg);    border-color: #bcdcf0; color: #08496e; }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.alert strong { font-weight: 650; }

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

.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--ink-soft);
}
label .req { color: var(--danger); }

.input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: .95rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}
.input:focus, select:focus, textarea:focus, .btn:focus-visible {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(27, 77, 216, .15);
}
.input[aria-invalid="true"] { border-color: var(--danger); }
textarea { min-height: 96px; resize: vertical; }

.hint { font-size: .82rem; color: var(--ink-muted); margin-top: 5px; }
.error { font-size: .84rem; color: var(--danger); margin-top: 5px; font-weight: 500; }

.check { display: flex; gap: 9px; align-items: flex-start; font-size: .9rem; }
.check input { margin-top: 3px; flex: 0 0 auto; }
.check label { margin: 0; font-weight: 400; color: var(--ink); }

fieldset { border: 0; margin: 0 0 18px; padding: 0; }
fieldset legend {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    color: var(--ink-muted);
    padding: 0 0 8px;
}

.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 17px;
    font: inherit;
    font-size: .93rem;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .12s, border-color .12s, opacity .12s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: #f6f8fc; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8c1d17; }

.btn-ghost     { background: transparent; color: var(--brand); padding-left: 8px; padding-right: 8px; }
.btn-ghost:hover:not(:disabled) { background: var(--brand-light); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .84rem; }

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

/* ------------------------------------------------------- definition lists */

dl.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 9px 20px; font-size: .92rem; }
dl.facts dt { color: var(--ink-muted); font-weight: 500; }
dl.facts dd { margin: 0; font-weight: 550; text-align: right; }

/* ------------------------------------------------------------------- plans */

.plan-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.plan {
    position: relative;
    display: block;
    cursor: pointer;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    transition: border-color .12s, box-shadow .12s;
}
.plan:hover { border-color: #b9c9ea; }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27, 77, 216, .12); }
.plan:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(27, 77, 216, .3); }

.plan .name { font-weight: 700; font-size: 1.02rem; }
.plan .price { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
.plan .price span { font-size: .8rem; font-weight: 500; color: var(--ink-muted); }
.plan ul { list-style: none; margin: 12px 0 0; padding: 0; font-size: .86rem; color: var(--ink-soft); }
.plan ul li { padding: 3px 0 3px 18px; position: relative; }
.plan ul li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: 700; }
.plan .tag {
    position: absolute; top: -10px; right: 14px;
    background: var(--brand); color: #fff;
    font-size: .68rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase;
    padding: 3px 9px; border-radius: 999px;
}

/* ------------------------------------------------------- segmented control */

.segmented { display: inline-flex; background: #eef1f7; border-radius: 999px; padding: 3px; gap: 3px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented .opt {
    display: block;
    padding: 7px 17px;
    border-radius: 999px;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
    white-space: nowrap;
}
.segmented label:has(input:checked) .opt { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

/* -------------------------------------------------------------- 2FA / code */

.code-input {
    font-family: var(--mono);
    font-size: 1.7rem;
    letter-spacing: .5em;
    text-align: center;
    padding: 14px 12px 14px 22px;
}

.secret-box {
    background: #f6f8fc;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    font-family: var(--mono);
    font-size: 1.02rem;
    letter-spacing: .06em;
    word-break: break-all;
    user-select: all;
}

.qr-frame {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    display: inline-block;
    line-height: 0;
}
.qr-frame svg { display: block; width: 100%; height: auto; max-width: 210px; }

.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding: 0 0 14px 34px; font-size: .93rem; }
.steps li::before {
    content: counter(step);
    position: absolute; left: 0; top: 0;
    width: 23px; height: 23px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand);
    font-size: .76rem; font-weight: 700;
    display: grid; place-items: center;
}

/* -------------------------------------------------------------- pagination */

.pagination { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; padding: 14px 20px; }
.pagination a, .pagination span {
    padding: 6px 11px;
    border-radius: var(--radius-sm);
    font-size: .87rem;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-soft);
}
.pagination a:hover { background: #f4f7fc; text-decoration: none; }
.pagination .active span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .disabled span { opacity: .45; }
.pagination svg { width: 15px; height: 15px; vertical-align: -2px; }

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

.divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }

.inline-form { display: inline; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; }

.totals { margin-left: auto; min-width: 250px; }
.totals dl.facts dd { font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--line); padding-top: 9px; margin-top: 4px; font-size: 1.12rem; }

.attention { border-left: 3px solid var(--warning); }
.attention.danger { border-left-color: var(--danger); }

/* ------------------------------------------------------------------ mobile */

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; padding: 12px; }
    .sidebar .brand { padding-bottom: 12px; }
    .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
    .nav a { white-space: nowrap; padding: 8px 13px; }
    .nav-label { display: none; }
    .sidebar-foot { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
    .sidebar-foot .who { padding: 0; }
    .topbar { padding: 12px 16px; }
    .content { padding: 16px 16px 40px; }
    .totals { min-width: 0; width: 100%; }
}

/* ------------------------------------------------------------------- print */

@media print {
    .sidebar, .topbar, .no-print, .btn { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; }
    a { color: inherit; text-decoration: none; }
}

.invoice-doc { max-width: 820px; margin: 0 auto; background: #fff; padding: 40px; }
.invoice-doc .head { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; margin-bottom: 30px; }
.invoice-doc .head h1 { font-size: 1.9rem; letter-spacing: -.02em; }
.invoice-doc .parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 26px; margin-bottom: 26px; }
.invoice-doc .parties h4 {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
    color: var(--ink-muted); margin-bottom: 6px;
}

/* --------------------------------------------------------------- danger zone */

/* Destructive actions look different from everything else on purpose: an
   irreversible delete should never be one careless click away from a save. */
.danger-zone { border-color: #f3c4c1; }
.danger-zone .card-head {
    background: var(--danger-bg);
    border-bottom-color: #f3c4c1;
}
.danger-zone .card-head h2 { color: #8c1d17; }
.confirm-delete label { display: block; margin-bottom: 6px; font-size: .9rem; }
.confirm-delete .btn-row { align-items: center; gap: 10px; flex-wrap: wrap; }
.confirm-delete input[type="text"] {
    flex: 1 1 260px;
    min-width: 220px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font: inherit;
    background: var(--surface);
}
.confirm-delete input[type="text"]:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 1px;
    border-color: var(--danger);
}

/* Money tiles: a coloured left edge so "overdue" is visible without reading. */
.stat.good { border-left: 3px solid var(--success); }
.stat.warn { border-left: 3px solid var(--warning); }
.stat.bad  { border-left: 3px solid var(--danger); }
.stat.good .value { color: var(--success); }
.stat.bad .value  { color: var(--danger); }
.stat .note + .note { margin-top: 1px; }

/* ------------------------------------------------------- support session */

/* Shown on every page while an administrator is signed in as a customer.
   Deliberately impossible to miss: the danger with impersonation is not the
   mechanism, it is forgetting that it is switched on. */
.impersonating {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 10px 18px;
    background: #4a2f00;
    color: #ffe9bf;
    font-size: .9rem;
    text-align: center;
}
.impersonating strong { color: #fff; }
.impersonating .btn {
    background: #ffd88a;
    border-color: #ffd88a;
    color: #3a2400;
    font-weight: 600;
}
.impersonating .btn:hover { background: #fff; border-color: #fff; }

/* A share-of-the-best-month bar in the income report. No chart library: it has
   to render from a static file on cPanel, work offline, and print. */
.bar {
    display: inline-block;
    height: 8px;
    min-width: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--brand), #4d7dff);
    vertical-align: middle;
}
