:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --text: #17211f;
  --muted: #66736f;
  --line: #dce6e2;
  --soft: #eef8f5;
  --primary: #2fc8b4;
  --primary-dark: #159886;
  --ink: #153f38;
  --danger: #e54855;
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(47, 200, 180, 0.16), transparent 28%),
    linear-gradient(135deg, #f7fbfa 0%, #eef5f3 100%);
  color: var(--text);
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 15px;
  color: #fff;
  background: var(--primary-dark);
  cursor: pointer;
  transition: 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  background: #0f7f70;
}

.ghost {
  color: var(--ink);
  background: #e8f1ef;
}

.danger {
  background: var(--danger);
}

.sidebar {
  width: 220px;
  min-height: 100vh;
  padding: 24px 16px;
  color: #fff;
  background: linear-gradient(180deg, #143f38 0%, #0f2b27 100%);
}

.brand {
  margin-bottom: 28px;
  font-size: 22px;
  font-weight: 800;
}

.nav {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: transparent;
}

.nav.active,
.nav:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
}

.shell {
  width: 100%;
  padding: 28px;
}

.hidden {
  display: none !important;
}

.login,
.topbar,
.import-panel,
.guide-card,
dialog form {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(220, 230, 226, 0.9);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(16, 46, 40, 0.08);
  backdrop-filter: blur(14px);
}

.login,
dialog form {
  padding: 24px;
}

.login {
  max-width: 420px;
  margin: 10vh auto;
}

.login h1,
.topbar h1,
.import-panel h2,
.guide-card h2 {
  margin: 0 0 8px;
}

.topbar {
  margin-bottom: 20px;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar p,
.guide-card p,
.panel-head p {
  margin: 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 200, 180, 0.14);
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.metrics div,
.empty,
.question-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.metrics div {
  padding: 22px;
}

.metrics span {
  display: block;
  font-size: 34px;
  font-weight: 800;
  color: var(--ink);
}

.metrics small,
.muted {
  color: var(--muted);
}

.guide-card {
  margin-top: 18px;
  padding: 22px;
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar input {
  min-width: 260px;
}

.toolbar select {
  width: 150px;
}

.toolbar-wrap {
  flex-wrap: wrap;
}

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

.question-row {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.question-row h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.off-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #7a2e0e;
  background: #fff1dd;
  font-size: 12px;
  vertical-align: middle;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.import-panel {
  padding: 24px;
}

.panel-head,
.import-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.upload-box {
  position: relative;
  margin: 18px 0 14px;
  border: 1.5px dashed #9bded3;
  border-radius: 12px;
  background: var(--soft);
}

.upload-box.dragging {
  border-color: var(--primary-dark);
  background: #dff7f2;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-box label {
  margin: 0;
  padding: 24px;
  display: grid;
  gap: 6px;
  text-align: center;
  color: var(--ink);
}

.upload-box span {
  color: var(--muted);
  font-size: 14px;
}

.import-panel textarea {
  min-height: 320px;
  margin: 0 0 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 12px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(12, 18, 24, 0.45);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
}

.check-row input {
  width: auto;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--primary-dark);
  box-shadow: 0 16px 38px rgba(15, 43, 39, 0.22);
}

.toast.bad {
  background: var(--danger);
}

@media (max-width: 780px) {
  body {
    display: block;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    display: flex;
    gap: 8px;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    margin: 0 14px 0 0;
    white-space: nowrap;
  }

  .nav {
    width: auto;
    white-space: nowrap;
  }

  .shell {
    padding: 16px;
  }

  .option-grid,
  .question-row,
  .topbar,
  .toolbar,
  .panel-head,
  .import-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar input,
  .toolbar select {
    width: 100%;
    min-width: 0;
  }

  .row-actions {
    justify-content: flex-end;
  }
}
