/* ═══════════════════════════════════════════════════════════
   IOM Platform — Design System
   Modern SaaS Dashboard (Cin7 / QuickBooks style)
═══════════════════════════════════════════════════════════ */

:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-light: #eff6ff;
    --brand-subtle: #dbeafe;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #0891b2;
    --info-bg: #ecfeff;

    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;

    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --sidebar-w: 240px;
    --header-h: 60px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);

    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', monospace;
}

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

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── AUTH SCREEN ─────────────────────────────────────── */
.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    text-align: center;
    margin-bottom: 32px;
}

.brand-logo {
    width: 56px; height: 56px;
    background: var(--brand);
    color: white;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px;
    margin: 0 auto 12px;
    letter-spacing: -0.5px;
}

.auth-brand h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

.auth-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.auth-switch {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 16px;
    font-size: 13px;
}

.auth-switch a { color: var(--brand); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }


/* ─── LAYOUT ─────────────────────────────────────────── */
#app {
    display: block;
    min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    transition: transform 0.25s ease;
}

body.nav-collapsed .sidebar { transform: translateX(-240px); }
body.nav-collapsed .main-content { margin-left: 0; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid #1e293b;
}

.brand-icon {
    width: 32px; height: 32px;
    background: var(--brand);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 11px; color: white;
    flex-shrink: 0;
}

