/* ==========================================================================
   PharmSys - Design System & Modern CSS Framework (Glassmorphism & Medical Dark)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Color Palette - Medical Sleek Dark (Default) */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-card-hover: rgba(51, 65, 85, 0.8);
  --bg-glass: rgba(15, 23, 42, 0.65);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(6, 182, 212, 0.5);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.3);
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  /* Status Colors */
  --badge-ok: rgba(16, 185, 129, 0.15);
  --badge-ok-text: #34d399;
  --badge-warning: rgba(245, 158, 11, 0.15);
  --badge-warning-text: #fbbf24;
  --badge-danger: rgba(244, 63, 94, 0.15);
  --badge-danger-text: #fb7185;

  /* Typography & Structure */
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', sans-serif;

  --sidebar-width: 260px;
  --topbar-height: 70px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px var(--accent-cyan-glow);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --backdrop-blur: blur(16px);
}

/* Light Theme Variables Toggle */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: #f8fafc;
  --bg-glass: rgba(255, 255, 255, 0.8);
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(at 10% 10%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.06) 0px, transparent 50%);
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.45) transparent;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

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

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.38);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(6, 182, 212, 0.65);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

[data-theme="light"] * {
  scrollbar-color: rgba(100, 116, 139, 0.4) transparent;
}

[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ==========================================================================
   Layout Architecture
   ========================================================================== */

html {
  -webkit-text-size-adjust: 100%;
}

.app-container {
  display: flex;
  min-height: 100vh;
  min-width: 0;
  width: 100%;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-cyan-glow);
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-menu {
  padding: 20px 14px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.menu-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 12px 4px;
  letter-spacing: 1px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.nav-link:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.1));
  color: var(--accent-cyan);
  border: 1px solid var(--border-active);
  font-weight: 600;
}

.nav-link i {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-parent {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}

.nav-parent .nav-caret {
  margin-left: auto;
  width: auto;
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.nav-group.open .nav-parent .nav-caret {
  transform: rotate(180deg);
}

.nav-submenu {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 6px 20px;
  padding-left: 10px;
  border-left: 1px solid var(--border-color);
}

.nav-group.open .nav-submenu {
  display: flex;
}

.nav-sub {
  padding: 9px 12px;
  font-size: 0.86rem;
}

.nav-sub:hover {
  transform: none;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
}

.user-details h4 {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.2;
}

.user-details span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  width: auto;
}

/* Topbar Styling */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-page-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.topbar-page-title h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.caja-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--badge-ok);
  color: var(--badge-ok-text);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.caja-status-pill.cerrada {
  background: var(--badge-danger);
  color: var(--badge-danger-text);
  border-color: rgba(244, 63, 94, 0.3);
}

.caja-status-link {
  text-decoration: none;
  flex-shrink: 0;
}

.caja-pill-short {
  display: none;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
}

.btn-icon.sidebar-toggle {
  display: none;
}

/* Page Body Container */
.content-body {
  padding: 30px;
  flex: 1;
}

/* ==========================================================================
   UI Components & Cards
   ========================================================================== */

/* Glass Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition-fast);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

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

.header-actions,
.page-toolbar,
.form-actions,
.login-demo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Metric Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.03));
  pointer-events: none;
}

.stat-info h3 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-info .value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 800;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.stat-icon.rose { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-ok { background: var(--badge-ok); color: var(--badge-ok-text); }
.badge-warning { background: var(--badge-warning); color: var(--badge-warning-text); }
.badge-danger { background: var(--badge-danger); color: var(--badge-danger-text); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-emerald {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-emerald:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-rose), #e11d48);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 11px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px var(--accent-cyan-glow);
}

.form-panel {
  margin: 8px 0 18px;
  padding: 14px 14px 4px;
  border: 1px solid rgba(6, 182, 212, 0.28);
  border-radius: 12px;
  background: rgba(6, 182, 212, 0.06);
}

.form-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.form-panel-help {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 12px;
}

.sell-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.sell-flag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.sell-flag:has(input:checked) {
  border-color: var(--border-active);
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.sell-flag input {
  width: 16px;
  height: 16px;
}

.form-match {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.1);
}

.form-match.is-visible {
  display: flex;
}

.form-match strong {
  display: block;
  font-size: 0.86rem;
}

.form-match span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.lote-existentes {
  margin-bottom: 14px;
}

.lote-existentes-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.lote-existentes-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.lote-existentes-item.is-alerta {
  border-color: rgba(245, 158, 11, 0.4);
}

.lote-existentes-item.is-vencido {
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--accent-rose);
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  padding: 14px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.1);
}

.table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

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

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ==========================================================================
   POS Specific Interface Grid
   ========================================================================== */

