/* GEM Tender Management Tool - Styles */
/* Color Palette inspired by Government Portal aesthetics */

:root {
    /* Primary Colors - Deep Navy & Teal */
    --primary-900: #0c1929;
    --primary-800: #122640;
    --primary-700: #1a3657;
    --primary-600: #234a6e;
    --primary-500: #2d5f85;
    --primary-400: #4a7c9c;
    
    /* Accent Colors - Warm Amber/Gold */
    --accent-500: #d4a418;
    --accent-400: #e6b82e;
    --accent-300: #f0c94d;
    --accent-glow: rgba(212, 164, 24, 0.3);
    
    /* Semantic Colors */
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.15);
    
    /* Neutrals */
    --bg-body: #0a0f1a;
    --bg-card: #111827;
    --bg-elevated: #1f2937;
    --bg-hover: #374151;
    --border: #2d3748;
    --border-light: #3d4a5c;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Typography */
    --font-display: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'Cascadia Code', 'Consolas', monospace;
    
    /* Spacing */
    --sidebar-width: 260px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-glow);
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, rgba(45, 95, 133, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 164, 24, 0.05) 0%, transparent 50%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 100px,
            rgba(45, 95, 133, 0.02) 100px,
            rgba(45, 95, 133, 0.02) 101px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 100px,
            rgba(45, 95, 133, 0.02) 100px,
            rgba(45, 95, 133, 0.02) 101px
        );
    pointer-events: none;
    z-index: -1;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-800) 0%, var(--primary-900) 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    color: var(--accent-400);
    text-shadow: 0 0 10px var(--accent-glow);
    animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.tagline {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-top: 4px;
}

/* Navigation */
.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: transparent;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border: none;
    width: 100%;
    text-align: left;
    font: inherit;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: var(--text-primary);
    box-shadow: var(--shadow-md);
}

.nav-item.active .nav-icon {
    color: var(--accent-400);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-btn, .import-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.export-btn:hover, .import-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-light);
}

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

/* Views */
.view {
    display: none;
    animation: fadeIn var(--transition-normal);
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* View Header */
.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.view-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.btn-back:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Quick Search */
.quick-search input {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    width: 250px;
    transition: all var(--transition-fast);
}

.quick-search input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(45, 95, 133, 0.2);
}

.quick-search input::placeholder {
    color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

/* Stage Stats Grid */
.stage-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stage-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.stage-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    opacity: 0.7;
    transition: all 0.3s ease;
}

.stage-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
}

.stage-stat-card:hover::before {
    opacity: 1;
    height: 4px;
}

.stage-stat-card.active {
    border-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, var(--bg-card) 100%);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.stage-stat-card.active::before {
    height: 4px;
    opacity: 1;
}

.stage-stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stage-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stage-stat-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 14px;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.stage-stat-card:hover .stage-stat-icon {
    opacity: 1;
    transform: scale(1.2);
}

@media (max-width: 992px) {
    .stage-stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .stage-stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .stage-stat-card {
        padding: 12px 8px;
    }
    
    .stage-stat-number {
        font-size: 22px;
    }
    
    .stage-stat-label {
        font-size: 8px;
    }
    
    .stage-stat-icon {
        font-size: 11px;
        top: 6px;
        right: 6px;
    }
}

.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Section Block */
.section-block {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-add-tender {
    padding: 4px 10px;
    font-size: 11px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-400);
    font-size: 13px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.btn-link:hover {
    color: var(--accent-400);
}

/* Alerts Section */
.alerts-section {
    margin-bottom: 24px;
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.alert-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.alert-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.alert-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.alert-card-header .alert-icon {
    font-size: 18px;
}

.alert-card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.alert-card-body {
    padding: 16px;
    max-height: 200px;
    overflow-y: auto;
}

.alert-ra {
    border-left: 3px solid var(--danger);
}

.alert-deadline {
    border-left: 3px solid var(--warning);
}

.empty-state-mini {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 20px 0;
}

/* RA Alert Items */
.ra-alert-item {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, transparent 100%);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ra-alert-item:last-child {
    margin-bottom: 0;
}

.ra-alert-item:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
}

.ra-alert-item .ra-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ra-alert-item .ra-time {
    font-size: 12px;
    color: var(--danger);
    font-weight: 500;
}

/* Deadline Items */
.deadline-item {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, transparent 100%);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deadline-item:last-child {
    margin-bottom: 0;
}

.deadline-item:hover {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.4);
}

