/* =========================================================
   WasteGuard — Design System "Sober Elegance"
   Paleta cálida Topo / Beige — Sin verde
   ========================================================= */

/* ── Variables ──────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --c-bg:           #EDE4D7;
  --c-bg-alt:       #F5EEE4;
  --c-surface:      #FDFAF6;
  --c-surface-2:    #F2EAE0;
  --c-surface-3:    #E8DECE;

  /* Brand */
  --c-primary:      #6B5040;
  --c-primary-h:    #573E30;
  --c-primary-txt:  #FDFAF6;
  --c-accent:       #B5784A;
  --c-accent-h:     #9A6138;
  --c-accent-light: #D4A882;

  /* Text */
  --c-text:         #1A1410;
  --c-text-2:       #4A3C30;
  --c-text-3:       #8A7A6A;
  --c-text-4:       #B0A090;

  /* Borders */
  --c-border:       #CFC4B4;
  --c-border-light: #E5DDD2;

  /* Semantic */
  --c-danger:       #943028;
  --c-danger-bg:    #F5EDEB;
  --c-danger-txt:   #7A2020;
  --c-warning:      #A87018;
  --c-warning-bg:   #F5ECDA;
  --c-warning-txt:  #8C5C10;
  --c-info:         #3D6B8C;
  --c-info-bg:      #E6EEF5;
  --c-info-txt:     #2A4F6E;
  --c-muted:        #D8CEBF;

  /* Layout */
  --nav-h:          68px;
  --header-h:       60px;
  --safe-b:         env(safe-area-inset-bottom, 8px);
  --safe-t:         env(safe-area-inset-top, 0px);

  /* Radius */
  --r-sm:   8px;
  --r-md:   14px;
  --r-lg:   20px;
  --r-xl:   28px;
  --r-full: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(50,30,15,.08), 0 1px 2px rgba(50,30,15,.06);
  --shadow-md:  0 4px 12px rgba(50,30,15,.10), 0 2px 4px rgba(50,30,15,.07);
  --shadow-lg:  0 8px 28px rgba(50,30,15,.13), 0 4px 8px rgba(50,30,15,.08);
  --shadow-xl:  0 20px 48px rgba(50,30,15,.18);

  /* Transitions */
  --t-fast:   150ms cubic-bezier(.4,0,.2,1);
  --t-base:   250ms cubic-bezier(.4,0,.2,1);
  --t-slow:   400ms cubic-bezier(.4,0,.2,1);
  --t-spring: 350ms cubic-bezier(.34,1.56,.64,1);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI',
          system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ── App Shell ──────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 768px;
  margin: 0 auto;
  position: relative;
  background: var(--c-bg);
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  padding-top: var(--safe-t);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.app-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header__logo-icon {
  width: 34px;
  height: 34px;
  background: var(--c-primary);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-primary-txt);
}

.app-header__brand {
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--c-text);
}

.app-header__sub {
  font-size: .72rem;
  color: var(--c-text-3);
  font-weight: 400;
  letter-spacing: .2px;
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-2);
  transition: background var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover, .icon-btn:active { background: var(--c-surface-2); color: var(--c-text); }

/* ── Bottom Nav ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 768px;
  z-index: 50;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border-light);
  display: flex;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  box-shadow: 0 -4px 20px rgba(50,30,15,.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding-block: 10px;
  color: var(--c-text-3);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .3px;
  text-transform: uppercase;
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  cursor: pointer;
}

.nav-item__icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: background var(--t-base), transform var(--t-spring);
}

.nav-item.active {
  color: var(--c-primary);
}

.nav-item.active .nav-item__icon {
  background: var(--c-surface-2);
  transform: translateY(-1px);
}

.nav-item__badge {
  position: absolute;
  top: 8px;
  right: 50%;
  transform: translateX(8px);
  min-width: 18px;
  height: 18px;
  background: var(--c-danger);
  color: white;
  border-radius: var(--r-full);
  font-size: .62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-inline: 4px;
  border: 2px solid var(--c-surface);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

/* ── Pages / Router ──────────────────────────────────────── */
.page {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 24px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(24px);
  transition: opacity var(--t-base), transform var(--t-base);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.page.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.page.exit-left  { transform: translateX(-24px); opacity: 0; }
.page.exit-right { transform: translateX(24px); opacity: 0; }
.page.enter-left  { transform: translateX(-24px); }
.page.enter-right { transform: translateX(24px); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border-light);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card--elevated {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--c-border-light);
}

