/* =================================================================
   MODERN CRM - PROFESSIONAL CLEAN DESIGN
   Based on Qolay App Design
   ================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ====================== VARIABLES ====================== */
:root {
    --primary: #6366f1;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    
    --bg-body: #f5f5f7;
    --bg-white: #ffffff;
    --bg-sidebar: #1e1e3f;
    
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-sidebar: #e5e7eb;
    
    --border: #e5e7eb;
    
    --sidebar-width: 240px;
    --topbar-height: 60px;
    
    --purple-light: #e9d5ff;
    --blue-light: #dbeafe;
    --green-light: #d1fae5;
    --orange-light: #fed7aa;
}

/* ====================== RESET ====================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-body);
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ====================== LOGIN PAGE ====================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: #1a1a2e;
}

.login-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    max-height: 700px;
    display: flex;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 80px rgba(0,0,0,0.3);
    margin: 20px;
}

.login-left {
    flex: 1;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    position: relative;
}

.login-illustration {
    max-width: 100%;
    height: auto;
}

.login-illustration img {
    width: 100%;
    height: auto;
}

.login-right {
    flex: 1;
    padding: 60px 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
}

.login-box {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.login-box h1 {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
    line-height: 1.2;
}

.login-box .subtitle {
    font-size: 15px;
    color: #6b7280;
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #374151;
    margin-bottom: 8px;
    font-weight: 500;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    color: #9ca3af;
    pointer-events: none;
}

.input-icon svg {
    width: 20px;
    height: 20px;
}

.login-box .form-group input {
    width: 100%;
    height: 52px;
    padding: 0 48px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    background: #f9fafb;
    color: #1f2937;
    transition: all 0.3s;
}

.login-box .form-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.login-box .form-group input::placeholder {
    color: #9ca3af;
}

.password-toggle {
    position: absolute;
    right: 16px;
    color: #9ca3af;
    cursor: pointer;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.forgot-password {
    display: block;
    text-align: right;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 24px;
    margin-top: -8px;
}

.forgot-password:hover {
    text-decoration: underline;
}

.btn-login {
    width: 100%;
    height: 52px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.btn-login:hover {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.alert {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 24px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

/* ====================== APP LAYOUT ====================== */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--bg-body);
}

/* ====================== SIDEBAR ====================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.sidebar-menu {
    padding: 20px 12px;
}

.menu-section {
    margin-bottom: 8px;
}

.menu-label {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 12px;
    margin-bottom: 8px;
    display: block;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-sidebar);
    border-radius: 8px;
    margin-bottom: 4px;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: 500;
}

.menu-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item.active {
    background: var(--primary);
    color: white;
}

.badge-mini {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 3px 7px;
    border-radius: 10px;
    font-weight: 600;
}

/* ====================== TOPBAR ====================== */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.menu-toggle {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: none;
}

.menu-toggle:hover {
    background: #f3f4f6;
}

.company-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
}

.company-selector:hover {
    background: #f3f4f6;
}

.company-icon {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

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

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

.topbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.topbar-btn:hover {
    background: #f3f4f6;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.user-menu:hover {
    background: #f3f4f6;
}

.user-menu img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

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

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

.user-role {
    font-size: 11px;
    color: var(--text-light);
}

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

.page-content {
    padding: 24px;
    flex: 1;
}

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

.content-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.content-header p {
    font-size: 13px;
    color: var(--text-light);
}

/* ====================== STATS GRID ====================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: var(--purple-light);
    color: #7c3aed;
}

.stat-icon.blue {
    background: var(--blue-light);
    color: #2563eb;
}

.stat-icon.green {
    background: var(--green-light);
    color: #059669;
}

.stat-icon.orange {
    background: var(--orange-light);
    color: #ea580c;
}

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.stat-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-link {
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
}

.stat-link:hover {
    text-decoration: underline;
}

/* ====================== CARDS ====================== */
.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

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

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

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

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

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
}

.dashboard-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.dashboard-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.summary-section {
    background: #f3f4f6;
    border: none;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.summary-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #6366f1;
    margin-bottom: 12px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
}

.summary-row .label {
    color: var(--text-secondary);
}

.summary-row .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ====================== TABLES ====================== */
.table-responsive {
    overflow-x: auto;
}

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

thead {
    background: #f9fafb;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-primary);
}

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

tbody tr:hover {
    background: #f9fafb;
}

/* ====================== BUTTONS ====================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #4f46e5;
}

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

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

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

.btn-link {
    background: none;
    color: var(--primary);
    padding: 4px 8px;
}

.btn-link:hover {
    background: #f3f4f6;
}

.btn-icon {
    padding: 8px;
    min-width: auto;
}

.btn-icon svg {
    display: block;
}

/* ====================== BADGES ====================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-secondary {
    background: #f3f4f6;
    color: var(--text-secondary);
}

/* ====================== FORMS ====================== */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input:not(.login-box input),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

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

