:root {
  --bg-primary: #121212;
  --bg-card: #1e1e1e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --text-muted: #6b7280;
  --accent-green: #10b981;
  --accent-green-alpha: rgba(16, 185, 129, 0.1);
  --accent-orange: #f97316;
  --accent-orange-alpha: rgba(249, 115, 22, 0.1);
  --progress-track: #2d2d2d;
  --border-radius-lg: 16px;
  --border-radius-sm: 8px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 20px;
  --spacing-lg: 28px;
  --spacing-xl: 40px;
  --transition-smooth: all 0.25s ease;
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
  --nav-control-height: 46px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-width: 320px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--spacing-lg) var(--spacing-xl);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid #2a2a2a;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.logo-icon {
  color: var(--accent-green);
}

.header-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.tools-menu,
.header-search {
  position: relative;
}

.tools-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 126px;
  height: var(--nav-control-height);
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  padding: 0 14px;
}

.tools-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  background-color: var(--accent-green);
  mask: url("circle-arrow-down.svg") center / contain no-repeat;
  -webkit-mask: url("circle-arrow-down.svg") center / contain no-repeat;
  color: var(--accent-green);
}

.tools-dropdown,
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 360px;
  overflow: hidden;
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  background: #1a1a1a;
  box-shadow: var(--shadow-md);
}

.tools-dropdown button,
.search-result {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  padding: 12px;
  text-align: left;
  white-space: nowrap;
}

.tools-dropdown button:hover,
.search-result:hover {
  background: rgba(255, 255, 255, 0.04);
}

.header-search {
  width: min(420px, 38vw);
}

.header-search input {
  width: 100%;
  height: var(--nav-control-height);
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  background: #171717;
  color: var(--text-primary);
  padding: 10px 12px;
}

.search-results {
  width: 100%;
}

.tools-dropdown {
  width: 360px;
}

.search-result span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

.compound-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--spacing-md);
}

.compound-form label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.compound-form input,
.compound-form select {
  width: 100%;
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  background: #171717;
  color: var(--text-primary);
  padding: 10px 12px;
  text-transform: none;
}

.compound-form button {
  align-self: end;
}

.compound-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: var(--spacing-lg);
  align-items: center;
  padding-top: var(--spacing-lg);
  border-top: 1px solid #2d2d2d;
}

.compound-results strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3rem);
}

.compound-results p {
  color: var(--text-secondary);
}

.compound-breakdown {
  display: grid;
  gap: 8px;
  margin-top: var(--spacing-md);
}

.compound-breakdown span {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
}

.compound-breakdown strong {
  display: inline;
  font-size: 1rem;
  color: var(--text-primary);
}

.compound-donut {
  height: 220px;
}

.compound-chart {
  height: 280px;
}

.if-form {
  display: grid;
  gap: var(--spacing-md);
}

.if-form label {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 90px;
  gap: var(--spacing-md);
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.if-form input[type="range"] {
  accent-color: var(--accent-green);
}

.if-form strong {
  color: var(--accent-green);
  font-size: 1rem;
  text-align: right;
}

.if-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--spacing-sm);
}

.if-chart {
  height: 300px;
}

.if-reached {
  background: rgba(16, 185, 129, 0.08);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  height: var(--nav-control-height);
  background-color: #2d2d2d;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--spacing-lg);
}

.dashboard-col {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.card {
  --theme-accent: var(--accent-green);
  --theme-accent-alpha: var(--accent-green-alpha);
  --theme-accent-alpha-hover: rgba(16, 185, 129, 0.2);
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-card);
  border: 1px solid #262626;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-lg);
  transition: var(--transition-smooth);
}

.card.orange-theme {
  --theme-accent: var(--accent-orange);
  --theme-accent-alpha: var(--accent-orange-alpha);
  --theme-accent-alpha-hover: rgba(249, 115, 22, 0.2);
}

.card:hover {
  border-color: #3a3a3a;
}

.secondary-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  transition: var(--transition-smooth);
}

.btn-primary {
  background-color: var(--theme-accent-alpha);
  color: var(--theme-accent);
}

.btn-primary:hover {
  border-color: var(--theme-accent);
  background-color: var(--theme-accent-alpha-hover);
}

.floating-add-stock-btn {
  position: fixed;
  right: 64px;
  bottom: 42px;
  z-index: 20;
  border: 1px solid rgba(249, 115, 22, 0.45);
  border-radius: var(--border-radius-sm);
  background: rgba(249, 115, 22, 0.16);
  color: var(--accent-orange);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transition: var(--transition-smooth);
}