.card-title {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--c-text-3);
}

.card-body {
  padding: 16px 18px;
}

/* ── KPI Grid ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border-light);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.kpi-card--primary::before   { background: var(--c-primary); }
.kpi-card--accent::before    { background: var(--c-accent); }
.kpi-card--warning::before   { background: var(--c-warning); }
.kpi-card--info::before      { background: var(--c-info); }

.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--c-text-3);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--c-text);
  line-height: 1;
}

.kpi-value span {
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: 0;
}

.kpi-sub {
  font-size: .72rem;
  color: var(--c-text-3);
  margin-top: 4px;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: .7rem;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: var(--r-full);
}

.kpi-trend--up   { color: var(--c-danger); background: var(--c-danger-bg); }
.kpi-trend--down { color: var(--c-warning); background: var(--c-warning-bg); }
.kpi-trend--flat { color: var(--c-text-3); background: var(--c-surface-2); }

/* ── Section Headers ─────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 8px;
}

.section-title {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--c-text-2);
}

.section-action {
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-accent);
  padding: 4px 0;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .2px;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }

.btn--primary {
  background: var(--c-primary);
  color: var(--c-primary-txt);
  box-shadow: 0 2px 8px rgba(107,80,64,.30);
}
.btn--primary:hover { background: var(--c-primary-h); }

.btn--accent {
  background: var(--c-accent);
  color: white;
  box-shadow: 0 2px 8px rgba(181,120,74,.30);
}
.btn--accent:hover { background: var(--c-accent-h); }

.btn--ghost {
  background: var(--c-surface-2);
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
}
.btn--ghost:hover { background: var(--c-surface-3); }

.btn--danger {
  background: var(--c-danger);
  color: white;
}

.btn--full { width: 100%; }
.btn--lg { padding: 16px 28px; font-size: 1rem; border-radius: var(--r-lg); }
.btn--sm { padding: 8px 14px; font-size: .8rem; }
.btn--icon { padding: 10px; gap: 0; }

.btn:disabled {
  opacity: .45;
  pointer-events: none;
}

/* Loading state */
.btn.loading { pointer-events: none; }
.btn.loading::after {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-left: 8px;
}

/* ── Form Elements ───────────────────────────────────────── */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--c-text-3);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 13px 16px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-size: .95rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(107,80,64,.12);
}

.form-input::placeholder { color: var(--c-text-4); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A7A6A' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Stepper input */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 50px;
}

.stepper__btn {
  width: 50px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: 1.3rem;
  font-weight: 400;
  border-right: 1px solid var(--c-border);
  transition: background var(--t-fast);
  flex-shrink: 0;
}

.stepper__btn:last-child {
  border-right: none;
  border-left: 1px solid var(--c-border);
}

.stepper__btn:active { background: var(--c-surface-3); }

.stepper__input {
  flex: 1;
  text-align: center;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--c-text);
  width: 100%;
}
.stepper__input:focus { outline: none; }

/* Chip select */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  border-radius: var(--r-full);
  font-size: .8rem;
  font-weight: 600;
  border: 1.5px solid var(--c-border);
  color: var(--c-text-2);
  background: var(--c-surface);
  transition: all var(--t-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover { border-color: var(--c-primary); color: var(--c-primary); }

.chip.selected {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: white;
  box-shadow: 0 2px 6px rgba(107,80,64,.25);
}

.chip.selected.chip--accent {
  background: var(--c-accent);
  border-color: var(--c-accent);
  box-shadow: 0 2px 6px rgba(181,120,74,.25);
}

/* ── Lists ───────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--t-fast);
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--c-surface-2); }

.list-item__icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.list-item__body {
  flex: 1;
  min-width: 0;
}

.list-item__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item__sub {
  font-size: .75rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

.list-item__right {
  text-align: right;
  flex-shrink: 0;
}

.list-item__amount {
  font-size: .92rem;
  font-weight: 700;
  color: var(--c-text);
}

.list-item__label {
  font-size: .7rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.badge--danger  { background: var(--c-danger-bg);  color: var(--c-danger-txt); }
.badge--warning { background: var(--c-warning-bg); color: var(--c-warning-txt); }
.badge--info    { background: var(--c-info-bg);    color: var(--c-info-txt); }
.badge--muted   { background: var(--c-surface-2);  color: var(--c-text-3); }
.badge--primary { background: var(--c-primary);    color: white; }

/* ── Stock Bar ───────────────────────────────────────────── */
.stock-bar {
  height: 4px;
  background: var(--c-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: 6px;
}

.stock-bar__fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .5s ease;
}

.stock-bar__fill--ok      { background: var(--c-info); }
.stock-bar__fill--warning { background: var(--c-warning); }
.stock-bar__fill--danger  { background: var(--c-danger); }

/* ── Search Bar ──────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-full);
  padding: 10px 16px;
  margin-bottom: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-bar:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(107,80,64,.10);
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: .9rem;
  color: var(--c-text);
}

.search-bar input:focus { outline: none; }
.search-bar input::placeholder { color: var(--c-text-4); }
.search-bar svg { color: var(--c-text-3); flex-shrink: 0; }

/* ── FAB ─────────────────────────────────────────────────── */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--c-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  transition: transform var(--t-spring), box-shadow var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.93); }
.fab:hover { box-shadow: var(--shadow-xl); }

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: min(calc(100vw - 32px), 380px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--c-text);
  color: white;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  animation: toast-in var(--t-spring) forwards;
  pointer-events: auto;
}

