/* ═══════════════════════════════════════════════════════════════════
   ระบบเบิกอุปกรณ์ v2 — Design System
   Mobile-first, Dark theme, Glassmorphism
   Font: Angsana New (Thai professional serif)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Font Declaration — Angsana New (bundled with Windows/Office) ── */
@font-face {
  font-family: 'Angsana New';
  src: local('Angsana New'), local('AngsanaNew');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Angsana New';
  src: local('Angsana New Bold'), local('AngsanaNew-Bold');
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

/* ── CSS Variables (Design Tokens) ──────────────────────────────── */
:root {
  /* Background layers */
  --bg: #0b0d1a;
  --surface: #111327;
  --surface2: #181b30;
  --surface3: #1f2340;
  --surface-hover: #232742;

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.6);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Primary palette — Indigo/Violet */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --accent: #8b5cf6;

  /* Gradient */
  --grad-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --grad-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --grad-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --grad-bg: radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.08) 0%, transparent 60%),
    linear-gradient(180deg, #0b0d1a 0%, #0e1020 100%);

  /* Semantic colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --info: #3b82f6;
  --red: #ef4444;

  /* Text */
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --text-bright: #f8fafc;

  /* Spacing & Shape */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);

  /* Transitions */
  --transition: all 0.2s ease;
  --transition-slow: all 0.35s ease;

  /* Nav */
  --nav-height: 64px;
}

/* ── Reset & Base ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* Fluid base: 16px on mobile → 18px on desktop for Angsana New readability */
  font-size: clamp(16px, 1.5vw + 12px, 18px);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Angsana New', 'AngsanaUPC', 'TH SarabunPSK', Georgia, serif;
  background: var(--bg);
  background-image: var(--grad-bg);
  background-attachment: fixed;
  color: var(--text);
  /* Angsana New has tall Thai vowel marks — use wider line-height */
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Sharper text rendering for serif Thai font */
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--text-bright);
}

img {
  max-width: 100%;
  display: block;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--surface3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ── Navbar ──────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(17, 19, 39, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 24px rgba(0, 0, 0, 0.4);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-bright);
  font-weight: 700;
  /* Angsana New reads slightly larger — tune to match visual weight */
  font-size: clamp(1rem, 1.2vw + 0.6rem, 1.15rem);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand:hover {
  color: var(--primary-light);
}

.nav-brand-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-brand-text {
  letter-spacing: -0.01em;
}

.nav-brand-badge {
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--grad-primary);
  color: white;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-link {
  color: var(--text-dim);
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1rem);
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-bright);
  background: var(--surface2);
}

.nav-link.active {
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.12);
}

.nav-logout {
  color: var(--danger);
}

.nav-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.nav-login {
  background: var(--grad-primary);
  color: white !important;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
}

.nav-login:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ── Main Content ─────────────────────────────────────────────────── */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 16px 60px;
  min-height: calc(100vh - var(--nav-height));
}

.main-content.wide {
  max-width: 1280px;
}

/* ── Page Header ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-text {
  flex: 1;
}

.page-title {
  /* Fluid heading: 1.5rem mobile → 2rem desktop */
  font-size: clamp(1.5rem, 2.5vw + 0.8rem, 2rem);
  font-weight: 700;
  color: var(--text-bright);
  /* Angsana New serif — reduce negative tracking */
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.page-sub {
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1rem);
  color: var(--text-muted);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-strong);
}

.card-title {
  font-size: clamp(1rem, 1.2vw + 0.6rem, 1.15rem);
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Form Elements ───────────────────────────────────────────────── */
.field {
  margin-bottom: 20px;
}

.label {
  display: block;
  font-size: clamp(0.82rem, 0.9vw + 0.5rem, 0.9rem);
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.label-icon {
  margin-right: 4px;
}

.text-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(0.95rem, 1.1vw + 0.55rem, 1.05rem);
  padding: 11px 14px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
  /* Align Thai baseline cleanly */
  line-height: 1.6;
}

.text-input::placeholder {
  color: var(--text-muted);
}

.text-input:focus {
  border-color: var(--primary);
  background: var(--surface3);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.text-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.text-input[type="number"] {
  -moz-appearance: textfield;
}

.text-input[type="number"]::-webkit-outer-spin-button,
.text-input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

select.text-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-error {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 5px;
  min-height: 18px;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 5px;
}

.required-badge {
  color: var(--warning);
  font-size: 0.75rem;
  font-weight: 500;
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: clamp(0.92rem, 1vw + 0.5rem, 1.05rem);
  font-weight: 700;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 44px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--grad-primary);
  color: white;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
  color: white;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface3);
  color: var(--text-bright);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--grad-danger);
  color: white;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.4);
  color: white;
}