/* ====================== MODAL ====================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.modal .close {
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

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

.modal form {
    padding: 24px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

/* ====================== INFO BOX ====================== */
.info-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.info-box h3 {
    font-size: 16px;
    font-weight: 600;
    color: #0c4a6e;
    margin-bottom: 12px;
}

.info-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-box ul li {
    padding: 8px 0 8px 24px;
    position: relative;
    font-size: 14px;
    color: #334155;
}

.info-box ul li:before {
    content: "ℹ️";
    position: absolute;
    left: 0;
}

/* ====================== FILTER BUTTONS ====================== */
.filter-buttons {
    display: flex;
    gap: 8px;
}

/* ====================== INVOICE VIEW ====================== */
.invoice-view-container {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.invoice-info-card {
    margin-bottom: 24px;
}

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

.info-grid label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-grid p {
    font-size: 14px;
    color: var(--text-primary);
    margin-top: 4px;
}

/* Customer Detail Page Specific */
.customer-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.currency-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    padding: 20px;
}

.customer-info-grid {
    grid-template-columns: 1fr 1fr;
}

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

.currency-card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 13px;
}

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

/* ====================== FOOTER ====================== */
.app-footer {
    background: #f9fafb;
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 100%;
}

.footer-text {
    color: var(--text-secondary);
    font-size: 12px;
    margin: 0;
}

.footer-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

