/* ============================================================
   IMS - RMB design system
   Light RMB theme (purple -> green, Poppins) is the default.
   Dark mode is optional: body.theme-dark (toggle in the top bar).
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

:root {
  --primary: #5B2BB5;
  --primary-2: #7C3AED;
  --accent: #0F7A4F;
  --grad: linear-gradient(135deg, #5B21B6 0%, #0F7A4F 100%);
  --grad-soft: linear-gradient(135deg, rgba(91,33,182,.09), rgba(15,122,79,.09));

  /* legacy names used by older inline page styles */
  --gold: var(--primary);
  --gold-light: var(--accent);
  --gold-dim: rgba(91,43,181,0.09);
  --gold-border: rgba(91,43,181,0.28);

  --bg: #EEF1F8;
  --bg-2: #FFFFFF;
  --bg-3: #FFFFFF;
  --bg-4: #F4F6FC;
  --surface: #FFFFFF;
  --surface-2: #F4F6FC;
  --surface-3: #E6EAF4;
  --border: #DCE1EE;
  --border-2: #7F89A5;
  --text: #131728;
  --text-2: #3F485C;
  --text-3: #5C667B;
  --danger: #B42318;
  --danger-dim: rgba(217,45,32,0.08);
  --success: #0B7A3E;
  --warn: #8A5300;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 2px 14px rgba(40,30,90,0.06);
  --shadow-lg: 0 18px 50px rgba(30,20,80,0.22);
  --topbar-h: 64px;
  --sidebar-w: 248px;
}

body.theme-dark {
  --grad: linear-gradient(135deg, #5B21B6 0%, #1E9A5C 100%);
  --bg: #0F111A;
  --bg-2: #151826;
  --bg-3: #181B2B;
  --bg-4: #1F2336;
  --surface: #181B2B;
  --surface-2: #1F2336;
  --surface-3: #272C44;
  --border: rgba(255,255,255,0.08);
  --border-2: rgba(255,255,255,0.14);
  --text: #EEF0F8;
  --text-2: #A5ACC4;
  --text-3: #8189A5;
  --primary: #A78BFA;
  --primary-2: #8B5CF6;
  --accent: #34D399;
  --gold-dim: rgba(167,139,250,0.14);
  --gold-border: rgba(167,139,250,0.35);
  --danger: #F87171;
  --danger-dim: rgba(248,113,113,0.12);
  --success: #34D399;
  --warn: #FBBF24;
  --shadow: 0 2px 14px rgba(0,0,0,0.35);
}

body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-weight: 600; }
a { color: var(--primary); }
button, input, select, textarea { font-family: inherit; }

/* ---------------- TOPBAR ---------------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 100; gap: 12px;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-btn { display: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text); cursor: pointer; align-items: center; justify-content: center; flex-shrink: 0; }
.menu-btn svg { width: 20px; height: 20px; fill: currentColor; }
.brand-icon { width: 38px; height: 38px; background: var(--grad); border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon svg { width: 18px; height: 18px; fill: #fff; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: .01em; white-space: nowrap; }
.brand-name span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; background: var(--bg-4); border: 1px solid var(--border); border-radius: 40px; padding: 5px 14px 5px 5px; font-size: 13px; color: var(--text-2); cursor: pointer; max-width: 220px; }
.user-chip span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }
.theme-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }
.theme-btn:hover { background: var(--bg-4); color: var(--text); }

/* ---------------- SIDEBAR ---------------- */
.sidebar {
  position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, #4C1D95 0%, #3F3A9E 48%, #0E8F66 100%);
  padding: 18px 14px 28px; display: flex; flex-direction: column; gap: 3px;
  z-index: 90; overflow-y: auto; transition: transform .25s ease;
}
body.theme-dark .sidebar { background: linear-gradient(180deg, #1C1640 0%, #1B2145 55%, #0B4B3A 100%); }
.sidebar-label { font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.55); padding: 0 12px; margin: 16px 0 4px; }
.sidebar-label:first-child { margin-top: 0; }
.sidebar-btn {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: none; background: transparent; color: rgba(255,255,255,.86); font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-align: left; text-decoration: none; transition: background .15s;
}
.sidebar-btn:hover { background: rgba(255,255,255,.13); color: #fff; }
.sidebar-btn.active { background: rgba(255,255,255,.2); color: #fff; box-shadow: inset 3px 0 0 #fff; }
.sidebar-btn svg { width: 16px; height: 16px; flex-shrink: 0; fill: currentColor; opacity: .9; }
.sidebar-overlay { display: none; position: fixed; inset: 0; top: var(--topbar-h); background: rgba(15,10,40,.5); z-index: 85; }

/* ---------------- MAIN ---------------- */
.main { margin-left: var(--sidebar-w); margin-top: var(--topbar-h); padding: 28px; min-height: calc(100vh - var(--topbar-h)); overflow-x: hidden; }
.no-sidebar .main { margin-left: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { color: var(--text-3); font-size: 13px; }

/* ---------------- STATS ---------------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.1; word-break: break-word; }
.stat-value.gold { color: var(--primary); }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------------- FILTER BAR ---------------- */
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text); font-size: 13px; padding: 9px 12px; outline: none; min-width: 0; max-width: 100%; }
.filter-bar input::placeholder { color: var(--text-3); }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--gold-dim); }
.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.filter-bar .grow { flex: 1 1 220px; }
.status-select { background: var(--bg-4); color: var(--text); border: 1px solid var(--border-2); border-radius: 8px; padding: 6px 8px; font-size: 12px; outline: none; min-width: 140px; }

