/* ============================================================
   style.css — SLS Matchbox QMS Design System
   Mobile-first, dark factory theme, safety-yellow accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base: #0d0f14;
  --bg-surface: #161b24;
  --bg-elevated: #1e2535;
  --bg-card: #1a2030;
  --border: #2a3348;
  --border-light: #323d54;

  --accent: #f5c518;
  --accent-dim: #c9a214;
  --accent-glow: rgba(245, 197, 24, 0.15);

  --text-primary: #e8edf5;
  --text-secondary: #8b95aa;
  --text-muted: #566070;

  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3);

  --nav-height: 64px;
  --bottom-nav-height: 72px;
  --sidebar-width: 260px;

  --transition: 0.2s ease;
}


/* ── Light Theme ──────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base: #f0f2f7;
  --bg-surface: #ffffff;
  --bg-elevated: #e8ecf4;
  --bg-card: #ffffff;
  --border: #d1d8e8;
  --border-light: #b8c2d8;

  --accent: #d4a800;
  --accent-dim: #b8920a;
  --accent-glow: rgba(212, 168, 0, 0.12);

  --text-primary: #1a2035;
  --text-secondary: #4a5568;
  --text-muted: #8a94a8;

  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-card: 0 2px 12px rgba(0,0,0,0.07);
}
[data-theme="light"] body {
  background: var(--bg-base);
  color: var(--text-primary);
}
[data-theme="light"] select.form-control option {
  background: #fff;
  color: #1a2035;
}
[data-theme="light"] .modal { background: #fff; }
[data-theme="light"] .modal-header { background: #fff; }
[data-theme="light"] #sidebar { background: #fff; }
[data-theme="light"] #top-header { background: #fff; }
[data-theme="light"] #bottom-nav { background: #fff; }
[data-theme="light"] .toast { background: #fff; }

/* Theme toggle button */
#theme-toggle {
  background: none; border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all 0.2s ease;
  flex-shrink: 0;
}
#theme-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--accent); }

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* ============================================================
   AUTH / LOGIN
   ============================================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(245,197,24,0.08) 0%, var(--bg-base) 60%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { width: 96px; height: 96px; border-radius: 20px; object-fit: contain; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--accent); margin-top: 12px; letter-spacing: 0.5px; }
.login-logo p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.login-hint { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 20px; font-size: 0.75rem; color: var(--text-secondary); line-height: 1.6; }
.login-hint strong { color: var(--accent); }

/* ============================================================
   APP SHELL
   ============================================================ */
#app-shell { display: none; min-height: 100vh; }
#app-shell.visible { display: flex; }

/* ── Top Header ─────────────────────────────────────────────── */
#top-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 16px;
  z-index: 100;
  gap: 12px;
}
#menu-toggle { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 8px; border-radius: var(--radius-sm); display: flex; align-items: center; }
#menu-toggle svg { width: 22px; height: 22px; }
#header-logo { display: flex; align-items: center; gap: 10px; flex: 1; }
#header-logo img { width: 36px; height: 36px; border-radius: 8px; }
#header-logo span { font-size: 0.95rem; font-weight: 700; color: var(--accent); }
#header-logo small { display: block; font-size: 0.65rem; color: var(--text-secondary); font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: 8px; }
#notif-btn { position: relative; background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 8px; border-radius: var(--radius-sm); }
#notif-btn svg { width: 22px; height: 22px; }
#notif-badge { position: absolute; top: 4px; right: 4px; background: var(--red); color: #fff; font-size: 0.6rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
#user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-glow); border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--accent); cursor: pointer; }

/* Mobile: slim icon-only header */
@media (max-width: 767px) {
  #top-header {
    height: 44px;
    padding: 0 10px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    justify-content: space-between;
  }
  #header-logo { display: none; }
  #main-content { margin-top: 44px; }
  #menu-toggle { padding: 6px; }
  #notif-btn { padding: 6px; }
  #user-avatar { width: 30px; height: 30px; font-size: 0.75rem; }
  #theme-toggle { width: 30px; height: 30px; font-size: 0.85rem; }
}


