:root {
  --ink: #17202a;
  --muted: #5d6978;
  --line: #d8dee7;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --accent: #277c78;
  --accent-2: #b23a48;
  --accent-3: #4f6bed;
  --good: #1f7a4d;
  --warn: #a15c00;
  --bad: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent-3);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px);
  color: #fff;
  background: #17202a;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: #cfd8e3;
  font-size: 13px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a,
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.nav a {
  border-color: #3b4652;
  background: #243140;
}

button.secondary,
.button.secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

button.danger {
  background: var(--accent-2);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(23, 32, 42, 0.06);
}

.panel.pad {
  padding: 20px;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  line-height: 1.15;
}

h1 {
  font-size: 34px;
}

p {
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

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

.stat {
  padding: 16px;
  border-left: 5px solid var(--accent);
}

.stat strong {
  display: block;
  font-size: 28px;
}

.map {
  display: grid;
  grid-template-columns: repeat(10, minmax(52px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.node {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e9edf3;
  color: #314155;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
}

.node.solved {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
}

.node span {
  position: absolute;
  inset: auto 5px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.dept {
  padding: 14px;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 8px;
  background: #e6ebf2;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #2b3848;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #c7d0dc;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 170px;
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 20px;
  align-items: start;
}

.result {
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  white-space: pre-wrap;
}

.ok {
  border-color: #9bd5b5;
  background: #eefaf3;
}

.error {
  border-color: #f0aaa5;
  background: #fff2f1;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.log div {
  padding: 10px;
  border-left: 4px solid var(--accent-3);
  background: #f3f6fb;
}

.hidden-frame {
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

@media (max-width: 860px) {
  .topbar,
  .intro,
  .two-col {
    grid-template-columns: 1fr;
  }

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

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

  .map {
    grid-template-columns: repeat(5, minmax(48px, 1fr));
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 28px;
  }

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