.floating-add-stock-btn:hover {
  background: rgba(249, 115, 22, 0.24);
  border-color: var(--accent-orange);
}

.btn-secondary,
.btn-toggle-view,
.chart-filter-btn {
  background: transparent;
  border: 1px solid #2d2d2d;
  color: var(--text-secondary);
}

.btn-secondary:hover,
.btn-toggle-view:hover,
.chart-filter-btn:hover {
  border-color: #555;
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.02);
}

.goal-widget-header,
.widget-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.goal-widget-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.goal-widget-title h2,
.widget-header-row h2 {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
}

.goal-widget-action {
  border: 1px solid var(--theme-accent);
  background: transparent;
  color: var(--theme-accent);
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 4px 10px;
  transition: none;
}

.goal-widget-action:hover {
  background: transparent;
}

.goal-values {
  margin-bottom: var(--spacing-md);
}

.current-value-label {
  font-size: clamp(1.9rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
}

.target-value-label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

.target-value-label span {
  color: var(--text-primary);
  font-weight: 600;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.progress-track-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  background-color: var(--progress-track);
  border-radius: 4px;
}

.progress-fill-bar {
  width: 0%;
  height: 100%;
  background-color: var(--theme-accent);
  border-radius: 4px;
  transition: width 0.8s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
}

.progress-percentage {
  color: var(--theme-accent);
  font-weight: 600;
}

.loading {
  opacity: 0.7;
}

#widget-goal-valor-mercado,
#widget-goal-dividendos {
  min-height: 235px;
}

#widget-historial-valor,
#widget-historial-dividendos {
  height: 380px;
}

#widget-valor-acciones,
#widget-dividendos-acciones {
  height: auto;
  min-height: 605px;
}

#widget-geografia,
#widget-distribucion-cartera {
  height: 540px;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--spacing-xs);
}

.chart-filter-btn {
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 6px 12px;
  transition: var(--transition-smooth);
}

.chart-filter-btn.active {
  border-color: var(--theme-accent);
  background-color: var(--theme-accent-alpha);
  color: var(--theme-accent);
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 250px;
  flex: 1;
}

#widget-historial-dividendos .chart-wrapper {
  height: 190px;
  min-height: 0;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  margin-bottom: var(--spacing-md);
  flex: 1;
}

.positions-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.825rem;
}

.positions-table th {
  padding: 12px 8px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #2d2d2d;
}

.positions-table td {
  height: 78px;
  padding: 12px 8px;
  border-bottom: 1px solid #2d2d2d;
  white-space: nowrap;
}

.positions-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.ticker-col {
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  font-weight: 700;
}

.stock-link {
  color: var(--text-primary);
  text-decoration: none;
}

.stock-link:hover {
  color: var(--theme-accent);
}

.ticker-name {
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 400;
}

.text-right {
  text-align: right;
}

.trend-up {
  color: #10b981;
}

.trend-down {
  color: #ef4444;
}

.toggle-expansion-wrapper {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-toggle-view {
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 24px;
  transition: var(--transition-smooth);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: var(--spacing-md);
}

.stat-box {
  min-width: 0;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  padding: 8px 4px;
  text-align: center;
}

.stat-box-title {
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-box-value {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-box-value.highlight {
  color: var(--theme-accent);
}

.mini-chart-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  height: 28px;
}

.mini-chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mini-chart-bar {
  width: 8px;
  min-height: 0;
  background-color: var(--theme-accent);
  border-radius: 2px 2px 0 0;
}

.mini-chart-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
}

.dividend-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-bottom: var(--spacing-md);
}

.dividend-list-header {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 12px 0;
  border-bottom: 1px solid #2d2d2d;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dividend-list-header span:first-child {
  width: 40%;
}

.dividend-list-header span:nth-child(2),
.dividend-list-header span:last-child {
  width: 30%;
}

.dividend-list-header span:nth-child(2) {
  text-align: center;
}

.dividend-list-header span:last-child {
  text-align: right;
}

.dividend-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  min-height: 78px;
  padding: 12px 0;
  border-bottom: 1px solid #2d2d2d;
}

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