/* ---------------- TABLES ---------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: auto; width: 100%; max-height: none; }
.table-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.table-title { font-size: 15px; font-weight: 600; color: var(--text); }
.table-actions { display: flex; gap: 8px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; z-index: 5; background: var(--grad); padding: 12px 14px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #fff; white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-4); }
.nowrap { white-space: nowrap; }
.id-badge { display: inline-block; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.name-cell { color: var(--text); font-weight: 500; }
.type-badge { display: inline-block; background: var(--gold-dim); border: 1px solid var(--gold-border); border-radius: 6px; padding: 2px 9px; font-size: 11.5px; font-weight: 500; color: var(--primary); white-space: nowrap; }
.cat-badge { display: inline-block; background: rgba(31,163,101,.10); border: 1px solid rgba(31,163,101,.28); border-radius: 6px; padding: 2px 9px; font-size: 11.5px; font-weight: 500; color: var(--accent); white-space: nowrap; }
.value-cell { font-weight: 600; color: var(--text); white-space: nowrap; }
.muted { color: var(--text-3); }
.qr-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--primary); }
.qr-btn svg { width: 17px; height: 17px; fill: currentColor; }
.qr-img { width: 44px; height: 44px; border-radius: 6px; object-fit: contain; background: #fff; padding: 2px; }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ---------------- BUTTONS ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 10px; border: 1px solid transparent; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap; line-height: 1.3; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-4); color: var(--text); }
.btn-gold, .btn-primary { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 2px 10px rgba(91,43,181,.25); }
.btn-gold:hover, .btn-primary:hover { filter: brightness(1.07); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(217,45,32,.3); }
.btn-danger:hover { background: rgba(217,45,32,.16); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.edit-btn, .view-btn { background: var(--gold-dim); border: 1px solid var(--gold-border); color: var(--primary); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 14px; transition: .15s; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.edit-btn:hover, .view-btn:hover { background: var(--gold-border); }
.delete-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(217,45,32,.25); background: var(--danger-dim); color: var(--danger); cursor: pointer; transition: .15s; flex-shrink: 0; font-size: 14px; }
.delete-btn:hover { background: rgba(217,45,32,.18); }
.delete-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* ---------------- MODALS ---------------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,10,40,.6); backdrop-filter: blur(5px); z-index: 200; align-items: center; justify-content: center; padding: 12px; }
.modal.open { display: flex; }
.modal-box { display: flex; flex-direction: column; max-height: 92vh; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); width: 460px; max-width: 100%; box-shadow: var(--shadow-lg); animation: slideUp .2s ease; overflow: hidden; }
.modal-box.modal-lg { width: 960px; max-width: 100%; }
.modal-box.modal-xl { width: 1100px; max-width: 100%; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.modal-head { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border-2); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 18px; line-height: 1; }
.modal-close:hover { background: var(--bg-4); color: var(--text); }
.modal-close svg { width: 14px; height: 14px; fill: currentColor; }
.modal-footer { padding: 14px 24px 18px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--border); flex-shrink: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px 18px; align-content: start; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.modal-body input, .modal-body select, .modal-body textarea,
.form-grid input, .form-grid select, .form-grid textarea, .auth-card input, .auth-card select {
  width: 100%; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text); font-size: 13.5px; padding: 10px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus, .form-grid input:focus, .form-grid select:focus, .auth-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--gold-dim); }
.modal-body input::placeholder, .modal-body textarea::placeholder { color: var(--text-3); }
.modal-body input[readonly], .modal-body input:disabled, .modal-body select:disabled { opacity: .7; cursor: not-allowed; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 5px; }
.field-label .req { color: var(--danger); }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin: 6px 0 -2px; padding-bottom: 6px; border-bottom: 1px dashed var(--border-2); }
.section-hint, .hint { font-size: 12px; color: var(--text-3); }
.dest-box { display: flex; gap: 10px; align-items: center; background: var(--grad-soft); border: 1px solid var(--gold-border); border-radius: 12px; padding: 10px 14px; font-size: 13px; color: var(--text); flex-wrap: wrap; justify-content: space-between; }
.dest-box strong { color: var(--primary); }
.readonly-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 16px; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; }
.readonly-grid .ro-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.readonly-grid .ro-value { font-size: 13.5px; color: var(--text); font-weight: 500; word-break: break-word; }
.choice-row { display: flex; gap: 12px; flex-wrap: wrap; }
.choice-card { flex: 1; min-width: 150px; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 18px; cursor: pointer; text-align: center; transition: all .15s; }
.choice-card:hover { border-color: var(--primary); background: var(--gold-dim); }
.choice-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.choice-sub { font-size: 12px; color: var(--text-3); }

/* progress (bulk add) */
.progress { height: 12px; background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .25s ease; }
.progress-text { font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-active { background: rgba(18,161,80,.12); color: var(--success); border: 1px solid rgba(18,161,80,.3); }
.badge-deactive { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(217,45,32,.3); }
.badge-maintenance { background: rgba(183,121,31,.12); color: var(--warn); border: 1px solid rgba(183,121,31,.3); }
.badge-store { background: rgba(37,99,235,.10); color: #2563EB; border: 1px solid rgba(37,99,235,.28); }
/* light "gate pass requested" hint on the dashboard */
.badge-pending { margin-top: 4px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; background: rgba(183,121,31,.08); color: var(--warn); border: 1px dashed rgba(183,121,31,.45); }
.badge-sold { background: var(--bg-4); color: var(--text-2); border: 1px solid var(--border-2); }
body.theme-dark .badge-store { color: #7db7ff; }

/* history */
.history-list { display: flex; flex-direction: column; }
.history-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--grad); margin-top: 6px; flex-shrink: 0; }
.history-title { font-size: 13.5px; color: var(--text); font-weight: 500; }
.history-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* print list */
#printList { max-height: 220px; overflow-y: auto; margin: 4px 0; }
#printList > div { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
#printList input[type=checkbox] { width: auto; accent-color: var(--primary); }

/* switch */
.switch { position: relative; display: inline-flex; justify-content: center; align-items: center; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-2); border-radius: 999px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + .slider { background: var(--danger); }
.switch input:checked + .slider:before { transform: translateX(19px); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.pager .pg { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pager button { min-width: 34px; height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; font-size: 13px; }
.pager button:hover:not(:disabled) { background: var(--bg-4); color: var(--text); }
.pager button.cur { background: var(--grad); color: #fff; border-color: transparent; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager select { background: var(--bg-4); border: 1px solid var(--border-2); border-radius: 9px; color: var(--text); padding: 6px 8px; }

/* chips / tabs / cards */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; background: var(--bg-4); border: 1px solid var(--border-2); font-size: 12.5px; color: var(--text); cursor: default; }
.chip b { color: var(--primary); }
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--primary); background: var(--gold-dim); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 16px; border: none; background: none; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text-2); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.card h3 { font-size: 14.5px; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 200px) 1fr auto; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; }
.bar-row .bar { height: 10px; border-radius: 99px; background: var(--bg-4); overflow: hidden; border: 1px solid var(--border); }
.bar-row .bar i { display: block; height: 100%; background: var(--grad); }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.bar-row .num { color: var(--text-2); font-weight: 600; white-space: nowrap; }

