:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #182230;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --soft: #e8f5f3;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

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

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 18px;
  line-height: 1.35;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.text-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

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

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

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.text-button {
  background: transparent;
  color: var(--accent);
  padding: 0;
}

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

.summary-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-card {
  border-radius: 8px;
  padding: 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.panel {
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 4px;
}

.panel-header.compact {
  display: block;
  padding-bottom: 14px;
}

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

.pricing-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.pricing-table th,
.pricing-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #edf1f6;
  padding: 8px;
  vertical-align: middle;
  white-space: nowrap;
}

.pricing-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #344054;
  font-size: 12px;
  text-align: left;
}

.pricing-table td {
  font-size: 13px;
}

.pricing-table input,
.pricing-table select {
  width: 100%;
  min-width: 92px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
}

.pricing-table .name-input {
  min-width: 230px;
}

.pricing-table .computed {
  background: #fbfdff;
  font-weight: 760;
  text-align: right;
}

.pricing-table .settlement {
  color: var(--accent-strong);
}

.pricing-table .delete-cell {
  text-align: center;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  color: var(--danger);
  background: #fff7f7;
  font-weight: 800;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.margin-panel,
.fee-panel {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

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

.switch-row {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.switch-row input {
  width: 16px;
  height: 16px;
  margin: 0 8px 0 0;
  padding: 0;
}

.wide-field {
  grid-column: 1 / -1;
}

.result-stack {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.result-stack > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

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

.result-stack strong {
  font-size: 18px;
}

.result-stack .accent {
  background: var(--soft);
  border-color: #b7ded9;
}

.fee-list {
  display: grid;
  gap: 10px;
  padding: 16px;
  max-height: 560px;
  overflow: auto;
}

.fee-category {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.fee-category summary {
  list-style: none;
  padding: 12px;
  font-weight: 800;
  cursor: pointer;
  background: #f8fafc;
}

.fee-category summary::-webkit-details-marker {
  display: none;
}

.fee-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.fee-grid span:nth-child(even) {
  font-weight: 800;
  color: var(--accent-strong);
}

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

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

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 18px;
  }

  .topbar,
  .panel-header {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

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

  .wide-field {
    grid-column: auto;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }
}
