/* GritWerk — Brand CSS */
:root {
    --bg-primary: #0c0c14;
    --bg-secondary: #12121f;
    --bg-card: #16162a;
    --bg-hover: #1c1c35;
    --border: rgba(255,255,255,0.06);
    --border-focus: rgba(0,255,213,0.4);
    --text-primary: #f0f0ff;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent: #00ffd5;
    --accent-hover: #33ffe0;
    --accent-dim: rgba(0,255,213,0.08);
    --accent-glow: rgba(0,255,213,0.15);
    --orchestrator: #a78bfa;
    --orchestrator-dim: rgba(167,139,250,0.12);
    --gain: #22dd88;
    --loss: #ef5350;
    --warning: #ffa726;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-width: 240px;
    --touch-min: 44px;
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

[x-cloak] { display: none !important; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.section-content {
    animation: fadeSlideIn 300ms var(--ease-out);
}
.section-heading {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow: hidden;
}
.sidebar nav {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-logo {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.sidebar-logo p { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

.nav-group { padding: 6px 0 2px; }
.nav-label {
    padding: 2px 20px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    min-height: var(--touch-min);
    position: relative;
    border-radius: 8px;
    transition: color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.nav-item:hover { color: var(--text-primary); background: var(--accent-dim); }
.nav-item.active {
    color: var(--accent);
    background: var(--accent-dim);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 0;
    border-top: 1px solid var(--border);
}

/* ── Mobile header ── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 110;
}
.hamburger {
    background: none; border: none; color: var(--text-primary);
    padding: 8px; cursor: pointer; min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
}
.mobile-title { font-size: 18px; font-weight: 700; }

/* ── Main content ── */
.content {
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    min-height: 100vh;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 24px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header .page-title { margin-bottom: 0; }

/* ── KPI Grid ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.kpi-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(0,255,213,0.03) 100%);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.1);
}
.kpi-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-family: var(--mono); }
.kpi-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.kpi-alert { border-color: var(--loss); }
.kpi-alert .kpi-value { color: var(--loss); }

/* ── Section card ── */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    backdrop-filter: blur(8px);
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.section-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* ── Data tables ── */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th {
    text-align: left;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--bg-hover); }
.data-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.data-table tbody tr { transition: background 120ms var(--ease-out); }
.data-table tbody tr:hover { background: var(--accent-dim); }

/* ── Pipeline board ── */
.pipeline-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    min-height: 400px;
}
.pipeline-col {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 200px;
}
.pipeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.pipeline-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}
.pipeline-count {
    font-size: 11px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}
.pipeline-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.pipeline-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.1);
}
.pipeline-card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.pipeline-card-client { font-size: 12px; color: var(--text-secondary); }
.pipeline-card-amount { font-size: 13px; color: var(--accent); margin-top: 6px; font-family: var(--mono); }

/* ── Activity list ── */
.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.activity-badge.payment { background: rgba(34,221,136,0.15); color: var(--gain); }
.activity-badge.project { background: var(--accent-dim); color: var(--accent); }
.activity-client { color: var(--text-secondary); font-size: 13px; min-width: 100px; }
.activity-desc { flex: 1; }
.activity-amount { font-family: var(--mono); color: var(--gain); font-size: 13px; }

/* ── Status badges ── */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 3px 8px;
    border-radius: 6px;
}
.status-lead { background: rgba(136,136,170,0.12); color: var(--text-secondary); border: 1px solid rgba(136,136,170,0.2); }
.status-proposal { background: rgba(255,167,38,0.12); color: var(--warning); border: 1px solid rgba(255,167,38,0.2); }
.status-active { background: rgba(0,255,213,0.12); color: var(--accent); border: 1px solid rgba(0,255,213,0.2); }
.status-delivered { background: rgba(34,221,136,0.12); color: var(--gain); border: 1px solid rgba(34,221,136,0.2); }
.status-paid { background: rgba(34,221,136,0.12); color: var(--gain); border: 1px solid rgba(34,221,136,0.2); }
.status-draft { background: rgba(136,136,170,0.12); color: var(--text-secondary); border: 1px solid rgba(136,136,170,0.2); }
.status-sent { background: rgba(0,255,213,0.12); color: var(--accent); border: 1px solid rgba(0,255,213,0.2); }
.status-overdue { background: rgba(239,83,80,0.12); color: var(--loss); border: 1px solid rgba(239,83,80,0.2); }
.status-pending { background: rgba(255,167,38,0.12); color: var(--warning); border: 1px solid rgba(255,167,38,0.2); }
.status-completed { background: rgba(34,221,136,0.12); color: var(--gain); border: 1px solid rgba(34,221,136,0.2); }
.status-refunded { background: rgba(239,83,80,0.12); color: var(--loss); border: 1px solid rgba(239,83,80,0.2); }
.status-voided { background: rgba(136,136,170,0.12); color: var(--text-muted); border: 1px solid rgba(136,136,170,0.15); }
.status-shipped { background: rgba(0,255,213,0.12); color: var(--accent); border: 1px solid rgba(0,255,213,0.2); }

/* ── Buttons ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    min-height: var(--touch-min);
    position: relative;
    transition: all 200ms var(--ease-out);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font);
    transition: background 120ms;
    min-height: 44px;
}
.btn-secondary:hover { background: var(--bg-card); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    min-height: 32px;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(239,83,80,0.15);
    color: var(--loss);
    border: 1px solid rgba(239,83,80,0.3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    min-height: 32px;
}
.btn-danger:hover { background: rgba(239,83,80,0.25); }

.btn-group {
    display: flex;
    gap: 8px;
}

/* ── Forms ── */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.field input, .field select, .field textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 120ms;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--border-focus);
}
.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888aa' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.field textarea { resize: vertical; min-height: 60px; }

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    margin-bottom: 20px;
    transition: border-color 120ms;
}
.search-input:focus { border-color: var(--border-focus); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 24px; }
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ── POS Register ── */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
    min-height: 500px;
}

