:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #182033;
  --muted: #667085;
  --line: #dbe3ef;
  --fixed: #2f66f6;
  --variable: #d9474f;
  --safe: #17a673;
  --remain: #cbd5e1;
  --over: #e5484d;
  --shadow: 0 16px 42px rgba(24, 32, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app {
  width: min(1140px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
}

.page-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.tab-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab-btn.active {
  color: #ffffff;
  background: var(--text);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 22px;
  align-items: stretch;
}

.hero-copy,
.budget-card,
.overview-panel,
.expense-box,
.summary-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 34px;
  color: #ffffff;
  background: linear-gradient(135deg, #172033, #24515f 58%, #168766);
}

.eyebrow {
  display: block;
  margin: 0 0 8px;
  color: #6d7c90;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy .eyebrow {
  color: #bce9dc;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: 44px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.subtitle {
  max-width: 620px;
  margin-bottom: 0;
  color: #e5edf5;
}

.budget-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 26px;
}

.card-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.budget-input-wrap {
  display: flex;
  align-items: center;
  height: 62px;
  padding: 0 18px;
  border: 1px solid #c7d3e3;
  border-radius: 8px;
  background: var(--panel-soft);
}

.budget-input-wrap:focus-within {
  border-color: var(--fixed);
  box-shadow: 0 0 0 4px rgba(47, 102, 246, 0.12);
}

.budget-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 26px;
  font-weight: 800;
}

.budget-input-wrap span {
  color: var(--muted);
  font-weight: 800;
}

.big-number {
  color: var(--text);
  font-size: 30px;
  line-height: 1.15;
}

.overview-panel {
  margin-top: 22px;
  padding: 26px;
}

.overview-heading,
.panel-header,
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.status-pill {
  padding: 9px 13px;
  border-radius: 999px;
  color: #475467;
  background: #eef2f7;
  font-size: 14px;
}

.overview-content {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 28px;
  align-items: center;
  margin-top: 24px;
}

.pie-chart {
  position: relative;
  width: 220px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--remain) 0deg 360deg);
  box-shadow: inset 0 0 0 18px #ffffff, 0 12px 28px rgba(24, 32, 51, 0.14);
  overflow: hidden;
}

.pie-label {
  position: absolute;
  max-width: 62px;
  padding: 3px 5px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(24, 32, 51, 0.68);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.warning-icon {
  display: none;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--over);
  font-size: 12px;
  font-style: normal;
  line-height: 18px;
  text-align: center;
}

.warning-icon.active {
  display: inline-block;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 700;
}

.legend b {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.legend i {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.fixed-dot {
  background: var(--fixed);
}

.variable-dot {
  background: var(--variable);
}

.remain-dot {
  background: var(--remain);
}

.over-dot {
  background: var(--over);
}

.message {
  min-height: 24px;
  margin: 16px 0 0;
  color: var(--over);
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  margin-top: 14px;
}

.expense-column {
  display: grid;
  gap: 22px;
}

.expense-box,
.summary-panel {
  padding: 24px;
}

.summary-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(24, 32, 51, 0.06);
}

.summary-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 22px;
}

.section-header p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.fixed-badge {
  color: var(--fixed);
  background: rgba(47, 102, 246, 0.1);
}

.variable-badge {
  color: var(--variable);
  background: rgba(217, 71, 79, 0.1);
}

.expense-list {
  display: grid;
  gap: 10px;
  min-height: 70px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.expense-list:empty::before {
  content: "아직 추가된 지출이 없습니다.";
  display: block;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
  text-align: center;
}

.expense-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.expense-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.expense-amount {
  color: var(--muted);
  font-weight: 700;
}

.delete-btn {
  padding: 8px 10px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--over);
  font-size: 13px;
  font-weight: 800;
}

.edit-btn {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  background: #eef2f7;
  font-size: 13px;
  font-weight: 800;
}

.add-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.add-title {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.add-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 76px;
  gap: 10px;
  align-items: end;
}

.add-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.add-grid label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.add-grid input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  outline: 0;
  background: #ffffff;
}

.add-grid input:focus {
  border-color: var(--fixed);
  box-shadow: 0 0 0 3px rgba(47, 102, 246, 0.12);
}

.add-grid button {
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--text);
  font-weight: 800;
}

.ghost-btn {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font-weight: 800;
}

.danger-btn {
  border-color: var(--over);
  color: #ffffff;
  background: var(--over);
}

.danger-btn:hover {
  background: #cf3035;
}