.toast.removing { animation: toast-out var(--t-base) forwards; }

.toast--success { background: var(--c-primary); }
.toast--error   { background: var(--c-danger); }
.toast--warning { background: var(--c-warning); }

.toast svg { flex-shrink: 0; opacity: .85; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(.95); }
}

/* ── Bottom Sheet / Modal ────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,20,16,.55);
  z-index: 60;
  opacity: 0;
  transition: opacity var(--t-base);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.visible { opacity: 1; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 768px;
  z-index: 70;
  background: var(--c-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-xl);
  max-height: 92dvh;
  overflow-y: auto;
  transition: transform var(--t-slow) cubic-bezier(.32,0,.67,0);
  padding-bottom: calc(24px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}

.sheet.visible {
  transform: translateX(-50%) translateY(0);
  transition-timing-function: cubic-bezier(.22,1,.36,1);
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--c-border);
  margin: 14px auto 8px;
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 16px;
  border-bottom: 1px solid var(--c-border-light);
}

.sheet__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--c-text);
}

.sheet__body { padding: 20px; }

/* ── Divider ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--c-border-light);
  margin: 12px 0;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state__icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-3);
  margin-bottom: 4px;
}

.empty-state__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c-text-2);
}

.empty-state__sub {
  font-size: .85rem;
  color: var(--c-text-3);
  max-width: 240px;
}

/* ── Skeleton ────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--c-surface-2) 25%,
    var(--c-surface-3) 50%,
    var(--c-surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

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

/* ── Page: Dashboard ─────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--c-warning-bg);
  border: 1px solid rgba(168,112,24,.25);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  font-size: .85rem;
  color: var(--c-warning-txt);
  font-weight: 500;
}

.alert-banner svg { color: var(--c-warning); flex-shrink: 0; }

/* ── Page: Registro ──────────────────────────────────────── */
.registro-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.costo-display {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.costo-display__label {
  font-size: .8rem;
  color: var(--c-text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.costo-display__value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--c-danger);
  letter-spacing: -0.5px;
}

/* Quick amount buttons */
.quick-amounts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-amt-btn {
  padding: 7px 12px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--c-border);
  font-size: .78rem;
  font-weight: 600;
  color: var(--c-text-2);
  background: var(--c-surface);
  transition: all var(--t-fast);
}

.quick-amt-btn:active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: white;
  transform: scale(.95);
}

/* ── Page: Inventario ────────────────────────────────────── */
.inv-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--t-fast);
}

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

.inv-item__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.inv-item__name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--c-text);
  flex: 1;
  min-width: 0;
}

.inv-item__cat {
  font-size: .72rem;
  color: var(--c-text-3);
  margin-top: 2px;
}

.inv-item__stock {
  text-align: right;
  flex-shrink: 0;
}

.inv-item__stock-value {
  font-size: .95rem;
  font-weight: 700;
  color: var(--c-text);
}

.inv-item__stock-min {
  font-size: .7rem;
  color: var(--c-text-3);
}

.inv-item__actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

/* ── Page: Historial ─────────────────────────────────────── */
.hist-day-header {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--c-text-3);
  padding: 12px 0 6px;
  display: flex;
  justify-content: space-between;
}

