
:root {
  color-scheme: dark;
  --bg: #111315;
  --panel: #191d21;
  --panel-2: #20262b;
  --text: #f2f5f7;
  --muted: #9aa6af;
  --line: #303841;
  --accent: #4fb3ff;
  --good: #47d18c;
  --warn: #f0b84f;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 0 26px;
  border-bottom: 1px solid var(--line);
}

h1 { margin: 0; font-size: 30px; }
h2 { margin: 28px 0 14px; font-size: 18px; color: var(--muted); }
p { color: var(--muted); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }

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

button, .button, input[type="text"], input[type="email"], input[type="password"], input[type="file"] {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 14px;
  font: inherit;
}

button, .button { cursor: pointer; }

button:hover, .button:hover { border-color: var(--accent); }
button.danger { border-color: rgba(255, 107, 107, 0.45); color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button:disabled { cursor: not-allowed; opacity: 0.55; }
button[hidden] { display: none; }

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

.job-overview {
  display: grid;
  gap: 18px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.status-badge.status-ok {
  border-color: rgba(71, 209, 140, 0.5);
  color: var(--good);
}

.status-badge.status-warn {
  border-color: rgba(240, 184, 79, 0.5);
  color: var(--warn);
}

.status-badge.status-bad {
  border-color: rgba(255, 107, 107, 0.55);
  color: var(--bad);
}

.status-badge.status-active {
  border-color: rgba(79, 179, 255, 0.55);
  color: var(--accent);
}

.status-badge-compact {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.job-issue {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(240, 184, 79, 0.48);
  border-radius: 8px;
  background: rgba(240, 184, 79, 0.08);
}

.job-issue[hidden] {
  display: none;
}

.job-issue.is-critical {
  border-color: rgba(255, 107, 107, 0.58);
  background: rgba(255, 107, 107, 0.08);
}

.job-issue.is-warning {
  border-color: rgba(240, 184, 79, 0.52);
}

.job-issue-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.issue-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid rgba(240, 184, 79, 0.5);
  border-radius: 999px;
  color: var(--warn);
  background: rgba(17, 19, 21, 0.45);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.job-issue.is-critical .issue-badge {
  border-color: rgba(255, 107, 107, 0.58);
  color: var(--bad);
}

.job-issue h2,
.job-issue h3,
.job-issue p {
  margin: 0;
}

.job-issue h2 {
  color: var(--text);
  font-size: 18px;
}

.job-issue h3 {
  color: #c6d0d8;
  font-size: 12px;
  text-transform: uppercase;
}

.job-issue-body {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr);
  gap: 16px;
}

.issue-steps {
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.issue-diagnostics summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.issue-diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-sections {
  display: grid;
  gap: 18px;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.card > h2:first-child,
.detail-section h2 {
  margin: 0;
}

.job-progress-output {
  display: grid;
  gap: 18px;
}

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

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-top: 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
}

.metric span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.metric strong { font-size: 18px; word-break: break-word; }
.metric small { display: block; color: var(--muted); margin-top: 8px; word-break: break-word; }

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(48, 56, 65, 0.78);
}

.section-heading h2 {
  margin-top: 0;
  color: var(--text);
}

.section-heading .notice {
  margin-bottom: 0;
}

.results-section {
  padding: 20px;
  background: #121820;
  border-color: rgba(64, 76, 88, 0.9);
}

.results-section.is-ready {
  border-color: rgba(71, 209, 140, 0.42);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.result-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 264px;
  gap: 12px;
  padding: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(32, 42, 52, 0.96), rgba(24, 31, 38, 0.96));
  border: 1px solid rgba(64, 76, 88, 0.86);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--result-accent, var(--accent));
  opacity: 0.9;
}

.result-card.is-disabled {
  background: rgba(28, 36, 44, 0.72);
}