.deadline-item .deadline-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.deadline-item .deadline-date {
    font-size: 12px;
    color: var(--warning);
    font-weight: 500;
}

.deadline-item.urgent {
    border-color: rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, transparent 100%);
}

.deadline-item.urgent .deadline-date {
    color: var(--danger);
}

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

/* Tables */
.tenders-table-container {
    overflow-x: auto;
}

.tenders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tenders-table th,
.tenders-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.tenders-table th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.tenders-table tr:hover td {
    background: rgba(45, 95, 133, 0.1);
}

.tenders-table td {
    color: var(--text-primary);
}

.tenders-table .other-detail-cell {
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--text-secondary);
}

.tenders-table .other-detail-cell:hover {
    white-space: normal;
    overflow: visible;
    background: var(--bg-elevated);
    position: relative;
    z-index: 10;
}

/* Stage Badges */
.stage-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-initial,
.stage-atc_spec,
.stage-bidding,
.stage-companies,
.stage-technical,
.stage-ra,
.stage-order,
.stage-dispatch,
.stage-payment { 
    background: rgba(59, 130, 246, 0.15); 
    color: #60a5fa; 
}
.stage-completed { 
    background: rgba(16, 185, 129, 0.15); 
    color: #34d399; 
}
.stage-direct-purchase { 
    background: rgba(245, 158, 11, 0.15); 
    color: #f59e0b; 
}

/* Days in Stage Indicators */
.days-in-stage {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}
.days-new {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}
.days-recent {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}
.days-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}
.days-overdue {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}
.days-in-stage-large {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
}
.days-in-stage-large.days-new {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.days-in-stage-large.days-recent {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.days-in-stage-large.days-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.days-in-stage-large.days-overdue {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Direct Purchase indicator styles */
.status-direct-purchase {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    font-weight: 600;
}
.status-regular {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}
.direct-purchase-section {
    border-left: 4px solid #f59e0b;
}
.tender-type-info {
    color: #92400e;
}

/* Warning background for Direct Purchase info */
:root {
    --warning-bg: rgba(245, 158, 11, 0.1);
}

/* Action Buttons in Table */
.action-btns {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-view {
    background: var(--primary-500);
    color: var(--text-primary);
}

.btn-view:hover {
    background: var(--primary-400);
}

.btn-edit {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-edit:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
}

/* Deadlines */
.deadlines-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deadline-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border-left: 3px solid var(--warning);
}

.deadline-item.urgent {
    border-left-color: var(--danger);
    background: linear-gradient(90deg, var(--danger-bg) 0%, var(--bg-elevated) 100%);
}

.deadline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.deadline-title {
    font-weight: 500;
    color: var(--text-primary);
}

.deadline-type {
    font-size: 12px;
    color: var(--text-muted);
}

.deadline-date {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Forms */
.tender-form {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.form-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.section-title .stage-badge {
    background: var(--primary-500);
    color: var(--text-primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(45, 95, 133, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

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

/* Toggle Group */
.toggle-group {
    display: flex;
    gap: 16px;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-400);
}

.toggle-option span {
    font-size: 14px;
    color: var(--text-primary);
}

/* Hidden class */
.hidden {
    display: none !important;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-400) 0%, var(--primary-500) 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    filter: brightness(1.1);
}

/* Completion Badge */
.completion-badge {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 10px;
    text-align: center;
}

.completion-badge span {
    font-size: 18px;
    font-weight: 600;
    color: var(--success);
}

/* Trash Page */
.trash-count {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: 20px;
}

/* Recent Updated Tenders */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-filter-info {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-elevated);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.update-time {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.trash-info {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
}

.trash-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

#trash-table .btn-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

#trash-table .btn-success:hover {
    background: var(--success);
    color: white;
}

#trash-table .btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

#trash-table .btn-danger:hover {
    background: var(--danger);
    color: white;
}

#empty-trash-btn {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    filter: brightness(1.1);
}

/* Filter Select */
.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-400);
}

/* Companies Grid */
.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: all var(--transition-fast);
}

.company-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.company-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.company-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.company-actions {
    display: flex;
    gap: 8px;
}

.company-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.company-detail {
    display: flex;
    gap: 8px;
    font-size: 13px;
}

.company-detail-label {
    color: var(--text-muted);
    min-width: 80px;
}

.company-detail-value {
    color: var(--text-secondary);
}

.company-stats {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 20px;
}

.company-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.company-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.company-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Search View */
.search-container {
    max-width: 800px;
}

.search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 4px rgba(45, 95, 133, 0.2);
}