.summary-table {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.summary-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 56px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-row span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.summary-row strong {
  font-size: 18px;
}

.total-row {
  background: #f6f8fb;
}

.remain-row {
  background: #eefaf5;
}

.insight-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.insight-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.insight-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.insight-card em {
  margin-left: 8px;
  color: #8a96a8;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.insight-card strong {
  font-size: 21px;
}

.insight-card p,
.mini-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.danger {
  color: var(--over);
}

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

.warning {
  color: #b7791f;
}

.asset-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 22px;
}

.asset-layout {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 22px;
}

.asset-forms {
  display: grid;
  gap: 22px;
  order: -1;
}

.asset-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.asset-input-grid label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.asset-input-grid label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.label-hint {
  color: #a7b0bf;
  font-size: 12px;
  font-weight: 700;
}

.asset-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  outline: 0;
  background: #ffffff;
}

.asset-input:focus {
  border-color: var(--fixed);
  box-shadow: 0 0 0 3px rgba(47, 102, 246, 0.12);
}

.import-btn {
  margin-top: 14px;
}

.drawer-open-btn {
  margin-top: 16px;
}

.asset-memo {
  width: 100%;
  min-height: 112px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  outline: 0;
  resize: vertical;
  background: #ffffff;
  color: var(--text);
}

.asset-memo:focus {
  border-color: var(--fixed);
  box-shadow: 0 0 0 3px rgba(47, 102, 246, 0.12);
}

.asset-ratio-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.ratio-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.ratio-heading strong {
  color: var(--text);
}

.ratio-bar {
  display: flex;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--remain);
}

.safe-ratio {
  width: 0%;
  background: #2f8fb3;
}

.risk-ratio {
  width: 0%;
  background: var(--variable);
}

.asset-chart-box {
  display: grid;
  gap: 20px;
  justify-items: center;
  margin-top: 22px;
}

.asset-legend {
  width: 100%;
  grid-template-columns: 1fr;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: rgba(24, 32, 51, 0);
  transition: background 0.22s ease;
}

.drawer-overlay.open {
  pointer-events: auto;
  background: rgba(24, 32, 51, 0.32);
}

.record-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  height: 100vh;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: #ffffff;
  box-shadow: -18px 0 42px rgba(24, 32, 51, 0.16);
  transform: translateX(105%);
  transition: transform 0.24s ease;
}

.record-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.record-save-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.record-save-box label {
  display: grid;
  gap: 7px;
}

.record-save-box label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.record-save-box input {
  height: 42px;
  padding: 0 12px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
}

.record-save-box button {
  height: 42px;
  padding: 0 13px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--text);
  font-weight: 800;
}

.record-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  overflow-y: auto;
  padding-right: 4px;
}

.record-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.record-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.record-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.record-mini-grid span {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.record-mini-grid strong {
  color: var(--text);
  font-size: 14px;
}

.record-actions {
  display: flex;
  gap: 8px;
}

.record-actions button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 800;
}

.detail-btn {
  color: #ffffff;
  background: var(--text);
}

.record-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 22px;
}

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

.trend-panel {
  margin-top: 22px;
}

.trend-chart {
  min-height: 320px;
  margin-top: 22px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.trend-svg {
  display: block;
  width: 100%;
  height: 300px;
}

.trend-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 5;
}

.trend-expense {
  stroke: var(--variable);
}

.trend-income {
  stroke: var(--fixed);
}

.trend-surplus {
  stroke: var(--safe);
}

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

.trend-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.trend-point {
  stroke: #ffffff;
  stroke-width: 3;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.trend-legend i {
  width: 18px;
  height: 5px;
  border-radius: 999px;
}

.trend-legend .expense-trend {
  background: var(--variable);
}

.trend-legend .asset-trend {
  background: var(--fixed);
}

.trend-legend .surplus-trend {
  background: var(--safe);
}

.trend-empty {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 920px) {
  .hero,
  .workspace,
  .overview-content,
  .asset-layout,
  .record-detail-grid {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    justify-self: center;
  }

  .asset-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  .app {
    width: min(100% - 20px, 1140px);
    padding: 20px 0;
  }

  .hero-copy,
  .budget-card,
  .overview-panel,
  .expense-box,
  .summary-panel {
    padding: 20px;
  }

  h1 {
    font-size: 34px;
  }

  .overview-heading,
  .panel-header,
  .section-header,
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .legend,
  .add-grid,
  .expense-item,
  .summary-row,
  .asset-input-grid,
  .asset-summary-grid,
  .record-save-box,
  .record-mini-grid {
    grid-template-columns: 1fr;
  }

  .expense-amount {
    justify-self: start;
  }

  .pie-label {
    display: none;
  }
}

