/* =====================================================================
   Zefinx Client Portal — theme + layout stylesheet
   Fully responsive (mobile / tablet / desktop). Six switchable themes
   driven by CSS custom properties on <html data-theme="...">.
   ===================================================================== */

:root {
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-w: 264px;
    --topbar-h: 62px;
    --transition: 0.2s ease;
    --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- Theme palettes ---------- */
html[data-theme="dark"] {
    --bg: #0f172a; --bg-2: #1e293b; --surface: rgba(30, 41, 59, 0.72);
    --surface-solid: #1e293b; --border: rgba(148, 163, 184, 0.18);
    --text: #e2e8f0; --text-muted: #94a3b8; --primary: #6366f1; --primary-2: #818cf8;
    --success: #22c55e; --danger: #ef4444; --warning: #f59e0b; --info: #38bdf8;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
html[data-theme="light"] {
    --bg: #f1f5f9; --bg-2: #e2e8f0; --surface: rgba(255, 255, 255, 0.85);
    --surface-solid: #ffffff; --border: rgba(15, 23, 42, 0.1);
    --text: #0f172a; --text-muted: #64748b; --primary: #4f46e5; --primary-2: #6366f1;
    --success: #16a34a; --danger: #dc2626; --warning: #d97706; --info: #0ea5e9;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
html[data-theme="black"] {
    --bg: #000000; --bg-2: #0a0a0a; --surface: rgba(20, 20, 20, 0.8);
    --surface-solid: #111111; --border: rgba(255, 255, 255, 0.1);
    --text: #f5f5f5; --text-muted: #9ca3af; --primary: #ffffff; --primary-2: #d4d4d4;
    --success: #22c55e; --danger: #ef4444; --warning: #f59e0b; --info: #38bdf8;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
html[data-theme="gold"] {
    --bg: #14110b; --bg-2: #1f1a10; --surface: rgba(35, 29, 16, 0.8);
    --surface-solid: #211b10; --border: rgba(212, 175, 55, 0.22);
    --text: #f6efdc; --text-muted: #c9b98a; --primary: #d4af37; --primary-2: #e9c968;
    --success: #7cb342; --danger: #e05656; --warning: #f0a020; --info: #6bb8c9;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
html[data-theme="blue"] {
    --bg: #0b1a2f; --bg-2: #10233f; --surface: rgba(16, 35, 63, 0.78);
    --surface-solid: #10233f; --border: rgba(96, 165, 250, 0.2);
    --text: #e0ecff; --text-muted: #93b4d8; --primary: #2563eb; --primary-2: #3b82f6;
    --success: #22c55e; --danger: #ef4444; --warning: #f59e0b; --info: #38bdf8;
    --shadow: 0 10px 30px rgba(2, 15, 40, 0.5);
}
html[data-theme="corporate"] {
    --bg: #eef2f6; --bg-2: #dfe6ee; --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff; --border: rgba(30, 58, 95, 0.12);
    --text: #16324f; --text-muted: #5b7286; --primary: #0f4c81; --primary-2: #1769aa;
    --success: #198754; --danger: #b02a37; --warning: #cc8a00; --info: #0d6efd;
    --shadow: 0 10px 30px rgba(15, 50, 79, 0.08);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    background: radial-gradient(1200px 600px at 100% -10%, var(--bg-2), var(--bg)) fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}
a { color: var(--primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; }

/* ---------- Auth / login ---------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
    width: 100%; max-width: 420px; background: var(--surface);
    backdrop-filter: blur(14px); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px;
}
.auth-logo { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.5px; }
.auth-logo span { color: var(--primary-2); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--surface-solid);
    border-right: 1px solid var(--border); position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column; z-index: 1040;
    transition: transform var(--transition);
}
.sidebar__brand {
    height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
    padding: 0 20px; font-weight: 800; font-size: 1.15rem;
    border-bottom: 1px solid var(--border);
}
.sidebar__brand span { color: var(--primary-2); }
.sidebar__nav { padding: 12px; overflow-y: auto; flex: 1; }
.sidebar__nav a {
    display: flex; align-items: center; gap: 12px; padding: 11px 14px;
    border-radius: var(--radius-sm); color: var(--text-muted); font-weight: 500;
    margin-bottom: 4px; transition: background var(--transition), color var(--transition);
}
.sidebar__nav a i { width: 20px; text-align: center; }
.sidebar__nav a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.sidebar__nav a.active { background: var(--primary); color: #fff; }
html[data-theme="black"] .sidebar__nav a.active,
html[data-theme="gold"] .sidebar__nav a.active { color: #111; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
    height: var(--topbar-h); position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 12px; padding: 0 20px;
    background: var(--surface); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar__title { font-weight: 700; font-size: 1.05rem; }
.topbar__spacer { flex: 1; }
.icon-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
    display: inline-grid; place-items: center; transition: background var(--transition);
}
.icon-btn:hover { background: var(--bg-2); }
#sidebarToggle { display: none; }

.content { padding: 22px; }

/* ---------- Cards ---------- */
.card-z {
    background: var(--surface); backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; transition: transform var(--transition);
}
.card-z:hover { transform: translateY(-2px); }

.stat-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.stat { display: flex; align-items: center; gap: 14px; }
.stat__icon {
    width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary-2);
    font-size: 1.1rem;
}
.stat__label { color: var(--text-muted); font-size: 0.8rem; }
.stat__value { font-size: 1.35rem; font-weight: 800; }

.account-grid {
    display: grid; gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.acct__head { display: flex; justify-content: space-between; align-items: flex-start; }
.acct__name { font-weight: 700; font-size: 1.05rem; }
.acct__meta { color: var(--text-muted); font-size: 0.82rem; }
.acct__rows { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.acct__row { display: flex; justify-content: space-between; font-size: 0.86rem; }
.acct__row span:first-child { color: var(--text-muted); }

/* ---------- Badges / indicators ---------- */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot--on { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); }
.dot--off { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 25%, transparent); }
.badge-z { padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-on { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.badge-off { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.badge-warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.text-profit { color: var(--success); font-weight: 700; }
.text-loss { color: var(--danger); font-weight: 700; }

/* ---------- Forms / buttons ---------- */
.form-label { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
.input-z {
    width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
    background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
    transition: border var(--transition);
}
.input-z:focus { outline: none; border-color: var(--primary); }
.btn-z {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    padding: 11px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer;
    background: var(--primary); color: #fff; font-weight: 600; transition: opacity var(--transition);
}
html[data-theme="black"] .btn-z, html[data-theme="gold"] .btn-z { color: #111; }
.btn-z:hover { opacity: 0.9; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table-z { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
table.table-z th, table.table-z td { padding: 11px 14px; text-align: left; white-space: nowrap; }
table.table-z thead th {
    color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--surface-solid);
}
table.table-z tbody tr { border-bottom: 1px solid var(--border); }
table.table-z tbody tr:hover { background: var(--bg-2); }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 2000; display: grid; gap: 10px; }
.toast-z {
    background: var(--surface-solid); border: 1px solid var(--border); color: var(--text);
    border-left: 4px solid var(--primary); padding: 12px 16px; border-radius: 12px;
    box-shadow: var(--shadow); min-width: 240px; animation: slidein 0.25s ease;
}
.toast-z.ok { border-left-color: var(--success); }
.toast-z.err { border-left-color: var(--danger); }
.toast-z.warn { border-left-color: var(--warning); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Overlay for mobile sidebar ---------- */
.backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 1035;
}

.muted { color: var(--text-muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.mt-3 { margin-top: 18px; } .mt-2 { margin-top: 12px; } .mb-2 { margin-bottom: 12px; }
.spin { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Responsive: tablet + mobile
   ===================================================================== */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    :root { --sidebar-w: 260px; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    #sidebarToggle { display: inline-grid; }
    .backdrop.show { display: block; }
    .acct__rows { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
    .content { padding: 14px; }
    .auth-card { padding: 24px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .topbar__title { font-size: 0.95rem; }
}
