/* --- 60-30-10 DESIGN SYSTEM (PURE CSS3) --- */
:root {
    /* 60% Neutral Base */
    --bg-main: #f4f7fa;
    --bg-surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* 30% Secondary */
    --secondary: #0f172a;
    --secondary-light: #334155;
    --secondary-bg: #f8fafc;

    /* 10% Construction Accents */
    --accent: #f59e0b;
    --accent-dark: #b45309;
    --accent-soft: #fef3c7;
    --success: #10b981;
    --danger: #ef4444;

    /* Sizing & Radius */
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* --- LAYOUT --- */
.app-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    min-height: 100vh;
}

/* --- SIDEBAR: INVENTORY --- */
.sidebar {
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.02);
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to bottom right, var(--secondary), var(--secondary-light));
    color: white;
}

.brand {
    display: flex;
    items-center: center;
    gap: 12px;
    margin-bottom: 4px;
}

.brand i {
    font-size: 24px;
    color: var(--accent);
}

.brand h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.inventory-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.category-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    margin: 20px 0 10px 4px;
}

.item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    transition: var(--transition);
}

.item-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.item-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.item-name {
    font-weight: 700;
    font-size: 14px;
}

.item-stock {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.stock-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.stock-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 1s ease;
}

.item-price-tag {
    font-size: 10px;
    background: var(--secondary-bg);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 6px;
    display: inline-block;
    font-weight: 700;
}

/* --- MAIN CONTENT: WORKFLOW --- */
.main-content {
    padding: 40px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.header-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 40px;
}

.stat-box {
    background: var(--bg-surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--secondary);
}

/* --- WORKFLOW TREE --- */
.phase-section {
    margin-bottom: 50px;
    position: relative;
}

.phase-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 24px;
}

.phase-badge {
    background: var(--secondary);
    color: white;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.phase-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--secondary);
}

.stage-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
    transition: var(--transition);
}

.stage-card.completed {
    border-color: var(--success);
    background: #f0fdf4;
}

.stage-summary {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.stage-info {
    display: flex;
    align-items: center;
    gap: 18px;
}

.stage-icon {
    width: 44px;
    height: 44px;
    background: var(--secondary-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--secondary);
}

.stage-text h3 {
    font-size: 16px;
    font-weight: 700;
}

.stage-text p {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- SUB-STEPS (ROBUST SECTION) --- */
.substeps-container {
    border-top: 1px solid var(--border-color);
    padding: 20px 24px;
    background: #fafbfc;
}

.step-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

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

.checkbox-container {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox-container.checked {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-details {
    flex-grow: 1;
}

.step-name {
    font-size: 14px;
    font-weight: 600;
}

.step-meta {
    display: flex;
    gap: 15px;
    margin-top: 4px;
}

.meta-pill {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pill-labor {
    background: #dbeafe;
    color: #1e40af;
}

.pill-mats {
    background: #fef3c7;
    color: #92400e;
}

/* --- PROCUREMENT MODAL --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: white;
    width: 450px;
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 800;
    cursor: pointer;
    border: none;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 12px;
    transition: var(--transition);
}

.btn-primary {
    background: var(--secondary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--secondary-light);
}

/* --- TOAST --- */
#toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--secondary);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    display: none;
    animation: slideUp 0.3s ease;
    z-index: 2000;
    box-shadow: var(--shadow);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        height: auto;
        position: relative;
    }

    .header-stats {
        grid-template-columns: 1fr;
    }
}