.pos-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.pos-cat-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    transition: all 120ms;
    min-height: 44px;
}
.pos-cat-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.pos-cat-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.pos-services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.pos-service-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 120ms;
    text-align: center;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.pos-service-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.pos-service-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.pos-service-price { font-size: 16px; font-family: var(--mono); color: var(--accent); }

.pos-cart {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.pos-cart-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pos-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.pos-cart-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-item-name { flex: 1; }
.pos-cart-item-qty {
    width: 40px;
    text-align: center;
    font-family: var(--mono);
    color: var(--text-secondary);
    font-size: 12px;
}
.pos-cart-item-price { font-family: var(--mono); min-width: 70px; text-align: right; }
.pos-cart-item-remove {
    background: none;
    border: none;
    color: var(--loss);
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    line-height: 1;
}

.pos-cart-footer {
    border-top: 1px solid var(--border);
    padding: 16px 20px;
}
.pos-cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}
.pos-cart-total .amount { font-family: var(--mono); color: var(--accent); }

.pos-payment-select {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.pos-pay-opt {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    font-family: var(--font);
    min-height: 36px;
}
.pos-pay-opt.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.pos-checkout-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font);
    min-height: 52px;
    transition: background 120ms;
}
.pos-checkout-btn:hover { background: #33ffe0; }
.pos-checkout-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pos-receipt-card {
    background: var(--bg-card);
    border: 1px solid var(--gain);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin-top: 16px;
}
.pos-receipt-card h4 { color: var(--gain); font-size: 16px; margin-bottom: 8px; }
.pos-receipt-tx { font-family: var(--mono); color: var(--accent); font-size: 18px; margin-bottom: 4px; }
.pos-receipt-amount { font-family: var(--mono); font-size: 24px; font-weight: 700; }

.pos-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}
.pos-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: all 120ms;
}
.pos-tab:hover { color: var(--text-primary); }
.pos-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── POS Quick Sale (legacy) ── */
.pos-result {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.pos-link-row {
    display: flex;
    gap: 8px;
}
.pos-link-row input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 13px;
}

/* ── Utility classes ── */
.accent { color: var(--accent); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.warning { color: var(--warning); }
.mono { font-family: var(--mono); }
.link { color: var(--accent); text-decoration: none; font-size: 13px; }
.link:hover { text-decoration: underline; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .pipeline-board { grid-template-columns: repeat(3, 1fr); }
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .pos-layout { grid-template-columns: 1fr; }
}

/* ── Sidebar backdrop (mobile) ── */
.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .mobile-header { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform 200ms; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }
    .content { margin-left: 0; padding: 72px 16px 24px; }
    .pipeline-board { grid-template-columns: 1fr 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .pos-services-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .pipeline-board { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr; }
    .pos-services-grid { grid-template-columns: 1fr; }
}

/* ── Agent Office ── */
.agent-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.agent-project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(8px);
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.agent-project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.1);
}
.status-border-active { border-left: 3px solid var(--accent); }
.status-border-paused { border-left: 3px solid var(--warning); }
.status-border-shipped { border-left: 3px solid var(--gain); }
.status-border-archived { border-left: 3px solid var(--text-muted); }