.pos-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  height: calc(100vh - var(--topbar-height) - 60px);
  min-width: 0;
  overflow: hidden;
}

.pos-catalog-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.pos-search-bar {
  display: flex;
  gap: 12px;
}

.pos-search-input {
  flex: 1;
  position: relative;
}

.pos-search-input i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.pos-search-input input {
  padding-left: 46px;
  font-size: 1rem;
}

.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  justify-content: start;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
  flex: 1;
  min-height: 0;
}

.pos-products-grid .pos-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.product-item-card {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: auto;
  height: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  cursor: default;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  box-sizing: border-box;
  overflow: visible;
}

.product-item-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.product-thumb-wrap {
  position: relative;
  margin-bottom: 8px;
}

.product-thumb {
  width: 100%;
  height: 72px;
  object-fit: contain;
  background: rgba(0,0,0,0.18);
  border-radius: 8px;
  margin-bottom: 0;
}

.product-thumb-count {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}

.product-item-card .title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.product-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 88px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  color: var(--text-dim);
  font-size: 2rem;
}

.product-img-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border-color);
}

.inv-thumb-wrap {
  position: relative;
  flex-shrink: 0;
}

.inv-thumb-count {
  position: absolute;
  right: -4px;
  bottom: -4px;
  background: var(--accent-cyan);
  color: #041018;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
}

.photo-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-dropzone {
  border: 1px dashed var(--border-active);
  border-radius: var(--radius-md);
  background: rgba(6, 182, 212, 0.05);
  padding: 10px;
  min-height: 120px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.photo-dropzone.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 148px;
}

.photo-dropzone:hover,
.photo-dropzone.is-dragover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
}

.photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  pointer-events: none;
}

.photo-empty i {
  font-size: 1.8rem;
  color: var(--accent-cyan);
}

.photo-empty strong {
  color: var(--text-main);
  font-size: 0.92rem;
}

.photo-empty span {
  font-size: 0.78rem;
}

.product-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.photo-dropzone.is-empty .product-gallery {
  width: 100%;
  justify-content: center;
}

.photo-add-tile {
  width: 96px;
  height: 96px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.photo-add-tile i {
  font-size: 1.4rem;
  color: var(--accent-cyan);
}

.photo-add-tile:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.gallery-thumb {
  position: relative;
  width: 96px;
  height: 96px;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-color);
}

.gallery-thumb-new img {
  outline: 2px solid var(--accent-cyan);
  outline-offset: -2px;
}

.gallery-thumb-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.82);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.gallery-thumb:hover .gallery-thumb-remove,
.gallery-thumb-remove:focus {
  opacity: 1;
}

.gallery-thumb-remove:hover {
  background: var(--accent-rose);
}

@media (max-width: 860px) {
  .gallery-thumb-remove {
    opacity: 1;
  }
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-dialog-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.app-dialog {
  width: 90%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.app-dialog-overlay.active .app-dialog {
  transform: translateY(0);
}

.app-dialog-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-size: 1.4rem;
}

.app-dialog-icon.is-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.app-dialog-title {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-main);
}

