:root {
  --ink: #1C1B1F;
  --ink-soft: #29282E;
  --paper: #F7F5F0;
  --surface: #FFFFFF;
  --surface-alt: #F0EDE4;
  --line: #E1DDD1;

  --text: #201F1C;
  --text-muted: #7C7669;

  --accent: #2F6F4E;
  --accent-ink: #16402A;
  --accent-soft: #E3EEE7;

  --warn: #B5482A;
  --warn-soft: #F6E3DA;

  --radius-s: 6px;
  --radius-m: 10px;

  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { 
  box-sizing: border-box; 
  -webkit-tap-highlight-color: transparent;
}

html, body { 
  height: 100%; 
  height: -webkit-fill-available;
  overflow: hidden; /* Prevent full-page bounce scrolling */
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input { font-family: inherit; color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- APP SHELL & GRID ---------- */

.app {
  display: flex;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  width: 100vw;
}

/* Sidebar Rail */
.rail {
  width: 220px;
  flex-shrink: 0;
  background: var(--ink);
  color: #EDEAE2;
  display: flex;
  flex-direction: column;
  transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
}

.rail__brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.rail__mark {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 1.2rem;
}

.rail__nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail__link {
  text-decoration: none;
  color: #C9C4B8;
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  touch-action: manipulation;
}

.rail__icon {
  font-size: 1.1rem;
  display: none; /* Displayed in tablet icon-rail mode */
}

.rail__link:hover { background: rgba(255,255,255,0.07); color: #fff; }
.rail__link.active { background: var(--accent); color: #fff; }

.rail__foot {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.rail__logout {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.16);
  color: #C9C4B8;
  padding: 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.rail__logout:hover { border-color: var(--warn); color: #fff; }

/* Main Screen Wrapper */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__search input {
  width: 340px;
  max-width: 35vw;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 8px 14px;
  border-radius: var(--radius-s);
  font-size: 0.9rem;
}

.topbar__search input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.topbar__meta { display: flex; align-items: center; gap: 16px; }
.topbar__clock {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.topbar__user { text-align: right; line-height: 1.2; }
.topbar__user-name { display: block; font-weight: 600; font-size: 0.85rem; }
.topbar__till { display: block; font-size: 0.75rem; color: var(--text-muted); }

.content {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0; /* CRITICAL for preventing child grid overflow */
  overflow-y: auto;
  overflow-x: hidden;
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */

/* Large Desktop Screens (1440px+) */
@media (min-width: 1440px) {
  .rail { width: 240px; }
  .content { padding: 24px; }
  .topbar { height: 64px; padding: 0 32px; }
  .topbar__search input { width: 420px; }
}

/* Tablets & Small Laptops (768px - 1199px) */
@media (max-width: 1199px) {
  .rail {
    width: 68px; /* Condense sidebar into icon rail */
  }

  .rail__name, 
  .rail__link .rail__label, 
  .rail__logout .rail__label {
    display: none; /* Hide textual labels */
  }

  .rail__brand {
    justify-content: center;
    padding: 16px 0;
  }

  .rail__icon {
    display: inline-block;
  }

  .rail__link {
    justify-content: center;
    padding: 12px 0;
  }

  .rail__logout {
    padding: 12px 0;
  }

  .content {
    padding: 14px;
  }

  .topbar {
    padding: 0 16px;
  }
}

/* Mobile Screens (< 768px) */
@media (max-width: 767px) {
  html, body { overflow: auto; }
  .app { flex-direction: column; height: auto; overflow: visible; }
  .rail { width: 100%; flex-direction: row; height: 50px; flex: 0 0 50px; }
  .rail__nav {
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 6px;
    overflow-x: auto;
    min-width: 0;
  }
  .rail__link { flex: 0 0 auto; padding: 10px 9px; font-size: 0.82rem; }
  .rail__brand, .rail__foot { display: none; }
  .rail__icon { display: block; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar__search { min-width: 0; flex: 1 1 auto; }
  .topbar__search input { max-width: 100%; width: 100%; padding: 8px; }
  .topbar__meta { gap: 8px; }
  .topbar__clock { display: none; }
  .topbar__user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}


/* ==========================================================================
   Modernized Button & Chip Design System (Pill-shaped, Vibrant Gradients, Soft Glow)
   ========================================================================== */

/* Base Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  min-height: 40px;
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid #e0e0e0;
  background: #ffffff;
  color: #201f1c;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
  white-space: nowrap;
}

.btn:hover {
  background: #fafafa;
  border-color: #c0c0c0;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Primary and Active States (Green Gradient) */
.btn-primary,
.btn--primary,
.btn.btn-primary,
.chip.active,
.cat-chip.active,
button.chip.active {
  background: linear-gradient(135deg, #137547 0%, #22a45a 100%) !important;
  color: #ffffff !important;
  border-radius: 20px !important;
  padding: 10px 24px;
  border: none !important;
  box-shadow: 0 4px 15px rgba(34, 164, 90, 0.4) !important;
  font-weight: 500;
  text-decoration: none;
}

.btn-primary:hover,
.btn--primary:hover,
.btn.btn-primary:hover {
  background: linear-gradient(135deg, #0c5c34 0%, #1a8b4b 100%) !important;
  box-shadow: 0 6px 20px rgba(34, 164, 90, 0.55) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.btn-primary:active,
.btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(34, 164, 90, 0.4) !important;
}

/* Action/Print Buttons (Teal Gradient) */
.btn-print,
.btn.btn-print {
  background: linear-gradient(135deg, #056654 0%, #0d9488 100%) !important;
  color: #ffffff !important;
  border-radius: 25px !important;
  padding: 12px 30px;
  border: none !important;
  box-shadow: 0 4px 15px rgba(13, 148, 136, 0.4) !important;
  font-weight: 500;
  text-decoration: none;
}

.btn-print:hover,
.btn.btn-print:hover {
  background: linear-gradient(135deg, #034b3e 0%, #0a736a 100%) !important;
  box-shadow: 0 6px 20px rgba(13, 148, 136, 0.55) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.btn-print:active,
.btn.btn-print:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4) !important;
}

/* Warning/Refund Buttons (Orange/Coral Gradient) */
.btn-warn,
.btn.btn-warn,
.btn--danger,
.btn.btn--danger {
  background: linear-gradient(135deg, #ae2012 0%, #ee9b00 100%) !important;
  color: #ffffff !important;
  border-radius: 25px !important;
  padding: 12px 30px;
  border: none !important;
  box-shadow: 0 4px 15px rgba(238, 155, 0, 0.4) !important;
  font-weight: 500;
  text-decoration: none;
}

.btn-warn:hover,
.btn.btn-warn:hover,
.btn--danger:hover,
.btn.btn--danger:hover {
  background: linear-gradient(135deg, #961b0f 0%, #d48a00 100%) !important;
  box-shadow: 0 6px 20px rgba(238, 155, 0, 0.55) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.btn-warn:active,
.btn.btn-warn:active,
.btn--danger:active,
.btn.btn--danger:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(238, 155, 0, 0.4) !important;
}

/* Ghost/Secondary Navigation Buttons */
.btn-ghost,
.btn.btn-ghost {
  background: #ffffff !important;
  color: #201f1c !important;
  border: 1px solid #e0e0e0 !important;
  border-radius: 20px !important;
  padding: 8px 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
  font-weight: 500;
}

.btn-ghost:hover,
.btn.btn-ghost:hover {
  background: #fafafa !important;
  border-color: #c0c0c0 !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08) !important;
  transform: translateY(-1px);
}

.btn-ghost:active,
.btn.btn-ghost:active {
  transform: translateY(0);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
}

/* Size Modifiers */
.btn-sm,
.btn--sm,
.btn--small {
  min-height: 32px;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 20px !important;
}

.btn-full {
  width: 100%;
  text-align: center;
}

/* Sidebar Logout Button */
.rail__logout,
button.rail__logout {
  width: 100%;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  color: #C9C4B8 !important;
  padding: 10px 18px;
  border-radius: 20px !important;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.rail__logout:hover,
button.rail__logout:hover {
  background: linear-gradient(135deg, #ae2012 0%, #ee9b00 100%) !important;
  border-color: transparent !important;
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(238, 155, 0, 0.4) !important;
  transform: translateY(-1px);
}

/* Chips & Category Filters */
.chip,
.cat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 20px !important;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  touch-action: manipulation;
}

.chip:hover,
.cat-chip:hover {
  border-color: #b0b0b0;
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.chip.active,
.cat-chip.active,
button.chip.active {
  background: linear-gradient(135deg, #137547 0%, #22a45a 100%) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 20px !important;
  box-shadow: 0 4px 15px rgba(34, 164, 90, 0.4) !important;
  font-weight: 500;
}

.chip.active:hover,
.cat-chip.active:hover {
  box-shadow: 0 6px 20px rgba(34, 164, 90, 0.55) !important;
  transform: translateY(-1px);
}

/* Table Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 5px 14px;
  border-radius: 20px !important;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

