@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
    /* Surfaces */
    --color-surface: #0a0a0a;
    --color-surface-raised: #111111;
    --color-surface-overlay: #1a1a1a;
    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-strong: rgba(255, 255, 255, 0.14);
    --color-text-primary: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-text-muted: #666666;
    --color-accent: #4f8cff;
    --color-accent-hover: #3a7bff;
    --color-accent-muted: rgba(79, 140, 255, 0.12);
    --color-success: #22c55e;
    --color-success-muted: rgba(34, 197, 94, 0.12);
    --color-warning: #f59e0b;
    --color-warning-muted: rgba(245, 158, 11, 0.12);
    --color-danger: #ef4444;
    --color-danger-muted: rgba(239, 68, 68, 0.12);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --transition: 150ms ease;

    /* Aliases consumed by component styles below */
    --bg: var(--color-surface);
    --surface: var(--color-surface-raised);
    --surface-2: var(--color-surface-overlay);
    --border: var(--color-border);
    --text: var(--color-text-primary);
    --muted: var(--color-text-secondary);
    --accent: var(--color-accent);
    --accent-hover: var(--color-accent-hover);
    --success: var(--color-success);
    --warn: var(--color-warning);
    --danger: var(--color-danger);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-display); font-size: 24px; margin: 0 0 4px; }
h2 { font-family: var(--font-display); font-size: 16px; }
h3 { margin: 0; font-size: 15px; }
code { background: var(--surface-2); padding: 1px 5px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }

/* ============================================
   APP SHELL
   ============================================ */
#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-surface-raised);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition);
    z-index: 100;
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    color: var(--color-text-primary);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; }
.nav-section { margin-bottom: 8px; }
.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 8px 12px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}
.nav-link:hover { color: var(--color-text-primary); background: var(--color-surface-overlay); text-decoration: none; }
.nav-link.active { color: var(--color-accent); background: var(--color-accent-muted); }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-link.active svg { opacity: 1; }
.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    background: var(--color-accent-muted);
    color: var(--color-accent);
}

.workspace-switcher { padding: 12px; border-top: 1px solid var(--color-border); }
.workspace-current {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--color-surface-overlay);
}
.workspace-avatar {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.workspace-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

#topbar {
    height: var(--topbar-height);
    min-height: var(--topbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; flex: 1; }
.topbar-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; margin: 0; }
.mobile-menu-btn { display: none; background: none; border: none; color: var(--color-text-primary); cursor: pointer; padding: 4px; }
.mobile-menu-btn svg { width: 24px; height: 24px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.user-menu { position: relative; }
.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    transition: background var(--transition);
}
.user-trigger:hover { background: var(--color-surface-raised); }
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--color-accent);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    object-fit: cover;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--color-text-primary); }
.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: var(--color-surface-overlay);
    border: 1px solid var(--color-border);
    margin-top: 4px;
    z-index: 200;
}
.user-dropdown.open { display: block; }
.dropdown-form { margin: 0; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    color: var(--color-text-secondary);
    font-size: 13px;
    font-family: var(--font-sans);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}
.dropdown-item:hover { color: var(--color-text-primary); background: var(--color-surface-raised); text-decoration: none; }
.dropdown-item svg { width: 16px; height: 16px; }
.dropdown-divider { border-top: 1px solid var(--color-border); margin: 4px 0; }
.dropdown-item.danger { color: var(--color-danger); }

#content { flex: 1; overflow-y: auto; padding: 32px; }
#content .page { max-width: 1400px; margin: 0 auto; }

#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}
#sidebar-overlay.open { display: block; }

/* ============================================
   AUTH LAYOUT
   ============================================ */
.auth-layout {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-surface);
    padding: 24px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    padding: 40px;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo { width: 48px; height: 48px; margin: 0 auto 20px; display: flex; align-items: center; justify-content: center; }
.auth-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.auth-subtitle { font-size: 14px; color: var(--color-text-secondary); margin: 0; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; }
.section-title { margin: 28px 0 12px; }

/* Buttons */
.btn {
    display: inline-block; padding: 9px 16px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); cursor: pointer;
    font-size: 13px; font-weight: 500;
}
.btn:hover { text-decoration: none; border-color: #3a444f; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.full { width: 100%; }

/* Cards / grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }

.pill { font-size: 11px; padding: 3px 9px; font-weight: 600; }
.pill-on { background: rgba(46,204,113,0.15); color: var(--success); }
.pill-off { background: rgba(139,152,165,0.15); color: var(--muted); }
.pill-idle { background: rgba(245,166,35,0.12); color: var(--warn); }

/* Meter */
.meter { height: 8px; background: var(--surface-2); margin: 14px 0 6px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); }
.meter-fill.hot { background: var(--danger); }
.meter-label { font-size: 13px; }

