/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366F1;
    --primary-dark: #4F46E5;
    --primary-light: #818CF8;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --success-color: #10B981;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --border-color: #E2E8F0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px -5px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #F8FAFC 0%, #EEF2FF 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    border: none;
}

/* Banner */
.banner {
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.05) 100%);
    padding: 16px 20px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: relative;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
}

.banner-icons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.banner-icon-box {
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.banner-icon-box i {
    font-size: 1.3rem;
    color: #ffffff;
}

.banner-icon-box:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.banner-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    gap: 0;
    margin: 2px 0;
}

.banner-title h1 {
    font-size: clamp(1.8rem, 5vw, 3.2rem);
    font-weight: 500;
    letter-spacing: 3px;
    color: white;
    text-shadow: 0 2px 20px rgba(0,0,0,0.3);
    text-transform: uppercase;
}

/* Stats row */
.header-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    background: rgba(255,255,255,0.1);
    padding: 16px 24px;
    backdrop-filter: blur(10px);
}

.stat-card {
    background: transparent;
    padding: 12px 20px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    transition: all 0.3s ease;
    border-right: 1px solid rgba(255,255,255,0.15);
}

.stat-card:last-child {
    border-right: none;
}

.stat-card:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

.stat-flash {
    animation: statPop 0.8s ease;
}

@keyframes statPop {
    0%   { background: transparent; }
    30%  { background: rgba(255,255,255,0.7); transform: scale(1.04); }
    60%  { background: rgba(255,255,255,0.5); }
    100% { background: transparent; transform: scale(1); }
}

.stat-card i {
    font-size: 2rem;
    color: #ffffff;
    opacity: 0.9;
}

.stat-card div {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.85);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 500;
    color: #ffffff;
    text-align: center;
}

/* Navigation Styles */
.nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    flex: 1;
    min-width: 150px;
    padding: 14px 22px;
    background: var(--card-bg);
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.nav-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: #F8FAFC;
}

.nav-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-lg);
}

.nav-btn i {
    font-size: 1.15rem;
}

/* Section Styles */
.section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.section.active {
    display: block;
}

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

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

