/* =====================================================================
   Media Warehouse — design system
   Radical visual refresh: dark luminous sidebar, unified motion tokens,
   interactive tabs/cards/tables. All class names and behavioral contracts
   (modal scroll-lock, responsive tables, print, reduced-motion) preserved.
   ===================================================================== */

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-darker: #115e59;
  --primary-light: #ccfbf1;
  --primary-50: #f0fdfa;
  --accent: #6366f1;
  --accent-dark: #4f46e5;

  --bg: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --border: #e4eaf1;
  --border-soft: #eef2f6;

  /* Dark sidebar surface */
  --side-bg-1: #0c1424;
  --side-bg-2: #0f2027;
  --side-text: #cbd5e1;
  --side-muted: #7c8ba1;
  --side-line: rgba(148, 163, 184, 0.14);
  --side-hover: rgba(148, 163, 184, 0.10);

  --danger: #e11d48;
  --danger-soft: #ffe4e6;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --info: #0ea5e9;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 14px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.12), 0 4px 8px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 22px 50px rgba(15, 23, 42, 0.20);
  --shadow-primary: 0 8px 20px rgba(13, 148, 136, 0.28);
  --glow-primary: 0 0 0 4px rgba(13, 148, 136, 0.12);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Motion tokens — one rhythm everywhere.
     Micro 120ms · standard 220ms · entrances 300-400ms · spring for emphasis */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 0.55, 0.2);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t: 220ms var(--ease-out);
  --t-spring: 360ms var(--ease-spring);

  --sidebar-width: 262px;
  --header-height: 60px;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, system-ui, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(1100px 560px at 100% -10%, #dcf2ee 0%, transparent 55%),
                    radial-gradient(900px 520px at -10% 110%, #e4e9fb 0%, transparent 50%),
                    radial-gradient(700px 400px at 55% 120%, #eaf5f2 0%, transparent 45%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary-dark); text-decoration: none; }
::selection { background: var(--primary-light); }

/* Scrollbar */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #c3cdd9; border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* ---------- Buttons ---------- */
button {
  position: relative;
  overflow: hidden;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  padding: 0.6rem 1.15rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: transform var(--t-fast), box-shadow var(--t), filter var(--t), background var(--t);
  white-space: nowrap;
  touch-action: manipulation;
}
/* Light sweep across primary buttons on hover — pure transform/opacity */
button::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 42%, rgba(255, 255, 255, 0.28) 50%, transparent 58%);
  transform: translateX(-130%);
  pointer-events: none;
  opacity: 0;
}
@media (hover: hover) {
  button:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(13, 148, 136, 0.36); filter: brightness(1.05); }
  button:hover::after { opacity: 1; transform: translateX(130%); transition: transform 650ms var(--ease-out), opacity 150ms; }
}
button:active { transform: translateY(0) scale(0.96); }
button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; filter: none; }
button:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 2px; }

