/* ==========================================================================
   ChemLab Portal - Reagent Ledger Interface
   ========================================================================== */

/* Fluid Typography Scale & Global Design Tokens */
:root {
  --font-h1: clamp(1.5rem, 5vw, 2.25rem);
  --font-h2: clamp(1.2rem, 4vw, 1.75rem);
  --font-h3: clamp(1.1rem, 3vw, 1.4rem);
  --font-body: clamp(0.9rem, 2vw, 1rem);
  
  --primary: #1e4d2b;
  --primary-light: #e8f5ed;
  --accent: #2c5282;
  --amber: #d97706;
  --red: #ef4444;
  --teal: #0d9488;
  --ink: #1a202c;
  --muted: #718096;
  --line: #edf2f7;
  --line-strong: #e2e8f0;
  --surface: #ffffff;
  --paper: #f8fafc;
  --paper-deep: #f1f5f9;
  
  /* 3-Tier Elevation System */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-glow: 0 0 20px rgba(31, 91, 69, 0.15);
  
  --radius: 12px;
  --font-ui: "IBM Plex Sans", -apple-system, sans-serif;
  --font-display: "Fraunces", serif;
  
  /* Animations */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-ui);
  background-color: var(--paper);
  color: var(--ink);
  margin: 0;
  overflow-x: hidden;
  line-height: 1.5;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(34, 124, 112, 0.28);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--paper-deep);
}

::-webkit-scrollbar-thumb {
  background: #a79d8a;
  border: 2px solid var(--paper-deep);
  border-radius: 999px;
}

#app {
  min-height: calc(100vh - 58px);
}

.view-container {
  display: none;
}

.view-container.active {
  display: block;
  animation: ledgerIn 260ms ease-out both;
}

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

.svg-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-md {
  width: 20px;
  height: 20px;
}

.icon-lg {
  width: 30px;
  height: 30px;
}

.icon-primary {
  color: var(--primary);
}

.icon-accent {
  color: var(--teal);
}

.icon-danger {
  color: var(--red);
}

.icon-warning {
  color: var(--amber);
}

.icon-white {
  color: #fff;
}

/* UI Components: Glassmorphism & Cards */
.glass {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}

.card {
  border-radius: 20px;
  padding: 30px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

/* ==========================================
   RECEIPT MODAL & PRINT STYLES (REDESIGNED)
   ========================================== */

/* The overlay remains full screen */
.receipt-modal.modal-overlay {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.85); /* Slightly darker backdrop */
  backdrop-filter: blur(8px);
}

.receipt-modal.modal-overlay.active {
  display: flex !important;
}

/* New responsive container for the split layout */
.receipt-modal-card {
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--surface);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Header stays sticky */
  box-shadow: var(--shadow-lg);
  animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Sticky Header: Fixes the 'missing X' problem on mobile */
.receipt-modal-header {
  padding: 18px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  z-index: 100;
}

.receipt-modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--primary);
}

