.form-field.hidden {
  display: none;
}

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

:root {
  color-scheme: dark;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: #0e1117;
  color: #f5f7fa;
  --surface: rgba(24, 28, 38, 0.92);
  --surface-elevated: rgba(36, 42, 55, 0.9);
  --border: rgba(255, 255, 255, 0.06);
  --text-muted: rgba(245, 247, 250, 0.65);
  --accent: #f1c40f;
  --accent-strong: #ffdd4a;
  --error: #ff6b6b;
  --success: #32d296;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
  /* space reserved at the bottom so content doesn't get overlapped by the fixed bottom nav */
  --bottom-nav-space: 7rem;
}



:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(241, 196, 15, 0.15), transparent 55%),
    radial-gradient(circle at bottom, rgba(241, 196, 15, 0.08), transparent 40%),
    #0e1117;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

body[data-theme="light"],
html[data-theme="light"] body {
  background: radial-gradient(circle at top, rgba(245, 158, 11, 0.15), transparent 55%),
    radial-gradient(circle at bottom, rgba(59, 130, 246, 0.12), transparent 45%),
    #f8fafc;
  color: #1f2937;
  --surface: rgba(255, 255, 255, 0.97);
  --surface-elevated: rgba(245, 247, 255, 0.95);
  --border: rgba(15, 23, 42, 0.12);
  --text-muted: rgba(30, 41, 59, 0.65);
  --accent: #f59e0b;
  --accent-strong: #fbbf24;
  --shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

body[data-theme="light"] input[type="number"],
body[data-theme="light"] input[type="datetime-local"],
body[data-theme="light"] textarea,
body[data-theme="light"] select,
html[data-theme="light"] body input[type="number"],
html[data-theme="light"] body input[type="datetime-local"],
html[data-theme="light"] body textarea,
html[data-theme="light"] body select {
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: inherit;
}

body[data-theme="light"] input[type="number"]:focus,
body[data-theme="light"] input[type="datetime-local"]:focus,
body[data-theme="light"] textarea:focus,
body[data-theme="light"] select:focus,
html[data-theme="light"] body input[type="number"]:focus,
html[data-theme="light"] body input[type="datetime-local"]:focus,
html[data-theme="light"] body textarea:focus,
html[data-theme="light"] body select:focus {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.12);
}

