/* ============================================================
   National Sales / National Flour Mill — Global Stylesheet
   Version: 9.0
   Sections:
     1. Reset & Base
     2. Typography
     3. Layout Helpers
     4. Sidebar
     5. Topbar
     6. Content & Cards
     7. KPI Cards
     8. Tables
     9. Badges & Status Pills
    10. Buttons
    11. Forms
    12. Modals (.ns-modal)
    13. Info Boxes & Alerts
    14. Empty & Loading States
    15. Auth Pages (login)
    16. SweetAlert2 Overrides
    17. Mobile Responsive
    18. PWA / Standalone Mode
   ============================================================ */

/* ============================================================
   1. RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #212529;
    background-color: #f4f6f9;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

img, svg { max-width: 100%; display: block; }
a { color: #0d6efd; text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* Prevent iOS zoom on input focus */
input, select, textarea, button {
    font-family: inherit;
    font-size: 16px;
}

/* ============================================================
   2. TYPOGRAPHY
   ============================================================ */
h1 { font-size: 24px; font-weight: 700; color: #1a2035; }
h2 { font-size: 18px; font-weight: 700; color: #1a2035; }
h3 { font-size: 16px; font-weight: 700; color: #1a2035; }
h4 { font-size: 14px; font-weight: 700; color: #1a2035; }
h5 { font-size: 13px; font-weight: 700; color: #1a2035; }
small { font-size: 12px; color: #6c757d; }

.text-muted { color: #6c757d; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: #dc3545; }
.text-success { color: #16a34a; }
.text-warning { color: #d97706; }

/* ============================================================
   3. LAYOUT HELPERS
   ============================================================ */
.app-container { display: flex; min-height: 100vh; }
.main-content {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.content-wrapper { padding: 30px; }

/* ============================================================
   4. SIDEBAR
   ============================================================ */
.sidebar {
    width: 260px;
    background-color: #1a2035;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: width 0.2s;
}
.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    background: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a2035;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}
.sidebar-brand .brand-text h2 { font-size: 16px; font-weight: 600; margin: 0; color: #fff; }
.sidebar-brand .brand-text p { font-size: 11px; color: #a0aec0; margin: 0; }

.sidebar-nav { flex: 1; padding: 20px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #a0aec0;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    transition: all 0.2s;
    min-height: 44px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: #0d6efd; color: #fff; }
.sidebar-nav a i { width: 20px; margin-right: 10px; text-align: center; font-size: 15px; }

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    font-size: 13px;
}
.sidebar-footer .user-email {
    color: #a0aec0;
    margin-bottom: 10px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-footer .sign-out {
    display: flex;
    align-items: center;
    color: #a0aec0;
    text-decoration: none;
    transition: color 0.2s;
    min-height: 40px;
}
.sidebar-footer .sign-out:hover { color: #fff; text-decoration: none; }
.sidebar-footer .sign-out i { margin-right: 10px; }

/* ============================================================
   5. TOPBAR
   ============================================================ */
.topbar {
    height: 65px;
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}
.topbar .page-title { font-size: 18px; font-weight: 600; color: #1a2035; }
.topbar .user-profile { display: flex; align-items: center; gap: 15px; }
.topbar .user-profile i { font-size: 18px; color: #6c757d; cursor: pointer; transition: color 0.2s; }
.topbar .user-profile i:hover { color: #0d6efd; }

/* ============================================================
   6. CONTENT & CARDS
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    gap: 15px;
}
.page-header h1 { font-size: 24px; font-weight: 700; color: #1a2035; margin-bottom: 5px; }
.page-header p { color: #6c757d; font-size: 14px; }

.dash-card,
.card,
.table-card,
.info-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
    overflow: hidden;
}
.dash-card { margin-bottom: 24px; }
.dash-card-header,
.card-header,
.table-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.dash-card-header h3,
.card-header h3,
.table-card-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #1a2035;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dash-card-header h3 i { color: #0d6efd; }
.dash-card-body,
.card-body,
.table-card-body { padding: 24px; }
.info-card { padding: 24px; }
.info-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: #1a2035;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f3f5;
    display: flex;
    align-items: center;
    gap: 10px;
}
.info-card h3 i { color: #0d6efd; }

.info-row { display: flex; margin-bottom: 14px; }
.info-row:last-child { margin-bottom: 0; }
.info-row label {
    width: 130px;
    font-size: 13px;
    color: #6c757d;
    font-weight: 600;
    flex-shrink: 0;
}
.info-row span {
    font-size: 14px;
    color: #212529;
    font-weight: 500;
    word-break: break-word;
}
.info-row span.empty { color: #adb5bd; font-weight: 400; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }

/* ============================================================
   7. KPI CARDS
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.kpi-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border: 1px solid #e9ecef;
}
.kpi-info h3 { font-size: 28px; font-weight: 700; margin: 0 0 5px 0; color: #212529; }
.kpi-info p { margin: 0; font-size: 14px; color: #6c757d; font-weight: 600; }
.kpi-info small { font-size: 12px; color: #adb5bd; }
.kpi-icon {
    width: 48px; height: 48px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.kpi-icon.navy { background: #eef2ff; color: #1a2035; }
.kpi-icon.info { background: #e0f2fe; color: #0284c7; }
.kpi-icon.success { background: #dcfce7; color: #16a34a; }
.kpi-icon.warning { background: #fef3c7; color: #d97706; }

/* Stats row (customer view) */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 15px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.stat-icon.navy { background: #eef2ff; color: #1a2035; }
.stat-icon.warning { background: #fef3c7; color: #d97706; }
.stat-icon.success { background: #dcfce7; color: #16a34a; }
.stat-info p { font-size: 13px; color: #6c757d; font-weight: 600; margin: 0 0 4px 0; }
.stat-info h3 { font-size: 22px; font-weight: 700; color: #212529; margin: 0; }

.dash-row { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }

.chart-container { width: 100%; height: 280px; }

/* ============================================================
   8. TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-clean { width: 100%; border-collapse: collapse; }
.table-clean th {
    background: #f8f9fa;
    font-size: 13px;
    color: #6c757d;
    font-weight: 600;
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
}
.table-clean td {
    font-size: 14px;
    color: #212529;
    padding: 15px 20px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}
.table-clean tr:last-child td { border-bottom: none; }
.table-clean tr:hover { background: #f8f9fa; }
.table-clean td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-clean th.num { text-align: right; }

/* Customer cell — company + contact person */
.customer-cell .company-name {
    color: #0d6efd;
    text-decoration: none;
    font-weight: 600;
    display: block;
}
.customer-cell .company-name:hover { text-decoration: underline; }
.customer-cell .contact-person {
    display: block;
    font-size: 12px;
    color: #adb5bd;
    margin-top: 2px;
    font-weight: 400;
}

/* ============================================================
   9. BADGES & STATUS PILLS
   ============================================================ */
.badge-alloc {
    background: #0d6efd;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-withdraw {
    background: #d97706;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-remaining {
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-status {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-finished { background: #e0f2fe; color: #0284c7; }
.badge-none { background: #f1f3f5; color: #6c757d; }

.role-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.role-admin { background: #0d6efd; color: #fff; }
.role-member { background: #fff; color: #1a2035; border: 1px solid #e2e8f0; }

.perm-summary { color: #6c757d; font-size: 13px; }
.perm-chip-group { display: flex; flex-direction: column; gap: 6px; }
.perm-chip {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    background: #e9ecef;
    color: #495057;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    width: fit-content;
}
.perm-chip .actions { font-weight: 400; color: #6c757d; margin-left: 6px; }

/* ============================================================
   10. BUTTONS
   ============================================================ */
.btn-primary,
.btn-secondary,
.btn-print,
.btn-export,
.btn-cancel,
.btn-save,
.btn-add-line,
.btn-icon-add,
.btn-add-loc {
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s;
    font-family: inherit;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.btn-primary {
    background: #0d6efd;
    color: #fff;
    border: none;
    padding: 10px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover { background: #0b5ed7; text-decoration: none; color: #fff; }

.btn-secondary,
.btn-print,
.btn-export {
    background: #fff;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn-secondary:hover,
.btn-print:hover,
.btn-export:hover { background: #f1f3f5; border-color: #0d6efd; color: #0d6efd; text-decoration: none; }

.btn-cancel {
    background: #fff;
    color: #4a5568;
    border: 1px solid #e2e8f0;
    padding: 10px 20px;
}
.btn-cancel:hover { background: #f1f3f5; }

.btn-save {
    background: #0d6efd;
    color: #fff;
    border: none;
    padding: 10px 20px;
}
.btn-save:hover { background: #0b5ed7; }

.btn-add-line {
    background: #fff;
    color: #0d6efd;
    border: 1px solid #e2e8f0;
    padding: 8px 14px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-add-line:hover { background: #f1f3f5; border-color: #0d6efd; }

.btn-icon-add {
    background: #fff;
    color: #0d6efd;
    border: 1px solid #e2e8f0;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
.btn-icon-add:hover { background: #f1f3f5; border-color: #0d6efd; }

.btn-add-loc {
    background: #fff;
    color: #0d6efd;
    border: 1px solid #e2e8f0;
    width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding: 0;
}
.btn-add-loc:hover { background: #f1f3f5; border-color: #0d6efd; }

/* Action icon buttons */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 6px;
    margin-left: 4px;
    transition: color 0.2s;
    border-radius: 6px;
    color: #6c757d;
}
.action-btn.view:hover { color: #0d6efd; background: #eef2ff; }
.action-btn.edit:hover { color: #0d6efd; background: #eef2ff; }
.action-btn.delete:hover { color: #dc3545; background: #fee2e2; }
.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================================
   11. FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 8px;
}
.form-group label span.req { color: #dc3545; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    color: #1a2035;
    background: #f8fafc;
    transition: border 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0d6efd;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}
.form-group input[readonly] {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}
.form-group textarea { resize: vertical; min-height: 70px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.help-text { font-size: 11px; color: #adb5bd; margin-top: 4px; display: block; }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn select,
.input-with-btn input { flex: 1; }

/* Toggle switch */
.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}
.toggle-info { flex: 1; }
.toggle-info strong { display: block; font-size: 14px; color: #1a2035; margin-bottom: 3px; }
.toggle-info small { font-size: 12px; color: #6c757d; }
.switch { position: relative; display: inline-block; width: 46px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .2s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}
.switch input:checked + .slider { background-color: #0d6efd; }
.switch input:checked + .slider:before { transform: translateX(22px); }

/* ============================================================
   12. MODALS (.ns-modal)
   Scoped to .ns-modal so we never fight other stylesheets
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    overflow-y: auto;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.ns-modal .modal-content {
    background: #fff;
    width: 100%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: fadeIn 0.2s;
    margin: auto;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ns-modal .modal-header {
    padding: 20px 25px;
    background: #1a2035;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.ns-modal .modal-header h2,
.ns-modal .modal-header #modalTitle {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0;
}
.ns-modal .modal-header p,
.ns-modal .modal-header #modalSubtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    margin: 4px 0 0 0;
}
.ns-modal .modal-close {
    background: none;
    border: none;
    font-size: 18px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.2s;
}
.ns-modal .modal-close:hover { color: #fff; background: rgba(255,255,255,0.1); }

.ns-modal .modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.ns-modal .modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
    flex-shrink: 0;
}

/* Inline error inside modal */
.inline-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.inline-error i { font-size: 16px; }

/* Tabs inside modal */
.tab-group {
    display: flex;
    gap: 8px;
    background: #f8f9fa;
    padding: 5px;
    border-radius: 8px;
    margin-bottom: 22px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover { color: #1a2035; }
.tab-btn.active {
    background: #fff;
    color: #0d6efd;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Product line rows */
.product-section {
    margin-top: 22px;
    padding-top: 22px;
    border-top: 1px solid #f1f3f5;
}
.product-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.product-section-header h4 {
    font-size: 14px;
    font-weight: 700;
    color: #1a2035;
    margin: 0;
}
.product-line {
    display: grid;
    grid-template-columns: 1fr 110px 40px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: start;
}
.product-line .input-wrapper { position: relative; }
.product-line select,
.product-line input {
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: #f8fafc;
    font-family: inherit;
    width: 100%;
}
.product-line select:focus,
.product-line input:focus {
    outline: none;
    border-color: #0d6efd;
    background: #fff;
}
.product-line input.qty-error {
    border-color: #dc3545;
    background: #fff5f5;
}
.balance-hint {
    font-size: 11px;
    color: #6c757d;
    margin-top: 4px;
    display: block;
}
.balance-hint.error { color: #dc3545; font-weight: 600; }

.btn-remove-line {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 16px;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.btn-remove-line:hover { background: #fee2e2; }

/* Vehicle section (withdrawal only) */
.vehicle-section { display: none; }
.vehicle-section.active { display: block; }

/* Permission modules (users.php) */
.perm-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 24px 0 8px;
    padding-top: 20px;
    border-top: 1px solid #f1f3f5;
}
.perm-header h4 { font-size: 14px; font-weight: 700; color: #1a2035; margin: 0; }
.perm-header p { font-size: 12px; color: #6c757d; margin: 3px 0 0 0; }

.perm-module {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 12px;
    background: #fdfdfd;
}
.perm-module-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.perm-module-title { font-size: 13px; font-weight: 700; color: #1a2035; margin: 0; }
.perm-module-desc { font-size: 12px; color: #6c757d; margin: 2px 0 0 0; }
.perm-select-all {
    font-size: 12px;
    color: #0d6efd;
    cursor: pointer;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
}
.perm-select-all:hover { text-decoration: underline; }
.perm-select-all:disabled { color: #adb5bd; cursor: not-allowed; text-decoration: none; }

.perm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.perm-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    user-select: none;
}
.perm-checkbox input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #0d6efd;
    margin: 0;
}
.perm-checkbox:hover { color: #0d6efd; }
.perm-checkbox input:disabled { cursor: not-allowed; }

/* ============================================================
   13. INFO BOXES & ALERTS
   ============================================================ */
.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.info-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px 25px;
    margin-top: 24px;
}
.info-box h4 {
    font-size: 14px;
    font-weight: 700;
    color: #1a2035;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.info-box h4 i { color: #0d6efd; font-size: 16px; }
.info-box p { font-size: 13px; color: #6c757d; line-height: 1.6; margin: 0; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-warn {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.alert-warn i { color: #d97706; }

.maintenance-banner {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}
.maintenance-banner i { font-size: 20px; }

/* Filter bar */
.filter-bar { margin-bottom: 20px; }
.filter-bar select {
    padding: 10px 15px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #1a2035;
    min-width: 200px;
    cursor: pointer;
    font-family: inherit;
}
.filter-bar select:focus { outline: none; border-color: #0d6efd; }

/* Chart legend */
.chart-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    font-size: 13px;
    color: #4a5568;
}
.chart-legend .item { display: flex; align-items: center; gap: 8px; }
.chart-legend .swatch { width: 14px; height: 14px; border-radius: 3px; }

/* Logo preview */
.logo-preview {
    margin-top: 10px;
    padding: 12px;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fdfdfd;
}
.logo-preview img { max-height: 60px; max-width: 180px; object-fit: contain; }
.logo-preview .ph {
    width: 60px;
    height: 60px;
    background: #e9ecef;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 20px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid #f1f3f5;
    margin-top: 20px;
}

/* ============================================================
   14. EMPTY & LOADING STATES
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}
.empty-state i { font-size: 40px; color: #cbd5e1; margin-bottom: 15px; }
.loading-state { text-align: center; padding: 40px 20px; color: #6c757d; }

/* ============================================================
   15. AUTH PAGES (login)
   ============================================================ */
.auth-body {
    background-color: #f4f6f9;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.auth-wrap {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.auth-card {
    display: flex;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    overflow: hidden;
    min-height: 600px;
}
.auth-brand {
    flex: 1;
    background-color: #1a2035;
    color: #fff;
    padding: 50px 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}
.auth-brand-inner { position: relative; z-index: 2; }
.auth-logo {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    overflow: hidden;
}
.auth-logo img { width: 80%; height: 80%; object-fit: contain; }
.auth-brand h1 { font-size: 28px; font-weight: 600; margin-bottom: 15px; line-height: 1.3; color: #fff; }
.auth-brand h1 span { color: #4da3ff; }
.auth-brand p { font-size: 15px; color: #a0aec0; line-height: 1.6; margin-bottom: 40px; }
.auth-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 20px 0; }
.auth-features { list-style: none; }
.auth-features li { display: flex; align-items: center; margin-bottom: 20px; }
.auth-feat-icon {
    width: 36px; height: 36px;
    background: rgba(77, 163, 255, 0.1);
    color: #4da3ff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 16px;
}
.auth-features .text strong { display: block; font-size: 14px; color: #fff; }
.auth-features .text small { font-size: 12px; color: #718096; }

.auth-panel {
    flex: 1;
    padding: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}
.auth-panel-inner { max-width: 380px; width: 100%; margin: 0 auto; }
.auth-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    font-size: 18px;
    color: #a0aec0;
    cursor: pointer;
}
.auth-toggle:hover { color: #0d6efd; }
.auth-lock {
    width: 48px; height: 48px;
    background: #eef2ff;
    color: #1a2035;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 20px;
}
.auth-panel h2 { font-size: 24px; font-weight: 700; color: #1a2035; margin-bottom: 8px; }
.auth-sub { font-size: 14px; color: #6c757d; margin-bottom: 30px; }
.auth-group { margin-bottom: 18px; }
.auth-group label { display: block; font-size: 13px; font-weight: 600; color: #4a5568; margin-bottom: 8px; }
.auth-group label i { margin-right: 6px; color: #a0aec0; }
.auth-field { position: relative; }
.auth-field input {
    width: 100%;
    padding: 12px 15px 12px 42px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #1a2035;
    background: #f8fafc;
    transition: all 0.2s;
}
.auth-field input:focus {
    outline: none;
    border-color: #0d6efd;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}
.auth-field-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
    font-size: 14px;
    pointer-events: none;
}
.auth-eye {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.auth-eye:hover { color: #0d6efd; }

.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    font-size: 13px;
}
.auth-check { display: flex; align-items: center; color: #4a5568; cursor: pointer; }
.auth-check input { margin-right: 8px; accent-color: #0d6efd; }
.auth-link { color: #0d6efd; font-weight: 600; text-decoration: none; }
.auth-link:hover { text-decoration: underline; }

.auth-submit {
    width: 100%;
    padding: 14px;
    background-color: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.auth-submit:hover { background: #0b5ed7; }

.auth-copy {
    text-align: center;
    font-size: 12px;
    color: #adb5bd;
    margin-top: 25px;
}
.auth-copy i { margin-right: 6px; }

.auth-or {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: #adb5bd;
    font-size: 12px;
}
.auth-or::before,
.auth-or::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e9ecef;
}
.auth-or span { font-weight: 600; }

.auth-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background: #fff;
    color: #1a2035;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}
.auth-google:hover { background: #f1f3f5; border-color: #0d6efd; text-decoration: none; color: #1a2035; }

.auth-signup {
    text-align: center;
    font-size: 13px;
    color: #6c757d;
    margin-top: 20px;
}

/* Info/warning banner in auth */
.info-banner {
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.info-banner-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}
.auth-maint { justify-content: center; }

/* Success / error boxes on login */
.success,
.error {
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ============================================================
   16. SWEETALERT2 OVERRIDES
   ============================================================ */
.swal2-container { z-index: 10000 !important; }

/* ============================================================
   17. MOBILE RESPONSIVE
   ============================================================ */

/* Tablet (max 1024px) */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-row { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr; }
}

/* Mobile (max 768px) — sidebar becomes icon rail */
@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar-brand { justify-content: center; padding: 15px 8px; }
    .sidebar-brand .logo { margin-right: 0; width: 36px; height: 36px; font-size: 15px; }
    .sidebar-brand .brand-text { display: none; }
    .sidebar-nav { padding: 15px 6px; }
    .sidebar-nav a { justify-content: center; padding: 14px 8px; margin-bottom: 4px; }
    .sidebar-nav a span { display: none; }
    .sidebar-nav a i { margin-right: 0; font-size: 18px; width: auto; }
    .sidebar-footer { padding: 15px 8px; text-align: center; }
    .sidebar-footer .user-email { display: none; }
    .sidebar-footer .sign-out { justify-content: center; }
    .sidebar-footer .sign-out span { display: none; }
    .sidebar-footer .sign-out i { margin-right: 0; font-size: 18px; }

    .main-content { margin-left: 64px; }

    .topbar { padding: 0 15px; height: 56px; }
    .topbar .page-title { font-size: 16px; }
    .topbar .user-profile { gap: 10px; }

    .content-wrapper { padding: 15px; }

    .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .page-header h1 { font-size: 20px; }
    .page-header p { font-size: 13px; }
    .page-header .btn-primary,
    .page-header .btn-print,
    .page-header .btn-secondary { width: 100%; justify-content: center; }

    .kpi-grid { grid-template-columns: 1fr; gap: 12px; }
    .kpi-card { padding: 16px; }
    .kpi-info h3 { font-size: 22px; }
    .kpi-icon { width: 40px; height: 40px; font-size: 16px; }

    .form-row { grid-template-columns: 1fr !important; gap: 12px; }
    .input-with-btn { flex-direction: column; }
    .input-with-btn .btn-icon-add { width: 100%; padding: 12px; }

    .product-line { grid-template-columns: 1fr !important; gap: 8px; padding-bottom: 12px; border-bottom: 1px dashed #e9ecef; }
    .product-line .btn-remove-line { justify-self: flex-end; }

    .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-clean { min-width: 640px; }
    .table-clean th { font-size: 12px; padding: 12px; }
    .table-clean td { font-size: 13px; padding: 12px; }

    /* Modal becomes bottom sheet */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .ns-modal .modal-content {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 92vh;
        animation: slideUp 0.25s ease-out;
    }
    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .ns-modal .modal-header { padding: 16px 20px; }
    .ns-modal .modal-header h2 { font-size: 16px; }
    .ns-modal .modal-body { padding: 20px; }
    .ns-modal .modal-footer { padding: 15px 20px; flex-direction: column-reverse; }
    .ns-modal .modal-footer .btn-cancel,
    .ns-modal .modal-footer .btn-save { width: 100%; justify-content: center; }

    .tab-group { flex-direction: column; }
    .tab-btn { width: 100%; }

    .filter-bar select { width: 100%; }
    .chart-container { height: 220px; }
    .info-box { padding: 16px; }
    .info-box h4 { font-size: 13px; }

    .perm-actions { grid-template-columns: 1fr !important; }

    /* Auth collapses */
    .auth-card { flex-direction: column; min-height: auto; }
    .auth-brand { padding: 40px 20px; text-align: center; }
    .auth-logo { margin: 0 auto 20px; }
    .auth-features { display: none; }
    .auth-panel { padding: 30px 20px; }
    .auth-sep { display: none; }
}

/* Small phones (max 480px) */
@media (max-width: 480px) {
    .sidebar { width: 56px; }
    .main-content { margin-left: 56px; }
    .sidebar-nav a i { font-size: 17px; }

    .topbar { padding: 0 10px; }
    .topbar .page-title { font-size: 15px; }
    .topbar .user-profile i { display: none; }
    .topbar .user-profile i.fa-bell { display: inline-block; }

    .content-wrapper { padding: 10px; }
    .page-header h1 { font-size: 18px; }

    .kpi-card { padding: 14px; }
    .kpi-info h3 { font-size: 20px; }
    .kpi-info p { font-size: 12px; }
    .kpi-info small { font-size: 11px; }
    .kpi-icon { width: 36px; height: 36px; font-size: 14px; }

    .badge-alloc, .badge-withdraw { font-size: 10px; padding: 3px 8px; }
    .table-clean { min-width: 560px; }
    .table-clean th, .table-clean td { padding: 10px 8px; font-size: 12px; }

    .btn-primary, .btn-secondary, .btn-print {
        font-size: 13px;
        padding: 9px 16px;
    }
}

/* ============================================================
   18. PWA STANDALONE MODE
   ============================================================ */
@media (display-mode: standalone) {
    .install-app-banner { display: none !important; }

    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .main-content {
        padding-bottom: env(safe-area-inset-bottom);
    }
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ============================================================
   END
   ============================================================ */