:root {
  color-scheme: dark;
  --bg: #070b0c;
  --bg-soft: #0d1415;
  --surface: #11191a;
  --surface-2: #182223;
  --surface-3: #223033;
  --line: rgba(220, 228, 229, 0.11);
  --line-strong: rgba(0, 229, 255, 0.3);
  --text: #edf7f8;
  --muted: #a9b9bc;
  --faint: #6f8185;
  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.12);
  --accent-text: #00272d;
  --success: #65d6ad;
  --warning: #f1c75b;
  --danger: #ff8f85;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --header-height: 72px;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(0, 229, 255, 0.06), transparent 32%),
    linear-gradient(180deg, #070b0c 0%, #0d1415 52%, #070b0c 100%);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
a,
input,
textarea,
select {
  min-width: 0;
}

img {
  max-width: 100%;
  display: block;
}

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  line-height: 1;
}

.app-body {
  padding-top: var(--header-height);
}

.app-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 clamp(18px, 4vw, 48px);
  background: rgba(7, 11, 12, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}

.brand,
.autopilot-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Manrope", system-ui, sans-serif;
  font-weight: 800;
  font-size: 22px;
}

.brand-icon,
.brand .material-symbols-outlined,
.autopilot-brand .material-symbols-outlined {
  color: var(--accent);
  filter: drop-shadow(0 0 14px rgba(0, 229, 255, 0.42));
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}

.header-nav a {
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  transition: color 180ms ease, background 180ms ease;
}

.header-nav a:hover,
.header-nav a.is-active {
  color: var(--text);
  background: var(--accent-soft);
}

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

.logout-form {
  margin: 0;
}

.logout-text {
  display: none;
}

.icon-button,
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
}

.icon-button {
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease;
}

.icon-button:hover {
  color: var(--accent);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.avatar {
  border: 1px solid var(--line-strong);
  background: linear-gradient(135deg, var(--surface-3), var(--surface));
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.page-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 32px;
}

.page-hero.narrow {
  display: block;
  max-width: 720px;
}

.page-hero h1,
.case-title-row h1,
.login-card h2,
.autopilot-stage h1 {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.08;
}

.page-hero h2,
.recent-cases h2,
.control-panel h2,
.comparison-header h2,
.edit-panel h2,
.current-session h2,
.security-callout h2 {
  margin: 0;
  font-family: "Manrope", system-ui, sans-serif;
}

.page-hero p,
.case-title-row p,
.login-card p,
.autopilot-stage p {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.07);
}

.button.primary {
  border-color: rgba(0, 229, 255, 0.7);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  box-shadow: 0 14px 32px rgba(0, 229, 255, 0.2);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.03);
}

.button.danger {
  color: var(--danger);
  border-color: rgba(255, 143, 133, 0.28);
  background: rgba(255, 143, 133, 0.06);
}

.button.full {
  width: 100%;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip,
.pill-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 9px 13px;
  cursor: pointer;
}

.chip.active,
.chip:hover,
.pill-button:hover {
  color: var(--accent);
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.complete {
  color: var(--success);
  border: 1px solid rgba(101, 214, 173, 0.32);
  background: rgba(101, 214, 173, 0.1);
}

.status-pill.processing {
  color: var(--warning);
  border: 1px solid rgba(241, 199, 91, 0.32);
  background: rgba(241, 199, 91, 0.1);
}

.status-pill.failed {
  color: var(--danger);
  border: 1px solid rgba(255, 143, 133, 0.32);
  background: rgba(255, 143, 133, 0.1);
}

.clinical-photo {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 20%),
    linear-gradient(90deg, #8b5f56 0 8%, #f2dfcf 8% 15%, #fff8ec 15% 23%, #f0d7c4 23% 31%, #fff8ed 31% 40%, #e9cdbb 40% 48%, #fff8ed 48% 58%, #eed4c0 58% 68%, #fff8ed 68% 77%, #e8cbb8 77% 85%, #8a5d56 85% 100%);
  box-shadow: inset 0 -50px 70px rgba(36, 13, 10, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.clinical-photo::before,
.clinical-photo::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.clinical-photo::before {
  top: 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(88, 38, 34, 0.72), rgba(123, 60, 53, 0.15), transparent);
}

.clinical-photo::after {
  bottom: 26%;
  height: 1px;
  background: rgba(90, 47, 39, 0.35);
}

.clinical-photo.teeth-b {
  filter: saturate(0.9) brightness(0.92);
}

.clinical-photo.teeth-c {
  filter: saturate(0.95) brightness(1.12);
}

.clinical-photo.muted {
  filter: grayscale(0.3) brightness(0.66);
}

.scanner {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.scanner::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 18%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
  animation: scan 2.8s ease-in-out infinite;
}

@keyframes scan {
  0%, 100% { transform: translateY(-60px); opacity: 0; }
  20%, 80% { opacity: 0.85; }
  50% { transform: translateY(260px); }
}

@media (max-width: 900px) {
  :root {
    --mobile-header-gap: 10px;
    --mobile-nav-height: 52px;
  }

  .app-shell {
    width: min(100% - 32px, 780px);
    padding-top: 22px;
  }

  .site-header {
    left: 12px;
    right: 12px;
    top: 10px;
    width: auto;
    height: var(--header-height);
    padding-inline: 14px;
    border: 1px solid rgba(220, 228, 229, 0.13);
    border-radius: 16px;
    background:
      linear-gradient(135deg, rgba(0, 229, 255, 0.1), transparent 42%),
      rgba(7, 11, 12, 0.74);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(0, 229, 255, 0.03);
    backdrop-filter: blur(22px) saturate(1.18);
  }

  .header-nav {
    order: 3;
    position: fixed;
    left: 12px;
    right: 12px;
    top: calc(10px + var(--header-height) + var(--mobile-header-gap));
    height: var(--mobile-nav-height);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    gap: 4px;
    padding: 5px;
    border-color: rgba(220, 228, 229, 0.13);
    border-radius: 15px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025)),
      rgba(8, 13, 14, 0.76);
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(18px) saturate(1.15);
    overflow: hidden;
  }

  .header-nav a {
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
  }

  .header-nav a.is-active {
    color: var(--accent);
    border: 1px solid rgba(0, 229, 255, 0.24);
    background: rgba(0, 229, 255, 0.13);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 18px rgba(0, 229, 255, 0.08);
  }

  .app-body {
    padding-top: calc(10px + var(--header-height) + var(--mobile-header-gap) + var(--mobile-nav-height) + 18px);
  }

  .page-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 560px) {
  :root {
    --header-height: 64px;
  }

  .app-shell {
    width: min(100% - 24px, 480px);
    padding-bottom: 48px;
  }

  .header-actions .icon-button {
    width: auto;
    min-width: 80px;
    height: 38px;
    display: inline-flex;
    gap: 6px;
    border-radius: 999px;
    padding: 0 11px;
    color: var(--danger);
    border-color: rgba(255, 143, 133, 0.22);
    background: rgba(255, 143, 133, 0.08);
  }

  .brand {
    font-size: 20px;
  }

  .logout-text {
    display: inline;
    font-size: 12px;
    font-weight: 800;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .page-hero h1,
  .case-title-row h1,
  .login-card h2,
  .autopilot-stage h1 {
    font-size: 34px;
  }
}

@media (max-width: 390px) {
  .header-nav a {
    font-size: 12px;
    padding-inline: 3px;
  }

  .brand {
    gap: 7px;
    font-size: 18px;
  }

  .header-actions {
    gap: 7px;
  }

  .header-actions .icon-button {
    min-width: 72px;
    padding-inline: 9px;
  }
}
