/* ── PipelineCalc Pro — Modern Dark Theme v2 ── */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161922;
    --bg-card: #1c1f2e;
    --bg-card-hover: #232740;
    --bg-input: #232740;
    --border: #2a2e45;
    --border-focus: #4f7df9;
    --text-primary: #e8eaf0;
    --text-secondary: #8a8fa8;
    --text-muted: #5c6178;
    --accent: #4f7df9;
    --accent-hover: #6b93ff;
    --accent-glow: rgba(79, 125, 249, .25);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --premium: #a855f7;
    --enterprise: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --shadow: 0 4px 24px rgba(0, 0, 0, .35);
    --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.02em; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Top Nav ── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: rgba(15, 17, 23, .85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.top-nav .brand {
    font-size: 1.15rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.top-nav .nav-links { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: .875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--text-muted); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0da574; color: #fff; }
.btn-warning { background: var(--warning); color: #1a1a2e; }
.btn-warning:hover { background: #e08e0a; color: #1a1a2e; }
.btn-danger { background: var(--danger); color: #fff; padding: 6px 14px; }
.btn-danger:hover { background: #d33; color: #fff; }
.btn-premium { background: linear-gradient(135deg, #a855f7, #6366f1); color: #fff; }
.btn-premium:hover { box-shadow: 0 0 24px rgba(168, 85, 247, .4); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page { padding: 32px 0 64px; }

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    transition: all var(--transition);
}
.card:hover { border-color: rgba(79, 125, 249, .3); }
.card-glow:hover { box-shadow: 0 0 30px var(--accent-glow); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: .9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }

/* Override Django's default form rendering */
form p { margin-bottom: 14px; }
form p label {
    display: block;
    margin-bottom: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
form p input, form p select {
    width: 100%;
    padding: 10px 14px;
    font-size: .9rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
form p input:focus, form p select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
form .helptext { display: block; font-size: .7rem; color: var(--text-muted); margin-top: 3px; }
form .errorlist { list-style: none; padding: 0; margin: 4px 0 0; }
form .errorlist li { font-size: .75rem; color: var(--danger); }

/* ── Tabs ── */
.tab-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow-x: auto;
}
.tab-btn {
    flex: 1;
    min-width: max-content;
    padding: 10px 20px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.tab-btn.active { color: #fff; background: var(--accent); box-shadow: 0 2px 12px var(--accent-glow); }
.tab-btn .badge-lock {
    display: inline-block;
    font-size: .6rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}
.badge-premium { background: rgba(168, 85, 247, .2); color: #c084fc; }
.badge-enterprise { background: rgba(245, 158, 11, .2); color: #fbbf24; }

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Calculator Grid ── */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}
.calc-card { position: relative; }
.calc-card h4 { font-size: 1rem; margin: 0 0 4px; }
.calc-card .calc-desc { font-size: .78rem; color: var(--text-muted); margin-bottom: 16px; }

/* ── Results ── */
.result-box {
    margin-top: 16px;
    padding: 14px 16px;
    background: rgba(16, 185, 129, .08);
    border: 1px solid rgba(16, 185, 129, .25);
    border-radius: var(--radius-sm);
}
.result-box .result-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--success);
    margin-bottom: 4px;
}
.result-box .result-value { font-size: 1.35rem; font-weight: 700; color: var(--success); }
.result-box .result-detail { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }

.locked-overlay {
    padding: 20px;
    text-align: center;
    background: rgba(79, 125, 249, .05);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}
.locked-overlay .lock-icon { font-size: 1.5rem; margin-bottom: 8px; }
.locked-overlay p { font-size: .85rem; color: var(--text-secondary); margin: 0 0 12px; }

/* ── Hero ── */
.hero { text-align: center; padding: 80px 20px 60px; }
.hero h1 { font-size: 3rem; line-height: 1.1; margin-bottom: 20px; }
.hero h1 .gradient-text {
    background: linear-gradient(135deg, var(--accent), #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    line-height: 1.6;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 48px;
}
.feature-card { text-align: left; }
.feature-card .feature-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; border-radius: 10px; margin-bottom: 14px;
}
.feature-card .icon-blue { background: rgba(79, 125, 249, .12); }
.feature-card .icon-purple { background: rgba(168, 85, 247, .12); }
.feature-card .icon-amber { background: rgba(245, 158, 11, .12); }
.feature-card .icon-green { background: rgba(16, 185, 129, .12); }
.feature-card h4 { font-size: .95rem; margin: 0 0 6px; }
.feature-card p { font-size: .82rem; color: var(--text-secondary); margin: 0; line-height: 1.5; }

/* ── Pricing ── */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}
.pricing-card { text-align: center; position: relative; overflow: hidden; }
.pricing-card.popular { border-color: var(--accent); }
.pricing-card.popular::before {
    content: "MOST POPULAR";
    position: absolute; top: 14px; right: -30px;
    transform: rotate(45deg);
    background: var(--accent); color: #fff;
    font-size: .6rem; font-weight: 700;
    padding: 4px 40px; letter-spacing: .06em;
}
.pricing-card .price { font-size: 2.4rem; font-weight: 800; margin: 16px 0 4px; }
.pricing-card .price span { font-size: .9rem; font-weight: 400; color: var(--text-muted); }
.pricing-card .plan-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.pricing-card .plan-desc { font-size: .82rem; color: var(--text-secondary); margin-bottom: 20px; }
.pricing-card ul { list-style: none; padding: 0; margin: 0 0 24px; text-align: left; }
.pricing-card ul li {
    padding: 7px 0; font-size: .82rem; color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.pricing-card ul li::before { content: "✓ "; color: var(--success); font-weight: 700; }
.pricing-card .current-badge {
    display: inline-block; padding: 4px 12px;
    font-size: .7rem; font-weight: 700; border-radius: 20px;
    background: rgba(16, 185, 129, .15); color: var(--success);
    margin-bottom: 12px;
}

/* ── Pricing page — redesigned ── */
.pricing-page { max-width: 1000px; }

/* Admin bar */
.admin-bar {
    margin-bottom: 20px; border-radius: 10px;
    background: linear-gradient(135deg, rgba(251,191,36,.08), rgba(251,191,36,.03));
    border: 1px solid rgba(251,191,36,.2);
    padding: 14px 18px;
}
.admin-bar-inner { display: flex; flex-direction: column; gap: 8px; }
.admin-bar-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.admin-bar-label { font-size: .8rem; font-weight: 700; color: var(--text-primary); }
.admin-bar-controls { display: flex; align-items: center; gap: 12px; }
.admin-mode-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); }
.admin-toggle-btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--border); border-radius: 8px;
    padding: 5px 12px; cursor: pointer; color: var(--text-secondary);
    font-size: .78rem; transition: all .15s;
}
.admin-toggle-btn:hover { background: var(--bg-card); border-color: var(--text-muted); color: var(--text-primary); }
.toggle-track {
    display: inline-block; width: 36px; height: 20px; border-radius: 10px;
    background: var(--border); position: relative; transition: background .2s;
    flex-shrink: 0;
}
.toggle-track.active { background: var(--warning); }
.toggle-thumb {
    position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: #fff; transition: left .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-track.active .toggle-thumb { left: 18px; }
.admin-bar-tip {
    font-size: .75rem; color: var(--text-muted); line-height: 1.5;
}
.admin-bar-tip code {
    background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 4px;
    font-family: var(--mono, monospace); font-size: .73rem; color: var(--text-primary);
    letter-spacing: .03em;
}

/* Plan summary strip */
.plan-summary {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; padding: 16px 20px; margin-bottom: 28px;
    gap: 16px; flex-wrap: wrap;
}
.plan-summary-left { display: flex; align-items: center; }
.plan-summary-tier { display: flex; align-items: center; gap: 12px; }
.tier-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.tier-icon--free { background: rgba(100,116,139,.12); }
.tier-icon--pro { background: rgba(99,102,241,.12); }
.tier-icon--pro_plus { background: rgba(251,191,36,.12); }
.plan-summary-name { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.plan-summary-status { font-size: .8rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
}
.status-dot--active { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,.4); }
.status-dot--warning { background: var(--warning); box-shadow: 0 0 6px rgba(251,191,36,.4); }
.status-dot--canceled { background: #ef4444; }
.status-dot--free { background: var(--text-muted); }

/* Billing toggle */
.billing-toggle-wrap {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-bottom: 24px;
}
.billing-label { font-size: .85rem; color: var(--text-muted); transition: color .15s; }
.billing-label.active { color: var(--text-primary); font-weight: 600; }
.billing-toggle {
    background: none; border: none; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center;
}
.billing-toggle-track {
    display: inline-block; width: 42px; height: 24px; border-radius: 12px;
    background: var(--border); position: relative; transition: background .2s;
}
.billing-toggle-track.active { background: var(--accent); }
.billing-toggle-thumb {
    position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; transition: left .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.billing-toggle-track.active .billing-toggle-thumb { left: 21px; }
.billing-save-badge {
    font-size: .7rem; font-weight: 700; color: var(--accent);
    background: rgba(99,102,241,.1); padding: 3px 8px; border-radius: 10px;
}

/* Pricing card overrides for redesigned page */
.pricing-card.is-current {
    border-color: var(--success); box-shadow: 0 0 0 1px var(--success), 0 4px 24px rgba(16,185,129,.08);
}
.pricing-card.recommended {
    border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 4px 24px rgba(99,102,241,.1);
    transform: scale(1.02);
}
.current-plan-ribbon {
    position: absolute; top: 0; left: 0; right: 0;
    background: var(--success); color: #fff;
    text-align: center; font-size: .65rem; font-weight: 700;
    padding: 4px 0; letter-spacing: .08em;
}
.recommended-ribbon {
    position: absolute; top: 0; left: 0; right: 0;
    background: var(--accent); color: #fff;
    text-align: center; font-size: .65rem; font-weight: 700;
    padding: 4px 0; letter-spacing: .08em;
}
.plan-header {
    display: flex; align-items: center; gap: 8px;
    justify-content: center; margin-top: 12px;
}
.plan-icon { font-size: 1.6rem; }
.btn-current {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; padding: 10px 16px; border-radius: 8px;
    background: rgba(16,185,129,.1); color: var(--success);
    border: 1px solid rgba(16,185,129,.2); font-weight: 600; font-size: .85rem;
    cursor: default;
}
.btn-upgrade {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; padding: 10px 16px; font-size: .85rem; font-weight: 600;
}
.card-action { margin-top: auto; }
.pricing-card { display: flex; flex-direction: column; padding-top: 20px; }
.pricing-card.is-current { padding-top: 28px; }
.pricing-card.recommended { padding-top: 28px; }

/* Shortcuts row */
.pricing-shortcuts {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 28px; flex-wrap: wrap;
}
.shortcut-link {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: .82rem; color: var(--text-secondary);
    text-decoration: none; padding: 6px 14px;
    border: 1px solid var(--border); border-radius: 8px;
    transition: all .15s;
}
.shortcut-link:hover {
    background: var(--bg-card); color: var(--text-primary);
    border-color: var(--text-muted);
}

/* ── Profile ── */
.profile-page { max-width: 820px; }
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.profile-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #a855f7);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.profile-info h2 { margin: 0 0 4px; font-size: 1.3rem; }
.profile-info p { margin: 0 0 6px; font-size: .85rem; color: var(--text-secondary); }
.tier-badge {
    display: inline-block; padding: 3px 10px;
    font-size: .7rem; font-weight: 700; border-radius: 20px;
    text-transform: uppercase; letter-spacing: .04em;
}
.tier-free     { background: rgba(79, 125, 249, .12); color: var(--accent); }
.tier-pro      { background: rgba(168, 85, 247, .12); color: #c084fc; }
.tier-pro_plus { background: rgba(245, 158, 11, .12); color: #fbbf24; }
.tier-premium  { background: rgba(168, 85, 247, .12); color: #c084fc; }
.tier-enterprise { background: rgba(245, 158, 11, .12); color: #fbbf24; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}
.stat-card { text-align: center; padding: 16px 12px; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 800; }
.stat-card .stat-limit { font-size: .9rem; font-weight: 500; color: var(--text-muted); }
.stat-card .stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.stat-bar { width: 100%; height: 4px; border-radius: 2px; background: var(--bg-dim, #2a2a3a); margin-top: 8px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent), #a855f7); transition: width .4s ease; }

/* Feature chips */
.profile-features { display: flex; gap: 10px; flex-wrap: wrap; }
.feature-chip {
    padding: 6px 14px; border-radius: 20px; font-size: .8rem; font-weight: 600;
    background: var(--bg-dim, #1e1e2e); color: var(--text-muted);
    border: 1px solid var(--border, #333);
}
.feature-chip.active { background: rgba(79,125,249,.1); color: var(--accent); border-color: var(--accent); }
.feature-chip .lock { font-size: .65rem; margin-left: 2px; }

/* Profile grid (edit + password side-by-side) */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-section {
    background: var(--card-bg, #1e1e2e); border: 1px solid var(--border, #2a2a3a);
    border-radius: 12px; padding: 20px;
}
.section-title { margin: 0 0 16px; font-size: 1rem; font-weight: 700; }
.field-label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 4px; margin-top: 12px; }
.field-label:first-of-type { margin-top: 0; }
.field-input {
    width: 100%; padding: 9px 12px; border-radius: 8px;
    background: var(--bg-dim, #161622); border: 1px solid var(--border, #333);
    color: var(--text, #e2e2e8); font-size: .9rem; font-family: inherit;
}
.field-input:focus { outline: none; border-color: var(--accent); }

/* Project list */
.project-list { display: flex; flex-direction: column; gap: 4px; }
.project-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-radius: 8px; text-decoration: none;
    color: var(--text, #e2e2e8); background: var(--bg-dim, #161622);
    transition: background .15s;
}
.project-row:hover { background: var(--accent-dim, rgba(79,125,249,.08)); }
.project-name { font-weight: 600; font-size: .9rem; }
.project-date { font-size: .75rem; color: var(--text-muted); }

.profile-footer { margin-top: 32px; font-size: .75rem; color: var(--text-muted); text-align: center; }

/* ── Alerts ── */
.alert { padding: 14px 18px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 16px; }
.alert-info { background: rgba(79, 125, 249, .1); border: 1px solid rgba(79, 125, 249, .25); color: var(--accent); }
.alert-success { background: rgba(16, 185, 129, .1); border: 1px solid rgba(16, 185, 129, .25); color: var(--success); }
.alert-warning { background: rgba(245, 158, 11, .1); border: 1px solid rgba(245, 158, 11, .25); color: var(--warning); }
.alert-danger { background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .25); color: var(--danger); }

/* ── Auth pages ── */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: calc(100vh - 56px); padding: 40px 20px;
}
.auth-box { width: 100%; max-width: 440px; }
.auth-box h2 { text-align: center; margin-bottom: 6px; }
.auth-box .auth-subtitle {
    text-align: center; font-size: .88rem; color: var(--text-secondary); margin-bottom: 28px;
}

/* ── Dashboard header ── */
.dash-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.dash-header h1 { font-size: 1.5rem; margin: 0; }
.dash-header .tier-info { font-size: .8rem; color: var(--text-muted); }

/* ── Utilities ── */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .calc-grid { grid-template-columns: 1fr; }
    .pricing-grid { grid-template-columns: 1fr; }
    .tab-bar { flex-wrap: nowrap; }
    .tab-btn { font-size: .78rem; padding: 8px 14px; }
    .sim-card-wide { grid-column: span 1; }
    .visual-wide svg { min-height: 140px; }
}

/* ── Project Grid ── */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}
.project-card { position: relative; }

/* ── SVG Visual Boxes ── */
.visual-box {
    margin-top: 14px;
    padding: 12px;
    background: rgba(15, 17, 23, .5);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.visual-box svg { width: 100%; height: auto; }
.visual-wide svg { min-height: 160px; }

/* Simulator wide cards span 2 columns */
.sim-card-wide { grid-column: span 2; }

/* ── SVG Animations ── */
.pulse-dot {
    animation: pulseDot 2s ease-in-out infinite;
}
@keyframes pulseDot {
    0%, 100% { r: 4; opacity: 1; }
    50% { r: 7; opacity: .5; }
}

.arrow-pulse { animation: arrowSlide 2s ease-in-out infinite; }
.arrow-pulse-2 { animation: arrowSlide 2s ease-in-out .3s infinite; }
.arrow-pulse-3 { animation: arrowSlide 2s ease-in-out .6s infinite; }
@keyframes arrowSlide {
    0%, 100% { opacity: .3; transform: translateX(0); }
    50% { opacity: .9; transform: translateX(4px); }
}

.pig-animate {
    animation: pigMove 3s ease-in-out infinite;
}
@keyframes pigMove {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(12px); }
}

.pig-fitting-animate {
    animation: pigApproach 3s ease-in-out infinite;
}
@keyframes pigApproach {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(20px); }
}

.disc-bend-1 {
    animation: discBend 2.5s ease-in-out infinite;
}
.disc-bend-2 {
    animation: discBend 2.5s ease-in-out .4s infinite;
}
@keyframes discBend {
    0%, 100% { rx: 6; }
    50% { rx: 10; }
}

.friction-heat {
    animation: heatPulse 1s ease-in-out infinite;
}
@keyframes heatPulse {
    0%, 100% { opacity: .3; }
    50% { opacity: .8; }
}

.turbulent-path {
    animation: turbulence 4s linear infinite;
    stroke-dasharray: 8 4;
    stroke-dashoffset: 0;
}
.turbulent-path-2 {
    animation: turbulence 4s linear .5s infinite;
    stroke-dasharray: 8 4;
}
@keyframes turbulence {
    to { stroke-dashoffset: -48; }
}

.batch-interface {
    animation: batchPulse 2s ease-in-out infinite;
}
@keyframes batchPulse {
    0%, 100% { opacity: .5; }
    50% { opacity: 1; }
}

/* ── Risk-level result colours ── */
.result-low { color: var(--success) !important; }
.result-medium { color: var(--warning) !important; }
.result-high { color: var(--danger) !important; }
.result-critical { color: #ff3333 !important; font-weight: 800; }

/* ── Save-to-Project Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    width: 100%;
    max-width: 480px;
    animation: fadeIn .2s ease;
}
.modal-box textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: .9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    resize: vertical;
    transition: border-color var(--transition);
}
.modal-box textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ══════════════════════════════════════════════════════════════════════════
   PIPE CONFIGURATION BAR
   ══════════════════════════════════════════════════════════════════════════ */
.pipe-config-bar {
    margin-bottom: 20px;
    padding: 16px 20px;
    border: 1px solid var(--accent);
    border-image: linear-gradient(135deg, var(--accent), #a855f7) 1;
    background: linear-gradient(135deg, rgba(79,125,249,.06), rgba(168,85,247,.04));
}
.pipe-config-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.pipe-field { flex: 0 0 180px; }
.pipe-field label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--accent);
    margin-bottom: 5px;
}
.pipe-field select {
    width: 100%;
    padding: 8px 12px;
    font-size: .85rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
}
.pipe-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.pipe-field select:disabled { opacity: .5; cursor: not-allowed; }

.pipe-readouts {
    display: flex;
    gap: 16px;
    flex: 1;
    min-width: 0;
}
.readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px;
}
.readout-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.readout-value {
    font-size: .95rem;
    font-weight: 700;
    color: var(--success);
    white-space: nowrap;
}

.pipe-mini-svg {
    flex: 0 0 70px;
    height: 70px;
}
.pipe-mini-svg svg { width: 70px; height: 70px; }

/* ══════════════════════════════════════════════════════════════════════════
   CATEGORY BAR (static tabs row 1)
   ══════════════════════════════════════════════════════════════════════════ */
.category-bar {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.cat-btn {
    flex: 1;
    min-width: max-content;
    padding: 10px 20px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    white-space: nowrap;
}
.cat-btn:hover { color: var(--text-primary); background: var(--bg-card); }
.cat-btn.active { color: #fff; background: var(--accent); box-shadow: 0 2px 12px var(--accent-glow); }

/* ══════════════════════════════════════════════════════════════════════════
   LAUNCHER GRID (calculator cards you click to open)
   ══════════════════════════════════════════════════════════════════════════ */
.launcher-pane { display: none; }
.launcher-pane.active { display: block; animation: fadeIn .25s ease; }

.launcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.launcher-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 14px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-card);
    position: relative;
    transition: all var(--transition);
}
.launcher-card:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
.launcher-icon { font-size: 1.6rem; margin-bottom: 8px; }
.launcher-label { font-size: .88rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.launcher-desc { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }
.launcher-lock {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: .6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════════════════
   DYNAMIC TAB BAR (row 2 — browser-like tabs)
   ══════════════════════════════════════════════════════════════════════════ */
.dyn-tab-bar {
    display: flex;
    gap: 2px;
    padding: 3px 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
    margin-bottom: 0;
}
.dyn-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    max-width: 200px;
}
.dyn-tab:hover { color: var(--text-primary); background: var(--bg-card); }
.dyn-tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
    border-bottom: 2px solid var(--accent);
}
.dyn-tab-launcher {
    color: var(--accent);
    font-weight: 700;
    font-size: .82rem;
    border-right: 1px solid var(--border);
    margin-right: 4px;
    padding-right: 16px;
    flex-shrink: 0;
}
.dyn-tab-launcher:hover { color: var(--accent-hover); background: rgba(79,125,249,.08); }
.dyn-tab-launcher.active { color: var(--accent); background: rgba(79,125,249,.12); border-bottom: 2px solid var(--accent); }
.dyn-tab-label { overflow: hidden; text-overflow: ellipsis; }
.dyn-tab-close {
    font-size: .65rem;
    opacity: .4;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all var(--transition);
}
.dyn-tab-close:hover { opacity: 1; background: var(--danger); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   DYNAMIC PANELS (calculator form + results side by side)
   ══════════════════════════════════════════════════════════════════════════ */
.dyn-panel {
    display: none;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--bg-card);
    animation: fadeIn .2s ease;
    margin-bottom: 20px;
}
.dyn-panel.active { display: block; }

.calc-panel-layout {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    min-height: 300px;
}
.calc-form-side {
    padding: 24px;
    border-right: 1px solid var(--border);
}
.calc-result-side {
    padding: 24px;
    overflow-y: auto;
}
.calc-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    align-items: center;
}

/* Empty state */
.empty-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .5; }
.empty-result p { font-size: .88rem; }

/* Loading state */
.calc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auto-filled highlight */
@keyframes autofillPulse {
    0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
    50%  { box-shadow: 0 0 0 4px rgba(16,185,129,.25); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
.autofilled {
    animation: autofillPulse .8s ease;
    border-color: var(--success) !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — Dynamic panels stack on mobile
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .calc-panel-layout {
        grid-template-columns: 1fr;
    }
    .calc-form-side { border-right: none; border-bottom: 1px solid var(--border); }
    .pipe-config-row { flex-direction: column; align-items: stretch; }
    .pipe-field { flex: 1 1 100%; }
    .pipe-readouts { flex-wrap: wrap; justify-content: center; }
    .launcher-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ══════════════════════════════════════════════════════════════════════════
   PROJECT CANVAS
   ══════════════════════════════════════════════════════════════════════════ */
.canvas-chrome {
    position: fixed;
    inset: 56px 0 0 0;  /* below top-nav */
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
    gap: 12px;
}
.canvas-toolbar-left, .canvas-toolbar-center, .canvas-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.canvas-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}
.canvas-zoom-label {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

/* Viewport */
.canvas-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: default;
    background:
        radial-gradient(circle at 1px 1px, rgba(79,125,249,.08) 1px, transparent 0);
    background-size: 30px 30px;
}

.canvas-world {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
}

.canvas-links-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}
.canvas-link-path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.5;
    stroke-dasharray: 8 4;
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke var(--transition);
    animation: linkDash 1.5s linear infinite;
}
.canvas-link-path:hover {
    stroke: var(--danger);
    stroke-width: 3;
}
@keyframes linkDash {
    to { stroke-dashoffset: -24; }
}
.canvas-link-dot {
    fill: var(--accent);
    pointer-events: none;
}

/* ── Canvas Card ── */
.canvas-card {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    min-width: 280px;
    max-width: 400px;
    z-index: 6;
    transition: box-shadow var(--transition);
}
.canvas-card:hover {
    box-shadow: 0 6px 30px rgba(0,0,0,.45);
    border-color: rgba(79,125,249,.4);
}
.canvas-card.dragging {
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
    z-index: 20;
    opacity: .92;
}
.canvas-card.collapsed .cv-body { display: none; }

.cv-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(79,125,249,.08), rgba(168,85,247,.05));
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: grab;
    user-select: none;
}
.cv-header:active { cursor: grabbing; }
.cv-icon { font-size: 1.1rem; }
.cv-title { font-size: .85rem; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cv-header-actions { display: flex; gap: 4px; }
.cv-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: .75rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition);
}
.cv-btn:hover { color: var(--text-primary); background: rgba(255,255,255,.08); }
.cv-delete-btn:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.cv-body { padding: 12px 14px; }

.cv-section-label {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.cv-field { margin-bottom: 8px; }
.cv-field label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
}
.cv-field-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cv-field-row .form-control-sm {
    padding: 6px 10px;
    font-size: .8rem;
    flex: 1;
}
.linked-field .form-control-sm {
    border-color: var(--accent);
    background: rgba(79,125,249,.06);
}
.link-badge {
    font-size: .65rem;
    opacity: .7;
}

/* Ports */
.cv-port {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: .55rem;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-card);
    cursor: crosshair;
    flex-shrink: 0;
    transition: all var(--transition);
}
.cv-port.visible {
    display: flex;
}
.cv-port:hover {
    border-color: var(--accent);
    background: rgba(79,125,249,.15);
    transform: scale(1.2);
}
.cv-port.selected {
    border-color: var(--success);
    background: rgba(16,185,129,.2);
    animation: portPulse 1s ease infinite;
}
.cv-port-in { color: var(--accent); }
.cv-port-out { color: var(--success); }

@keyframes portPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
    50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.cv-actions {
    margin: 10px 0;
    display: flex;
    gap: 6px;
}

.cv-results-section { margin-top: 8px; border-top: 1px solid var(--border); padding-top: 10px; }

.cv-result-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: .78rem;
}
.cv-result-label { color: var(--text-muted); flex: 1; }
.cv-result-value { color: var(--success); font-weight: 700; }
.cv-empty-results {
    text-align: center;
    padding: 12px;
    color: var(--text-muted);
    font-size: .8rem;
}

/* ── Add Card Drawer ── */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.drawer-panel {
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.drawer-search { margin-bottom: 12px; }
.drawer-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.drawer-group-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    padding: 10px 4px 4px;
}
.drawer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
    color: var(--text-primary);
}
.drawer-item:hover {
    border-color: var(--accent);
    background: rgba(79,125,249,.06);
}
.drawer-item-icon { font-size: 1.3rem; flex-shrink: 0; }
.drawer-item-info { display: flex; flex-direction: column; }
.drawer-item-label { font-size: .88rem; font-weight: 700; }
.drawer-item-desc { font-size: .72rem; color: var(--text-muted); }

/* ── Link Mode Bar ── */
.link-mode-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,.4);
    font-size: .85rem;
    color: var(--text-secondary);
}
.link-mode-bar em { color: var(--accent); }
.link-mode-bar strong { color: var(--text-primary); }

/* Active state for toggle button */
.canvas-toolbar .btn.active {
    background: rgba(79,125,249,.15);
    color: var(--accent);
    border-color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════════════
   LIGHT MODE — all pages that use app.css
   ══════════════════════════════════════════════════════════════════════ */
body.light-mode {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f1f5;
    --bg-input: #f0f1f5;
    --border: #e2e4ea;
    --border-focus: #4f46e5;
    --text-primary: #1a1a2e;
    --text-secondary: #5a5a70;
    --text-muted: #8888a0;
    --accent: #4f46e5;
    --accent-hover: #6366f1;
    --accent-glow: rgba(79, 70, 229, .18);
    --shadow: 0 4px 24px rgba(0, 0, 0, .06);
}
body.light-mode .top-nav {
    background: rgba(255, 255, 255, .92);
    border-bottom-color: #e2e4ea;
}
body.light-mode .top-nav .brand {
    -webkit-text-fill-color: unset;
    background: none;
    color: #4f46e5;
}
body.light-mode .btn-ghost { border-color: #e2e4ea; color: #5a5a70; }
body.light-mode .btn-ghost:hover { background: #f0f1f5; color: #1a1a2e; border-color: #cdd0d9; }
body.light-mode .btn-danger { background: #fef2f2; color: #dc2626; }
body.light-mode .btn-danger:hover { background: #dc2626; color: #fff; }
body.light-mode .auth-page { background: var(--bg-primary); }
body.light-mode .auth-box .card { background: #fff; border-color: #e2e4ea; box-shadow: 0 4px 24px rgba(0,0,0,.06); }
body.light-mode .profile-page .stat-card { background: #fff; border-color: #e2e4ea; }
body.light-mode .profile-section { background: #fff; border-color: #e2e4ea; }
body.light-mode .pricing-card { background: #fff; border-color: #e2e4ea; }
body.light-mode .pricing-card.is-current { border-color: var(--accent); }
body.light-mode .alert { background: #f0f1f5; border-color: #e2e4ea; color: #374151; }
/* Scope link colour to non-button, non-nav-item anchors so button text stays visible */
body.light-mode a:not(.btn):not(.acc-nav-item):not(.acc-proj-name):not(.acc-proj-btn):not(.acc-proj-thumb):not(.admin-page-row) { color: #4f46e5; }
body.light-mode a:not(.btn):not(.acc-nav-item):not(.acc-proj-name):not(.acc-proj-btn):not(.acc-proj-thumb):not(.admin-page-row):hover { color: #6366f1; }
/* Ensure button text colours are preserved in light mode */
body.light-mode .btn-primary { color: #fff; }
body.light-mode .btn-success { color: #fff; }
body.light-mode .btn-warning { color: #1a1a2e; }
body.light-mode .btn-premium { color: #fff; }
/* Account/profile page light overrides */
body.light-mode .acc-sidebar,
body.light-mode .acc-proj-card,
body.light-mode .acc-form-card,
body.light-mode .acc-usage-card { background: #ffffff; border-color: #e2e4ea; }
body.light-mode .acc-proj-thumb { background: #f0f2f7; }
body.light-mode .acc-proj-thumb:hover { background: #e5e7ef; }
body.light-mode .acc-view-toggle { background: #f0f2f7; border-color: #e2e4ea; }
body.light-mode .acc-search { background: #f0f2f7; border-color: #e2e4ea; color: #1a1a2e; }
body.light-mode .acc-usage-bar { background: #e2e4ea; }
body.light-mode .acc-nav-item { color: #4a4f68; }
body.light-mode .acc-nav-item:hover { background: #f0f2f7; color: #1a1a2e; }
body.light-mode .acc-nav-item.active { background: rgba(79,70,229,.1); color: #4f46e5; }
body.light-mode .acc-proj-name { color: #1a1a2e; }
body.light-mode .acc-proj-name:hover { color: #4f46e5; }
body.light-mode .acc-proj-btn { background: #f0f2f7; border-color: #e2e4ea; color: #4a4f68; }
body.light-mode .acc-proj-btn:hover { background: #e2e4ea; color: #1a1a2e; }
body.light-mode .acc-share-tag { background: rgba(79,70,229,.1); color: #4f46e5; }
body.light-mode .field-label { color: #1a1a2e; }
body.light-mode .field-input { background: #f0f2f7; border-color: #e2e4ea; color: #1a1a2e; }
body.light-mode .field-input:focus { border-color: #4f46e5; }
body.light-mode .acc-tab-title { color: #1a1a2e; }
body.light-mode .acc-tab-sub,
body.light-mode .acc-usage-label,
body.light-mode .acc-email,
body.light-mode .acc-proj-meta,
body.light-mode .acc-meta-dot,
body.light-mode .acc-form-foot { color: #8a8fa8; }

/* --------------------------------------------------
   ACCOUNT / PROFILE PAGE  (revamped layout)
   -------------------------------------------------- */
.acc-layout {
    display: flex;
    min-height: calc(100vh - 60px);
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 16px;
    gap: 24px;
    align-items: flex-start;
}

/* -- Sidebar -- */
.acc-sidebar {
    flex-shrink: 0;
    width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 16px 16px;
    position: sticky;
    top: 80px;
}
.acc-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700; color: #fff;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.acc-name { font-weight: 700; font-size: 15px; color: var(--text-primary); text-align: center; }
.acc-email { font-size: 12px; color: var(--text-400); text-align: center; margin-top: 2px; word-break: break-all; }

/* Nav */
.acc-nav { width: 100%; margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.acc-nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; text-decoration: none;
    transition: background .15s, color .15s;
    position: relative;
}
.acc-nav-item:hover { background: var(--bg-700); color: var(--text-primary); }
.acc-nav-item.active { background: rgba(99,102,241,.15); color: var(--accent); }
.acc-nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff; font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 4px;
}
.acc-nav-sep { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.acc-sidebar-footer { width: 100%; margin-top: auto; padding-top: 16px; }

/* -- Main -- */
.acc-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Tabs */
.acc-tab { display: none; }
.acc-tab.active { display: block; }

.acc-tab-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.acc-tab-title { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.acc-tab-sub { font-size: 13px; color: var(--text-400); margin: 4px 0 0; }

/* Toolbar */
.acc-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.acc-view-toggle {
    display: flex;
    background: var(--bg-700);
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}
.acc-view-btn {
    padding: 5px 9px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .12s, color .12s;
}
.acc-view-btn:hover { background: var(--bg-600); color: var(--text-primary); }
.acc-view-btn.active { background: var(--bg-500); color: var(--text-primary); }
.acc-search {
    flex: 1;
    max-width: 280px;
    padding: 7px 12px;
    background: var(--bg-700);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color .15s;
}
.acc-search:focus { border-color: var(--accent); }

/* Usage bar (thin progress under header) */
.acc-usage-bar-wrap { margin-bottom: 18px; }
.acc-usage-bar {
    height: 4px;
    background: var(--bg-600);
    border-radius: 2px;
    overflow: hidden;
}
.acc-usage-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.acc-usage-warn { background: var(--red, #ef4444); }

/* Project grid */
.acc-proj-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.acc-proj-grid.acc-proj-list {
    grid-template-columns: 1fr;
}
.acc-proj-card {
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color .15s, box-shadow .15s;
    position: relative;
}
.acc-proj-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(99,102,241,.12); }
.acc-proj-card.acc-proj-archived { opacity: .55; }
.acc-proj-thumb {
    display: flex; align-items: center; justify-content: center;
    height: 110px;
    background: var(--bg-700);
    text-decoration: none;
    transition: background .15s;
}
.acc-proj-thumb:hover { background: var(--bg-600); }
.acc-proj-thumb-img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.acc-proj-thumb-icon { font-size: 36px; }

/* List mode overrides */
.acc-proj-list .acc-proj-card {
    flex-direction: row;
    align-items: center;
    border-radius: 8px;
}
.acc-proj-list .acc-proj-thumb {
    width: 52px; height: 52px;
    flex-shrink: 0;
    border-radius: 8px;
}
.acc-proj-list .acc-proj-thumb-icon { font-size: 22px; }

.acc-proj-info {
    padding: 10px 12px 8px;
    flex: 1;
    min-width: 0;
}
.acc-proj-name {
    display: block;
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-bottom: 4px;
}
.acc-proj-name:hover { color: var(--accent); }
.acc-proj-meta {
    display: flex; flex-wrap: wrap; gap: 4px;
    font-size: 11px; color: var(--text-400);
    align-items: center;
}
.acc-meta-dot { color: var(--text-500); }
.acc-share-tag {
    background: rgba(99,102,241,.15);
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.acc-proj-actions {
    display: flex;
    gap: 4px;
    padding: 4px 8px 8px;
    justify-content: flex-end;
}
.acc-proj-btn {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--bg-700);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background .12s, color .12s;
    cursor: pointer;
}
.acc-proj-btn:hover { background: var(--bg-500); color: var(--text-primary); }

/* Empty state */
.acc-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-400);
}
.acc-empty-icon { font-size: 48px; margin-bottom: 12px; }
.acc-empty h3 { font-size: 16px; color: var(--text-secondary); margin: 0 0 6px; }
.acc-empty p { font-size: 13px; margin: 0 0 16px; }

/* Forms */
.acc-form-card {
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    max-width: 520px;
}
.acc-field { margin-bottom: 16px; }
.acc-form-foot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-400); }

/* Usage grid (plan tab) */
.acc-usage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.acc-usage-card {
    background: var(--bg-800);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}
.acc-usage-label { font-size: 11px; color: var(--text-400); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-bottom: 6px; }
.acc-usage-value { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.acc-usage-limit { font-size: 14px; font-weight: 400; color: var(--text-400); }
.acc-section-heading { font-size: .8rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 10px; }

/* Responsive: collapse sidebar to top on mobile */
@media (max-width: 768px) {
    .acc-layout { flex-direction: column; padding: 12px 10px; }
    .acc-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; border-radius: 10px; padding: 14px; gap: 10px; position: static; }
    .acc-avatar { width: 44px; height: 44px; font-size: 18px; margin-bottom: 0; }
    .acc-name, .acc-email { text-align: left; }
    .acc-nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
    .acc-nav-item { padding: 6px 10px; font-size: 12px; }
    .acc-sidebar-footer { display: none; }
    .acc-proj-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
