/* ============================================
   BuildTrack — Custom Styles
   Bootstrap 5 overrides + layout system
   ============================================ */

/* --- Auth gate: hide body until JS confirms session --- */
body:not(.auth-ready) .main-wrapper { opacity: 0; }
body.auth-ready .main-wrapper { opacity: 1; transition: opacity 0.15s ease; }

/* --- CSS Variables (Design Tokens) --- */
:root {
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-active: #2563eb;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --primary: #2563eb;
    --primary-light: #eff6ff;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
}

/* --- Base --- */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand h2 {
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.025em;
}

.sidebar-brand small {
    color: var(--text-sidebar);
    font-size: 0.75rem;
    font-weight: 400;
}

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.15s ease;
}

.sidebar-nav li a:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-nav li a.active {
    background-color: var(--sidebar-active);
    color: #ffffff;
}

.sidebar-nav li a.sidebar-back {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.5rem;
}

.sidebar-nav li a.sidebar-back:hover {
    color: #ffffff;
    background-color: transparent;
}

.sidebar-nav li a i {
    font-size: 1.1rem;
    width: 1.25rem;
    text-align: center;
}

/* Locked / phase-gated nav items */
.sidebar-nav li a.sidebar-locked {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: all; /* keep hover so tooltip shows */
}
.sidebar-nav li a.sidebar-locked:hover {
    background-color: transparent;
    color: var(--text-sidebar);
}
.sidebar-lock-icon {
    margin-left: auto;
    font-size: 0.65rem;
    opacity: 0.8;
    flex-shrink: 0;
}

/* Contract / Selections tab bar */
.contract-tab-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.contract-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.contract-tab:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}
.contract-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Trade block in Selections Summary */
.sel-trade { margin-bottom: 1.75rem; }
.sel-trade-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border-color);
}
.sel-trade-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.sel-trade-sub {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-sidebar);
    font-size: 0.75rem;
}

/* --- Dropdowns --- */
.dropdown-menu {
    font-size: 0.82rem;
}

.dropdown-item {
    padding: 0.35rem 0.85rem;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0;
}

/* --- Top Bar --- */
.top-bar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.top-bar h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

/* Compact buttons in header top-bar */
.top-bar .btn-sm {
    padding: 0.25rem 0.65rem;
    font-size: 0.72rem;
}

.btn-settings {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    border: none;
    background: none;
}

.btn-settings:hover {
    color: var(--primary);
    background-color: var(--bg-body);
}

.project-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.project-badge .badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3em 0.7em;
}

/* --- Page Content --- */
.page-content {
    padding: 2rem;
}