.search-btn {
    padding: 14px 28px;
    background: var(--primary-500);
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.search-btn:hover {
    background: var(--primary-400);
}

.search-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.search-filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    cursor: pointer;
}

.search-filters input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-400);
}

.search-results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    min-height: 300px;
}

.search-result-item {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition-fast);
}

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

.search-result-item:hover {
    background: var(--bg-elevated);
}

.search-result-type {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--primary-400);
    margin-bottom: 4px;
}

.search-result-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.search-result-details {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Tender Detail View */
.tender-detail-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Tender view: full-width fields, aligned grids, readable textareas */
.tender-detail-stages {
    max-width: 1080px;
    margin: 0 auto;
}

.tender-detail-stages .detail-section-body {
    padding: 16px 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tender-detail-stages .detail-form-row {
    margin-bottom: 18px;
}

.tender-detail-stages .detail-form-row:last-child,
.tender-detail-stages .detail-section-body > .detail-hint:last-child {
    margin-bottom: 0;
}

.tender-detail-stages .detail-section-body > .detail-hint {
    margin-top: -8px;
    margin-bottom: 0;
}

.tender-detail-stages .detail-grid {
    align-items: start;
    gap: 18px 20px;
}

.tender-detail-stages .detail-grid .detail-item {
    min-width: 0;
}

.tender-detail-stages .detail-section-body input[type="text"],
.tender-detail-stages .detail-section-body input[type="number"],
.tender-detail-stages .detail-section-body input[type="date"],
.tender-detail-stages .detail-section-body input[type="datetime-local"],
.tender-detail-stages .detail-section-body select {
    max-width: none;
    width: 100%;
    box-sizing: border-box;
}

.tender-detail-stages .detail-section-body textarea.detail-value-input {
    max-width: none;
    width: 100%;
    max-height: none;
    min-height: 88px;
    resize: vertical;
    box-sizing: border-box;
}

.tender-detail-stages .detail-section-body textarea#td-quantity_and_price {
    min-height: 72px;
}

.tender-detail-stages .detail-section-body textarea#td-ra_detail {
    min-height: 80px;
}

.tender-detail-stages .detail-section-body textarea#td-notes {
    min-height: 140px;
}

.tender-detail-stages .detail-section-body textarea.atc-spec-textarea {
    min-height: 72px;
}

.tender-detail-stages .atc-spec-toggles-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    justify-content: flex-start;
}

.tender-detail-stages .atc-spec-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tender-detail-stages .atc-spec-toggle-group .status-toggle {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tender-detail-stages .ra-stage-row-dates-bid {
    margin-bottom: 0;
}

.tender-detail-stages .ra-stage-row-operate {
    margin-top: 4px;
}

.tender-detail-stages .ra-operate-field-wrap {
    max-width: min(100%, 360px);
}

.tender-detail-stages .tender-type-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tender-detail-stages .tender-type-toggle .btn {
    flex: 1 1 auto;
    min-width: 120px;
}

.tender-detail-stages .tender-stage-companies-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.tender-detail-stages .tender-stage-companies-body .tender-companies-list {
    width: 100%;
}

.tender-detail-stages .detail-grid-dispatch .detail-item {
    padding: 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.tender-detail-stage-row {
    margin-top: 12px;
    padding: 0 4px;
}

.tender-detail-save-actions {
    padding: 8px 0 4px;
    justify-content: flex-start;
}

@media (max-width: 900px) {
    .tender-detail-stages .detail-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.detail-section-header {
    background: var(--bg-elevated);
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.detail-section-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-section-header h3 .stage-badge {
    margin-right: 4px;
    animation: badgePulse 3s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(45, 95, 133, 0.3); }
    50% { box-shadow: 0 2px 12px rgba(45, 95, 133, 0.5); }
}

/* Detail Section - Enhanced */
.detail-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
    transition: all var(--transition-fast);
    position: relative;
}

.detail-section::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--primary-400);
}