.agent-project-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}
.agent-project-name { font-size: 16px; font-weight: 700; }
.agent-project-stack { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.agent-project-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.4; }

.agent-project-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.agent-stat { font-size: 12px; color: var(--text-muted); }
.agent-stat-val { font-family: var(--mono); color: var(--accent); font-weight: 600; }

.agent-project-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 4px;
}

.agent-project-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.agent-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--accent-dim);
    color: var(--accent);
    margin-right: 4px;
}

.agent-burn-bars { display: flex; flex-direction: column; gap: 12px; }
.agent-burn-row { display: flex; align-items: center; gap: 12px; }
.agent-burn-label { min-width: 160px; font-size: 14px; font-weight: 500; display: flex; align-items: center; }
.agent-burn-bar-wrap { flex: 1; height: 20px; background: var(--bg-primary); border-radius: 4px; overflow: hidden; }
.agent-burn-bar { height: 100%; background: linear-gradient(90deg, var(--accent), rgba(0,255,213,0.4)); border-radius: 4px; transition: width 300ms; }
.agent-burn-val { min-width: 80px; text-align: right; font-size: 13px; color: var(--accent); }

.status-paused { background: rgba(255,167,38,0.12); color: var(--warning); border: 1px solid rgba(255,167,38,0.2); }

.worker-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--wc) 20%, var(--bg-primary));
    border: 2px solid var(--wc);
    color: var(--wc);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}
.worker-avatar.sm {
    width: 24px;
    height: 24px;
    font-size: 9px;
    border-width: 1.5px;
}

.worker-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--wc) 15%, transparent);
    color: var(--wc);
    white-space: nowrap;
}

.worker-bar-wrap {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}
.worker-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 300ms;
    opacity: 0.85;
}

@media (max-width: 768px) {
    .agent-projects-grid { grid-template-columns: 1fr; }
    .agent-burn-label { min-width: 100px; font-size: 12px; }
    .agent-burn-val { min-width: 60px; font-size: 11px; }
}

/* ── Live Projects ── */
.live-projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 12px;
}
.live-project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    backdrop-filter: blur(8px);
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.live-project-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.1);
}
.live-project-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.live-project-url {
    font-size: 12px;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}
.live-project-stack {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.live-project-status {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}

@media (max-width: 768px) {
    .live-projects-grid { grid-template-columns: 1fr; }
}

/* ── Agent Team Roster ── */
.agent-team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.agent-team-card {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.agent-team-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.agent-team-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.agent-team-role {
    font-size: 11px;
    color: var(--text-secondary);
}
.agent-team-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.agent-team-stat {
    display: flex;
    flex-direction: column;
}
.agent-team-stat-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}
.agent-team-stat-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}
/* ── Org Tree ── */
.org-tree {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}
.org-coleads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 600px) {
    .org-coleads { grid-template-columns: 1fr; }
}
.org-node {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 32px;
}
.org-node-top {
    display: flex;
    align-items: center;
    gap: 18px;
}
.org-node-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.org-root {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(0, 255, 213, 0.12);
}
.org-lead {
    border-color: #a78bfa;
    box-shadow: 0 0 16px rgba(167, 139, 250, 0.12);
}
.worker-avatar.lg {
    width: 52px;
    height: 52px;
    font-size: 18px;
}
.org-info { flex: 1; }
.org-name { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.org-role { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.org-connector {
    width: 2px;
    height: 20px;
    background: var(--border);
    align-self: center;
}
.org-branches {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    width: 100%;
}
.org-branch {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px 24px;
}
.org-branch-header {
    display: flex;
    align-items: center;
    gap: 16px;
}
.org-branch-info { flex: 1; min-width: 0; }
.org-branch-name { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.org-branch-role { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.org-branch-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.org-branch-metric {
    display: flex;
    flex-direction: column;
}
.org-metric-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-family: 'JetBrains Mono', monospace;
}
.org-metric-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}
.org-branch-idle {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 768px) {
    .org-branches { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .org-branches { grid-template-columns: 1fr; }
}

/* ── Settings ── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.settings-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.settings-msg {
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}
.settings-msg.gain { background: rgba(34,221,136,0.1); color: var(--gain); }
.settings-msg.loss { background: rgba(239,83,80,0.1); color: var(--loss); }

.passkey-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.passkey-item:last-child { border-bottom: none; }

.passkey-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.passkey-name {
    font-size: 14px;
    font-weight: 500;
}
.passkey-date {
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .settings-grid { grid-template-columns: 1fr; }
}

/* ── Theme Toggle Button ── */
.theme-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    width: 100%;
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    transition: color 150ms, border-color 150ms;
    margin-bottom: 4px;
}
.theme-btn:hover { color: var(--accent); border-color: rgba(0,255,213,0.3); }
.theme-btn svg { flex-shrink: 0; }
.theme-btn .icon-sun  { display: none; }
.theme-btn .icon-moon { display: block; }
[data-theme="light"] .theme-btn .icon-sun  { display: block; }
[data-theme="light"] .theme-btn .icon-moon { display: none; }
[data-theme="light"] .theme-btn:hover { color: var(--accent); border-color: rgba(0,120,110,0.3); }

/* ── Light Mode ── */
[data-theme="light"] {
    --bg-primary:     #f4f4f8;
    --bg-secondary:   #ffffff;
    --bg-card:        #ffffff;
    --bg-hover:       #ebebf3;
    --border:         rgba(0,0,0,0.08);
    --border-focus:   rgba(0,120,110,0.45);
    --text-primary:   #0f0f1a;
    --text-secondary: #555577;
    --text-muted:     #9999bb;
    --accent:         #007870;
    --accent-hover:   #009a90;
    --accent-dim:     rgba(0,120,110,0.08);
    --accent-glow:    rgba(0,120,110,0.15);
    --orchestrator:   #6d28d9;
    --orchestrator-dim: rgba(109,40,217,0.1);
}

[data-theme="light"] body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

[data-theme="light"] .sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border);
    box-shadow: 1px 0 12px rgba(0,0,0,0.06);
}