/* ── Sidebar Overlay ─────────────────────────────────────────── */
#sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  display: none;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* ── Sidebar ──────────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#sidebar.open { transform: translateX(0); }
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-header img { width: 44px; height: 44px; border-radius: 10px; }
.sidebar-header-text h2 { font-size: 0.95rem; font-weight: 700; color: var(--accent); }
.sidebar-header-text p { font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }
.sidebar-user-info {
  padding: 12px 20px;
  background: var(--bg-elevated);
  margin: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.sidebar-user-info .user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.sidebar-user-info .user-role { font-size: 0.72rem; color: var(--accent); font-weight: 500; margin-top: 2px; }
#sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.nav-section-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: 12px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(245,197,24,0.2); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
#logout-btn {
  width: 100%; padding: 10px; border-radius: var(--radius-sm);
  background: var(--red-bg); border: 1px solid rgba(239,68,68,0.2);
  color: var(--red); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
#logout-btn:hover { background: var(--red); color: #fff; }

/* ── Main Content ────────────────────────────────────────────── */
#main-content {
  flex: 1;
  margin-top: var(--nav-height);
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  min-height: calc(100vh - var(--nav-height));
  width: 100%;
}
.page { display: none; padding: 16px; animation: fadeIn 0.3s ease; max-width: 100%; overflow-x: hidden; }

.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Bottom Navigation (Mobile) ──────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center;
  z-index: 100;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px 4px; cursor: pointer;
  color: var(--text-muted); font-size: 0.6rem; font-weight: 500;
  transition: all var(--transition); border-radius: var(--radius-sm);
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item.active svg { filter: drop-shadow(0 0 6px rgba(245,197,24,0.5)); }

/* ============================================================
   COMPONENTS
   ============================================================ */

