:root {
  color-scheme: dark;
  --page-bg: #0f172a;
  --surface-bg: #1e293b;
  --surface-border: rgba(148, 163, 184, 0.2);
  --surface-shadow: rgba(15, 23, 42, 0.55);
  --text-body: #cbd5f5;
  --text-muted: #94a3b8;
  --text-bright: #fbbf24;
  --positive: #38bdf8;
  --negative: #f87171;
  --panel-income: linear-gradient(160deg, rgba(16, 185, 129, 0.55), rgba(15, 118, 110, 0.4));
  --panel-assets: linear-gradient(160deg, rgba(59, 130, 246, 0.55), rgba(37, 99, 235, 0.4));
  --panel-liabilities: linear-gradient(160deg, rgba(99, 102, 241, 0.55), rgba(79, 70, 229, 0.4));
  --panel-expenses: linear-gradient(160deg, rgba(244, 63, 94, 0.55), rgba(225, 29, 72, 0.4));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.page-body {
  margin: 0;
  min-height: 100vh;
  height: 100vh;
  background: var(--page-bg);
  color: var(--text-body);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.4;
  padding: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: hidden;
}

body.page-body::selection {
  background: rgba(251, 191, 36, 0.35);
  color: #fff;
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(15, 23, 42, 0.5);
  overflow: hidden;
  z-index: 50;
  display: none;
  transition: opacity 0.3s ease;
}

.loading-bar[data-hidden="true"] {
  opacity: 0;
  pointer-events: none;
}

.loading-bar__progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
  transition: width 0.2s ease-out;
}

.dashboard {
  width: min(100%, 1400px);
  height: 100%;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  box-shadow: 0 12px 24px var(--surface-shadow);
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  overflow: hidden;
}

.slider-column {
  width: 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.slider-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  transform: rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.year-slider {
  writing-mode: vertical-rl;
  direction: ltr;
  width: 16px;
  flex: 1;
  margin-block: 0.5rem;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.year-slider:focus {
  outline: none;
}

.year-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fbbf24;
  border: 2px solid rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.25);
  transition: transform 0.2s ease;
}

.year-slider::-webkit-slider-thumb:active {
  transform: scale(1.05);
}

.year-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fbbf24;
  border: 2px solid rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.25);
  transition: transform 0.2s ease;
}

.year-slider::-moz-range-thumb:active {
  transform: scale(1.05);
}

.year-slider::-webkit-slider-runnable-track {
  width: 100%;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.year-slider::-moz-range-track {
  width: 100%;
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}

.content-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.year-header {
  text-align: center;
}

.year-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.row-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  flex: 1 1 0%;
  min-height: 0;
  transition: flex 0.35s ease, max-height 0.35s ease;
}

.row-group section {
  transition: max-height 0.35s ease;
}

.row-group[data-expanded="true"] {
  flex: 0 0 auto;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.panel {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  padding: 0.9rem;
  min-height: 140px;
  display: flex;
  border: 4px solid rgba(15, 23, 42, 0.85);
  box-shadow: 0 16px 26px rgba(15, 23, 42, 0.45);
}

.panel-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      to right,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px
    );
  background-size: 1.4rem 1.4rem;
  opacity: 0.35;
  pointer-events: none;
}

.panel[data-quadrant="income"] {
  background: var(--panel-income);
}

.panel[data-quadrant="assets"] {
  background: var(--panel-assets);
}

.panel[data-quadrant="liabilities"] {
  background: var(--panel-liabilities);
}

.panel[data-quadrant="expenses"] {
  background: var(--panel-expenses);
}

.panel-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.panel-title {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: #fff;
}

.panel-total {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
}

.panel-entries {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.3rem 1.4rem 1.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.4rem;
  align-content: start;
  border-radius: 20px;
  border: 3px solid rgba(15, 23, 42, 0.8);
  background-color: rgba(148, 178, 208, 0.28);
  background-image: radial-gradient(
      rgba(15, 23, 42, 0.85) 20%,
      transparent 22%
    ),
    radial-gradient(rgba(15, 23, 42, 0.35) 20%, transparent 22%);
  background-size: 36px 36px;
  background-position: 0 0, 18px 18px;
  box-shadow: inset 0 10px 24px rgba(15, 23, 42, 0.4);
}

.panel-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: rgba(226, 232, 240, 0.75);
  font-size: 0.75rem;
  min-height: 3rem;
  padding: 0.5rem;
}

