:root {
  --blue-950: #0b2447;
  --blue-850: #123e73;
  --blue-700: #1557a6;
  --blue-500: #2878d7;
  --blue-100: #eaf3ff;
  --blue-050: #f6faff;
  --border: #d9e6f7;
  --ink: #1f2a3d;
  --muted: #637083;
  --danger: #d62728;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--blue-050) 0%, #ffffff 38%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Roboto, sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 24px 20px;
  background: #eef6ff;
  border-right: 1px solid var(--border);
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--blue-950);
  letter-spacing: 0;
}

.sidebar h2 {
  margin-bottom: 22px;
  font-size: 1.28rem;
}

.sidebar h3 {
  margin: 22px 0 12px;
  font-size: 1rem;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--blue-950);
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid #bfd5f2;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea:focus,
input:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(40, 120, 215, 0.14);
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  height: 18px;
}

#searchButton,
#downloadCsv {
  border: 1px solid var(--blue-700);
  border-radius: 8px;
  background: var(--blue-700);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

#searchButton {
  width: 100%;
  min-height: 42px;
  margin: 8px 0 16px;
}

#searchButton:hover,
#downloadCsv:hover {
  background: var(--blue-950);
  border-color: var(--blue-950);
}

main {
  min-width: 0;
  padding: 32px;
}

.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  margin-bottom: 8px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.message {
  border-radius: 8px;
  margin-bottom: 18px;
  padding: 14px 16px;
  line-height: 1.55;
}

.message.info {
  background: var(--blue-100);
  border: 1px solid #cfe2fb;
  color: #184a86;
}

.message.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.message.loading {
  background: #f8fafc;
  border: 1px solid #dbe4ee;
  color: #334155;
}

.hidden {
  display: none !important;
}

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

.metric {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(26, 87, 166, 0.08);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--blue-950);
  font-size: 1.35rem;
}

.metric small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

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

.chart-panel {
  min-height: 420px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(26, 87, 166, 0.06);
}

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

.section-header h2 {
  font-size: 1.25rem;
}

#downloadCsv {
  min-height: 38px;
  padding: 0 14px;
}

.table-wrap {
  max-height: 540px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  border-bottom: 1px solid #e6eef9;
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f7ff;
  color: var(--blue-950);
}

td.item-name {
  min-width: 280px;
  white-space: normal;
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  main {
    padding: 24px 16px;
  }

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

@media (max-width: 520px) {
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 10px;
  }

  .metric strong {
    font-size: 1.12rem;
  }
}