.section-header h2 {
    font-size: 1.75rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 45px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-select {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Custom Table Styles */
.custom-table-container {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
    width: 100%;
}

/* Inner scroll wrapper — only this scrolls horizontally */
.custom-table-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    width: 100%;
}

.custom-table-header {
    display: grid;
    grid-template-columns: 50px 80px 2fr 70px 80px 80px 80px 80px 100px 120px;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding-right: 0;
    box-sizing: border-box;
}

/* Custom scrollbar for table body */
.custom-table-body::-webkit-scrollbar {
    width: 8px;
}

.custom-table-body::-webkit-scrollbar-track {
    background: #F1F5F9;
}

.custom-table-body::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

.custom-table-body::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

.custom-table-body {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.custom-table-header .table-col {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-right: 1px solid var(--border-color);
    font-weight: 600;
}

.custom-table-header .table-col:last-child {
    border-right: none;
}

.custom-table-header .table-col i {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* Table row transitions - optimized for performance */
.table-row {
    display: grid;
    grid-template-columns: 50px 80px 2fr 70px 80px 80px 80px 80px 100px 120px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
    font-size: 15px;
    font-weight: 400;
    cursor: pointer;
    will-change: background-color;
}

.table-row:hover {
    background: linear-gradient(135deg, #FAFBFC 0%, #F8FAFC 100%);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.table-row.row-selected {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

.table-row.row-out-of-stock.row-selected {
    background-color: #FEE2E2;
    outline-color: var(--danger-color);
}

.table-row.row-out-of-stock {
    background-color: #FEF2F2;
    opacity: 0.75;
}

.table-row.row-out-of-stock:hover {
    background-color: #FEE2E2;
}

.table-col {
    display: flex;
    align-items: center;
    padding: 20px 16px;
    gap: 10px;
    border-right: 1px solid #F3F4F6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.table-col:last-child {
    border-right: none;
}

/* Checkbox column */
.col-check {
    width: 44px;
    justify-content: center;
}

.row-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--danger-color);
}

.col-total     { font-weight: 400; color: var(--primary-color); font-size: 15px; }
.col-product   { font-weight: 400; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.col-box, .col-inside, .col-ea, .col-sp, .col-profit, .col-profit-plus { justify-content: center; text-align: center; }
.col-profit    { font-weight: 400; color: var(--success-color); }
.col-profit-plus { font-weight: 400; color: var(--primary-color); font-size: 15px; }
.col-edit {
    justify-content: center;
    gap: 8px;
}
.col-actions {
    justify-content: center;
    gap: 8px;
    overflow: visible !important;
    min-width: 120px;
    width: 120px;
    flex-shrink: 0;
}

/* Out of stock badge */
.oos-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 400;
    vertical-align: middle;
    white-space: nowrap;
}

/* Cog settings button */
.cog-btn {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    cursor: pointer;
    color: var(--primary-color);
    font-size: 1rem;
    padding: 8px 10px;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cog-btn:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
    transform: rotate(90deg);
    box-shadow: var(--shadow-md);
}

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

/* Table settings dropdown - optimized positioning */
.table-settings-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-xl);
    z-index: 999;
    padding: 8px;
    animation: fadeInDown 0.2s ease;
    will-change: transform, opacity;
}

.table-settings-menu.open {
    display: block;
}

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

.settings-menu-title {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    padding: 4px 14px 6px;
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    font-weight: 400;
}

.settings-menu-item:hover {
    background: #F3F4F6;
}

.settings-menu-item input[type="checkbox"] {
    accent-color: var(--primary-color);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.settings-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

.settings-menu-action {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
    font-weight: 400;
}

.settings-menu-action:hover {
    background: #F3F4F6;
}

.settings-menu-action.danger {
    color: var(--danger-color);
}

.settings-menu-action.danger:hover {
    background: #FEF2F2;
}

.table-action-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 400;
    box-shadow: var(--shadow);
}

.table-action-btn i {
    font-size: 0.9rem;
}

.table-action-btn.edit {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    color: #1E40AF;
}

.table-action-btn.edit:hover {
    background: linear-gradient(135deg, #BFDBFE 0%, #93C5FD 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.table-action-btn.delete {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    color: #991B1B;
}

.table-action-btn.delete:hover {
    background: linear-gradient(135deg, #FECACA 0%, #FCA5A5 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Responsive Table */
@media (max-width: 1200px) {
    .custom-table-header,
    .table-row {
        grid-template-columns: 45px 75px 2fr 65px 75px 75px 75px 75px 95px 115px;
        font-size: 14px;
    }
    
    .custom-table-header .table-col,
    .table-row .table-col {
        padding: 16px 12px;
    }
}

@media (max-width: 768px) {
    .custom-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .custom-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .custom-table-header,
    .custom-table-body,
    .table-row {
        min-width: 1100px;
    }
    
    .custom-table-header,
    .table-row {
        grid-template-columns: 50px 90px 200px 70px 80px 80px 80px 80px 100px 120px !important;
        font-size: 13px;
    }
    
    .custom-table-header .table-col,
    .table-row .table-col {
        padding: 14px 10px;
        white-space: nowrap;
    }
    
    .col-product {
        white-space: normal !important;
        word-wrap: break-word;
        overflow: visible !important;
    }
}

/* Old Table Styles - Keep for backward compatibility */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.inventory-table thead {
    background: var(--primary-color);
    color: white;
}

.inventory-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inventory-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.inventory-table tbody tr:hover {
    background-color: #F9FAFB;
}

.inventory-table td {
    padding: 15px;
    font-size: 0.95rem;
}

.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 15px;
    font-weight: 400;
}

.status-in-stock {
    background-color: #D1FAE5;
    color: #065F46;
}

.status-low-stock {
    background-color: #FEF3C7;
    color: #92400E;
}

.status-out-of-stock {
    background-color: #FEE2E2;
    color: #991B1B;
}

.action-btn {
    padding: 8px 12px;
    margin: 0 3px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.action-btn-edit {
    background-color: #DBEAFE;
    color: #1E40AF;
}

.action-btn-edit:hover {
    background-color: #BFDBFE;
}

.action-btn-delete {
    background-color: #FEE2E2;
    color: #991B1B;
}

.action-btn-delete:hover {
    background-color: #FECACA;
}

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

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* Form Styles */
.form-container {
    background: var(--card-bg);
    padding: 35px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

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

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

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

.form-group label {
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.auto-calc-badge {
    font-size: 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
    margin-left: auto;
}

.form-group input:read-only {
    background-color: #F3F4F6;
    cursor: not-allowed;
    color: var(--primary-color);
    font-weight: 400;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

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

.form-group textarea {
    resize: vertical;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 5px 0;
    text-align: left;
    margin-top: 5px;
}

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

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-start;
}

/* Button Styles */
.btn {
    padding: 12px 28px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn .fa-spinner {
    animation: spin 1s linear infinite;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: #F1F5F9;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #E2E8F0;
    transform: translateY(-2px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #DC2626 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Reports Styles */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.report-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.report-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.report-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.report-header h3 {
    font-size: 1.2rem;
}

.report-header i {
    font-size: 1.5rem;
    opacity: 0.9;
}

.report-content {
    padding: 20px;
}

.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.report-row span {
    color: var(--text-secondary);
}

.report-row strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Categories Styles */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.category-card {
    background: var(--card-bg);
    padding: 28px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid var(--border-color);
}

.category-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-xl);
}

.category-card i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.category-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.category-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.category-delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: #FEE2E2;
    color: #991B1B;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.category-card:hover .category-delete-btn {
    opacity: 1;
}

.category-delete-btn:hover {
    background: #FECACA;
}


/* Phone Table Styles */
.phone-table-header {
    display: grid;
    grid-template-columns: 1fr 160px 160px 90px;
    background: #F3F4F6;
    border-bottom: 2px solid var(--border-color);
    font-weight: 500;
    font-size: 15px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 480px;
}

.phone-row {
    display: grid;
    grid-template-columns: 1fr 160px 160px 90px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    transition: background 0.15s;
    min-width: 480px;
}

.phone-row:hover {
    background: #F9FAFB;
}

.phone-col {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-right: 1px solid #F3F4F6;
}

.phone-col:last-child {
    border-right: none;
}

.phone-col-name {
    font-weight: 400;
    color: var(--text-primary);
}

.phone-col-num,
.phone-col-num1 {
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    justify-content: flex-end;
}

.phone-col-actions {
    justify-content: center;
    gap: 5px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.3s ease;
    border: 1px solid var(--border-color);
}

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

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

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

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background-color: var(--border-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
}

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

/* ── Responsive Design ─────────────────────────────────────── */

/* Mobile (≤768px) */
@media (max-width: 768px) {
    .container {
        padding: 8px;
    }

    /* ── Banner: shrink icon boxes, smaller title ── */
    .banner {
        padding: 10px 8px 8px;
        gap: 5px;
    }

    .banner-icon-box {
        width: 36px;
        height: 36px;
        border-radius: 6px;
    }

    .banner-icon-box i {
        font-size: 0.95rem;
    }

    .banner-icons {
        gap: 5px;
    }

    .banner-title h1 {
        font-size: clamp(1.2rem, 7vw, 2rem);
        letter-spacing: 2px;
    }

    /* ── Stats: 3 columns side by side ── */
    .header-stats {
        grid-template-columns: repeat(3, 1fr);
        padding: 8px;
        gap: 0;
    }

    .stat-card {
        flex-direction: column;
        padding: 8px 6px;
        gap: 4px;
        text-align: center;
    }

    .stat-card i {
        font-size: 1.2rem;
    }

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

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

    /* ── Nav: horizontal scrolling pill row ── */
    .nav {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        margin-bottom: 16px;
        padding-bottom: 4px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar { display: none; }

    .nav-btn {
        flex: 0 0 auto;
        min-width: unset;
        padding: 10px 14px;
        font-size: 0.85rem;
        white-space: nowrap;
        border-radius: 20px;
    }

    /* ── Section header ── */
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header h2 {
        font-size: 1.2rem;
    }

    /* ── Search & filter ── */
    .search-filter {
        width: 100%;
        flex-direction: column;
    }

    .search-box {
        width: 100%;
        min-width: unset;
    }

    .filter-select {
        width: 100%;
    }
    
    /* Hide visibility button on mobile */
    #tableSettingsBtn {
        display: none !important;
    }

    /* ── Inventory table: horizontal scroll ── */
    .custom-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
        width: 100%;
    }
    
    .custom-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    /* ── Hide entire Actions column on mobile and adjust grid ── */
    .col-actions {
        display: none !important;
    }
    
    .custom-table-header,
    .table-row {
        grid-template-columns: 40px 75px 160px 65px 70px 70px 70px 70px 90px 110px !important;
        width: 820px !important;
        font-size: 14px !important;
    }
    
    .custom-table-header {
        font-weight: 700 !important;
        font-size: 15px !important;
        letter-spacing: 0.5px !important;
    }
    
    .custom-table-header .table-col,
    .table-row .table-col {
        padding: 12px 6px !important;
    }
    
    /* Product name can wrap */
    .col-product {
        white-space: normal !important;
        word-wrap: break-word;
        width: 160px !important;
        min-width: 160px !important;
        max-width: 160px !important;
    }
    
    /* Ensure numbers stay on one line */
    .col-total, .col-box, .col-inside, .col-ea, .col-sp, .col-profit, .col-profit-plus {
        white-space: nowrap !important;
        justify-content: flex-end;
    }
    
    .col-check {
        justify-content: center;
        padding: 12px 6px !important;
    }
    
    .col-edit {
        gap: 4px !important;
    }
    
    .col-edit .table-action-btn {
        padding: 6px 10px !important;
    }

    /* ── Form ── */
    .form-container {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 1rem; /* prevent iOS zoom on focus */
        padding: 10px 12px;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    /* ── Reports ── */
    .reports-grid {
        grid-template-columns: 1fr;
    }

    /* ── Categories ── */
    .categories-grid {
        grid-template-columns: 1fr;
    }

    /* ── Category delete always visible on touch ── */
    .category-delete-btn {
        opacity: 1 !important;
    }

    /* ── Phone table: horizontal scroll ── */
    .custom-table-container,
    #phoneTableBody {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .phone-table-header,
    .phone-row {
        min-width: 480px;
    }

    /* ── Modals full-width on mobile ── */
    .modal-content {
        width: 96%;
        margin: 0 auto;
    }

    /* ── Table settings dropdown: open left ── */
    .table-settings-menu {
        right: auto;
        left: auto;
        min-width: 180px;
    }
}

/* Small phones (≤480px) */
@media (max-width: 480px) {
    /* Hide icon rows in banner to save space */
    .banner-icons {
        display: none;
    }

    .banner {
        padding: 10px 8px;
    }

    /* Stack stats 1 per row if very narrow */
    .header-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .stat-card {
        padding: 6px 4px;
    }

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

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

    /* Tighter nav pills */
    .nav-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .nav,
    .section-header button,
    .search-filter,
    .action-btn,
    .form-actions {
        display: none;
    }

    body {
        background: white;
    }

    .section {
        display: block !important;
    }
}

