/* ============================================
   RFPDOC.com - Government Contractor Platform
   Clean & Government-Formal Design System
   ============================================ */

:root {
    /* Government Blue Palette */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;

    /* Neutral Grays */
    --gray-25: #fcfcfd;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Functional Colors */
    --green-50: #f0fdf4;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --yellow-50: #fefce8;
    --yellow-500: #eab308;
    --yellow-600: #ca8a04;
    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;

    /* Surfaces */
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #1d4ed8;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 68px;
    --header-height: 56px;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
}

/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--gray-800);
    background: var(--bg-body);
    line-height: 1.5;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { color: var(--blue-700); }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

/* ============ APP LAYOUT ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--gray-300);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width var(--duration-normal) var(--ease-out);
    overflow: visible;
    border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    height: var(--header-height);
    overflow: hidden;
    position: relative;
    background: var(--bg-sidebar);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: white;
}

.logo-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.03em;
    color: #fff;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast);
}
.sidebar-toggle:hover { color: white; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-4) var(--space-3);
}

.nav-section {
    margin-bottom: var(--space-5);
}

.nav-section-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
    padding: 0.5rem 0.875rem 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.45rem 0.875rem;
    border-radius: 7px;
    font-size: 0.8375rem;
    font-weight: 500;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.15s;
    margin-bottom: 1px;
}
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.nav-item.active {
    background: #2563eb;
    color: #fff;
}
.nav-item.active svg { color: #fff; }

.nav-badge {
    margin-left: auto;
    background: var(--blue-500);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563eb;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: var(--text-xs);
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    color: var(--gray-500);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast);
}
.logout-btn:hover { color: var(--red-500); }

/* ============ SIDEBAR COLLAPSED STATE ============ */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

/* Hide text labels when collapsed */
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn {
    display: none;
}

/* Center the logo icon when collapsed */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: var(--space-4) 0;
}

/* Flip the toggle arrow when collapsed */
.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Keep toggle always visible — move to center when collapsed */
.sidebar.collapsed .sidebar-toggle {
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-sidebar);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0 var(--radius) var(--radius) 0;
    width: 20px;
    padding: 6px 2px;
    z-index: 10;
    opacity: 0;
    transition: opacity var(--duration-fast);
}
.sidebar:hover .sidebar-toggle,
.sidebar.collapsed .sidebar-toggle {
    opacity: 1;
}

/* Center nav icons when collapsed */
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.55rem 0;
}

/* Tooltip on collapsed items */
.sidebar.collapsed .nav-item {
    position: relative;
}
.sidebar.collapsed .nav-item::after {
    content: attr(data-label);
    position: absolute;
    left: calc(var(--sidebar-collapsed) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 200;
}
.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
}

/* Footer layout when collapsed — only avatar, centered */
.sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding: var(--space-3) 0;
}
.sidebar.collapsed .user-info {
    justify-content: center;
}

/* Sidebar-collapsed pushes main content in ─ overrides default margin */
.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

/* ============ MAIN CONTENT ============ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--duration-normal) var(--ease-out);
}

/* ============ TOP BAR ============ */
.top-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--gray-600);
    cursor: pointer;
    padding: var(--space-2);
}

.top-bar-search {
    flex: 1;
    max-width: 340px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: var(--gray-400);
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.top-bar-search:focus-within {
    border-color: var(--blue-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
}
.top-bar-search input {
    background: none;
    border: none;
    outline: none;
    font-size: 0.875rem;
    color: #0f172a;
    width: 100%;
}
.top-bar-search input::placeholder { color: var(--gray-400); }

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast);
}
.icon-btn:hover {
    background: var(--gray-100);
    color: var(--gray-700);
}

/* ============ CONTENT AREA ============ */
.content-area {
    padding: var(--space-6) var(--space-8);
    flex: 1;
    min-width: 0;
    max-width: 1400px;
    width: 100%;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f5f9;
    gap: var(--space-4);
}

