/*
 * FX Group design system.
 *
 * Ported from /var/www/cr's platform shell (resources/views/layouts/
 * platform.blade.php — the --pf-* tokens, white sidebar, KPI cards,
 * tables and pill badges) and re-coloured for a trading product:
 * deep navy chrome, green for primary actions / BUY / profit, red for
 * SELL / loss. Plain CSS, no build step.
 */

:root {
    --fx-navy: #0c1a33;
    --fx-navy-ink: #07101f;
    --fx-green: #0f9f6e;
    --fx-green-ink: #0b7d57;
    --fx-green-lt: rgba(15, 159, 110, 0.1);
    --fx-red: #dc3545;
    --fx-red-ink: #b42331;
    --fx-red-lt: rgba(220, 53, 69, 0.09);
    --fx-blue: #2563eb;
    --fx-blue-lt: rgba(37, 99, 235, 0.09);
    --fx-amber: #b45309;
    --fx-amber-lt: rgba(217, 119, 6, 0.12);

    --fx-text: #0c1a33;
    --fx-muted: #5b6478;
    --fx-faint: #8a93a6;
    --fx-line: color-mix(in srgb, #0c1a33 10%, #fff);
    --fx-slate-100: color-mix(in srgb, #0c1a33 6%, #fff);
    --fx-canvas: color-mix(in srgb, #0c1a33 3.5%, #fff);
    --fx-surface: #fff;
    --fx-radius: 16px;
    --fx-radius-sm: 10px;
    --fx-font: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --fx-shadow: 0 1px 2px rgba(12, 26, 51, 0.04);
    --fx-shadow-lg: 0 10px 30px rgba(12, 26, 51, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; font-family: var(--fx-font); font-size: 15px; line-height: 1.5;
    background: var(--fx-canvas); color: var(--fx-text);
}
a { color: var(--fx-green-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; line-height: 1.2; }
p { margin: 0 0 0.75rem; }
img { max-width: 100%; }
.num, .mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--fx-muted); }
.faint { color: var(--fx-faint); }
.small { font-size: 0.8rem; }
.text-green { color: var(--fx-green-ink); }
.text-red { color: var(--fx-red-ink); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Brand mark ───────────────────────────────────────────────── */
.fx-brand { display: flex; align-items: center; gap: 0.6rem; color: var(--fx-text); text-decoration: none !important; }
.fx-brand-mark {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    background: linear-gradient(140deg, var(--fx-navy) 0%, #183463 100%);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(12, 26, 51, 0.25);
}
.fx-brand-mark svg { width: 20px; height: 20px; }
.fx-brand-word { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.02em; }
.fx-brand-word span { color: var(--fx-green); }
.fx-brand-sub { display: block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--fx-green-ink); }

/* ── App shell ────────────────────────────────────────────────── */
.fx-shell { display: flex; min-height: 100vh; }
.fx-nav {
    width: 256px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--fx-line);
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.02);
}
.fx-nav-brand { height: 72px; padding: 0 1.25rem; display: flex; align-items: center; border-bottom: 1px solid var(--fx-line); }
.fx-nav-links { flex: 1; overflow-y: auto; padding: 0.5rem 0 1rem; }
.fx-nav-section {
    display: block; padding: 1.25rem 1.25rem 0.4rem; font-size: 0.64rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.1em; color: var(--fx-faint);
}
.fx-nav-link {
    display: flex; align-items: center; gap: 0.7rem; margin: 0.12rem 0.85rem; padding: 0.58rem 0.8rem;
    border-radius: var(--fx-radius-sm); font-size: 0.88rem; font-weight: 500; color: var(--fx-muted);
    transition: background 0.15s ease, color 0.15s ease;
}
.fx-nav-link i { font-size: 1.15rem; width: 20px; text-align: center; color: var(--fx-faint); }
.fx-nav-link:hover { background: var(--fx-slate-100); color: var(--fx-text); text-decoration: none; }
.fx-nav-link.active { background: var(--fx-green-lt); color: var(--fx-green-ink); font-weight: 700; }
.fx-nav-link.active i { color: var(--fx-green); }
.fx-nav-link .fx-count {
    margin-left: auto; background: var(--fx-red); color: #fff; font-size: 0.65rem; font-weight: 700;
    border-radius: 999px; padding: 0.05rem 0.45rem;
}
.fx-nav-footer { padding: 0.85rem; border-top: 1px solid var(--fx-line); }
.fx-user { display: flex; align-items: center; gap: 0.65rem; padding: 0.35rem 0.4rem 0.55rem; min-width: 0; }
.fx-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    background: var(--fx-navy); color: #fff; font-weight: 700; font-size: 0.8rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.fx-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fx-avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }
.fx-avatar.xl { width: 112px; height: 112px; font-size: 2rem; border: 4px solid #fff; box-shadow: var(--fx-shadow-lg); }
.fx-user-name { font-size: 0.84rem; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-user-role { font-size: 0.7rem; color: var(--fx-green-ink); font-weight: 600; }
.fx-logout {
    display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.5rem 0.6rem; border: 0; background: none;
    border-radius: var(--fx-radius-sm); font: 600 0.84rem var(--fx-font); color: var(--fx-muted); cursor: pointer;
}
.fx-logout:hover { background: var(--fx-red-lt); color: var(--fx-red-ink); }

.fx-main { margin-left: 256px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fx-topbar {
    background: #fff; border-bottom: 1px solid var(--fx-line); min-height: 72px; padding: 0.9rem 2rem;
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.fx-topbar h1 { font-size: 1.2rem; font-weight: 700; }
.fx-topbar-sub { font-size: 0.8rem; color: var(--fx-muted); margin-top: 0.15rem; }
.fx-topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.fx-icon-btn {
    position: relative; width: 38px; height: 38px; border-radius: var(--fx-radius-sm); border: 1px solid var(--fx-line);
    background: #fff; color: var(--fx-muted); display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
    cursor: pointer;
}
.fx-icon-btn:hover { color: var(--fx-text); text-decoration: none; background: var(--fx-canvas); }
.fx-icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--fx-red); border: 2px solid #fff; }
.fx-nav-toggle { display: none; }
.fx-content { padding: 1.75rem 2rem 3rem; max-width: 1400px; width: 100%; }
.fx-backdrop { display: none; }

@media (max-width: 991.98px) {
    .fx-nav { transform: translateX(-100%); transition: transform 0.2s ease; }
    .fx-nav.open { transform: none; box-shadow: var(--fx-shadow-lg); }
    .fx-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(12, 26, 51, 0.35); z-index: 35; }
    .fx-main { margin-left: 0; }
    .fx-nav-toggle { display: inline-flex; }
    .fx-topbar { padding: 0.75rem 1rem; min-height: 64px; }
    .fx-topbar h1 { font-size: 1.05rem; }
    .fx-content { padding: 1.1rem 1rem 2.5rem; }
}

/* ── Cards / KPIs ─────────────────────────────────────────────── */
.card {
    background: var(--fx-surface); border: 1px solid var(--fx-line); border-radius: var(--fx-radius);
    box-shadow: var(--fx-shadow); min-width: 0;
}
.card-header {
    padding: 0.95rem 1.25rem; border-bottom: 1px solid var(--fx-line);
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
}
.card-header h2 { font-size: 0.95rem; font-weight: 700; }
.card-header .sub { font-size: 0.75rem; color: var(--fx-muted); font-weight: 400; margin-top: 0.1rem; }
.card-body { padding: 1.15rem 1.25rem; }
.card-footer { padding: 0.8rem 1.25rem; border-top: 1px solid var(--fx-line); background: var(--fx-canvas); border-radius: 0 0 var(--fx-radius) var(--fx-radius); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 1rem; }
@media (max-width: 1199.98px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 767.98px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
/* Stat tiles stay two-up on phones (see Mobile section below). */

.kpi { padding: 1.05rem 1.2rem; display: flex; flex-direction: column; gap: 0.2rem; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.kpi-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fx-muted); }
.kpi-icon { width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0; }
.kpi-icon.green { background: var(--fx-green-lt); color: var(--fx-green-ink); }
.kpi-icon.blue { background: var(--fx-blue-lt); color: var(--fx-blue); }
.kpi-icon.amber { background: var(--fx-amber-lt); color: var(--fx-amber); }
.kpi-icon.red { background: var(--fx-red-lt); color: var(--fx-red-ink); }
.kpi-icon.navy { background: var(--fx-slate-100); color: var(--fx-navy); }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 0.75rem; color: var(--fx-muted); }

.split-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--fx-slate-100); }
.split-bar span { display: block; height: 100%; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.78rem; color: var(--fx-muted); margin-top: 0.6rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 0.35rem; vertical-align: -1px; }

.chart-wrap { position: relative; height: 260px; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 1.25rem; font-size: 0.88rem; margin: 0; }
.dl dt { color: var(--fx-muted); }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left; padding: 0.65rem 1.1rem; background: var(--fx-canvas); font-size: 0.66rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--fx-muted); border-bottom: 1px solid var(--fx-line); white-space: nowrap;
}
.table td { padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--fx-line); font-size: 0.86rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--fx-canvas) 60%, #fff); }
.table .right, .table th.right { text-align: right; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 0.74rem; color: var(--fx-muted); margin-top: 0.1rem; }
.cell-user { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--fx-muted); }
.empty i { font-size: 2rem; color: var(--fx-faint); display: block; margin-bottom: 0.5rem; }
.row-actions { display: flex; gap: 0.3rem; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 999px;
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.badge-success { background: var(--fx-green-lt); color: var(--fx-green-ink); }
.badge-danger { background: var(--fx-red-lt); color: var(--fx-red-ink); }
.badge-warning { background: var(--fx-amber-lt); color: var(--fx-amber); }
.badge-info { background: var(--fx-blue-lt); color: var(--fx-blue); }
.badge-secondary { background: var(--fx-slate-100); color: var(--fx-muted); }
.badge-verified { background: var(--fx-blue-lt); color: var(--fx-blue); text-transform: none; letter-spacing: 0; font-size: 0.72rem; }
.dir { font-weight: 800; letter-spacing: 0.04em; padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.72rem; }
.dir-buy { background: var(--fx-green); color: #fff; }
.dir-sell { background: var(--fx-red); color: #fff; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.6rem 1.05rem;
    border-radius: var(--fx-radius-sm); border: 1px solid transparent; font: 600 0.88rem/1.2 var(--fx-font);
    cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn i { font-size: 1.05em; }
.btn-primary { background: var(--fx-green); color: #fff; }
.btn-primary:hover { background: var(--fx-green-ink); }
.btn-dark { background: var(--fx-navy); color: #fff; }
.btn-dark:hover { background: var(--fx-navy-ink); }
.btn-outline { background: #fff; border-color: var(--fx-line); color: var(--fx-text); }
.btn-outline:hover { background: var(--fx-canvas); border-color: color-mix(in srgb, #0c1a33 18%, #fff); }
.btn-danger { background: #fff; border-color: color-mix(in srgb, var(--fx-red) 35%, #fff); color: var(--fx-red-ink); }
.btn-danger:hover { background: var(--fx-red-lt); }
.btn-ghost { background: none; color: var(--fx-muted); padding: 0.4rem 0.55rem; }
.btn-ghost:hover { background: var(--fx-slate-100); color: var(--fx-text); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.4rem; font-size: 1rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 767.98px) { .form-grid { grid-template-columns: 1fr; } }
.field label, .label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--fx-text); }
.field .hint { font-size: 0.75rem; color: var(--fx-muted); margin-top: 0.3rem; }
.input, .select, .textarea {
    width: 100%; padding: 0.62rem 0.8rem; border: 1px solid color-mix(in srgb, #0c1a33 16%, #fff); border-radius: var(--fx-radius-sm);
    background: #fff; font: 400 0.92rem var(--fx-font); color: var(--fx-text); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 110px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--fx-green); box-shadow: 0 0 0 3px var(--fx-green-lt); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--fx-red); }
.invalid { color: var(--fx-red-ink); font-size: 0.76rem; margin-top: 0.3rem; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--fx-radius-sm) 0 0 var(--fx-radius-sm); }
.input-group .addon {
    display: flex; align-items: center; padding: 0 0.8rem; border: 1px solid color-mix(in srgb, #0c1a33 16%, #fff); border-left: 0;
    border-radius: 0 var(--fx-radius-sm) var(--fx-radius-sm) 0; background: var(--fx-canvas); color: var(--fx-muted); font-size: 0.85rem; white-space: nowrap;
}
.input-group .addon.pre { border-left: 1px solid color-mix(in srgb, #0c1a33 16%, #fff); border-right: 0; border-radius: var(--fx-radius-sm) 0 0 var(--fx-radius-sm); }
.input-group .addon.pre + .input { border-radius: 0 var(--fx-radius-sm) var(--fx-radius-sm) 0; }
.check { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.88rem; cursor: pointer; }
.check input { margin-top: 0.2rem; width: 16px; height: 16px; accent-color: var(--fx-green); flex-shrink: 0; }
.segmented { display: inline-flex; background: var(--fx-slate-100); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 0.45rem 1.1rem; border-radius: 9px; font-weight: 700; font-size: 0.85rem; cursor: pointer; color: var(--fx-muted); }
.segmented input:checked + span { background: #fff; color: var(--fx-text); box-shadow: var(--fx-shadow); }
.segmented input:checked + span.buy { background: var(--fx-green); color: #fff; }
.segmented input:checked + span.sell { background: var(--fx-red); color: #fff; }
.segmented input:focus-visible + span { outline: 2px solid var(--fx-green); }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.25rem; }

.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--fx-line); }
.toolbar .input, .toolbar .select { width: auto; padding: 0.45rem 0.7rem; font-size: 0.85rem; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 320px; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tab { padding: 0.42rem 0.8rem; border-radius: 9px; font-size: 0.82rem; font-weight: 600; color: var(--fx-muted); }
.tab:hover { background: var(--fx-slate-100); text-decoration: none; color: var(--fx-text); }
.tab.active { background: var(--fx-navy); color: #fff; }
.tab .n { opacity: 0.7; font-weight: 500; margin-left: 0.2rem; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
    display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.8rem 1rem; border-radius: 12px; font-size: 0.88rem;
    border: 1px solid transparent; margin-bottom: 1rem;
}
.alert i { font-size: 1.15rem; flex-shrink: 0; margin-top: 0.05rem; }
.alert-success { background: var(--fx-green-lt); border-color: color-mix(in srgb, var(--fx-green) 25%, #fff); color: var(--fx-green-ink); }
.alert-error { background: var(--fx-red-lt); border-color: color-mix(in srgb, var(--fx-red) 25%, #fff); color: var(--fx-red-ink); }
.alert-info { background: var(--fx-blue-lt); border-color: color-mix(in srgb, var(--fx-blue) 20%, #fff); color: #1d4ed8; }
.alert-warning { background: var(--fx-amber-lt); border-color: color-mix(in srgb, #d97706 25%, #fff); color: var(--fx-amber); }
.alert ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }

/* ── Signal card (member feed, public page) ───────────────────── */
.signal { padding: 1rem 1.15rem; }
.signal + .signal { border-top: 1px solid var(--fx-line); }
.signal-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.signal-pair { font-weight: 800; font-size: 1.05rem; letter-spacing: 0.02em; }
.signal-meta { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.signal-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 0.5rem; margin-top: 0.8rem; }
.level { background: var(--fx-canvas); border-radius: 10px; padding: 0.5rem 0.7rem; }
.level-k { font-size: 0.63rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fx-muted); }
.level-v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.level.sl .level-v { color: var(--fx-red-ink); }
.level.tp .level-v { color: var(--fx-green-ink); }
.level.locked .level-v { color: var(--fx-faint); letter-spacing: 0.1em; }
.signal-analysis { margin-top: 0.7rem; font-size: 0.88rem; color: var(--fx-muted); white-space: pre-line; }
.signal-foot { margin-top: 0.6rem; font-size: 0.75rem; color: var(--fx-faint); display: flex; gap: 0.9rem; flex-wrap: wrap; }

/* ── Pagination ───────────────────────────────────────────────── */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--fx-muted); }
.pager-links { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.pager-links a, .pager-links span {
    min-width: 32px; padding: 0.3rem 0.6rem; border: 1px solid var(--fx-line); border-radius: 8px; text-align: center;
    color: var(--fx-text); font-weight: 600; background: #fff;
}
.pager-links a:hover { text-decoration: none; border-color: var(--fx-green); color: var(--fx-green-ink); }
.pager-links .current { background: var(--fx-navy); border-color: var(--fx-navy); color: #fff; }
.pager-links .disabled { color: var(--fx-faint); background: transparent; }

/* ── Misc ─────────────────────────────────────────────────────── */
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-actions h2 { font-size: 1.05rem; font-weight: 700; }
.banner { border-radius: 12px; padding: 0.85rem 1rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.banner-warning { background: var(--fx-amber-lt); color: var(--fx-amber); }
.banner-dark { background: var(--fx-navy); color: #fff; }
.banner .btn { margin-left: auto; }
.copy-field { display: flex; gap: 0.4rem; align-items: center; background: var(--fx-canvas); border: 1px solid var(--fx-line); border-radius: 10px; padding: 0.35rem 0.35rem 0.35rem 0.75rem; }
.copy-field code { flex: 1; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--fx-line); margin: 1.1rem 0; border: 0; }
.notice-list a { display: flex; gap: 0.8rem; align-items: flex-start; padding: 0.85rem 1.2rem; border-bottom: 1px solid var(--fx-line); color: inherit; }
.notice-icon { flex: 0 0 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--fx-canvas); color: var(--fx-muted, #5b6b88); font-size: 1.1rem; }
.notice-list .unread .notice-icon { background: rgba(15, 159, 110, 0.12); color: var(--fx-green); }
.notice-body { flex: 1; min-width: 0; display: block; }
.notice-head { display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline; }
.notice-text { display: block; margin-top: 0.2rem; overflow-wrap: anywhere; }
.notice-list a:hover { background: var(--fx-canvas); text-decoration: none; }
.notice-list .unread { border-left: 3px solid var(--fx-green); }
.photo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
@media (max-width: 479.98px) { .hide-xs { display: none; } }
.stack { min-width: 0; }


/* ── Mobile ───────────────────────────────────────────────────── */
/* Stat (KPI) tiles: always two per row on phones, compact. A lone last tile spans the row. */
@media (max-width: 767.98px) {
    .grid-2:has(> .kpi), .grid-3:has(> .kpi), .grid-4:has(> .kpi) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
    .grid:has(> .kpi) > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .kpi { padding: 0.8rem 0.85rem; }
    .kpi-top { margin-bottom: 0.15rem; }
    .kpi-icon { width: 26px; height: 26px; font-size: 0.9rem; border-radius: 8px; }
    .kpi-label { font-size: 0.62rem; letter-spacing: 0.04em; }
    .kpi-value { font-size: 1.2rem; overflow-wrap: anywhere; }
    .kpi-sub { font-size: 0.7rem; }
}

@media (max-width: 767.98px) {
    /* ≥16px stops iOS Safari zooming the page when a field is focused. */
    .input, .select, .textarea, .toolbar .input, .toolbar .select { font-size: 16px; }
    .toolbar .search { max-width: none; flex-basis: 100%; }
    .toolbar .input, .toolbar .select { flex: 1 1 auto; }
    /* Comfortable tap targets. */
    .btn { min-height: 42px; }
    .btn-sm { min-height: 36px; padding: 0.45rem 0.8rem; }
    .fx-icon-btn { min-width: 42px; min-height: 42px; }
    .btn-block-mobile, .form-actions .btn { width: 100%; }
    .form-actions { flex-direction: column-reverse; }
    .card-header { flex-wrap: wrap; gap: 0.5rem; }
    code { overflow-wrap: anywhere; word-break: break-all; }
    .alert { font-size: 0.85rem; }
    .chart-wrap { height: 220px; }
}

/* Tables become labelled cards on phones: each row a block, each cell
   "Label ····· value". Labels come from the <th> text (layout script sets
   data-label). Tables marked .table-keep keep the grid layout. */
@media (max-width: 639.98px) {
    .table-wrap:has(table.table:not(.table-keep)) { overflow-x: visible; }
    table.table:not(.table-keep) thead { display: none; }
    table.table:not(.table-keep), table.table:not(.table-keep) tbody { display: block; width: 100%; }
    table.table:not(.table-keep) tr { display: block; padding: 0.75rem 1rem; border-bottom: 1px solid var(--fx-line); }
    table.table:not(.table-keep) tr:last-child { border-bottom: 0; }
    table.table:not(.table-keep) tbody tr:hover td { background: none; }
    table.table:not(.table-keep) td {
        display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem;
        padding: 0.28rem 0; border: 0; text-align: right; font-size: 0.86rem; min-width: 0;
    }
    table.table:not(.table-keep) td > * { min-width: 0; }
    table.table:not(.table-keep) td::before {
        content: attr(data-label); flex: 0 0 auto; max-width: 45%; text-align: left;
        font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fx-muted); padding-top: 0.15rem;
    }
    /* First cell is the row's heading: full width, no label. */
    table.table:not(.table-keep) td:first-child { display: block; text-align: left; padding-bottom: 0.4rem; font-size: 0.92rem; }
    table.table:not(.table-keep) td:first-child::before { display: none; }
    /* Cells with no header (action buttons) sit on their own line. */
    table.table:not(.table-keep) td[data-label=""] { justify-content: flex-end; padding-top: 0.5rem; }
    table.table:not(.table-keep) td[data-label=""]::before { display: none; }
    table.table:not(.table-keep) td.empty, table.table:not(.table-keep) td[colspan] { display: block; text-align: center; }
    table.table:not(.table-keep) td[colspan]::before { display: none; }
    table.table:not(.table-keep) .nowrap { white-space: normal; }
    .badge { white-space: nowrap; }
}

/* ── Notification bell dropdown ───────────────────────────────── */
.fx-notif { position: relative; }
.fx-notif-count {
    position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--fx-red); color: #fff; border: 2px solid #fff; font-size: 0.65rem; font-weight: 800; line-height: 14px; text-align: center;
}
.fx-notif-panel {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 380px; max-width: calc(100vw - 24px);
    background: #fff; border: 1px solid var(--fx-line); border-radius: 14px; box-shadow: 0 18px 40px -12px rgba(12, 26, 51, 0.28);
    display: flex; flex-direction: column; overflow: hidden;
}
.fx-notif-panel[hidden] { display: none; }
.fx-notif-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.7rem 0.9rem 0.7rem 1.1rem; border-bottom: 1px solid var(--fx-line); }
.fx-notif-head form { margin: 0; }
.fx-notif-list { max-height: min(60vh, 440px); overflow-y: auto; overscroll-behavior: contain; }
.fx-notif-list a { padding: 0.75rem 1rem; }
.fx-notif-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fx-notif-all { display: flex; align-items: center; justify-content: center; gap: 0.35rem; padding: 0.8rem; border-top: 1px solid var(--fx-line); font-weight: 700; font-size: 0.88rem; color: var(--fx-green-ink); background: var(--fx-canvas); }
.fx-notif-all:hover { text-decoration: none; background: color-mix(in srgb, var(--fx-canvas) 70%, #e9eef6); }
@media (max-width: 639.98px) {
    /* Phones: a full-width sheet just under the top bar. */
    .fx-notif { position: static; }
    .fx-notif-panel { position: fixed; top: 64px; left: 8px; right: 8px; width: auto; max-width: none; }
    .fx-notif-list { max-height: calc(100vh - 200px); }
}

/* Tabs (notifications page + bell dropdown) */
.fx-tabs { display: flex; gap: 0.25rem; padding: 0 0.75rem; border-bottom: 1px solid var(--fx-line); }
.fx-tabs a, .fx-tabs button {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.85rem 0.8rem; margin-bottom: -1px; border: 0; background: none;
    border-bottom: 2px solid transparent; color: var(--fx-muted); font: 600 0.9rem/1 var(--fx-font); cursor: pointer; text-decoration: none;
}
.fx-tabs a:hover, .fx-tabs button:hover { color: var(--fx-text); text-decoration: none; }
.fx-tabs .active { color: var(--fx-text); border-bottom-color: var(--fx-green); }
.fx-tabs-sm { padding: 0; border-bottom: 0; }
.fx-tabs-sm button { padding: 0.35rem 0.55rem 0.55rem; font-size: 0.86rem; }
.fx-tab-count { min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--fx-red); color: #fff; font-size: 0.68rem; font-weight: 800; line-height: 1.4; text-align: center; }
.fx-notif-head { padding-top: 0.45rem; padding-bottom: 0.35rem; }
.fx-notif-head form[hidden] { display: none; }
.fx-email-frame { display: block; width: 100%; height: min(78vh, 1100px); border: 0; background: #F4F6FA; }

/* ── Share card (provider Members) & join QR (public page) ─────── */
.share-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 1.5rem; align-items: start; }
.share-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.share-btn {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.8rem; border: 1px solid var(--fx-line); border-radius: 999px;
    background: #fff; color: var(--fx-text); font: 600 0.85rem/1 var(--fx-font); cursor: pointer; text-decoration: none;
}
.share-btn:hover { background: var(--fx-canvas); text-decoration: none; }
.share-btn i { font-size: 1.1rem; }
.share-btn[hidden] { display: none; }
.share-qr { display: grid; gap: 0.6rem; justify-items: center; padding: 0.9rem; border: 1px solid var(--fx-line); border-radius: 14px; background: #fff; }
.share-qr-code svg, .join-qr-code svg { display: block; width: 100%; height: auto; max-width: 200px; }
.share-qr-actions { display: flex; gap: 0.4rem; }
.join-qr-code { display: inline-block; padding: 0.4rem; border: 1px solid var(--fx-line); border-radius: 12px; line-height: 0; }
.join-qr-code svg { max-width: 180px; }
@media (max-width: 767.98px) {
    .share-grid { grid-template-columns: minmax(0, 1fr); }
    .share-qr { justify-self: stretch; }
    .share-btn { min-height: 40px; }
}

/* ── System ▸ Roles & Activity logs ───────────────────────────── */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.85rem; }
.perm-group { border: 1px solid var(--fx-line); border-radius: 12px; padding: 0.75rem 0.9rem 0.85rem; margin: 0; min-width: 0; }
.perm-group legend { padding: 0 0.35rem; font-size: 0.86rem; }
.perm-group .check { margin-top: 0.45rem; }
.perm-item { display: flex; align-items: center; gap: 0.45rem; font-size: 0.86rem; margin-top: 0.4rem; }
.perm-item.on i { color: var(--fx-green-ink); }
.perm-item.off { color: var(--fx-faint); }
.diff-old { background: var(--fx-red-lt); color: var(--fx-red-ink); overflow-wrap: anywhere; }
.diff-new { background: var(--fx-green-lt); color: var(--fx-green-ink); overflow-wrap: anywhere; }