.detail-section:hover {
    border-color: var(--border-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Unified accent color for all stages */
.detail-section::before { 
    background: linear-gradient(180deg, #3b82f6, #1d4ed8); 
}

/* ==================== POLISHED DESIGN SYSTEM ==================== */

/* Compact & Consistent Input Fields */
.detail-section-body input[type="text"],
.detail-section-body input[type="number"],
.detail-section-body input[type="date"],
.detail-section-body input[type="datetime-local"],
.detail-section-body select {
    height: 38px;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    width: 100%;
    max-width: 280px;
    transition: all var(--transition-fast);
}

.detail-section-body input:focus,
.detail-section-body select:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 2px rgba(45, 95, 133, 0.2);
}

/* Compact Textarea */
.detail-section-body textarea {
    min-height: 38px;
    max-height: 60px;
    resize: none;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    width: 100%;
    max-width: 400px;
}

.detail-section-body textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 2px rgba(45, 95, 133, 0.2);
}

/* Date Picker Styling */
input[type="date"],
input[type="datetime-local"] {
    cursor: pointer;
    position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.7);
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Inline Edit Group - Compact */
.inline-edit-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-edit-group input,
.inline-edit-group select {
    height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 13px;
    max-width: 220px;
}

/* Compact Buttons */
.btn-sm {
    padding: 6px 12px;
    font-size: 11px;
    height: 28px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Button in Stage Header */
.detail-section-header .btn-sm {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 500;
    height: 26px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* When header has both button and collapsible arrow */
.detail-section.collapsible .detail-section-header .btn-sm {
    margin-right: 0;
}

.btn-action {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Status Toggle - Compact */
.status-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.status-toggle .btn-sm {
    padding: 4px 10px;
    font-size: 10px;
    height: 26px;
}

.status-indicator {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* EMD Fields in Modal */
.emd-fields {
    margin-top: 12px;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.emd-fields .form-group {
    margin-bottom: 12px;
}

.emd-fields .form-group:last-child {
    margin-bottom: 0;
}

.emd-photo-preview {
    margin-top: 8px;
}

.emd-photo-preview img {
    border: 1px solid var(--border);
}

/* File Input Styling */
input[type="file"] {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 8px 0;
}

input[type="file"]::file-selector-button {
    background: var(--primary-500);
    color: var(--text-primary);
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-right: 10px;
    transition: background var(--transition-fast);
}

input[type="file"]::file-selector-button:hover {
    background: var(--primary-400);
}

/* Company Details Layout */
.tender-company-item {
    padding: 10px 12px;
    margin-bottom: 8px;
}

.tender-company-item:last-child {
    margin-bottom: 0;
}

.tender-company-details {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tender-company-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.tender-company-emd-number {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.tender-company-amount {
    display: block;
    font-size: 12px;
    color: var(--accent-400);
    font-weight: 600;
    margin-top: 2px;
}

.tender-company-emd-amount {
    display: block;
    font-size: 12px;
    color: var(--success, #22c55e);
    font-weight: 600;
    margin-top: 2px;
}

.tender-company-ip {
    font-size: 11px;
}

/* Detail Grid Improvements */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.detail-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.detail-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.detail-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-row .status-label {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.notes-icon {
    font-size: 16px;
}

@media (max-width: 768px) {
    .detail-grid-3,
    .detail-grid-4,
    .detail-grid-2 {
        grid-template-columns: 1fr;
    }
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-value.amount {
    font-size: 16px;
    color: var(--accent-400);
    font-family: var(--font-mono);
}

/* Modal Form Improvements */
.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

/* Checkbox label should be inline with checkbox */
.modal-body .form-group label.checkbox-styled {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    cursor: pointer;
}

.modal-body .form-group label.checkbox-styled input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    padding: 0;
    accent-color: var(--primary-400);
    cursor: pointer;
}

.modal-body .form-group input,
.modal-body .form-group select,
.modal-body .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 13px;
    transition: all var(--transition-fast);
}

.modal-body .form-group input:focus,
.modal-body .form-group select:focus,
.modal-body .form-group textarea:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 2px rgba(45, 95, 133, 0.2);
}

/* ==================== Stage Progress Tracker ==================== */

.stage-progress-tracker {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    margin-bottom: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
    gap: 0;
}

.stage-progress-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 90px;
    position: relative;
}

.stage-progress-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    transition: all var(--transition-normal);
    border: 3px solid var(--border);
    background: var(--bg-body);
    color: var(--text-muted);
}

.stage-progress-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    max-width: 80px;
    line-height: 1.2;
}

/* Completed Stage */
.stage-progress-item.completed .stage-progress-circle {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-color: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.stage-progress-item.completed .stage-progress-label {
    color: #60a5fa;
    font-weight: 600;
}

/* Current Stage */
.stage-progress-item.current .stage-progress-circle {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border-color: #3b82f6;
    color: white;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5);
    animation: currentPulse 2s ease-in-out infinite;
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(59, 130, 246, 0.5); transform: scale(1); }
    50% { box-shadow: 0 4px 24px rgba(59, 130, 246, 0.7); transform: scale(1.05); }
}

.stage-progress-item.current .stage-progress-label {
    color: #93c5fd;
    font-weight: 700;
}

/* Pending Stage */
.stage-progress-item.pending .stage-progress-circle {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text-muted);
}

.stage-progress-item.pending .stage-progress-label {
    color: var(--text-muted);
}

/* Progress Line */
.stage-progress-line {
    width: 40px;
    height: 3px;
    background: var(--border);
    flex-shrink: 0;
    margin: 0 4px;
    margin-bottom: 24px;
    border-radius: 2px;
}

.stage-progress-line.completed {
    background: linear-gradient(90deg, #3b82f6, #3b82f6);
}

/* Responsive */
@media (max-width: 768px) {
    .stage-progress-tracker {
        padding: 16px 12px;
        justify-content: flex-start;
    }
    
    .stage-progress-item {
        min-width: 70px;
    }
    
    .stage-progress-circle {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    
    .stage-progress-label {
        font-size: 8px;
        max-width: 60px;
    }
    
    .stage-progress-line {
        width: 20px;
    }
}

/* Collapsible Section Styles */
.detail-section.collapsible .detail-section-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.detail-section.collapsible .detail-section-header:hover {
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(45, 95, 133, 0.15) 100%);
}

.detail-section.collapsible .detail-section-header::after {
    content: '▼';
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    margin-left: 12px;
    flex-shrink: 0;
}

.detail-section.collapsible.collapsed .detail-section-header::after {
    transform: rotate(-90deg);
}

.detail-section.collapsible .detail-section-body {
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
}

.detail-section.collapsible.collapsed .detail-section-body {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0;
}

.detail-section.collapsible:not(.collapsed) .detail-section-body {
    max-height: 2000px;
    opacity: 1;
}

/* Section Header Improvements */
.detail-section-header {
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(45, 95, 133, 0.1) 100%);
}

.detail-section-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Stage Badge in Detail Headers - Enhanced */
.detail-section-header .stage-badge {
    font-size: 10px;
    padding: 5px 12px;
    border-radius: 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--primary-500) 0%, var(--primary-600) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(45, 95, 133, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Stage-specific badge colors */
.detail-section .stage-badge { 
    background: linear-gradient(135deg, #3b82f6, #1d4ed8); 
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3); 
}

.detail-section-body {
    padding: 10px 14px;
}

/* Add New Tender Button - Dashboard */
.btn-add-tender {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
}

/* Tracking Section Improvements */
.tracking-section {
    margin-top: 12px;
    padding-top: 12px;
}

.tracking-item {
    padding: 10px 0;
}

.tracking-label {
    font-size: 13px;
}

/* ==================== EMD Tracker Page ==================== */

.emd-stats-row {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

/* ==================== Companies Page ==================== */

.company-form {
    padding: 20px;
}

.company-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.company-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.company-form .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.company-form .form-group input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.company-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-hint a {
    color: var(--primary-400);
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

.company-form .form-actions {
    display: flex;
    justify-content: flex-end;
}

.company-count {
    font-size: 13px;
    color: var(--text-muted);
    padding: 4px 12px;
    background: var(--bg-elevated);
    border-radius: 20px;
}

.companies-table-panel {
    margin-top: 8px;
}

.companies-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.companies-search-input {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 420px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
}

.companies-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.companies-page-size-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.companies-showing {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: auto;
}

.companies-table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.companies-table th.sortable,
.all-tenders-data-table th.sortable,
.emd-data-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.companies-table th.sortable:hover,
.all-tenders-data-table th.sortable:hover,
.emd-data-table th.sortable:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.companies-table th.companies-actions-col {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.companies-actions-cell {
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}

.companies-actions-cell .btn {
    margin-left: 6px;
}

.companies-actions-cell .btn:first-child {
    margin-left: 0;
}

.companies-table th.sortable .th-label,
.all-tenders-data-table th.sortable .th-label,
.emd-data-table th.sortable .th-label {
    margin-right: 4px;
}

.companies-table th.sort-asc .th-label::after,
.companies-table th.sort-desc .th-label::after,
.all-tenders-data-table th.sort-asc .th-label::after,
.all-tenders-data-table th.sort-desc .th-label::after,
.emd-data-table th.sort-asc .th-label::after,
.emd-data-table th.sort-desc .th-label::after {
    content: '';
    display: inline-block;
    margin-left: 6px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    vertical-align: middle;
    opacity: 0.85;
}

.companies-table th.sort-asc .th-label::after,
.all-tenders-data-table th.sort-asc .th-label::after,
.emd-data-table th.sort-asc .th-label::after {
    border-bottom: 6px solid var(--accent);
    border-top: none;
}

.companies-table th.sort-desc .th-label::after,
.all-tenders-data-table th.sort-desc .th-label::after,
.emd-data-table th.sort-desc .th-label::after {
    border-top: 6px solid var(--accent);
    border-bottom: none;
}

.all-tenders-data-table th.all-tenders-actions-col {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.emd-data-table th.emd-actions-col {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

#emd-table.emd-data-table th.emd-actions-col {
    width: auto;
}

.all-tenders-table-panel {
    margin-top: 8px;
}

#emd-table-panel .companies-toolbar {
    margin-bottom: 16px;
}

.companies-table td:first-child,
.companies-table th:first-child,
.all-tenders-data-table td:first-child,
.all-tenders-data-table th:first-child,
.emd-data-table td:first-child,
.emd-data-table th:first-child {
    width: 64px;
    text-align: right;
}

.companies-table td:first-child,
.all-tenders-data-table td:first-child,
.emd-data-table td:first-child {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

.companies-pagination {
    margin-top: 16px;
}

.companies-pagination-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.companies-page-info {
    font-size: 13px;
    color: var(--text-muted);
    padding: 0 8px;
}

.companies-empty-full,
.companies-empty-filter {
    margin-top: 12px;
}

.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px;
}

.company-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
}

.company-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.company-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-bottom: 1px solid var(--border);
}

.company-card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon.btn-delete {
    background: transparent;
    color: var(--text-muted);
}

.btn-icon.btn-delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.company-card-body {
    padding: 16px;
}

.company-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.company-detail:last-child {
    border-bottom: none;
}

.company-detail .label {
    font-size: 12px;
    color: var(--text-muted);
}

.company-detail .value {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* ==================== EMD Page ==================== */

.emd-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px 28px;
    text-align: center;
    min-width: 140px;
    position: relative;
    overflow: hidden;
}

.emd-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary-400);
}

.emd-stat-card.emd-pending::before {
    background: var(--warning);
}

.emd-stat-card.emd-received::before {
    background: var(--success);
}

.emd-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.emd-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emd-tracker-container {
    max-width: 100%;
}

.emd-table-container {
    overflow-x: auto;
}

#emd-table.emd-data-table {
    table-layout: fixed;
    width: 100%;
    min-width: 880px;
}

/* ID column: align with global .emd-data-table first-child rules */
#emd-table.emd-data-table .emd-col-id { width: 4rem; }
#emd-table.emd-data-table .emd-col-office { width: 11%; }
#emd-table.emd-data-table .emd-col-product { width: 17%; }
#emd-table.emd-data-table .emd-col-company { width: 15%; }
#emd-table.emd-data-table .emd-col-ref { width: 9%; }
#emd-table.emd-data-table .emd-col-amount { width: 6.5rem; }
#emd-table.emd-data-table .emd-col-date { width: 6.75rem; }
#emd-table.emd-data-table .emd-col-status { width: 7.5rem; }
#emd-table.emd-data-table .emd-col-received { width: 7.25rem; }
#emd-table.emd-data-table .emd-col-draft { width: 6.5rem; }
#emd-table.emd-data-table .emd-col-actions { width: 6.75rem; }

#emd-table.emd-data-table th,
#emd-table.emd-data-table td {
    padding: 10px 12px;
    vertical-align: middle;
}

#emd-table.emd-data-table .emd-td-clip {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#emd-table.emd-data-table .emd-td-mono {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 12px;
}

