:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #17212f;
  --muted: #627084;
  --line: #d8e0ea;
  --brand: #17324d;
  --brand-2: #24527a;
  --gold: #d7a947;
  --teal: #0f8f86;
  --blue: #2d6ea8;
  --green: #2f855a;
  --amber: #b7791f;
  --red: #c94a3c;
  --red-soft: #fff1ef;
  --green-soft: #edf8f2;
  --blue-soft: #edf6ff;
  --gold-soft: #fff7df;
  --shadow: 0 14px 38px rgba(23, 50, 77, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 86px;
  padding: 14px;
  background: var(--brand);
  color: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--gold);
  color: var(--brand);
  font-weight: 900;
}

.kicker {
  margin: 0 0 4px;
  color: #dce8f4;
  font-size: 0.82rem;
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.12;
}

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

.select-label {
  color: #dce8f4;
  font-size: 0.78rem;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

.top-actions select {
  border-color: rgba(255, 255, 255, 0.32);
}

.install-button,
.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.tiny-button,
.tab-button,
.nav-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.install-button,
.primary-button {
  background: var(--gold);
  color: #142337;
  padding: 10px 14px;
}

.secondary-button {
  background: var(--brand);
  color: white;
  padding: 10px 14px;
}

.ghost-button {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line);
  padding: 10px 12px;
}

.danger-button {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f2b9b2;
  padding: 10px 12px;
}

.tiny-button {
  min-height: 34px;
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line);
  padding: 6px 9px;
  font-size: 0.82rem;
}

.app-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar {
  display: none;
}

.nav-button {
  flex: 0 0 auto;
  min-width: 88px;
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line);
  padding: 10px 12px;
  white-space: nowrap;
}

.nav-button.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.view-root {
  display: grid;
  gap: 14px;
}

.band {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.band-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.band-title {
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
}

.band-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two,
.grid.three,
.grid.four {
  grid-template-columns: 1fr;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat,
.student-card,
.metric-tile,
.timeline-row,
.report-block,
.message-card,
.file-drop {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  min-height: 104px;
  padding: 13px;
}

.stat-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.stat-value {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.38rem, 7vw, 2.1rem);
  line-height: 1;
  font-weight: 900;
}

.stat-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.4;
}

.student-list {
  display: grid;
  gap: 10px;
}

.student-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 13px;
}

.student-card.active {
  border-color: var(--brand-2);
  box-shadow: inset 4px 0 0 var(--brand-2);
}

.student-main {
  display: grid;
  gap: 4px;
}

.student-name {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
}

.meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
}

.chip.good {
  background: var(--green-soft);
  color: var(--green);
}

.chip.warn {
  background: var(--gold-soft);
  color: var(--amber);
}

.chip.bad {
  background: var(--red-soft);
  color: var(--red);
}

.form-grid {
  display: grid;
  gap: 11px;
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 900;
}

.field.inline {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-grid,
.metric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

.metric-tile {
  display: grid;
  gap: 9px;
  min-height: 144px;
  padding: 12px;
}

.metric-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.metric-title {
  margin: 0;
  font-weight: 900;
  color: var(--brand);
}

.metric-group {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 7px;
}

.metric-input-row input {
  min-height: 52px;
  font-size: 1.18rem;
  font-weight: 800;
}

.standard-score-details {
  margin-top: 8px;
}

.standard-score-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.standard-score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.standard-score-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.standard-score-grid input {
  min-height: 40px;
  font-size: 0.96rem;
  font-weight: 800;
}

.subsection-head {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.subsection-head h3,
.subsection-head h4 {
  margin: 0;
  color: var(--brand);
  font-size: 1rem;
  font-weight: 900;
}

.standard-page {
  gap: 16px;
}

.standard-section {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.standard-filter-grid {
  margin-top: 6px;
}

.action-field {
  align-self: end;
}

.standard-age-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.age-chip {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.84rem;
  font-weight: 900;
}

.age-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.standard-item-grid,
.standard-score-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.standard-item-card,
.standard-score-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.standard-item-card.active {
  border-color: var(--teal);
  box-shadow: inset 4px 0 0 var(--teal);
}

.standard-item-card h3,
.standard-score-card h4 {
  margin: 0;
  color: var(--brand);
  font-size: 1rem;
  font-weight: 900;
}

.standard-score-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.standard-score-card-head strong {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--gold-soft);
  color: var(--amber);
  font-size: 1.02rem;
}

.standard-record-value {
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.22rem;
  font-weight: 900;
  text-align: center;
}

.standard-score-groups {
  display: grid;
  gap: 14px;
}

.standard-score-group {
  display: grid;
  gap: 10px;
}

.standard-score-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-2);
}

.standard-score-group-head h4 {
  margin: 0;
  color: var(--brand);
  font-size: 1.05rem;
  font-weight: 900;
}

.standard-score-group-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.standard-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.standard-table-details {
  margin-top: 4px;
}

.standard-table-details summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 900;
}