/* toast */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface); border: 1px solid var(--border-2); border-left: 4px solid var(--primary); color: var(--text); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: slideUp .2s ease; }
.toast.ok { border-left-color: var(--success); }
.toast.err { border-left-color: var(--danger); }

/* ---------------- AUTH PAGES (login / QR login / migration) ---------------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-hero { flex: 1.1; background: linear-gradient(180deg, #5B21B6 0%, #3B3A8F 55%, #14663F 100%); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; text-align: center; gap: 18px; }
.auth-hero .logo { width: 84px; height: 84px; background: #fff; border-radius: 20px; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-hero .logo svg { width: 40px; height: 40px; fill: #5B21B6; }
.auth-hero h1 { font-size: 34px; font-weight: 700; }
.auth-hero p { max-width: 380px; font-size: 14px; opacity: .9; }
.auth-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 28px; background: #F3F6FB; }
.auth-card { width: 100%; max-width: 400px; background: #fff; color: #1B1F2E; border-radius: 24px; padding: 34px 30px; box-shadow: 0 10px 40px rgba(40,30,90,.12); margin: auto; }
.auth-wrap > .auth-card { align-self: center; }
.auth-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 4px; color: #1B1F2E; }
.auth-sub { text-align: center; color: #8D96AB; font-size: 13px; margin-bottom: 22px; }
.auth-card input { background: #F3F6FB; border: 1px solid #D5DBE8; color: #1B1F2E; margin-bottom: 14px; padding: 13px 14px; }
.auth-card .pw { position: relative; }
.auth-card .pw .toggle-pw { position: absolute; right: 14px; top: 13px; cursor: pointer; color: #8D96AB; font-size: 12px; user-select: none; }
.auth-error { background: rgba(217,45,32,.08); border: 1px solid rgba(217,45,32,.3); color: #D92D20; font-size: 13px; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.auth-foot { text-align: center; font-size: 12px; color: #8D96AB; margin-top: 18px; }
.auth-btn, .auth-card .btn-primary { width: 100%; padding: 13px; border: none; border-radius: 12px; background: var(--grad); color: #fff; font-weight: 600; font-size: 14.5px; cursor: pointer; box-shadow: 0 4px 14px rgba(91,43,181,.3); }
.auth-btn:disabled { opacity: .65; cursor: not-allowed; }
body.auth { background: #F3F6FB; }

/* ---------------- SCROLLBARS ---------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 20px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 1100px) { .form-grid.cols-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar { transform: translateX(-100%); width: min(280px, 82vw); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-overlay { display: block; }
  .main { margin-left: 0; padding: 16px; }
  .topbar { padding: 0 12px; }
  .user-chip span.nm { display: none; }
  .user-chip { padding: 5px; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 700px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .brand-name { font-size: 14px; }
  .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .stat-value { font-size: 19px; }
  .filter-bar { padding: 12px; }
  .filter-bar > *, .filter-bar .filter-group { flex: 1 1 calc(50% - 10px); }
  .filter-bar input, .filter-bar select { width: 100%; }
  .filter-bar .grow { flex-basis: 100%; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.modal-lg, .modal-box.modal-xl { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .modal-body { padding: 16px; } .modal-head { padding: 14px 16px; } .modal-footer { padding: 12px 16px; }
  .modal-footer .btn { flex: 1; }
  .table-header { padding: 12px 14px; }
  .table-actions .btn { flex: 1; }
  /* card layout for tables marked class="rt" (cells carry data-label) */
  table.rt, table.rt tbody, table.rt tr, table.rt td { display: block; width: 100%; }
  table.rt thead { display: none; }
  table.rt tr { padding: 12px 14px; border-bottom: 8px solid var(--bg); background: var(--surface); }
  table.rt tbody td { border: none; padding: 5px 0; display: flex; justify-content: space-between; gap: 14px; align-items: center; white-space: normal; text-align: right; }
  table.rt tbody td::before { content: attr(data-label); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); text-align: left; flex-shrink: 0; }
  table.rt tbody td[data-label=""]::before, table.rt tbody td:not([data-label])::before { display: none; }
  table.rt tbody td.name-cell { font-size: 15px; justify-content: flex-start; text-align: left; }
  .row-actions { flex-wrap: wrap; justify-content: flex-end; }
  .bar-row { grid-template-columns: 90px 1fr auto; }
  .pager { justify-content: center; }
}
@media (max-width: 420px) { .stats-row { grid-template-columns: 1fr; } }

