@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --background-dark: #0f172a;
    --surface-dark: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Space Grotesk', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--background-dark);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.12), transparent 45%),
        radial-gradient(circle at 80% 0%, rgba(236, 72, 153, 0.12), transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    scroll-behavior: smooth;
}

body.sidebar-open {
    overflow: hidden;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.p-4 {
    padding: 1rem;
}

.p-6 {
    padding: 1.5rem;
}

.w-full {
    width: 100%;
}

img,
video,
iframe,
canvas {
    max-width: 100%;
    height: auto;
}

.filter-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-left: auto;
}

.filter-form>* {
    flex: 0 0 auto;
}

@media screen and (max-width: 1024px) {
    .filter-form {
        width: 100%;
        margin-left: 0;
        justify-content: flex-start;
    }
}

@media screen and (max-width: 768px) {
    .filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .filter-form>* {
        width: 100% !important;
    }
}

/* Glassmorphism Card */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
    min-height: 44px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

@media screen and (max-width: 768px) {
    .form-control {
        font-size: 16px;
        padding: 0.6rem 0.85rem;
    }
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1e1b4b, transparent),
        radial-gradient(circle at bottom left, #312e81, transparent);
}

.login-card {
    width: 100%;
    max-width: 400px;
}

@media screen and (max-width: 768px) {
    .login-card {
        max-width: 100%;
        margin: 0 1rem;
        padding: 1.5rem;
    }

    .login-card h1 {
        font-size: 1.5rem !important;
    }

    .login-page {
        padding: 1rem 0;
    }
}

@media screen and (max-width: 480px) {
    .login-card {
        margin: 0 0.5rem;
        padding: 1rem;
    }

    .login-card h1 {
        font-size: 1.3rem !important;
    }

    .login-card form {
        width: 100%;
    }

    .form-control {
        font-size: 16px;
        min-height: 44px;
    }

    .btn {
        min-height: 44px;
        width: 100%;
    }
}

/* Dashboard */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--surface-dark);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding-left: 1rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.filters-grid {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
    gap: 1rem;
    align-items: end;
}

@media screen and (max-width: 1024px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media screen and (max-width: 640px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.table-container.stackable-table-wrapper {
    overflow: visible;
    margin: 0;
    padding: 0;
}

.stackable-table {
    width: 100%;
    border-collapse: collapse;
}

@media screen and (max-width: 1024px) {
    .stackable-table {
        min-width: 0;
    }
}

@media screen and (max-width: 768px) {
    .stackable-table thead {
        display: none;
    }

    .stackable-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .stackable-table tr {
        display: flex;
        flex-direction: column;
        padding: 1rem;
        border-radius: var(--radius);
        border: 1px solid var(--glass-border);
        background: rgba(15, 23, 42, 0.85);
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
    }

    .stackable-table td {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        padding: 0 !important;
    }

    .stackable-table td + td {
        margin-top: 0.85rem;
        padding-top: 0.85rem !important;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
    }

    .stackable-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-secondary);
    }

    .stackable-table td[data-label="Actions"] {
        gap: 0.5rem;
    }

    .stackable-table td[data-label="Actions"] > div {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
        gap: 0.4rem !important;
    }

    .stackable-table td[data-label="Actions"] > * {
        width: 100%;
    }

    .stackable-table td[data-label="Actions"] .btn {
        width: 100%;
        justify-content: center;
    }

    .stackable-table td[data-label="Actions"] > a,
    .stackable-table td[data-label="Actions"] > button {
        width: 100%;
        justify-content: center;
    }
}

@media screen and (max-width: 768px) {
    .table-responsive {
        overflow: visible;
    }

    .table-responsive .table {
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    .table-responsive .table thead {
        display: none;
    }

    .table-responsive .table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .table-responsive .table tbody tr {
        display: flex;
        flex-direction: column;
        padding: 1rem;
        border-radius: var(--radius);
        border: 1px solid var(--glass-border);
        background: rgba(15, 23, 42, 0.85);
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
    }

    .table-responsive .table tbody td {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
        padding: 0;
    }

    .table-responsive .table tbody td + td {
        margin-top: 0.85rem;
        padding-top: 0.85rem;
        border-top: 1px solid rgba(148, 163, 184, 0.2);
    }

    .table-responsive .table tbody td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-secondary);
    }

    .table-responsive .table tbody td[data-label="Actions"] .action-buttons,
    .table-responsive .table tbody td[data-label="Actions"] > div {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
        gap: 0.4rem;
    }

    .table-responsive .table tbody td[data-label="Actions"] .btn,
    .table-responsive .table tbody td[data-label="Actions"] select {
        width: 100%;
        justify-content: center;
    }
}

