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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark-base);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
}

/* App Container Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.app-body {
  display: flex;
  flex: 1;
  width: 100%;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  overflow-x: hidden;
}

.app-main {
  flex: 1;
  min-width: 0; /* Permite a los contenedores hijos colapsar y adaptarse sin desbordar */
  padding: 20px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  transition: padding var(--transition-normal);
}

/* Typography Headings */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; line-height: 1.25; }
h2 { font-size: 1.35rem; line-height: 1.3; }
h3 { font-size: 1.15rem; line-height: 1.35; }
h4 { font-size: 1rem; line-height: 1.4; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-family: var(--font-family-body);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
  box-shadow: none;
}

.btn-primary:hover {
  background: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline-danger {
  background: transparent;
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-outline-danger:hover {
  background: var(--color-danger-bg);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Inputs & Form Control */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-family-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Fix para la legibilidad de menús desplegables (dropdown options en Windows/Chrome) */
select,
.select-control,
.form-select {
  background-color: var(--bg-input, #0f172a);
  color: var(--text-primary, #f8fafc);
}

select option,
.select-control option,
.form-select option,
optgroup {
  background-color: #1e293b !important;
  color: #f8fafc !important;
  padding: 6px 10px;
}

select option:disabled,
.select-control option:disabled,
.form-select option:disabled,
option:disabled,
option[disabled],
.select-option-disabled {
  color: #64748b !important;
  background-color: #0f172a !important;
  font-style: italic !important;
  opacity: 0.55 !important;
}


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

::-webkit-scrollbar-track {
  background: var(--bg-dark-base);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Utility Helpers */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }

/* Glassmorphism Panel */
.glass-panel {
  background: var(--bg-dark-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

/* Responsive Rules */
@media (max-width: 900px) {
  .app-main {
    padding: 14px 10px calc(70px + var(--safe-area-bottom) + 36px) 10px;
  }
}

@media (orientation: landscape) and (max-height: 550px) {
  .app-body {
    margin-top: 48px !important;
    min-height: calc(100vh - 48px) !important;
  }
  .app-main {
    padding: 10px 14px calc(50px + var(--safe-area-bottom)) 14px !important;
  }
}

/* SVG Chart Hover & Focus Styling */
circle[data-tooltip-title],
circle[data-tooltip-val],
rect[data-tooltip-title],
rect[data-tooltip-val] {
  transition: transform 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
  transform-origin: center center;
}

circle[data-tooltip-title]:hover,
circle[data-tooltip-val]:hover {
  r: 7.5;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.6));
}

rect[data-tooltip-title]:hover,
rect[data-tooltip-val]:hover {
  filter: brightness(1.3) drop-shadow(0 0 6px rgba(96, 165, 250, 0.5));
}