.btn-success {
  background: var(--grad-success);
  color: white;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(16, 185, 129, 0.4);
  color: white;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
  min-height: 36px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

/* Submit button (large) */
.submit-btn {
  width: 100%;
  padding: 15px 24px;
  font-family: inherit;
  font-size: clamp(1rem, 1.2vw + 0.6rem, 1.15rem);
  font-weight: 700;
  background: var(--grad-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(99, 102, 241, 0.35);
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.02em;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.5);
}

.submit-btn:active:not(:disabled) {
  transform: translateY(0);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Item Row (requisition form) ─────────────────────────────────── */
.item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  animation: fadeInSlide 0.25s ease;
  transition: var(--transition);
}

.item-row > div:first-child {
  grid-column: 1 / -1;
}

.item-row:hover {
  border-color: var(--border-strong);
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item-equip-btn {
  width: 100%;
  background: var(--surface3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  min-height: 44px;
}

.item-equip-btn:hover {
  border-color: var(--primary);
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.08);
}

.item-equip-btn.selected {
  border-style: solid;
  border-color: var(--primary);
  color: var(--text-bright);
  background: rgba(99, 102, 241, 0.1);
}

.item-stock-badge {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  padding-left: 2px;
}

.item-stock-badge.low {
  color: var(--warning);
}

.item-stock-badge.empty {
  color: var(--danger);
}

.item-qty-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.qty-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.item-qty-input {
  width: 80px;
  background: var(--surface3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  /* Keep monospace for numbers */
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: clamp(1rem, 1.1vw + 0.6rem, 1.1rem);
  font-weight: 600;
  padding: 9px 10px;
  text-align: center;
  outline: none;
  transition: var(--transition);
  -moz-appearance: textfield;
}

.item-qty-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.item-qty-input::-webkit-inner-spin-button,
.item-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

.item-remove-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0;
}

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

.add-item-btn {
  width: 100%;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}

.add-item-btn:hover {
  border-color: var(--primary);
  color: var(--primary-light);
  background: rgba(99, 102, 241, 0.05);
}

/* ── Photo Section ───────────────────────────────────────────────── */
.photo-area {
  margin-top: 6px;
}

.photo-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

.photo-btn:hover {
  background: var(--surface3);
  border-color: var(--primary);
  color: var(--primary-light);
}

.photo-btn.primary {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  color: var(--primary-light);
}

.photo-preview {
  margin-top: 12px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
}

.photo-preview img {
  max-height: 200px;
  border-radius: var(--radius-sm);
  width: auto;
}

.photo-preview-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.compress-badge {
  display: inline-block;
  font-size: 0.72rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 8px;
}

.hidden-input {
  display: none !important;
}

.hidden {
  display: none !important;
}

/* ── Search Popup ────────────────────────────────────────────────── */
.search-popup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: popupFadeIn 0.2s ease;
}

.search-popup.hidden {
  display: none;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.popup-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

@media (min-width: 640px) {
  .search-popup {
    align-items: center;
  }

  .popup-box {
    border-radius: var(--radius-xl);
    max-height: 70vh;
    margin: 16px;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-bright);
  flex-shrink: 0;
}

.popup-close-btn {
  width: 32px;
  height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: var(--transition);
}

.popup-close-btn:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.popup-search {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.popup-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: var(--transition);
}

.popup-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.popup-search-input::placeholder {
  color: var(--text-muted);
}

.popup-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.popup-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}

.popup-list-item:last-child {
  border-bottom: none;
}

.popup-list-item:hover {
  background: var(--surface-hover);
}

.popup-list-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.popup-item-name {
  font-size: clamp(0.95rem, 1.1vw + 0.55rem, 1.05rem);
  color: var(--text);
  font-weight: 600;
}

.popup-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: right;
}

.popup-item-stock {
  display: block;
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: clamp(0.82rem, 0.95vw + 0.45rem, 0.92rem);
  font-weight: 600;
}

.popup-item-stock.ok {
  color: var(--success);
}

.popup-item-stock.low {
  color: var(--warning);
}

.popup-item-stock.empty {
  color: var(--danger);
}

.popup-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 20px;
  font-size: 0.9rem;
}

/* ── Toast Notification ──────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface3);
  border: 1px solid var(--border-strong);
  color: var(--text-bright);
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: clamp(0.92rem, 1vw + 0.5rem, 1rem);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  max-width: calc(100vw - 32px);
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  white-space: pre-line;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.toast.error {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.toast.info {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary-light);
}

/* ── Modal Overlay ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-box-wide {
  max-width: 640px;
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-bright);
}

.modal-body {
  padding: 16px 24px 24px;
}

.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  gap: 10px;
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* Image modal */
.modal-img-box {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-img-box img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: var(--radius);
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.8);
}

