/* ============================================
   MediStock – Hospital Inventory System
   Design: Clinical precision meets operational clarity
   Palette: Deep navy + medical teal + alert spectrum
   ============================================ */

:root {
  --navy:       #0d1b2a;
  --navy-mid:   #1b2f45;
  --navy-light: #253d57;
  --teal:       #0a9396;
  --teal-light: #94d2bd;
  --teal-pale:  #e0f4f5;
  --white:      #ffffff;
  --off-white:  #f0f4f8;
  --border:     #d1dce8;

  /* Status colors */
  --ok:         #2d9e5f;
  --ok-bg:      #e8f7f0;
  --low:        #d4820a;
  --low-bg:     #fef3e0;
  --critical:   #c0392b;
  --critical-bg:#fde8e6;
  --out:        #7f1d1d;
  --out-bg:     #fecaca;

  /* Typography */
  --font-body:  'Inter', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', monospace;

  /* Layout */
  --nav-h:      60px;
  --radius:     8px;
  --radius-lg:  12px;
  --shadow:     0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--navy);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---- Navbar ---- */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--navy);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; min-width: 180px; }
.nav-logo { font-size: 1.4rem; }
.nav-title { font-size: 1.1rem; font-weight: 700; color: var(--white); letter-spacing: -0.02em; }
.nav-badge {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--teal); color: var(--white); padding: 2px 8px; border-radius: 20px;
}
.nav-badge.supplier { background: #7c3aed; }

.nav-links { display: flex; list-style: none; gap: 0.25rem; flex: 1; }
.nav-links a {
  color: #94a3b8; font-size: 0.875rem; font-weight: 500;
  padding: 0.4rem 0.75rem; border-radius: var(--radius);
  transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--white); background: var(--navy-light); text-decoration: none;
}
.nav-links a.active { color: var(--teal-light); }

