:root {
  --bg: #eaf1f8;
  --ink: #17202c;
  --ink-soft: #344255;
  --muted: #718095;
  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-soft: rgba(255, 255, 255, 0.38);
  --line: rgba(49, 65, 85, 0.13);
  --line-bright: rgba(255, 255, 255, 0.72);
  --blue: #0a84ff;
  --blue-deep: #075bb5;
  --green: #248a55;
  --amber: #b56a13;
  --red: #c3403b;
  --slate: #242e3b;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-lg: 0 26px 80px rgba(47, 68, 92, 0.18);
  --shadow-md: 0 14px 34px rgba(47, 68, 92, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Montserrat", "Segoe UI", sans-serif;
  background:
    linear-gradient(135deg, rgba(10, 132, 255, 0.16), transparent 34%),
    linear-gradient(225deg, rgba(36, 138, 85, 0.12), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 52%, #dde8f3 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.56), transparent 72%);
}

.shell {
  position: relative;
  width: min(1440px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

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

.hero,
.panel,
.login-panel {
  border: 1px solid var(--line-bright);
  border-bottom-color: var(--line);
  border-radius: var(--radius-xl);
  background: var(--glass);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 18px;
  padding: 30px;
}

.login-panel h1 {
  max-width: none;
}

.login-error {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(195, 64, 59, 0.18);
  border-radius: var(--radius-md);
  background: rgba(195, 64, 59, 0.1);
  color: var(--red);
  font-weight: 700;
}

.hero {
  min-height: 176px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 30px;
  align-items: end;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--blue-deep);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-kicker {
  margin-bottom: 5px;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 16ch;
  font-size: clamp(2.2rem, 4vw, 4.6rem);
  line-height: 0.98;
  font-weight: 800;
}

h2 {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
}

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

.lede {
  max-width: 58ch;
  margin: 14px 0 0;
  line-height: 1.6;
  font-weight: 500;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-actions form {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  margin-top: 18px;
  padding: 20px;
}

.grid .panel {
  margin-top: 0;
}

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

.stats {
  display: grid;
  gap: 10px;
}

.stats-primary,
.stats-secondary {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stats-secondary {
  margin-top: 10px;
}

.stat {
  min-width: 0;
  min-height: 82px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.42)),
    var(--glass-soft);
  box-shadow: var(--shadow-md);
}

.stat span {
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.stat strong {
  min-width: 0;
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.3vw, 1.9rem);
  font-weight: 800;
  line-height: 1.02;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat strong.stat-text {
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.stat-warning strong {
  color: var(--amber);
}

.stat-phase strong {
  text-transform: capitalize;
}

.status-code-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.72fr);
  gap: 10px;
  margin-top: 10px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(140px, 1fr) 110px auto;
  gap: 12px;
  align-items: end;
}

.search-results-panel .search-form {
  margin-bottom: 10px;
}

.search-meta {
  margin: 0 0 14px;
  font-size: 0.86rem;
  font-weight: 650;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-weight: 650;
}

input:focus,
select:focus {
  border-color: rgba(10, 132, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
}

.button {
  min-height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(47, 68, 92, 0.14);
}

.button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.button-primary {
  background: linear-gradient(180deg, #3aa0ff, var(--blue));
  color: #fff;
  box-shadow: 0 12px 26px rgba(10, 132, 255, 0.25);
}

.button-secondary,
.button-ghost {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.button-small {
  min-height: 32px;
  padding: 6px 11px;
  font-size: 0.76rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.52);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(245, 249, 253, 0.92);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(18px);
}

td {
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(10, 132, 255, 0.07);
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

.pill {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(10, 132, 255, 0.12);
  color: var(--blue-deep);
  font-size: 0.72rem;
  font-weight: 800;
}

.pill.success {
  background: rgba(36, 138, 85, 0.14);
  color: var(--green);
}

.pill.warning {
  background: rgba(181, 106, 19, 0.14);
  color: var(--amber);
}

.pill.neutral {
  background: rgba(113, 128, 149, 0.14);
  color: var(--muted);
}

.meta-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.microtext {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.4;
}

.codebox {
  max-height: 220px;
  min-height: 84px;
  margin: 0;
  overflow: auto;
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(31, 41, 55, 0.94);
  color: #edf6ff;
  white-space: pre-wrap;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.codebox-compact {
  min-height: 0;
}

.is-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  animation: spin 800ms linear infinite;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 35, 0.42);
  backdrop-filter: blur(18px);
}

.modal-panel {
  position: relative;
  width: min(900px, calc(100vw - 24px));
  margin: min(8vh, 48px) auto;
  padding: 22px;
  border: 1px solid var(--line-bright);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(16, 24, 35, 0.28);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.preview-stage {
  min-height: 230px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(10, 132, 255, 0.12), rgba(255, 255, 255, 0.38)),
    rgba(255, 255, 255, 0.4);
}

.preview-stage video,
.preview-stage audio {
  width: 100%;
  display: block;
}

.preview-stage video {
  background: #05070a;
}

.preview-stage audio {
  padding: 42px 24px;
}

.preview-empty {
  color: var(--muted);
  font-weight: 700;
}

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

@media (max-width: 1180px) {
  .grid,
  .status-code-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .shell {
    width: min(100% - 20px, 1440px);
    margin-top: 10px;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    flex-direction: column;
    align-items: start;
    padding: 18px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .panel {
    padding: 16px;
  }

  .stats-primary,
  .stats-secondary {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .modal-panel {
    margin: 16px auto;
    padding: 16px;
  }

  .modal-header {
    flex-direction: column;
  }
}