.brand-name { font-weight: 700; font-size: 14px; color: #f8fafc; display: block; }
.brand-tenant { font-size: 11px; color: #64748b; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }

.sidebar-nav { flex: 1; padding: 12px 8px; }

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #475569;
    padding: 12px 8px 4px;
    margin-top: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    position: relative;
}

.nav-item svg {
    width: 16px; height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #1e3a8a; color: #93c5fd; }
.nav-item.active svg { stroke: #93c5fd; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.nav-badge.badge-warn { background: var(--warning); }
.nav-badge:empty { display: none; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid #1e293b;
}

.ws-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #64748b;
    margin-bottom: 12px;
}

.ws-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #475569;
    transition: background 0.3s;
}

.ws-dot.connected { background: #22c55e; }
.ws-dot.error { background: var(--danger); }

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

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #1e3a8a;
    color: #93c5fd;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    flex-shrink: 0;
}

.warehouse-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.warehouse-row {
    align-items: flex-end;
    gap: 12px;
}

.warehouse-action {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.warehouse-scan-result {
    margin-top: 10px;
    min-height: 44px;
}

.warehouse-result-pill {
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 999px;
    padding: 3px 8px;
    margin-bottom: 6px;
    background: var(--surface-2);
}

.warehouse-queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.warehouse-card {
    border: 1px solid var(--border);
}

.warehouse-card-head,
.warehouse-card-body,
.warehouse-card-actions {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.warehouse-card-head { margin-bottom: 12px; }
.warehouse-card-body { color: var(--text-secondary); margin-bottom: 14px; }
.warehouse-card-order { font-weight: 700; font-size: 16px; }
.warehouse-card-actions { justify-content: flex-end; }

.warehouse-item-form {
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.warehouse-item-head { margin-bottom: 10px; }

@media (max-width: 900px) {
    .warehouse-toolbar {
        grid-template-columns: 1fr;
    }

    .warehouse-row {
        flex-direction: column;
        align-items: stretch;
    }

    .warehouse-action {
        width: 100%;
        justify-content: stretch;
    }

    .warehouse-action .btn {
        flex: 1;
    }

    .warehouse-card-body,
    .warehouse-card-actions,
    .warehouse-card-head {
        flex-direction: column;
    }
}

.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #64748b; text-transform: capitalize; }

.logout-btn {
    margin-left: auto;
    color: #475569;
}
.logout-btn:hover { color: #94a3b8; }

/* ─── MAIN CONTENT ────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
    transition: margin-left 0.25s ease;
}

.top-header {
    height: var(--header-h);
    background: var(--surface);
    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;
    min-width: 0;
    gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

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

.notification-bell {
    position: relative;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.notification-bell:hover { background: var(--surface-2); }

.notification-bell svg {
    width: 20px; height: 20px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notif-count {
    position: absolute;
    top: 3px; right: 3px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.notifications-panel {
    position: fixed;
    top: var(--header-h);
    right: 16px;
    width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 500px;
    overflow-y: auto;
}

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

.notif-header h3 { font-size: 14px; font-weight: 600; }

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--brand-light); }

.notif-item h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item p { font-size: 12px; color: var(--text-secondary); }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.page-content {
    flex: 1;
    padding: 24px;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

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

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

input:not([type=checkbox]):not([type=radio]), select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font);
}

input[type=checkbox], input[type=radio] {
    width: auto;
    padding: 0;
    flex-shrink: 0;
}

input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

input::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ─── BUTTONS ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
}

.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

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

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-dark); }
.btn-secondary:hover { background: var(--border); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

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

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-full { width: 100%; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 6px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; transition: background 0.15s; }
.btn-icon svg { width: 16px; height: 16px; stroke: var(--text-secondary); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon:hover { background: var(--surface-2); }
.btn-icon:hover svg { stroke: var(--text); }

/* ─── CARDS ───────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
    overflow: hidden;
}

.card table {
    min-width: unset;
    width: 100%;
}

.card .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.card-title { font-size: 15px; font-weight: 600; }
.card-actions { display: flex; gap: 8px; align-items: center; }

/* ─── STAT CARDS ─────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    min-width: 0;
    overflow: hidden;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-value {
    font-size: clamp(15px, 1.4vw, 22px);
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-trend { font-size: 12px; margin-top: 6px; font-weight: 500; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

.stat-card.brand { background: var(--brand); color: white; border-color: var(--brand-dark); }
.stat-card.brand .stat-label { color: rgba(255,255,255,.7); }
.stat-card.brand .stat-value { color: white; }
.stat-card.brand .stat-sub { color: rgba(255,255,255,.7); }

/* ─── TABLES ─────────────────────────────────────────── */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    width: 100%;
    min-width: 0;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

.table-toolbar-left { display: flex; gap: 8px; align-items: center; flex: 1; }
.table-toolbar-right { display: flex; gap: 8px; align-items: center; }

.search-input {
    width: 260px;
    padding: 7px 12px 7px 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
}

.filter-select { width: auto; min-width: 120px; }

table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--surface-2);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

thead th:hover { color: var(--text); }
thead th.sorted { color: var(--brand); }
thead th.sorted::after { content: ' ↑'; }
thead th.sorted.desc::after { content: ' ↓'; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

tbody td {
    padding: 11px 14px;
    color: var(--text);
    vertical-align: middle;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-controls { display: flex; gap: 4px; }
.pagination-controls button {
    padding: 5px 10px;
    border: 1px solid var(--border-dark);
    background: var(--surface);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.pagination-controls button:hover { background: var(--surface-2); }
.pagination-controls button.active { background: var(--brand); color: white; border-color: var(--brand); }
.pagination-controls button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── BADGES / PILLS ─────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-fulfilling { background: #dbeafe; color: #1e40af; }
.badge-fulfilled { background: #e0f2fe; color: #0369a1; }
.badge-shipped { background: #ede9fe; color: #5b21b6; }
.badge-delivered { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-refunded { background: #fce7f3; color: #9d174d; }
.badge-draft { background: var(--surface-2); color: var(--text-muted); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: var(--surface-2); color: var(--text-muted); }
.badge-low { background: var(--warning-bg); color: var(--warning); }
.badge-out { background: var(--danger-bg); color: var(--danger); }

/* ─── MODALS ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 400px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

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

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

/* ─── PAGE HEADERS ────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; }

/* ─── GRID LAYOUTS ────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ─── CHARTS ──────────────────────────────────────────── */
.chart-container {
    position: relative;
    padding: 8px 0;
}

/* ─── TOASTS ──────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 360px;
}

.toast {
    background: var(--surface);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: toastIn 0.25s ease;
    font-size: 13px;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

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

.toast-title { font-weight: 600; color: var(--text); }
.toast-msg { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

/* ─── ALERT BANNERS ───────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-info { background: var(--info-bg); color: var(--info); border-color: #a5f3fc; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #fde68a; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }

/* ─── LOADING ─────────────────────────────────────────── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: var(--text-muted);
    gap: 10px;
}

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; stroke: var(--border-dark); margin: 0 auto 12px; display: block; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ─── TABS ────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--surface-2);
    padding: 3px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    width: fit-content;
}

.tab {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.15s;
    border: none;
    background: none;
}

.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── DETAIL VIEW ─────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.detail-field label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); display: block; margin-bottom: 3px; }
.detail-field span { font-size: 14px; color: var(--text); font-weight: 500; }

/* ─── INVENTORY TABLE COLORS ──────────────────────────── */
.stock-ok { color: var(--success); font-weight: 600; }
.stock-low { color: var(--warning); font-weight: 600; }
.stock-out { color: var(--danger); font-weight: 600; }

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-240px); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .stat-grid { grid-template-columns: 1fr; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
    .table-toolbar-left { flex-wrap: wrap; }
    .search-input { width: 100%; }
    .page-content { padding: 16px; }
}

/* ─── REAL-TIME HIGHLIGHT ────────────────────────────── */
@keyframes rowHighlight {
    0% { background: #eff6ff; }
    100% { background: transparent; }
}
.highlight-new { animation: rowHighlight 2s ease forwards; }

/* ─── MISC ────────────────────────────────────────────── */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.font-mono { font-family: var(--font-mono); font-size: 12px; }
.fw-600 { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ─── PRODUCT FORM PAGE ───────────────────────────────── */
.pf-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.pf-title-input {
    flex: 1;
    min-width: 200px;
    font-size: 18px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 6px 10px;
    background: transparent;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.pf-title-input:hover { border-color: var(--border); background: var(--surface); }
.pf-title-input:focus { border-color: var(--brand); background: var(--surface); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.pf-title-input::placeholder { color: var(--text-muted); font-weight: 400; }
.pf-header-actions { display: flex; gap: 8px; margin-left: auto; }

.pf-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
.pf-main { display: flex; flex-direction: column; gap: 16px; }
.pf-sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }

.pf-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.pf-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.pf-section-subtitle { font-size: 12px; color: var(--text-muted); margin-top: -12px; margin-bottom: 14px; }

/* Tag input */
.tag-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: text;
    min-height: 38px;
    align-items: center;
    transition: border-color .15s, box-shadow .15s;
}
.tag-input-wrapper:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.tag-input-wrapper input {
    border: none; outline: none; padding: 0; background: transparent;
    font-size: 13px; min-width: 80px; flex: 1;
}
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--brand-subtle); color: var(--brand-dark);
    padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500;
}
.tag-chip button {
    background: none; border: none; cursor: pointer; color: var(--brand);
    padding: 0; line-height: 1; font-size: 14px; opacity: .7;
}
.tag-chip button:hover { opacity: 1; }

/* Variant builder */
.variant-option-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--surface-2);
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.variant-option-row .opt-name { flex-shrink: 0; width: 140px; }
.variant-option-values { flex: 1; }
.variant-option-values .tag-input-wrapper { background: var(--surface); }
.variant-opt-remove {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    padding: 4px; border-radius: 4px; flex-shrink: 0; margin-top: 4px;
}
.variant-opt-remove:hover { color: var(--danger); background: var(--danger-bg); }

.variant-table-wrap { overflow-x: auto; margin-top: 16px; }
.variant-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.variant-table th {
    text-align: left; padding: 8px 10px; font-weight: 600;
    background: var(--surface-2); border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.variant-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.variant-table tr:last-child td { border-bottom: none; }
.variant-table input[type=text], .variant-table input[type=number] {
    width: 100%; padding: 4px 8px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 12px; background: var(--surface);
}
.variant-table input:focus { border-color: var(--brand); outline: none; }
.variant-name-cell { font-weight: 600; white-space: nowrap; }

/* Pricing: compare-at strikethrough preview */
.price-preview { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.price-preview s { color: var(--danger); }

/* Dimension inputs inline */
.dim-row { display: flex; gap: 8px; align-items: center; }
.dim-row input { width: 80px; }
.dim-sep { color: var(--text-muted); font-size: 13px; }

/* SEO preview */
.seo-preview {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 12px;
}
.seo-preview .seo-url { color: #137333; margin-bottom: 2px; }
.seo-preview .seo-title-p { color: #1a0dab; font-size: 15px; font-weight: 400; margin-bottom: 2px; line-height: 1.3; }
.seo-preview .seo-desc-p { color: var(--text-secondary); }

@media (max-width: 960px) {
    .pf-layout { grid-template-columns: 1fr; }
    .pf-sidebar { position: static; }
}

/* ─── PRODUCT IMAGES ─────────────────────────────────── */
.product-thumb {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    object-fit: cover;
    border: 1px solid var(--border);
    display: block;
}
.product-thumb-placeholder {
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 20px;
}
.image-upload-zone {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: var(--surface-2);
    display: block;
    margin-top: 12px;
}
.image-upload-zone:hover, .image-upload-zone.drag-over {
    border-color: var(--brand);
    background: var(--brand-light);
}
.image-upload-zone input[type=file] { display: none; }
.image-upload-zone .upload-icon { font-size: 26px; margin-bottom: 6px; }
.image-upload-zone .upload-label { font-weight: 600; color: var(--text-secondary); }
.image-upload-zone p { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.image-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--border);
    aspect-ratio: 1;
    background: var(--surface-2);
}
.image-item.is-feature { border-color: var(--brand); }
.image-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: opacity .15s;
}
.image-item:hover .image-item-overlay { opacity: 1; }
.image-item-overlay button {
    background: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600;
    width: 76px;
    line-height: 1.4;
}
.image-item-overlay .btn-set-feature { color: var(--brand); }
.image-item-overlay .btn-delete-img { color: var(--danger); }
.image-feature-badge {
    position: absolute;
    top: 4px; left: 4px;
    background: var(--brand);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* ─── POS Terminal ─────────────────────────────── */
.pos-terminal {
    display: grid;
    grid-template-columns: 1fr 380px;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 60px);
    gap: 0;
    overflow: hidden;
}
.pos-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.pos-header h2 { margin: 0; font-size: 16px; }
.pos-session-info { display: flex; gap: 16px; align-items: center; flex: 1; }
.pos-session-badge { background: var(--success-bg, #d1fae5); color: var(--success, #065f46); font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.pos-products {
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
}
.pos-search-bar input {
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
}
.pos-search-bar input:focus { outline: none; border-color: var(--brand); }
.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.pos-product-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
    user-select: none;
    min-height: 44px;
}
.pos-product-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.pos-product-card.in-cart { border-color: var(--success, #10b981); background: var(--success-bg, #f0fdf4); }
.pos-product-card .prod-name { font-weight: 600; font-size: 13px; line-height: 1.3; margin-bottom: 4px; }
.pos-product-card .prod-sku { font-size: 11px; color: var(--text-muted); }
.pos-product-card .prod-price { font-size: 15px; font-weight: 700; color: var(--brand); margin-top: 6px; }
.pos-product-card .prod-stock { font-size: 11px; color: var(--text-muted); }
.pos-product-card .in-cart-badge {
    position: absolute; top: 6px; right: 6px;
    background: var(--success, #10b981); color: #fff;
    font-size: 10px; font-weight: 700;
    padding: 2px 6px; border-radius: 10px;
}
.pos-cart {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}
.pos-cart-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pos-cart-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.pos-cart-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
}
.pos-cart-item:last-child { border-bottom: none; }
.pos-cart-item-name { font-size: 13px; font-weight: 500; }
.pos-cart-item-sku { font-size: 11px; color: var(--text-muted); }
.pos-qty-control { display: flex; align-items: center; gap: 4px; }
.pos-qty-btn {
    width: 26px; height: 26px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    color: var(--text);
    transition: background 0.1s;
    min-height: 44px;
    min-width: 44px;
}
.pos-qty-btn:hover { background: var(--border); }
.pos-qty-input {
    width: 36px; height: 26px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
}
.pos-item-total { font-size: 13px; font-weight: 600; min-width: 60px; text-align: right; }
.pos-remove-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; padding: 0 4px; line-height: 1; min-height: 44px; }
.pos-remove-btn:hover { color: var(--danger, #ef4444); }
.pos-cart-totals { border-top: 2px solid var(--border); padding: 12px 16px; }
.pos-total-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; color: var(--text-muted); }
.pos-total-row.grand { font-size: 18px; font-weight: 800; color: var(--text); margin-top: 8px; border-top: 1px solid var(--border); padding-top: 8px; }
.pos-cart-actions { padding: 8px 16px; display: flex; gap: 8px; border-top: 1px solid var(--border); }
.pos-cart-actions .btn { flex: 1; font-size: 12px; padding: 6px 8px; min-height: 44px; }
.pos-payment-btns { padding: 12px 16px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; border-top: 2px solid var(--border); }
.pos-pay-btn {
    padding: 14px 8px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
}
.pos-pay-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pos-pay-cash { background: #10b981; color: #fff; }
.pos-pay-cash:hover:not(:disabled) { background: #059669; }
.pos-pay-card { background: #3b82f6; color: #fff; }
.pos-pay-card:hover:not(:disabled) { background: #2563eb; }
.pos-pay-split { background: #8b5cf6; color: #fff; }
.pos-pay-split:hover:not(:disabled) { background: #7c3aed; }
.pos-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.pos-numpad-btn {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    transition: background 0.1s;
    min-height: 44px;
}
.pos-numpad-btn:hover { background: var(--border); }
.pos-numpad-btn.preset { background: var(--bg); font-size: 14px; }
.pos-numpad-btn.del { color: var(--danger, #ef4444); }
.pos-cash-display {
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.pos-cash-display .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.pos-cash-display .value { font-size: 28px; font-weight: 800; color: var(--text); }
.pos-cash-display .change { font-size: 20px; font-weight: 700; color: var(--success, #10b981); }
.pos-no-session {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: 16px;
    color: var(--text-muted);
}
.pos-no-session svg { width: 64px; height: 64px; opacity: 0.3; }
.pos-no-session h3 { font-size: 20px; color: var(--text); margin: 0; }
.pos-no-session p { margin: 0; }
.pos-txn-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pos-txn-row:last-child { border-bottom: none; }
.pos-txn-meta { flex: 1; }
.pos-txn-meta .txn-num { font-weight: 600; font-size: 13px; }
.pos-txn-meta .txn-time { font-size: 11px; color: var(--text-muted); }
.pos-txn-amount { font-weight: 700; font-size: 14px; }
.pos-txn-method { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }
.pos-load-more { text-align: center; padding: 12px 0; }
.pos-cart-customer { padding: 6px 16px; font-size: 12px; color: var(--brand); font-weight: 600; background: var(--brand-light); border-bottom: 1px solid var(--border); }
.pos-cart-note { padding: 6px 16px; font-size: 12px; color: var(--text-muted); background: var(--warning-bg, #fffbeb); border-bottom: 1px solid var(--border); }
