:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #66736f;
  --line: #d9e0dd;
  --panel: #ffffff;
  --page: #eef3f1;
  --accent: #0d766e;
  --accent-2: #b84f34;
  --accent-soft: #dcefeb;
  --warn: #a23a25;
  --shadow: 0 18px 45px rgba(25, 43, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.masthead {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
}

.icon-button:hover {
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field {
  display: flex;
  align-items: center;
  height: 46px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
}

.field em {
  flex: 0 0 auto;
  padding-right: 12px;
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
  white-space: nowrap;
}

.validation {
  min-height: 20px;
  margin-top: 14px;
  color: var(--warn);
  font-size: 14px;
}

.results-stack {
  display: grid;
  gap: 16px;
  margin: 14px 0;
}

.result-section {
  display: grid;
  gap: 10px;
}

.result-section h2 {
  color: var(--muted);
  font-size: 14px;
}

.results-grid {
  display: grid;
  gap: 14px;
}

.one-up {
  grid-template-columns: 1fr;
}

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

.three-up {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  min-height: 142px;
  padding: 20px;
}

.metric.primary {
  background: var(--accent);
  color: #fff;
}

.metric span,
.metric p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metric.primary span,
.metric.primary p {
  color: rgba(255, 255, 255, 0.78);
}

.metric strong {
  display: block;
  margin: 12px 0 10px;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.chart-panel {
  padding: 22px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend i {
  width: 20px;
  height: 3px;
  border-radius: 999px;
}

.line-a {
  background: var(--accent);
}

.line-b {
  background: var(--accent-2);
}

#balanceChart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
}

.axis {
  stroke: #b8c4c0;
  stroke-width: 1;
}

.grid-line {
  stroke: #e5ebe8;
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.depletion-marker {
  stroke: var(--accent);
  stroke-dasharray: 7 6;
  stroke-width: 2;
}

.depletion-label-bg {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 1;
}

.depletion-label {
  fill: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.empty-chart {
  fill: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app {
    padding: 18px;
  }

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

  .two-up {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 12px;
  }

  .form-grid,
  .three-up {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .chart-panel,
  .metric {
    padding: 16px;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