.hist-day-total {
  font-size: .78rem;
  font-weight: 700;
  color: var(--c-danger);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.fade-in { animation: fade-in var(--t-base) ease forwards; }

/* ── Tipo colors ─────────────────────────────────────────── */
.tipo-desecho    { background: #F5EDEB; color: #7A2020; }
.tipo-porcionado { background: #EEF2F8; color: #2A4F6E; }
.tipo-caducado   { background: #F5ECDA; color: #8C5C10; }
.tipo-produccion { background: #EDE4D7; color: #5A4035; }
.tipo-devolucion { background: #F0EAF5; color: #4A306A; }

/* ── Responsive – Tablet ─────────────────────────────────── */
@media (min-width: 600px) {
  .page { padding: 24px 24px 32px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .form-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-value { font-size: 1.8rem; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 4px; }

/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Dark mode support ───────────────────────────────────── */
/* Deliberadamente no incluido — la paleta cálida es la identidad de marca */

/* =========================================================
   AI Chef Consultant — "Sober Elegance" warm neutral
   Paleta: Topo · Arena · Beige. PROHIBIDO verde y azul.
   ========================================================= */

/* Variables propias de la tarjeta AI */
:root {
  --ai-bg:          #F7F2EA;          /* arena cálida */
  --ai-bg-alt:      #EFE8DC;          /* topo claro */
  --ai-border:      rgba(160,115,58,.22);
  --ai-accent:      #8C6530;          /* caoba/amber oscuro */
  --ai-accent-h:    #73521F;
  --ai-accent-light:#C49A5C;          /* arena dorada */
  --ai-glow:        rgba(176,136,76,.18);
  --ai-text:        #2A1E10;
  --ai-text-2:      #6B5030;
  --ai-text-muted:  #9A8060;
  --ai-alert-bg:    #F2E8D8;
  --ai-alert-border:rgba(160,115,58,.30);
}

/* ── Tarjeta contenedora ─────────────────────────────────── */
.ai-card {
  position: relative;
  background: linear-gradient(145deg, var(--ai-bg) 0%, var(--ai-bg-alt) 100%);
  border: 1px solid var(--ai-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow:
    0 2px 12px var(--ai-glow),
    inset 0 1px 0 rgba(255,255,255,.6);
  margin-bottom: 16px;
}

/* Línea superior de marca */
.ai-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--ai-accent), var(--ai-accent-light), var(--ai-accent));
  background-size: 200% 100%;
  animation: ai-shimmer-line 3s linear infinite;
}

@keyframes ai-shimmer-line {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ── Cabecera de la tarjeta ──────────────────────────────── */
.ai-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  gap: 10px;
}

.ai-card__title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ai-card__icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--ai-accent) 0%, var(--ai-accent-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FAF6F0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(140,101,48,.30);
}

.ai-card__label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.ai-card__name {
  font-size: .88rem;
  font-weight: 800;
  color: var(--ai-text);
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-card__by {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--ai-accent);
}

.ai-card__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Botón idioma */
.ai-lang-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--ai-border);
  background: var(--ai-bg);
  color: var(--ai-text-2);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: all var(--t-fast);
  cursor: pointer;
}
.ai-lang-btn:hover { background: var(--ai-bg-alt); border-color: var(--ai-accent-light); }
.ai-lang-btn.active {
  background: var(--ai-accent);
  border-color: var(--ai-accent);
  color: #FAF6F0;
}

/* Botón refrescar */
.ai-refresh-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid var(--ai-border);
  color: var(--ai-text-muted);
  transition: all var(--t-fast);
  cursor: pointer;
}
.ai-refresh-btn:hover { background: var(--ai-bg-alt); color: var(--ai-accent); }
.ai-refresh-btn.spinning svg { animation: spin .7s linear infinite; }

/* ── Cuerpo del análisis ─────────────────────────────────── */
.ai-card__body {
  padding: 0 16px 16px;
}

/* Divider */
.ai-divider {
  height: 1px;
  background: var(--ai-border);
  margin: 0 0 14px;
}

/* Texto generado con efecto typewriter */
.ai-text {
  font-size: .875rem;
  line-height: 1.65;
  color: var(--ai-text);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 40px;
}

/* Cursor parpadeante mientras escribe */
.ai-text.typing::after {
  content: '▋';
  display: inline-block;
  color: var(--ai-accent);
  animation: ai-cursor .6s step-end infinite;
  margin-left: 1px;
}

@keyframes ai-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Estado de carga (skeleton IA) ───────────────────────── */
.ai-loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.ai-loading__bar {
  height: 12px;
  border-radius: var(--r-sm);
  background: linear-gradient(90deg,
    var(--ai-bg-alt) 25%,
    rgba(196,154,92,.25) 50%,
    var(--ai-bg-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

/* ── Alertas proactivas ──────────────────────────────────── */
.ai-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.ai-alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ai-alert-bg);
  border: 1px solid var(--ai-alert-border);
  border-radius: var(--r-md);
  font-size: .8rem;
}

.ai-alert-item__icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ai-accent);
  background: rgba(140,101,48,.12);
  margin-top: 1px;
}

.ai-alert-item__body { flex: 1; min-width: 0; }

.ai-alert-item__title {
  font-weight: 700;
  color: var(--ai-text);
  line-height: 1.3;
}

.ai-alert-item__detail {
  color: var(--ai-text-2);
  margin-top: 2px;
  font-size: .74rem;
}

.ai-alert-item__cost {
  font-weight: 800;
  color: var(--c-danger);
  font-size: .82rem;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Fallback / no-key state ─────────────────────────────── */
.ai-fallback {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: rgba(160,115,58,.08);
  border-radius: var(--r-md);
  font-size: .82rem;
  color: var(--ai-text-2);
}
.ai-fallback svg { color: var(--ai-accent); flex-shrink: 0; margin-top: 1px; }

/* ── Footer metadata ─────────────────────────────────────── */
.ai-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 14px;
  font-size: .68rem;
  color: var(--ai-text-muted);
  border-top: 1px solid var(--ai-border);
  letter-spacing: .2px;
}

.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ai-accent-light);
  display: inline-block;
  margin-right: 5px;
  animation: ai-pulse 2.5s ease-in-out infinite;
}