button.secondary { background: #fff; color: var(--text-soft); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
@media (hover: hover) { button.secondary:hover { background: #f8fafc; box-shadow: var(--shadow); filter: none; } }
button.danger { background: linear-gradient(135deg, #f43f5e 0%, var(--danger) 100%); box-shadow: 0 8px 20px rgba(225, 29, 72, 0.28); }
button.ghost { background: transparent; color: var(--primary-dark); box-shadow: none; padding: 0.4rem 0.6rem; }
@media (hover: hover) { button.ghost:hover { background: var(--primary-50); transform: none; } }
button.sm { padding: 0.42rem 0.8rem; font-size: 0.82rem; border-radius: 9px; }
button.block { width: 100%; }

/* Anchor styled as a button (e.g. طباعة رمز QR) */
a.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; font-weight: 600; font-size: 0.92rem;
  padding: 0.6rem 1.15rem; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-primary); white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t), filter var(--t);
}
a.btn.sm { padding: 0.42rem 0.8rem; font-size: 0.82rem; border-radius: 9px; }
@media (hover: hover) { a.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(13, 148, 136, 0.36); filter: brightness(1.05); } }
a.btn:active { transform: scale(0.96); }
a.btn:focus-visible { outline: 3px solid var(--primary-light); outline-offset: 2px; }

/* ---------- Inputs ---------- */
input, select, textarea {
  font-family: inherit;
  font-size: 0.93rem;
  padding: 0.62rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  width: 100%;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}
label { font-size: 0.82rem; color: var(--muted); display: block; margin-bottom: 0.35rem; font-weight: 600; }
.field { margin-bottom: 0.95rem; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100%; }

/* Dark luminous sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--side-bg-1) 0%, var(--side-bg-2) 100%);
  border-inline-end: 1px solid var(--side-line);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 50;
  transition: transform 280ms var(--ease-out);
}
/* Soft aurora inside the sidebar (decorative, non-interactive) */
.sidebar::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px 260px at 85% -5%, rgba(13, 148, 136, 0.22) 0%, transparent 60%),
              radial-gradient(360px 300px at -20% 108%, rgba(99, 102, 241, 0.16) 0%, transparent 55%);
}
.sidebar .brand {
  position: relative;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 1.2rem 1.1rem;
  font-weight: 800;
  font-size: 1.04rem;
  color: #f1f5f9;
  border-bottom: 1px solid var(--side-line);
}
.sidebar .brand .brand-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6 0%, var(--primary-dark) 100%);
  color: #fff; display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.45);
  animation: brandGlow 4s ease-in-out infinite;
}
.sidebar nav { position: relative; padding: 0.75rem; overflow-y: auto; flex: 1; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.35); background-clip: content-box; }
.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.66rem 0.8rem;
  border-radius: 12px;
  color: var(--side-text);
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.sidebar nav a .nav-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(148, 163, 184, 0.12); color: var(--side-muted);
  flex: 0 0 auto;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t);
}
@media (hover: hover) {
  .sidebar nav a:hover { background: var(--side-hover); color: #f1f5f9; transform: translateX(-3px); }
  .sidebar nav a:hover .nav-icon { color: #5eead4; transform: scale(1.08); }
}
.sidebar nav a:active { transform: scale(0.98); }
.sidebar nav a.active {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.28), rgba(13, 148, 136, 0.10));
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.25);
}
.sidebar nav a.active .nav-icon {
  background: linear-gradient(135deg, #14b8a6, var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.5);
}
.sidebar nav a.active::before {
  content: ''; position: absolute; inset-inline-start: -0.75rem; top: 50%; transform: translateY(-50%);
  width: 4px; height: 62%; border-radius: 999px;
  background: linear-gradient(180deg, #2dd4bf, var(--primary));
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.8);
  animation: indicatorIn 300ms var(--ease-spring) both;
}
.sidebar .foot { position: relative; padding: 0.9rem 1rem; border-top: 1px solid var(--side-line); font-size: 0.78rem; color: var(--side-muted); }

.main { flex: 1; margin-inline-start: var(--sidebar-width); min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  min-height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}
.topbar .menu-btn { display: none; background: #fff; color: var(--text); box-shadow: var(--shadow-sm); border: 1px solid var(--border); padding: 0.45rem; border-radius: 10px; }
.topbar .user-chip { display: flex; align-items: center; gap: 0.65rem; font-size: 0.86rem; }
.topbar .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: grid; place-items: center; font-weight: 700;
  box-shadow: var(--shadow-primary);
  transition: transform var(--t-spring), box-shadow var(--t);
}
@media (hover: hover) { .topbar .user-chip:hover .avatar { transform: scale(1.1) rotate(-6deg); box-shadow: 0 0 0 4px var(--primary-light), var(--shadow-primary); } }

/* NOTE: page containers must never keep a transform/filter after their entry
   animation — a retained transform turns them into the containing block for
   position:fixed children, pushing modals out of the viewport on long pages.
   Use the opacity-only fadeIn here. */
.content { padding: 1.5rem; max-width: 1280px; margin: 0 auto; animation: fadeIn 0.4s var(--ease-out) both; }

.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1.3rem; }
.page-head h1 { font-size: 1.5rem; margin: 0; font-weight: 800; letter-spacing: -0.01em; }
.page-head h1 .sub { display: block; font-size: 0.8rem; font-weight: 500; color: var(--muted); margin-top: 0.15rem; }

.backdrop { display: none; }

/* ---------- Cards / grids ---------- */
.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.stat-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.card .body { padding: 1.1rem; }