.plan-picker { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* Lists */
.list { border: 1px solid var(--border); }
.list-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    background: var(--surface); color: var(--text);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
.list-main { display: flex; flex-direction: column; gap: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 3px 9px; background: rgba(79,140,255,0.14); color: var(--accent); }
.chip-muted { background: var(--surface-2); color: var(--muted); }

.new-client-form { display: flex; gap: 8px; margin-bottom: 16px; }
.new-client-form input { flex: 1; }
input[type=text], input[type=email], input[type=password], input[type=url] {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: 9px 11px; font-size: 13px; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* Alerts */
.alert { padding: 10px 14px; margin: 10px 0; font-size: 13px; border: 1px solid transparent; }
.alert-error { background: rgba(231,76,60,0.1); border-color: rgba(231,76,60,0.3); color: #ffb4ab; }
.alert-warn { background: rgba(245,166,35,0.1); border-color: rgba(245,166,35,0.3); color: #f5c877; }
.alert-success { background: rgba(46,204,113,0.1); border-color: rgba(46,204,113,0.3); color: #8ff0b8; }

/* Switch */
.switch { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; }
.switch input { display: none; }
.slider { width: 40px; height: 22px; background: var(--surface-2); border: 1px solid var(--border); position: relative; transition: background .15s; flex-shrink: 0; }
.slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: rgba(79,140,255,0.35); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }
.switch input:disabled + .slider { opacity: .4; }
.switch-text { font-size: 13px; }
.entitlement-line { margin: 12px 0 0; }

/* Auth form fields */
.field { display: block; margin: 14px 0; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.auth-divider { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { padding: 0 12px; }
.btn-google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border-color: #dadce0; }
.btn-google:hover { background: #f5f5f5; border-color: #dadce0; }

/* Toast */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--border); padding: 10px 18px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; }
#toast.error { border-color: rgba(231,76,60,0.5); color: #ffb4ab; }
#toast.success { border-color: rgba(46,204,113,0.5); color: #8ff0b8; }

/* Health tables + scores */
.data-table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); }
.data-table th, .data-table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.data-table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.url-cell { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.score { display: inline-block; min-width: 34px; text-align: center; padding: 3px 6px; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.score-good { background: rgba(46,204,113,0.16); color: var(--success); }
.score-ok   { background: rgba(245,166,35,0.16); color: var(--warn); }
.score-bad  { background: rgba(231,76,60,0.16); color: #ff6f61; }
.score-na   { background: var(--surface-2); color: var(--muted); }

.head-actions { display: flex; gap: 8px; }
.quota-bar { background: var(--surface); border: 1px solid var(--border); padding: 14px 16px; margin-bottom: 16px; font-size: 13px; }
.quota-bar .meter { margin-bottom: 0; }

.score-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.score-tile { background: var(--surface); border: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.score-tile-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.score-tile .score { font-size: 18px; min-width: 44px; padding: 6px 10px; }
.card-link { margin-top: 12px; }
@media (max-width: 640px) { .score-summary { grid-template-columns: repeat(2, 1fr); } }

/* Core Web Vitals + audit drill-down */
.cwv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.cwv-tile { background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.cwv-tile.score-good { border-left-color: var(--success); }
.cwv-tile.score-ok   { border-left-color: var(--warn); }
.cwv-tile.score-bad  { border-left-color: #ff6f61; }
.cwv-tile.score-na   { border-left-color: var(--border); }
.cwv-label { font-size: 12px; color: var(--muted); }
.cwv-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .cwv-grid { grid-template-columns: repeat(2, 1fr); } }

.audit-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.audit-item { background: var(--surface); border: 1px solid var(--border); padding: 0; }
.audit-item > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.audit-item > summary::-webkit-details-marker { display: none; }
.audit-item[open] > summary { border-bottom: 1px solid var(--border); }
.audit-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); }
.audit-dot.score-good { background: var(--success); }
.audit-dot.score-ok   { background: var(--warn); }
.audit-dot.score-bad  { background: #ff6f61; }
.audit-dot.score-na   { background: var(--muted); }
.audit-title { flex: 1; }
.audit-metric { color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-desc { padding: 12px 16px 0; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.audit-items { list-style: none; margin: 10px 0 0; padding: 8px 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.audit-items li { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; border-top: 1px solid var(--border); padding-top: 6px; }
.audit-items li:first-child { border-top: none; padding-top: 0; }
.audit-item-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); opacity: .85; }
.audit-item-value { flex: 0 0 auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============================================
   DASHBOARD — header, stats, widgets
   ============================================ */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 800; margin: 0 0 6px; }
.page-subtitle { font-size: 14px; color: var(--color-text-secondary); margin: 0; }
.dash-toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Stat cards (KPIs) */
.stats-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat-card { background: var(--color-surface-raised); border: 1px solid var(--color-border); padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.accent { background: var(--color-accent-muted); color: var(--color-accent); }
.stat-icon.success { background: var(--color-success-muted); color: var(--color-success); }
.stat-icon.warning { background: var(--color-warning-muted); color: var(--color-warning); }
.stat-icon.danger { background: var(--color-danger-muted); color: var(--color-danger); }
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; }

/* Product cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.product-card { background: var(--color-surface-raised); border: 1px solid var(--color-border); padding: 22px; display: flex; flex-direction: column; transition: border-color var(--transition); }
.product-card:hover { border-color: var(--color-border-strong); }
.product-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.product-icon { width: 42px; height: 42px; background: var(--color-accent-muted); display: flex; align-items: center; justify-content: center; color: var(--color-accent); }
.product-icon svg { width: 20px; height: 20px; }
.product-badge { font-size: 11px; font-weight: 600; padding: 3px 8px; text-transform: uppercase; letter-spacing: 0.03em; }
.product-badge.active { background: var(--color-success-muted); color: var(--color-success); }
.product-badge.free { background: var(--color-surface-overlay); color: var(--color-text-muted); }
.product-badge.coming-soon { background: var(--color-warning-muted); color: var(--color-warning); }
.product-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.product-desc { font-size: 13px; color: var(--color-text-secondary); margin: 0 0 18px; flex: 1; }
.product-actions { display: flex; gap: 8px; }

/* Widget grid */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; align-items: start; }
.widget { position: relative; grid-column: span 12; min-width: 0; }
.widget.size-third { grid-column: span 4; }
.widget.size-half { grid-column: span 6; }
.widget.size-twothirds { grid-column: span 8; }
.widget.size-full { grid-column: span 12; }
@media (max-width: 900px) {
    .widget.size-third, .widget.size-half, .widget.size-twothirds { grid-column: span 12; }
}

.widget-card { background: var(--color-surface-raised); border: 1px solid var(--color-border); padding: 20px; height: 100%; }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.widget-head h3 { font-family: var(--font-display); font-size: 15px; font-weight: 700; margin: 0; }
.widget-link { font-size: 12px; color: var(--color-text-secondary); }
.widget-link:hover { color: var(--color-text-primary); text-decoration: none; }
.widget-empty { color: var(--color-text-muted); font-size: 13px; padding: 8px 0; }

/* Allowance rows */
.allowance { padding: 12px 0; border-top: 1px solid var(--color-border); }
.allowance:first-child { border-top: none; padding-top: 0; }
.allowance-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.allowance-name { font-size: 13px; font-weight: 600; }
.allowance-meta { font-size: 12px; color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }

/* Activity + snapshot lists */
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--color-border); font-size: 13px; color: var(--color-text-primary); }
.mini-row:first-child { border-top: none; }
a.mini-row:hover { text-decoration: none; }
a.mini-row:hover .mini-title { color: var(--color-accent); }
.mini-main { min-width: 0; overflow: hidden; }
.mini-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sub { font-size: 12px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-time { font-size: 11px; color: var(--color-text-muted); flex-shrink: 0; white-space: nowrap; }

/* Quick actions */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.qa-btn { display: flex; align-items: center; gap: 10px; padding: 14px; background: var(--color-surface-overlay); border: 1px solid var(--color-border); color: var(--color-text-primary); font-size: 13px; font-weight: 500; transition: border-color var(--transition); }
.qa-btn:hover { border-color: var(--color-accent); text-decoration: none; }
.qa-btn svg { width: 18px; height: 18px; color: var(--color-accent); flex-shrink: 0; }

/* ============================================
   SETTINGS / ACCOUNT MANAGEMENT
   ============================================ */
.user-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* Select fields (match text inputs) */
select.select-input {
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
    padding: 9px 11px; font-size: 13px; width: 100%; appearance: none;
}
select.select-input:focus { outline: none; border-color: var(--accent); }

/* Danger button + card */
.btn-danger { background: var(--color-danger-muted); border-color: rgba(239, 68, 68, 0.4); color: #ff8a80; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.22); border-color: var(--danger); color: #fff; }
.card-danger { border-color: rgba(239, 68, 68, 0.35); }
.card-danger h3 { color: #ff8a80; }

/* Avatar editor */
.avatar-row { display: flex; align-items: center; gap: 16px; margin: 6px 0 12px; }
.avatar-preview {
    width: 64px; height: 64px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
    border: 1.5px solid var(--accent); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 600; color: var(--accent);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.avatar-actions .muted { flex-basis: 100%; margin: 0; }

/* Preference toggle rows */
.pref-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.pref-row:first-of-type { border-top: none; }
.pref-row p { margin: 2px 0 0; }
.pref-row .switch { margin-top: 0; flex-shrink: 0; }
.pref-row .btn { flex-shrink: 0; }

/* Delete-account modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.72);
    display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 200;
}
.modal-overlay[hidden] { display: none; }
.modal {
    width: 100%; max-width: 440px; background: var(--surface);
    border: 1px solid var(--border-strong, var(--border)); padding: 24px;
}
.modal h3 { margin-bottom: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ============================================
   NAV SHELL (Phase 0)
   ============================================ */

/* "Soon" / disabled nav items */
.nav-link.is-soon { opacity: .5; cursor: default; }
.nav-link.is-soon:hover { background: transparent; color: var(--color-text-secondary); }
.nav-soon {
    margin-left: auto; font-size: 10px; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; padding: 2px 6px; color: var(--color-text-muted);
    background: var(--color-surface-overlay); border: 1px solid var(--color-border);
}

/* Workspace indicator (sidebar footer) */
.workspace-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.workspace-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }

/* Client switcher (top bar) */
.client-switcher { position: relative; }
.client-switcher-trigger {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    background: var(--color-surface-overlay); border: 1px solid var(--color-border);
    color: var(--color-text-secondary); font-size: 13px; font-family: var(--font-sans);
    padding: 7px 12px; transition: border-color var(--transition), color var(--transition);
}
.client-switcher-trigger:hover { color: var(--color-text-primary); border-color: var(--color-border-strong); }
.client-switcher-trigger svg { width: 16px; height: 16px; }
.client-switcher-chevron { width: 14px; height: 14px; opacity: .7; }
.client-switcher-menu {
    display: none; position: absolute; top: 100%; right: 0; width: 280px; margin-top: 4px;
    background: var(--color-surface-overlay); border: 1px solid var(--color-border);
    z-index: 200; max-height: 380px; flex-direction: column;
}
.client-switcher.open .client-switcher-menu { display: flex; }
.client-switcher-search { padding: 10px; border-bottom: 1px solid var(--color-border); }
.client-switcher-search input { width: 100%; }
.client-switcher-list { overflow-y: auto; flex: 1; }
.client-switcher-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    color: var(--color-text-secondary); font-size: 13px;
}
.client-switcher-item:hover { background: var(--color-surface-raised); color: var(--color-text-primary); text-decoration: none; }
.client-switcher-avatar {
    width: 24px; height: 24px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; background: var(--color-accent);
}
.client-switcher-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-switcher-empty { padding: 16px; color: var(--color-text-muted); font-size: 13px; text-align: center; margin: 0; }
.client-switcher-all {
    display: block; padding: 10px 12px; border-top: 1px solid var(--color-border);
    font-size: 12px; color: var(--color-accent); text-align: center;
}
.client-switcher-all:hover { background: var(--color-surface-raised); text-decoration: none; }
.client-switcher-item.is-hidden { display: none; }

/* Breadcrumbs */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.breadcrumbs a { color: var(--color-text-secondary); }
.breadcrumbs a:hover { color: var(--color-text-primary); }
.crumb-sep { color: var(--color-text-muted); }
.crumb-current { color: var(--color-text-primary); font-weight: 500; }

@media (max-width: 640px) {
    .client-switcher-trigger span { display: none; }
    .client-switcher-menu { width: 240px; }
}

/* Team page */
.team-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-avatar {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: #fff; background: var(--color-accent);
}
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.team-role { width: auto; }
.team-scope-note { margin: 8px 0 0; }
.team-clients { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.team-client-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; cursor: pointer; }
.team-client-row input { width: auto; }

/* ============================================
   CLIENT WORKSPACE (Phase 2)
   ============================================ */
.client-tabs {
    display: flex; gap: 4px; flex-wrap: wrap;
    border-bottom: 1px solid var(--border); margin: 0 0 20px;
}
.client-tab {
    padding: 10px 14px; font-size: 13px; font-weight: 500; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.client-tab:hover { color: var(--text); text-decoration: none; }
.client-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 2px 0 0; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

/* ============================================
   CLIENT PORTAL (Phase 5)
   ============================================ */
#portal { min-height: 100vh; display: flex; flex-direction: column; }
#portal-topbar {
    height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.portal-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; }
.portal-nav { display: flex; gap: 4px; }
.portal-nav a { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.portal-nav a:hover, .portal-nav a.active { color: var(--text); text-decoration: none; }
.portal-user { display: flex; align-items: center; gap: 12px; }
#portal-content { flex: 1; overflow-y: auto; padding: 32px; }
#portal-content .page { max-width: 1000px; margin: 0 auto; }
@media (max-width: 640px) {
    #portal-topbar { padding: 0 14px; }
    .portal-brand span { display: none; }
    #portal-content { padding: 20px 14px; }
}

/* ============================================
   SETTINGS LAYOUT
   ============================================ */
.settings-layout { display: grid; grid-template-columns: 216px minmax(0, 760px); gap: 40px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.settings-nav-link { padding: 10px 12px; font-size: 13px; font-weight: 500; color: var(--muted); border-left: 2px solid transparent; }
.settings-nav-link:hover { color: var(--text); text-decoration: none; }
.settings-nav-link.active { color: var(--accent); border-left-color: var(--accent); background: var(--color-accent-muted); }
.settings-content { min-width: 0; }
.settings-panel[hidden] { display: none; }
.settings-grid { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 820px) {
    .settings-layout { grid-template-columns: 1fr; gap: 14px; }
    .settings-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); padding-bottom: 8px; position: static; }
    .settings-nav-link { border-left: none; border-bottom: 2px solid transparent; }
    .settings-nav-link.active { border-left: none; border-bottom-color: var(--accent); }
    .settings-grid { grid-template-columns: 1fr; }
}

/* Notes widget */
.notes-area { width: 100%; min-height: 120px; resize: vertical; background: var(--color-surface-overlay); border: 1px solid var(--color-border); color: var(--color-text-primary); font-family: var(--font-sans); font-size: 13px; line-height: 1.6; padding: 12px; outline: none; }
.notes-area:focus { border-color: var(--color-accent); }

/* ── Customize mode ── */
.dash.editing .widget { outline: 1px dashed var(--color-border-strong); outline-offset: 3px; }
.dash.editing .widget.dragging { opacity: 0.4; }
.dash.editing .widget.drop-before { outline: 2px dashed var(--color-accent); }
.widget-toolbar { display: none; position: absolute; top: 6px; right: 6px; z-index: 5; gap: 2px; background: var(--color-surface-overlay); border: 1px solid var(--color-border); }
.dash.editing .widget-toolbar { display: flex; }
.widget-toolbar button { background: none; border: none; color: var(--color-text-secondary); padding: 6px; cursor: pointer; display: flex; }
.widget-toolbar button:hover { color: var(--color-text-primary); background: var(--color-surface-raised); }
.widget-toolbar button svg { width: 15px; height: 15px; }
.widget-handle { cursor: grab; }
.widget-handle:active { cursor: grabbing; }

.add-widget-tray { border: 1px dashed var(--color-border-strong); background: var(--color-surface-raised); padding: 16px; margin-bottom: 16px; }
.add-widget-tray h3 { font-family: var(--font-display); font-size: 14px; margin: 0 0 12px; }
.add-widget-list { display: flex; flex-wrap: wrap; gap: 8px; }
.add-widget-list:empty::after { content: "All widgets are on your dashboard."; color: var(--color-text-muted); font-size: 13px; }
.add-widget-chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--color-surface-overlay); border: 1px solid var(--color-border); color: var(--color-text-primary); font-size: 13px; cursor: pointer; }
.add-widget-chip:hover { border-color: var(--color-accent); }
.add-widget-chip svg { width: 14px; height: 14px; color: var(--color-accent); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }
    #sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: block; }
    #content { padding: 20px; }
    .score-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .auth-card { padding: 28px 20px; }
    #content { padding: 16px; }
    .new-client-form { flex-direction: column; }
}
