:root {
  --ink: #101a2f;
  --muted: #68758b;
  --line: #d8e0ec;
  --panel: #ffffff;
  --field: #f7f9fd;
  --accent: #314b92;
  --accent-strong: #18284f;
  --accent-soft: #e9eefb;
  --danger-soft: #fde9ec;
  --danger: #a83443;
  --nav: #10182d;
  --nav-deep: #08101f;
  --ice: #d7e7f5;
  --shadow: 0 18px 45px rgba(25, 40, 79, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(215, 231, 245, 0.9), transparent 28%),
    #eef3f9;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background:
    linear-gradient(160deg, rgba(55, 78, 150, 0.45), rgba(8, 16, 31, 0.1) 38%),
    linear-gradient(180deg, var(--nav), var(--nav-deep));
  color: #f5faf6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-logo {
  width: 64px;
  height: 64px;
  border: 2px solid rgba(215, 231, 245, 0.9);
  border-radius: 50%;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  object-fit: cover;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-title h3,
.section-title p,
.mapper h4,
.grades-panel h4 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  letter-spacing: 0.2px;
}

.brand p {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 13px;
}

.steps {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
  font-size: 14px;
  text-align: left;
}

.step span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 700;
}

.step.active,
.step:hover {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.step.active span {
  background: #ffffff;
  color: var(--accent-strong);
}

.nav-label {
  margin: 16px 0 4px;
  color: rgba(255, 255, 255, 0.54);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.school-picker {
  position: relative;
  display: grid;
  gap: 9px;
  margin-bottom: 10px;
  padding: 13px;
  border: 1px solid rgba(215, 231, 245, 0.18);
  border-radius: 8px;
  background: rgba(215, 231, 245, 0.08);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 800;
}

.school-picker > span {
  color: #ffffff;
  font-size: 11px;
  text-transform: uppercase;
}

.school-picker-button {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 2px 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 12px;
  border: 1px solid rgba(215, 231, 245, 0.6);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(232, 239, 251, 0.96));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 26px rgba(0, 0, 0, 0.16);
  text-align: left;
}

.school-picker-button strong,
.school-picker-menu strong {
  overflow: hidden;
  color: #14254f;
  font-size: 12px;
  font-weight: 950;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.school-picker-button small,
.school-picker-menu small {
  color: #5f7196;
  font-size: 11px;
  font-weight: 800;
}

.school-picker-button svg {
  grid-row: 1 / span 2;
  grid-column: 2;
  width: 18px;
  height: 18px;
  color: var(--accent-strong);
}

.school-picker-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 13px;
  left: 13px;
  z-index: 30;
  display: none;
  padding: 6px;
  border: 1px solid rgba(215, 231, 245, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(24, 39, 79, 0.98), rgba(8, 16, 31, 0.98));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

.school-picker.open .school-picker-menu {
  display: grid;
  gap: 4px;
}

.school-picker-menu button {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 52px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}

.school-picker-menu button strong {
  color: rgba(255, 255, 255, 0.92);
}

.school-picker-menu button small {
  color: rgba(215, 231, 245, 0.68);
}

.school-picker-menu button:hover,
.school-picker-menu button.active {
  border-color: rgba(215, 231, 245, 0.3);
  background: rgba(255, 255, 255, 0.1);
}

.school-picker-menu button.active strong {
  color: #ffffff;
}

.school-picker-menu button.active small {
  color: #d7e7f5;
}

.hidden {
  display: none !important;
}

.is-disabled {
  opacity: 0.48;
}

.workspace {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px;
}

.topbar,
.section-title,
.mapper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 72px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 30px;
  line-height: 1.15;
}

.server-pill,
.status-pill,
.row-counter {
  min-height: 32px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #eef3ff;
  color: #283f7e;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.server-pill.ok,
.status-pill,
.row-counter {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.panel {
  padding: 22px;
  border: 1px solid rgba(216, 224, 236, 0.92);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.section-title {
  margin-bottom: 18px;
}

.section-title h3 {
  margin-top: 3px;
  font-size: 20px;
}

.control-strip,
.form-grid,
.mapper-grid,
.grades-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.control-strip {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f9fbff, var(--field));
}

.counter-card {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 13px 14px;
  border: 1px solid #b8c5e5;
  border-radius: 8px;
  background: linear-gradient(135deg, #f7faff, #eaf0ff);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.counter-card span,
.counter-card small {
  color: #556174;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.counter-card strong {
  color: #19356f;
  font-size: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: #38443c;
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c9d1cb;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(49, 75, 146, 0.22);
  outline-offset: 2px;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 170px;
  padding: 28px;
  border: 2px dashed #b9c5bd;
  border-radius: 8px;
  background: var(--field);
  color: var(--muted);
  text-align: center;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-zone svg {
  width: 38px;
  height: 38px;
  color: var(--accent);
}

.drop-zone strong {
  color: var(--ink);
  font-size: 18px;
}

.mapper,
.grades-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.mapper-header {
  margin-bottom: 12px;
}

.mapper-header span {
  color: var(--muted);
  font-size: 13px;
}

.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 15px;
  font-weight: 800;
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.3;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.preview-frame-wrap {
  position: relative;
  min-height: 720px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe6f0;
}

#previewFrame {
  display: block;
  width: 100%;
  height: 720px;
  border: 0;
  background: #dfe6f0;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.preview-frame-wrap.has-preview .preview-empty {
  display: none;
}

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

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

th {
  background: #f6f8f5;
  color: #4d5a52;
  font-size: 12px;
  text-transform: uppercase;
}

.empty-state {
  height: 88px;
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.error {
  background: var(--danger-soft);
  color: var(--danger);
}

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17201b;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .steps,
  .control-strip,
  .form-grid,
  .mapper-grid,
  .grades-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-title,
  .mapper-header {
    align-items: stretch;
    flex-direction: column;
  }

  .steps,
  .control-strip,
  .form-grid,
  .mapper-grid,
  .grades-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button,
  .action-row {
    width: 100%;
  }
}