.app-dialog-message {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.app-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.app-dialog-actions .btn {
  min-width: 120px;
}

.preview-related-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  text-decoration: underline;
  padding: 0;
}

.modal-content.product-preview-modal {
  max-width: 720px;
  max-height: min(86vh, 620px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px 16px 12px;
}

.product-preview-modal .card-header {
  flex-shrink: 0;
  margin-bottom: 12px;
  padding-bottom: 10px;
}

#product-preview-body {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.preview-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.preview-gallery,
.preview-gallery.is-empty,
.preview-photo-main {
  width: 210px;
  height: 210px;
  min-width: 210px;
  min-height: 210px;
  max-width: 210px;
  max-height: 210px;
}

.preview-gallery {
  position: sticky;
  top: 0;
}

.preview-gallery.is-empty {
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.78rem;
}

.preview-gallery.is-empty i {
  font-size: 1.8rem;
  color: var(--accent-cyan);
}

.preview-photo-main {
  position: relative;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-photo-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.preview-nav.prev { left: 8px; }
.preview-nav.next { right: 8px; }

.preview-photo-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.preview-thumbs {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 6px;
  margin: 0;
  overflow-x: auto;
}

.preview-thumb {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  padding: 0;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.preview-thumb.active {
  border-color: var(--accent-cyan);
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-info .preview-meta {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 0 0 10px;
}

.preview-prices {
  margin: 12px 0;
}

.preview-actions {
  width: 100%;
}

.preview-pack-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 10px;
}

.preview-pack-btn {
  flex: 1;
  min-width: 72px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.preview-pack-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.12));
  border-color: var(--border-active);
  color: var(--accent-cyan);
}

.preview-pack-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-qty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
}

.preview-qty-row > span {
  font-size: 0.82rem;
  font-weight: 600;
}

.preview-qty-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-qty-input {
  width: 64px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
}

.preview-qty-input:disabled {
  opacity: 0.5;
}

.preview-qty-row small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.preview-add-btn {
  width: 100%;
}

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

.pos-card-lab {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.pos-card-open {
  display: block;
  width: 100%;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.product-item-card.is-adding {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.35);
}

.pack-rows {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
}

.pack-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 6px 4px 4px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 0.78rem;
}

.pack-row-main {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(58px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 8px;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.pack-row.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.12));
  border-color: var(--border-active);
  color: var(--accent-cyan);
}

.pack-row.is-disabled,
.pack-row-main:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.pack-row-cart {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex: 0 0 auto;
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
}

.pack-row-cart .cart-qty-btn {
  width: 26px;
  height: 26px;
}

.pack-row-qty,
.cart-item-qty-input {
  width: 56px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.88rem;
  text-align: center;
  padding: 0 4px;
  -moz-appearance: textfield;
}

.pack-row-qty::-webkit-outer-spin-button,
.pack-row-qty::-webkit-inner-spin-button,
.cart-item-qty-input::-webkit-outer-spin-button,
.cart-item-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pack-row-qty:focus,
.cart-item-qty-input:focus {
  outline: none;
  border-color: var(--border-active);
}

.pack-row-incart {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.18);
  color: var(--accent-cyan);
  font-size: 0.7rem;
  font-weight: 800;
  margin-right: 4px;
}