.result-card-report { --result-accent: #ff6b6b; --result-accent-rgb: 255, 107, 107; }
.result-card-model { --result-accent: #4fb3ff; --result-accent-rgb: 79, 179, 255; }
.result-card-pointcloud { --result-accent: #7c8cff; --result-accent-rgb: 124, 140, 255; }
.result-card-ortho { --result-accent: #f0b84f; --result-accent-rgb: 240, 184, 79; }
.result-card-zip { --result-accent: #47d18c; --result-accent-rgb: 71, 209, 140; }

.result-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  min-width: 42px;
  height: 42px;
  border: 1px solid rgba(var(--result-accent-rgb, 79, 179, 255), 0.62);
  border-radius: 8px;
  background: rgba(var(--result-accent-rgb, 79, 179, 255), 0.16);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.result-card h3 {
  min-height: 44px;
  margin: 0;
  color: var(--text);
  font-size: 17px;
  line-height: 1.25;
}

.result-card p {
  min-height: 66px;
  margin: 0;
  font-size: 14px;
}

.result-card small {
  display: grid;
  gap: 4px;
  min-height: 52px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.result-card small span {
  color: #c6d0d8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.availability-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 19, 24, 0.72);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.availability-badge.status-ok {
  border-color: rgba(71, 209, 140, 0.5);
  background: rgba(71, 209, 140, 0.1);
}
.availability-badge.status-warn {
  border-color: rgba(240, 184, 79, 0.5);
  background: rgba(240, 184, 79, 0.1);
}
.availability-badge.status-bad {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.result-action {
  width: 100%;
  margin-top: auto;
  text-align: center;
  border-color: rgba(var(--result-accent-rgb, 79, 179, 255), 0.5);
  background: rgba(15, 19, 24, 0.64);
}

.result-action:not(:disabled):hover {
  border-color: var(--result-accent, var(--accent));
}
.muted { color: var(--muted); }

.status-ok { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:last-child td { border-bottom: 0; }

tr.row-failed td {
  background: rgba(255, 107, 107, 0.045);
}

.table-issue-hint {
  display: inline-block;
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.table-issue-hint.has-issue {
  color: var(--bad);
}

.notice {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
}

.progress-wrap {
  margin-top: 16px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 8px;
}

.progress-head strong { color: var(--text); }

.progress-track {
  position: relative;
  width: 100%;
  height: 12px;
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.progress-track.is-processing::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  width: 42%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.07) 32%, rgba(255, 255, 255, 0.22) 50%, rgba(255, 255, 255, 0.07) 68%, transparent 100%);
  transform: translateX(-160%);
  animation: progress-shimmer 3.6s linear infinite;
  pointer-events: none;
}

.progress-bar {
  position: relative;
  z-index: 1;
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease;
}

@keyframes progress-shimmer {
  from { transform: translateX(-160%); }
  to { transform: translateX(340%); }
}

.form-row,
.upload-panel {
  display: grid;
  gap: 10px;
}

.form-row {
  grid-template-columns: minmax(140px, 180px) minmax(220px, 1fr) auto;
  align-items: center;
}

label {
  color: var(--muted);
  font-size: 14px;
}

input[type="file"] { width: 100%; }


.advanced-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.advanced-actions {
  margin-top: 14px;
}

.advanced-panel .result {
  margin-top: 14px;
}

.result {
  min-height: 120px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
}

@media (max-width: 640px) {
  main { width: min(100% - 20px, 1080px); padding-top: 18px; }
  header { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 24px; }
  .form-row { grid-template-columns: 1fr; }
  .status-row { align-items: flex-start; flex-direction: column; }
  .job-issue-header { flex-direction: column; }
  .job-issue-body { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: 1fr; }
  .results-section { padding: 16px; }
  .section-heading { padding-bottom: 14px; }
  .result-card { min-height: 0; }
  .result-card h3, .result-card p, .result-card small { min-height: 0; }
}

.account-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.account-button {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(560px, calc(100vw - 32px));
  padding: 18px 54px 18px 18px;
  border: 1px solid rgba(79, 179, 255, 0.24);
  border-radius: 8px;
  background: #15191d;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.46);
}

.account-menu[hidden],
.account-profile[hidden],
.account-auth-panel[hidden],
.account-method-panel[hidden],
.account-choice-panel[hidden],
.account-signed-in-actions[hidden],
.account-form label[hidden],
.account-form input[hidden],
.account-actions button[hidden],
.account-secondary-actions button[hidden] {
  display: none !important;
}

.account-menu-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.account-menu-head strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}

.account-menu-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.account-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(203, 213, 225, 0.55);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  font-size: 24px;
  line-height: 1;
}

.account-close:hover {
  border-color: rgba(248, 250, 252, 0.86);
  background: rgba(30, 41, 59, 0.98);
}

.account-state {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-beta {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 107, 107, 0.58);
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.12);
  color: #fecaca;
  font-size: 11px;
  font-weight: 900;
}

.account-profile {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 38, 43, 0.7);
}

.account-profile img,
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(79, 179, 255, 0.16);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.account-profile span {
  display: block;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.account-profile small {
  color: var(--muted);
}

.account-access {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.account-access.is-active {
  border: 1px solid rgba(60, 214, 133, 0.48);
  background: rgba(60, 214, 133, 0.12);
  color: #bbf7d0;
}

.account-access.is-blocked {
  border: 1px solid rgba(255, 107, 107, 0.58);
  background: rgba(255, 107, 107, 0.12);
  color: #fecaca;
}

.account-access.is-unknown {
  border: 1px solid rgba(245, 193, 108, 0.55);
  background: rgba(245, 193, 108, 0.12);
  color: #fde68a;
}

.account-access-warning {
  display: block;
  margin-top: 6px;
}

.account-auth-panel {
  display: grid;
  gap: 12px;
}

.account-choice-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.account-choice-card {
  display: grid;
  gap: 6px;
  min-height: 132px;
  padding: 14px;
  text-align: center;
  border-color: rgba(64, 76, 88, 0.86);
  background: rgba(32, 38, 43, 0.72);
}

.account-choice-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.account-choice-card strong {
  color: var(--text);
  font-size: 15px;
}

.account-choice-card small {
  color: var(--muted);
  line-height: 1.35;
}

.account-method-panel {
  display: grid;
  gap: 12px;
}

.account-method-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-method-head strong {
  color: var(--text);
  font-size: 15px;
}

.account-method-head button {
  padding: 7px 10px;
}

.account-form {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(32, 38, 43, 0.58);
}

.account-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.account-form input[type="email"],
.account-form input[type="password"],
.account-form input[type="text"] {
  width: 100%;
}

.account-actions {
  margin-top: 8px;
}

.account-actions button {
  flex: 1 1 auto;
}

.account-secondary-actions {
  display: flex;
  justify-content: center;
}

.account-secondary-actions button {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  padding: 6px 8px;
}

.account-terms {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.account-message {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
}

.account-message.is-error {
  color: var(--bad);
}

.account-message.is-info {
  color: var(--good);
}

@media (max-width: 640px) {
  .account-shell { width: 100%; }
  .account-button { max-width: 100%; }
  .account-menu {
    position: fixed;
    top: 76px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100vh - 96px);
    overflow: auto;
  }
  .account-choice-panel { grid-template-columns: 1fr; }
}