.receipt-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Action Buttons in Header */
.btn-show-qr, .btn-print {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-show-qr {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(30, 77, 43, 0.1);
}

.btn-show-qr:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-show-qr:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

.btn-print {
  background: var(--paper-deep);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn-print:hover {
  background: var(--line-strong);
}

/* Scrollable Body with Panels */
.receipt-modal-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  background: var(--paper-deep);
  padding: 24px;
  gap: 24px;
}

/* Receipt Paper (Left Side) */
.receipt-content {
  flex: 2;
  background: white;
  padding: 40px;
  border-radius: 4px; /* classic paper look */
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  position: relative;
  min-height: 100%;
}

.receipt-header {
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.receipt-header h2 {
  font-family: var(--font-display);
  color: var(--primary);
  margin: 0;
  font-size: 24px;
}

.receipt-header p {
  color: var(--muted);
  margin: 4px 0 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.receipt-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 30px;
  font-size: 13px;
}

.receipt-meta-item span {
  color: var(--muted);
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
}

.receipt-meta-item strong, .receipt-meta-item span:last-child {
  color: var(--ink);
  font-weight: 600;
}

.receipt-meta-full {
  grid-column: span 2;
  padding: 12px;
  background: var(--paper);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 40px;
}

.receipt-table th {
  text-align: left;
  border-bottom: 1px solid var(--line-strong);
  padding: 10px 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.receipt-th-qty {
  text-align: center;
  width: 60px;
}

.receipt-table td {
  padding: 12px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}

.receipt-footer {
  margin-top: 60px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.signature-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signature-line {
  border-top: 1px solid var(--ink);
  width: 100%;
  max-width: 180px;
  padding-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
}

/* QR Side Panel (Right Side) */
.qr-side-panel {
  flex: 1;
  max-width: 260px;
  background: var(--surface);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  height: fit-content;
  position: sticky;
  top: 0;
}

.qr-panel-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.close-btn-sm {
  font-size: 1.2rem;
  padding: 0;
}

.receipt-qr {
  background: #fff;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.qr-hint {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.4;
}

/* ==========================================
   PRINT OPTIMIZATION (1-PAGE CLEAN OUTPUT)
   ========================================== */
@media print {
  @page {
    margin: 5mm;
  }
  
  body * {
    visibility: hidden !important;
  }
  
  .receipt-modal, .receipt-modal-card {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: none !important;
    visibility: visible !important;
    display: block !important;
    overflow: visible !important;
  }

  .receipt-modal-header, .qr-side-panel, .no-print {
    display: none !important;
  }

  .receipt-content {
    visibility: visible !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  .receipt-content * {
    visibility: visible !important;
  }
}

/* Timeline */
.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 4px;
}

.timeline-event {
  display: flex;
  gap: 12px;
  position: relative;
}

.timeline-event::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 24px;
  bottom: -20px;
  width: 1px;
  background: var(--line);
}

.timeline-event:last-child::before {
  display: none;
}

.timeline-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--line);
  border: 3px solid var(--surface);
  flex-shrink: 0;
  z-index: 1;
  margin-top: 4px;
}

.timeline-dot.active { background: var(--accent); }
.timeline-dot.success { background: var(--primary); }
.timeline-dot.warning { background: var(--amber); }

.timeline-content {
  display: flex;
  flex-direction: column;
}

.timeline-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Empty State Illustration */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

.svg-illustration {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-receipt-small {
  font-size: 12px;
  padding: 4px 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  color: #475569;
}

.btn-receipt-small:hover {
  background: #e2e8f0;
}


/* Mobile adjustments for New Modal */
@media (max-width: 768px) {
  .receipt-modal-card {
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .receipt-modal-header {
    flex-direction: column;
    padding: 12px;
    gap: 10px;
    align-items: center;
    text-align: center;
  }

  .receipt-modal-header h2 {
    font-size: 1.1rem;
  }

  .receipt-header-actions {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  .btn-show-qr, .btn-print {
    flex: 1;
    justify-content: center;
    padding: 10px 6px;
    font-size: 0.8rem;
  }

  .receipt-modal-body {
    flex-direction: column;
    padding: 12px;
    gap: 0;
  }
  
  .receipt-content {
    padding: 24px 16px;
    box-shadow: none;
    border: none;
  }

  /* QR Panel on Mobile: Transform to a centered overlay */
  .qr-side-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    max-width: 90%;
    width: 300px;
    box-shadow: 0 0 0 1000px rgba(0,0,0,0.6); /* CSS Backdrop Hack */
    border: 2px solid var(--primary);
    animation: qrPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes qrPop {
    from { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  }

  .qr-side-panel.hidden {
    display: none !important;
  }
}

/* Login */

#login-view {
  min-height: calc(100vh - 58px);
  display: none;
  place-items: center;
  padding: 28px 18px;
}

#login-view.active {
  display: grid;
}

.login-card {
  width: min(100%, 468px);
  padding: 36px 38px 38px;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), var(--teal), var(--amber));
}

.login-card::after {
  content: "H2SO4";
  position: absolute;
  right: 20px;
  bottom: 14px;
  z-index: 0;
  color: rgba(31, 91, 69, 0.065);
  font-family: var(--font-display);
  font-size: 4.8rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.login-card > * {
  position: relative;
  z-index: 1;
}

.logo-animation {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: var(--primary);
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.82), transparent 30%),
    linear-gradient(135deg, #dceadf, #c8ddd0);
  border: 1px solid #a8c3b2;
  border-radius: 6px;
  box-shadow: inset 0 -12px 22px rgba(31, 91, 69, 0.08);
}

.lab-mark {
  width: 46px;
  height: 46px;
  overflow: visible;
}

.mark-flask,
.mark-bond,
.mark-liquid {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mark-flask {
  stroke-width: 3;
}

.mark-liquid {
  stroke: var(--teal);
  stroke-width: 3;
}

.mark-bond {
  stroke-width: 1.7;
  opacity: 0.72;
}

.mark-node {
  fill: var(--amber);
  transform-origin: center;
  animation: moleculePulse 3.4s ease-in-out infinite;
}

.node-b {
  animation-delay: 0.4s;
}

.node-c {
  animation-delay: 0.8s;
}

@keyframes moleculePulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.78;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.login-card h1 {
  font-family: var(--font-display);
  max-width: 390px;
  font-size: clamp(1.95rem, 6vw, 2.55rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: 0;
  color: var(--primary);
}

.login-card p {
  margin-top: 10px;
  color: var(--muted);
}

form {
  margin-top: 26px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #26372f;
  text-transform: uppercase;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.form-group input,
.form-group select,
.form-group textarea,
.member-add-form input {
  width: 100%;
  color: var(--ink);
  background: var(--paper-deep);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 11px 12px;
}

.input-wrapper input {
  padding-left: 40px;
}

.form-group textarea {
  min-height: 96px;
  resize: vertical;
}

.form-group select {
  appearance: none;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--primary) 50%),
    linear-gradient(135deg, var(--primary) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.btn-primary,
.btn-accent,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.btn-primary,
.btn-accent {
  width: 100%;
  color: #fffdf8;
  background: var(--primary);
  box-shadow: 0 10px 22px rgba(31, 91, 69, 0.16);
}

.btn-primary:hover,
.btn-accent:hover {
  background: var(--primary);
  box-shadow: 0 15px 28px rgba(31, 91, 69, 0.22);
  transform: translateY(-2px);
}

.btn-primary:active,
.btn-accent:active {
  background: #102d25;
  box-shadow: 0 6px 14px rgba(31, 91, 69, 0.18);
  transform: translateY(0);
}

.btn-primary.is-loading,
.btn-accent.is-loading {
  cursor: wait;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14), transparent 40%, rgba(255, 255, 255, 0.14)),
    var(--primary);
  background-size: 180% 100%;
  animation: buttonLoad 1.1s linear infinite;
}

@keyframes buttonLoad {
  from {
    background-position: 180% 0;
  }
  to {
    background-position: -180% 0;
  }
}

.btn-shine {
  display: none;
}

.btn-secondary {
  gap: 7px;
  padding: 0 13px;
  color: var(--primary);
  background: var(--primary-light);
  border: 1px solid #b6cebf;
}

.btn-secondary:hover {
  background: #cfe2d5;
}

.btn-danger {
  padding: 0 13px;
  color: var(--red);
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  color: #fff;
  background: var(--red);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.receipt-select-wrapper select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.receipt-select-wrapper select:hover {
  border-color: var(--primary);
}

#dashboard-view {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 22px;
}

/* Navbar: Integrated Brand & Actions */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  margin-bottom: 2rem;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text h2 {
  margin: 0;
  font-family: 'Fraunces', serif;
  font-weight: 650;
  font-size: 1.4rem;
  color: var(--primary);
  line-height: 1.1;
}

.nav-actions {
  display: flex;
  gap: 12px;
}

.welcome-badge {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(30, 77, 43, 0.15);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  width: fit-content;
  margin-top: 4px;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  margin-top: 18px;
}

.dashboard-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Stats Row - Intelligent Grid */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
}

.stats-row.full-width {
  grid-column: 1 / -1;
  align-items: start;
}

.stat-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  border-radius: 20px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  background: var(--surface);
  border: 1px solid var(--line);
}