body[data-theme="light"] select,
html[data-theme="light"] body select {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 6 5-6' stroke='%2336475e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

.app-shell {
  width: min(100%, 1080px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* keep a bottom padding that matches the fixed bottom navigation to avoid overlap
     include the safe-area inset for devices with display cutouts (iPhone notch, etc.) */
  padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  padding-bottom: calc(var(--bottom-nav-space) + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
  gap: 1.5rem;
}

.app-header {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.app-header h1 {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.app-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* ensure app content is pushed down on devices with notches / status bars (PWAs) */
.app-content {
  margin-top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
}

.card {
  background: var(--surface);
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.card--highlight {
  border-color: rgba(241, 196, 15, 0.4);
  background: linear-gradient(145deg, rgba(241, 196, 15, 0.1), rgba(255, 255, 255, 0.03));
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.card-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.card-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form {
  display: grid;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.form-field span {
  color: var(--text-muted);
  font-weight: 500;
}

input[type="number"],
input[type="datetime-local"],
select {
  appearance: none;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  transition: border 0.2s ease, background 0.2s ease;
  outline: none;
}

input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus {
  border-color: rgba(241, 196, 15, 0.65);
  background: rgba(241, 196, 15, 0.08);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 6 5-6' stroke='%23f5f7fa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.95rem;
  padding-right: 2.7rem;
}

select::-ms-expand {
  display: none;
}

.form-field textarea {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  min-height: 110px;
  resize: vertical;
  transition: border 0.2s ease, background 0.2s ease;
  outline: none;
}

.form-field textarea:focus {
  border-color: rgba(241, 196, 15, 0.65);
  background: rgba(241, 196, 15, 0.08);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.form-actions .primary-button,
.form-actions .button-secondary {
  width: 100%;
}

.form-actions .button-secondary[hidden] {
  display: none;
}

.form-helper {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.primary-button {
  margin-top: 0.25rem;
  width: 100%;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #141414;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0.95rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(241, 196, 15, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 30px rgba(241, 196, 15, 0.3);
}

.primary-button:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

.primary-button[disabled] {
  opacity: 0.65;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.button-secondary:hover,
.button-secondary:focus-visible {
  background: rgba(241, 196, 15, 0.12);
  color: var(--accent);
  outline: none;
}

.button-secondary[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-danger {
  background: rgba(255, 107, 107, 0.12);
  color: var(--error);
  border: 1px solid rgba(255, 107, 107, 0.35);
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.button-danger:hover,
.button-danger:focus-visible {
  background: rgba(255, 107, 107, 0.24);
  border-color: rgba(255, 107, 107, 0.55);
  color: #fff;
  outline: none;
}

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

.status-error {
  color: var(--error);
}

.status-info {
  color: var(--accent);
}

.form-field input.is-invalid,
.form-field select.is-invalid,
.form-field textarea.is-invalid {
  border-color: rgba(255, 107, 107, 0.85) !important;
  box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.35);
}

body[data-theme="light"] .form-field input.is-invalid,
body[data-theme="light"] .form-field select.is-invalid,
body[data-theme="light"] .form-field textarea.is-invalid,
html[data-theme="light"] body .form-field input.is-invalid,
html[data-theme="light"] body .form-field select.is-invalid,
html[data-theme="light"] body .form-field textarea.is-invalid {
  border-color: rgba(220, 38, 38, 0.65) !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--surface-elevated);
  border-radius: 999px;
  border: 1px solid rgba(241, 196, 15, 0.2);
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 0.35rem;
  width: min(100%, 420px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  margin-bottom: 1rem;
}

.nav-button {
  border: none;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.65rem 0.35rem;
  border-radius: 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.nav-button small {
  font-size: 0.65rem;
  color: var(--text-muted);
}

body.page-resumen .nav-button[data-page="resumen"],
body.page-consumo .nav-button[data-page="consumo"],
body.page-ajustes .nav-button[data-page="ajustes"],
body.page-historial .nav-button[data-page="historial"] {
  background: rgba(241, 196, 15, 0.18);
  color: var(--accent);
  font-weight: 600;
}

body.page-resumen .nav-button[data-page="resumen"] small,
body.page-consumo .nav-button[data-page="consumo"] small,
body.page-ajustes .nav-button[data-page="ajustes"] small,
body.page-historial .nav-button[data-page="historial"] small {
  color: var(--accent);
}

.nav-button:hover,
.nav-button:focus-visible {
  background: rgba(241, 196, 15, 0.1);
  outline: none;
}

.nav-button--primary {
  background: var(--accent);
  color: #141414;
  width: 3.5rem;
  height: 3.5rem;
  justify-self: center;
  border-radius: 50%;
  font-size: 1.6rem;
  box-shadow: 0 16px 32px rgba(241, 196, 15, 0.35);
}

.nav-button--primary:hover,
.nav-button--primary:focus-visible {
  background: var(--accent-strong);
}

.nav-icon {
  width: 1.35rem;
  height: 1.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.nav-icon svg rect,
.nav-icon svg path,
.nav-icon svg polyline,
.nav-icon svg circle {
  fill: currentColor;
  stroke: none;
}

.nav-icon svg polyline {
  stroke: currentColor;
  fill: none;
}

.nav-icon svg .solid-shape {
  fill: currentColor;
  stroke: none;
}

.nav-icon svg .stroke-shape {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

.stat-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stat-card__label {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.stat-card__value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.stat-card__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
}

.stat-card__helper {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

body.theme-high-contrast,
html.theme-high-contrast body {
  background-color: #05070a;
  color: #ffffff;
}

body.theme-high-contrast .card,
html.theme-high-contrast body .card {
  border-color: rgba(241, 196, 15, 0.5);
  background: rgba(10, 12, 18, 0.98);
}

body.theme-high-contrast .card--highlight,
html.theme-high-contrast body .card--highlight {
  background: linear-gradient(160deg, rgba(241, 196, 15, 0.2), rgba(10, 12, 18, 0.95));
}

body.theme-high-contrast .nav-button:hover,
body.theme-high-contrast .nav-button:focus-visible,
html.theme-high-contrast body .nav-button:hover,
html.theme-high-contrast body .nav-button:focus-visible {
  background: rgba(241, 196, 15, 0.18);
}

body.theme-high-contrast .primary-button,
html.theme-high-contrast body .primary-button {
  box-shadow: 0 20px 36px rgba(241, 196, 15, 0.45);
}

@media (max-width: 480px) {
  .app-shell {
    padding: 1.25rem 0.85rem calc(var(--bottom-nav-space) + env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding: 1.35rem 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .nav-button {
    padding: 0.55rem 0.35rem;
    font-size: 0.75rem;
  }

  .nav-button small {
    font-size: 0.6rem;
  }

  .nav-button--primary {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 1.45rem;
  }

  /* keep the bottom navigation inset from the viewport edges on small screens
     so it visually aligns with the app content padding */
  .bottom-nav {
    left: 0.85rem;
    right: 0.85rem;
    transform: none;
    width: calc(100% - 1.7rem);
  }

  /* hide native scrollbars on small screens but keep scrolling functional
     - Firefox: scrollbar-width
     - IE/Edge: -ms-overflow-style
     - WebKit (Safari/Chrome on mobile): ::-webkit-scrollbar
     This only hides the visual chrome, it does NOT disable scrolling. */
  html, body, .app-shell {
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
  }

  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  .app-shell::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
  }
}

@media (max-width: 360px) {
  .nav-button {
    gap: 0.15rem;
  }

  .nav-button small {
    font-size: 0.55rem;
  }

  /* ensure the nav has the same side spacing as the app shell padding */
  .bottom-nav {
    left: 0.85rem;
    right: 0.85rem;
    transform: none;
    width: calc(100% - 1.7rem);
    padding: 0.45rem;
    gap: 0.25rem;
  }
}

@media (min-width: 640px) {
  .app-shell {
    padding: 2rem 2.25rem calc(var(--bottom-nav-space) + env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding: 1.75rem 1.6rem;
  }

  .form {
    gap: 1.35rem;
  }

  .form-field:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 960px) {
  body {
    align-items: center;
  }

  .app-content {
    flex-direction: row;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .card {
    flex: 1 1 320px;
  }
}

