:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --text: #141720;
  --muted: #667085;
  --line: #dbe3ec;
  --accent: #00a78e;
  --accent-dark: #047c70;
  --accent-2: #ff7a1a;
  --info: #3455db;
  --danger: #e23b4d;
  --success: #18a05f;
  --energy: #f2c94c;
  --disabled: #d6dde5;
  --shadow: 0 16px 42px rgba(18, 28, 45, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(135deg, rgba(0, 167, 142, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(255, 122, 26, 0.09), transparent 320px),
    var(--bg);
}

button {
  font: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px 0 14px;
  background: rgba(244, 247, 251, 0.92);
  border-bottom: 1px solid rgba(219, 227, 236, 0.72);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin: 0;
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

p {
  margin: 0;
}

.screen {
  display: grid;
  gap: 18px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.tile:hover,
.answer-button:hover {
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible,
.tile:focus-visible,
.answer-button:focus-visible {
  outline: 3px solid rgba(0, 167, 142, 0.26);
  outline-offset: 2px;
}

.icon-button {
  width: 44px;
  color: var(--accent-dark);
  background: var(--surface);
  border-color: var(--line);
  font-size: 24px;
  box-shadow: 0 8px 22px rgba(18, 28, 45, 0.08);
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 18px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(4, 124, 112, 0.2);
}

.primary-button:hover {
  background: #03695f;
}

.secondary-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.secondary-button:hover {
  border-color: rgba(0, 167, 142, 0.5);
  box-shadow: 0 8px 20px rgba(18, 28, 45, 0.08);
}

.danger-button {
  color: #fff;
  background: var(--danger);
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.timer-panel {
  min-width: 118px;
  padding: 10px 12px;
  text-align: right;
  background: #101828;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(18, 28, 45, 0.16);
}

.timer-panel span {
  display: block;
  color: #a6b4c4;
  font-size: 12px;
  font-weight: 700;
}

.timer-panel strong {
  display: block;
  margin-top: 2px;
  color: #ffffff;
  font-size: 24px;
  line-height: 1;
}

.timer-panel.warning strong {
  color: var(--energy);
}

.stats-panel {
  display: grid;
  gap: 12px;
  padding: 4px 0 2px;
}

.stats-heading,
.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-header {
  align-items: center;
  padding-top: 4px;
}

.section-header p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

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

.stat-card {
  min-height: 88px;
  padding: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 252, 0.96));
  border: 1px solid var(--line);
  border-top: 4px solid var(--info);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(18, 28, 45, 0.08);
}

.stat-card.success {
  border-top-color: var(--success);
}

.stat-card.danger {
  border-top-color: var(--danger);
}

.stat-card.accent {
  border-top-color: var(--accent-2);
}

.stat-card span,
.result-metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong,
.result-metrics strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

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

.history-item {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(18, 28, 45, 0.06);
}

.history-item.passed {
  border-left-color: var(--success);
}

.history-item strong {
  font-size: 14px;
}

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

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

.tile {
  position: relative;
  min-height: 86px;
  overflow: hidden;
  padding: 13px;
  color: var(--text);
  text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 252, 0.98));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(18, 28, 45, 0.08);
  cursor: pointer;
}

.tile::before {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--info));
}

.tile:hover {
  border-color: rgba(0, 167, 142, 0.48);
  box-shadow: 0 14px 28px rgba(18, 28, 45, 0.12);
}

.tile strong {
  display: block;
  font-size: 17px;
  line-height: 1.15;
}

.tile span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.question-tile {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 146px;
  gap: 8px;
  padding: 10px;
}

.question-tile img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--surface-2);
  border-radius: 6px;
}

.question-tile .no-image {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  color: var(--muted);
  background:
    repeating-linear-gradient(
      135deg,
      #edf2f7 0,
      #edf2f7 8px,
      #f7fafc 8px,
      #f7fafc 16px
    );
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.question-tile.answered {
  color: #667085;
  background: #e4e9ef;
  box-shadow: none;
  cursor: default;
}

.question-tile.answered::after {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #fff;
  content: "✓";
  background: var(--success);
  border-radius: 50%;
  font-weight: 900;
}

.question-tile.answered img,
.question-tile.answered .no-image {
  filter: grayscale(1);
  opacity: 0.58;
}

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

.pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 5px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(18, 28, 45, 0.06);
}

.question-view,
.result-view,
.empty-state {
  display: grid;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-view {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.question-image {
  width: 100%;
  max-height: min(48vh, 480px);
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.question-image-placeholder {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

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

.answer-button {
  width: 100%;
  min-height: 54px;
  padding: 12px;
  color: var(--text);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.answer-button.selected {
  background: #ecfffb;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 167, 142, 0.18);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.58);
}

.modal[hidden] {
  display: none;
}

.modal-dialog {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-status {
  padding: 18px;
  color: #fff;
  background: linear-gradient(135deg, #128a55, var(--success));
  border-radius: 8px;
}

.result-status.failed {
  background: linear-gradient(135deg, #b42337, var(--danger));
}

.result-status span {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 4px 8px;
  color: #101828;
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

.result-status h2 {
  font-size: 32px;
}

.result-status p {
  margin-top: 8px;
  font-weight: 700;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 8px 0 2px;
}

.result-metrics div {
  min-width: 0;
  padding: 4px 0 8px;
  border-bottom: 3px solid var(--line);
}

.result-metrics div:nth-child(2) {
  border-bottom-color: var(--success);
}

.result-metrics div:nth-child(3) {
  border-bottom-color: var(--danger);
}

.review-list {
  display: grid;
  gap: 12px;
}

.review-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--danger);
  border-radius: 8px;
}

.review-card strong {
  color: var(--danger);
}

.review-image {
  width: 100%;
  max-height: 340px;
  object-fit: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.review-image-placeholder {
  display: grid;
  min-height: 130px;
  place-items: center;
  color: var(--muted);
  background:
    repeating-linear-gradient(
      135deg,
      #edf2f7 0,
      #edf2f7 8px,
      #f7fafc 8px,
      #f7fafc 16px
    );
  border-radius: 6px;
  font-weight: 800;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: auto 1fr;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 21px;
  }

  .timer-panel {
    grid-column: 1 / -1;
    text-align: left;
  }

  .stats-heading,
  .section-header {
    align-items: flex-start;
  }

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

  .stat-card {
    min-height: 78px;
    padding: 11px;
  }

  .stat-card strong,
  .result-metrics strong {
    font-size: 25px;
  }

  .history-list {
    display: grid;
  }

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

  .tile {
    min-height: 70px;
    padding: 8px;
  }

  .tile strong {
    font-size: 13px;
  }

  .tile span {
    margin-top: 4px;
    font-size: 11px;
  }

  .question-tile {
    min-height: 122px;
    padding: 6px;
  }

  .question-tile.answered::after {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }

  .question-view,
  .result-view,
  .empty-state {
    padding: 12px;
  }

  .result-view {
    padding: 0;
  }

  .result-status h2 {
    font-size: 28px;
  }

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

@media (max-width: 420px) {
  h1 {
    font-size: 25px;
  }

  .stats-heading {
    display: grid;
  }

  .section-header {
    display: grid;
  }

  .stat-card span,
  .result-metrics span {
    font-size: 12px;
  }

  .question-tile {
    min-height: 112px;
  }
}
