/* ============================================================
   IMM — K-Care Hospital
   assets/css/app.css
   Full design system — Outfit font, purple theme
   ============================================================ */

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

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand */
  --purple:        #8B5CF6;
  --purple-dark:   #6D28D9;
  --purple-darker: #5B21B6;
  --purple-light:  #EDE9FE;
  --purple-xlight: #F5F3FF;

  /* Sidebar */
  --sidebar-bg:    #1A0B3B;
  --sidebar-w:     220px;
  --topbar-h:      56px;

  /* Surfaces */
  --surface:       #FFFFFF;
  --page-bg:       #F8F7FF;
  --surface-2:     #F9FAFB;

  /* Borders */
  --border:        #E8E4F8;
  --border-2:      #D1D5DB;

  /* Text */
  --text:          #1A1040;
  --text-2:        #4B5563;
  --text-3:        #9CA3AF;

  /* Status colours */
  --green:         #16A34A;
  --green-bg:      #F0FDF4;
  --green-border:  #86EFAC;

  --amber:         #D97706;
  --amber-bg:      #FFFBEB;
  --amber-border:  #FCD34D;

  --red:           #DC2626;
  --red-bg:        #FEF2F2;
  --red-border:    #FCA5A5;

  --blue:          #2563EB;
  --blue-bg:       #EFF6FF;
  --blue-border:   #93C5FD;

  --teal:          #0F766E;
  --teal-bg:       #F0FDFA;
  --teal-border:   #99F6E4;

  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(139,92,246,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg:     0 10px 40px rgba(139,92,246,.12), 0 4px 12px rgba(0,0,0,.08);

  /* Radius */
  --r-sm:   6px;
  --r:      8px;
  --r-md:   10px;
  --r-lg:   12px;
  --r-xl:   16px;
  --r-full: 9999px;

  /* Transitions */
  --t:  .15s ease;
  --t2: .25s ease;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--page-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  background: linear-gradient(135deg, #1A0B3B 0%, #2D1B69 50%, #1A0B3B 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

/* decorative blobs */
.login-body::before,
.login-body::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: .15;
  pointer-events: none;
}
.login-body::before {
  width: 50vw; height: 50vw;
  max-width: 400px; max-height: 400px;
  background: var(--purple);
  top: -100px; right: -80px;
}
.login-body::after {
  width: 40vw; height: 40vw;
  max-width: 300px; max-height: 300px;
  background: #6D28D9;
  bottom: -100px; left: -80px;
}

.login-card {
  background: #fff;
  border-radius: var(--r-xl);
  padding: 44px 48px;
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 44px; height: 44px;
  background: var(--purple);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.login-logo-text { line-height: 1.25; }
.login-logo-text strong { font-size: 16px; font-weight: 600; color: var(--text); display: block; }
.login-logo-text span   { font-size: 12px; color: var(--text-3); }

.login-title { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }

.login-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--t2);
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* ── Mini (icon-only) mode ─── */
.sidebar.mini { width: 56px; }
.sidebar.mini .sidebar-logo-text,
.sidebar.mini .nav-divider,
.sidebar.mini .nav-label,
.sidebar.mini .nav-badge,
.sidebar.mini .sidebar-user-name,
.sidebar.mini .sidebar-user-role { display: none !important; }
.sidebar.mini .sidebar-logo { padding: 14px 11px; justify-content: center; }
.sidebar.mini .nav-item { padding: 10px; margin: 1px 6px; justify-content: center; gap: 0; }
.sidebar.mini .nav-item svg { width: 18px; height: 18px; opacity: .7; }
.sidebar.mini .nav-item.active svg { opacity: 1; }
.sidebar.mini .sidebar-footer { padding: 8px 6px; }
.sidebar.mini .sidebar-user { justify-content: center; }
.sidebar.mini .sidebar-toggle-btn svg { transform: rotate(180deg); }
/* Tooltip on mini mode */
.sidebar.mini .nav-item { position: relative; }
.sidebar.mini .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%; transform: translateY(-50%);
  background: #2D1B5E;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  padding: 5px 12px;
  border-radius: var(--r);
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.1);
}
.sidebar.mini .nav-item:hover::after { opacity: 1; }

/* ── Logo ─── */
.sidebar-logo {
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--purple);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-logo-text strong { color: #fff; font-size: 13px; font-weight: 600; display: block; line-height: 1.3; }
.sidebar-logo-text span   { color: rgba(255,255,255,.4); font-size: 10px; }

/* ── Collapse toggle button ─── */
.sidebar-toggle-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.35); padding: 2px;
  display: flex; align-items: center;
  transition: color var(--t);
  margin-left: auto;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { color: rgba(255,255,255,.8); }
.sidebar-toggle-btn svg { width: 16px; height: 16px; transition: transform var(--t2); }

