/* ============================================
   HACO Project Management - Design System
   ============================================ */

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

    /* Background & Surface (Light Theme) */
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.9);

    /* Text (Light Theme) */
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-accent: #2563eb;

    /* Status 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: #06b6d4;
    --info-bg: rgba(6, 182, 212, 0.15);

    /* Borders */
    --border-color: rgba(148, 163, 184, 0.3);
    --border-hover: rgba(148, 163, 184, 0.5);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.1);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Global background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

::selection {
    background: var(--primary-500);
    color: white;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.35);
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-slow), transform var(--transition-slow);
    backdrop-filter: blur(20px);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    flex-shrink: 0;
}

.logo-icon span {
    font-size: 24px;
    color: white;
}

.logo-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #1d4ed8, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-normal);
    position: relative;
    font-weight: 500;
    font-size: 0.93rem;
}

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(99, 102, 241, 0.08));
    color: var(--primary-400);
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary-500);
    border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-round {
    font-size: 22px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

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

.user-avatar {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary-600), #7c3aed);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-avatar span {
    font-size: 20px;
    color: white;
}

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

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    position: relative;
    z-index: 1;
    transition: margin-left var(--transition-slow);
}

/* ============================================
   Top Bar
   ============================================ */

.topbar {
    height: var(--topbar-height);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 40px;
    min-width: 320px;
    transition: all var(--transition-normal);
}

.search-box:focus-within {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-box .material-icons-round {
    font-size: 20px;
    color: var(--text-muted);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}

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

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
    display: none;
}

.notification-badge.show {
    display: flex;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.topbar-date .material-icons-round {
    font-size: 18px;
    color: var(--primary-400);
}

/* ============================================
   Views
   ============================================ */

.view {
    display: none;
    padding: 28px;
    animation: fadeInUp 0.4s ease;
}

.view.active {
    display: block;
}

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

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

.view-header h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.view-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

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

/* ============================================
   Buttons
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    white-space: nowrap;
}

.btn .material-icons-round {
    font-size: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.45);
    transform: translateY(-1px);
}

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

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

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-sm .material-icons-round {
    font-size: 16px;
}

.btn-save-master {
    background: linear-gradient(135deg, #059669, #10b981); /* Emerald green */
    border: none;
    color: white;
    padding: 8px 16px;
    height: 40px;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
    animation: pulse-save 3s infinite;
}

