:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --border: #e3e6eb;
  --primary: #2f5597;
  --primary-hover: #264680;
  --primary-text: #ffffff;
  --input-bg: #f1f3f6;
  --error-bg: #fdecec;
  --error-text: #a12b2b;
  --info-bg: #eef4ff;
  --info-text: #234a8a;
  --low: #e3f4e8;
  --low-text: #1e7b34;
  --mid: #fff4d6;
  --mid-text: #8a5a00;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1d2129;
    --text: #e6e9ee;
    --muted: #98a2b3;
    --border: #2e3440;
    --primary: #5b86d6;
    --primary-hover: #739ae0;
    --primary-text: #0f1420;
    --input-bg: #262b35;
    --error-bg: #3a1f22;
    --error-text: #f2a7a7;
    --info-bg: #1e2a40;
    --info-text: #a9c4f5;
    --low: #1d3326;
    --low-text: #8fd5a3;
    --mid: #3a3020;
    --mid-text: #f0cf86;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}

h1 { font-size: 28px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 4px; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

label { display: block; font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin: 4px 0 0; }

input, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 120px; }
.field + .field { margin-top: 16px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button.primary:hover { background: var(--primary-hover); }
.button.full { width: 100%; margin-top: 20px; }
.button:disabled { opacity: 0.6; cursor: wait; }

.top-link { display: inline-block; margin-bottom: 20px; font-size: 14px; padding: 6px 12px; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tool-grid .card { display: flex; flex-direction: column; }
.tool-grid .card p { flex: 1; }

.message { border-radius: 8px; padding: 12px 14px; margin-top: 16px; white-space: pre-line; }
.message.error { background: var(--error-bg); color: var(--error-text); }
.message.info { background: var(--info-bg); color: var(--info-text); }

.progress { margin-top: 20px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--input-bg); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }
.progress-text { color: var(--muted); font-size: 13px; margin-top: 6px; }

.result { margin-top: 32px; }
.result-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { text-align: left; color: var(--muted); font-weight: 600; background: var(--input-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
td.low { background: var(--low); color: var(--low-text); font-weight: 600; }

.footer { margin-top: 32px; }

/* 넓은 표가 있는 페이지 */
main.wide { max-width: 1180px; }
.card.narrow { max-width: 760px; }

.steps { margin: 4px 0 16px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.steps li + li { margin-top: 4px; }
.steps strong { color: var(--text); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; }
.filter legend { padding: 0 4px; font-size: 13px; color: var(--muted); }
.filter label, label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.filter input { width: auto; }
select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

.count-input { display: flex; align-items: center; gap: 6px; min-width: 150px; }
.count-input input { width: 110px; padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.button.small { padding: 5px 9px; font-size: 13px; }

.label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.label-row label { margin: 0; }

.trend-panel { margin-bottom: 16px; }
.trend-panel h3 { margin: 0 0 4px; font-size: 16px; }
.chart-box { position: relative; height: 320px; }
td.trend-up { color: var(--low-text); font-weight: 600; }
td.trend-down { color: var(--error-text); font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--input-bg); color: var(--muted); }
.badge.low { background: var(--low); color: var(--low-text); }
.badge.mid { background: var(--mid); color: var(--mid-text); }
.badge.high { background: var(--error-bg); color: var(--error-text); }

[hidden] { display: none !important; }