/* ── Flat nav container ─── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 4px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

/* ── Section dividers (label only, not clickable) ─── */
.nav-divider {
  padding: 14px 20px 4px;
  font-size: 9px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.22);
  user-select: none;
}

/* ── Nav items ─── */
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin: 1px 8px;
  border-radius: var(--r); cursor: pointer;
  color: rgba(255,255,255,.6);
  font-size: 13px; font-weight: 400;
  transition: all var(--t); text-decoration: none; position: relative;
}
.nav-item:hover  { background: rgba(139,92,246,.2); color: rgba(255,255,255,.9); text-decoration: none; }
.nav-item.active { background: var(--purple); color: #fff; font-weight: 500; }
.nav-item svg    { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  margin-left: auto; background: #EF4444; color: #fff;
  font-size: 10px; border-radius: var(--r-full);
  padding: 1px 6px; font-weight: 600; min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t);
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.sidebar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { color: #fff; font-size: 12px; font-weight: 500; line-height: 1.3; }
.sidebar-user-role { color: rgba(255,255,255,.4); font-size: 10px; text-transform: capitalize; }

/* ── Main area ───────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 200;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); flex: 1; }
.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}
.topbar-search input {
  padding: 6px 12px 6px 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  font-size: 13px;
  background: var(--page-bg);
  color: var(--text);
  outline: none;
  width: 220px;
  transition: all var(--t);
}
.topbar-search input:focus {
  border-color: var(--purple);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(139,92,246,.1);
}
.topbar-search svg {
  position: absolute;
  left: 10px;
  width: 14px; height: 14px;
  color: var(--text-3);
  pointer-events: none;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: #DDD6FE transparent;
}
.page-content::-webkit-scrollbar { width: 5px; }
.page-content::-webkit-scrollbar-thumb { background: #DDD6FE; border-radius: 3px; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-label .req { color: var(--red); margin-left: 2px; }

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t);
  width: 100%;
}
.form-control:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139,92,246,.1);
}
.form-control:disabled {
  background: var(--surface-2);
  color: var(--text-3);
  cursor: not-allowed;
}
.form-control.is-invalid { border-color: var(--red); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.1); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 3px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  grid-column: 1 / -1;
}

/* ── Checkbox / Radio ───────────────────────────────────── */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 15px; height: 15px;
  accent-color: var(--purple);
  cursor: pointer;
  flex-shrink: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--t);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}
.btn-primary:hover {
  background: var(--purple-dark);
  border-color: var(--purple-dark);
  text-decoration: none;
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-outline:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  text-decoration: none;
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-3);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text-2); text-decoration: none; }

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  text-decoration: none;
}

.btn-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-border);
}
.btn-success:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  text-decoration: none;
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 7px; }
.btn-icon svg { width: 16px; height: 16px; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-block { width: 100%; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-green  { background: var(--green-bg);   color: var(--green);  border: 1px solid var(--green-border); }
.badge-amber  { background: var(--amber-bg);   color: var(--amber);  border: 1px solid var(--amber-border); }
.badge-red    { background: var(--red-bg);     color: var(--red);    border: 1px solid var(--red-border); }
.badge-blue   { background: var(--blue-bg);    color: var(--blue);   border: 1px solid var(--blue-border); }
.badge-teal   { background: var(--teal-bg);    color: var(--teal);   border: 1px solid var(--teal-border); }
.badge-purple { background: var(--purple-light);color: var(--purple-darker); border: 1px solid #DDD6FE; }
.badge-gray   { background: #F3F4F6; color: #6B7280; border: 1px solid #E5E7EB; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.card-body  { padding: 16px; }

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}
.stat-sub  { font-size: 12px; color: var(--text-3); }
.stat-up   { color: var(--green) !important; }
.stat-down { color: var(--red)   !important; }
.stat-bar  { height: 3px; background: var(--border); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 2px; transition: width .4s ease; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  color: var(--text);
  border-bottom: 1px solid #F3F4F6;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--purple-xlight); }

/* Checkbox column */
th.col-check, td.col-check {
  width: 36px;
  padding-right: 4px;
  text-align: center;
}

.table-actions { display: flex; gap: 6px; align-items: center; }

/* Sortable header */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--purple); }
th.sortable::after { content: ' ↕'; opacity: .4; font-size: 9px; }
th.sort-asc::after  { content: ' ↑'; opacity: 1; color: var(--purple); }
th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--purple); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.filter-search {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.filter-search input {
  padding-left: 32px;
  width: 100%;
}
.filter-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-3);
  pointer-events: none;
}
.filter-right { margin-left: auto; display: flex; gap: 8px; }