.page-header h1 {
    font-size: 1.375rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.025em;
    margin-bottom: 0.15rem;
    font-family: var(--font-display);
}

.page-header p {
    font-size: 0.875rem;
    color: #64748b;
    margin-top: 0;
}

/* ============ CARDS ============ */
.card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fafafa;
}

.card-body {
    padding: 1.25rem 1.5rem;
}

.card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.card-subtitle {
    font-size: 0.8125rem;
    color: #64748b;
    margin-top: 1px;
}

/* ============ STAT CARDS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: box-shadow var(--duration-fast), transform var(--duration-fast);
}
.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.stat-card .stat-icon,
.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.stat-icon.blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon.green  { background: #f0fdf4; color: #22c55e; }
.stat-icon.yellow { background: #fefce8; color: #eab308; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    margin-top: 0;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: var(--text-xs);
    font-weight: 500;
    margin-top: var(--space-2);
    padding: 2px 6px;
    border-radius: 4px;
}
.stat-change.up { color: var(--green-600); background: var(--green-50); }
.stat-change.down { color: var(--red-600); background: var(--red-50); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    box-shadow: 0 1px 3px rgba(37,99,235,0.3);
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.35); }

.btn-secondary {
    background: #fff;
    color: #334155;
    border-color: #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }

.btn-ghost {
    background: transparent;
    color: #475569;
    border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }

.btn-danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 0.625rem 1.375rem;
    font-size: 0.9375rem;
    border-radius: 8px;
}

/* ============ TABLE ============ */
.table-container {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fafafa;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.table-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #0f172a;
}

.table-filters {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}

table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.8125rem;
    color: #334155;
    vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }

table tr:hover td { background: #f8fafc; }

.table-link {
    color: #1e40af;
    font-weight: 500;
    transition: color var(--duration-fast);
}
.table-link:hover { color: #1e3a8a; text-decoration: underline; }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    border-top: 1px solid var(--gray-200);
    font-size: var(--text-sm);
    color: var(--gray-500);
}

/* ============ BADGES & STATUS ============ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-blue   { background: #eff6ff; color: #1d4ed8; }
.badge-green  { background: #f0fdf4; color: #15803d; }
.badge-yellow { background: #fefce8; color: #a16207; }
.badge-red    { background: #fef2f2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: var(--space-2);
}
.status-dot.active { background: var(--green-500); }
.status-dot.closing { background: var(--yellow-500); }
.status-dot.closed { background: var(--gray-400); }

/* ============ FORMS ============ */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.3rem;
}

.form-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.875rem;
    color: #0f172a;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--gray-400);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-4);
}

/* ============ FILTER BAR ============ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.filter-bar .form-select,
.filter-bar .form-input {
    width: auto;
    min-width: 160px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 4px 10px;
    background: var(--blue-50);
    color: var(--blue-600);
    border-radius: 16px;
    font-size: var(--text-xs);
    font-weight: 500;
}
.filter-chip button {
    background: none;
    border: none;
    color: var(--blue-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.filter-chip-settings {
    background: #f8f9fa;
    color: #64748b;
    border: 1px solid #e2e8f0;
    gap: 5px;
}

/* ============ DETAIL PAGE ============ */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-6);
    align-items: start;
}

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

.detail-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--space-6));
}

.detail-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.meta-item {
    padding: var(--space-3);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.meta-label {
    font-size: var(--text-xs);
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 2px;
}

.meta-value {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-900);
}

/* ============ SUMMARY PANEL ============ */
.summary-panel {
    background: linear-gradient(135deg, var(--blue-50) 0%, white 100%);
    border: 1px solid var(--blue-200);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}

.summary-panel h3 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--blue-800);
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.summary-section {
    margin-bottom: var(--space-4);
}

.summary-section h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-1);
}

.summary-section p,
.summary-section li {
    font-size: var(--text-sm);
    color: var(--gray-600);
    line-height: 1.6;
}

.summary-section ul {
    list-style: none;
    padding: 0;
}

