:root {
  --bg: #070b14;
  --panel: #1d263d;
  --field: #060a18;
  --text: #f7f9ff;
  --muted: #b9c5e4;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #59c9f7;
  --accent-dark: #2d79ff;
  --ok: #0f8a5f;
  --warn: #ffbf5b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  background: transparent;
  color: #fff;
}

.app-header {
  min-height: 118px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 34px 30px 0;
}

.app-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.app-logo-mark {
  width: 96px;
  height: 72px;
}

.app-logo span {
  color: #168dff;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
}

.app-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px;
}

.client-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.login {
  width: min(618px, calc(100vw - 32px));
  margin: 17vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 48px 40px 40px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  width: 78px;
  height: 58px;
}

.brand-name {
  margin-top: -2px;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  color: #168dff;
}

h1, h2 { margin: 0 0 12px; }
.login h1 {
  text-align: center;
  font-size: 25px;
  margin-bottom: 8px;
}
p { color: var(--muted); }
.login p {
  text-align: center;
  margin-bottom: 20px;
}
label {
  display: block;
  font-weight: 400;
  color: var(--muted);
  margin: 18px 0 8px;
}

input {
  width: 100%;
  height: 45px;
  padding: 10px 14px;
  border: 1px solid #080d1d;
  border-radius: 8px;
  font-size: 16px;
  background: var(--field);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: #2f7cff;
  box-shadow: 0 0 0 3px rgba(47, 124, 255, 0.18);
}

button {
  border: 0;
  border-radius: 999px;
  width: 100%;
  height: 47px;
  padding: 0 16px;
  background: linear-gradient(90deg, #65d3ff, #2f7cff);
  color: #07101d;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

button:hover { filter: brightness(1.04); }
.link-button { float: right; background: transparent; padding: 0; }

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 112px;
  height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #65d3ff, #2f7cff);
  color: #07101d;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.pill-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5) brightness(0.72);
  opacity: 0.72;
}

.media-button {
  flex: 0 0 auto;
  width: auto;
}

.media-section {
  text-align: center;
  margin-bottom: 64px;
}

.media-section h1 {
  font-size: 31px;
  font-weight: 500;
  margin-bottom: 36px;
}

.client-video {
  display: block;
  width: min(1028px, calc(100vw - 64px));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  background: #000;
  border-radius: 0;
}

.media-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 18px auto 0;
  width: min(1028px, calc(100vw - 64px));
}

.video-actions {
  width: min(520px, calc(100vw - 64px));
}

.media-buttons .pill-button {
  min-width: 112px;
  height: 42px;
  font-size: 16px;
}

.exam-viewer {
  position: relative;
  width: min(1140px, calc(100vw - 64px));
  margin: 0 auto;
  background: #000;
  min-height: 520px;
  overflow: hidden;
}

.exam-count {
  position: absolute;
  top: 16px;
  left: 22px;
  color: #c7c7c7;
  font-size: 16px;
  z-index: 2;
}

.viewer-icons {
  position: absolute;
  top: 16px;
  right: 18px;
  color: #b9c5e4;
  font-size: 25px;
  letter-spacing: 14px;
  z-index: 2;
}

.exam-image {
  display: block;
  max-width: 100%;
  max-height: 742px;
  min-height: 520px;
  margin: 0 auto;
  object-fit: contain;
}

.image-actions {
  width: min(1140px, calc(100vw - 64px));
}

.image-toolbar {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 14px 28px;
  width: min(1140px, calc(100vw - 64px));
  margin: 18px auto 0;
}

.image-nav,
.image-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.image-nav {
  padding-right: 28px;
  border-right: 1px solid var(--line);
}

.missing-image {
  display: grid;
  place-items: center;
  min-height: 520px;
  color: var(--muted);
}

.forgot-link {
  display: block;
  color: var(--muted);
  text-align: right;
  margin: 16px 0 18px;
  text-decoration: none;
}