/* ============================================================
   TABS
   ============================================================ */
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 7px 16px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  color: var(--text-3);
  transition: all var(--t);
  white-space: nowrap;
}
.tab-btn:hover  { color: var(--text); background: rgba(0,0,0,.04); }
.tab-btn.active { background: var(--purple); color: #fff; }
.tab-pane       { display: none; }
.tab-pane.active{ display: block; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
.modal-lg { max-width: 720px; }
.modal-sm { max-width: 380px; }
@keyframes modalIn {
  from { transform: translateY(-12px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.modal-header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  padding: 4px;
  border-radius: var(--r-sm);
  transition: all var(--t);
  display: flex;
  align-items: center;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-close svg   { width: 18px; height: 18px; }
.modal-body   { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--red-bg);   border-color: var(--red-border);   color: var(--red); }
.alert-warning { background: var(--amber-bg); border-color: var(--amber-border); color: var(--amber); }
.alert-info    { background: var(--blue-bg);  border-color: var(--blue-border);  color: var(--blue); }
.alert-success { background: var(--green-bg); border-color: var(--green-border); color: var(--green); }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .4s ease; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
}

/* ============================================================
   ASSET DETAIL — sticky edit bar
   ============================================================ */
.sticky-bar {
  position: sticky;
  top: -1px;           /* -1px prevents 1px gap at scroll top */
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
  margin: -20px -20px 20px;
  /* Extend background to cover topbar border line */
  padding-top: 13px;
}
.sticky-bar-id {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-light);
  padding: 3px 10px;
  border-radius: var(--r-full);
}
.sticky-bar-name { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }
.sticky-bar-actions { display: flex; gap: 8px; margin-left: auto; }

/* ============================================================
   PHOTO GALLERY
   ============================================================ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: border-color var(--t);
}
.photo-thumb:hover { border-color: var(--purple); }
.photo-thumb.primary { border-color: var(--purple); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .primary-tag {
  position: absolute;
  bottom: 4px; left: 4px;
  background: var(--purple);
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: var(--r-sm);
  font-weight: 600;
}
.photo-upload-zone {
  aspect-ratio: 1;
  border: 2px dashed var(--border-2);
  border-radius: var(--r);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--t);
  color: var(--text-3);
  font-size: 12px;
  gap: 4px;
}
.photo-upload-zone:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-xlight); }
.photo-upload-zone svg { width: 22px; height: 22px; }

/* ============================================================
   TIMELINE (ticket activity log)
   ============================================================ */
.timeline { display: flex; flex-direction: column; }
.tl-item  { display: flex; gap: 12px; padding-bottom: 20px; position: relative; }
.tl-item::before {
  content: '';
  position: absolute;
  left: 11px; top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  font-size: 10px;
  font-weight: 700;
}
.tl-dot-purple { background: var(--purple-light); color: var(--purple-darker); }
.tl-dot-green  { background: var(--green-bg);     color: var(--green); }
.tl-dot-red    { background: var(--red-bg);        color: var(--red); }
.tl-dot-amber  { background: var(--amber-bg);      color: var(--amber); }
.tl-dot-gray   { background: #F3F4F6;              color: #9CA3AF; }
.tl-content    { flex: 1; padding-top: 2px; }
.tl-meta       { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.tl-text       { font-size: 13px; color: var(--text-2); }
.tl-note       {
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 6px;
}

/* ============================================================
   TICKET PIPELINE
   ============================================================ */
.ticket-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 16px 0;
  overflow-x: auto;
  padding-bottom: 4px;
}
.pipeline-step {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
}
.pipeline-node {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-full);
  border: 1px solid var(--border-2);
  color: var(--text-3);
  background: var(--surface-2);
  white-space: nowrap;
}
.pipeline-node.done    { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.pipeline-node.current { background: var(--purple); color: #fff; border-color: var(--purple); }
.pipeline-arrow { width: 24px; height: 2px; background: var(--border); flex-shrink: 0; }
.pipeline-arrow.done { background: var(--green-border); }

/* ============================================================
   KCARE ID GENERATOR (add asset form)
   ============================================================ */
.kcare-preview {
  background: var(--purple-xlight);
  border: 1px solid var(--purple-light);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple-darker);
  letter-spacing: .03em;
  margin-top: 4px;
  font-family: monospace;
}
.kcare-preview .kcare-part { opacity: .5; }
.kcare-preview .kcare-fill { opacity: 1; }
.abbr-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.abbr-chip {
  padding: 3px 10px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t);
  font-family: monospace;
}
.abbr-chip:hover { background: var(--purple-light); border-color: var(--purple); color: var(--purple-darker); }

/* ============================================================
   QR PRINT STYLES — scoped to .qr-label
   ============================================================ */
.qr-label {
  width: 90mm;
  min-height: 45mm;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 6mm 5mm;
  display: flex;
  gap: 5mm;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  page-break-inside: avoid;
}
.qr-label-info { flex: 1; min-width: 0; }
.qr-label-name {
  font-size: 11px;
  font-weight: 700;
  color: #1A1040;
  line-height: 1.3;
  margin-bottom: 3px;
}
.qr-label-id   { font-size: 9px; font-family: monospace; color: #6D28D9; margin-bottom: 2px; }
.qr-label-dept { font-size: 9px; color: #6B7280; margin-bottom: 2px; }
.qr-label-pm   { font-size: 9px; color: #D97706; }
.qr-label-qr   { flex-shrink: 0; }

/* ============================================================
   UTILITIES
   ============================================================ */
.d-flex   { display: flex; }
.d-grid   { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1  { margin-top: 4px; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-1  { margin-bottom: 4px; }
.mb-2  { margin-bottom: 8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.mb-5  { margin-bottom: 20px; }
.text-muted  { color: var(--text-3); }
.text-small  { font-size: 12px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }
.w-100  { width: 100%; }
.mono   { font-family: monospace; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-header h1 { font-size: 20px; font-weight: 600; color: var(--text); }
.page-header p  { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .3; }
.empty-state p   { font-size: 14px; margin-top: 6px; }

.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.loading-spin {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--r);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn .2s ease;
  max-width: 320px;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-warning { background: var(--amber); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .three-col  { grid-template-columns: 1fr 1fr; }
}

/* ── Tablet: sidebar mini ── */
@media (max-width: 1024px) {
  .main-area.sidebar-mini { margin-left: 56px; }
}

/* ── Hamburger button ── */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: none;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  color: var(--text-2);
  flex-shrink: 0;
  padding: 0;
  transition: background var(--t);
}
.hamburger-btn:hover { background: var(--page-bg); }

/* ── Mobile overlay ── */
.mob-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 399;
  backdrop-filter: blur(2px);
}
.mob-nav-overlay.active { display: block; }

/* ── Mobile breakpoint ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  /* Hide sidebar by default — shown as drawer when .mob-open */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    width: 260px !important;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    /* ensure it stays visible when open even if mini class is set */
  }
  .sidebar.mob-open {
    transform: translateX(0);
    /* Override mini mode on mobile — show full sidebar */
    width: 260px !important;
  }
  .sidebar.mob-open .sidebar-logo-text,
  .sidebar.mob-open .nav-label,
  .sidebar.mob-open .nav-badge,
  .sidebar.mob-open .sidebar-user-name,
  .sidebar.mob-open .sidebar-user-role { display: flex !important; }
  .sidebar.mob-open .sidebar-logo { padding: 14px 16px; justify-content: flex-start; }
  .sidebar.mob-open .nav-item { padding: 10px 12px; margin: 1px 8px; justify-content: flex-start; gap: 10px; }

  /* Main area takes full width — no sidebar offset */
  .main-area { margin-left: 0 !important; }
  .main-area.sidebar-mini { margin-left: 0 !important; }

  /* Prevent body scroll when nav open */
  body.mob-nav-active { overflow: hidden; }

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* Layout adjustments */
  .stats-grid    { grid-template-columns: 1fr 1fr; }
  .form-grid     { grid-template-columns: 1fr; }
  .two-col,
  .three-col     { grid-template-columns: 1fr; }
  .page-content  { padding: 14px; }
  .topbar        { padding: 0 12px; gap: 8px; }
  .topbar-search { display: none; }
  .filter-bar    { flex-direction: column; align-items: stretch; }
  .filter-right  { margin-left: 0; }
  .table-wrap    { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Show search on mobile but narrower */
  .topbar-search { display: flex; }
  .topbar-search input { width: 120px; font-size: 12px; }
  /* Hide "Add Asset" text, show icon only */
  .topbar-add-text { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .login-card { padding: 24px 18px; width: calc(100vw - 32px); max-width: 100%; }
}

/* ── Prevent decorative blobs causing horizontal scroll ── */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100%; }
.login-body::before,
.login-body::after { max-width: 100vw; overflow: hidden; }

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, .topbar, .filter-bar, .sticky-bar,
  .btn, .tab-bar, .modal-backdrop { display: none !important; }
  .main-area { overflow: visible; }
  .page-content { padding: 0; overflow: visible; }
  body { background: #fff; }
}

/* ── SmartSelect — type-to-search component ─────────────── */
.smart-select-wrap { position: relative; }
.smart-select-wrap .form-control { font-size: 13px; }

/* Dropdown */
.smart-select-wrap [id$="-dd"] {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 9998;
  max-height: 240px;
  overflow-y: auto;
  font-size: 13px;
}

/* QR scan modal */
#qr-scanner-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
#qr-scanner-modal.open { display: flex; }

/* Quick-add inline form */
.quick-add-form {
  background: var(--purple-xlight);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  margin-top: 6px;
}