.ai-status-dot.active { background: var(--ai-accent); }

@keyframes ai-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.8); }
}

/* =========================================================
   Clerk Auth — Sign-in overlay + component overrides
   Paleta: Arena (#EEE5D8), Topo (#6B5040), Cream (#FDFAF6)
   ========================================================= */

/* ── Sign-in overlay ──────────────────────────────────── */
#auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--c-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
}

#auth-overlay.hidden {
  display: none;
}

.auth-overlay__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--c-primary);
}

.auth-overlay__logo svg { flex-shrink: 0; }

.auth-overlay__wordmark {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--c-primary);
}

.auth-overlay__sub {
  font-size: .8rem;
  color: var(--c-text-3);
  text-align: center;
  max-width: 280px;
}

#clerk-signin-mount {
  width: 100%;
  max-width: 400px;
}

/* ── Clerk component appearance (CSS variables) ──────── */
/* These target Clerk's injected shadow-DOM variables      */
:root {
  --clerk-color-primary:              #6B5040;
  --clerk-color-primary-hover:        #5A4033;
  --clerk-color-background:           #FDFAF6;
  --clerk-color-surface:              #EEE5D8;
  --clerk-color-input-background:     #FDFAF6;
  --clerk-color-text:                 #1A1410;
  --clerk-color-text-secondary:       #7A6A5A;
  --clerk-color-neutral:              #B5A898;
  --clerk-color-danger:               #943028;
  --clerk-border-radius:              10px;
  --clerk-font-family:                inherit;
}

/* ── Header org/user bar ─────────────────────────────── */
#app-header {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  min-height: 44px;
}

#app-header.visible { display: flex; }

/* ── Admin-only nav items ────────────────────────────── */
.nav-item[data-admin-only] {
  display: none;
}
.nav-item[data-admin-only].visible {
  display: flex;
}

/* ── Settings page cards ─────────────────────────────── */
.settings-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 18px;
}

.settings-card__title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--c-text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--c-border);
  gap: 12px;
}

.settings-row:last-child { border-bottom: none; }

.settings-row__label {
  font-size: .82rem;
  color: var(--c-text-2);
  flex: 1;
}

.settings-row__value {
  font-size: .82rem;
  font-weight: 600;
  color: var(--c-text);
  text-align: right;
}

.settings-row__value code {
  font-family: monospace;
  font-size: .78rem;
  background: var(--c-bg);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--c-primary);
}

/* ── Generic badge variants ──────────────────────────── */
.badge--info    { background: rgba(61,107,140,.12); color: #3D6B8C; }
.badge--warning { background: var(--c-warning-bg);  color: var(--c-warning-txt); }
}