.dividend-item-left,
.dividend-item-right {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dividend-item-left {
  width: 40%;
}

.dividend-item-center,
.dividend-item-right {
  width: 30%;
}

.dividend-item-center {
  display: flex;
  justify-content: center;
}

.dividend-item-right {
  align-items: flex-end;
}

.dividend-amount {
  color: var(--theme-accent);
  font-size: 0.9rem;
  font-weight: 600;
}

.dividend-yields-sub {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.map-container {
  position: relative;
  width: 100%;
  height: 310px;
  margin-bottom: var(--spacing-md);
  overflow: hidden;
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  background-color: #121212;
}

#world-map-container,
.leaflet-container {
  width: 100%;
  height: 100%;
  background: #121212 !important;
  outline: 0;
}

.leaflet-popup-content-wrapper {
  background: #1e1e1e !important;
  color: var(--text-primary) !important;
  border: 1px solid #2d2d2d !important;
  border-radius: var(--border-radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
  font-family: "Inter", sans-serif !important;
}

.leaflet-popup-tip {
  background: #1e1e1e !important;
}

.map-legend {
  display: flex;
  width: 100%;
  flex-direction: column;
  margin-top: auto;
}

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #2d2d2d;
  font-size: 0.8rem;
  padding: 6px 0;
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.legend-color-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-percent {
  display: inline-block;
  width: 46px;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
}

.donut-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 240px;
  flex: 1;
}

.distribution-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(180px, 1fr);
  gap: var(--spacing-lg);
  align-items: center;
  flex: 1;
}

.distribution-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.distribution-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 10px 0;
  border-bottom: 1px solid #2d2d2d;
  font-size: 0.85rem;
}

.distribution-item span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 600;
}

.distribution-item i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.distribution-item strong {
  color: var(--text-secondary);
}

.distribution-list .btn-toggle-view {
  align-self: flex-end;
  margin-top: var(--spacing-md);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md);
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  transition: var(--transition-smooth);
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background-color: var(--bg-card);
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid #2d2d2d;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.form-group input,
.form-group select {
  background-color: #121212;
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  transition: var(--transition-smooth);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 2px var(--theme-accent-alpha);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.detail-page {
  max-width: 1180px;
}

.back-link {
  display: inline-flex;
  margin-bottom: var(--spacing-md);
  color: var(--text-secondary);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent-orange);
}

.detail-card {
  gap: var(--spacing-lg);
}

.detail-loading {
  color: var(--text-secondary);
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid #2d2d2d;
}

.detail-company {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.detail-company img,
.detail-logo-fallback {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #ffffff;
  object-fit: contain;
  padding: 10px;
}

.detail-logo-fallback {
  display: grid;
  place-items: center;
  background: var(--accent-orange-alpha);
  color: var(--accent-orange);
  font-weight: 800;
  padding: 0;
}

.detail-company span {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.detail-company h1 {
  margin: 2px 0 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.detail-price {
  text-align: right;
}

.detail-price strong {
  display: block;
  font-size: 2rem;
}

.detail-price span {
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--spacing-sm);
}

.detail-chart {
  padding-bottom: var(--spacing-lg);
  border-bottom: 1px solid #2d2d2d;
}

.detail-chart .chart-wrapper {
  height: 230px;
}

.detail-metric {
  min-width: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid #2d2d2d;
  border-radius: var(--border-radius-sm);
}

.detail-metric span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.detail-estimate {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--accent-orange-alpha);
  color: var(--accent-orange);
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: middle;
}

.dividend-date-card small {
  display: block;
  margin-top: 8px;
  color: var(--text-secondary);
  font-weight: 700;
}

.detail-section {
  padding-top: var(--spacing-md);
  border-top: 1px solid #2d2d2d;
}

.detail-section h2 {
  margin-bottom: var(--spacing-sm);
  font-size: 1.1rem;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-md);
}

.detail-tags span {
  padding: 6px 10px;
  background: var(--accent-orange-alpha);
  border-radius: var(--border-radius-sm);
  color: var(--accent-orange);
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-section p {
  color: var(--text-secondary);
  line-height: 1.7;
}

@media (max-width: 900px) {
  .app-container {
    padding: var(--spacing-md);
  }

  .app-header {
    flex-wrap: wrap;
  }

  .header-search {
    order: 3;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .compound-form,
  .compound-results,
  .if-kpis {
    grid-template-columns: 1fr;
  }

  .if-form label {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .if-form strong {
    text-align: left;
  }

  .dashboard-col {
    gap: var(--spacing-md);
  }

  .distribution-layout {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .floating-add-stock-btn {
    right: 16px;
    bottom: 16px;
    padding: 10px 14px;
  }

  .app-header,
  .goal-widget-header,
  .widget-header-row,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-price {
    text-align: left;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dividend-list-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .dividend-list-header {
    display: none;
  }

  .dividend-item-left,
  .dividend-item-center,
  .dividend-item-right {
    width: 100%;
    align-items: flex-start;
    justify-content: flex-start;
  }
}