.stat-bubble:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.stat-bubble-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-bubble-icon.amber { background: #fef3c7; color: var(--amber); }
.stat-bubble-icon.blue { background: #ebf8ff; color: var(--accent); }
.stat-bubble-icon.green { background: var(--primary-light); color: var(--primary); }
.stat-bubble-icon.teal { background: #f0fdfa; color: var(--teal); }

.stat-bubble-info {
  margin-top: 12px;
}

.stat-bubble-info .label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 4px;
}

.stat-bubble-info .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1;
}

/* Util Bar */
.util-bar-container {
  width: 120px;
  height: 6px;
  background: var(--paper-deep);
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
}

.util-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 99px;
  transition: width 1s ease-in-out;
}

.welcome-card {
  padding: 22px;
  background:
    linear-gradient(90deg, rgba(31, 91, 69, 0.08), transparent 62%),
    var(--surface);
}

.welcome-card h1 {
  max-width: 700px;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--primary);
}

.welcome-card p,
.section-desc {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.welcome-card p {
  margin-top: 8px;
}

.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.section-desc {
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.collapsible-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--primary);
}

.collapsible-content {
  margin-top: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow-y: auto;
  padding-right: 2px;
}

.list-item,
.borrow-item,
.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: 6px;
}

.borrow-item {
  display: block;
  border-left-color: var(--primary);
}