/* Page Header */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 1.3rem; font-weight: 800; color: var(--text-primary); }
.page-header p { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-header-row h1 { font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-header h3 { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 16px; }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer; position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--kpi-color, var(--accent));
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--kpi-bg, var(--accent-glow)); }
.kpi-icon svg { width: 15px; height: 15px; color: var(--kpi-color, var(--accent)); }
.kpi-value { font-size: 1.4rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.kpi-label { font-size: 0.68rem; color: var(--text-secondary); font-weight: 500; line-height: 1.3; }

/* Alert Banner */
.alert-banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 0.82rem;
  animation: pulse-border 2s ease-in-out infinite;
}
.alert-danger { background: var(--red-bg); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }
.alert-warning { background: var(--amber-bg); border: 1px solid rgba(245,158,11,0.3); color: var(--amber); }
.alert-info { background: var(--blue-bg); border: 1px solid rgba(59,130,246,0.3); color: var(--blue); }
.alert-success { background: var(--green-bg); border: 1px solid rgba(34,197,94,0.3); color: var(--green); }
@keyframes pulse-border { 0%,100% { opacity: 1; } 50% { opacity: 0.8; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  border: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #1a1a00; }
.btn-primary:hover { background: var(--accent-dim); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 14px 24px; font-size: 0.95rem; border-radius: var(--radius); }
.btn-full { width: 100%; }
.btn svg { width: 16px; height: 16px; }

/* Quick Action Buttons */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.quick-action-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all var(--transition); text-align: center;
}
.quick-action-btn:hover { background: var(--accent-glow); border-color: rgba(245,197,24,0.3); transform: translateY(-2px); }
.quick-action-btn svg { width: 28px; height: 28px; color: var(--accent); }
.quick-action-btn span { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-control {
  width: 100%; padding: 12px 14px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 0.9rem; transition: border-color var(--transition);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
select.form-control option { background: var(--bg-elevated); color: var(--text-primary); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions .btn { flex: 1; }

/* Result Selector */
.result-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-option { display: none; }
.result-label {
  padding: 10px 8px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); text-align: center;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  transition: all var(--transition); color: var(--text-secondary);
}
.result-option:checked + .result-label.approved { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.result-option:checked + .result-label.rejected { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.result-option:checked + .result-label.hold { background: var(--amber-bg); border-color: var(--amber); color: var(--amber); }
.result-label:hover { border-color: var(--border-light); color: var(--text-primary); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-grey { background: var(--bg-elevated); color: var(--text-secondary); }

/* Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead { background: var(--bg-elevated); }
th { padding: 10px 12px; text-align: left; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tr:hover td { background: var(--bg-elevated); }

/* List Items */
.list-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 10px; transition: all var(--transition); cursor: pointer;
}
.list-item:hover { border-color: var(--border-light); transform: translateY(-1px); }
.list-item-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 0.75rem; color: var(--text-secondary); margin-top: 3px; }
.list-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 500; display: none; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  position: sticky; top: 0;
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  padding: 16px 20px; display: flex; align-items: center;
  justify-content: space-between; z-index: 1;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.modal-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 6px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-x: hidden; }
/* Ensure no form control overflows modal width */
.modal-body input,
.modal-body select,
.modal-body textarea { max-width: 100%; box-sizing: border-box; }

/* Workflow Stepper */
.workflow-stepper { display: flex; flex-direction: column; gap: 0; margin: 16px 0; }
.workflow-step { display: flex; gap: 12px; }
.step-connector { display: flex; flex-direction: column; align-items: center; }
.step-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg-elevated); color: var(--text-muted);
}
.step-dot.active { background: var(--accent); color: #1a1a00; border-color: var(--accent); }
.step-dot.done { background: var(--green); color: #fff; border-color: var(--green); }
.step-line { width: 2px; flex: 1; min-height: 24px; background: var(--border); margin: 2px 0; }
.step-line.done { background: var(--green); }
.step-content { padding: 4px 0 20px; flex: 1; }
.step-label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); line-height: 32px; }
.step-notes { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }

/* Accordion */
.accordion-item { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.accordion-header {
  padding: 14px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); transition: background var(--transition);
}
.accordion-header:hover { background: var(--bg-elevated); }
.accordion-header h4 { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); }
.accordion-header .chevron { transition: transform 0.2s; color: var(--text-muted); }
.accordion-header.open .chevron { transform: rotate(180deg); }
.accordion-body { display: none; padding: 16px; background: var(--bg-elevated); border-top: 1px solid var(--border); }
.accordion-body.open { display: block; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--bg-elevated); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { padding: 8px 14px; border-radius: 6px; border: none; background: none; color: var(--text-secondary); font-size: 0.82rem; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all var(--transition); }
.tab-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-card); }

/* All module-level tab bars — always single scrollable row, never wrap */
.tab-bar-scroll {
  display: flex; gap: 0;
  flex-wrap: nowrap; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 2px solid var(--border);
  margin-bottom: 14px;
}
.tab-bar-scroll::-webkit-scrollbar { display: none; }

/* Mobile responsive adjustments (< 768px) */
@media (max-width: 767px) {
  /* Compact page header */
  .module-title { font-size: 1.1rem !important; }
  .module-subtitle { font-size: 0.68rem !important; }

  /* Single-column forms on mobile */
  .form-row { grid-template-columns: 1fr !important; }
  .form-control { font-size: 0.85rem; padding: 10px 12px; }
  .form-label { font-size: 0.72rem; }
  /* Date inputs — don't stretch full width */
  input[type="date"].form-control { max-width: 160px; width: auto; }

  /* KPI cards — 2 columns */
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .kpi-value { font-size: 1.1rem; }

  /* Buttons */
  .btn { font-size: 0.8rem; padding: 9px 14px; }
  .btn-sm { font-size: 0.72rem; padding: 5px 9px; }

  /* Modals */
  .modal { max-height: 92vh; }
  .modal-body { padding: 14px; }

  /* Tables */
  table { font-size: 0.74rem; }
  th, td { padding: 7px 9px; }

  /* Inline tab containers in module JS — force no-wrap scroll */
  div[style*="overflow-x:auto"] { flex-wrap: nowrap !important; }
}


