:root {
    --bg-primary: #030d14;
    --bg-secondary: rgba(5, 63, 90, 0.2);
    --card-bg: rgba(10, 50, 72, 0.45);
    --border-color: rgba(54, 205, 116, 0.15);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary: #36CD74;
    --primary-hover: #22a55a;
    --primary-glow: rgba(54, 205, 116, 0.15);
    --secondary: #053F5A;
    --accent: #23CDFC;
    --gold: #FDC160;
    --danger: #ef4444;
    --font-header: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;

    --glow-green: 0 0 15px rgba(54, 205, 116, 0.25);
    --glow-cyan: 0 0 15px rgba(35, 205, 252, 0.25);
    --glow-gold: 0 0 15px rgba(253, 193, 96, 0.25);
    --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.lucide {
    width: 1em;
    height: 1em;
    stroke-width: 2px;
    vertical-align: -0.125em;
    flex-shrink: 0;
}

h1, h2, h3, h4, h5, h6, .logo-text {
    font-family: var(--font-header);
    letter-spacing: -0.01em;
}

p { color: var(--text-secondary); line-height: 1.5; }
code {
    background: rgba(255,255,255,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Login screen */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, rgba(54,205,116,0.08), var(--bg-primary) 60%);
    z-index: 1000;
}
.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 380px;
    text-align: center;
    backdrop-filter: blur(10px);
}
.login-logo-wrap {
    margin-bottom: 24px;
    text-align: center;
}
.login-logo {
    width: 210px;
    height: auto;
}
.login-desc { font-size: 0.9rem; margin-bottom: 24px; }
.login-btn-container { display: flex; justify-content: center; }
.login-error { color: var(--danger); font-size: 0.85rem; margin-top: 16px; }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar styling (Slate glassmorphism) */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding-left: 10px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: 12px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-item a:hover, .nav-item.active a {
    color: var(--text-primary);
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.nav-item.active a .nav-icon {
    color: var(--primary);
}

.nav-icon {
    font-size: 18px;
    transition: var(--transition-smooth);
}

/* User card in sidebar */
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #050505;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.logout-btn:hover {
    color: var(--danger);
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 5px;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Tab contents (hidden by default) */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Glassmorphic Cards */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-card);
    transition: var(--transition-smooth);
    margin-bottom: 24px;
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.dashboard-grid.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card { display: flex; flex-direction: column; gap: 4px; padding: 20px; margin-bottom: 0; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); font-family: var(--font-header); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--primary);
    color: #050505;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: rgba(51, 65, 85, 0.8);
    border-color: rgba(255,255,255,0.2);
}

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inputs & Form Controls */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    transition: var(--transition-smooth);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

textarea.form-control { resize: vertical; min-height: 80px; font-family: var(--font-body); }

/* Tables styling */
.clean-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

/* Clickable text links inside table cells (e.g. a project name that opens
   Project Detail) — bare unstyled <a> tags fall back to browser-default
   link blue, illegible against this app's dark background. */
.table-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.table-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.clean-table th, .clean-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.clean-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clean-table th[data-sort-key] {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.clean-table th[data-sort-key]:hover {
    color: var(--text-primary);
}

/* Long headers opt into wrapping onto two lines so their column can narrow;
   the freed width goes to whichever column carries .col-wide. Specificity is
   deliberately higher than the th[data-sort-key] nowrap rule above so it
   wins regardless of source order.
   The two caps are sized off the widest single word in each group, since a
   cap narrower than that word wraps to 3+ cramped lines instead of 2:
   110px fits "ESTIMATED" (79px + 24px padding); 150px fits "COMPLETED (PM)"
   on its own second line (123px + padding). */
.clean-table th.th-wrap,
.clean-table th[data-sort-key].th-wrap {
    white-space: normal;
    max-width: 110px;
}

.clean-table th.th-wrap-lg,
.clean-table th[data-sort-key].th-wrap-lg {
    white-space: normal;
    max-width: 150px;
}

/* First claim on the space the wrapped headers give up. */
.clean-table th.col-wide {
    min-width: 240px;
}

/* Short phrases ("Substantial Completion") that read fine on two lines once
   their column narrows — capped to match the .th-wrap-lg header above them
   so a long value can't re-widen the column. */
.clean-table td.cell-wrap {
    white-space: normal;
    max-width: 150px;
}

/* Denser padding for wide tables that would otherwise overflow horizontally. */
.clean-table.table-compact th,
.clean-table.table-compact td {
    padding: 12px 12px;
}

.sort-indicator {
    display: inline-block;
    width: 12px;
    margin-left: 2px;
    color: var(--primary);
}

.clean-table td {
    font-size: 14px;
    color: var(--text-primary);
}

.clean-table tr:hover td {
    background: rgba(255,255,255,0.02);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: inline-block;
}

.badge-success {
    background: rgba(54, 205, 116, 0.15);
    color: var(--primary);
    border: 1px solid rgba(54, 205, 116, 0.3);
}

.badge-info {
    background: rgba(35, 205, 252, 0.15);
    color: var(--accent);
    border: 1px solid rgba(35, 205, 252, 0.3);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
    background: rgba(253, 193, 96, 0.15);
    color: var(--gold);
    border: 1px solid rgba(253, 193, 96, 0.3);
}

/* Wizard: single-page sections + sticky pill nav */
.wizard-header-sticky {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--bg-primary);
    padding-bottom: 20px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 20px 20px -20px rgba(0, 0, 0, 0.5);
}

.wizard-nav-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wizard-pill {
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    white-space: nowrap;
    flex: 1 1 0;
    text-align: center;
}

.wizard-pill:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

.wizard-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #050505;
    box-shadow: 0 0 12px var(--primary-glow);
}

.wizard-section {
    margin-bottom: 30px;
    scroll-margin-top: 180px;
}

.wizard-section:first-of-type {
    margin-top: 25px;
}

.wizard-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.wizard-section-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.line-item-category-block { margin-bottom: 28px; }
.line-item-category-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.li-table input, .li-table select { padding: 6px 8px; font-size: 13px; }
.li-table td { padding: 8px 6px; }
.li-table th { padding: 8px 6px; font-size: 11px; }
.li-readonly { color: var(--text-secondary); font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }

/* Costs tab: QuickBooks sync status + filter bar */
.qb-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.qb-filter-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

.scope-section-card, .milestone-row {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 14px;
}