.nav-user { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.user-name { color: #94a3b8; font-size: 0.85rem; white-space: nowrap; }
.btn-logout {
  font-size: 0.8rem; font-weight: 600; color: var(--white);
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  padding: 0.3rem 0.75rem; border-radius: var(--radius); transition: all 0.15s;
}
.btn-logout:hover { background: #c0392b; border-color: #c0392b; text-decoration: none; }

/* ---- Main Content ---- */
.main-content { flex: 1; padding: 1.75rem 2rem; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ---- Flash Messages ---- */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1.25rem; border-radius: var(--radius); margin-bottom: 1.25rem;
  font-size: 0.9rem; font-weight: 500;
}
.flash-success { background: var(--ok-bg); color: var(--ok); border-left: 4px solid var(--ok); }
.flash-error   { background: var(--critical-bg); color: var(--critical); border-left: 4px solid var(--critical); }
.flash-warning { background: var(--low-bg); color: var(--low); border-left: 4px solid var(--low); }
.flash-info    { background: var(--teal-pale); color: var(--teal); border-left: 4px solid var(--teal); }
.flash-close   { background: none; border: none; cursor: pointer; font-size: 1.2rem; opacity: 0.6; line-height: 1; }

/* ---- Page Header ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.75rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--navy); letter-spacing: -0.03em; }
.page-header p  { color: #64748b; font-size: 0.9rem; margin-top: 0.2rem; }
.page-actions   { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---- Cards ---- */
.card {
  background: var(--white); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fafbfc;
}
.card-header h2 { font-size: 0.95rem; font-weight: 600; color: var(--navy); }
.card-body { padding: 1.25rem; }

/* ---- Stat Cards ---- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem; border: 1px solid var(--border);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.teal::before   { background: var(--teal); }
.stat-card.ok::before     { background: var(--ok); }
.stat-card.warn::before   { background: var(--low); }
.stat-card.danger::before { background: var(--critical); }

.stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1.1; margin: 0.3rem 0; }
.stat-sub   { font-size: 0.8rem; color: #94a3b8; }
.stat-icon  { position: absolute; right: 1.25rem; top: 1.25rem; font-size: 1.75rem; opacity: 0.15; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--white); font-size: 0.875rem; }
thead { background: var(--navy); }
thead th { color: #94a3b8; font-size: 0.72rem; font-weight: 600; text-transform: uppercase;
           letter-spacing: 0.08em; padding: 0.75rem 1rem; text-align: left; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--off-white); }
tbody td { padding: 0.75rem 1rem; color: #374151; vertical-align: middle; }
.td-mono { font-family: var(--font-mono); font-size: 0.8rem; color: #64748b; }

/* ---- Badges ---- */
.badge {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}
.badge-ok       { background: var(--ok-bg);       color: var(--ok); }
.badge-low      { background: var(--low-bg);       color: var(--low); }
.badge-critical { background: var(--critical-bg);  color: var(--critical); }
.badge-out      { background: var(--out-bg);       color: var(--out); }
.badge-admin    { background: #dbeafe; color: #1d4ed8; }
.badge-supplier { background: #ede9fe; color: #6d28d9; }
.badge-nurse    { background: #fce7f3; color: #9d174d; }
.badge-in       { background: var(--ok-bg); color: var(--ok); }
.badge-out-tx   { background: var(--critical-bg); color: var(--critical); }
.badge-adj      { background: #e0f2fe; color: #0369a1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--font-body); font-size: 0.875rem; font-weight: 600;
  padding: 0.5rem 1.1rem; border-radius: var(--radius); border: none;
  cursor: pointer; transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary   { background: var(--teal);    color: var(--white); }
.btn-primary:hover   { background: #07797c; }
.btn-secondary { background: var(--off-white); color: var(--navy); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: var(--critical); color: var(--white); }
.btn-danger:hover    { background: #a93226; }
.btn-warning   { background: var(--low);      color: var(--white); }
.btn-warning:hover   { background: #b8700a; }
.btn-navy      { background: var(--navy);     color: var(--white); }
.btn-navy:hover      { background: var(--navy-mid); }
.btn-sm { font-size: 0.78rem; padding: 0.3rem 0.7rem; }
.btn-lg { font-size: 1rem; padding: 0.7rem 1.5rem; }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: #374151; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input,
.form-group select,
.form-group textarea {
  font-family: var(--font-body); font-size: 0.9rem; color: var(--navy);
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 0.55rem 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s; outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,147,150,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: #94a3b8; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, #0d3b52 100%);
  padding: 1rem;
}
.login-card {
  background: var(--white); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px; overflow: hidden;
}
.login-header {
  background: var(--teal); padding: 2rem 2rem 1.5rem;
  text-align: center; color: var(--white);
}
.login-header .logo { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }
.login-header h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.04em; }
.login-header p  { opacity: 0.85; font-size: 0.85rem; margin-top: 0.3rem; }
.login-body { padding: 2rem; }
.login-body .form-group { margin-bottom: 1rem; }
.login-body input {
  width: 100%; font-size: 1rem;
  padding: 0.75rem 1rem; border-radius: var(--radius);
}
.login-submit {
  width: 100%; font-size: 1rem; padding: 0.85rem;
  background: var(--teal); color: var(--white); border: none;
  border-radius: var(--radius); font-weight: 700; cursor: pointer;
  margin-top: 0.5rem; transition: background 0.15s;
}
.login-submit:hover { background: #07797c; }
.login-error {
  background: var(--critical-bg); color: var(--critical);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  font-size: 0.85rem; font-weight: 500; margin-bottom: 1rem;
  border-left: 4px solid var(--critical);
}
.login-footer { text-align: center; font-size: 0.75rem; color: #94a3b8; padding: 0 2rem 1.5rem; }

/* ---- Dashboard Grid ---- */
.dashboard-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 1.25rem; }
.col-8  { grid-column: span 8; }
.col-4  { grid-column: span 4; }
.col-6  { grid-column: span 6; }
.col-12 { grid-column: span 12; }

/* ---- Stock Level Bar ---- */
.stock-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 4px; }
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.stock-bar-fill.ok       { background: var(--ok); }
.stock-bar-fill.low      { background: var(--low); }
.stock-bar-fill.critical { background: var(--critical); }
.stock-bar-fill.out      { background: var(--out); }

/* ---- Alert Card ---- */
.alert-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1rem; border-radius: var(--radius);
  background: var(--off-white); border: 1px solid var(--border);
  margin-bottom: 0.5rem; transition: background 0.1s;
}
.alert-item:last-child { margin-bottom: 0; }
.alert-item.critical { background: var(--critical-bg); border-color: #f5a89e; }
.alert-item.low      { background: var(--low-bg);      border-color: #f5d08e; }
.alert-icon { font-size: 1.2rem; flex-shrink: 0; }
.alert-info { flex: 1; min-width: 0; }
.alert-name { font-weight: 600; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-loc  { font-size: 0.78rem; color: #64748b; }
.alert-qty  { text-align: right; flex-shrink: 0; }
.alert-qty strong { display: block; font-size: 1.1rem; font-weight: 700; }
.alert-qty span   { font-size: 0.75rem; color: #94a3b8; }

/* ============================================
   NURSE STOCK-OUT STATION — refined, calm, pro
   ============================================ */
body.role-nurse {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(10,147,150,0.12), transparent 60%),
    #070b13;
}

.nurse-mode { max-width: 100%; padding: 0; display: flex; flex-direction: column; min-height: 100vh; }

/* ---- Top bar ---- */
.nurse-topbar {
  background: rgba(13,27,42,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0.85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.nurse-topbar .brand { display: flex; align-items: center; gap: 0.55rem; }
.brand-logo { font-size: 1.35rem; }
.brand-name { color: var(--white); font-weight: 800; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand-tag {
  font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--teal-light); background: rgba(10,147,150,0.15);
  padding: 3px 8px; border-radius: 20px; margin-left: 0.25rem;
}
.nurse-topbar-right { display: flex; align-items: center; gap: 1rem; }

.session-counter {
  display: flex; flex-direction: column; align-items: center; line-height: 1;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius); padding: 0.35rem 0.85rem; min-width: 56px;
}
.session-num { color: var(--teal-light); font-size: 1.25rem; font-weight: 800; font-family: var(--font-mono); }
.session-lbl { color: #5b6b80; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.nurse-id { display: flex; align-items: center; gap: 0.4rem; color: #94a3b8; font-size: 0.85rem; font-weight: 500; }
.nurse-id-icon { font-size: 0.9rem; }
.nurse-topbar .logout-btn {
  font-size: 0.78rem; color: #94a3b8;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  padding: 0.45rem 1rem; border-radius: var(--radius); cursor: pointer;
  text-decoration: none; transition: all 0.15s;
}
.nurse-topbar .logout-btn:hover { background: rgba(192,57,43,0.2); color: #fca5a5; border-color: rgba(192,57,43,0.3); text-decoration: none; }

/* ---- Location bar ---- */
.location-bar {
  background: rgba(13,27,42,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 0.85rem 1.5rem;
}
.location-bar-inner { max-width: 620px; margin: 0 auto; }

.location-current { display: flex; align-items: center; gap: 0.85rem; }
.location-pin { font-size: 1.3rem; }
.location-label { color: #5b6b80; font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.location-value { color: var(--white); font-size: 1.15rem; font-weight: 700; margin-top: 1px; }
.location-change {
  margin-left: auto; font-size: 0.78rem; font-weight: 600; color: var(--teal-light);
  background: rgba(10,147,150,0.12); border: 1px solid rgba(10,147,150,0.25);
  padding: 0.45rem 1rem; border-radius: var(--radius); cursor: pointer; transition: all 0.15s;
}
.location-change:hover { background: rgba(10,147,150,0.22); }

.location-picker-prompt { color: #94a3b8; font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.location-picker-prompt strong { color: var(--teal-light); }
.location-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.location-chip {
  font-size: 0.92rem; font-weight: 600; color: #cbd5e1;
  background: var(--navy-mid); border: 1.5px solid var(--navy-light);
  padding: 0.7rem 1.25rem; border-radius: 999px; cursor: pointer; transition: all 0.15s;
  min-height: 46px;
}
.location-chip:hover { border-color: var(--teal); color: var(--white); background: var(--navy-light); }
.location-chip:active { transform: scale(0.97); }

/* ---- Scan zone ---- */
.nurse-scan-zone {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 1.75rem 1.5rem 2.5rem;
}

.nurse-error-banner {
  width: 100%; max-width: 560px;
  background: linear-gradient(180deg, #c0392b, #a93226); color: var(--white); font-weight: 600;
  text-align: center; padding: 1rem 1.25rem; font-size: 0.95rem; display: none;
  border-radius: var(--radius-lg); margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(192,57,43,0.35);
  animation: shake 0.4s ease;
}
.nurse-error-banner.show { display: block; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

/* ---- Scan box ---- */
.scan-box {
  width: 100%; max-width: 560px;
  background: linear-gradient(180deg, rgba(27,47,69,0.9), rgba(19,34,51,0.9));
  border-radius: 22px; border: 1px solid rgba(255,255,255,0.08);
  padding: 1.75rem;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* Locked state (before location chosen) */
.scan-locked {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5rem 1rem; text-align: center;
}
.scan-locked-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.6; animation: bobUp 1.6s ease-in-out infinite; }
@keyframes bobUp { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.scan-locked-text { color: #64748b; font-size: 1rem; font-weight: 500; }

/* Active state */
.scan-active { display: none; }
.scan-active.ready { display: block; }

.scan-prompt {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  color: var(--teal-light); font-size: 0.85rem; font-weight: 600;
  margin-bottom: 1rem; text-align: center;
}
.scan-pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--teal);
  box-shadow: 0 0 0 0 rgba(10,147,150,0.6); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(10,147,150,0.5); }
  70% { box-shadow: 0 0 0 12px rgba(10,147,150,0); }
  100% { box-shadow: 0 0 0 0 rgba(10,147,150,0); }
}

.scan-input-wrap { position: relative; margin-bottom: 1.25rem; }
.scan-icon { position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); font-size: 1.4rem; color: var(--teal); pointer-events: none; }
#barcodeInput {
  width: 100%; font-family: var(--font-mono); font-size: 1.3rem; font-weight: 600;
  color: var(--white); background: rgba(7,11,19,0.6); border: 2px solid var(--teal);
  border-radius: var(--radius-lg); padding: 1.05rem 1rem 1.05rem 3.4rem;
  outline: none; caret-color: var(--teal); letter-spacing: 0.04em;
  box-shadow: 0 0 0 4px rgba(10,147,150,0.12);
  transition: box-shadow 0.2s;
}
#barcodeInput::placeholder { color: #475569; font-size: 1rem; font-weight: 400; letter-spacing: 0; }
#barcodeInput:focus { box-shadow: 0 0 0 5px rgba(10,147,150,0.28); }

/* Product preview */
.product-preview {
  background: rgba(7,11,19,0.5); border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.07); padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem; display: none;
  animation: fadeUp 0.25s ease;
}
.product-preview.visible { display: block; }
.product-preview.error { border-color: rgba(192,57,43,0.5); background: rgba(192,57,43,0.08); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.preview-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.preview-info { min-width: 0; flex: 1; }
.preview-name { font-size: 1.25rem; font-weight: 800; color: var(--white); letter-spacing: -0.02em; line-height: 1.2; }
.preview-meta { font-size: 0.8rem; color: #64748b; margin-top: 0.3rem; }

.preview-stock-badge {
  flex-shrink: 0; text-align: center; border-radius: var(--radius);
  padding: 0.5rem 0.85rem; min-width: 84px;
  border: 1.5px solid var(--navy-light); background: rgba(255,255,255,0.03);
}
.preview-stock-badge.ok   { border-color: rgba(45,158,95,0.4);  background: rgba(45,158,95,0.1); }
.preview-stock-badge.low  { border-color: rgba(212,130,10,0.5); background: rgba(212,130,10,0.12); }
.preview-stock-badge.out  { border-color: rgba(192,57,43,0.5);  background: rgba(192,57,43,0.12); }
.preview-stock-num { font-size: 1.6rem; font-weight: 800; font-family: var(--font-mono); color: var(--white); line-height: 1; }
.preview-stock-badge.ok  .preview-stock-num { color: #4ade80; }
.preview-stock-badge.low .preview-stock-num { color: #fbbf24; }
.preview-stock-badge.out .preview-stock-num { color: #f87171; }
.preview-stock-label { font-size: 0.66rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }

.preview-lowwarn {
  display: none; margin-top: 0.85rem; padding: 0.6rem 0.85rem;
  background: rgba(212,130,10,0.12); border: 1px solid rgba(212,130,10,0.3);
  border-radius: var(--radius); color: #fbbf24; font-size: 0.82rem; font-weight: 600;
}

/* Quantity */
.qty-section { margin-bottom: 1.25rem; }
.qty-label { display: block; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; margin-bottom: 0.6rem; text-align: center; }
.qty-wrap { display: flex; align-items: center; gap: 1rem; justify-content: center; }
.qty-btn {
  width: 58px; height: 58px; border-radius: 16px; font-size: 1.8rem; font-weight: 700;
  background: var(--navy-light); color: var(--white); border: 1px solid rgba(255,255,255,0.08); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.12s;
  flex-shrink: 0;
}
.qty-btn:hover { background: var(--teal); border-color: var(--teal); }
.qty-btn:active { transform: scale(0.92); }
#qtyInput {
  width: 110px; font-family: var(--font-mono); font-size: 2rem; font-weight: 800; text-align: center;
  color: var(--white); background: rgba(7,11,19,0.6); border: 1.5px solid var(--navy-light);
  border-radius: var(--radius-lg); padding: 0.5rem; outline: none;
  -moz-appearance: textfield;
}
#qtyInput::-webkit-outer-spin-button, #qtyInput::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* BIG confirm button */
.btn-stock-out {
  width: 100%; padding: 1.35rem; font-size: 1.25rem; font-weight: 800; letter-spacing: 0.01em;
  background: linear-gradient(180deg, #0fb5b8, #0a9396); color: var(--white); border: none; border-radius: 18px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; justify-content: center; gap: 0.7rem;
  box-shadow: 0 8px 24px rgba(10,147,150,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-stock-out-icon { font-size: 1.4rem; }
.btn-stock-out:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(10,147,150,0.55), inset 0 1px 0 rgba(255,255,255,0.2); }
.btn-stock-out:active:not(:disabled) { transform: translateY(0); }
.btn-stock-out:disabled { background: #16202e; color: #475569; cursor: not-allowed; box-shadow: none; }

/* ---- Success toast ---- */
.nurse-success {
  position: fixed; inset: 0; background: rgba(3,6,12,0.8); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.nurse-success.show { opacity: 1; pointer-events: all; }
.nurse-success-card {
  background: linear-gradient(180deg, var(--navy-mid), var(--navy));
  border-radius: 24px; padding: 2.5rem 2.5rem 2rem;
  text-align: center; border: 1px solid rgba(10,147,150,0.3); max-width: 380px; width: 90%;
  box-shadow: 0 0 80px rgba(10,147,150,0.25);
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.success-check { width: 72px; height: 72px; margin: 0 auto 1.1rem; }
.success-svg { width: 100%; height: 100%; }
.success-svg circle { stroke: var(--teal); stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: drawCircle 0.5s ease forwards; }
.success-svg path { stroke: var(--teal); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: drawCheck 0.35s 0.4s ease forwards; }
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }

.success-msg  { color: var(--white); font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.success-sub  { color: #94a3b8; font-size: 0.9rem; margin-top: 0.5rem; }
.success-sub span { color: var(--teal-light); font-weight: 700; }
.success-undo {
  margin-top: 1.25rem; font-size: 0.95rem; font-weight: 700; color: var(--white);
  background: rgba(255,255,255,0.08); border: 1.5px solid rgba(255,255,255,0.15);
  padding: 0.7rem 1.75rem; border-radius: 12px; cursor: pointer; transition: all 0.15s;
}
.success-undo:hover { background: rgba(212,130,10,0.2); border-color: rgba(212,130,10,0.4); color: #fbbf24; }
.success-dismiss { color: #475569; font-size: 0.78rem; margin-top: 1rem; }

/* ---- Recent list ---- */
.nurse-recent { width: 100%; max-width: 560px; margin-top: 1.75rem; }
.nurse-recent-title { color: #5b6b80; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; font-weight: 700; margin-bottom: 0.75rem; padding-left: 0.25rem; }
.nurse-recent-empty {
  color: #3b4858; font-size: 0.85rem; text-align: center; padding: 1.5rem 1rem;
  border: 1px dashed rgba(255,255,255,0.07); border-radius: var(--radius-lg);
}
.recent-empty-icon { display: block; font-size: 1.5rem; margin-bottom: 0.5rem; opacity: 0.5; }

.nurse-tx-item {
  background: rgba(27,47,69,0.6); border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem; margin-bottom: 0.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border: 1px solid rgba(255,255,255,0.06); animation: fadeUp 0.3s ease;
}
.nurse-tx-item.undone { opacity: 0.45; }
.nurse-tx-item.undone .nurse-tx-name { text-decoration: line-through; }
.nurse-tx-main { min-width: 0; flex: 1; }
.nurse-tx-name { color: var(--white); font-size: 0.92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nurse-tx-meta { color: #64748b; font-size: 0.75rem; margin-top: 2px; }
.nurse-tx-right { display: flex; align-items: center; gap: 0.85rem; flex-shrink: 0; }
.nurse-tx-qty { color: #f87171; font-size: 1.1rem; font-weight: 800; font-family: var(--font-mono); }
.nurse-tx-undo {
  font-size: 0.78rem; font-weight: 600; color: #94a3b8;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  padding: 0.4rem 0.85rem; border-radius: var(--radius); cursor: pointer; transition: all 0.15s;
}
.nurse-tx-undo:hover { background: rgba(212,130,10,0.18); color: #fbbf24; border-color: rgba(212,130,10,0.35); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Stock-In Form ---- */
.stock-in-card { max-width: 700px; }
.barcode-scan-row {
  display: flex; gap: 0.75rem; align-items: flex-end;
}
.barcode-scan-row .form-group { flex: 1; }
.barcode-scan-row .btn { height: 42px; }

/* ---- Export Page ---- */
.export-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.export-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1.5px solid var(--border); padding: 1.5rem;
  text-align: center; transition: all 0.15s; cursor: pointer;
}
.export-card:hover { border-color: var(--teal); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.export-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.export-card h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.export-card p  { font-size: 0.8rem; color: #64748b; margin-top: 0.25rem; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 0.35rem; margin-top: 1.25rem; flex-wrap: wrap; }
.page-btn {
  font-size: 0.82rem; font-weight: 600; padding: 0.35rem 0.7rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--white); color: var(--navy); cursor: pointer; transition: all 0.12s;
  text-decoration: none;
}
.page-btn:hover { background: var(--teal); color: var(--white); border-color: var(--teal); text-decoration: none; }
.page-btn.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ---- Search/Filter Bar ---- */
.filter-bar {
  display: flex; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: flex-end;
}
.filter-bar input, .filter-bar select {
  font-family: var(--font-body); font-size: 0.875rem; color: var(--navy);
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 0.5rem 0.85rem; outline: none; transition: border-color 0.15s;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--teal); }
.filter-bar input[type="search"] { min-width: 220px; }

/* ---- Footer ---- */
.site-footer {
  background: var(--navy); color: #475569; font-size: 0.78rem;
  padding: 0.85rem 2rem; display: flex; justify-content: space-between;
  border-top: 1px solid var(--navy-light); margin-top: auto;
}

/* ---- Utilities ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: #94a3b8; }
.text-ok   { color: var(--ok); }
.text-warn { color: var(--low); }
.text-danger { color: var(--critical); }
.text-teal { color: var(--teal); }
.fw-bold { font-weight: 700; }
.mono { font-family: var(--font-mono); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #64748b; }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: #374151; }
.empty-state p  { font-size: 0.85rem; margin-top: 0.3rem; }

/* ============================================
   RESPONSIVE — Mobile & Tablet
   Breakpoints: 1024px (tablet), 768px (tablet-sm), 480px (mobile)
   ============================================ */

/* ---- Hamburger Menu Button ---- */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block; height: 2px;
  background: var(--white); border-radius: 2px;
  transition: all 0.25s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile Drawer Menu ---- */
.mobile-menu {
  display: none;
  position: fixed;
  top: var(--nav-h); left: 0; right: 0;
  background: var(--navy-mid);
  border-bottom: 2px solid var(--teal);
  z-index: 99;
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
}
.mobile-menu.open {
  display: block;
  opacity: 1;
  transform: translateY(0);
}
.mobile-menu a {
  display: flex; align-items: center;
  color: #94a3b8; font-size: 0.95rem; font-weight: 500;
  padding: 0.75rem 0.85rem; border-radius: var(--radius);
  transition: all 0.15s; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover, .mobile-menu a.active {
  color: var(--white); background: var(--navy-light); text-decoration: none;
}
.mobile-menu a.active { color: var(--teal-light); }
.mobile-menu-divider {
  border: none; border-top: 1px solid rgba(255,255,255,0.08);
  margin: 0.5rem 0;
}
.mobile-menu-user {
  font-size: 0.8rem; color: #64748b;
  padding: 0.5rem 0.85rem 0.25rem;
}
.mobile-menu .btn-logout-mobile {
  display: block; margin-top: 0.5rem;
  background: rgba(192,57,43,0.15); color: #f87171;
  border: 1px solid rgba(192,57,43,0.3); border-radius: var(--radius);
  padding: 0.6rem 0.85rem; font-size: 0.875rem; font-weight: 600;
  text-decoration: none; text-align: center;
}

/* ---- Tablet (≤1024px) ---- */
@media (max-width: 1024px) {
  .col-8  { grid-column: span 12; }
  .col-4  { grid-column: span 12; }
  .col-6  { grid-column: span 12; }
  .col-12 { grid-column: span 12; }

  .main-content { padding: 1.25rem 1.25rem; }

  /* Reorder dashboard: alerts before activity */
  .dashboard-grid { display: flex; flex-direction: column; gap: 1.25rem; }

  /* Nav: hide links, show hamburger */
  .nav-links { display: none !important; }
  .nav-hamburger { display: flex; }
  .nav-user .user-name { display: none; }

  /* Stats: 2x2 grid on tablet */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Tables: horizontal scroll with sticky first col */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* Form grid: 2 cols max */
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid [style*="grid-column: span 2"] { grid-column: span 2; }

  /* Filter bar: wrap */
  .filter-bar { flex-wrap: wrap; gap: 0.5rem; }
  .filter-bar input[type="search"] { min-width: 160px; flex: 1; }

  /* Page header */
  .page-header { flex-wrap: wrap; gap: 0.75rem; }
  .page-actions { flex-wrap: wrap; }

  /* Export cards: 1 col */
  .export-options { grid-template-columns: 1fr; }
}

/* ---- Small Tablet / Large Mobile (≤768px) ---- */
@media (max-width: 768px) {
  :root { --nav-h: 56px; }

  .main-content { padding: 1rem; }

  /* Navbar compact */
  .navbar { padding: 0 1rem; gap: 0.75rem; }
  .nav-brand { min-width: auto; }
  .nav-title { font-size: 1rem; }
  .nav-badge { display: none; }
  .btn-logout { display: none; } /* shown in mobile menu */

  /* Stats: still 2 cols but smaller */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-card { padding: 1rem 1.1rem; }
  .stat-value { font-size: 1.6rem; }
  .stat-icon { font-size: 1.4rem; }

  /* Page header */
  .page-header h1 { font-size: 1.25rem; }
  .page-header p  { font-size: 0.82rem; }
  .btn { font-size: 0.82rem; padding: 0.45rem 0.9rem; }

  /* Cards */
  .card-header { padding: 0.85rem 1rem; }
  .card-body   { padding: 1rem; }

  /* Tables: smaller text, scroll */
  table { min-width: 540px; font-size: 0.8rem; }
  thead th { font-size: 0.68rem; padding: 0.6rem 0.75rem; }
  tbody td  { padding: 0.6rem 0.75rem; }

  /* Alert items */
  .alert-name { font-size: 0.82rem; }
  .alert-loc  { font-size: 0.72rem; }

  /* Location stock bars */
  .stock-bar { width: 40px !important; }

  /* Footer */
  .site-footer { flex-direction: column; gap: 0.25rem; text-align: center; padding: 0.75rem 1rem; }

  /* Form grid: 1 col */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid [style*="grid-column: span 2"] { grid-column: span 1; }

  /* Nurse scan */
  .nurse-topbar { padding: 0.75rem 1rem; }
  .brand-tag { display: none; }
  .nurse-id span:not(.nurse-id-icon) { display: none; }
  .location-bar { padding: 0.75rem 1rem; }
  .nurse-scan-zone { padding: 1rem; }
  .scan-box { padding: 1.25rem; border-radius: 16px; }
  #barcodeInput { font-size: 1.1rem; padding: 0.85rem 0.85rem 0.85rem 3rem; }
  .scan-icon { font-size: 1.3rem; }

  /* Transaction filters */
  .filter-bar > div { flex: 1; min-width: 120px; }
  .filter-bar input[type="date"] { width: 100%; }

  /* Pagination */
  .pagination { gap: 0.25rem; }
  .page-btn { padding: 0.3rem 0.55rem; font-size: 0.78rem; }
}

/* ---- Mobile (≤480px) ---- */
@media (max-width: 480px) {
  .main-content { padding: 0.75rem; }

  /* Stats: stack 2x2 then single on very small */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .stat-card { padding: 0.85rem; }
  .stat-value { font-size: 1.4rem; }
  .stat-sub { display: none; }
  .stat-icon { display: none; }

  /* Page header: stack */
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }

  /* Dashboard grid: single column */
  .dashboard-grid { gap: 0.75rem; }

  /* Cards */
  .card { border-radius: var(--radius); }
  .card-header { padding: 0.75rem; }
  .card-body   { padding: 0.75rem; }
  .card-header h2 { font-size: 0.875rem; }

  /* Tables: very compact */
  table { min-width: 480px; font-size: 0.75rem; }
  thead th { padding: 0.5rem 0.6rem; font-size: 0.64rem; }
  tbody td  { padding: 0.5rem 0.6rem; }
  .td-mono  { font-size: 0.72rem; }

  /* Alert items */
  .alert-item { padding: 0.65rem 0.75rem; gap: 0.65rem; }

  /* Buttons */
  .btn { font-size: 0.8rem; padding: 0.42rem 0.75rem; }
  .btn-sm { font-size: 0.72rem; padding: 0.28rem 0.55rem; }
  .btn-lg { font-size: 0.9rem; padding: 0.6rem 1.1rem; }

  /* Forms */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .form-grid { gap: 0.85rem; }
  .form-group input,
  .form-group select,
  .form-group textarea { font-size: 16px; /* prevent iOS zoom */ }

  /* Filter bar: stack */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select, .filter-bar .btn { width: 100%; }
  .filter-bar input[type="search"] { min-width: unset; }

  /* Flash */
  .flash { font-size: 0.82rem; padding: 0.7rem 0.85rem; }

  /* Barcode scan page */
  .nurse-topbar { padding: 0.6rem 0.75rem; }
  .brand-name { font-size: 0.95rem; }
  .session-counter { padding: 0.3rem 0.6rem; min-width: 46px; }
  .session-num { font-size: 1.05rem; }
  .location-bar { padding: 0.6rem 0.75rem; }
  .location-value { font-size: 1rem; }
  .location-chip { font-size: 0.88rem; padding: 0.65rem 1.1rem; }
  .nurse-scan-zone { padding: 0.75rem; gap: 0; }
  .scan-box { padding: 1rem; border-radius: 14px; }
  #barcodeInput {
    font-size: 16px; /* prevent iOS zoom */
    padding: 0.85rem 0.75rem 0.85rem 2.75rem;
    letter-spacing: 0.02em;
  }
  .scan-icon { font-size: 1.1rem; left: 0.75rem; }
  .product-preview { padding: 0.9rem; margin-bottom: 1rem; }
  .preview-name { font-size: 1.1rem; }
  .preview-stock-num { font-size: 1.35rem; }
  .qty-wrap { gap: 0.75rem; }
  .qty-btn { width: 52px; height: 52px; font-size: 1.6rem; }
  #qtyInput { font-size: 1.7rem; width: 90px; }
  .btn-stock-out {
    font-size: 1.1rem; padding: 1.2rem 1rem;
    border-radius: 14px; letter-spacing: 0;
  }

  /* Nurse recent */
  .nurse-recent { margin-top: 1rem; }
  .nurse-tx-item { padding: 0.7rem 0.85rem; }

  /* Login */
  .login-header { padding: 1.5rem 1.5rem 1rem; }
  .login-header .logo { font-size: 2rem; }
  .login-header h1 { font-size: 1.3rem; }
  .login-body { padding: 1.25rem; }
  .login-footer { padding: 0 1.25rem 1.25rem; }

  /* Export cards */
  .export-card { padding: 1.1rem; }
  .export-card .icon { font-size: 2rem; }

  /* Stock-in form */
  .barcode-scan-row { flex-direction: column; }

  /* Pagination: hide middle pages */
  .pagination .page-btn:not(.active):not(:first-child):not(:last-child) {
    display: none;
  }

  /* Nurse success overlay */
  .nurse-success-card { padding: 2rem 1.5rem; }
  .success-icon { font-size: 2.75rem; }
  .success-msg  { font-size: 1.1rem; }
}

/* ---- Very small phones (≤360px) ---- */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 0.75rem; }
  .nav-title { font-size: 0.9rem; }
  .main-content { padding: 0.5rem; }
  .scan-box { padding: 0.85rem; }
  .btn-stock-out { font-size: 1rem; padding: 1rem 0.75rem; }
}

/* ---- Touch-friendly tap targets ---- */
@media (hover: none) and (pointer: coarse) {
  /* Ensure all tappable elements are at least 44px tall */
  .btn, .page-btn, .nav-links a, .mobile-menu a {
    min-height: 44px;
    display: inline-flex; align-items: center;
  }
  .qty-btn { min-height: 44px; min-width: 44px; }
  .btn-stock-out { min-height: 64px; }
  .form-group input,
  .form-group select { min-height: 44px; }

  /* Remove hover effects on touch */
  .stat-card:hover { transform: none; box-shadow: var(--shadow); }
  .export-card:hover { transform: none; box-shadow: none; }
}

/* ---- Landscape phone ---- */
@media (max-width: 768px) and (orientation: landscape) {
  .nurse-scan-zone { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 1rem; padding: 0.75rem; }
  .nurse-error-banner { width: 100%; }
  .scan-box { max-width: 420px; }
  .nurse-recent { max-width: 400px; margin-top: 0; }
  :root { --nav-h: 50px; }
}

/* ---- Print ---- */
@media print {
  .navbar, .mobile-menu, .nav-hamburger, .site-footer,
  .btn, .page-actions, .filter-bar, .pagination { display: none !important; }
  .main-content { padding: 0; max-width: 100%; }
  .table-wrap { overflow: visible; box-shadow: none; border: none; }
  table { min-width: unset; font-size: 10pt; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  .badge { border: 1px solid currentColor; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