/* Score Bar */
.score-bar { margin: 8px 0; }
.score-bar-label { display: flex; justify-content: space-between; font-size: 0.78rem; margin-bottom: 4px; }
.score-bar-track { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.score-high { background: var(--green); }
.score-med { background: var(--amber); }
.score-low { background: var(--red); }

/* Stat Row */
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 0.82rem; color: var(--text-secondary); }
.stat-value { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

/* Photo Upload */
.photo-upload-zone {
  border: 2px dashed var(--border-light); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: all var(--transition); background: var(--bg-elevated);
}
.photo-upload-zone:hover { border-color: var(--accent); background: var(--accent-glow); }
.photo-upload-zone svg { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 8px; }
.photo-upload-zone p { font-size: 0.82rem; color: var(--text-secondary); }
.photo-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.photo-thumb { width: 72px; height: 72px; border-radius: var(--radius-sm); object-fit: cover; border: 2px solid var(--border); }

/* Empty State */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 0.88rem; }

/* Search Bar */
.search-bar { position: relative; margin-bottom: 16px; }
.search-bar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.search-bar input { padding-left: 38px; }

/* Compliance Expiry Status */
.expiry-valid { color: var(--green); }
.expiry-soon { color: var(--amber); }
.expiry-expired { color: var(--red); }

/* Chart Container */
.chart-container { position: relative; height: 220px; margin: 12px 0; }

/* QR Code display */
.qr-display { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.qr-display canvas, .qr-display img { border: 4px solid #fff; border-radius: 8px; }
.qr-label { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); text-align: center; }
.qr-sublabel { font-size: 0.72rem; color: var(--text-secondary); text-align: center; }

/* Section title */
.section-title { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 20px 0 10px; }

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-gap { display: flex; gap: 8px; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ── Mobile Base (all screens) ──────────────────────── */
.page { padding: 12px; }

/* ── Tablet / Desktop (768px+) ──────────────────────── */
@media (min-width: 768px) {
  #app-shell.visible { gap: 0; }
  #top-header { display: none; }
  #sidebar { position: fixed; transform: translateX(0); }
  #sidebar.sidebar-desktop { transform: translateX(0); }
  #main-content { margin-left: var(--sidebar-width); margin-top: 0; }
  #sidebar-overlay { display: none !important; }
  #menu-toggle { display: none; }
  #bottom-nav { left: var(--sidebar-width); }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { border-radius: var(--radius-xl); margin: 20px; max-width: 560px; align-self: center; }
  .modal-overlay { align-items: center; }
  .page { padding: 20px; }
}
@media (min-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .quick-actions { grid-template-columns: repeat(5, 1fr); }
  #main-content { padding: 0 0 24px; }
  .page { padding: 24px; max-width: 900px; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  #top-header, #sidebar, #bottom-nav, .no-print { display: none !important; }
  #main-content { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; }
}

/* ── Loading Spinner ──────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast Notification ───────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: calc(var(--bottom-nav-height) + 16px); left: 50%;
  transform: translateX(-50%); z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: 90%; max-width: 360px;
}
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 0.85rem; font-weight: 500; color: var(--text-primary);
  box-shadow: var(--shadow); width: 100%;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
}
.toast.toast-success { border-color: var(--green); color: var(--green); background: var(--green-bg); }
.toast.toast-error { border-color: var(--red); color: var(--red); background: var(--red-bg); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ── NCR Kanban ──────────────────────────────────────────────── */
/* ── Invoice Item Row Grid (responsive) ──────────────────────── */
.so-item-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 1fr 1fr;
  gap: 6px;
  align-items: end;
}
@media (max-width: 767px) {
  .so-item-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.ncr-status-bar {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px;
}
.ncr-status-chip {
  padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
  white-space: nowrap; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text-secondary);
  transition: all var(--transition);
}
.ncr-status-chip.active { background: var(--accent-glow); border-color: rgba(245,197,24,0.3); color: var(--accent); }
