/* QPBUDDY 360 - application styles (vanilla CSS, no framework) */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1c2733;
  --muted: #64748b;
  --line: #dbe2e9;
  --accent: #0b6bcb;
  --accent-dark: #0857a3;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 22px;
  background: #10202e;
  color: #fff;
}
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.topbar .brand span { color: #7fb3e8; font-weight: 500; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  color: #cfe0ef; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); }
.topbar nav a.active { background: var(--accent); color: #fff; }
.topbar .auth { font-size: 14px; }
.topbar .auth a { color: #cfe0ef; }
.topbar .auth .user { color: #9fb8cc; margin-right: 8px; }

main { max-width: 1180px; margin: 0 auto; padding: 20px; }

.foot {
  max-width: 1180px; margin: 30px auto 40px; padding: 0 20px;
  font-size: 12px; color: var(--muted);
}

/* ---------- components ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,32,46,.05);
}
.card h2 { margin-top: 0; font-size: 18px; }
.card h3 { font-size: 15px; color: var(--muted); margin: 22px 0 8px; text-transform: uppercase; letter-spacing: .4px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-head h2 { margin: 0; }
.card-head h2 a { color: var(--ink); text-decoration: none; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.desc { color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 40px; text-align: center; }

.page-head h1 { margin: 0 0 4px; font-size: 24px; }
.page-head .sub { color: var(--muted); margin: 0 0 12px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  padding: 7px 14px; border-radius: 6px; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line); font-size: 14px;
}
.tabs a:hover { border-color: var(--accent); }
.tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 14px; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #e2e8f0; color: #334155;
}
.badge-ready, .badge-ready_for_calibration { background: #dcfce7; color: #166534; }
.badge-failed, .badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-uploaded, .badge-new { background: #e0f2fe; color: #075985; }
.badge-calibrating, .badge-validating, .badge-extracting, .badge-sampling,
.badge-initialising_slam, .badge-slam_processing, .badge-optimising,
.badge-exporting_trajectory, .badge-generating_previews { background: #fef9c3; color: #854d0e; }

dl.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 16px; margin: 14px 0; }
dl.stats div { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
dl.stats dt { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
dl.stats dd { margin: 2px 0 0; font-weight: 600; }

.alert { padding: 12px 16px; border-radius: var(--radius); margin: 12px 0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ---------- forms ---------- */
label { display: block; margin: 12px 0 4px; font-weight: 500; font-size: 14px; }
input[type=text], input[type=number], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d4f0; border-color: var(--accent); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 180px; }
.form-card { max-width: 720px; }
fieldset { border: 1px dashed var(--line); border-radius: 6px; margin: 14px 0; }
fieldset legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
.inline-form { display: inline-block; margin-top: 8px; }

.auth-card { max-width: 380px; margin: 60px auto; }
.auth-card h1 { margin-top: 0; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.log-error td { color: var(--err); }
.log-warning td { color: var(--warn); }

/* ---------- upload ---------- */
.upload-zone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; cursor: pointer; background: #fafbfc;
  transition: border-color .15s, background .15s;
}
.upload-zone.dragover { border-color: var(--accent); background: #eef6fd; }
.upload-progress { margin: 14px 0; }
.upload-progress .bar, .big-progress, .mini-progress {
  height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden;
}
.upload-progress .bar div, .big-progress div, .mini-progress div {
  height: 100%; background: var(--accent); width: 0; transition: width .3s;
}
.big-progress { height: 18px; margin: 18px 0; }
.mini-progress { height: 6px; margin: 10px 0; }

/* ---------- calibration ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
@media (max-width: 900px) { .cal-layout { grid-template-columns: 1fr; } }
.cal-plan-pane, .cal-side-pane { min-width: 0; }
.pane-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.plan-canvas-wrap {
  position: relative; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; min-height: 320px;
}
.plan-canvas-wrap canvas { display: block; cursor: crosshair; }
.plan-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center; color: var(--muted); font-size: 14px;
}
.cp-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.cp-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 13px;
}
.cp-item.selected { border-color: var(--accent); background: #eef6fd; }
.cal-result { margin-top: 10px; }
.cal-summary { margin-bottom: 12px; }
.cal-quality-Excellent { color: var(--ok); font-weight: 700; }
.cal-quality-Good { color: var(--ok); }
.cal-quality-Acceptable { color: var(--warn); }
.cal-quality-Poor { color: var(--err); font-weight: 700; }

/* ---------- walkthrough ---------- */
.walkthrough { display: flex; flex-direction: column; gap: 10px; }
.wt-pano { position: relative; background: #0b1220; border-radius: var(--radius); overflow: hidden; }
#pano-container, #traj-container { width: 100%; height: 100%; }
#pano-container { height: 52vh; min-height: 320px; }
.pano-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #cfe0ef; font-size: 15px; background: rgba(11,18,32,.6);
}
.pano-hud {
  position: absolute; top: 12px; left: 12px; color: #e2f0fb; background: rgba(11,18,32,.55);
  padding: 5px 10px; border-radius: 6px; font-size: 13px;
}
.pano-controls {
  position: absolute; bottom: 12px; left: 12px; display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; background: rgba(11,18,32,.55); padding: 6px 10px; border-radius: 8px; color: #e2f0fb;
}
.pano-controls .btn { background: #1d2c40; color: #e2f0fb; border-color: #2c4058; }
.pano-controls .muted { color: #cfe0ef; }
.wt-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 900px) { .wt-bottom { grid-template-columns: 1fr; } }
.wt-plan, .wt-3d { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.wt-plan .plan-canvas-wrap, .wt-3d #traj-container { height: 340px; }
.layer-toggles { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }
.layer-toggles label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-weight: 400; }
.wt-status {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; font-size: 14px; font-variant-numeric: tabular-nums;
}
.wt-status .nav-buttons { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- diagnostics ---------- */
.quality-chart { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 14px; min-height: 220px; }

/* ---------- misc ---------- */
.status-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