.footer-credit {
    color: var(--text-secondary);
    font-size: 12px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-credit strong {
    color: var(--primary);
    font-weight: 600;
}

.footer-icon {
    font-size: 14px;
}

/* ====================== UTILITIES ====================== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* ====================== TOAST ANIMATIONS ====================== */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

/* ====================== INVOICE ITEMS ====================== */
.invoice-item .form-grid {
    align-items: end;
}

/* ====================== RESPONSIVE ====================== */

/* Tablet - 1024px and below */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }
    
    .dashboard-grid,
    .dashboard-grid-2col {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .page-content {
        padding: 20px;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .content-header h1 {
        font-size: 22px;
    }
    
    .invoice-item .form-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .app-footer {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* Mobile - 768px and below */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
        width: 100%;
    }
    
    body {
        position: relative;
    }
    
    /* Global overflow fix */
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Login Page */
    .login-container {
        flex-direction: column;
        height: auto;
        max-height: none;
        margin: 10px;
        border-radius: 16px;
    }
    
    .login-left {
        display: none;
    }
    
    .login-right {
        padding: 40px 24px;
    }
    
    .login-box h1 {
        font-size: 26px;
    }
    
    /* Sidebar - Full overlay with backdrop */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
        width: 280px;
        max-width: 85vw;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Hide sidebar brand icon on mobile */
    .sidebar-brand {
        padding: 0 16px;
    }
    
    /* Backdrop for sidebar */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-backdrop.active {
        display: block;
    }
    
    /* Main wrapper */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    /* Topbar adjustments */
    .topbar {
        padding: 0 12px;
        height: 56px;
        width: 100%;
        max-width: 100vw;
    }
    
    :root {
        --topbar-height: 56px;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .company-selector {
        display: none;
    }
    
    .topbar-right {
        gap: 6px;
    }
    
    .topbar-btn {
        width: 32px;
        height: 32px;
    }
    
    .user-menu {
        padding: 4px;
    }
    
    .user-info {
        display: none;
    }
    
    /* Content */
    .page-content {
        padding: 16px 12px;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .content-header {
        margin-bottom: 16px;
        max-width: 100%;
    }
    
    .content-header h1 {
        font-size: 20px;
        word-break: break-word;
    }
    
    .content-header p {
        font-size: 12px;
        word-break: break-word;
    }
    
    /* Alerts - Prevent overflow */
    .alert {
        padding: 12px 14px;
        font-size: 13px;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 16px;
        max-width: 100%;
    }
    
    .stat-card {
        padding: 16px;
        gap: 12px;
        max-width: 100%;
    }
    
    .stat-icon {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    
    .stat-content h3 {
        font-size: 24px;
        word-break: break-word;
    }
    
    .stat-content p {
        font-size: 12px;
        word-break: break-word;
    }
    
    /* Cards */
    .card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 10px;
        max-width: 100%;
        overflow: hidden;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 16px;
        padding-bottom: 12px;
    }
    
    .card-header h2 {
        font-size: 15px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .section-header h2 {
        font-size: 15px;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        padding: 0;
        scrollbar-width: thin;
        scrollbar-color: #d1d5db #f3f4f6;
        max-width: 100%;
        width: 100%;
    }
    
    .table-responsive::-webkit-scrollbar {
        height: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f3f4f6;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #9ca3af;
    }
    
    .table-responsive table {
        min-width: 100%;
        width: max-content;
    }
    
    th {
        padding: 10px 6px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    td {
        padding: 12px 6px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 14px;
        font-size: 13px;
        white-space: normal;
        min-height: 44px; /* Touch friendly */
        text-align: center;
        word-break: break-word;
    }
    
    .btn-sm {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 36px;
        white-space: normal;
        word-break: break-word;
    }
    
    .filter-buttons {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    /* Forms */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .invoice-item .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    .form-group label {
        font-size: 12px;
    }
    
    .form-group input:not(.login-box input),
    .form-group select,
    .form-group textarea {
        font-size: 13px;
        min-height: 44px; /* Touch friendly */
    }
    
    /* Modal - Full screen on mobile */
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        animation: slideUp 0.3s ease-out;
    }
    
    @keyframes slideUp {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
    
    .modal-header {
        padding: 16px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .modal form {
        padding: 16px;
        overflow-y: auto;
    }
    
    /* Dashboard specific */
    .dashboard-section {
        padding: 16px;
        max-width: 100%;
    }
    
    .dashboard-grid,
    .dashboard-grid-2col {
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 100%;
    }
    
    .dashboard-full-width {
        grid-column: 1;
        max-width: 100%;
    }
    
    .summary-section {
        padding: 12px 16px;
        margin-bottom: 12px;
    }
    
    .summary-section h3 {
        font-size: 13px;
    }
    
    .summary-row {
        font-size: 12px;
    }
    
    /* Invoice view */
    .invoice-view-container {
        padding: 16px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* Info box */
    .info-box {
        padding: 16px;
        margin-top: 16px;
    }
    
    .info-box h3 {
        font-size: 14px;
    }
    
    .info-box ul li {
        font-size: 13px;
    }
    
    /* Badge */
    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    /* Form actions */
    .form-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    /* Chart containers */
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Action button groups */
    .content-header > div:last-child {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    /* Customer Detail Page - Mobile fixes */
    .customer-detail-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .customer-detail-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .currency-cards-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 16px 0;
    }
    
    .customer-info-grid {
        grid-template-columns: 1fr;
    }
    
    .info-full-width {
        grid-column: 1;
    }
    
    .currency-card-details {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .card-header-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .card-header-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    .content-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Invoice/Payment cards in detail pages */
    .invoice-view-container {
        border-radius: 8px;
    }
    
    /* Hide long text, show ellipsis */
    .user-name,
    .company-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* Breadcrumb */
    .breadcrumb {
        font-size: 11px;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Status badges should wrap */
    .badge {
        white-space: nowrap;
    }
    
    /* Footer */
    .app-footer {
        padding: 16px 12px;
        margin-left: 0;
        width: 100%;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .footer-text,
    .footer-credit {
        font-size: 12px;
    }
}

/* Small Mobile - 480px and below */
@media (max-width: 480px) {
    .login-right {
        padding: 30px 20px;
    }
    
    .login-box h1 {
        font-size: 24px;
    }
    
    .login-box .subtitle {
        font-size: 14px;
    }
    
    .login-box .form-group input {
        height: 48px;
        font-size: 14px;
    }
    
    .btn-login {
        height: 48px;
        font-size: 15px;
    }
    
    .topbar {
        padding: 0 10px;
    }
    
    .page-content {
        padding: 12px 10px;
    }
    
    .content-header h1 {
        font-size: 18px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .stat-content h3 {
        font-size: 22px;
    }
    
    .stat-content p {
        font-size: 11px;
    }
    
    .card {
        padding: 12px;
        border-radius: 8px;
    }
    
    .card-header {
        padding-bottom: 10px;
        margin-bottom: 12px;
    }
    
    .card-header h2 {
        font-size: 14px;
    }
    
    .table-responsive {
        margin: 0 -12px;
        padding: 0 12px;
    }
    
    th {
        padding: 8px 6px;
        font-size: 9px;
    }
    
    td {
        padding: 10px 6px;
        font-size: 11px;
    }
    
    .btn {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .btn-sm {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .modal-header {
        padding: 12px;
    }
    
    .modal form {
        padding: 12px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
        max-width: 90vw;
    }
    
    .user-menu img {
        width: 28px;
        height: 28px;
    }
}

/* Landscape mobile fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .login-container {
        margin: 10px;
    }
    
    .login-right {
        padding: 30px 24px;
    }
    
    .modal-content {
        height: auto;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Fix horizontal overflow */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }
    
    .app-container {
        overflow-x: hidden;
        width: 100%;
    }
    
    * {
        max-width: 100%;
    }
    
    img {
        max-width: 100%;
        height: auto;
    }
}

/* Touch-friendly improvements for all mobile devices */
@media (max-width: 768px) and (hover: none) {
    /* Minimum touch target size */
    .btn,
    .topbar-btn,
    .menu-toggle,
    .menu-item,
    a,
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .stat-card:hover,
    .card:hover,
    tr:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Better tap highlights */
    * {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1);
    }
    
    /* Smooth scrolling */
    html {
        scroll-behavior: smooth;
    }
    
    /* Better input focus on mobile */
    input:focus,
    select:focus,
    textarea:focus {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
