:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #17211d;
  --muted: #65716c;
  --line: #d9e0dc;
  --green: #18664a;
  --green-2: #0f4e39;
  --blue: #285f9f;
  --red: #a43d3d;
  --gold: #8b6f1f;
  --shadow: 0 16px 45px rgba(28, 40, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", system-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;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 5px;
  font-size: 19px;
}

h3 {
  margin-bottom: 5px;
  font-size: 15px;
}

.top-actions,
.table-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 15px;
  background: var(--green);
  color: #fff;
}

.primary-button:hover {
  background: var(--green-2);
}

.ghost-button {
  padding: 0 14px;
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: #aeb9b3;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  background: #fff;
  border-color: var(--line);
  color: var(--red);
  font-size: 20px;
  line-height: 1;
}

.controls-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  padding: 16px;
  background: #e7eeea;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.control {
  min-width: 0;
}

.control label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 11px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(24, 102, 74, 0.14);
  border-color: var(--green);
}

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

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

.kpi-card {
  min-height: 124px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card span,
.kpi-card small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
  word-break: keep-all;
}

.kpi-card.accent {
  border-color: rgba(40, 95, 159, 0.34);
  background: #f1f7ff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.8fr);
  gap: 14px;
}

.panel {
  padding: 18px;
}

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

.panel-heading p,
.import-box p,
.notice {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-submit {
  width: 100%;
}

.import-box {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 0.5fr);
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px dashed #b8c6bf;
  border-radius: 8px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

.report-table th {
  width: 48%;
}

.report-table td {
  font-weight: 800;
  text-align: right;
}

.notice {
  margin-top: 14px;
  padding: 12px;
  background: #fff8e5;
  border: 1px solid #eddca5;
  border-radius: 7px;
  color: #6c5817;
}

.records-panel {
  margin-top: 14px;
}

.table-heading {
  align-items: center;
}

.table-tools {
  min-width: min(320px, 100%);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tax-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tax-pill.taxable {
  background: #e8f4ee;
  color: var(--green-2);
}

.tax-pill.zero-rated {
  background: #eaf2ff;
  color: var(--blue);
}

.tax-pill.exempt {
  background: #fbf1d2;
  color: var(--gold);
}

@media (max-width: 1080px) {
  .controls-band,
  .kpi-grid,
  .workspace-grid,
  .entry-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-panel {
    grid-column: 1 / -1;
  }
}

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

  .topbar,
  .panel-heading,
  .table-heading,
  .import-box {
    display: block;
  }

  .top-actions {
    margin-top: 16px;
    flex-wrap: wrap;
  }

  .controls-band,
  .kpi-grid,
  .workspace-grid,
  .entry-form {
    grid-template-columns: 1fr;
  }

  .table-tools {
    margin-top: 12px;
  }
}