.modal-img-box .modal-close-btn {
  position: absolute;
  top: -44px;
  right: 0;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  border-color: transparent;
  font-size: 1.2rem;
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1rem);
  min-width: 500px;
}

.data-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: clamp(0.78rem, 0.85vw + 0.45rem, 0.88rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

/* ── Stock Badge ─────────────────────────────────────────────────── */
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: clamp(0.8rem, 0.88vw + 0.45rem, 0.88rem);
  font-weight: 700;
  min-width: 56px;
  justify-content: center;
}

.stock-badge.ok {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.stock-badge.low {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.stock-badge.empty {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled) {
  background: var(--surface3);
  color: var(--text-bright);
  border-color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Skeleton loader ─────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

.skeleton-row {
  height: 52px;
  margin-bottom: 8px;
  border-radius: var(--radius);
}

.skeleton-row:nth-child(2) {
  width: 85%;
}

.skeleton-row:nth-child(3) {
  width: 70%;
}

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Login Page ──────────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-logo {
  font-size: 3.5rem;
  text-align: center;
  margin-bottom: 8px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.login-title {
  text-align: center;
  font-size: clamp(1.4rem, 2.5vw + 0.8rem, 1.75rem);
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: clamp(0.92rem, 1vw + 0.52rem, 1rem);
  margin-bottom: 28px;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  padding: 10px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-back {
  display: block;
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-back:hover {
  color: var(--primary-light);
}

/* ── Admin Tabs ──────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  width: fit-content;
}

.admin-tab {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: clamp(0.9rem, 1vw + 0.5rem, 1rem);
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.admin-tab:hover {
  color: var(--text-bright);
}

.admin-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ── Toolbar (search + actions row) ─────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  flex: 1;
  min-width: 200px;
}

.toolbar-search-icon {
  color: var(--text-muted);
  font-size: 1rem;
}

.toolbar-search input {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 0;
  outline: none;
  width: 100%;
}

.toolbar-search input::placeholder {
  color: var(--text-muted);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Date Filter Bar ─────────────────────────────────────────────── */
.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.date-filter label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.date-sep {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Stats Row ───────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-num {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: clamp(1.1rem, 1.5vw + 0.7rem, 1.35rem);
  font-weight: 700;
  color: var(--primary-light);
}

.stat-label {
  font-size: clamp(0.8rem, 0.9vw + 0.46rem, 0.88rem);
  color: var(--text-muted);
}

/* ── Equipment Image (thumbnail) ─────────────────────────────────── */
.equip-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  transition: var(--transition);
}

.equip-thumb:hover {
  transform: scale(1.1);
  border-color: var(--primary);
}

.equip-no-img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* ── Count badge ─────────────────────────────────────────────────── */
.count-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: var(--primary-light);
  font-size: clamp(0.75rem, 0.82vw + 0.42rem, 0.82rem);
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: 'Courier New', 'Consolas', monospace;
}

/* ── Form row grid ───────────────────────────────────────────────── */
.form-row {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .form-row.col2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row.col3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main-content {
    padding: 20px 12px 48px;
  }

  .page-title {
    /* clamp() already handles mobile — this acts as safety floor */
    font-size: 1.5rem;
  }

  .card {
    padding: 18px;
  }

  .login-card {
    padding: 28px 20px;
  }

  .admin-tabs {
    width: 100%;
  }

  .admin-tab {
    flex: 1;
    text-align: center;
  }

  .modal-box {
    max-width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    min-width: unset;
  }
}

@media (min-width: 768px) {
  .item-row {
    grid-template-columns: 1fr 150px 44px;
    align-items: end;
  }

  .item-row > div:first-child {
    grid-column: auto;
  }

  .item-qty-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .item-qty-input {
    width: 100%;
  }
}

/* ── Misc utilities ──────────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-muted {
  color: var(--text-muted);
}

.text-mono {
  font-family: 'Courier New', 'Consolas', monospace;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.flex {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flex-1 {
  flex: 1;
}

.gap-2 {
  gap: 8px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Footer card ─────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: clamp(0.82rem, 0.9vw + 0.46rem, 0.9rem);
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

/* ── Tablet breakpoint font tweaks ──────────────────────────────── */
@media (min-width: 641px) and (max-width: 1024px) {
  html {
    font-size: 17px;
  }
}

/* ── Desktop & large screens ─────────────────────────────────────── */
@media (min-width: 1025px) {
  html {
    font-size: 18px;
  }

  .nav-link {
    font-size: 1rem;
  }

  .data-table {
    font-size: 1rem;
  }
}