.pack-row-add {
  border: none;
  border-radius: 6px;
  background: var(--accent-emerald, #10b981);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.pack-row-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pack-row-remove {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pack-row-name {
  font-weight: 700;
}

.pack-row-left {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.pack-row.active .pack-row-left {
  color: var(--accent-cyan);
}

.pack-row-price {
  font-weight: 800;
  white-space: nowrap;
}

.stock-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

.stock-chip {
  background: rgba(16, 185, 129, 0.14);
  color: var(--badge-ok-text);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
}

.stock-chip.is-zero {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.quick-add {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid rgba(6, 182, 212, 0.45);
  border-radius: 10px;
  background: rgba(6, 182, 212, 0.08);
}

.quick-add-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.quick-add-head small {
  color: var(--text-muted);
}

.quick-add-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quick-add-controls .preview-qty-controls {
  flex: 0 0 auto;
}

.quick-add-controls .btn {
  flex: 1 1 120px;
}

.preview-related h4 {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.preview-related-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.preview-related-item {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  min-width: 200px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-main);
  cursor: pointer;
}

.preview-related-item:hover {
  border-color: var(--accent-cyan);
}

.preview-related-item img,
.preview-related-ph {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.preview-related-ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.preview-related-item span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.preview-related-item strong {
  font-size: 0.82rem;
}

.preview-related-item small {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.preview-related-empty {
  color: var(--text-muted);
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .preview-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .preview-info {
    width: 100%;
  }

  .preview-gallery,
  .preview-gallery.is-empty,
  .preview-photo-main {
    width: 180px;
    height: 180px;
    min-width: 180px;
    min-height: 180px;
    max-width: 180px;
    max-height: 180px;
    position: relative;
  }

  .preview-related-list {
    grid-template-columns: none;
  }
}

.substitute-card {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.substitute-card-main {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.substitute-card .product-thumb-wrap {
  width: 72px;
  flex-shrink: 0;
  margin-bottom: 0;
}

.substitute-card .product-thumb {
  width: 72px;
  height: 72px;
}

.product-item-card .principio {
  font-size: 0.78rem;
  color: var(--accent-cyan);
  margin-bottom: 10px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.product-item-card .prices {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 10px;
  min-width: 0;
}

.pos-card-prices {
  min-width: 0;
}

.pos-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}

.pos-card-actions .btn:only-child {
  grid-column: 1 / -1;
}

.pos-card-actions .btn {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.price-caja {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.price-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.product-item-card.out-of-stock {
  opacity: 0.55;
}

.dashboard-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 30px;
}

.caja-warning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--badge-warning);
  color: var(--badge-warning-text);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.stock-box {
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}
.stock-box small {
  display: block;
  font-weight: 500;
  opacity: 0.85;
}
.stock-ok { color: var(--badge-ok-text); }
.stock-low { color: var(--badge-warning-text); }
.stock-out { color: var(--badge-danger-text); }
.stock-expired { color: var(--badge-danger-text) !important; }

.client-box {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}
.comprobante-switch {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.comp-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.pago-switch {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.pago-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 72px;
  padding: 10px 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: pointer;
  text-align: center;
  transition: var(--transition-fast);
}

.pago-btn i {
  font-size: 1.25rem;
}

.pago-btn strong {
  font-size: 0.82rem;
  font-weight: 700;
  color: inherit;
}

.pago-btn small {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.pago-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.12));
  border-color: var(--border-active);
  color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan-glow);
}

.pago-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cash-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -6px 0 14px;
}

.cash-quick-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.cash-quick-btn:hover,
.cash-quick-btn.active {
  border-color: var(--border-active);
  color: var(--accent-cyan);
}

.pos-change-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  background: var(--bg-primary);
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.pos-change-box #pos-change-due {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.pos-digital-box {
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.comp-btn.active {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(59, 130, 246, 0.12));
  border-color: var(--border-active);
  color: var(--accent-cyan);
}
.client-ticket-info {
  background: var(--bg-primary);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.82rem;
}
.client-ticket-info small {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
}
.client-identified {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.client-identified .form-control {
  padding: 8px 10px;
  font-size: 0.82rem;
}
.client-lookup-status {
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Cart Panel Right */
.pos-cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-width: 0;
}

.cart-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-item-title {
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

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

.cart-item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cart-item-total {
  font-weight: 800;
  white-space: nowrap;
}

.cart-item-qty {
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.cart-pack-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.16);
  color: var(--accent-cyan);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--accent-rose);
  cursor: pointer;
  font-size: 1.15rem;
  padding: 2px 4px;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-qty-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cart-summary-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.25);
}

.summary-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.summary-line.total {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 10px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-fast);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 550px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition-fast);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

/* Login Card Specific */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
}