/* ---------------- LIGHT THEME REFINEMENTS (RMB purple/green, high contrast) ---------------- */
body:not(.theme-dark) .sidebar { background: linear-gradient(180deg, #4C1D95 0%, #3D2F9B 50%, #0B6B49 100%); }
body:not(.theme-dark) .sidebar-label { color: rgba(255,255,255,.72); }
body:not(.theme-dark) .sidebar-btn { color: #FFFFFF; }
body:not(.theme-dark) .sidebar-btn:hover { background: rgba(255,255,255,.16); }
body:not(.theme-dark) .sidebar-btn.active { background: rgba(255,255,255,.26); box-shadow: inset 3px 0 0 #fff; font-weight: 600; }
body:not(.theme-dark) .topbar { background: #fff; border-bottom: 3px solid transparent; border-image: linear-gradient(90deg,#5B21B6,#0F7A4F) 1; }
body:not(.theme-dark) tbody tr:nth-child(even) td { background: #F8F9FD; }
body:not(.theme-dark) tbody tr:hover td { background: #EFE9FC; }
body:not(.theme-dark) .stat-card, body:not(.theme-dark) .card, body:not(.theme-dark) .table-wrap, body:not(.theme-dark) .filter-bar { box-shadow: 0 1px 2px rgba(30,25,80,.06), 0 6px 18px rgba(30,25,80,.06); }
body:not(.theme-dark) .filter-bar input, body:not(.theme-dark) .filter-bar select,
body:not(.theme-dark) .modal-body input, body:not(.theme-dark) .modal-body select, body:not(.theme-dark) .modal-body textarea,
body:not(.theme-dark) .form-grid input, body:not(.theme-dark) .form-grid select { background: #fff; }
body:not(.theme-dark) .badge-active { background: #E3F6EA; } body:not(.theme-dark) .badge-deactive { background: #FDE8E6; }
body:not(.theme-dark) .badge-maintenance { background: #FFF1D6; } body:not(.theme-dark) .badge-store { background: #E3EDFF; color: #1D4ED8; }
@media (max-width: 700px) { body:not(.theme-dark) table.rt tbody tr:nth-child(even) td { background: transparent; } }

/* ---------------- HCI: focus, targets, motion, totals, numbers ---------------- */
:focus-visible { outline: 3px solid var(--primary-2); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.btn { min-height: 38px; } .btn-sm { min-height: 32px; }
.edit-btn, .view-btn, .delete-btn, .qr-btn { min-width: 36px; min-height: 36px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { padding: 14px 16px !important; font-size: 14px !important; font-weight: 700; color: var(--text); background: var(--surface-2) !important; border-top: 2px solid var(--primary); white-space: nowrap; }
tfoot td:first-child { text-transform: uppercase; letter-spacing: .06em; font-size: 12px !important; color: var(--primary); }
tfoot td + td { text-align: right; font-variant-numeric: tabular-nums; }

/* loading overlay + skeleton */
.page-loader { position: fixed; inset: 0; z-index: 500; display: none; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: rgba(238,241,248,.82); backdrop-filter: blur(2px); color: var(--text); font-weight: 600; }
body.theme-dark .page-loader { background: rgba(15,17,26,.82); }
.page-loader.show { display: flex; }
.spin { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--border-2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-strip { height: 4px; background: var(--border); overflow: hidden; border-radius: 4px; display: none; }
.load-strip.show { display: block; } .load-strip i { display: block; height: 100%; width: 35%; background: var(--grad); animation: strip 1s ease-in-out infinite; }
@keyframes strip { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

/* export menu */
.exp-bar { display: flex; justify-content: flex-end; padding: 8px 12px 0; }
.exp-menu { position: relative; display: inline-block; }
.exp-list { display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; min-width: 150px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: var(--shadow-lg); overflow: hidden; }
.exp-menu.open .exp-list { display: block; }
.exp-list button { display: block; width: 100%; text-align: left; padding: 10px 14px; border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 13px; }
.exp-list button:hover { background: var(--gold-dim); }

/* searchable dropdown panel */
.ss-panel { display: none; position: fixed; z-index: 1000; background: var(--surface); color: var(--text); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; flex-direction: column; }
.ss-panel.open { display: flex; }
.ss-search { padding: 8px; border-bottom: 1px solid var(--border); }
.ss-search input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--bg-4); color: var(--text); font-size: 13.5px; outline: none; }
.ss-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--gold-dim); }
.ss-panel ul { list-style: none; overflow-y: auto; flex: 1; padding: 4px; margin: 0; }
.ss-panel li { padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.ss-panel li.act { background: var(--gold-dim); } .ss-panel li.sel { font-weight: 700; color: var(--primary); }
.ss-empty { display: none; padding: 14px; color: var(--text-3); text-align: center; font-size: 13px; }
.ss-panel.sheet { left: 0 !important; right: 0; bottom: 0; top: auto !important; width: 100% !important; max-height: 70vh !important; border-radius: 18px 18px 0 0; }

/* ---------------- PRINT ---------------- */
@media print {
  body { background: #fff; }
  .no-print, .topbar, .sidebar { display: none !important; }
  .main { margin: 0; padding: 0; }
}
/* ===================== GATE PASS (print) ===================== */
.gatepass-page { max-width: 780px; margin: 40px auto; background: #fff; color: #111; border-radius: 6px; overflow: hidden; box-shadow: 0 10px 50px rgba(0,0,0,0.6); border: 1px solid #e5e5e5; }
.gatepass-header { background: linear-gradient(135deg, #4c1d95 0%, #0f7a52 100%); color: #fff; padding: 26px 32px; display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #1FA365; }
.gatepass-header .gp-brand { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: 0.02em; }
.gatepass-header .gp-brand span { color: var(--gold-light); }
.gatepass-header .gp-type { font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: #4c1d95; background: #fff; padding: 6px 14px; border-radius: 20px; font-weight: 700; }
.gatepass-body { padding: 30px 32px; }
.gp-top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 6px; padding-bottom: 18px; border-bottom: 2px dashed #ddd; }
.gp-no { font-family: 'Syne', sans-serif; font-weight: 700; color: #222; font-size: 14px; }
.gp-qr-box { text-align: center; flex-shrink: 0; }
.gp-qr-box img { width: 84px; height: 84px; border: 1px solid #ddd; border-radius: 6px; padding: 4px; background: #fff; }
.gp-qr-caption { font-size: 9.5px; color: #999; margin-top: 4px; line-height: 1.3; }
.gp-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #999; margin: 20px 0 10px; border-bottom: 1px solid #ddd; padding-bottom: 5px; font-weight: 600; }
.gp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px; }
.gp-grid .gp-item .gp-label { font-size: 11px; color: #888; }
.gp-grid .gp-item .gp-value { font-size: 14px; color: #111; font-weight: 600; }
.gp-summary-box { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; background: #f7f5ef; border: 1px solid #e8e2d0; border-radius: 8px; padding: 16px 18px; }
.gp-summary-item .gp-summary-label { font-size: 10.5px; color: #8a7a3f; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.gp-summary-item .gp-summary-value { font-family: 'Syne', sans-serif; font-size: 17px; font-weight: 700; color: #444; }
.gp-summary-item.highlight .gp-summary-value { color: #8a6d1f; }
.gp-summary-item.profit .gp-summary-value { color: #1c7a4d; }
.gp-summary-item.loss .gp-summary-value { color: #b02a2a; }
.gp-signatures { display: flex; justify-content: space-between; margin-top: 60px; }
.gp-sign { text-align: center; width: 220px; }
.gp-sign .line { border-top: 1px solid #333; margin-bottom: 6px; padding-top: 6px; font-size: 12px; color: #666; }
.gp-footer { text-align: center; font-size: 11px; color: #999; padding: 14px; border-top: 1px solid #eee; background: #fafafa; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .gatepass-page { box-shadow: none; margin: 0; border: none; }
}


/* dashboard: the list scrolls inside its card so the header row stays visible */
.vscroll { max-height: calc(100vh - 300px); min-height: 220px; overflow: auto; }
.table-wrap:has(> .vscroll) { overflow: hidden; }
@media (max-width: 700px) { .vscroll { max-height: none; overflow: visible; } }

/* overview */
.bi-card .cv { overflow-y: auto; overflow-x: hidden; } .bi-card .cvi { position: relative; height: 100%; min-height: 180px; }
tr.grp-row td { background: var(--gold-dim) !important; color: var(--primary); font-weight: 700; padding: 10px 14px !important; letter-spacing: .02em; }
tr.sub-row td { background: var(--surface-2) !important; font-weight: 700; color: var(--text); border-top: 1px solid var(--border-2); padding: 10px 14px !important; text-align: right; }
tr.sub-row td:first-child { text-align: left; }
