/* ==================== REZEH - Staff Portal Shared Design System ==================== */
:root {
    /* Core Colors */
    --primary: #1b74e4;
    --primary-hover: #1a6dd4;
    --primary-light: #e7f3ff;
    --primary-border: #b8d4f0;
    --success: #31a24c;
    --success-light: #dcfce7;
    --danger: #e41e3f;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-dark: #92400e;
    --info: #06b6d4;
    --info-light: rgba(6, 182, 212, 0.1);
    --purple: #8b5cf6;
    --purple-light: #f3f0ff;
    
    /* Neutrals */
    --text: #1c1e21;
    --text-secondary: #65676b;
    --text-muted: #8a8d91;
    --bg: #f0f2f5;
    --card: #ffffff;
    --border: #e4e6eb;
    --border-light: #f0f2f5;
    --input-bg: #f0f2f5;
    --hover-bg: #f5f6f7;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.15);
    
    /* Spacing (4px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    
    /* Typography */
    --font-xs: 11px;
    --font-sm: 13px;
    --font-base: 15px;
    --font-lg: 17px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 50%;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* iOS specific additions */
    --ios-blue: #007AFF;
    --ios-red: #FF3B30;
    --ios-orange: #FF9500;
    --ios-green: #34C759;
    --ios-purple: #AF52DE;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --separator: #E5E5EA;
    --fill: #F2F2F7;
    --fill-secondary: #E5E5EA;
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    font-size: var(--font-base);
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

/* ==================== TYPOGRAPHY ==================== */
h1 { font-size: var(--font-xl); font-weight: var(--font-weight-bold); }
h2 { font-size: var(--font-lg); font-weight: var(--font-weight-semibold); }
h3 { font-size: var(--font-base); font-weight: var(--font-weight-semibold); }
h4 { font-size: var(--font-sm); font-weight: var(--font-weight-semibold); }

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ==================== LAYOUT COMPONENTS ==================== */

/* Login Container */
.login-container {
    max-width: 400px;
    margin: 60px auto;
    background: var(--card);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-icon {
    font-size: 48px;
    margin-bottom: var(--space-3);
}

.login-container h2 {
    font-size: var(--font-2xl);
    margin-bottom: var(--space-1);
}

.login-container p {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin-bottom: var(--space-6);
}

/* Header */
.header {
    background: var(--card);
    padding: var(--space-3) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-bold);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-sm);
}

/* Permission Bar */
.perm-bar {
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    color: var(--primary-hover);
    margin: var(--space-3) var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.perm-bar strong {
    margin-right: var(--space-1);
}

/* Tabs */
.tabs {
    background: var(--card);
    padding: 0 var(--space-4);
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    position: sticky;
    top: 56px;
    z-index: 99;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-sm);
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab:hover {
    color: var(--text);
    background: var(--hover-bg);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: var(--font-weight-semibold);
}

.tab .badge {
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    min-width: 20px;
    text-align: center;
    line-height: 1.4;
}

.tab .badge.urgent {
    background: var(--danger);
    animation: pulse 2s infinite;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-3);
    padding: var(--space-4);
}

.stat-card {
    background: var(--card);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border: 1px solid var(--border);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-info h3 {
    font-size: var(--font-2xl);
    font-weight: var(--font-weight-bold);
    line-height: 1.1;
}

.stat-info p {
    color: var(--text-muted);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-medium);
}

.stat-card.new { border-left: 4px solid var(--danger); }
.stat-card.confirmed { border-left: 4px solid var(--primary); }
.stat-card.active { border-left: 4px solid var(--warning); }
.stat-card.delivered { border-left: 4px solid var(--purple); }
.stat-card.revenue { border-left: 4px solid var(--text); }

/* Content Area */
.content {
    padding: var(--space-4);
    max-width: 960px;
    margin: 0 auto;
}

/* Sections */
.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);
    }
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: var(--space-2);
}

.card-header h2 {
    font-size: var(--font-base);
    font-weight: var(--font-weight-bold);
}

/* Filters Bar */
.filters-bar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    font-size: var(--font-base);
    min-width: 200px;
    background: var(--card);
    flex: 1;
    transition: all var(--transition-normal);
}

.search-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.1);
}