.forgot-link:hover {
  color: #fff;
}

.error {
  padding: 10px 12px;
  border: 1px solid #ffd0d0;
  border-radius: 6px;
  background: rgba(255, 72, 72, 0.12);
  color: #ffd0d0;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

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

.spaced { margin-top: 18px; }

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

.meta div {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.video-box {
  width: 100%;
  background: #000;
  border-radius: 8px;
}

.ok { color: var(--ok); font-weight: 700; }
.warn { color: var(--warn); font-weight: 700; }

.images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef2f7;
}

.image-card small {
  display: block;
  padding: 8px;
  color: var(--muted);
}

#print-sheet {
  display: none;
}

@media (max-width: 820px) {
  .grid, .meta { grid-template-columns: 1fr; }
  .wrap { padding: 16px; }
  body {
    overflow-x: hidden;
  }
  .login {
    margin-top: 9vh;
    padding: 38px 24px 28px;
  }
  .app-header {
    min-height: 82px;
    padding: 16px 16px 0;
    align-items: flex-start;
  }
  .app-logo-mark {
    width: 62px;
    height: 46px;
  }
  .app-logo span {
    font-size: 21px;
  }
  .app-actions {
    margin-top: 10px;
    gap: 8px;
  }
  .app-actions .pill-button {
    min-width: 84px;
    height: 38px;
    font-size: 14px;
    padding: 0 12px;
  }
  .client-wrap {
    max-width: 100%;
    padding: 18px 12px 56px;
  }
  .media-section {
    margin-bottom: 44px;
  }
  .media-section h1 {
    font-size: 27px;
    margin-bottom: 22px;
  }
  .client-video,
  .exam-viewer {
    width: calc(100vw - 24px);
  }
  .exam-viewer,
  .exam-image,
  .missing-image {
    min-height: 300px;
  }
  .media-buttons {
    width: calc(100vw - 24px);
    gap: 8px;
  }
  .video-actions {
    width: calc(100vw - 24px);
  }
  .image-toolbar {
    grid-template-columns: 1fr;
    width: calc(100vw - 24px);
    gap: 12px;
  }
  .image-nav {
    padding-right: 0;
    padding-bottom: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .image-nav,
  .image-tools {
    width: 100%;
  }
  .media-buttons .pill-button {
    min-width: 94px;
    height: 38px;
    font-size: 14px;
    padding: 0 12px;
  }
  .image-toolbar .pill-button {
    min-width: calc(50% - 6px);
    height: 40px;
    font-size: 14px;
  }
  .image-tools .pill-button {
    min-width: calc(33.333% - 8px);
  }
}

@media (max-width: 480px) {
  .app-header {
    padding-inline: 12px;
  }
  .login {
    width: calc(100vw - 24px);
    padding: 34px 20px 26px;
  }
  .client-video {
    width: calc(100vw - 20px);
  }
  .exam-viewer {
    width: calc(100vw - 20px);
    min-height: 260px;
  }
  .exam-image,
  .missing-image {
    min-height: 260px;
    max-height: 72vh;
  }
  .image-toolbar,
  .media-buttons,
  .video-actions {
    width: calc(100vw - 20px);
  }
  .image-tools .pill-button {
    min-width: 100%;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  body.printing-exam > *:not(#print-sheet) {
    display: none !important;
  }

  body.printing-exam {
    background: #fff;
    color: #000;
  }

  body.printing-exam #print-sheet {
    display: block;
  }

  .print-page {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5mm;
    height: calc(297mm - 16mm);
    page-break-after: always;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  .print-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin: 0;
    border: 1px solid #ccc;
    break-inside: avoid;
    overflow: hidden;
  }

  .print-item img {
    width: 100%;
    height: calc(100% - 14px);
    object-fit: contain;
    background: #000;
  }

  .print-item figcaption {
    height: 14px;
    font: 10px Arial, sans-serif;
    text-align: center;
    color: #000;
  }
}
