:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1c2526;
  --muted: #697474;
  --line: #dfe5df;
  --accent: #0b6b5f;
  --accent-strong: #064f47;
  --gain: #b42318;
  --loss: #175cd3;
  --warn: #8a5a00;
  --shadow: 0 12px 30px rgba(24, 35, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary,
.segmented button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

button.secondary:hover,
.segmented button:hover,
.segmented button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button.icon {
  width: 38px;
  min-width: 38px;
  padding: 0;
  background: #eef2ee;
  color: var(--muted);
}

button.icon:hover {
  background: #e3ebe5;
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px) 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
}

main {
  display: grid;
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 48px) 40px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

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

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

.metric {
  min-height: 112px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 14px;
  font-size: 24px;
  letter-spacing: 0;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

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

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.segmented button {
  min-width: 64px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: right;
  font-size: 14px;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 24px;
  border-radius: 999px;
  background: #edf7f4;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.gain {
  color: var(--gain);
}

.loss {
  color: var(--loss);
}

.strategy-list {
  display: grid;
  gap: 10px;
}

.strategy-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 70px 72px 38px;
  gap: 8px;
  align-items: center;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(11, 107, 95, 0.14);
}

.strategy-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

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

#ratioTotal.invalid {
  color: var(--warn);
}

#saveStrategyBtn {
  width: 100%;
}

.status-line {
  min-height: 20px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

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

.cash-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.cash-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.cash-item strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  white-space: nowrap;
}

.empty {
  padding: 30px 10px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    width: 100%;
    justify-content: space-between;
  }

  .summary-grid,
  .cash-grid {
    grid-template-columns: 1fr;
  }

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

  .strategy-row {
    grid-template-columns: 1fr 1fr 62px 66px 38px;
  }

  .metric strong {
    font-size: 21px;
  }
}