.filter-select {
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    font-size: var(--font-sm);
    background: var(--card);
    cursor: pointer;
    min-width: 120px;
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
}

th {
    background: var(--input-bg);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-xs);
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    padding: var(--space-3) var(--space-4);
    text-align: left;
    border-bottom: 2px solid var(--border);
}

td {
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-sm);
    border-bottom: 1px solid var(--border-light);
}

tr:hover td {
    background: var(--hover-bg);
}

tr.new-row td {
    background: #fff9f0;
}

/* ==================== BADGES & STATUS ==================== */

/* Status Badges */
.status {
    padding: var(--space-1) var(--space-3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: var(--font-weight-semibold);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-new { background: var(--danger-light); color: var(--danger); }
.status-confirmed { background: var(--primary-light); color: var(--primary); }
.status-preparing { background: var(--warning-light); color: var(--warning-dark); }
.status-ready { background: var(--success-light); color: var(--success); }
.status-delivering { background: var(--purple-light); color: var(--purple); }
.status-delivered { background: var(--success-light); color: #059669; }
.status-cancelled { background: var(--danger-light); color: var(--danger); }

/* Payment Status */
.payment-status {
    padding: 2px 10px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    white-space: nowrap;
}

.payment-paid { background: var(--success-light); color: var(--success); }
.payment-pending { background: var(--warning-light); color: var(--warning-dark); }
.payment-cod { background: var(--primary-light); color: var(--primary); }

/* Badge Status (Inventory) */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

.badge-active { background: var(--success-light); color: #15803d; }
.badge-inactive { background: var(--danger-light); color: #991b1b; }
.badge-alert { background: var(--warning-light); color: var(--warning-dark); }

/* Pill Badges */
.badge-pill {
    background: var(--input-bg);
    padding: var(--space-1) var(--space-3);
    border-radius: 20px;
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    white-space: nowrap;
}

.badge-role {
    background: var(--info-light);
    color: var(--info);
}

/* Brand Pills */
.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-1) var(--space-2);
    border-radius: 20px;
    font-size: 12px;
    margin: 1px;
    font-weight: var(--font-weight-medium);
}

.brand-pill.ready {
    background: var(--success-light);
    color: var(--success);
}

.brand-pill.preparing {
    background: var(--warning-light);
    color: var(--warning-dark);
}

/* ==================== BUTTONS ==================== */
.btn {
    border: none;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    transition: all var(--transition-fast);
    background: var(--input-bg);
    color: var(--text);
    white-space: nowrap;
    line-height: 1;
    text-decoration: none;
}

.btn:hover {
    background: #e4e6e9;
    transform: translateY(-1px);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn i {
    font-size: 14px;
}

/* Button Variants */
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #2a8c3e;
}

.btn-warning {
    background: var(--warning);
    color: #1c1e21;
}
.btn-warning:hover {
    background: #e8960a;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #c71a32;
}

.btn-info {
    background: var(--info);
    color: #fff;
}
.btn-info:hover {
    background: #0596b0;
}

.btn-wa {
    background: #00a884;
    color: #fff;
}
.btn-wa:hover {
    background: #008f72;
}

.btn-call {
    background: #6366f1;
    color: #fff;
}
.btn-call:hover {
    background: #4f46e5;
}

/* Button Sizes */
.btn-xs {
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
}
.btn-xs i {
    font-size: var(--font-xs);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
}
.btn-sm i {
    font-size: 12px;
}

.btn-lg {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-base);
    width: 100%;
    justify-content: center;
    border-radius: var(--radius-md);
    font-weight: var(--font-weight-bold);
}

/* Logout Button */
.btn-logout {
    background: transparent;
    color: var(--text);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-sm);
    transition: all var(--transition-fast);
}

.btn-logout:hover {
    background: var(--input-bg);
}

/* ==================== FORMS ==================== */
.form-group {
    margin-bottom: var(--space-3);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-1);
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-xs);
    text-transform: uppercase;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    outline: none;
    font-size: var(--font-base);
    font-family: inherit;
    background: var(--card);
    color: var(--text);
    transition: all var(--transition-normal);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: flex;
    gap: var(--space-3);
}

.form-row .form-group {
    flex: 1;
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    backdrop-filter: blur(2px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card);
    width: 100%;
    max-width: 550px;
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s ease;
}