/* Print Ticket Styling */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: absolute; left: 0; top: 0; width: 100%; }
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1280px) {
  .pos-container {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
    gap: 16px;
  }

  .pos-catalog-panel {
    overflow: visible;
  }

  .pos-products-grid {
    max-height: none;
    overflow: visible;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  }

  .pos-cart-panel {
    min-height: 0;
    height: auto;
    overflow: visible;
    position: relative;
    z-index: 1;
  }

  .cart-items-list {
    max-height: 220px;
  }
}

@media (max-width: 1200px) {
  .dashboard-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {

  .sidebar {
    display: flex;
    transform: translateX(-100%);
    z-index: 120;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle,
  .btn-icon.sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .main-wrapper {
    margin-left: 0;
  }
}

@media (max-width: 860px) {
  .content-body {
    padding: 14px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    gap: 8px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .topbar-page-title {
    flex: 1;
    min-width: 0;
  }

  .topbar-page-title h1 {
    font-size: 0.98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .caja-status-pill {
    display: inline-flex;
    padding: 5px 10px;
    font-size: 0.72rem;
    gap: 6px;
  }

  .caja-pill-full {
    display: none;
  }

  .caja-pill-short {
    display: inline;
  }

  .card {
    padding: 16px;
  }

  .card-title {
    font-size: 1rem;
  }

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

  .stat-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  .stats-grid {
    gap: 12px;
    margin-bottom: 18px;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }

  .table {
    min-width: 560px;
  }

  .table th,
  .table td {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
    gap: 10px;
  }

  .product-item-card {
    padding: 12px;
  }

  .pos-card-actions .btn {
    min-height: 40px;
    font-size: 0.78rem;
  }

  .pos-search-input input {
    font-size: 16px;
  }

  .pos-container {
    gap: 12px;
  }

  .form-grid-2,
  .form-grid-3,
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .modal-overlay,
  .app-dialog-overlay {
    padding: 10px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .modal-content {
    width: 100%;
    max-width: 100% !important;
    padding: 16px;
    margin: 6px 0 20px;
    max-height: none;
  }

  .caja-warning-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .caja-header-row {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  .page-toolbar,
  .header-actions,
  .form-actions,
  .login-demo-actions,
  .app-dialog-actions {
    width: 100%;
  }

  .header-actions .btn,
  .form-actions .btn,
  .page-toolbar .btn,
  .login-demo-actions .btn,
  .app-dialog-actions .btn {
    flex: 1 1 auto;
    min-height: 42px;
  }

  #inventory-search,
  #kardex-product {
    max-width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100%;
  }

  .comprobante-switch,
  .pago-switch {
    grid-template-columns: 1fr 1fr;
  }

  .cart-header {
    padding: 14px;
  }

  .cart-summary-footer {
    padding: 14px;
  }

  .cart-qty-btn {
    width: 36px;
    height: 36px;
  }

  .login-body {
    padding: 16px;
    align-items: flex-start;
  }

  .login-card {
    padding: 24px 18px;
    max-width: 100%;
  }

  .sidebar {
    width: min(var(--sidebar-width), 86vw);
  }
}

@media (max-width: 480px) {
  .pos-products-grid {
    grid-template-columns: 1fr;
  }

  .pos-card-actions {
    grid-template-columns: 1fr;
  }

  .content-body {
    padding: 10px;
  }

  .topbar-page-title h1 {
    font-size: 0.9rem;
    max-width: 42vw;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
  }

  .table {
    min-width: 520px;
  }

  .form-actions,
  .modal-content [style*="justify-content:flex-end"],
  .modal-content [style*="display: flex"][style*="gap: 12px"] {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn,
  .modal-content [style*="justify-content:flex-end"] .btn,
  .modal-content [style*="display: flex"][style*="gap: 12px"] .btn {
    width: 100%;
  }
}