.list-item.Pending {
  border-left-color: var(--amber);
}

.list-item.Approved,
.list-item.Released {
  border-left-color: var(--primary);
}

.list-item.Rejected {
  border-left-color: var(--red);
}

.list-item.Returned,
.list-item.Active {
  border-left-color: var(--accent);
}

.item-info {
  min-width: 0;
}

.item-title {
  display: block;
  font-weight: 700;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.item-subtitle,
.other-pending-details {
  color: var(--muted);
  font-size: 0.86rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-badge.Pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.status-badge.Approved,
.status-badge.Released {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #bbf7d0;
}

.status-badge.Rejected {
  background: #fee2e2;
  color: var(--red);
  border: 1px solid #fecaca;
}

.status-badge.Returned,
.status-badge.Active {
  background: #ebf8ff;
  color: var(--accent);
  border: 1px solid #bee3f8;
}

.empty-text {
  padding: 22px;
  color: var(--muted);
  background: var(--paper-deep);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  text-align: center;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(23, 33, 28, 0.38);
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: min(100%, 520px);
  padding: 22px;
  border-top: 5px solid var(--teal);
  background: var(--surface);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 1.35rem;
}

.close-btn {
  width: 36px;
  height: 36px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
}

.close-btn:hover {
  background: #fee2e2;
  color: var(--red);
}

.member-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  margin-bottom: 18px;
}

.members-list-wrapper {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.members-list-wrapper h4 {
  margin-bottom: 10px;
  color: var(--ink);
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.member-row {
  border-left-color: var(--teal);
}

.member-row-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.btn-remove-member {
  min-height: 32px;
  padding: 0 8px;
  color: var(--red);
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 700;
}

.btn-remove-member:hover {
  background: #fee2e2;
}

/* Toasts */

.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--primary);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  animation: toastIn 220ms ease-out both;
  transition: opacity 220ms ease, transform 220ms ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.error {
  border-left-color: var(--red);
}

.toast.info {
  border-left-color: var(--accent);
}

.add-item-box {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 15px;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.cart-container {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.cart-header h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.btn-text-only {
  background: none;
  border: none;
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-text-only:hover {
  background: rgba(239, 68, 68, 0.1);
}

.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cart-item-info {
  display: flex;
  flex-direction: column;
}

.cart-item-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9rem;
}

.cart-item-qty {
  font-size: 0.8rem;
  color: var(--muted);
}

.remove-item-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-item-btn:hover {
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
}

.main-footer {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

.hidden {
  display: none !important;
}

/* Activity Templates Grid (Phase 4) */
.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.activity-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.activity-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.activity-card h4 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--primary);
  font-size: 1.1rem;
}

.activity-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.activity-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.item-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 99px;
}

.btn-quick-claim {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Skeleton Loading Animation */
.activity-skeleton {
  height: 140px;
  background: linear-gradient(90deg, var(--paper-deep) 25%, var(--line) 50%, var(--paper-deep) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 12px;
}

@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Responsive Design: Master Media Queries */
@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  #app {
    padding: 0;
  }

  #dashboard-view {
    padding: 16px;
  }

  /* Requirement: 1.25rem heading */
  .welcome-card h1 {
    font-size: 1.25rem !important;
    line-height: 1.3;
  }

  /* Requirement: Header Arrangement */
  .navbar {
    flex-direction: column;
    padding: 1.25rem 1rem;
    gap: 1.5rem;
    text-align: center;
  }

  .nav-brand {
    flex-direction: column;
    gap: 8px;
  }

  .brand-text {
    align-items: center;
  }

  /* Requirement: Stacked Vertical Actions */
  .receipt-footer {
    flex-direction: column;
    align-items: center;
    gap: 40px;
    margin-top: 40px;
  }

  .signature-box {
    width: 100%;
  }

  .signature-line {
    max-width: 240px;
    margin: 0 auto;
  }

  .nav-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .btn-secondary,
  .btn-danger {
    width: 100%;
    padding: 12px;
    justify-content: center;
    font-size: 0.9rem;
  }

  /* Requirement: 2x2 Grid for Metrics */
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-bubble {
    padding: 20px 12px;
  }

  .stat-bubble-info .value {
    font-size: 1.25rem;
  }

  .stat-bubble-info .label {
    font-size: 0.65rem;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .card {
    padding: 24px 16px;
  }
}