.modal-content h3 {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-bold);
    margin-bottom: var(--space-4);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    color: #fff;
    z-index: 9999;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-sm);
    box-shadow: var(--shadow-lg);
    max-width: 350px;
    animation: slideIn 0.3s ease;
    word-wrap: break-word;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--text); }

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-3);
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== CONNECTION STATUS ==================== */
.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--success);
    flex-shrink: 0;
}

.connection-dot.offline {
    background: var(--danger);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==================== NOTIFICATION BAR ==================== */
.notification-bar {
    background: var(--danger);
    color: #fff;
    padding: var(--space-3) var(--space-4);
    text-align: center;
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-sm);
    cursor: pointer;
    display: none;
}

.notification-bar.show {
    display: block;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: var(--space-3);
    color: var(--border);
}

.empty-state h3 {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-1);
}

.empty-state p {
    font-size: var(--font-sm);
}

/* ==================== IMAGES ==================== */
.product-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.brand-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    padding: 3px;
}

/* ==================== RIDER INFO ==================== */
.rider-info {
    font-size: 12px;
    color: var(--text-secondary);
}

.rider-info.assigned {
    color: var(--primary);
    font-weight: var(--font-weight-semibold);
}

/* ==================== BRAND CARDS ==================== */
.brand-mini {
    background: var(--card);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    margin: var(--space-1) 0;
    font-size: var(--font-sm);
    border: 1px solid var(--border-light);
}

.brand-mini.ready {
    background: var(--success-light);
    border-color: #b7e4c7;
}

.brand-mini.preparing {
    background: var(--warning-light);
    border-color: #fde68a;
}

.brand-mini strong {
    font-size: var(--font-base);
}

.brand-detail-card {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin: var(--space-2) 0;
    border: 1px solid var(--border);
}

/* Summary Bar */
.summary-bar {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-top: var(--space-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-base);
}

.summary-bar.all-ready {
    background: var(--success-light);
    color: var(--success);
}

/* ==================== iOS INSPIRED COMPONENTS ==================== */

/* Nav Bar */
.nav-bar {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    max-width: 800px;
    margin: 0 auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #1b74e4, #1a6dd4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
}