.summary-section ul li::before {
    content: "→ ";
    color: var(--blue-500);
    font-weight: 600;
}

/* ============ PROPOSAL GENERATOR ============ */
.generator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
    align-items: start;
    min-width: 0;
}

.generator-form { min-width: 0; }
.generator-preview { min-width: 0; }

.generator-preview {
    position: sticky;
    top: calc(var(--header-height) + var(--space-6));
    max-height: calc(100vh - var(--header-height) - var(--space-12));
    overflow-y: auto;
}

.preview-content {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    font-size: var(--text-sm);
    line-height: 1.7;
    box-shadow: var(--shadow-md);
}

.preview-content h2 {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--gray-900);
    margin: var(--space-6) 0 var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--blue-600);
}

.preview-content h2:first-child { margin-top: 0; }

.preview-content p {
    margin-bottom: var(--space-3);
    color: var(--gray-700);
}

/* ============ STEPS / PROGRESS ============ */
.steps {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-bottom: var(--space-6);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-400);
    border-radius: var(--radius-sm);
}

.step.active {
    color: var(--blue-600);
    background: var(--blue-50);
}

.step.complete {
    color: var(--green-600);
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    border: 2px solid currentColor;
}

.step.active .step-number { background: var(--blue-600); color: white; border-color: var(--blue-600); }
.step.complete .step-number { background: var(--green-600); color: white; border-color: var(--green-600); }

.step-connector {
    width: 24px;
    height: 2px;
    background: var(--gray-200);
}

/* ============ TABS ============ */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab {
    padding: 0.6rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    text-decoration: none;
}
.tab:hover { color: #0f172a; }
.tab.active {
    color: #1e40af;
    border-bottom-color: #1e40af;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============ EMPTY STATE ============ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #94a3b8;
}

.empty-state svg { margin-bottom: 1rem; opacity: 0.4; color: var(--gray-300); }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: #475569; margin-bottom: 0.4rem; }
.empty-state p { font-size: 0.875rem; margin-bottom: 1.25rem; max-width: 400px; color: var(--gray-500); }

/* ============ LOADING / SKELETON ============ */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 20px; width: 40%; margin-bottom: 16px; }

/* ============ SPINNER ============ */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ TOAST / NOTIFICATION ============ */
.toast-container {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.toast {
    background: var(--bg-surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    min-width: 300px;
    animation: slideIn 0.3s var(--ease-out);
}

.toast.success { border-left: 3px solid var(--green-500); }
.toast.error { border-left: 3px solid var(--red-500); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============ PAGINATION ============ */
.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-2);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--gray-700);
    text-decoration: none;
    transition: all var(--duration-fast);
}

.pagination a:hover { background: var(--gray-50); border-color: var(--gray-300); }
.pagination .active { background: var(--blue-600); color: white; border-color: var(--blue-600); }

/* ============ MODAL ============ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }

/* Alias for .modal-overlay usage */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal {
    background: #fff;
    border-radius: 12px;
    width: 520px;
    max-width: calc(100vw - 2rem);
    box-shadow: 0 24px 64px rgba(0,0,0,0.2);
    overflow: hidden;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.modal-title,
.modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .detail-sidebar {
        position: static;
    }
    .generator-layout {
        grid-template-columns: 1fr;
    }
    .generator-preview {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.open { transform: translateX(0); }

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

    .mobile-menu-btn { display: block; }

    .content-area {
        padding: var(--space-4);
    }

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

    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
    }

    .page-header {
        flex-direction: column;
    }

    .table-header {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .form-select,
    .filter-bar .form-input {
        width: 100%;
    }
}

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

/* ============ UTILITIES ============ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #64748b; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Pre-JS sidebar collapse — prevents flash on page load */
html[data-sidebar-collapsed='1'] #sidebar {
    width: var(--sidebar-collapsed);
}
html[data-sidebar-collapsed='1'] .main-content {
    margin-left: var(--sidebar-collapsed);
}