#emd-table.emd-data-table .emd-td-nowrap {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#emd-table.emd-data-table .emd-td-received {
    vertical-align: middle;
}

#emd-table.emd-data-table .emd-td-draft {
    overflow: hidden;
}

#emd-table.emd-data-table .emd-draft-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-secondary);
}

#emd-table.emd-data-table .emd-received-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    line-height: 1.25;
}

#emd-table.emd-data-table .emd-received-date-line {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

#emd-table.emd-data-table .emd-receipt-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent, #3b82f6);
    text-decoration: none;
}

#emd-table.emd-data-table .emd-receipt-link:hover {
    text-decoration: underline;
}

#emd-table.emd-data-table .emd-actions-cell {
    text-align: right;
    vertical-align: middle;
}

#emd-table.emd-data-table .emd-actions-inner {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    max-width: 100%;
}

.emd-status-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.emd-status-cell .emd-status-select {
    width: 100%;
    max-width: 100%;
    font-size: 13px;
}

.emd-return-date-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.emd-inline-date-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.emd-received-date-input {
    font-size: 13px;
}

.emd-table-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.emd-ref-badge {
    background: var(--bg-elevated);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
}

.emd-received-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.emd-received-date {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Status Colors */
.status-yes {
    background: var(--success-bg);
    color: var(--success);
}

.status-no {
    background: var(--danger-bg);
    color: var(--danger);
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Companies in Tender Detail */
.tender-companies-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tender-company-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tender-company-item.is-l1 {
    border-color: var(--success);
    background: linear-gradient(90deg, var(--success-bg) 0%, var(--bg-elevated) 100%);
}

.tender-company-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.l1-badge {
    background: var(--success);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
}

.tender-company-name {
    font-weight: 500;
    color: var(--text-primary);
}

.tender-company-ip {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.tender-company-emd {
    font-size: 12px;
}

.emd-submitted {
    color: var(--success);
}

.emd-pending {
    color: var(--danger);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color var(--transition-fast);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 24px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn var(--transition-normal);
}

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

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-info {
    border-left: 4px solid var(--info);
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

/* Inline Edit - see polished design section above */

/* Checkbox styled */
.checkbox-styled {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.checkbox-styled input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-400);
    cursor: pointer;
}

.checkbox-styled span {
    color: var(--text-secondary);
}

/* Payment and Dispatch tracking */
.tracking-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.tracking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.tracking-item-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.tracking-item-inline .tracking-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.tracking-item-inline .status-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tracking-label {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .sidebar {
        width: 70px;
    }
    
    .sidebar-header {
        padding: 16px 10px;
        text-align: center;
    }
    
    .logo-text, .tagline {
        display: none;
    }
    
    .logo-icon {
        font-size: 24px;
    }
    
    .nav-item span:not(.nav-icon) {
        display: none;
    }
    
    .nav-item {
        justify-content: center;
        padding: 14px;
    }
    
    .nav-icon {
        margin: 0;
    }
    
    .sidebar-footer button span:last-child {
        display: none;
    }
    
    .main-content {
        margin-left: 70px;
        padding: 20px;
    }
    
    :root {
        --sidebar-width: 70px;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .quick-search input {
        width: 100%;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .companies-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .tenders-table {
        font-size: 12px;
    }
    
    .tenders-table th,
    .tenders-table td {
        padding: 10px 8px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Selection */
::selection {
    background: var(--primary-400);
    color: white;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .sidebar, .nav-menu, .header-actions, .form-actions, .action-btns {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .stat-card, .section-block, .detail-section {
        border: 1px solid #ccc;
        background: white;
    }
}

/* Stage 1 — Direct Purchase Details (shown when Tender Type = Open Purchase) */
.direct-purchase-wrap {
    margin-top: 20px;
}

.direct-purchase-card {
    background: #0b0e14;
    border: 1px solid var(--border);
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    overflow: hidden;
}

.direct-purchase-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s ease;
}

.direct-purchase-header:hover {
    background: rgba(59, 130, 246, 0.12);
}

.direct-purchase-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    flex-shrink: 0;
}

.direct-purchase-icon {
    font-size: 14px;
    line-height: 1;
}

.direct-purchase-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.direct-purchase-caret {
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.direct-purchase-body {
    padding: 20px 18px 22px;
}

.direct-purchase-fields-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .direct-purchase-fields-row {
        grid-template-columns: 1fr;
    }
}

.direct-purchase-card.collapsed .direct-purchase-body {
    display: none;
}

.direct-purchase-card .detail-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.direct-purchase-card .detail-value-input {
    background: #111827;
    border-color: #2d3748;
}

.tender-detail-stages .detail-actions {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