/* Status Badges */
.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-new {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-contacted {
    background-color: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.badge-qualified {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge-won {
    background-color: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.badge-lost {
    background-color: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Dashboard Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Responsive Grids */
.grid-responsive-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.grid-responsive-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.grid-responsive-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.grid-responsive-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

@media screen and (max-width: 768px) {
    .grid-responsive-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-responsive-3 {
        grid-template-columns: 1fr;
    }

    .grid-responsive-2 {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 576px) {
    .grid-responsive-4 {
        grid-template-columns: 1fr;
    }

    .flex-responsive {
        flex-direction: column;
    }
}

.stat-card {
    padding: 1.5rem;
}

.stat-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Notification Styles */
.notification-wrapper {
    position: relative;
    margin-right: 1.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.notification-icon {
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-icon:hover {
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--surface-dark);
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 350px;
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    overflow: hidden;
    animation: fadeIn 0.2s ease-out;
}

.notification-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.02);
}

.mark-all-read {
    font-size: 0.8rem;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.mark-all-read:hover {
    text-decoration: underline;
}

.notification-list {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.05);
    /* Slight tint for unread */
    border-left: 3px solid var(--primary-color);
}

.notification-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.notification-icon-circle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-text {
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.show-dropdown {
    display: block;
}

/* Scrollbar for notification list */
.notification-list::-webkit-scrollbar {
    width: 6px;
}

.notification-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST APPROACH
   ============================================ */

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    outline: none;
    border-radius: var(--radius);
    padding: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 1.5rem;
    line-height: 1;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mobile-menu-toggle:hover {
    transform: translateY(-2px);
}

.mobile-menu-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.5);
}

.sidebar.mobile-open {
    transform: translateX(0);
}

/* Overlay for mobile menu */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   TABLET AND BELOW (max-width: 1024px)
   ============================================ */
@media screen and (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .main-content {
        padding: 1.5rem;
    }

    .sidebar {
        width: 220px;
    }
}

/* ============================================
   TABLET (max-width: 768px)
   ============================================ */
@media screen and (max-width: 768px) {

    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Sidebar becomes slide-in menu */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
    }

    .dashboard-layout {
        flex-direction: column;
    }

    .main-content {
        padding: 1rem;
        margin-top: 60px;
        /* Space for mobile menu button */
    }

    /* Header adjustments */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .header h1 {
        font-size: 1.5rem !important;
    }

    /* Stats Grid - 2 columns on tablet */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    /* Cards */
    .card {
        padding: 1.25rem;
    }

    /* Tables - Horizontal scroll */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1.25rem;
        padding: 0 1.25rem;
    }

    table {
        min-width: 600px;
    }

    th,
    td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    /* Forms */
    .form-control {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Buttons */
    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.95rem;
    }

    /* Login Page */
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }

    /* Notification Dropdown */
    .notification-dropdown {
        width: 320px;
        right: -10px;
    }

    .notification-wrapper {
        margin-right: 0.75rem;
    }

    /* Search and Filter Forms */
    form[method="GET"] {
        width: 100%;
    }

    form[method="GET"] input[type="text"] {
        width: 100% !important;
        max-width: none !important;
    }

    form[method="GET"] select {
        width: auto !important;
        min-width: 120px;
    }
}

/* ============================================
   MOBILE (max-width: 640px)
   ============================================ */
@media screen and (max-width: 640px) {

    /* Typography */
    body {
        font-size: 14px;
    }

    .header h1 {
        font-size: 1.25rem !important;
    }

    /* Stats Grid - Single column on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-title {
        font-size: 0.85rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    /* Cards */
    .card {
        padding: 1rem;
        border-radius: 8px;
    }

    /* Main Content */
    .main-content {
        padding: 0.75rem;
    }

    /* Sidebar */
    .sidebar {
        width: 260px;
    }

    .sidebar-brand {
        font-size: 1.25rem;
        margin-bottom: 2rem;
    }

    /* Navigation Links */
    .nav-link {
        padding: 0.65rem 0.85rem;
        font-size: 0.95rem;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        width: 100%;
    }

    .btn-primary {
        width: 100%;
    }

    /* Header Actions */
    .header .flex {
        width: 100%;
        justify-content: space-between;
    }

    /* Forms */
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-label {
        font-size: 0.85rem;
    }

    .form-control {
        padding: 0.65rem 0.85rem;
        font-size: 16px;
    }

    /* Login Page */
    .login-card {
        margin: 0.75rem;
        padding: 1.25rem;
    }

    .login-card h1 {
        font-size: 1.5rem !important;
    }

    /* Tables */
    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.6rem 0.4rem;
    }

    th {
        font-size: 0.75rem;
    }

    /* Badges */
    .badge {
        padding: 0.2rem 0.6rem;
        font-size: 0.7rem;
    }

    /* Notification Dropdown */
    .notification-dropdown {
        width: calc(100vw - 2rem);
        max-width: 320px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .notification-list {
        max-height: 300px;
    }

    .notification-item {
        padding: 0.85rem;
    }

    .notification-text {
        font-size: 0.85rem;
    }

    .notification-time {
        font-size: 0.7rem;
    }

    /* Search and Filter Forms */
    form[method="GET"] {
        flex-direction: column;
        gap: 0.5rem;
    }

    form[method="GET"] select,
    form[method="GET"] input,
    form[method="GET"] button,
    form[method="GET"] a {
        width: 100% !important;
        max-width: none !important;
    }

    /* Flex utilities for mobile */
    .flex.items-center {
        flex-wrap: wrap;
    }

    .justify-between {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Gap adjustments */
    .gap-4 {
        gap: 0.75rem;
    }

    /* Utility classes for mobile */
    .mobile-full-width {
        width: 100% !important;
    }

    /* Dashboard & Leads Page Specific */
    /* Action buttons in table cells - stack vertically */
    td>div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 0.35rem !important;
    }

    td>div[style*="display: flex"]>a,
    td>div[style*="display: flex"]>button {
        width: 100% !important;
        justify-content: center;
    }

    /* Filter badges - wrap properly */
    .flex.items-center.gap-4 {
        flex-wrap: wrap;
        gap: 0.5rem !important;
    }

    .flex.items-center.gap-4 .badge {
        flex: 0 0 auto;
    }

    /* Header with notification and button */
    .header .flex.items-center {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .header .btn-primary {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Table responsive improvements */
    .table-container table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Make table cells more compact on mobile */
    td ion-icon {
        font-size: 1rem;
    }

    /* Form fields in leads - stack properly */
    .flex.gap-4.mb-4 {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .flex.gap-4.mb-4 .form-group {
        width: 100% !important;
    }

    /* Email Templates Page Specific */
    /* Action buttons in email templates table */
    td>a.btn {
        display: inline-flex;
        margin-bottom: 0.35rem;
        width: auto;
        min-width: 44px;
        /* Touch-friendly size */
    }

    /* Info boxes with code snippets */
    div[style*="background: rgba(99, 102, 241, 0.1)"] {
        font-size: 0.85rem;
        padding: 0.85rem !important;
    }

    div[style*="background: rgba(99, 102, 241, 0.1)"] code {
        font-size: 0.75rem;
        word-break: break-word;
    }

    /* Template form max-width override on mobile */
    .card[style*="max-width: 900px"],
    .card[style*="max-width: 600px"] {
        max-width: 100% !important;
    }

    /* User Management Page Specific */
    /* Action buttons in users table - inline with spacing */
    td>a.btn+a.btn {
        margin-left: 0;
        margin-top: 0.35rem;
    }

    /* Role badges */
    .badge[style*="background: rgba"] {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    /* Password field helper text */
    .form-label {
        font-size: 0.85rem;
        line-height: 1.4;
    }
}

/* ============================================
   SMALL MOBILE (max-width: 480px)
   ============================================ */
@media screen and (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .main-content {
        padding: 0.5rem;
    }

    .card {
        padding: 0.85rem;
    }

    .header h1 {
        font-size: 1.1rem !important;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .sidebar {
        width: 240px;
    }

    .notification-dropdown {
        width: calc(100vw - 1rem);
    }

    /* Compact table for very small screens */
    table {
        min-width: 500px;
    }

    th,
    td {
        padding: 0.5rem 0.3rem;
        font-size: 0.8rem;
    }
}

/* ============================================
   EXTRA SMALL MOBILE (max-width: 375px)
   ============================================ */
@media screen and (max-width: 375px) {
    .login-card {
        margin: 0.5rem;
        padding: 1rem;
    }

    .sidebar {
        width: 220px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .btn {
        padding: 0.55rem 0.85rem;
        font-size: 0.85rem;
    }
}

/* ============================================
   LANDSCAPE MOBILE (max-height: 500px)
   ============================================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .login-page {
        padding: 1rem 0;
    }

    .login-card {
        margin: 0.5rem auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    .sidebar {
        padding: 1rem 0.75rem;
    }

    .sidebar-brand {
        margin-bottom: 1.5rem;
    }
}

/* ============================================
   UNIVERSAL RESPONSIVE FIXES FOR ALL PAGES
   ============================================ */

/* Ensure all containers are responsive */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

@media screen and (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 15px;
    }
}

@media screen and (max-width: 768px) {
    .container {
        padding: 0 12px;
    }
}

@media screen and (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
}

/* Ensure all buttons are touch-friendly */
button,
.btn,
a[class*="btn"],
input[type="button"],
input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    transition: all 0.2s ease;
}

/* Ensure all inputs are touch-friendly */
input,
textarea,
select {
    font-size: 16px;
    min-height: 44px;
    box-sizing: border-box;
}

/* Fix images to be responsive */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Fix action grids */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

@media screen and (max-width: 768px) {
    .action-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.75rem;
    }
}

@media screen and (max-width: 480px) {
    .action-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Improve modal responsiveness */
.modal-content {
    max-width: 90vw !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

@media screen and (max-width: 480px) {
    .modal-content {
        margin: 1rem auto !important;
        border-radius: 8px !important;
    }
}

/* Better notification dropdown on mobile */
@media screen and (max-width: 768px) {
    .notification-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 70vh !important;
        border-radius: 12px 12px 0 0 !important;
        width: 100% !important;
    }
}

/* Ensure consistent spacing */
@media screen and (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .sidebar,
    .mobile-menu-toggle,
    .notification-wrapper,
    .btn,
    form[method="GET"] {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .card {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ============================================ */

/* Mobile devices (up to 640px) */
@media (max-width: 640px) {
    .container {
        padding: 0 15px;
    }

    .header {
        padding: 1rem;
    }

    .header h1 {
        font-size: 1.25rem !important;
    }

    /* Grid layouts - stack on mobile */
    .grid,
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* Form groups */
    .form-group {
        margin-bottom: 1rem;
    }

    /* Cards */
    .card {
        padding: 1rem !important;
        margin-bottom: 1rem;
    }

    /* Tables - make scrollable */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Stats grid */
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    /* Buttons */
    .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    /* Hero sections */
    [style*="font-size: 2.5rem"] {
        font-size: 1.75rem !important;
    }

    /* Notification dropdown */
    .notification-dropdown {
        right: 0;
        left: auto;
        width: 90vw;
        max-width: 350px;
    }

    /* Action bars */
    [style*="justify-content: space-between"] {
        flex-direction: column;
        gap: 1rem;
    }

    /* Scope table */
    #scope-table-body tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    #scope-table-body td {
        padding: 0.5rem 0 !important;
    }

    /* Commercial table */
    #commercial-table-body tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 8px;
        margin-bottom: 1rem;
    }

    /* Hide table headers on mobile, show labels instead */
    .table-container thead {
        display: none;
    }

    /* Add labels to table cells */
    .table-container td::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25rem;
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    /* Payment terms boxes */
    [style*="display: flex; gap: 20px"] {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* Tools grid */
    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: 1fr !important;
    }
}

/* Tablets (641px to 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
    .container {
        padding: 0 20px;
    }

    /* 2-column grids on tablet */
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tables */
    .table-container {
        overflow-x: auto;
    }

    table {
        min-width: 100%;
    }

    /* Cards */
    .card {
        padding: 1.5rem;
    }
}

/* Large tablets and small desktops (1025px to 1280px) */
@media (min-width: 1025px) and (max-width: 1280px) {
    .container {
        max-width: 1024px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 896px) and (orientation: landscape) {
    .header {
        padding: 0.75rem 1rem;
    }

    .card {
        padding: 1rem;
    }

    [style*="margin-bottom: 2rem"] {
        margin-bottom: 1rem !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    .btn,
    button,
    a {
        min-height: 44px;
        min-width: 44px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--border-color);
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Dark mode support (if system prefers dark) */
@media (prefers-color-scheme: dark) {
    :root {
        --background-dark: #0a0f1e;
        --surface-dark: #151b2e;
    }
}

/* ============================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ============================================ */

/* Mobile-specific proposal form improvements */
@media screen and (max-width: 640px) {

    /* Notification button - better touch target */
    .notification-btn {
        padding: 0.75rem;
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Action bar - stack buttons vertically */
    [style*="display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 0"] {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }

    [style*="display: flex; gap: 1.5rem; align-items: center"] {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    /* Save as Draft and Generate buttons */
    button[name="save_draft"],
    button[name="create_proposal"] {
        width: 100% !important;
        padding: 0.85rem 1.5rem !important;
        font-size: 1rem !important;
    }

    /* Discard Draft button */
    button[onclick="window.history.back()"] {
        width: 100% !important;
        order: 3;
    }

    /* Format selector */
    [style*="display: flex; gap: 0.75rem; align-items: center; color: var(--text-secondary)"] {
        width: 100%;
        justify-content: center;
        padding: 0.5rem;
        background: rgba(255, 255, 255, 0.02);
        border-radius: 8px;
    }

    /* Step headers - reduce font size */
    .card h3 {
        font-size: 1.1rem !important;
    }

    .card [style*="font-size: 1.25rem"] {
        font-size: 1.1rem !important;
    }

    /* Icon containers in step headers */
    .card [style*="width: 32px; height: 32px"] {
        width: 28px !important;
        height: 28px !important;
        font-size: 0.9rem !important;
    }

    /* Step numbers */
    .card [style*="STEP"] {
        font-size: 0.7rem !important;
    }

    /* Tools and Standards grid - single column */
    [style*="grid-template-columns: repeat(auto-fill, minmax(250px, 1fr))"],
    [style*="grid-template-columns: repeat(auto-fill, minmax(280px, 1fr))"] {
        grid-template-columns: 1fr !important;
    }

    /* Checkbox items - better spacing */
    [style*="display: flex; align-items: flex-start; gap: 0.75rem"] {
        gap: 0.5rem;
    }

    /* Hero section text */
    [style*="font-size: 2.5rem"] {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }

    [style*="font-size: 1.8rem"] {
        font-size: 1.3rem !important;
    }

    /* Stats cards - 4 column to 2 column */
    [style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    /* Stat card content */
    [style*="font-size: 1.5rem; font-weight: 800"] {
        font-size: 1.25rem !important;
    }

    /* Previous proposals table */
    .table-container table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Recent proposals section */
    [style*="max-width: 1000px; margin: 4rem auto"] {
        margin: 2rem auto !important;
    }

    /* Deliverables dropdown and button */
    [style*="display: flex; gap: 10px; margin-bottom: 12px"] {
        flex-direction: column;
        gap: 0.5rem;
    }

    [style*="display: flex; gap: 10px; margin-bottom: 12px"] button {
        width: 100%;
    }

    /* Scope table - card layout on mobile */
    .scope-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 1rem !important;
        background: rgba(255, 255, 255, 0.03) !important;
        border-radius: 8px !important;
        margin-bottom: 0.75rem !important;
    }

    .scope-row td {
        display: block !important;
        padding: 0 !important;
        border: none !important;
    }

    .scope-row td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
        margin-bottom: 0.25rem;
    }

    /* Hide scope table header on mobile */
    #scope-table-body {
        display: block;
    }

    .table thead {
        display: none;
    }

    /* Client information grid */
    [style*="display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Prepared By section */
    [style*="grid-column: span 2"] {
        grid-column: span 1 !important;
    }

    /* Payment terms boxes */
    [style*="flex: 1; background: #f0fdf4"] {
        flex: none !important;
        width: 100% !important;
    }

    /* Investment includes list */
    [style*="display: grid; grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Sample reports grid */
    [style*="display: grid; grid-template-columns: 1fr 1fr; gap: 20px"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Footer info */
    [style*="display: flex; justify-content: center; gap: 2rem"] {
        flex-direction: column !important;
        gap: 0.75rem !important;
        align-items: flex-start !important;
    }
}

/* Very small mobile devices */
@media screen and (max-width: 375px) {

    /* Further reduce padding */
    .card {
        padding: 0.75rem !important;
    }

    .main-content {
        padding: 0.5rem !important;
    }

    /* Smaller buttons */
    .btn {
        padding: 0.65rem 1rem !important;
        font-size: 0.9rem !important;
    }

    /* Stats grid - single column */
    [style*="grid-template-columns: repeat(4, 1fr)"],
    [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }

    /* Notification dropdown - full width */
    .notification-dropdown {
        width: calc(100vw - 1rem) !important;
        left: 0.5rem !important;
        right: 0.5rem !important;
        transform: none !important;
    }
}

/* Tablet portrait */
@media screen and (min-width: 641px) and (max-width: 768px) {

    /* Stats - 2 columns */
    [style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Tools and Standards - 2 columns */
    [style*="grid-template-columns: repeat(auto-fill, minmax(250px, 1fr))"],
    [style*="grid-template-columns: repeat(auto-fill, minmax(280px, 1fr))"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Action bar - keep horizontal but wrap */
    [style*="display: flex; gap: 1.5rem; align-items: center"] {
        flex-wrap: wrap;
    }
}

/* Landscape mobile */
@media screen and (max-width: 896px) and (orientation: landscape) {

    /* Reduce vertical spacing */
    .card {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    [style*="margin-bottom: 2rem"] {
        margin-bottom: 1rem !important;
    }

    [style*="margin-top: 2rem"] {
        margin-top: 1rem !important;
    }

    /* Compact header */
    .header {
        padding: 0.75rem 0 !important;
    }

    /* Sidebar - reduce padding */
    .sidebar {
        padding: 1rem 0.75rem !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {

    /* Fix for iOS input zoom */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Fix for iOS sticky position */
    .notification-dropdown {
        position: absolute;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {

    /* Better touch targets */
    .btn,
    button,
    a {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
}

/* Ensure mobile menu works */
@media screen and (max-width: 768px) {

    /* Mobile menu button */
    .notification-btn {
        background: transparent;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        position: relative;
    }

    /* Better dropdown positioning on mobile */
    .notification-dropdown {
        position: fixed !important;
        top: 60px !important;
        right: 10px !important;
        left: 10px !important;
        width: auto !important;
        max-width: none !important;
        transform: none !important;
    }
}

/* ============================= COMPREHENSIVE RESPONSIVE DESIGN ============================= */

/* Touch Target Sizes (48px minimum) */
.btn, button, a.btn, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
}

input[type="checkbox"], input[type="radio"] {
    min-width: 18px;
    min-height: 18px;
    cursor: pointer;
}

/* Responsive Typography with Clamp */
html {
    font-size: clamp(14px, 2vw, 16px);
}

h1 {
    font-size: clamp(1.5rem, 5vw, 3rem);
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.3rem, 4vw, 2.2rem);
    line-height: 1.2;
}

h3 {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    line-height: 1.3;
}

h4, h5, h6 {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

p {
    font-size: clamp(0.9rem, 2vw, 1rem);
    line-height: 1.6;
}

/* ===== Tablet Landscape (1024px - 1439px) ===== */
@media (min-width: 1024px) and (max-width: 1439px) {
    .container {
        max-width: 1000px;
        padding: 0 1.5rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .grid-responsive-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-responsive-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-responsive-4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .sidebar {
        width: 200px;
        padding: 1.5rem 1rem;
    }
    
    .sidebar-brand {
        font-size: 1.3rem;
    }
    
    .nav-link {
        font-size: 0.95rem;
        padding: 0.75rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 1rem !important;
    }
}

/* ===== Tablet Portrait (768px - 1023px) ===== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .dashboard-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        display: grid;
        grid-template-columns: auto 1fr;
        align-items: center;
        gap: 2rem;
    }
    
    .sidebar-brand {
        font-size: 1.2rem;
    }
    
    .sidebar nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.75rem;
        font-size: 0.9rem;
        text-align: center;
    }
    
    .main-content {
        flex: 1;
        padding: 1.5rem 1rem;
    }
    
    .grid-responsive-2 {
        grid-template-columns: 1fr;
    }
    
    .grid-responsive-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-responsive-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem;
        padding: 0 1rem;
        border-radius: 0;
    }
    
    table {
        font-size: 0.85rem;
        min-width: 600px;
    }
    
    th, td {
        padding: 0.75rem !important;
    }
    
    .btn {
        padding: 0.65rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .form-control {
        font-size: 1rem;
        padding: 0.7rem;
    }
}

/* ===== Large Mobile / Small Tablet (481px - 767px) ===== */
@media (min-width: 481px) and (max-width: 767px) {
    body {
        font-size: 15px;
    }
    
    .container {
        padding: 0 0.75rem;
    }
    
    .card {
        padding: 0.875rem;
        margin-bottom: 0.75rem;
    }
    
    .dashboard-layout {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        border: none;
        padding: 1.25rem 1rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .sidebar nav {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.5rem;
        font-size: 0.85rem;
        text-align: center;
    }
    
    .main-content {
        padding: 1rem 0.75rem;
    }
    
    .header {
        padding: 0.75rem;
        flex-wrap: wrap;
    }
    
    .header h1 {
        font-size: 1.3rem;
        flex-basis: 100%;
    }
    
    .grid-responsive-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .grid-responsive-3 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .grid-responsive-4 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-control {
        padding: 0.65rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        min-height: 44px;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    table {
        font-size: 0.8rem;
        min-width: 500px;
    }
    
    th, td {
        padding: 0.5rem !important;
    }
    
    .alert {
        padding: 0.75rem;
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }
}

/* ===== Mobile Phones (up to 480px) ===== */
@media (max-width: 480px) {
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    .container {
        max-width: 100%;
        padding: 0 0.5rem;
    }
    
    .card {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
    }
    
    .dashboard-layout {
        flex-direction: column;
    }
    
    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 240px;
        border: none;
        padding: 1.25rem 1rem;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    
    .sidebar-brand {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .sidebar nav {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
        text-align: left;
    }
    
    .icon {
        display: inline-flex;
        margin-bottom: 0;
    }
    
    .main-content {
        padding: 0.75rem 0.5rem;
    }
    
    /* Header Mobile */
    .header {
        padding: 0.75rem 0.5rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
        flex-basis: 100%;
        margin: 0;
    }
    
    /* Grids */
    .grid-responsive-2,
    .grid-responsive-3,
    .grid-responsive-4,
    .grid-responsive-auto {
        grid-template-columns: 1fr !important;
        gap: 0.5rem;
    }
    
    /* Forms */
    .form-group {
        margin-bottom: 0.75rem;
    }
    
    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.35rem;
    }
    
    .form-control {
        width: 100%;
        padding: 0.6rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        border-radius: 6px;
    }
    
    textarea.form-control {
        min-height: 80px;
        resize: vertical;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        min-height: 44px;
        min-width: 44px;
        border-radius: 6px;
    }
    
    .btn-sm {
        padding: 0.5rem 0.6rem;
        font-size: 0.7rem;
        min-height: 36px;
    }
    
    .btn span {
        display: none;
    }
    
    .btn ion-icon {
        font-size: 1rem;
    }
    
    /* Tables */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -0.75rem;
        border-radius: 0;
    }
    
    table {
        font-size: 0.7rem;
        width: 100%;
        min-width: 400px;
        border-collapse: collapse;
    }
    
    th, td {
        padding: 0.4rem !important;
        text-align: left;
    }
    
    th {
        background: rgba(0, 0, 0, 0.2);
        font-weight: 600;
    }
    
    /* Alerts */
    .alert {
        padding: 0.6rem;
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
        border-radius: 6px;
    }
    
    /* Input Types */
    input[type="checkbox"],
    input[type="radio"] {
        width: 18px;
        height: 18px;
        margin: 0 0.35rem 0 0;
    }
    
    /* Modals */
    .modal {
        padding: 0.5rem;
    }
    
    .modal-content {
        border-radius: 8px;
        max-width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Notifications */
    .notification-dropdown {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        max-height: 70vh !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    /* Dropdowns */
    select {
        font-size: 16px; /* Prevents zoom */
        min-height: 44px;
    }
    
    /* Flexbox Utilities */
    .flex-wrap {
        flex-wrap: wrap;
    }
    
    .justify-center {
        justify-content: center;
    }
    
    /* Show mobile menu toggle */
    .mobile-menu-toggle {
        display: flex;
    }
}

/* ===== Ultra-Wide Screens (1440px+) ===== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px;
    }
    
    .card {
        padding: 2.5rem;
    }
    
    .grid-responsive-2 {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
    
    .grid-responsive-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-responsive-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== Landscape Orientation Mobile ===== */
@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        width: 180px !important;
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        z-index: 100;
    }
    
    .main-content {
        margin-left: 180px;
    }
    
    .card {
        margin-bottom: 0.5rem;
    }
    
    table {
        font-size: 0.75rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .header, .sidebar, .nav-link, .btn {
        display: none;
    }
    
    .card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    table {
        page-break-inside: avoid;
    }
}