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

/* ==========================================================================
   TOKENS DE DISEÑO: BENTO LUJO OSCURO & MODO CLARO ELEGANTE
   ========================================================================== */
:root {
  --bg-outer: #030304;
  --bg-app: #09090B;
  --bg-surface: #131316;
  --bg-card: #151519;
  --bg-card-grad: linear-gradient(145deg, #19191E 0%, #111114 100%);
  --bg-gold-card: linear-gradient(145deg, rgba(214, 184, 146, 0.22) 0%, rgba(181, 142, 97, 0.06) 100%);
  --bg-glass: rgba(19, 19, 22, 0.84);
  --border: rgba(255, 255, 255, 0.07);
  --border-gold: rgba(214, 184, 146, 0.32);
  --text-primary: #F7F5F0;
  --text-secondary: #98948D;
  --text-muted: #5F5C56;
  --gold-1: #E8CFA8;
  --gold-2: #D6B892;
  --gold-3: #B58E61;
  --gold-grad: linear-gradient(135deg, #E8CFA8 0%, #D6B892 50%, #B58E61 100%);
  --gold-soft: rgba(214, 184, 146, 0.14);
  --gold-text: #09090B;
  --success: #34D399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --wa: #25D366;
  --wa-soft: rgba(37, 211, 102, 0.16);
}

[data-theme="light"] {
  --bg-outer: #E4E4E7;
  --bg-app: #F5F5F7;
  --bg-surface: #EBEBEF;
  --bg-card: #FFFFFF;
  --bg-card-grad: linear-gradient(145deg, #FFFFFF 0%, #FAFAFC 100%);
  --bg-gold-card: linear-gradient(145deg, rgba(181, 142, 97, 0.16) 0%, rgba(214, 184, 146, 0.08) 100%);
  --bg-glass: rgba(255, 255, 255, 0.86);
  --border: rgba(17, 17, 19, 0.07);
  --border-gold: rgba(181, 142, 97, 0.42);
  --text-primary: #111113;
  --text-secondary: #636366;
  --text-muted: #8E8E93;
  --gold-1: #C8A476;
  --gold-2: #B58E61;
  --gold-3: #967247;
  --gold-grad: linear-gradient(135deg, #C8A476 0%, #B58E61 55%, #967247 100%);
  --gold-soft: rgba(181, 142, 97, 0.13);
  --gold-text: #FFFFFF;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --warning: #D97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --wa: #16A34A;
  --wa-soft: rgba(22, 163, 74, 0.14);
}

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

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Barra superior fija para cubrir la zona de hora/batería en iPhone */
.ios-status-shield {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0px);
  background-color: var(--bg-app);
  z-index: 60;
  pointer-events: none;
}

/* Contenedor App Móvil Responsive con Safe Area iPhone */
.app-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background-color: var(--bg-app);
  position: relative;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  padding-left: 16px;
  padding-right: 16px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
}

@media (min-width: 500px) {
  html, body { background-color: var(--bg-outer); }
  body { padding: 14px 0; }
  .app-shell {
    min-height: calc(100dvh - 28px);
    border-radius: 38px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  }
}

/* Utilidades de color */
.bento-card {
  background: var(--bg-card-grad);
  border: 1px solid var(--border);
  border-radius: 26px;
}
.bento-gold {
  background: var(--bg-gold-card);
  border: 1px solid var(--border-gold);
  border-radius: 26px;
}
.btn-gold {
  background: var(--gold-grad);
  color: var(--gold-text);
}
.text-gold { color: var(--gold-2); }
.text-sub { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.bg-surface { background-color: var(--bg-surface); }
.border-base { border-color: var(--border); }
.tabular { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   SPLASH SCREEN ANIMADO
   ========================================================================== */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at 50% 42%, #171512 0%, #09090B 68%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  cursor: pointer;
}
#splash-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-path {
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
  animation: drawZ 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.splash-fill {
  opacity: 0;
  animation: fillZ 0.55s ease 0.65s forwards;
}
.splash-glow {
  animation: pulseGlow 1.5s ease-in-out infinite;
}
.splash-text {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeUp 0.55s ease 0.75s forwards;
}
@keyframes drawZ { to { stroke-dashoffset: 0; } }
@keyframes fillZ { to { opacity: 1; } }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }
@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(214, 184, 146, 0.28)); }
  50% { filter: drop-shadow(0 0 28px rgba(232, 207, 168, 0.62)); }
}

/* ==========================================================================
   PESTAÑAS Y BARRA INFERIOR FLOTANTE (GLASSMORPHISM + SAFE AREA IPHONE)
   ========================================================================== */
.tab-panel { display: none; animation: panelIn 0.2s ease; }
.tab-panel.active { display: block; }
#tab-cortar.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 130px);
}
@keyframes panelIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.floating-nav-wrap {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 398px;
  z-index: 50;
}
.floating-nav {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 28px;
  height: 66px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 22px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.nav-item svg { width: 21px; height: 21px; stroke-width: 1.9; }
.nav-item.active {
  color: var(--gold-2);
  background: var(--gold-soft);
}

/* ==========================================================================
   CRONÓMETRO CIRCULAR MINIMALISTA GRANDÍSIMO
   ========================================================================== */
.sw-wrap {
  width: min(306px, 82vw);
  height: min(306px, 82vw);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s ease;
}
.sw-wrap:active { transform: scale(0.96); }
.sw-wrap.running::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 9999px;
  background: radial-gradient(circle, rgba(214, 184, 146, 0.2) 0%, transparent 72%);
  animation: swPulse 2s ease-in-out infinite;
}
@keyframes swPulse {
  0%, 100% { transform: scale(0.97); opacity: 0.65; }
  50% { transform: scale(1.06); opacity: 1; }
}

/* Inputs & Modales con Safe Area */
.z-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.z-input:focus { border-color: var(--gold-2); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 80;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
}
.modal-backdrop.open { display: flex; }
.modal-sheet {
  width: 100%;
  max-width: 416px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 20px;
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 24px);
  overflow-y: auto;
  animation: sheetUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes sheetUp { from { transform: translateY(28px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Toast con Safe Area */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
  padding: 10px 18px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: all 0.22s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Print fallback */
#print-report-area { display: none; }
@media print {
  body * { visibility: hidden; }
  #print-report-area, #print-report-area * { visibility: visible; }
  #print-report-area {
    display: block !important;
    position: fixed;
    inset: 0;
    background: #fff;
    color: #111;
    padding: 28px;
  }
}
