:root {
  --ink: #14213d;
  --muted: #5d6979;
  --line: #dbe2ea;
  --panel: #ffffff;
  --page: #f5f7fa;
  --gdh: #2f4b8f;
  --gds: #008c83;
  --good: #047857;
  --warn: #b45309;
  --soft-blue: #e7f0ff;
  --soft-green: #e6f5ef;
  --soft-orange: #fff0e6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    sans-serif;
}

button,
input,
label {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 55%, #fef7ed 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.eyebrow,
.subtitle,
.label,
.hint,
.panel-heading p,
.upload-status {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.subtitle {
  margin-bottom: 0;
  font-size: 16px;
}

.upload-panel {
  min-width: 250px;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-button,
.icon-button,
.seg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #ffffff;
  color: var(--ink);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.upload-button {
  min-height: 46px;
  padding: 0 16px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(20, 33, 61, 0.08);
}

.upload-button:hover,
.icon-button:hover,
.seg-button:hover {
  transform: translateY(-1px);
  border-color: #aab7c5;
}

.upload-status {
  margin: 0;
  font-size: 13px;
  text-align: right;
}

.summary-grid,
.main-grid {
  display: grid;
  gap: 16px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.summary-card,
.chart-panel,
.weekday-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-card {
  min-height: 124px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.summary-card.metric-card {
  grid-template-rows: auto 1fr;
  align-content: stretch;
}

.summary-card.metric-card strong {
  align-self: center;
}

.summary-card.baseline {
  background: var(--soft-blue);
}

.summary-card strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
}

.summary-card .metric {
  font-size: 15px;
  color: var(--muted);
}

.label,
.hint {
  font-size: 13px;
}

.hint:empty {
  display: none;
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.control-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: #e9eef5;
  border-radius: 8px;
}

.week-filter {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.week-filter select {
  min-width: 130px;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font-weight: 800;
  cursor: pointer;
}

.unit-toggle {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: #e9eef5;
  border-radius: 8px;
}

.unit-button {
  min-height: 42px;
  min-width: 62px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.unit-button.active {
  background: #ffffff;
  border-color: #c9d4e1;
  box-shadow: 0 5px 14px rgba(20, 33, 61, 0.08);
}

.seg-button {
  min-height: 42px;
  min-width: 118px;
  padding: 0 14px;
  background: transparent;
  border-color: transparent;
  font-weight: 700;
}

.seg-button.active {
  background: #ffffff;
  border-color: #c9d4e1;
  box-shadow: 0 5px 14px rgba(20, 33, 61, 0.08);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
}

.swatch.gdh {
  background: var(--gdh);
}

.swatch.gds {
  background: var(--gds);
}

.main-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.8fr);
}

.chart-panel,
.weekday-panel,
.table-panel {
  padding: 20px;
}

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading p {
  margin-bottom: 0;
  font-size: 14px;
}

.chart-wrap {
  height: 410px;
}

.weekday-cards {
  display: grid;
  gap: 10px;
}

.weekday-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f9fbfd;
  border: 1px solid #e5ebf2;
  border-radius: 8px;
}

.weekday-name {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.mini-bars {
  display: grid;
  gap: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: 74px 1fr 52px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.bar-track {
  height: 8px;
  overflow: hidden;
  background: #e7edf4;
  border-radius: 99px;
}

.bar-fill {
  display: block;
  width: var(--bar-width, 0%);
  height: 100%;
  background: var(--bar-color, var(--gdh));
  border-radius: inherit;
}

.bar-fill.gdh {
  background: var(--gdh);
}

.bar-fill.gds {
  background: var(--gds);
}

.gap-pill {
  min-width: 76px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--soft-orange);
  color: var(--warn);
  text-align: center;
  font-weight: 800;
  font-size: 13px;
}

.gap-pill.positive {
  background: var(--soft-green);
  color: var(--good);
}

.gap-pill.muted {
  background: #eef2f7;
  color: var(--muted);
}

.holiday-note {
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
  width: fit-content;
}

.table-panel {
  margin-top: 18px;
}

.table-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1f6;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5f9;
  color: #415064;
  font-size: 13px;
}

td {
  font-size: 14px;
}

.diff-positive {
  color: var(--good);
  font-weight: 800;
}

.diff-negative {
  color: var(--warn);
  font-weight: 800;
}

.note-date {
  text-decoration: underline dotted #9a3412 2px;
  text-underline-offset: 4px;
  cursor: help;
}

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

@media (max-width: 960px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .control-strip {
    display: grid;
  }

  .upload-panel {
    justify-items: stretch;
  }

  .upload-status {
    text-align: left;
  }

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

  .control-strip {
    align-items: stretch;
  }

  .segmented {
    width: 100%;
  }

  .control-left {
    width: 100%;
  }

  .seg-button {
    min-width: 0;
    flex: 1;
  }

  .week-filter {
    width: 100%;
  }

  .week-filter select {
    width: 100%;
  }

  .unit-toggle {
    width: 100%;
  }

  .unit-button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 20px;
  }

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

  .chart-wrap {
    height: 320px;
  }

  .weekday-card {
    grid-template-columns: 42px 1fr;
  }

  .gap-pill {
    grid-column: 2;
    width: fit-content;
  }
}
