:root {
  --shell: #080e18;
  --surface: #101927;
  --surface-raised: #142032;
  --surface-soft: #0c1522;
  --border: #2a384d;
  --border-strong: #3a4c66;
  --gold: #f2b643;
  --cyan: #52b5cf;
  --success: #53d2a2;
  --danger: #f26b70;
  --copy: #f4f7fb;
  --copy-muted: #9cabbf;
}

html { background: var(--shell); }
body {
  color: var(--copy);
  background-color: var(--shell);
  background-image:
    linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.014) 1px, transparent 1px),
    radial-gradient(circle at 78% -20%, rgba(45,91,122,.22), transparent 34%);
  background-size: 40px 40px, 40px 40px, auto;
}

body, button, input, select { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { min-height: 44px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.panel {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(18,28,43,.98), rgba(13,22,35,.98));
  box-shadow: 0 14px 34px rgba(0,0,0,.2);
}

.eyebrow { color: var(--gold); font-size: .68rem; letter-spacing: .17em; }
.hint, .muted { color: var(--copy-muted); line-height: 1.55; }

/* Login */
.auth-shell {
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 430px);
  gap: clamp(48px, 9vw, 150px);
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(36px, 7vw, 110px);
}
.auth-brand { max-width: 760px; }
.auth-brand h1 { max-width: 11ch; font-size: clamp(3rem, 6vw, 6rem); line-height: .98; }
.auth-brand > p { max-width: 570px; line-height: 1.7; }
.auth-wordmark { margin-bottom: clamp(38px, 8vh, 90px); }
.auth-wordmark img { filter: drop-shadow(0 14px 32px rgba(242,182,67,.15)); }
.auth-features { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 28px; }
.auth-features span { padding: 8px 11px; border: 1px solid var(--border); border-radius: 6px; color: #c8d3e1; background: rgba(15,25,39,.65); font-size: .78rem; }
.auth-panel { padding: clamp(24px, 3vw, 36px); border-top: 3px solid var(--gold); }
.auth-panel h2 { font-size: 1.7rem; }

/* Main frame */
.app-shell { grid-template-columns: 264px minmax(0, 1fr); }
aside { width: 264px; padding: 24px 16px 20px; background: rgba(7,13,23,.98); }
.brand { padding: 0 9px 25px; border-bottom: 1px solid #202c3d; }
.brand strong { font-size: 1.02rem; letter-spacing: .02em; }
.brand small { margin-top: 3px; font-size: .62rem; font-weight: 700; letter-spacing: .13em; }
nav { gap: 5px; margin-top: 20px; }
.nav {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 10px;
  border-radius: 8px;
  color: #aab8c9;
  font-size: .88rem;
  font-weight: 650;
}
.nav:before { content: none !important; }
.nav-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #304056;
  border-radius: 7px;
  color: #c2cfdd;
  background: #101b2a;
  font-size: 1rem;
}
.nav:hover, .nav.active { color: #fff; background: #172337; }
.nav.active { box-shadow: inset 3px 0 var(--gold); }
.nav.active .nav-icon { color: #1a1203; border-color: var(--gold); background: var(--gold); }
.account { padding: 17px 10px 0; }
.account strong { font-size: .86rem; }
.account small { margin-top: 2px; font-size: .74rem; }

.workspace { max-width: 1760px; padding: clamp(20px, 2.2vw, 36px); }
.workspace > header { min-height: 68px; margin-bottom: 20px; padding-bottom: 18px; border-bottom: 1px solid rgba(74,91,116,.45); }
.workspace h1 { font-size: clamp(1.65rem, 2.4vw, 2.25rem); letter-spacing: -.025em; }
.workspace h2 { font-size: clamp(1.18rem, 1.7vw, 1.48rem); }
.header-actions { gap: 10px; }
.system-pill { min-width: 156px; justify-content: flex-start; padding: 8px 13px; border-radius: 8px; }
.system-pill > span { display: grid; line-height: 1.2; }
.system-pill small { color: #7f91a7; font-size: .58rem; font-weight: 750; letter-spacing: .13em; }
.system-pill strong { color: #dce6f1; font-size: .78rem; font-weight: 700; }
.header-logout { min-height: 42px; border-radius: 8px; box-shadow: none; }

/* Inspection */
.toolbar { min-height: 78px; align-items: center; margin-bottom: 16px; padding: 13px 18px; }
.toolbar label { min-width: min(510px, 65%); margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .04em; }
.profile-state { display: grid; justify-items: end; gap: 2px; text-align: right; }
.profile-state > span { color: #7f91a7; font-size: .59rem; font-weight: 800; letter-spacing: .14em; }
.model-state { color: #dce6f1; font-size: .82rem; }
.station-grid { grid-template-columns: minmax(0, 1.55fr) minmax(340px, .7fr); gap: 16px; }
.camera-panel, .result-panel { min-width: 0; }
.panel-head { align-items: center; }
.panel-head h2 { margin-bottom: 0; }
.tag { border-radius: 6px; }
.video-wrap { margin: 15px 0; border-color: #3b4c64; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.02); }
.video-empty span { color: #53667d; }
.video-empty p { font-size: .9rem; }
.fullscreen-button { border-radius: 7px; }
.camera-panel > .button-row { display: grid; grid-template-columns: repeat(4, minmax(0, auto)); justify-content: start; }
.camera-panel > .button-row button { white-space: nowrap; }
.auto-box { border-radius: 9px; background: #0c1623; }
.result-panel { min-height: 0; }
.empty-result { min-height: 390px; height: auto; }
.empty-result span { width: 62px; height: 62px; margin: 0 auto 8px; display: grid; place-items: center; border: 1px solid #34465e; border-radius: 50%; color: #71849b; font-size: 2rem; }
.empty-result p { font-size: 1.05rem; }
.decision { border-radius: 9px; font-size: clamp(1.3rem, 2vw, 1.65rem); }
.photo { border-radius: 8px; }
.margins span { border: 1px solid rgba(62,79,103,.55); border-radius: 7px; }

/* Management areas */
.cal-grid { gap: 16px; }
.step-card, .camera-state, .role-description, .count-grid div, .models > div, .user-row, .record { border-radius: 8px; }
.count-grid div { border: 1px solid rgba(57,74,98,.55); }
.models > div, .user-row { background: #0c1623; }
.sample-button { border-radius: 8px; }
.zone-row input { min-width: 0; }
.error, .notice { border-radius: 7px; }

/* Tablet */
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  aside { width: 220px; padding-inline: 12px; }
  .brand { padding-inline: 7px; }
  .brand-logo { width: 40px; height: 40px; flex-basis: 40px; }
  .nav { grid-template-columns: 32px 1fr; padding-inline: 8px; font-size: .8rem; }
  .nav-icon { width: 28px; height: 28px; }
  .station-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: 0; }
  .empty-result { min-height: 230px; }
}

@media (max-width: 860px) {
  .app-shell { display: block; }
  aside {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: 8px 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,.24);
  }
  .brand { padding: 0 12px 0 0; border: 0; }
  .brand-logo { width: 34px; height: 34px; flex-basis: 34px; }
  .brand div, .account { display: none; }
  nav { display: flex; gap: 5px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  .nav { min-width: max-content; grid-template-columns: 26px auto; min-height: 42px; padding: 5px 9px; font-size: .72rem; white-space: nowrap; }
  .nav-icon { width: 25px; height: 25px; font-size: .82rem; }
  .workspace { padding: 18px; }
  .workspace > header { min-height: 60px; }
  .cal-grid, .calibration-camera-grid { grid-template-columns: 1fr; }
  .record { grid-template-columns: 108px minmax(0,1fr) !important; }
}

/* Phone */
@media (max-width: 620px) {
  aside { padding: 7px 8px; grid-template-columns: auto minmax(0,1fr); }
  .brand { padding-right: 7px; }
  .nav { grid-template-columns: 24px auto; padding-inline: 7px; }
  .nav-icon { width: 23px; height: 23px; }
  .workspace { padding: 12px; }
  .workspace > header { align-items: flex-start; gap: 13px; margin-bottom: 14px; padding-bottom: 14px; }
  .workspace > header .eyebrow { display: none; }
  .workspace h1 { font-size: 1.48rem; }
  .header-actions { width: 100%; }
  .system-pill { min-width: 0; flex: 1; }
  .header-logout { padding-inline: 10px; font-size: .75rem; }
  .toolbar { gap: 12px; padding: 12px; }
  .toolbar label { min-width: 100%; }
  .profile-state { justify-items: start; text-align: left; }
  .panel { padding: 14px; }
  .panel-head { align-items: flex-start; }
  .camera-panel > .button-row { grid-template-columns: 1fr 1fr; }
  .camera-panel > .button-row button { width: 100%; padding-inline: 9px; font-size: .78rem; }
  .auto-box { align-items: stretch; }
  .auto-box button { width: 100%; }
  .video-wrap { margin-block: 12px; }
  .fullscreen-button { right: 8px; bottom: 8px; padding: 8px 10px; font-size: .72rem; }
  .empty-result { min-height: 190px; }
  .calibration-class-buttons { grid-template-columns: 1fr; }
  .zone-row { grid-template-columns: 28px 1fr 1fr; }
  .record { grid-template-columns: 88px minmax(0,1fr) !important; }
  .record-thumb { width: 88px; min-height: 118px; }
  .record-content { padding: 12px; }
  .record-title { align-items: flex-start; flex-direction: column; gap: 7px; }
  .auth-shell { padding: 22px 16px; gap: 28px; }
  .auth-brand h1 { font-size: clamp(2.35rem, 13vw, 3.5rem); }
  .auth-wordmark { margin-bottom: 28px; }
  .auth-features { display: none; }
}

@media (max-width: 390px) {
  .nav > span:last-child { display: none; }
  .nav { min-width: 37px; grid-template-columns: 1fr; justify-items: center; padding-inline: 6px; }
  .header-logout { font-size: 0; }
  .header-logout span { font-size: 1.15rem; }
  .camera-panel > .button-row { grid-template-columns: 1fr; }
}