.btn-save-master:hover {
    background: linear-gradient(135deg, #047857, #059669);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-save-master.saving {
    opacity: 0.8;
    pointer-events: none;
    filter: grayscale(0.5);
}

.btn-save-master .material-icons-round {
    font-size: 20px;
}

@keyframes pulse-save {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@media (max-width: 768px) {
    .btn-save-master .btn-text {
        display: none;
    }
    .btn-save-master {
        padding: 0;
        width: 40px;
    }
}

.spinning {
    animation: spin 1s linear infinite;
}

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

/* ============================================
   Filter Select
   ============================================ */

.filter-select {
    padding: 10px 36px 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: all var(--transition-fast);
}

.filter-select:hover {
    border-color: var(--border-hover);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ============================================
   Stats Cards
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card[data-color="blue"]::before { background: linear-gradient(90deg, var(--primary-500), var(--primary-300)); }
.stat-card[data-color="amber"]::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card[data-color="green"]::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card[data-color="red"]::before { background: linear-gradient(90deg, #ef4444, #f87171); }

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

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card[data-color="blue"] .stat-icon { background: rgba(59, 130, 246, 0.12); color: var(--primary-400); }
.stat-card[data-color="amber"] .stat-icon { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.stat-card[data-color="green"] .stat-icon { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.stat-card[data-color="red"] .stat-icon { background: rgba(239, 68, 68, 0.12); color: #f87171; }

.stat-icon .material-icons-round {
    font-size: 26px;
}

.stat-info {
    flex: 1;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}

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

.stat-trend {
    color: var(--text-muted);
}

.stat-trend .material-icons-round {
    font-size: 22px;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--danger);
}

/* ============================================
   Section Card
   ============================================ */

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
}

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

.section-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Data Table
   ============================================ */

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

.full-table {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px;
    backdrop-filter: blur(10px);
}

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

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--bg-elevated);
    padding: 14px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

.data-table th:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.data-table th:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.th-sortable {
    cursor: pointer;
    user-select: none;
}

.th-sortable:hover {
    color: var(--text-primary);
}

.sort-icon {
    font-size: 16px !important;
    vertical-align: middle;
    opacity: 0.5;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

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

/* Status badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge .material-icons-round {
    font-size: 14px;
}

.status-pending {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-completed {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-overdue {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Progress bar */
.progress-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 3px;
    overflow: hidden;
    min-width: 80px;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar-fill.low { background: linear-gradient(90deg, #ef4444, #f97316); }
.progress-bar-fill.mid { background: linear-gradient(90deg, #f59e0b, #eab308); }
.progress-bar-fill.high { background: linear-gradient(90deg, #22c55e, #10b981); }
.progress-bar-fill.full { background: linear-gradient(90deg, var(--primary-500), #8b5cf6); }

.progress-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

/* Action buttons */
.action-btns {
    display: flex;
    gap: 4px;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.action-btn .material-icons-round {
    font-size: 18px;
}

.action-btn:hover {
    background: var(--bg-surface);
}

.action-btn.view:hover { color: var(--info); }
.action-btn.edit:hover { color: var(--primary-400); }
.action-btn.delete:hover { color: var(--danger); background: var(--danger-bg); }

/* Date cell with icon */
.date-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.date-cell .material-icons-round {
    font-size: 14px;
    color: var(--text-muted);
}

.date-cell.filled .material-icons-round {
    color: var(--success);
}

.date-empty {
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================
   Contracts Grid
   ============================================ */

.contracts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 20px;
}

.contract-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.contract-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-xl), var(--shadow-glow);
}

.contract-card-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(99, 102, 241, 0.04));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.contract-card-header .contract-type {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--primary-400);
    margin-bottom: 6px;
}

.contract-card-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.contract-card-header .model-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.contract-card-body {
    padding: 20px 24px;
}

.contract-info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

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

.contract-info-row .material-icons-round {
    font-size: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.contract-info-row .label {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.contract-info-row .value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.contract-card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ============================================
   Timeline
   ============================================ */

.timeline-container {
    position: relative;
    padding: 20px 0;
}

.timeline-item {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
    position: relative;
}

.timeline-left {
    width: 160px;
    flex-shrink: 0;
    text-align: right;
    padding-top: 4px;
}

.timeline-project-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.timeline-model {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.timeline-line {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.timeline-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-500);
    border: 3px solid var(--bg-primary);
    box-shadow: 0 0 0 2px var(--primary-500);
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.timeline-dot.completed { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.pending { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.overdue { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }

.timeline-connector {
    width: 2px;
    flex: 1;
    background: linear-gradient(to bottom, var(--border-color), transparent);
    margin-top: 4px;
}

.timeline-right {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    backdrop-filter: blur(10px);
    transition: all var(--transition-normal);
}

.timeline-right:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.timeline-milestones {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.milestone {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
}

.milestone.done {
    border-left-color: var(--success);
}

.milestone.upcoming {
    border-left-color: var(--warning);
}

.milestone-icon {
    font-size: 18px;
}

.milestone.done .milestone-icon { color: var(--success); }
.milestone.upcoming .milestone-icon { color: var(--warning); }
.milestone:not(.done):not(.upcoming) .milestone-icon { color: var(--text-muted); }

.milestone-info {
    flex: 1;
}

.milestone-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.milestone-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Reports
   ============================================ */

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

.report-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    backdrop-filter: blur(10px);
}

.report-card.wide {
    grid-column: span 2;
}

.report-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-card h3 .material-icons-round {
    font-size: 22px;
    color: var(--primary-400);
}

.chart-container {
    height: 260px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

.model-stats, .company-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

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

.stat-item-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-400);
}

/* ============================================
   Modal
   ============================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-normal);
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-xl);
}

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

.modal-lg {
    max-width: 860px;
}

.modal-sm {
    max-width: 420px;
}

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

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

/* ============================================
   Form Styles
   ============================================ */

.form-section {
    margin-bottom: 28px;
}

.form-section h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.form-section h4 .material-icons-round {
    font-size: 20px;
    color: var(--primary-400);
}

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

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

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

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

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

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

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ============================================
   Detail Modal Content
   ============================================ */

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

.detail-section {
    padding: 20px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.detail-section.full {
    grid-column: span 2;
}

.detail-section h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--primary-400);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-section h4 .material-icons-round {
    font-size: 18px;
}

.detail-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.06);
}

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

.detail-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.detail-value {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.detail-value.success { color: var(--success); }
.detail-value.warning { color: var(--warning); }
.detail-value.danger { color: var(--danger); }

/* Progress timeline in detail */
.detail-progress-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 8px;
}

.progress-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
    padding-bottom: 24px;
}

.progress-step:last-child {
    padding-bottom: 0;
}

.progress-step-marker {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    flex-shrink: 0;
}

.step-dot .material-icons-round {
    font-size: 16px;
    color: var(--text-muted);
}

.progress-step.done .step-dot {
    background: var(--success-bg);
    border-color: var(--success);
}

.progress-step.done .step-dot .material-icons-round {
    color: var(--success);
}

.step-line {
    width: 2px;
    flex: 1;
    background: var(--border-color);
    min-height: 20px;
}

.progress-step.done .step-line {
    background: var(--success);
}

.progress-step-content {
    flex: 1;
    padding-top: 4px;
}

.step-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

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

.step-date.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================
   Notification Panel
   ============================================ */

.notification-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    transform: translateX(100%);
    transition: transform var(--transition-slow);
    display: flex;
    flex-direction: column;
}

.notification-panel.active {
    transform: translateX(0);
}

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

.notification-header h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

.notification-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.notification-item {
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    transition: all var(--transition-fast);
}

.notification-item:hover {
    border-color: var(--border-hover);
}

.notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-icon.warning { background: var(--warning-bg); color: var(--warning); }
.notification-icon.info { background: var(--info-bg); color: var(--info); }
.notification-icon.danger { background: var(--danger-bg); color: var(--danger); }

.notification-icon .material-icons-round {
    font-size: 18px;
}

.notification-content {
    flex: 1;
}

.notification-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 4px;
}

.notification-time {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ============================================
   Toast
   ============================================ */

.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 300px;
}

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

.toast .material-icons-round {
    font-size: 20px;
}

.toast.success .material-icons-round { color: var(--success); }
.toast.error .material-icons-round { color: var(--danger); }
.toast.info .material-icons-round { color: var(--info); }

.toast-message {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

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

/* ============================================
   Deadlines List
   ============================================ */

.deadlines-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.deadline-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.deadline-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-surface-hover);
}

.deadline-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.deadline-icon.soon {
    background: var(--warning-bg);
    color: var(--warning);
}

.deadline-icon.overdue {
    background: var(--danger-bg);
    color: var(--danger);
}

.deadline-icon.ok {
    background: var(--info-bg);
    color: var(--info);
}

.deadline-info {
    flex: 1;
}

.deadline-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

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

.deadline-date {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.deadline-date.soon { color: var(--warning); }
.deadline-date.overdue { color: var(--danger); }
.deadline-date.ok { color: var(--info); }

/* ============================================
   Empty State
   ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .material-icons-round {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h4 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.88rem;
}

/* ============================================
   Responsive
   ============================================ */

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity var(--transition-normal);
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

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

    .reports-grid {
        grid-template-columns: 1fr;
    }

    .report-card.wide {
        grid-column: span 1;
    }

    .contracts-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* --- Mobile (â‰¤768px) --- */
@media (max-width: 768px) {
    /* Sidebar: off-canvas drawer */
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 200;
        width: 280px;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    }

    /* Main content: full width */
    .main-content {
        margin-left: 0 !important;
        width: 100vw !important;
    }

    /* Topbar: compact */
    .topbar {
        padding: 0 12px;
        height: 52px;
    }

    .topbar-left {
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .topbar-right {
        gap: 6px;
        flex-shrink: 0;
    }

    .search-box {
        min-width: 0;
        flex: 1;
        padding: 0 10px;
        height: 36px;
    }

    .search-box input {
        font-size: 0.85rem;
    }

    .search-box input::placeholder {
        font-size: 0.8rem;
    }

    .topbar-date {
        display: none;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .theme-toggle {
        width: 32px;
        height: 32px;
    }

    .theme-toggle .material-icons-round {
        font-size: 18px;
    }

    /* Stats: 2-column grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-icon .material-icons-round {
        font-size: 20px;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .stat-label {
        font-size: 0.72rem;
    }

    .stat-trend {
        display: none;
    }

    /* Views: tighter padding */
    .view {
        padding: 14px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 16px;
    }

    .view-header h2 {
        font-size: 1.25rem;
    }

    .view-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    .view-actions .btn,
    .view-actions .btn-export,
    .view-actions .btn-print {
        flex: 1;
        min-width: 0;
        justify-content: center;
        padding: 8px 10px;
        font-size: 0.78rem;
    }

    .filter-group {
        width: 100%;
    }

    .filter-select {
        width: 100%;
        font-size: 0.82rem;
        padding: 8px 32px 8px 12px;
    }

    /* Section cards */
    .section-card {
        padding: 14px;
        margin-bottom: 14px;
        border-radius: var(--radius-md);
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 12px;
    }

    .section-header h3 {
        font-size: 0.95rem;
    }

    /* Tables */
    .table-container {
        border-radius: var(--radius-md);
    }

    .full-table {
        border-radius: var(--radius-md);
    }

    table.data-table {
        min-width: 900px;
    }

    .data-table th {
        padding: 10px 12px;
        font-size: 0.72rem;
    }

    .data-table td {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    /* Forms */
    .form-grid {
        grid-template-columns: 1fr;
    }

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

    /* Detail modal */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-section.full {
        grid-column: span 1;
    }

    /* Contracts */
    .contracts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .contract-card-header {
        padding: 14px 16px;
    }

    .contract-card-body {
        padding: 12px 16px;
    }

    .contract-card-footer {
        padding: 12px 16px;
    }

    /* Timeline */
    .timeline-item {
        flex-direction: column;
        gap: 0;
    }

    .timeline-left {
        width: 100%;
        text-align: left;
        padding: 0 0 8px 0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .timeline-line {
        display: none;
    }

    .timeline-right {
        padding: 14px;
    }

    .timeline-milestones {
        grid-template-columns: 1fr;
    }

    .milestone {
        padding: 8px 10px;
    }

    /* Reports */
    .reports-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .report-card {
        padding: 16px;
    }

    .report-card.wide {
        grid-column: span 1;
    }

    .chart-container {
        height: 200px;
    }

    /* Modal: near full-screen on mobile */
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .modal-lg {
        max-width: 100%;
    }

    .modal-sm {
        max-width: 100%;
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-header h3 {
        font-size: 1.05rem;
    }

    .modal-body {
        padding: 14px 16px;
    }

    .modal-footer {
        padding-top: 14px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

    /* Account modal layout: stack vertically */
    #accountModal .modal-body > div {
        flex-direction: column !important;
    }

    #accountModal .modal-body > div > div {
        border-right: none !important;
        padding-right: 0 !important;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 16px !important;
        min-width: 100% !important;
    }

    #accountModal .modal-body > div > div:last-child {
        border-bottom: none;
        padding-bottom: 0 !important;
        padding-top: 16px !important;
    }

    /* Pagination */
    .pagination {
        flex-direction: column;
        gap: 8px;
        padding: 12px;
    }

    .page-size {
        width: 100%;
        justify-content: center;
    }

    .pagination-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Notification panel: full-width */
    .notification-panel {
        width: 100vw;
    }

    /* Toast: bottom-center on mobile */
    .toast-container {
        bottom: 16px;
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: auto;
        width: 100%;
    }

    /* Deadlines */
    .deadline-item {
        padding: 10px 12px;
        gap: 10px;
    }

    .deadline-icon {
        width: 34px;
        height: 34px;
    }

    .deadline-title {
        font-size: 0.82rem;
    }

    .deadline-desc {
        font-size: 0.72rem;
    }

    .deadline-date {
        font-size: 0.78rem;
    }

    /* License banner */
    .license-banner {
        font-size: 0.8rem;
        padding: 8px 12px;
        flex-direction: column;
        gap: 8px;
    }

    .license-banner span {
        text-align: center;
        font-size: 0.78rem;
    }

    /* Login card */
    .login-card {
        padding: 28px 20px;
        width: 95vw;
        max-width: 400px;
    }

    /* Empty state */
    .empty-state {
        padding: 30px 16px;
    }

    .empty-state .material-icons-round {
        font-size: 48px;
    }

    .empty-state h4 {
        font-size: 0.95rem;
    }

    .empty-state p {
        font-size: 0.82rem;
    }

    /* Model/company stats */
    .model-stats, .company-stats {
        grid-template-columns: 1fr;
    }

    /* Form section heading */
    .form-section h4 {
        font-size: 0.88rem;
    }

    /* About modal */
    #aboutModal .modal {
        max-width: 100% !important;
    }
}

/* --- Small phone (â‰¤480px) --- */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stat-card {
        padding: 12px 10px;
        flex-direction: row;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon .material-icons-round {
        font-size: 18px;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .section-header {
        flex-direction: column;
        gap: 6px;
    }

    .login-card {
        padding: 20px 16px;
        width: 100%;
        max-width: none;
        border-radius: var(--radius-md);
    }

    .login-screen {
        padding: 12px;
    }

    .view {
        padding: 10px;
    }

    .topbar {
        padding: 0 8px;
    }

    .topbar-right {
        gap: 2px;
    }

    .view-header h2 {
        font-size: 1.1rem;
    }

    .contracts-grid {
        gap: 10px;
    }

    .contract-card-header h4 {
        font-size: 0.92rem;
    }

    /* About modal text */
    #aboutModal .modal-body h4 {
        font-size: 0.95rem !important;
    }

    /* Action buttons in table â€“ make them bigger for touch */
    .action-btn {
        width: 36px;
        height: 36px;
    }

    .action-btn .material-icons-round {
        font-size: 20px;
    }

    /* Countdown badge */
    .countdown-badge {
        font-size: 0.62rem;
        padding: 2px 4px;
    }
}

/* ============================================
   Animations
   ============================================ */

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-hover) 50%, var(--bg-surface) 75%);
    background-size: 200px 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Counter animation utility */
.count-up {
    display: inline-block;
    transition: transform 0.3s ease;
}

/* ============================================
   Export button styles
   ============================================ */
.export-btns {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Pagination
   ============================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-50);
    border-color: var(--primary-300);
    color: var(--primary-600);
}

.page-btn.active {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-size {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.page-size select {
    padding: 4px 20px 4px 8px;
}

/* ============================================
   Login Screen & License Overlay
   ============================================ */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary), var(--primary-100));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--bg-surface);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card .logo {
    justify-content: center;
    margin-bottom: 32px;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.login-card .form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 6px;
    display: block;
    color: var(--text-primary);
}

.login-card .form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
}

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

.login-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    justify-content: center;
    margin-top: 8px;
}

.view-only-mode {
    filter: grayscale(0.5);
    pointer-events: none;
}

.view-only-mode .main-content, .view-only-mode .sidebar {
    pointer-events: auto;
}

/* Hide action buttons in view-only mode */
body.view-only-style .btn-primary,
body.view-only-style .action-btn.edit,
body.view-only-style .action-btn.delete,
body.view-only-style .contract-card-footer {
    display: none !important;
}

body.role-user-style .view-only-hide {
    display: none !important;
}

.license-banner {
    background: var(--danger);
    color: white;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1000;
    display: none;
}

.license-banner.active {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.license-banner button {
    background: white;
    color: var(--danger);
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
}

.license-banner button:hover {
    background: var(--primary-50);
}

/* Scroll Fix */
.table-container { overflow: auto; max-height: calc(100vh - 250px); }

/* Full Width Fixes */
body { width: 100vw; }
.main-content { width: calc(100vw - var(--sidebar-width)); overflow-x: hidden; }
.view { width: 100%; padding: 28px; box-sizing: border-box; }
.table-container { width: 100%; overflow: auto; max-height: calc(100vh - 220px); }
table.data-table { width: 100%; min-width: 1300px; }

/* ============================================
   Dark Mode
   ============================================ */
body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-elevated: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.95);
    --bg-body: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-accent: #60a5fa;
    --border-color: rgba(148, 163, 184, 0.15);
    --border-hover: rgba(148, 163, 184, 0.3);
    --border-light: rgba(148, 163, 184, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

body.dark-mode::before {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 50%);
}

body.dark-mode .login-card { background: var(--bg-secondary); border-color: var(--border-color); }
body.dark-mode .sidebar { background: var(--bg-secondary); }
body.dark-mode .topbar { background: rgba(15, 23, 42, 0.85); }
body.dark-mode .modal { background: var(--bg-secondary); }
body.dark-mode input, body.dark-mode select, body.dark-mode textarea {
    background: rgba(0,0,0,0.2); color: var(--text-primary); border-color: var(--border-color);
}
body.dark-mode .contract-card { background: var(--bg-card); }
body.dark-mode .section-card { background: var(--bg-card); }
body.dark-mode .stat-card { background: var(--bg-card); }
body.dark-mode .report-card { background: var(--bg-card); }

/* Theme Toggle Button */
.theme-toggle {
    width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--border-color); background: var(--bg-surface);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition-fast); color: var(--text-muted);
}
.theme-toggle:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.theme-toggle .material-icons-round { font-size: 20px; }

/* ============================================
   Page Transition Animations
   ============================================ */
.view { opacity: 0; transform: translateY(8px); transition: opacity 0.3s ease, transform 0.3s ease; pointer-events: none; }
.view.active { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ============================================
   Priority Badges
   ============================================ */
.priority-badge {
    display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
    border-radius: 12px; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.3px;
}
.priority-high { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.priority-medium { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.priority-low { background: rgba(16, 185, 129, 0.12); color: #10b981; }

/* ============================================
   Countdown Badges on table rows
   ============================================ */
.countdown-badge {
    display: inline-flex; align-items: center; gap: 3px; padding: 2px 6px;
    border-radius: 6px; font-size: 0.68rem; font-weight: 600; white-space: nowrap;
}
.countdown-badge.overdue { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.countdown-badge.soon { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.countdown-badge.ok { background: rgba(16, 185, 129, 0.1); color: #10b981; }

/* ============================================
   Activity Log
   ============================================ */
.activity-log { display: flex; flex-direction: column; gap: 0; }
.activity-item {
    display: flex; align-items: flex-start; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border-color); font-size: 0.85rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 32px; height: 32px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
}
.activity-icon.add { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.activity-icon.edit { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.activity-icon.delete { background: rgba(239, 68, 68, 0.12); color: #ef4444; }
.activity-icon.login { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.activity-text { flex: 1; color: var(--text-secondary); line-height: 1.4; }
.activity-text strong { color: var(--text-primary); }
.activity-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }

/* ============================================
   Export / Utility Buttons
   ============================================ */
.btn-export {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.1); color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3); cursor: pointer;
    font-weight: 600; font-size: 0.82rem; transition: all var(--transition-fast);
    font-family: inherit;
}
.btn-export:hover { background: rgba(16, 185, 129, 0.2); }
.btn-export .material-icons-round { font-size: 18px; }

.btn-print {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: var(--radius-sm);
    background: rgba(99, 102, 241, 0.1); color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.3); cursor: pointer;
    font-weight: 600; font-size: 0.82rem; transition: all var(--transition-fast);
    font-family: inherit;
}
.btn-print:hover { background: rgba(99, 102, 241, 0.2); }
.btn-print .material-icons-round { font-size: 18px; }

/* ============================================
   Value display (currency)
   ============================================ */
.value-currency {
    font-weight: 700; color: var(--success); font-size: 1.05rem;
}

/* ============================================
   On-time stat
   ============================================ */
.stat-card[data-color="purple"] .stat-icon { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.stat-card[data-color="cyan"] .stat-icon { background: rgba(6, 182, 212, 0.12); color: #06b6d4; }

/* ============================================
   Print Styles
   ============================================ */
@media print {
    body * { visibility: hidden; }
    #printArea, #printArea * { visibility: visible; }
    #printArea {
        position: absolute; left: 0; top: 0; width: 100%;
        padding: 20px; background: white; color: #1e293b;
    }
    #printArea h2 { font-size: 18px; margin-bottom: 16px; }
    #printArea table { width: 100%; border-collapse: collapse; }
    #printArea td, #printArea th { border: 1px solid #ccc; padding: 8px; font-size: 12px; }
    .no-print { display: none !important; }
}


/* ============================================
   Attachment Links
   ============================================ */
.attachment-link {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--primary-400); text-decoration: none; font-weight: 500;
    font-size: 0.85rem; padding: 3px 8px; border-radius: 6px;
    background: rgba(59, 130, 246, 0.08);
    transition: all var(--transition-fast);
    max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attachment-link:hover {
    background: rgba(59, 130, 246, 0.15); text-decoration: underline;
    color: var(--primary-300);
}
.attachment-file {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--text-secondary); font-size: 0.85rem;
    padding: 3px 8px; border-radius: 6px;
    background: var(--bg-surface);
}

/* ============================================
   Custom Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.5); }
body.dark-mode ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.2); }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); }

/* ============================================
   Sticky Table Header
   ============================================ */
.table-container thead th {
    position: sticky; top: 0; z-index: 10;
    background: var(--bg-elevated); backdrop-filter: blur(8px);
}
body.dark-mode .table-container thead th {
    background: var(--bg-secondary);
}

/* ============================================
   View Header Flex for Dashboard
   ============================================ */
.view-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-wrap: wrap; gap: 12px;
}

/* ============================================
   HACO Contracts Tree List
   ============================================ */
.haco-contracts-tree {
    padding: 10px 0;
}
.contract-year-group {
    margin-bottom: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}
.contract-year-group:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}
.year-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(59, 130, 246, 0.05);
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-600);
    font-size: 1.05rem;
}
.year-header strong {
    flex: 1;
}
.year-header .material-icons-round {
    font-size: 20px;
}
.count-badge {
    background: var(--primary-100);
    color: var(--primary-700);
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.company-list {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}
.company-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 10px 32px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.company-list li:hover {
    background: var(--bg-surface-hover);
}
.company-list .list-bullet {
    color: var(--primary-400);
    font-size: 1.5rem;
    line-height: 0;
    position: relative;
    top: -4px;
}
.company-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}
.company-name {
    font-weight: 500;
    color: var(--text-primary);
}
.company-model {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   Image Upload & Lightbox Preview
   ============================================ */
.image-upload-wrapper {
    width: 100%;
}
.image-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    cursor: pointer;
    transition: all var(--transition-fast);
    gap: 8px;
    color: var(--text-secondary);
}
.image-upload-label:hover {
    border-color: var(--primary-400);
    color: var(--primary-400);
    background: rgba(59, 130, 246, 0.05);
}
.image-upload-label span.material-icons-round {
    font-size: 32px;
}
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}
.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.image-preview-item .btn-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    transition: background 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.image-preview-item .btn-remove:hover {
    background: rgb(220, 38, 38);
}
.image-preview-item .upload-spinner {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    gap: 6px;
}
.image-preview-item .upload-spinner .spinner-icon {
    animation: rotate 1.2s linear infinite;
    font-size: 20px;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Detail Image Gallery */
.detail-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 12px;
}
.gallery-item {
    aspect-ratio: 4/3;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-sm);
}
.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lightbox overlay customisation */
.lightbox-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}
#lightboxImage {
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 3px solid rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}


/* ============================================
   Warehouse Module
   ============================================ */

.row-exported {
    opacity: 0.65;
    background: var(--bg-surface-hover);
}

.row-exported td {
    color: var(--text-muted);
}

/* Warehouse filter badge on nav */
#view-warehouse .view-header h2::after {
    content: '';
}

/* Export modal compact form */
#exportWarehouseModal .form-group label {
    font-weight: 600;
    font-size: 0.88rem;
}

#exportWarehouseModal .form-group input {
    margin-top: 6px;
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

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

/* Warehouse action button - export */
.action-btn[onclick*="openExportWarehouseModal"] {
    background: rgba(245, 158, 11, 0.1);
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.action-btn[onclick*="openExportWarehouseModal"]:hover {
    background: rgba(245, 158, 11, 0.2);
    transform: translateY(-1px);
}

/* Commission date label highlight */
#commissionDate {
    border-color: rgba(16, 185, 129, 0.3);
}

#commissionDate:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