/* --- Cards --- */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* --- Stat Cards --- */
.stat-card {
    padding: 1.25rem;
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0.5rem 0 0.15rem;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-target {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.2rem;
}

/* --- Tables --- */
.table {
    margin-bottom: 0;
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom-width: 1px;
    padding: 0.75rem 1rem;
}

.table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

/* --- Budget Specific --- */
.budget-summary-bar {
    display: flex;
    gap: 2rem;
    padding: 1.25rem;
}

.budget-summary-item .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.budget-summary-item .value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* --- Budget Layout --- */
.budget-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.budget-main {
    flex: 1;
    min-width: 0;
}

.budget-sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

@media (max-width: 1199.98px) {
    .budget-layout {
        flex-direction: column;
    }
    .budget-sidebar {
        width: 100%;
        position: static;
        max-height: none;
    }
}

/* Option column header labels */
.option-header {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    text-align: center;
}

.option-label-display {
    font-size: 0.6rem;
    font-weight: 500;
    display: inline;
    opacity: 0.7;
    margin-left: 0.3rem;
}

.option-label-placeholder {
    font-size: 0.6rem;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.option-header:hover .option-label-placeholder {
    opacity: 0.8;
}

.option-label-edit-icon {
    font-size: 0.5rem;
    margin-left: 0.15rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.option-header:hover .option-label-edit-icon {
    opacity: 0.7;
}

.option-label-text {
    font-size: 0.6rem;
}

.option-label-input {
    font-size: 0.6rem;
    width: 70px;
    padding: 0.1rem 0.3rem;
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 3px;
    text-align: center;
    background: rgba(255,255,255,0.7);
    margin-left: 0.2rem;
}

.option-header-a {
    background-color: #dbeafe;
    color: #1e40af;
}

.option-header-b {
    background-color: #dcfce7;
    color: #166534;
}

.option-header-c {
    background-color: #fef3c7;
    color: #92400e;
}

/* Subtle column tinting + center alignment */
.option-a-col, .option-b-col, .option-c-col { text-align: center; }
.option-a-col { color: #1e40af; }
.option-b-col { color: #166534; }
.option-c-col { color: #92400e; }

/* Fixed-width right-aligned value wrapper — centered in the cell */
.budget-val {
    display: inline-block;
    width: 100px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Selected option column background */
.option-selected-a .option-a-col { background-color: rgba(219, 234, 254, 0.25); }
.option-selected-b .option-b-col { background-color: rgba(220, 252, 231, 0.25); }
.option-selected-c .option-c-col { background-color: rgba(254, 243, 199, 0.25); }

/* Select/Selected row at bottom */
.budget-select-row td {
    border: none;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* Option select/selected buttons */
.budget-opt-btn {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    border: 1px solid;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.02em;
}

.budget-opt-btn-a { border-color: #93c5fd; color: #1e40af; background: transparent; }
.budget-opt-btn-a:hover { background: #dbeafe; }
.budget-opt-btn-a.budget-opt-btn-selected { background: #dbeafe; border-color: #3b82f6; cursor: default; }

.budget-opt-btn-b { border-color: #86efac; color: #166534; background: transparent; }
.budget-opt-btn-b:hover { background: #dcfce7; }
.budget-opt-btn-b.budget-opt-btn-selected { background: #dcfce7; border-color: #22c55e; cursor: default; }

.budget-opt-btn-c { border-color: #fcd34d; color: #92400e; background: transparent; }
.budget-opt-btn-c:hover { background: #fef3c7; }
.budget-opt-btn-c.budget-opt-btn-selected { background: #fef3c7; border-color: #f59e0b; cursor: default; }

/* Trade header rows */
.trade-header {
    background-color: #f1f5f9;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

.trade-header:hover {
    background-color: #e2e8f0;
}

.trade-header.trade-active {
    background-color: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.trade-header td {
    padding: 0.75rem 1rem;
    border-top: 2px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.trade-chevron {
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.trade-sub-badge {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    margin-left: 0.5rem;
}

/* Budget inline inputs */
.budget-input {
    width: 100px;
    text-align: right;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    margin: 0 auto;
    display: block;
}

.budget-input:hover {
    border-color: var(--border-color);
    background-color: #fff;
}

.budget-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.budget-input-saved {
    background-color: var(--success-light) !important;
    border-color: var(--success) !important;
}

.budget-input-error {
    background-color: var(--danger-light) !important;
    border-color: var(--danger) !important;
}

/* Item row styling */
.budget-item-row td {
    border-bottom: 1px solid #f1f5f9;
}

/* Item drag grip */
.budget-item-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 28px;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: grab;
    opacity: 0.3;
    transition: opacity 0.15s;
    border-radius: 3px;
    flex-shrink: 0;
}

.budget-item-grip:hover {
    opacity: 1;
    color: var(--text-secondary);
    background-color: var(--bg-body);
}

.budget-item-grip:active {
    cursor: grabbing;
}

.budget-item-row:hover .budget-item-grip {
    opacity: 0.7;
}

/* SortableJS drag states */
.sortable-ghost {
    opacity: 0.4;
    background-color: var(--primary-light) !important;
}

.sortable-chosen {
    background-color: #fff;
}

.sortable-drag {
    background-color: #fff;
    box-shadow: var(--shadow);
}

.budget-item-row {
    position: relative;
}

.budget-delete-btn {
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.budget-item-row:hover .budget-delete-btn {
    opacity: 1;
}

.budget-delete-btn:hover {
    color: var(--danger);
}

/* SortableJS ghost — library item placeholder in budget tbody */
.trade-items-body > .sortable-ghost.library-item {
    height: 40px;
}

.trade-items-body > .sortable-ghost.library-item td {
    padding: 0;
    border: none;
    position: relative;
}

.trade-items-body > .sortable-ghost.library-item td::after {
    content: '';
    position: absolute;
    left: 2rem;
    right: 2rem;
    top: 50%;
    height: 3px;
    background-color: var(--primary);
    border-radius: 2px;
}

/* Hide the library item inner content when it's the ghost placeholder */
.trade-items-body > .sortable-ghost.library-item .library-item-inner {
    display: none;
}

/* Trade spacer */
.budget-trade-spacer td {
    height: 30px;
    border: none;
    background: transparent;
}

/* Subtotal / total rows */
.subtotal-row td {
    background-color: #f8fafc;
    border-top: 2px solid var(--border-color);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.grand-total-row td {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 1rem;
    border-top: 2px solid var(--primary);
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

/* SortableJS ghost — faded card in library sidebar */
.library-table .sortable-ghost.library-item .library-item-inner {
    opacity: 0.3;
    border-color: var(--primary);
}

/* Library table — invisible wrapper, cards are on the inner div */
.library-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.3rem;
}

.library-table td {
    padding: 0;
    border: none;
}

/* Library sidebar items — tr is the sortable element, inner div is the card */
.library-item {
    cursor: grab;
}

.library-item-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    transition: box-shadow 0.15s, border-color 0.15s;
}

.library-item:hover .library-item-inner {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.library-grip {
    color: #94a3b8;
    font-size: 1rem;
}

.library-item:hover .library-grip {
    color: var(--text-secondary);
}

/* --- Schedule Specific --- */
/* --- Schedule: Toolbar --- */
.schedule-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
}

.schedule-controls {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding-right: 0.25rem;
}

.schedule-control-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.schedule-control-item label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    cursor: pointer;
    line-height: 1;
}

.schedule-control-item .form-check {
    margin: 0;
    padding: 0;
    min-height: auto;
    display: flex;
    align-items: center;
}

.schedule-control-item .form-check-input {
    margin: 0;
}

.schedule-grid-toggle .btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    line-height: 1.2;
}

.schedule-grid-toggle .btn:first-child {
    border-radius: 999px 0 0 999px !important;
}

.schedule-grid-toggle .btn:last-child {
    border-radius: 0 999px 999px 0 !important;
}

/* Zoom slider styled like a pill */
.schedule-zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 180px;
    height: 16px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    outline: none;
    padding: 0 3px;
    cursor: pointer;
}

.schedule-zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    cursor: grab;
    border: none;
}

.schedule-zoom-slider::-moz-range-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    cursor: grab;
    border: none;
}

.schedule-zoom-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    line-height: 1;
    min-width: 36px;
    text-align: left;
}

/* Hover line following mouse */
.tl-hover-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    border-left: 1px dashed #94a3b8;
    pointer-events: none;
    z-index: 4;
}

.tl-hover-bubble {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.tl-hover-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-top-color: #1e293b;
}

.schedule-view-tabs {
    display: flex;
    gap: 0;
}

.schedule-view-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}

.schedule-view-tab:hover {
    color: var(--text-primary);
}

.schedule-view-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.schedule-view-tab i {
    font-size: 1rem;
}

/* --- Schedule: Shared --- */
.schedule-trade-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.schedule-trade-header {
    cursor: pointer;
    background: #f8fafc;
}

.schedule-trade-header:hover {
    background: #f1f5f9;
}

.schedule-task-row .schedule-name-input {
    border: 1px solid transparent !important;
    background: transparent !important;
    font-size: 0.85rem;
}

.schedule-task-row .schedule-name-input:hover {
    border-color: var(--border-color) !important;
    background: #fff !important;
}

.schedule-task-row .schedule-name-input:focus {
    border-color: var(--primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
}

.schedule-task-row .schedule-date-input {
    font-size: 0.8rem;
    border: 1px solid transparent;
    background: transparent;
    padding: 0.2rem 0.3rem;
}

.schedule-task-row .schedule-date-input:hover {
    border-color: var(--border-color);
    background: #fff;
}

.schedule-task-row .schedule-date-input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
    outline: none;
}

.schedule-delete-btn {
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.schedule-task-row:hover .schedule-delete-btn {
    opacity: 1;
}

.schedule-delete-btn:hover {
    color: var(--danger);
}

.schedule-add-task {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.schedule-add-task:hover {
    color: var(--primary);
}

/* --- Schedule: Board View --- */
.schedule-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.schedule-board-col {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 300px;
}

.schedule-board-col-header {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
    color: var(--text-secondary);
}

.schedule-board-card {
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    overflow: hidden;
    cursor: grab;
    transition: box-shadow 0.15s;
}

.schedule-board-card:hover {
    box-shadow: var(--shadow-sm);
}

.schedule-board-card-bar {
    height: 3px;
}

.schedule-board-card-body {
    padding: 0.5rem 0.6rem;
}

.schedule-board-card-title {
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.schedule-board-card-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

/* --- Schedule: Timeline View --- */
.tl-container {
    display: flex;
    overflow: hidden;
    border-radius: var(--radius);
}

.tl-left {
    width: 220px;
    min-width: 220px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-card);
    flex-shrink: 0;
}

.tl-left-header {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0 0.75rem;
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.tl-left-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tl-left-trade {
    background: #f8fafc;
    font-size: 0.75rem;
}

.tl-left-task {
    padding-left: 1.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.tl-right {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
}

.tl-header-wrap {
    position: relative;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}

.tl-header-months {
    position: relative;
    border-bottom: 1px solid #e2e8f0;
    background: #f1f5f9;
}

.tl-header-days {
    position: relative;
}

.tl-month {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    padding-left: 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    border-left: 1px solid var(--border-color);
    letter-spacing: 0.02em;
}

.tl-month:first-child {
    padding-left: 12px;
}

.tl-day {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #94a3b8;
    font-weight: 500;
}

.tl-day-weekend {
    background: rgba(0,0,0,0.02);
    color: #cbd5e1;
}

.tl-header-days-hidden .tl-day {
    color: transparent;
}

.tl-header-days-hidden .tl-week-label {
    visibility: hidden;
}

.tl-week-label {
    position: absolute;
    top: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: #94a3b8;
    font-weight: 500;
    border-left: 1px solid #e2e8f0;
}

.tl-trade-add {
    font-size: 0.9rem;
    color: #cbd5e1;
    cursor: pointer;
    padding: 0 0.25rem;
    transition: color 0.15s;
}

.tl-trade-add:hover {
    color: var(--primary);
}

.tl-body {
    position: relative;
    background: var(--bg-card);
}

.tl-grid-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: #f1f5f9;
}

.tl-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(239, 68, 68, 0.5);
    z-index: 5;
}

.tl-today-bubble {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 1;
    z-index: 6;
}

.tl-today-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-top-color: var(--danger);
}


.tl-bar-row {
    position: relative;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.1s;
}

.tl-bar-row.tl-row-hover,
.tl-left-task.tl-row-hover {
    background-color: #f8fafc;
}

.tl-bar {
    position: absolute;
    top: 5px;
    height: 18px;
    border-radius: 3px;
    opacity: 0.85;
    cursor: grab;
    z-index: 2;
    transition: opacity 0.1s;
}

.tl-bar:hover {
    opacity: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.tl-bar-dragging {
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 10;
    cursor: grabbing;
}

.tl-bar-handle {
    position: absolute;
    top: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
}

.tl-bar-handle-l { left: 0; border-radius: 3px 0 0 3px; }
.tl-bar-handle-r { right: 0; border-radius: 0 3px 3px 0; }

.tl-bar-handle:hover {
    background: rgba(255,255,255,0.3);
}

.tl-grip {
    font-size: 0.7rem;
    color: #94a3b8;
    cursor: grab;
    margin-right: 0.15rem;
    opacity: 0;
    transition: opacity 0.15s;
}

.tl-left-task:hover .tl-grip {
    opacity: 1;
    color: var(--text-secondary);
}

.tl-sort-ghost {
    opacity: 0.4;
    background: var(--primary-light);
}

.tl-sort-group {
    /* Wrapper for sortable tasks within a trade */
}

.tl-trade-group {
    /* Wrapper for trade header + tasks, sortable at trade level */
}

.tl-trade-grip {
    font-size: 0.75rem;
    color: #cbd5e1;
    cursor: grab;
    margin-right: 0.1rem;
    transition: color 0.15s;
}

.tl-trade-grip:hover {
    color: var(--text-secondary);
}

/* Date labels on bars */
.tl-date-label {
    position: absolute;
    top: 8px;
    font-size: 0.55rem;
    color: #94a3b8;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
}

.tl-date-start {
    transform: translateX(-100%);
    padding-right: 3px;
}

.tl-date-end {
    padding-left: 3px;
}

/* Right-click context menu */
.schedule-context-menu {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    padding: 0.3rem 0;
    z-index: 1000;
    min-width: 160px;
}

.schedule-context-menu a {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    text-decoration: none;
}

.schedule-context-menu a:hover {
    background: var(--bg-body);
}

.schedule-context-menu hr {
    margin: 0.25rem 0;
    border-color: var(--border-color);
}

.schedule-ctx-section {
    padding: 0.35rem 0.75rem;
}

.schedule-ctx-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.3rem;
}

.schedule-ctx-duration {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.schedule-ctx-duration a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.4rem !important;
    font-size: 0.7rem !important;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary) !important;
    min-width: 2rem;
    text-align: center;
}

.schedule-ctx-duration a:hover {
    background: var(--primary-light) !important;
    border-color: var(--primary);
    color: var(--primary) !important;
}

.schedule-ctx-duration a.active {
    background: var(--primary) !important;
    border-color: var(--primary);
    color: #fff !important;
}

/* Template popover */
.schedule-template-popover {
    position: fixed;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 1000;
    width: 240px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
}

.schedule-template-header {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.schedule-template-list {
    overflow-y: auto;
    max-height: 220px;
}

.schedule-template-item {
    display: block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid #f1f5f9;
}

.schedule-template-item:hover {
    background: var(--bg-body);
}

.schedule-template-custom {
    padding: 0.5rem 0.6rem;
    border-top: 1px solid var(--border-color);
}

/* Trade summary bar */
.tl-trade-bar {
    position: absolute;
    top: 11px;
    height: 6px;
    border-radius: 3px;
    opacity: 0.35;
    cursor: grab;
    z-index: 1;
    transition: opacity 0.15s;
}

.tl-trade-bar:hover {
    opacity: 0.55;
}

.tl-trade-bar-dragging {
    opacity: 0.6;
    cursor: grabbing;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* Duration text inside bars */
.tl-bar-duration {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
}

.tl-milestone {
    position: absolute;
    top: 7px;
    width: 14px;
    height: 14px;
    background: #1e293b;
    transform: rotate(45deg);
    border-radius: 2px;
    z-index: 2;
    cursor: grab;
}

.tl-milestone:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.tl-milestone-dragging {
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: grabbing;
}

/* --- Subs Module --- */
.sub-card {
    transition: box-shadow 0.15s ease;
}

.sub-card:hover {
    box-shadow: var(--shadow);
}

.sub-name {
    font-weight: 600;
    font-size: 1rem;
}

.partner-logo {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.partner-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.partner-logo.partner-logo-empty {
    background: #f1f5f9;
    border-color: transparent;
    padding: 0;
    color: #94a3b8;
    font-size: 1.1rem;
}

.min-width-0 { min-width: 0; }

.sub-details {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sub-detail {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sub-detail i {
    width: 1rem;
    margin-right: 0.4rem;
    font-size: 0.75rem;
}

.sub-notes {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.6rem;
    background-color: var(--bg-body);
    border-radius: 4px;
    line-height: 1.4;
}

.sub-filter .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
}

/* Payment terms on sub cards */
.payment-terms {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.6rem;
    background-color: var(--bg-body);
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.payment-terms i {
    color: var(--success);
    margin-right: 0.15rem;
}

.payment-milestone {
    white-space: nowrap;
}

.payment-milestone strong {
    color: var(--text-primary);
}

.payment-divider {
    color: var(--text-secondary);
    font-size: 0.65rem;
    margin: 0 0.15rem;
}

/* Invite code display */
/* Plain icon-only button — no border, no background, just the icon */
.btn-icon-sm {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.2rem 0.3rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}
.btn-icon-sm:hover,
.btn-icon-sm:focus {
    color: var(--text-primary);
    background: var(--bg-secondary);
    outline: none;
}

.invite-code-display {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

/* Phase filter buttons */
.phase-filter .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
}

/* View mode toggle */
.view-mode .btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.7rem;
}

/* --- Documents Specific --- */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--bg-card);
}

.upload-zone:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.upload-zone i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.upload-zone p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.9rem;
}

.upload-zone.upload-zone-hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

.doc-card {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.doc-card:last-child {
    border-bottom: none;
}

/* Actual content preview (images show photo, PDFs show page 1 canvas) */
.doc-thumb-preview {
    flex-shrink: 0;
    width: 128px;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
}

.doc-thumb-preview:hover { opacity: 0.85; }

.doc-thumb-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-thumb-preview.doc-thumb-rendered img {
    object-fit: contain;
    background: #fff;
}

/* Colored file-type icon box (always shown) */
.doc-type-box {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    cursor: pointer;
    flex-shrink: 0;
}

.doc-type-box:hover { opacity: 0.85; }

.doc-type-box.doc-thumb-image   { color: #1d4ed8; background: #dbeafe; }
.doc-type-box.doc-thumb-pdf     { color: #b91c1c; background: #fee2e2; }
.doc-type-box.doc-thumb-word    { color: #1d4ed8; background: #dbeafe; }
.doc-type-box.doc-thumb-excel   { color: #065f46; background: #d1fae5; }
.doc-type-box.doc-thumb-ppt     { color: #92400e; background: #fef3c7; }
.doc-type-box.doc-thumb-generic { color: #475569; background: #f1f5f9; }

.doc-card .doc-info {
    flex: 1;
    min-width: 0;
}

.doc-name-clickable {
    cursor: pointer;
    transition: color 0.15s;
}

.doc-name-clickable:hover { color: var(--primary); }

.doc-card .doc-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inline edit fields */
.doc-fields {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
    margin-top: 2px;
    overflow: hidden;
}

.doc-field-sep {
    font-size: 0.72rem;
    color: #cbd5e1;
    padding: 0 3px;
    flex-shrink: 0;
}

.doc-field-select {
    border: none;
    background: transparent;
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 1px 2px;
    cursor: pointer;
    border-radius: 3px;
    max-width: 90px;
}

.doc-field-select:hover,
.doc-field-select:focus {
    background: #f1f5f9;
    outline: none;
}

.doc-status-select[data-value="active"]   { color: #2563eb; }
.doc-status-select[data-value="signed"]   { color: #059669; }
.doc-status-select[data-value="pending"]  { color: #d97706; }
.doc-status-select[data-value="template"] { color: #d97706; }
.doc-status-select[data-value="complete"] { color: #059669; }

.doc-field-input {
    border: none;
    background: transparent;
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 1px 2px;
    border-radius: 3px;
    min-width: 0;
    flex: 1;
}

.doc-field-input::placeholder { color: #cbd5e1; font-style: italic; }

.doc-field-input:hover,
.doc-field-input:focus {
    background: #f1f5f9;
    outline: none;
}

/* Preview modal */
.doc-preview-desc {
    width: 100%;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    background: transparent;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 2px 0;
    outline: none;
}

.doc-preview-desc::placeholder { color: #cbd5e1; font-style: italic; }

.doc-preview-desc:focus {
    border-bottom-color: var(--primary);
    color: var(--text-primary);
}

.doc-preview-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    padding: 1.5rem;
    min-height: 400px;
}

.doc-preview-img-wrap img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.doc-preview-frame {
    width: 100%;
    height: 80vh;
    border: none;
    display: block;
}

.doc-preview-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 4rem 1rem;
    min-height: 400px;
}

.doc-preview-fallback i {
    font-size: 3rem;
    color: #94a3b8;
}

.doc-empty {
    padding: 3rem 1rem;
    text-align: center;
}

/* --- Activity List --- */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 0.4rem;
    flex-shrink: 0;
}

.activity-text {
    font-size: 0.875rem;
    flex: 1;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Filter Tabs/Buttons --- */
.filter-group .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
}

/* --- Scope Module --- */
.scope-trade-card {
    transition: box-shadow 0.15s ease;
}

.scope-trade-card:hover {
    box-shadow: var(--shadow);
}

.scope-items-editor .table th {
    font-size: 0.7rem;
    padding: 0.4rem 0.5rem;
}

.scope-items-editor .table td {
    padding: 0.35rem 0.5rem;
    vertical-align: middle;
}

.scope-items-editor .form-control-sm {
    font-size: 0.8rem;
}

/* Scope meta tags */
.scope-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.scope-meta-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.scope-opt-a { background-color: #dbeafe; color: #1e40af; }
.scope-opt-b { background-color: #dcfce7; color: #166534; }
.scope-opt-c { background-color: #fef3c7; color: #92400e; }

.scope-meta-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.7);
    font-weight: 700;
    font-size: 0.7rem;
}

.scope-sub-tag {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--bg-card);
}

/* Scope item text input — borderless until hover/focus */
.scope-desc {
    border: 1px solid transparent !important;
    background: transparent !important;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.scope-desc:hover {
    border-color: var(--border-color) !important;
    background-color: #fff !important;
}

.scope-desc:focus {
    border-color: var(--primary) !important;
    background-color: #fff !important;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1) !important;
}

.scope-add-item {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.scope-add-item:hover {
    color: var(--primary);
}

.scope-item-delete {
    color: #cbd5e1;
    cursor: pointer;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.scope-item-delete:hover {
    color: var(--danger);
}

.rfq-subs-box {
    background-color: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

/* Individual sub card */
.rfq-sub-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-card);
}

.rfq-sub-card:last-of-type {
    margin-bottom: 0;
}

/* Tiny round logo in front of the sub name */
.scope-sub-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.scope-sub-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.scope-sub-logo.scope-sub-logo-empty {
    color: #94a3b8;
    font-size: 0.7rem;
}

/* Progress status bar */
.rfq-progress {
    display: flex;
    gap: 0.35rem;
}

.rfq-step {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--bg-body);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.rfq-step:hover {
    background: #e2e8f0;
    color: var(--text-secondary);
}

.rfq-step-done {
    background: #dcfce7;
    color: #166534;
}

.rfq-step-active {
    background: #dbeafe;
    color: #1e40af;
    box-shadow: 0 0 0 1.5px #3b82f6;
}

.rfq-step-declined {
    background: #fee2e2 !important;
    color: #991b1b !important;
    box-shadow: none !important;
}

.rfq-step-declined.rfq-step-active {
    box-shadow: 0 0 0 1.5px #ef4444 !important;
}

/* --- Target Cost Breakdown --- */
.target-breakdown-box {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.target-row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #e2e8f0;
}

.target-row:last-child {
    border-bottom: none;
}

.target-row-total {
    font-weight: 700;
    border-top: 2px solid var(--border-color);
    border-bottom: none;
    padding-top: 0.6rem;
    margin-top: 0.15rem;
}

.target-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.target-row:first-child .target-value {
    color: var(--primary);
    font-size: 1rem;
}

/* --- Project Cards (Home Page) --- */
.project-card {
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    overflow: hidden;
}

.project-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.project-card-photo {
    background-color: var(--bg-body);
    overflow: hidden;
}

.project-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--border-color);
    font-size: 2.5rem;
}

.project-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.project-card-meta {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.project-card-budget {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.project-card-add {
    border: 2px dashed var(--border-color);
    background-color: transparent;
}

.project-card-add:hover {
    border-color: var(--primary);
    background-color: var(--primary-light);
}

/* --- Mobile Menu Toggle --- */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    background: var(--sidebar-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
}

/* --- Responsive --- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .top-bar {
        padding-left: 4rem;
    }
}

@media (max-width: 575.98px) {
    .page-content {
        padding: 1rem;
    }

    .budget-summary-bar {
        flex-direction: column;
        gap: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.35rem;
    }
}

/* ============================================
   Auth Pages — Login & Register
   ============================================ */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 2.5rem 2rem;
}

.auth-card.auth-card-wide {
    max-width: 560px;
}

/* Role selection cards */
.role-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.role-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: var(--bg-body);
    user-select: none;
}

.role-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.role-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.role-card i {
    font-size: 1.75rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.4rem;
    transition: color 0.15s;
}

.role-card.selected i,
.role-card:hover i {
    color: var(--primary);
}

.role-card-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.role-card-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand h2 {
    font-weight: 700;
    color: var(--sidebar-bg);
    margin-bottom: 0.15rem;
}

.auth-brand small {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Password toggle inside field */
.pw-field {
    position: relative;
}

.pw-field .form-control {
    padding-right: 2.5rem;
}

.pw-toggle {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.pw-toggle:hover {
    color: var(--text-primary);
}

/* Site Admin link at bottom of sidebar */
.sidebar-admin-link {
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--sidebar-hover);
}

.sidebar-admin-link a {
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}

.sidebar-admin-link a:hover,
.sidebar-admin-link a.active {
    color: var(--text-sidebar-active);
    background: var(--sidebar-hover);
}

/* Sidebar user footer */
.sidebar-user {
    padding: 0.6rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-user-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    color: var(--text-sidebar-active);
    text-decoration: none;
    transition: background-color 0.15s;
    min-width: 0;
}

.sidebar-user-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-sidebar-active);
}

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-user-avatar.has-photo { background: #fff; }

.sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Sidebar brand — light cell so transparent PNG logos read on the dark sidebar */
.sidebar-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 6px;
    padding: 6px 10px;
    height: 44px;
    margin-bottom: 0.25rem;
}

.sidebar-brand-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-signout-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 1rem;
    transition: background-color 0.15s, color 0.15s;
    flex-shrink: 0;
}

.sidebar-signout-btn:hover {
    background: var(--sidebar-hover);
    color: var(--text-sidebar-active);
}

/* User Profile Modal */
.profile-section-title {
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

/* Image upload widgets (headshot + logo) inside user profile modal */
.up-photo-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.up-photo-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}
.up-photo-round,
.up-photo-square {
    width: 84px;
    height: 84px;
    flex-shrink: 0;
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
    position: relative;
}
.up-photo-round { border-radius: 50%; }
.up-photo-square { border-radius: 10px; }
.up-photo-round:hover,
.up-photo-square:hover { border-color: var(--primary); }
.up-photo-round:hover .up-photo-overlay,
.up-photo-square:hover .up-photo-overlay { opacity: 1; }
.up-photo-round img { width: 100%; height: 100%; object-fit: cover; }
.up-photo-square img { width: 100%; height: 100%; object-fit: contain; }
.up-photo-icon { font-size: 1.75rem; color: #94a3b8; }
.up-photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.up-photo-remove {
    background: none;
    border: 0;
    padding: 0;
    margin-top: 0.25rem;
    font-size: 0.7rem;
    color: var(--danger, #dc3545);
    text-decoration: underline;
    cursor: pointer;
}

/* Project cover-photo widget inside project settings modal (16:9) */
.proj-photo-box {
    width: 160px;
    aspect-ratio: 16 / 9;
    flex-shrink: 0;
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
    position: relative;
}
.proj-photo-box:hover { border-color: var(--primary); }
.proj-photo-box:hover .proj-photo-overlay { opacity: 1; }
.proj-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.proj-photo-icon { font-size: 2rem; color: #94a3b8; }
.proj-photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0;
    transition: opacity 0.15s;
}

.pay-method-group {
    background: #f8fafc;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
}

.pay-method-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.pay-method-header i {
    color: var(--primary);
    margin-right: 0.35rem;
}

/* Invite codes — shared base */
.invite-code {
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 5px;
    border: 1.5px dashed;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

/* Available — creamy gold */
.invite-code.available {
    background: #fdf8ed;
    border-color: #d4a855;
    color: #7a5c1e;
}

.invite-code.available:hover {
    background: #f5ecda;
    border-color: #b8922e;
    color: #5a420f;
}

/* Used — soft grey */
.invite-code.used {
    background: #f4f4f5;
    border-color: #c8c8cc;
    color: #888;
}

.invite-code.used:hover {
    background: #eaeaec;
    border-color: #aaa;
    color: #666;
}

/* Copied flash */
.invite-code.copied {
    background: #e8f5e9;
    border-color: var(--success);
    color: var(--success);
}

/* Impersonation bar */
.impersonate-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: #1e293b;
    color: #fff;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 9999;
    font-size: 0.85rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.2);
}

.impersonate-bar i {
    margin-right: 0.35rem;
}

.impersonate-bar button {
    background: #dc2626;
    color: #fff;
    border: none;
    padding: 0.35rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.impersonate-bar button:hover {
    background: #b91c1c;
}

.has-impersonate-bar .page-content {
    padding-bottom: 4rem;
}

@media (max-width: 768px) {
    .impersonate-bar {
        left: 0;
    }
}

/* ── Timeline trade-name popover ──────────────────────────────────── */
.tl-trade-name {
    cursor: default;
}

.tl-sub-popover {
    position: fixed;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    padding: 0.5rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    pointer-events: none;
    white-space: nowrap;
}

.tl-sub-popover-logo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.tl-sub-popover-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tl-sub-popover-logo i {
    font-size: 1rem;
    color: #64748b;
}

.tl-sub-popover-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* ── Subs page filter pills ───────────────────────────────────────── */
.sub-filter-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.7rem;
    font-size: 0.76rem;
    font-weight: 500;
    border: none;
    border-radius: 20px;
    background: #e2e8f0;
    color: #475569;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    line-height: 1.5;
}

.sub-filter-btn:hover {
    background: #cbd5e1;
    color: #1e293b;
}

.sub-filter-btn.active {
    background: #64748b;
    color: #fff;
}

/* ============================================
   Floating Timer Widget
   ============================================ */
.timer-widget {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1080;
    width: 260px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    padding: 0.625rem 0.75rem;
    font-family: inherit;
}

.timer-widget[hidden] { display: none; }

.timer-widget-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.timer-widget-main-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.timer-widget-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
}

.timer-widget-dot.pulsing {
    background: #ef4444;
    animation: timer-pulse 1.4s ease-in-out infinite;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(1.4); }
}

.timer-widget-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
}

.timer-widget-project-label {
    font-size: 0.72rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timer-widget-btn {
    border: none;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.timer-widget-start { background: #10b981; }
.timer-widget-start:hover { background: #059669; }
.timer-widget-stop  { background: #ef4444; }
.timer-widget-stop:hover  { background: #dc2626; }

.timer-widget-context {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.timer-widget-context-title {
    font-size: 0.85rem;
    color: #1e293b;
    line-height: 1.3;
}

.timer-widget-context-elapsed {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.85rem;
    color: #64748b;
}

.timer-widget-context-buttons {
    display: flex;
    gap: 0.4rem;
}

.timer-widget-form {
    margin-top: 0.625rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.timer-widget-form-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
}

/* 3-hour nudge toast — positioned above the widget with a visible gap */
.timer-toast {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + 120px);
    z-index: 1085;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    padding: 0.625rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 320px;
    animation: timer-toast-in 0.25s ease-out;
}

@keyframes timer-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.timer-toast-text {
    flex: 1;
    font-size: 0.85rem;
    color: #1e293b;
}

.timer-toast-close {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}

.timer-toast-close:hover { color: #1e293b; }

/* Mobile: shrink the widget */
@media (max-width: 640px) {
    .timer-widget { width: 220px; bottom: 0.75rem; right: 0.75rem; }
}

/* ============================================
   Time Log — Entry Rows
   ============================================ */
.tl-entry-list {
    display: flex;
    flex-direction: column;
}

.tl-entry-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.tl-entry-row:first-child {
    border-top: none;
}

.tl-entry-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.tl-entry-body {
    flex: 1;
    min-width: 0;
}

.tl-entry-desc {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tl-entry-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: #64748b;
}

.tl-meta-dot {
    color: #cbd5e1;
    line-height: 1;
}

.tl-meta-pill {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.05rem 0.4rem;
    font-size: 0.72rem;
    color: #475569;
}

.tl-entry-duration {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
    white-space: nowrap;
    min-width: 60px;
}

.tl-entry-actions {
    display: flex;
    gap: 0.1rem;
}

.tl-action-edit {
    color: #94a3b8;
    padding: 0.2rem 0.35rem;
    font-size: 0.85rem;
    text-decoration: none;
}
.tl-action-edit:hover { color: #3b82f6; }

.tl-action-delete {
    color: #94a3b8;
    padding: 0.2rem 0.35rem;
    font-size: 0.85rem;
    text-decoration: none;
}
.tl-action-delete:hover { color: #ef4444; }

@media (max-width: 640px) {
    .tl-entry-row { gap: 0.6rem; padding: 0.75rem 1rem; }
    .tl-entry-duration { min-width: 50px; font-size: 0.9rem; }
}

/* ============================================
   Time Log — Weekly Heatmap
   ============================================ */
.tl-heatmap {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-x: auto;
}

.tl-heatmap-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tl-heatmap-day-col {
    width: 52px;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    text-align: right;
    padding-right: 6px;
    white-space: nowrap;
}

.tl-heatmap-date {
    color: #94a3b8;
    font-weight: 400;
}

.tl-heatmap-hour-label {
    flex: 1;
    min-width: 0;
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: center;
    white-space: nowrap;
    line-height: 1;
    padding-bottom: 3px;
}

.tl-heatmap-cell {
    flex: 1;
    min-width: 0;
    height: 20px;
    border-radius: 3px;
    background: #f1f5f9;
    cursor: default;
    transition: opacity 0.1s;
}

.tl-heatmap-cell:hover {
    opacity: 0.8;
    outline: 2px solid #94a3b8;
    outline-offset: 1px;
}

/* Totals by type — chips */
.tl-type-chip {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
}

.tl-type-chip-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.tl-type-chip-label {
    font-size: 0.82rem;
    color: #475569;
}

.tl-type-chip-val {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
}