.nav-brand .brand-text {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.nav-brand .brand-sub {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 400;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-ring {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1b74e4, #1a6dd4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

/* Gateway Tabs */
.gateway-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 60px;
    z-index: 99;
}

.gateway-tab {
    flex: 1;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: 1px solid var(--separator);
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.gateway-tab:active { transform: scale(0.96); }
.gateway-tab.active { background: var(--text); color: white; border-color: var(--text); font-weight: 600; }
.gateway-tab .tab-badge { background: var(--ios-red); color: white; padding: 1px 7px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.gateway-tab.active .tab-badge { background: rgba(255,255,255,0.3); }

/* Overview Row */
.overview-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 12px 16px;
}

.overview-tile {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.overview-tile:active { transform: scale(0.96); }
.overview-tile h4 { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 2px; }
.overview-tile p { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; font-weight: 500; }
.overview-tile.new h4 { color: var(--ios-red); }
.overview-tile.preparing h4 { color: var(--ios-orange); }
.overview-tile.ready h4 { color: var(--ios-green); }
.overview-tile.delivered h4 { color: var(--ios-purple); }

/* Cards Container */
.cards-container {
    padding: 16px;
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Nav Card */
.nav-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.nav-card:active { transform: scale(0.96); }
.nav-card .card-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.nav-card .card-icon.blue { background: #E8F2FF; }
.nav-card .card-icon.green { background: #E8F8ED; }
.nav-card .card-icon.purple { background: #F3E8FF; }
.nav-card .card-icon.orange { background: #FFF3E0; }
.nav-card h3 { font-size: 14px; font-weight: 600; }
.nav-card p { font-size: 11px; color: var(--text-secondary); }

/* iOS Buttons */
.btn-ios {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    min-height: 32px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-ios:active { transform: scale(0.96); }
.btn-ios.primary { background: var(--ios-blue); color: white; }
.btn-ios.danger { background: var(--ios-red); color: white; }
.btn-ios.small { padding: 4px 10px; font-size: 11px; min-height: 26px; border-radius: 14px; }
.btn-ios.block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; border-radius: 14px; }

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.login-overlay.show { display: flex; }

.login-card {
    background: var(--card);
    padding: 32px 24px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card .login-icon {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    background: linear-gradient(135deg, #1b74e4, #1a6dd4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 16px;
}

.login-card h2 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }

/* PWA Install Button */
#pwa-install-btn {
    display: none;
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ios-blue);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    z-index: 9999;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

/* Segmented Control */
.segmented-wrapper {
    padding: 8px 16px;
    background: var(--card);
    border-bottom: 0.5px solid var(--separator);
    position: sticky;
    top: 52px;
    z-index: 99;
}

.segmented-scroll {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.segmented-scroll::-webkit-scrollbar { display: none; }

.segment-item {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    font-family: inherit;
}

.segment-item:active { transform: scale(0.96); }
.segment-item.active {
    background: var(--text);
    color: white;
    font-weight: 600;
}

.segment-badge {
    background: rgba(255,255,255,0.3);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.segment-item:not(.active) .segment-badge {
    background: var(--fill-secondary);
    color: var(--text-secondary);
}

.segment-badge.urgent {
    background: var(--ios-red);
    color: white;
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Stats Tiles */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    padding: 12px 16px;
}

.stat-tile {
    background: var(--card);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.stat-tile:active { transform: scale(0.96); }

.stat-icon-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 18px;
}

.stat-tile h4 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.stat-tile p {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Search Wrapper */
.search-wrapper {
    position: relative;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    padding: 10px 16px 10px 36px;
    border: none;
    border-radius: 10px;
    outline: none;
    font-size: 15px;
    background: var(--fill);
    color: var(--text);
    font-family: inherit;
    transition: all 0.2s;
}

.search-input:focus {
    background: var(--card);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
    pointer-events: none;
}

/* Filter Row */
.filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-select-ios {
    padding: 8px 28px 8px 12px;
    border: 1px solid var(--separator);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    background: var(--card);
    color: var(--text);
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
    outline: none;
    min-width: 110px;
}

.filter-select-ios:focus {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.date-chips {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: flex-end;
}

.filter-chip {
    padding: 7px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--separator);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: inherit;
}

.filter-chip:active { transform: scale(0.96); }
.filter-chip.active {
    background: var(--ios-blue);
    color: white;
    border-color: var(--ios-blue);
}

.btn-refresh {
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    background: var(--ios-blue);
    color: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-refresh:active { transform: scale(0.96); }

/* Table Wrapper */
.table-wrapper {
    background: var(--card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-header {
    display: grid;
    grid-template-columns: 1fr 1.2fr 0.8fr 0.8fr 0.8fr 0.8fr 0.8fr 0.8fr 1fr;
    padding: 10px 16px;
    background: var(--fill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--separator);
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1.2fr 0.8fr 0.8fr 0.8fr 0.8fr 0.8fr 0.8fr 1fr;
    padding: 14px 16px;
    align-items: center;
    font-size: 14px;
    border-bottom: 0.5px solid var(--separator);
    transition: background 0.15s;
}

.table-row:last-child { border-bottom: none; }
.table-row:active { background: var(--fill); }
.table-row.urgent { background: #FFF5F5; }

/* iOS Badges */
.ios-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.ios-badge.blue { background: #E8F2FF; color: var(--ios-blue); }
.ios-badge.orange { background: #FFF3E0; color: var(--ios-orange); }
.ios-badge.green { background: #E8F8ED; color: var(--ios-green); }
.ios-badge.purple { background: #F3E8FF; color: var(--ios-purple); }
.ios-badge.red { background: #FFE5E5; color: var(--ios-red); }
.ios-badge.gray { background: var(--fill); color: var(--text-secondary); }

.ios-pill {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.ios-pill.paid { background: #E8F8ED; color: var(--ios-green); }
.ios-pill.pending { background: #FFF3E0; color: var(--ios-orange); }
.ios-pill.cod { background: #E8F2FF; color: var(--ios-blue); }

/* Order Cards */
.order-cards { display: none; }

.order-card-ios {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}

.order-card-ios:active { transform: scale(0.98); }
.order-card-ios.urgent { border-left: 4px solid var(--ios-red); }
.order-card-ios.grouped { border-left: 4px solid var(--ios-blue); }

.card-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.card-detail {
    background: var(--fill);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 0.5px solid var(--separator);
}

/* Sheet Modal */
.modal-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
}

.modal-sheet.show { display: flex; }

.sheet-content {
    background: var(--card);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
    animation: sheetUp 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.sheet-handle {
    width: 36px;
    height: 5px;
    background: var(--fill-secondary);
    border-radius: 3px;
    margin: 12px auto 8px;
}

.sheet-header {
    padding: 8px 20px 16px;
    border-bottom: 0.5px solid var(--separator);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheet-body { padding: 16px 20px 32px; }

.sheet-section {
    background: var(--fill);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

/* Toast iOS */
.toast-ios {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 14px;
    color: white;
    z-index: 9999;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

.toast-ios.success { background: rgba(52, 199, 89, 0.95); }
.toast-ios.error { background: rgba(255, 59, 48, 0.95); }
.toast-ios.info { background: rgba(0, 0, 0, 0.85); }

@keyframes toastIn {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .content {
        padding: var(--space-3);
    }
    
    .header {
        padding: var(--space-3);
    }
    
    .header h1 {
        font-size: var(--font-base);
    }
    
    .tabs {
        padding: 0 var(--space-3);
    }
    
    .tab {
        padding: var(--space-3);
        font-size: 12px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-2);
        padding: var(--space-3);
    }
    
    .stat-card {
        padding: var(--space-3);
    }
    
    .stat-info h3 {
        font-size: var(--font-xl);
    }
    
    .table-container {
        margin: 0 -16px;
        width: calc(100% + 32px);
    }
    
    .header {
        padding: var(--space-2) var(--space-3);
    }
    
    .header h1 {
        font-size: var(--font-base);
    }
    
    .tabs {
        padding: 0 var(--space-2);
        top: 48px;
    }
    
    .tab {
        padding: var(--space-2) var(--space-3);
        font-size: 12px;
        gap: var(--space-1);
    }
    
    .tab .badge {
        font-size: 10px;
        padding: 1px 6px;
        min-width: 16px;
    }
    
    .content {
        padding: var(--space-3);
    }
    
    .filters-bar {
        flex-direction: column;
        gap: var(--space-2);
    }
    
    .search-box {
        width: 100%;
        min-width: unset;
    }
    
    .filter-select {
        width: 100%;
    }
    
    .modal-content {
        max-width: 95%;
        margin: 0;
        border-radius: var(--radius-lg);
        padding: var(--space-4);
    }
    
    .login-container {
        margin: var(--space-8) var(--space-3);
        padding: var(--space-6) var(--space-4);
    }
    
    .login-container h2 {
        font-size: var(--font-xl);
    }
    
    .btn {
        min-height: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
    }
    
    .btn-xs {
        min-height: 32px;
    }
    
    .perm-bar {
        margin: var(--space-2) var(--space-3);
        font-size: var(--font-xs);
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* iOS mobile overrides */
    .table-wrapper { display: none; }
    .order-cards { display: block; }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .overview-row { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .overview-tile h4 { font-size: 18px; }
    
    .filter-select-ios {
        min-width: 90px;
        font-size: 12px;
        padding: 8px 24px 8px 10px;
    }
    
    .filter-chip {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .date-chips { gap: 3px; }
}

/* Small Mobile */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-1);
    }
    
    .stat-card {
        padding: var(--space-2);
    }
    
    .stat-info h3 {
        font-size: var(--font-lg);
    }
    
    .stat-info p {
        font-size: var(--font-xs);
    }
    
    .tabs {
        padding: 0 var(--space-1);
    }
    
    .tab {
        padding: var(--space-2);
        font-size: var(--font-xs);
    }

    .cards-container { gap: 10px; padding: 12px; }
    .nav-card { padding: 16px 12px; }
    .overview-row { grid-template-columns: repeat(2, 1fr); }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* Inventory-specific additions */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: 11px; text-transform: uppercase; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 12px; border: 2px solid var(--border); border-radius: var(--radius-sm); outline: none; font-size: 13px; font-family: inherit; background: var(--card); color: var(--text); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.product-img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: var(--input-bg); padding: 2px; }

.badge-status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fef2f2; color: #991b1b; }
.badge-alert { background: #fef3c7; color: #92400e; }

@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
}