/* Stat cards */
.stat {
  position: relative;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  animation: fadeInUp 0.45s var(--ease-out) both;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.stat::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(120deg, transparent 45%, rgba(255, 255, 255, 0.55) 52%, transparent 60%);
  transform: translateX(-130%);
}
@media (hover: hover) {
  .stat:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
  .stat:hover::after { opacity: 1; transform: translateX(130%); transition: transform 700ms var(--ease-out), opacity 150ms; }
  .stat:hover .stat-icon { transform: scale(1.1) rotate(-4deg); }
}
.stat .stat-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  margin-bottom: 0.5rem; color: var(--primary-dark); background: var(--primary-50);
  transition: transform var(--t-spring);
}
.stat .num { font-size: 1.95rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 0.84rem; margin-top: 0.35rem; font-weight: 600; }
.stat.accent { border-color: var(--primary); box-shadow: var(--glow-primary), var(--shadow-sm); }
.stat.accent .stat-icon { background: var(--primary-50); color: var(--primary-dark); }
.stat.warn { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.10), var(--shadow-sm); }
.stat.warn .stat-icon { background: var(--warning-soft); color: #b45309; }
.stat.danger { border-color: #fb7185; box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.10), var(--shadow-sm); }
.stat.danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.ok { border-color: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.10), var(--shadow-sm); }
.stat.ok .stat-icon { background: var(--success-soft); color: #15803d; }

/* item cards */
.item-card { position: relative; cursor: pointer; }
@media (hover: hover) {
  .item-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: #cde5e0; }
  .item-card:hover .item-img { transform: scale(1.04); }
}
.item-card:active { transform: translateY(-1px) scale(0.995); }
.item-card .item-img { transition: transform 500ms var(--ease-out); }

/* Full colored status border around cards */
.status-edge { border-width: 2px; }
.status-edge-available { border-color: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.10), var(--shadow-sm); }
.status-edge-in_use { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.10), var(--shadow-sm); }
.status-edge-maintenance { border-color: #fb7185; box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.10), var(--shadow-sm); }
@media (hover: hover) {
  .item-card.status-edge:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
  .item-card.status-edge-available:hover { border-color: #16a34a; }
  .item-card.status-edge-in_use:hover { border-color: #d97706; }
  .item-card.status-edge-maintenance:hover { border-color: #e11d48; }
}
.status-line { height: 5px; width: 100%; }
.status-available { background: linear-gradient(90deg, #22c55e, #16a34a); }
.status-in_use { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.status-maintenance { background: linear-gradient(90deg, #fb7185, #e11d48); }
.item-img { width: 100%; height: 160px; object-fit: cover; background: #f1f5f9; display: block; }
.item-img.placeholder { display: grid; place-items: center; color: #cbd5e1; font-size: 2.6rem; background: linear-gradient(135deg, #f8fafc, #eef2f6); }
.item-card h3 { margin: 0 0 0.35rem; font-size: 1.02rem; font-weight: 700; }
.item-card .meta { font-size: 0.83rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.22rem; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.74rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 700;
  transition: transform var(--t-fast);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.available { background: var(--success-soft); color: #166534; }
.badge.in_use { background: var(--warning-soft); color: #92400e; }
.badge.maintenance { background: var(--danger-soft); color: #9f1239; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); max-height: 72vh; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.68rem 0.9rem; height: 44px; text-align: start; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th { background: #f6f9fc; color: var(--muted); font-weight: 700; position: sticky; top: 0; z-index: 2; font-size: 0.8rem; text-transform: none; }
td.num, th.num { font-variant-numeric: tabular-nums; }
tbody tr { transition: background var(--t-fast), box-shadow var(--t-fast); animation: fadeIn 0.35s var(--ease-out) both; }
tbody tr:last-child td { border-bottom: none; }
@media (hover: hover) {
  /* RTL: the accent bar sits on the row's right edge */
  tbody tr:hover { background: var(--primary-50); box-shadow: inset -3px 0 0 var(--primary); }
}
/* Stagger the first rows for a soft cascade (opacity-only, no layout shift) */
tbody tr:nth-child(1) { animation-delay: 0.02s; }
tbody tr:nth-child(2) { animation-delay: 0.05s; }
tbody tr:nth-child(3) { animation-delay: 0.08s; }
tbody tr:nth-child(4) { animation-delay: 0.11s; }
tbody tr:nth-child(5) { animation-delay: 0.14s; }
tbody tr:nth-child(6) { animation-delay: 0.17s; }
tbody tr:nth-child(7) { animation-delay: 0.20s; }
tbody tr:nth-child(8) { animation-delay: 0.23s; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.2rem; background: #fff; padding: 0.7rem; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.toolbar input, .toolbar select { width: auto; min-width: 170px; flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(9, 16, 32, 0.55);
  -webkit-backdrop-filter: blur(9px) saturate(1.1) brightness(0.96);
  backdrop-filter: blur(9px) saturate(1.1) brightness(0.96);
  display: grid; place-items: center; padding: 1.2rem; z-index: 100;
  animation: overlayIn 0.25s ease both;
}

/* Lock page scroll while any modal is open: the dialog stays centered and the
   background cannot be scrolled away from under it. */
html:has(.modal-overlay) { overflow: hidden; }
.modal-body { overscroll-behavior: contain; }
.modal {
  position: relative;
  background: #fff; border-radius: var(--radius-xl); width: 100%; max-width: 560px;
  max-height: 90vh; max-height: 90dvh; display: flex; flex-direction: column;
  box-shadow: 0 30px 70px rgba(8, 15, 30, 0.4), 0 0 0 1px rgba(255,255,255,0.4) inset;
  outline: none;
  transform-origin: center;
  animation: modalIn 0.38s var(--ease-spring) both;
}
.modal.lg { max-width: 860px; }
.modal-grabber { display: none; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem;
  padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #ffffff, #f8fcfb); flex: 0 0 auto;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-title { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.modal-title-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: var(--shadow-primary);
  animation: popIn 0.45s var(--ease-spring) both; animation-delay: 0.05s;
}
.modal-head h2 { margin: 0; font-size: 1.18rem; font-weight: 800; letter-spacing: -0.01em; }
.modal-subtitle { margin: 0.15rem 0 0; font-size: 0.82rem; color: var(--muted); font-weight: 500; }
.modal-head .x { background: #f1f5f9; color: var(--muted); padding: 0.45rem; border-radius: 10px; box-shadow: none; flex: 0 0 auto; }
@media (hover: hover) { .modal-head .x:hover { background: var(--danger-soft); color: var(--danger); transform: rotate(90deg); filter: none; } }
.modal-body { padding: 1.4rem; overflow-y: auto; flex: 1 1 auto; }
.modal-foot { display: flex; gap: 0.6rem; justify-content: flex-start; padding: 1rem 1.4rem; border-top: 1px solid var(--border-soft); background: #fff; flex: 0 0 auto; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* Styled file upload control */
.file-input {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.8rem 0.95rem;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.file-input input[type="file"] { display: none; }
@media (hover: hover) { .file-input:hover { border-color: var(--primary); background: var(--primary-50); } }
.file-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.file-input.has-file { border-style: solid; border-color: var(--success); background: var(--success-soft); }
.file-input .fi-icon {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; background: #fff; color: var(--primary-dark);
  box-shadow: var(--shadow-xs);
}
.file-input.has-file .fi-icon { color: #15803d; }
.file-input .fi-text { display: flex; flex-direction: column; min-width: 0; }
.file-input .fi-label { font-weight: 700; color: var(--text-soft); font-size: 0.9rem; }
.file-input .fi-name { font-weight: 700; color: var(--text); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.file-input .fi-hint { font-size: 0.74rem; color: var(--muted); margin-top: 0.1rem; }

/* Search box with leading icon */
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; inset-inline-start: 0.75rem; color: var(--muted); pointer-events: none; transition: color var(--t-fast); }
.search-box input { padding-inline-start: 2.4rem; }
.search-box:focus-within svg { color: var(--primary); }

/* Selectable item list (inside issue popup) */
.select-list { display: flex; flex-direction: column; gap: 0.45rem; max-height: 320px; overflow-y: auto; padding: 0.15rem; margin: 0 -0.15rem; }
.select-row {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: start;
  padding: 0.7rem 0.85rem; border-radius: var(--radius-sm);
  background: #fff; color: var(--text); border: 1.5px solid var(--border);
  box-shadow: none; transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
@media (hover: hover) { .select-row:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-50); transform: none; filter: none; box-shadow: none; } }
.select-row:disabled { opacity: 0.5; cursor: not-allowed; }
.select-row.selected { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 3px var(--primary-light); }
.select-row .sr-check {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto; display: grid; place-items: center;
  background: #f1f5f9; color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-spring);
}
.select-row.selected .sr-check { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; transform: scale(1.06); }
.select-row .sr-main { display: flex; flex-direction: column; min-width: 0; }
.select-row .sr-name { font-weight: 700; font-size: 0.92rem; }
.select-row .sr-sub { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Selectable item CARDS (issue popup) */
.select-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; max-height: 360px; overflow-y: auto; padding: 0.2rem; margin: 0 -0.2rem; }
.sel-card {
  display: flex; flex-direction: column; text-align: start; padding: 0; overflow: hidden;
  background: #fff; color: var(--text); border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
@media (hover: hover) { .sel-card:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); filter: none; } }
.sel-card:disabled { opacity: 0.5; cursor: not-allowed; }
.sel-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.sel-card-img { position: relative; width: 100%; }
.sel-card-img .item-img, .sel-card-img .item-img.placeholder { height: 96px; font-size: 1.8rem; }
.sel-card-check { position: absolute; top: 0.4rem; inset-inline-start: 0.4rem; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: var(--shadow-sm); animation: popIn 0.3s var(--ease-spring) both; }
.sel-card-body { padding: 0.55rem 0.7rem 0.7rem; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.sel-card-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-card-sub { font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sel-card-sub.barcode { font-weight: 700; color: var(--primary-dark); }
.sel-card-sub.out { color: var(--danger); font-weight: 700; }

/* Multi-select cart bar + quantity stepper (issue popup) */
.cart-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; background: var(--primary-50); border: 1px solid var(--primary-light); color: var(--primary-darker); border-radius: var(--radius-sm); padding: 0.5rem 0.85rem; margin-bottom: 0.8rem; font-size: 0.88rem; font-weight: 700; animation: fadeInUp 0.3s var(--ease-out) both; }
.qty-stepper { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.5rem; }
.qty-stepper button { width: 30px; height: 30px; min-height: 0; padding: 0; border-radius: 8px; background: #fff; color: var(--primary-dark); border: 1.5px solid var(--border); box-shadow: none; font-size: 1.1rem; font-weight: 800; }
@media (hover: hover) { .qty-stepper button:hover { background: var(--primary-50); border-color: var(--primary); transform: none; filter: none; box-shadow: none; } }
.qty-stepper input { width: 52px; text-align: center; padding: 0.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sel-card.disabled { opacity: 0.5; cursor: not-allowed; }
.sel-card[role="button"] { cursor: pointer; }
.sel-card:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* Members-with-custody list */
.member-grid { display: flex; flex-direction: column; gap: 0.6rem; }
.member-row {
  display: flex; align-items: center; gap: 0.8rem; width: 100%; text-align: start;
  padding: 0.75rem 0.95rem; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  animation: fadeInUp 0.4s var(--ease-out) both;
}
@media (hover: hover) { .member-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cde5e0; filter: none; } }
.member-grid > *:nth-child(2) { animation-delay: 0.04s; }
.member-grid > *:nth-child(3) { animation-delay: 0.08s; }
.member-grid > *:nth-child(4) { animation-delay: 0.12s; }
.member-grid > *:nth-child(5) { animation-delay: 0.16s; }
.member-grid > *:nth-child(6) { animation-delay: 0.20s; }
.member-row .member-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; font-weight: 800; font-size: 1.1rem;
}
.member-row .member-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-row .member-name { font-weight: 800; font-size: 1rem; }
.member-row .member-badge { font-size: 0.78rem; color: var(--muted); }
.member-row .member-counts { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.member-row .member-chevron { color: var(--muted-2); flex: 0 0 auto; transform: scaleX(-1); transition: transform var(--t); }
@media (hover: hover) { .member-row:hover .member-chevron { transform: scaleX(-1) translateX(-4px); color: var(--primary-dark); } }

/* Issued items list (member popup) */
.issued-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.8rem; }
.issued-item { display: flex; gap: 0.7rem; padding: 0.6rem; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.issued-item.custody { border-color: #fcd34d; background: #fffdf5; }
.issued-img { width: 70px; height: 70px; flex: 0 0 auto; border-radius: 10px; overflow: hidden; }
.issued-img .item-img, .issued-img .item-img.placeholder { height: 70px; font-size: 1.6rem; }
.issued-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.issued-name { font-weight: 700; font-size: 0.92rem; }
.issued-meta { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.8rem; color: var(--text-soft); }

/* Cover image (consumable detail popup) */
.detail-cover { position: relative; width: 100%; border-radius: var(--radius-lg); overflow: hidden; border: 2px solid var(--border); box-shadow: var(--shadow-sm); }
.detail-cover .item-img { height: 260px; }
.detail-cover .item-img.placeholder { height: 260px; font-size: 4rem; }
.detail-cover .cover-badge { position: absolute; top: 0.85rem; inset-inline-start: 0.85rem; font-size: 0.82rem; padding: 0.3rem 0.8rem; box-shadow: var(--shadow); }
@media (max-width: 560px) { .detail-cover .item-img, .detail-cover .item-img.placeholder { height: 190px; } }

/* Detail rows (consumable detail popup) */
.detail-rows { display: flex; flex-direction: column; gap: 0.6rem; }
.detail-rows > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0.85rem; background: #f8fafc; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.detail-rows .dr-lbl { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.detail-rows .dr-val { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Tabs (animated pill) ---------- */
.tabs {
  display: flex; gap: 0.3rem;
  background: #e8edf4;
  padding: 0.3rem; border-radius: 13px; margin-bottom: 1.2rem;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.06);
}
.tabs button {
  flex: 1; background: transparent; color: var(--muted); border-radius: 10px; box-shadow: none;
  padding: 0.55rem 0.9rem; font-weight: 700;
  transition: color var(--t-fast), background var(--t), box-shadow var(--t), transform var(--t-fast);
}
@media (hover: hover) { .tabs button:hover { background: rgba(255, 255, 255, 0.65); transform: none; filter: none; color: var(--text-soft); } }
.tabs button:active { transform: scale(0.97); }
.tabs button.active {
  background: #fff; color: var(--primary-darker);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.10), 0 0 0 1px rgba(13, 148, 136, 0.14);
  animation: tabPop 0.3s var(--ease-spring);
}

/* misc */
.row { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); animation: fadeInUp 0.4s var(--ease-out) both; }
.empty .empty-icon { width: 76px; height: 76px; border-radius: 22px; margin: 0 auto 0.9rem; display: grid; place-items: center; font-size: 2.2rem; background: linear-gradient(135deg, #f8fafc, #eef2f6); color: #cbd5e1; box-shadow: var(--shadow-sm); animation: floatSoft 4s ease-in-out infinite; }
.alert { padding: 0.8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; animation: alertIn 0.35s var(--ease-spring) both; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: #9f1239; border-color: #fecdd3; }
.alert.success { background: var(--success-soft); color: #166534; border-color: #bbf7d0; }
.alert.info { background: #e0f2fe; color: #075985; border-color: #bae6fd; }
.spacer { flex: 1; }
.pill { font-size: 0.74rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: #eef2f6; color: var(--text-soft); font-weight: 700; }
.flex { display: flex; align-items: center; gap: 0.5rem; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

/* Member note on a custody session (member portal + admin views) */
.note-chip {
  display: inline-flex; align-items: flex-start; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; line-height: 1.55;
  color: #92400e; background: #fffbeb;
  border: 1px dashed #fcd34d; border-radius: 10px;
  padding: 0.32rem 0.6rem; max-width: 100%;
  white-space: normal; text-align: start;
  animation: fadeInUp 0.3s var(--ease-out) both;
}
.note-chip svg { flex: 0 0 auto; margin-top: 0.18rem; }
.note-chip.on { background: #fefce8; border-style: solid; }

/* QR section (settings) */
.qr-row { display: flex; gap: 1.1rem; align-items: flex-start; flex-wrap: wrap; margin-top: 0.4rem; }
.qr-preview {
  flex: 0 0 auto; width: 190px;
  background: #fff; border: 2px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.7rem; box-shadow: var(--shadow-sm);
  transition: transform var(--t-spring), box-shadow var(--t), border-color var(--t);
}
@media (hover: hover) { .qr-preview:hover { transform: scale(1.04) rotate(-1deg); box-shadow: var(--shadow-md); border-color: var(--primary); } }
.qr-preview svg { width: 100%; height: auto; display: block; }
.qr-side { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 0.55rem; }
.qr-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.2rem;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #0b4f4a 55%, #0e3a52 100%);
  position: relative; overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(60px); opacity: 0.5;
  animation: float 9s ease-in-out infinite;
}
.login-wrap::before { width: 420px; height: 420px; background: #14b8a6; top: -120px; inset-inline-end: -100px; }
.login-wrap::after { width: 380px; height: 380px; background: #6366f1; bottom: -140px; inset-inline-start: -90px; animation-delay: -4s; }
/* Member portal variant: indigo-forward identity */
.login-wrap.member-login { background: linear-gradient(135deg, #1e1b4b 0%, #1e3a5f 55%, var(--primary-darker) 100%); }
.login-wrap.member-login::before { background: #6366f1; }
.login-wrap.member-login::after { background: #14b8a6; }
.login-card {
  position: relative; z-index: 1;
  background: rgba(255, 255, 255, 0.98); border-radius: var(--radius-xl); padding: 2.2rem 1.8rem; width: 100%; max-width: 400px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.35);
  animation: popIn 0.45s var(--ease-spring);
}
.login-card .logo { width: 64px; height: 64px; margin: 0 auto 0.9rem; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: var(--shadow-primary); animation: brandGlow 4s ease-in-out infinite; }
.login-card .logo.member { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35); }
.login-card h1 { text-align: center; font-size: 1.3rem; margin: 0 0 0.3rem; font-weight: 800; }
.login-card .login-sub { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0 0 1.6rem; }
.login-card .login-credit { text-align: center; color: var(--muted); font-size: 0.75rem; margin: 1.4rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border, #e5e7eb); }
.login-hint {
  display: flex; align-items: flex-start; gap: 0.5rem;
  margin-top: 1.1rem; padding: 0.7rem 0.85rem;
  background: var(--primary-50); border: 1px solid var(--primary-light); border-radius: var(--radius-sm);
  color: var(--primary-darker); font-size: 0.78rem; font-weight: 600; line-height: 1.55;
}
.login-hint svg { flex: 0 0 auto; margin-top: 0.1rem; }
.member-login .login-hint { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { padding-inline-end: 2.8rem; }
.pw-toggle {
  position: absolute; inset-inline-end: 0.35rem;
  width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 9px;
  background: transparent; color: var(--muted); box-shadow: none;
}
@media (hover: hover) { .pw-toggle:hover { background: #f1f5f9; color: var(--primary-dark); transform: none; filter: none; box-shadow: none; } }
.pw-toggle.on { color: var(--primary-dark); background: var(--primary-50); }

/* Sidebar nav pending-count badge */
.sidebar nav a .nav-count {
  margin-inline-start: auto;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 0.7rem; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.5);
  animation: pulseBadge 2.2s ease-out infinite;
}

.loading-screen { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--primary-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* skeleton */
.skeleton { background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }

/* ---------- Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.9) translateY(6px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes float { 0%, 100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(-26px) translateX(14px); } }
@keyframes floatSoft { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { 0% { opacity: 0; transform: translateY(22px) scale(0.95); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes tabPop { 0% { transform: scale(0.94); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes alertIn { 0% { opacity: 0; transform: translateY(-8px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes indicatorIn { 0% { opacity: 0; transform: translateY(-50%) scaleY(0.3); } 100% { opacity: 1; transform: translateY(-50%) scaleY(1); } }
@keyframes brandGlow {
  0%, 100% { box-shadow: 0 6px 18px rgba(20, 184, 166, 0.45); }
  50% { box-shadow: 0 6px 26px rgba(20, 184, 166, 0.75); }
}
@keyframes pulseBadge {
  0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
  100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

/* Mobile: dialog becomes a bottom sheet that slides up */
@media (max-width: 560px) {
  .modal-overlay { padding: 0; place-items: end center; }
  .modal {
    max-width: 100%; max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheetUp 0.36s var(--ease-out) both;
  }
  .modal-grabber { display: block; width: 44px; height: 5px; border-radius: 999px; background: #d4dbe3; margin: 0.6rem auto 0; flex: 0 0 auto; }
  .modal-head { border-radius: 0; padding-top: 0.6rem; }
  .modal-foot { border-radius: 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* stagger helper */
.stat-grid .stat:nth-child(1){animation-delay:.02s}
.stat-grid .stat:nth-child(2){animation-delay:.06s}
.stat-grid .stat:nth-child(3){animation-delay:.10s}
.stat-grid .stat:nth-child(4){animation-delay:.14s}
.stat-grid .stat:nth-child(5){animation-delay:.18s}
.stat-grid .stat:nth-child(6){animation-delay:.22s}
.stat-grid .stat:nth-child(7){animation-delay:.26s}
.stat-grid .stat:nth-child(8){animation-delay:.30s}
.grid > *{animation: fadeInUp 0.4s var(--ease-out) both;}
.grid > *:nth-child(2){animation-delay:.04s}
.grid > *:nth-child(3){animation-delay:.08s}
.grid > *:nth-child(4){animation-delay:.12s}
.grid > *:nth-child(5){animation-delay:.16s}
.grid > *:nth-child(6){animation-delay:.20s}
.member-cards > * { animation: fadeInUp 0.4s var(--ease-out) both; }
.member-cards > *:nth-child(2){animation-delay:.05s}
.member-cards > *:nth-child(3){animation-delay:.10s}
.member-cards > *:nth-child(4){animation-delay:.15s}
.member-cards > *:nth-child(5){animation-delay:.20s}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  /* The desktop rail occupies inline-start (the right side in RTL).
     Clear that same logical margin on narrow screens to avoid a 262px
     horizontal overflow that made the interface look unstyled/cropped. */
  .main { margin-inline-start: 0; width: 100%; }
  .topbar .menu-btn { display: inline-flex; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(3px); z-index: 40; animation: fadeIn 0.2s ease; }
  .content { padding: 1rem; }
  .page-head h1 { font-size: 1.25rem; }
  th, td { padding: 0.6rem 0.7rem; }
}

@media print {
  .sidebar, .topbar, .toolbar, .no-print, button, .m-bottomnav, .m-topbar { display: none !important; }
  .main, .m-shell { margin: 0 !important; max-width: none !important; box-shadow: none !important; }
  .content { padding: 0; max-width: none; }
  .table-wrap { border: none; box-shadow: none; }
  body { background: #fff; }
}

/* =====================================================================
   Member mobile-first experience (bottom nav shell)
   ===================================================================== */
.m-shell {
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100dvh;
  max-width: 540px; margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(15, 23, 42, 0.10);
  overscroll-behavior: contain; position: relative;
}
.m-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  padding-top: calc(0.9rem + env(safe-area-inset-top));
  background: linear-gradient(120deg, #0f766e 0%, #115e59 45%, #134e63 100%);
  background-size: 180% 180%;
  animation: gradientDrift 14s ease infinite;
  color: #fff;
  box-shadow: 0 6px 20px rgba(13, 148, 136, 0.3);
}
.m-user { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.m-avatar { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,0.22); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; flex: 0 0 auto; backdrop-filter: blur(4px); box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }
.m-user-meta { min-width: 0; }
.m-name { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-role { font-size: 0.76rem; opacity: 0.9; }
.m-logout { background: rgba(255,255,255,0.18); color: #fff; min-height: 42px; padding: 0 1rem; border-radius: 999px; font-size: 0.85rem; flex: 0 0 auto; box-shadow: none; }
@media (hover: hover) { .m-logout:hover { background: rgba(255,255,255,0.3); transform: none; filter: none; box-shadow: none; } }
@keyframes gradientDrift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.m-content { flex: 1; padding: 1.1rem 1.1rem calc(1.1rem + 80px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; animation: fadeIn 0.4s var(--ease-out) both; }
.m-content .page-head { margin-bottom: 0.9rem; }
.m-content .page-head h1 { font-size: 1.3rem; }

.m-bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 540px; display: flex;
  background: rgba(255,255,255,0.95); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.10);
  padding-bottom: env(safe-area-inset-bottom); z-index: 30;
}
.m-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.25rem; min-height: 64px; color: var(--muted); font-size: 0.74rem; font-weight: 700;
  text-decoration: none; position: relative; transition: color var(--t-fast);
}
.m-tab .m-tab-icon { width: 44px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background var(--t), transform var(--t-spring); }
.m-tab.active { color: var(--primary-darker); }
.m-tab.active .m-tab-icon { background: var(--primary-light); animation: tabPop 0.35s var(--ease-spring); }
.m-tab.active::before { content: ''; position: absolute; top: 0; width: 36px; height: 3px; border-radius: 999px; background: var(--primary); box-shadow: 0 1px 6px rgba(13, 148, 136, 0.5); animation: fadeIn 0.25s ease both; }

.m-shell .grid { grid-template-columns: 1fr; gap: 0.9rem; }
.m-shell .item-img { height: 180px; }
.m-shell button.block { min-height: 50px; font-size: 1rem; }
.m-shell .card .body { padding: 1.1rem 1.15rem; }
.m-shell .card h3 { font-size: 1.1rem; }
.m-shell .meta { font-size: 0.9rem; gap: 0.35rem; }

.receipt-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem; transition: transform var(--t), box-shadow var(--t); }
@media (hover: hover) { .receipt-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); } }
.receipt-card .rc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.receipt-card .rc-title { font-weight: 800; font-size: 1.05rem; }
.receipt-card .rc-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.9rem; font-size: 0.85rem; }
.receipt-card .rc-rows .lbl { color: var(--muted); font-size: 0.74rem; display: block; font-weight: 600; }
.receipt-card .rc-rows .val { font-weight: 700; }

.m-filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.m-filters input { min-height: 48px; }

@media (min-width: 560px) {
  .m-shell { margin: 1rem auto; min-height: calc(100dvh - 2rem); border-radius: var(--radius-xl); overflow: hidden; }
}

/* =====================================================================
   Responsive tables -> stacked cards on phones
   ===================================================================== */
@media (max-width: 640px) {
  .table-wrap:has(.responsive-table) { max-height: none; border: none; background: transparent; overflow: visible; box-shadow: none; }
  .responsive-table thead { display: none; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.8rem; padding: 0.5rem 1rem; box-shadow: var(--shadow-sm); animation: fadeInUp 0.35s var(--ease-out) both; }
  .responsive-table tr:hover { background: #fff; box-shadow: var(--shadow-sm); }
  .responsive-table td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: auto; padding: 0.55rem 0; border: none; border-bottom: 1px dashed var(--border-soft); white-space: normal; text-align: start; }
  .responsive-table td:last-child { border-bottom: none; }
  .responsive-table td::before { content: attr(data-label); font-weight: 700; color: var(--muted); font-size: 0.78rem; flex: 0 0 42%; }
  .responsive-table td.actions::before { content: ''; flex: 0; }
  .responsive-table td.actions { justify-content: stretch; padding-top: 0.7rem; }
  .responsive-table td.actions > * { flex: 1; }
  .responsive-table td.actions button { width: 100%; }

  button { min-height: 46px; }
  button.sm { min-height: 40px; padding: 0.45rem 0.85rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar input, .toolbar select { width: 100%; min-width: 0; }
  .page-head { align-items: flex-start; }
  .page-head .flex { width: 100%; }
  .modal-foot { flex-wrap: wrap; }
  .modal-foot button { flex: 1 1 auto; }
  .topbar .user-chip .avatar { display: none; }
  .topbar .user-chip > div:not(.avatar) { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ---- Return popup: damage toggle ---- */
.damage-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  margin-top: 0.4rem;
  border: 1.5px solid var(--border, #e2e8f0);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  background: var(--surface, #fff);
}
.damage-toggle:hover { border-color: #cbd5e1; }
.damage-toggle.on {
  border-color: var(--danger, #dc2626);
  background: rgba(220, 38, 38, 0.06);
}
.damage-toggle input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  accent-color: var(--danger, #dc2626);
  flex: 0 0 auto;
  cursor: pointer;
}
.damage-toggle .dt-icon {
  display: inline-flex;
  color: #94a3b8;
  margin-top: 0.1rem;
  transition: color 0.2s, transform 0.25s var(--ease-spring);
}
.damage-toggle.on .dt-icon { color: var(--danger, #dc2626); transform: scale(1.12); }
.damage-toggle .dt-text { display: flex; flex-direction: column; gap: 0.2rem; }
.damage-toggle .dt-title { font-weight: 700; font-size: 0.92rem; }
.damage-toggle .dt-sub { font-size: 0.78rem; color: var(--text-soft, #64748b); line-height: 1.5; }

/* ---------- Pending (awaiting receipt confirmation) status ---------- */
.badge.pending { background: #e0e7ff; color: #3730a3; }
.status-edge-pending { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10), var(--shadow-sm); }
.status-pending { background: linear-gradient(90deg, #a5b4fc, #6366f1); }

/* ---------- Member (personnel) mobile portal ---------- */
.member-shell { min-height: 100%; display: flex; flex-direction: column; }
.member-topbar {
  display: flex; align-items: center; gap: 0.65rem;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  padding: 0.65rem 1rem;
  position: sticky; top: 0; z-index: 30;
}
.member-topbar .brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; display: grid; place-items: center; flex: 0 0 auto;
  box-shadow: var(--shadow-primary);
}
.member-topbar-title .t1 { font-weight: 800; font-size: 0.92rem; line-height: 1.2; }
.member-topbar-title .t2 { font-size: 0.72rem; color: var(--muted); }
.member-content { padding: 1rem; max-width: 640px; width: 100%; margin: 0 auto; animation: fadeIn 0.4s var(--ease-out) both; }

.member-hello { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.member-hello .avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
  box-shadow: var(--shadow-primary); flex: 0 0 auto;
}
.member-hello-name { font-weight: 800; font-size: 1.05rem; }

.member-tabs { position: sticky; top: 56px; z-index: 20; }
.member-tabs button { padding: 0.5rem 0.4rem; font-size: 0.85rem; }
.tab-count {
  display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem;
  padding: 0 0.3rem; margin-inline-start: 0.25rem;
  border-radius: 999px; background: var(--danger, #dc2626); color: #fff;
  font-size: 0.7rem; font-weight: 800; line-height: 1;
}

/* ---- Member portal: quick stats + notification banner + bottom nav ---- */
.m-quickstats { display: flex; align-items: stretch; gap: 0.6rem; margin-bottom: 0.9rem; }
.m-chip {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  background: #fff; color: var(--text); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 0.55rem 0.6rem; box-shadow: var(--shadow-xs); min-height: 62px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.m-chip .n { font-size: 1.35rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.m-chip .l { font-size: 0.74rem; color: var(--muted); font-weight: 700; }
.m-chip.on { border-color: var(--primary); box-shadow: var(--glow-primary), var(--shadow-xs); }
.m-chip.warn .n { color: #b45309; }
.m-chip.warn.on { border-color: var(--warning); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12), var(--shadow-xs); }
.m-chip:active { transform: scale(0.96); }
.m-refresh {
  flex: 0 0 auto; width: 52px; min-height: 62px; border-radius: var(--radius);
  background: #fff; color: var(--primary-dark); border: 2px solid var(--border); box-shadow: var(--shadow-xs); padding: 0;
}
@media (hover: hover) { .m-refresh:hover { border-color: var(--primary); background: var(--primary-50); transform: none; filter: none; box-shadow: var(--shadow-xs); } }
.m-refresh:active svg { transform: rotate(-180deg); transition: transform 0.35s ease; }

.m-banner {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: start;
  background: linear-gradient(135deg, #fffbeb, #fef3c7); color: #78350f;
  border: 2px solid #fcd34d; border-radius: var(--radius-lg);
  padding: 0.85rem 1rem; margin-bottom: 0.9rem;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.08), var(--shadow-sm);
  animation: fadeInUp 0.4s var(--ease-out) both;
}
@media (hover: hover) { .m-banner:hover { transform: translateY(-2px); box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.12), var(--shadow); filter: none; } }
.m-banner-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--warning), #d97706); color: #fff;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35);
  animation: floatSoft 3s ease-in-out infinite;
}
.m-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.m-banner-text b { font-size: 0.95rem; }
.m-banner-text span { font-size: 0.78rem; opacity: 0.85; font-weight: 500; }
.m-banner-chev { flex: 0 0 auto; transform: scaleX(-1); opacity: 0.6; }

.m-bottomnav button.m-tab {
  background: transparent; box-shadow: none; border-radius: 0; padding: 0.4rem 0;
  color: var(--muted); font-weight: 700; font-size: 0.74rem; min-height: 64px;
  overflow: visible;
}
.m-bottomnav button.m-tab::after { content: none; }
@media (hover: hover) { .m-bottomnav button.m-tab:hover { transform: none; filter: none; box-shadow: none; color: var(--primary-dark); } }
.m-bottomnav button.m-tab:active { transform: scale(0.94); }
.m-tab .m-tab-icon { position: relative; }
.m-tab-badge {
  position: absolute; top: -4px; inset-inline-end: -2px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 0.66rem; font-weight: 800; line-height: 1;
  box-shadow: 0 0 0 2px #fff;
  animation: popIn 0.3s var(--ease-spring) both;
}
.m-tab-badge.neutral { background: var(--primary); }

/* Very narrow phones: keep all five tabs on one row */
@media (max-width: 380px) {
  .m-tab { font-size: 0.68rem; }
  .m-tab .m-tab-icon { width: 38px; }
}

.member-cards { display: flex; flex-direction: column; gap: 0.7rem; }
.member-item { padding: 0.75rem; }
.member-item.compact { padding: 0.65rem 0.8rem; }
.member-item-head { display: flex; gap: 0.7rem; }
.member-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.member-item-actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px dashed var(--border);
}
.member-item-actions button { flex: 1 1 auto; justify-content: center; }