.row-toggle {
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: var(--text-body);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  gap: 0.3rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.row-toggle:hover,
.row-toggle:focus-visible {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(148, 163, 184, 0.6);
  color: #fff;
  outline: none;
}

.row-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.row-group[data-expanded="true"] .row-toggle-icon {
  transform: rotate(180deg);
}

.row-group[data-expanded="false"] .panel-entries {
  max-height: min(16rem, 50vh);
  overflow-y: auto;
}

.row-group[data-expanded="true"] .panel-entries {
  max-height: none;
  overflow: visible;
}

.row-group[data-expanded="true"] .panel {
  overflow: visible;
}



.battleship-container {
  position: relative;
  min-height: 0;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 3px solid rgba(15, 23, 42, 0.78);
  background: linear-gradient(165deg, rgba(37, 54, 81, 0.92), rgba(15, 23, 42, 0.92));
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.35), 0 12px 22px rgba(15, 23, 42, 0.55);
  display: grid;
  grid-template-columns: minmax(160px, 0.95fr) minmax(200px, 1fr);
  gap: 1rem;
  align-items: center;
  isolation: isolate;
  --hull-width: 260px;
  --hull-height: 80px;
  --peg-scale: 1;
}

.battleship-container::before {
  content: "";
  position: absolute;
  inset: 0.55rem;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  pointer-events: none;
  opacity: 0.75;
}

.battleship-container.ship-patrol {
  --hull-width: 200px;
  --hull-height: 64px;
  --peg-scale: 0.85;
}

.battleship-container.ship-submarine {
  --hull-width: 230px;
  --hull-height: 70px;
  --peg-scale: 0.9;
}

.battleship-container.ship-destroyer {
  --hull-width: 260px;
  --hull-height: 80px;
  --peg-scale: 1;
}

.battleship-container.ship-battleship {
  --hull-width: 300px;
  --hull-height: 90px;
  --peg-scale: 1.05;
}

.battleship-container.ship-carrier {
  --hull-width: 330px;
  --hull-height: 96px;
  --peg-scale: 1.1;
}

.battleship-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  z-index: 2;
}

.battleship-label-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.battleship-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e2e8f0;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(30, 41, 59, 0.55);
}

.entry-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #f8fafc;
  max-width: 220px;
  line-height: 1.25;
}

.info-icon {
  width: 14px;
  height: 14px;
  color: rgba(148, 163, 184, 0.75);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.battleship-container:hover .info-icon,
.battleship-container:focus-within .info-icon {
  color: #fbbf24;
}

.entry-value-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: #fde68a;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.entry-card {
  position: relative;
  width: min(100%, var(--hull-width));
  height: var(--hull-height);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.entry-card svg.battleship-hull {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.6));
}

.entry-card::after {
  content: "";
  position: absolute;
  inset: 18% 16%;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: inset 0 0 18px rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.entry-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, -6px);
  padding: 0.45rem 0.6rem;
  background: rgba(15, 23, 42, 0.97);
  color: #fff;
  border-radius: 6px;
  font-size: 0.68rem;
  width: max-content;
  max-width: 220px;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
}

.battleship-container:hover .entry-tooltip,
.battleship-container:focus-within .entry-tooltip {
  opacity: 1;
}

.entry-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.97) transparent transparent transparent;
}

.entry-tooltip-title {
  margin: 0 0 0.2rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  padding-bottom: 0.2rem;
}

.entry-tooltip-value {
  margin: 0;
  font-weight: 600;
}

.entry-tooltip-value span {
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

.entry-pin-wrapper {
  position: absolute;
  inset: 24% 14%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(var(--pin-grid-columns, 4), minmax(0, 1fr));
  grid-template-rows: repeat(var(--pin-grid-rows, 2), minmax(0, 1fr));
  gap: calc(0.18rem * var(--peg-scale, 1));
  width: 100%;
  height: 100%;
  align-content: center;
  justify-items: center;
  pointer-events: auto;
}

.pin-cell {
  width: calc(0.34rem * var(--peg-scale, 1));
  height: calc(0.34rem * var(--peg-scale, 1));
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
}

.pin-dot {
  width: 65%;
  height: 65%;
  border-radius: 999px;
}

.pin-dot.pin-ten.positive {
  background: #f8fafc;
  box-shadow: 0 0 0 1px rgba(226, 232, 240, 0.6);
}

.pin-dot.pin-ten.negative {
  background: rgba(239, 68, 68, 0.9);
  box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.7);
}

.pin-dot.pin-hundred.positive {
  background: rgba(34, 197, 94, 0.95);
  box-shadow: 0 0 0 1px rgba(21, 128, 61, 0.7);
}

.pin-dot.pin-hundred.negative {
  background: rgba(185, 28, 28, 0.9);
  box-shadow: 0 0 0 1px rgba(153, 27, 27, 0.75);
}

.pin-more {
  font-size: 0.6rem;
  color: rgba(226, 232, 240, 0.85);
  align-self: center;
}


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.animate-fade-in {
  animation: fadeIn 0.45s ease-out both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .dashboard {
    flex-direction: column;
    align-items: stretch;
  }

  .slider-column {
    flex-direction: row;
    justify-content: center;
    width: 100%;
    height: auto;
  }

  .panel-entries {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .battleship-container {
    grid-template-columns: 1fr;
    text-align: center;
    --hull-width: min(280px, 90vw);
  }

  .battleship-info {
    align-items: center;
  }
}

@media (max-width: 720px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 0;
  }
}

@media (min-width: 721px) {
  .panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