[data-theme="light"] .sidebar-logo { border-bottom-color: var(--border); }
[data-theme="light"] .sidebar-footer { border-top-color: var(--border); }

[data-theme="light"] .nav-item:hover,
[data-theme="light"] .nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
}
[data-theme="light"] .nav-item.active::before { background: var(--accent); }

[data-theme="light"] .mobile-header {
    background: var(--bg-secondary);
    border-bottom-color: var(--border);
}

[data-theme="light"] .kpi-card {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .kpi-value { color: var(--accent); }

[data-theme="light"] .section-card {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="light"] .data-table thead th {
    background: var(--bg-hover);
    border-bottom-color: var(--border);
    color: var(--text-secondary);
}
[data-theme="light"] .data-table tbody tr:hover { background: var(--bg-hover); }
[data-theme="light"] .data-table td { border-bottom-color: var(--border); }

[data-theme="light"] .btn-primary {
    background: var(--accent);
    color: #fff;
}
[data-theme="light"] .btn-primary:hover { background: var(--accent-hover); }
[data-theme="light"] .btn-secondary {
    border-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] .btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

[data-theme="light"] .modal-backdrop { background: rgba(0,0,0,0.35); }
[data-theme="light"] .modal-box {
    background: var(--bg-secondary);
    border-color: var(--border);
    box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
[data-theme="light"] .modal-header { border-bottom-color: var(--border); }
[data-theme="light"] .modal-footer { border-top-color: var(--border); }

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: var(--bg-primary);
    border-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    border-color: var(--border-focus);
}

[data-theme="light"] .agent-project-card {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="light"] .org-node {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .org-root {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(0,120,110,0.12);
}
[data-theme="light"] .org-lead {
    border-color: #6d28d9;
    box-shadow: 0 0 16px rgba(109,40,217,0.12);
}
[data-theme="light"] .org-branch {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .org-connector { background: var(--border); }

[data-theme="light"] .pipeline-col-header { background: var(--bg-hover); }
[data-theme="light"] .pipeline-card {
    background: var(--bg-secondary);
    border-color: var(--border);
}
[data-theme="light"] .pipeline-card:hover { background: var(--bg-hover); }

[data-theme="light"] .settings-card {
    background: var(--bg-secondary);
    border-color: var(--border);
}

[data-theme="light"] .search-input,
[data-theme="light"] .filter-select {
    background: var(--bg-secondary);
    border-color: var(--border);
    color: var(--text-primary);
}

[data-theme="light"] .badge {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="light"] .worker-avatar {
    background: color-mix(in srgb, var(--wc, var(--accent)) 18%, var(--bg-hover));
    color: var(--wc, var(--accent));
    border-color: color-mix(in srgb, var(--wc, var(--accent)) 35%, transparent);
}

[data-theme="light"] .tab-btn {
    background: none;
    border-color: var(--border);
    color: var(--text-secondary);
}
[data-theme="light"] .tab-btn.active,
[data-theme="light"] .tab-btn:hover {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}
