:root {
  color-scheme: dark;
  --bg: #071016;
  --panel: rgba(13, 28, 38, 0.72);
  --panel-strong: rgba(16, 38, 52, 0.92);
  --line: rgba(128, 223, 255, 0.2);
  --text: #ecfbff;
  --muted: #94aeb8;
  --cyan: #49d8ff;
  --green: #52f0b0;
  --violet: #a88cff;
  --danger: #ff6d8a;
}

* { box-sizing: border-box; }

html {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(73, 216, 255, 0.18), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(82, 240, 176, 0.12), transparent 25%),
    linear-gradient(135deg, #071016 0%, #0a1820 48%, #0c111a 100%);
  color: var(--text);
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

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

button {
  border: 0;
  border-radius: 8px;
  color: #031018;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

button.danger {
  color: white;
  background: rgba(255, 109, 138, 0.18);
  border: 1px solid rgba(255, 109, 138, 0.35);
}

input, textarea, select {
  width: 100%;
  color: var(--text);
  background: rgba(3, 16, 24, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

.login-panel, .panel, .card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.login-panel {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: 12px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 36px rgba(73, 216, 255, 0.45);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.brand p, .muted {
  margin: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
}

.mobile-topbar,
.menu-backdrop {
  display: none;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(4, 12, 18, 0.72);
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav {
  display: grid;
  gap: 10px;
  margin-top: 28px;
  min-width: 0;
}

.nav button {
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav button.active, .nav button:hover {
  border-color: var(--line);
  background: rgba(73, 216, 255, 0.08);
}

.content {
  padding: 26px;
  display: grid;
  gap: 22px;
  align-content: start;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
}

.grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

.card, .panel {
  border-radius: 10px;
  padding: 18px;
  min-width: 0;
}

.metric-value {
  display: block;
  font-size: 34px;
  font-weight: 900;
  color: var(--cyan);
}

.two-col {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

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

.full { grid-column: 1 / -1; }

.drop {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(73, 216, 255, 0.45);
  background: rgba(73, 216, 255, 0.06);
  border-radius: 10px;
  padding: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.mobile-exam-list {
  display: none;
}

th, td {
  text-align: left;
  padding: 11px 8px;
  border-bottom: 1px solid rgba(128, 223, 255, 0.12);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  color: #031018;
  background: var(--green);
}

.status.error { background: var(--danger); color: white; }
.status.processing { background: var(--violet); color: white; }

.report {
  white-space: pre-wrap;
  line-height: 1.55;
  color: #d9f6ff;
  overflow-x: auto;
  max-width: 100%;
}

.loader-box {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(73, 216, 255, 0.35);
  border-radius: 10px;
  background: rgba(73, 216, 255, 0.05);
}

.pulse-loader {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 4px solid rgba(73, 216, 255, 0.18);
  border-top-color: var(--cyan);
  border-right-color: var(--green);
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 34px rgba(73, 216, 255, 0.28);
}

.loader-box strong {
  display: block;
  margin-bottom: 7px;
  font-size: 18px;
}

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

.endpoint-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 16, 24, 0.42);
}

.endpoint-item code {
  display: block;
  margin-top: 8px;
  color: var(--green);
  word-break: break-all;
}

.manual-list {
  margin: 0;
  padding-left: 20px;
  color: #d9f6ff;
  line-height: 1.7;
}

.manual-list li + li {
  margin-top: 7px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.api-key {
  word-break: break-all;
  color: var(--green);
}

.hidden { display: none; }

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: 0;
    left: 0;
    width: min(82vw, 300px);
    max-width: 300px;
    height: 100vh;
    padding: 18px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    backdrop-filter: blur(18px);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
  }

  .mobile-topbar {
    position: sticky;
    z-index: 18;
    top: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100vw;
    max-width: 100vw;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(4, 12, 18, 0.92);
    backdrop-filter: blur(18px);
  }

  .mobile-topbar .brand {
    margin-bottom: 0;
    min-width: 0;
  }

  .mobile-topbar .brand h1,
  .mobile-topbar .brand p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-topbar .secondary {
    flex: 0 0 auto;
  }

  .menu-backdrop {
    position: fixed;
    z-index: 19;
    inset: 0;
    display: none;
    padding: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.52);
  }

  body.menu-open .menu-backdrop {
    display: block;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

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

  .brand p {
    font-size: 13px;
  }

  .nav {
    display: grid;
    gap: 9px;
    margin-top: 20px;
    overflow: visible;
    padding-bottom: 0;
  }

  .nav button {
    min-height: 38px;
    padding: 9px 12px;
    white-space: normal;
    font-size: 11px;
  }

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

  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
    gap: 16px;
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

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

  .topbar h2 {
    font-size: 24px;
  }

  .card,
  .panel {
    padding: 15px;
  }

  .drop {
    min-height: 126px;
  }

  .actions button {
    flex: 1 1 130px;
  }

  .desktop-table {
    display: none;
  }

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

  .mobile-exam-card {
    display: grid;
    gap: 9px;
    padding: 12px;
    border: 1px solid rgba(128, 223, 255, 0.12);
    border-radius: 8px;
    background: rgba(3, 16, 24, 0.34);
  }

  .mobile-exam-card div {
    min-width: 0;
    display: grid;
    gap: 3px;
  }

  .mobile-exam-card span:first-child {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-exam-card b {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
    font-weight: 500;
  }
}

@media (max-width: 560px) {
  .login-shell {
    padding: 14px;
  }

  .login-panel {
    padding: 22px;
  }

  .content {
    padding: 12px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 29px;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .panel h3,
  .card h3 {
    font-size: 17px;
  }

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

  .report {
    font-size: 12px;
  }

  .endpoint-item {
    padding: 12px;
  }

  .manual-list {
    padding-left: 18px;
  }
}