.standard-score-viewer {
  display: grid;
  gap: 10px;
}

.standard-score-preview th,
.standard-score-preview td {
  white-space: nowrap;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.keypad-button {
  min-height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--brand);
  font-weight: 900;
}

.metric-config-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.metric-config-row input {
  min-height: 40px;
}

.bar-list {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(84px, 132px) 1fr minmax(72px, auto);
  gap: 9px;
  align-items: center;
}

.bar-label {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.86rem;
}

.bar-track {
  height: 16px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--teal);
}

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

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

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

.bar-value {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
  white-space: nowrap;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 0.88rem;
}

th {
  background: var(--brand);
  color: white;
  font-size: 0.78rem;
}

tr:last-child td {
  border-bottom: 0;
}

.report-layout {
  display: grid;
  gap: 14px;
}

.report-layout.single {
  grid-template-columns: 1fr;
}

.report-paper {
  display: grid;
  gap: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.report-title {
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.25rem, 4vw, 1.8rem);
}

.report-paper .stat-value {
  font-size: clamp(1.22rem, 3vw, 1.65rem);
  line-height: 1.15;
}

.report-block {
  padding: 13px;
}

.report-block h3 {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 1rem;
}

.report-block p,
.message-card p {
  margin: 0;
  line-height: 1.65;
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-row {
  display: grid;
  gap: 4px;
  padding: 11px;
}

.timeline-date {
  color: var(--brand);
  font-weight: 900;
  font-size: 0.82rem;
}

.message-card {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.message-card textarea {
  min-height: 132px;
}

.alert-list {
  display: grid;
  gap: 8px;
}

.alert {
  padding: 10px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--blue-soft);
  color: var(--brand);
  line-height: 1.45;
}

.alert.warn {
  background: var(--gold-soft);
  color: #744d00;
  border-color: #ead08a;
}

.alert.bad {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f0b5ad;
}

.file-drop {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.session-panel {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.choice-grid,
.student-picker-list {
  display: grid;
  gap: 8px;
}

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

.choice-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.choice-card.compact {
  grid-template-columns: auto 1fr auto;
}

.choice-card.active {
  border-color: var(--brand-2);
  background: var(--blue-soft);
}

.choice-card input[type="checkbox"] {
  width: 22px;
  min-height: 22px;
}

.choice-card span {
  display: grid;
  gap: 3px;
}

.choice-card strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.choice-card small {
  color: var(--muted);
  font-weight: 700;
}

.student-selection-board {
  display: grid;
  gap: 12px;
}

.student-selection-board h4 {
  margin: 0 0 8px;
  color: var(--brand);
}

.student-drop-zone {
  min-height: 180px;
  padding: 10px;
  border: 1px dashed #9eb4c8;
  border-radius: 8px;
  background: var(--surface-2);
}

.student-drop-zone.drag-over {
  border-color: var(--teal);
  background: #e8f7f5;
}

.student-drag-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 56px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.student-drag-card.active,
.student-drag-card.selected {
  border-color: var(--brand-2);
  background: var(--blue-soft);
}

.student-drag-card.dragging {
  opacity: 0.55;
}

.student-drag-card span {
  display: grid;
  gap: 3px;
}

.student-drag-card strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.student-drag-card small {
  color: var(--muted);
  font-weight: 700;
}

.metric-settings-grid,
.measurement-entry-list {
  display: grid;
  gap: 12px;
}

.metric-setting,
.measurement-card {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.measurement-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.measurement-card-head h3 {
  margin: 0;
  color: var(--brand);
}

.comment-details {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.comment-details summary {
  color: var(--brand);
  font-weight: 900;
  cursor: pointer;
}

.batch-summary {
  color: var(--brand);
  font-weight: 900;
  cursor: pointer;
}

.comment-details .form-grid {
  margin-top: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  width: min(calc(100% - 28px), 520px);
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  box-shadow: var(--shadow);
  transform: translate(-50%, 120px);
  opacity: 0;
  transition: 0.2s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(10, 22, 35, 0.38);
}

.modal-layer[hidden] {
  display: none !important;
}

.modal {
  width: min(100%, 560px);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-title {
  margin: 0;
  color: var(--brand);
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.number-pad button {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 900;
}

.print-only {
  display: none;
}

@media (min-width: 720px) {
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .standard-item-grid,
  .standard-score-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  .student-selection-board {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.85fr);
  }

  .metric-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-config-row {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  }

  .student-card {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

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

@media (min-width: 1040px) {
  .grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

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

  .standard-score-card-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .report-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  }

  .report-layout.single {
    grid-template-columns: 1fr;
  }

  .measurement-entry-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px 10px 96px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .install-button {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 88px 1fr;
  }

  .bar-value {
    grid-column: 2;
    text-align: left;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .app-nav,
  .toolbar,
  .no-print,
  .toast,
  .modal-layer {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .band,
  .report-paper,
  .report-block {
    border: 0;
    box-shadow: none;
  }

  .report-paper {
    padding: 0;
  }
}
