:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #2364aa;
  --primary-dark: #174f8a;
  --brand: #238337;
  --brand-dark: #17652a;
  --accent: #2a9d8f;
  --danger: #bd3440;
  --warning: #b7791f;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-logo {
  width: 210px;
  max-width: 32vw;
  height: 72px;
  object-fit: contain;
  object-position: left center;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 21px;
}

h3 {
  font-size: 17px;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

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

.tab,
.ghost,
.primary,
.file-button,
.status-actions button {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.tab {
  background: #eef2f7;
  color: var(--text);
}

.tab.active,
.primary {
  background: var(--brand);
  color: #ffffff;
}

.primary:hover {
  background: var(--brand-dark);
}

.ghost,
.file-button,
.status-actions button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost:hover,
.file-button:hover,
.status-actions button:hover {
  border-color: var(--brand);
}

.ghost.danger {
  color: #b42318;
}

.ghost.danger:hover {
  border-color: #d92d20;
  background: #fff4f2;
}

main {
  padding: 24px clamp(16px, 4vw, 48px) 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout {
  display: grid;
  gap: 20px;
}

.layout.two {
  grid-template-columns: minmax(320px, 460px) 1fr;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.panel-head.compact {
  margin-top: 16px;
  margin-bottom: 10px;
}

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

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(35, 131, 55, 0.18);
  border-color: var(--brand);
}

.card-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 240px) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.answers-editor {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.answer-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 36px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.answer-row input[type="checkbox"],
.checkline input {
  width: 18px;
  height: 18px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #f4f6f8;
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 12px;
  background: #edf7f5;
  color: #126b61;
  font-weight: 600;
}

.card-list,
.exam-area {
  display: grid;
  gap: 12px;
}

.card-item,
.result-item,
.question-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.card-item h3,
.question-card h3 {
  margin-bottom: 10px;
}

.user-item {
  cursor: pointer;
}

.user-item:hover,
.user-item:focus {
  border-color: var(--brand);
  outline: none;
}

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

.answer-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.answer-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfe;
}

.answer-option.correct {
  border-color: var(--accent);
  background: #eefaf8;
}

.answer-option.wrong {
  border-color: var(--danger);
  background: #fff1f2;
}

.answer-option input {
  width: 18px;
  margin-top: 2px;
}

.media {
  max-width: 100%;
  max-height: 260px;
  display: block;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.actions.vertical {
  display: grid;
}

.status-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.hidden,
.file-button input {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card p {
  margin: 8px 0 20px;
}

.login-logo {
  width: 240px;
  max-width: 100%;
  height: 86px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
}

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

.stats-table th,
.stats-table td {
  border: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.stats-table th {
  background: #eef2f7;
  font-weight: 700;
}

.level-ok {
  background: #eefaf8;
}

.level-mid {
  background: #fff8e8;
}

.level-low {
  background: #fff1f2;
}

.recent-list {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.empty {
  color: var(--muted);
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.checkline {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2937;
  color: #ffffff;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

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

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-logo {
    max-width: 220px;
  }

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

  .card-filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 15px;
  }

  .topbar {
    position: static;
    padding: 16px;
    gap: 16px;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .brand-logo {
    width: 180px;
    height: 58px;
    max-width: 100%;
  }

  .topbar h1 {
    font-size: 26px;
  }

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

  .tab,
  .ghost,
  .primary,
  .file-button,
  .status-actions button {
    width: 100%;
    min-height: 46px;
  }

  main {
    padding: 16px;
  }

  .panel,
  .login-card {
    padding: 18px;
  }

  .login-screen {
    align-items: start;
    min-height: 100svh;
    padding: 16px;
  }

  .login-logo {
    width: 190px;
    height: 68px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .answer-row {
    grid-template-columns: 32px 1fr 32px;
  }

  .answer-row input[type="url"] {
    grid-column: 2 / 4;
  }
}
