/* FAM2 admin web app
 *
 * Palette and typeface follow the FAM / BEUMER Group Color Guide:
 *   background 213/213/213 · lines 075/075/075 · primary blue 000/157/224
 *   accents 255/153/000 and 255/204/102 · Arial
 * The greys and the blue were verified against the supplied logo artwork.
 */

:root {
  /* --- FAM / BEUMER Color Guide --- */
  --fam-bg: #d5d5d5;          /* 213,213,213 - drawing ground */
  --fam-line: #4b4b4b;        /*  75, 75, 75 - drawing lines, primary text */
  --fam-blue: #009de0;        /*   0,157,224 - primary */
  --fam-blue-dark: #0079ad;   /* darker step, for text on light and hovers */
  --fam-blue-light: #4cbceb;  /* the tint used inside the logo */
  --fam-orange: #ff9900;      /* 255,153,  0 - accent */
  --fam-sand: #ffcc66;        /* 255,204,102 - accent */

  /* --- surfaces derived from the guide --- */
  --bg: #e8e8e8;
  --bg-elevated: #ffffff;
  --bg-panel: #f2f2f2;
  --bg-input: #ffffff;
  --border: #c9c9c9;
  --border-strong: #a8a8a8;
  --text: var(--fam-line);
  --text-muted: #6f6f6f;

  --accent: var(--fam-blue);
  --accent-hover: var(--fam-blue-dark);
  --danger: #f44336;
  --warning: var(--fam-orange);
  --success: #4caf50;
  --info: var(--fam-blue);

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 8px 24px rgba(75, 75, 75, 0.18);
  --sidebar-width: 400px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Arial, Helvetica, "Liberation Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* ---------- buttons & fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover { background: #e4e4e4; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--fam-blue);
  color: #ffffff;
  font-weight: 700;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg-panel); color: var(--text); }

.btn-danger { background: transparent; border-color: #e0b4b0; color: #c0392b; }
.btn-danger:hover { background: #fbeceb; }

.btn-small { padding: 5px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.plus { font-size: 17px; line-height: 1; }

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}
.icon-btn:hover { color: var(--text); }

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  background: #fbeceb;
  border: 1px solid #e0b4b0;
  border-radius: var(--radius-sm);
  color: #c0392b;
  font-size: 13px;
}

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

/* ---------- login ---------- */

.login-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f4f4f4 0%, var(--fam-bg) 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 28px; }
.brand-mark { width: 168px; height: auto; display: block; margin: 0 auto 10px; }
.login-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- app shell ---------- */

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.topbar-brand img { height: 26px; width: auto; display: block; }
.topbar-brand em {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.breadcrumb {
  flex: 1;
  color: var(--text-muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb b { color: var(--text); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-chip {
  font-size: 13px;
  color: var(--text-muted);
  padding: 5px 11px;
  background: var(--bg-panel);
  border-radius: 999px;
}

.view { flex: 1; overflow: auto; }

/* ---------- structures list ---------- */

#structures-view { padding: 28px 24px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.card {
  position: relative;
  padding: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }

.card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  padding-right: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card .card-file { font-size: 12px; color: var(--text-muted); margin: 0 0 14px; }

.card-stats { display: flex; gap: 18px; }
.card-stat { display: flex; flex-direction: column; }
.card-stat strong { font-size: 18px; font-weight: 700; }
.card-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.card-delete {
  position: absolute;
  top: 12px;
  right: 10px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .card-delete { opacity: 1; }

.empty-state { text-align: center; padding: 70px 20px; }
.empty-state h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
.empty-state p { margin: 0 0 20px; color: var(--text-muted); }

/* ---------- viewer ---------- */

.viewer { display: flex; overflow: hidden; }

.canvas-wrap { position: relative; flex: 1; min-width: 0; background: var(--fam-bg); }
#dxf-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }

.canvas-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(6px);
}

.tool-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}
.tool-btn:hover { background: var(--bg-panel); }
.zoom-label { padding: 0 8px; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.toolbar-divider { width: 1px; height: 20px; background: var(--border); }

.tool-btn-wide {
  width: auto;
  gap: 7px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
}
.tool-btn-wide:hover { color: var(--text); }
.tool-btn-wide.active { color: var(--fam-blue-dark); background: rgba(0, 157, 224, 0.12); }

.check-box {
  width: 13px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
}
.tool-btn-wide.active .check-box { background: var(--accent); border-color: var(--accent); }
.tool-btn-wide.active .check-box::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 3px;
  height: 7px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ---------- selection ---------- */

.selection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.selection-summary { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.selection-summary strong { font-size: 15px; }

.plate-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
  max-height: 118px;
  overflow-y: auto;
}

.plate-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 5px 3px 9px;
  background: rgba(0, 157, 224, 0.12);
  border: 1px solid rgba(0, 157, 224, 0.45);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  cursor: pointer;
}
.plate-chip:hover { background: rgba(0, 157, 224, 0.22); }

.chip-remove {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  border-radius: 50%;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.65;
}
.chip-remove:hover { opacity: 1; background: rgba(0, 0, 0, 0.3); }

.canvas-hint {
  position: absolute;
  bottom: 14px;
  left: 14px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.canvas-legend {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  backdrop-filter: blur(6px);
}
.legend-row { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }
.legend-row b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: auto; }

.canvas-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: var(--fam-bg);
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sidebar ---------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.sidebar-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-head p { margin: 3px 0 0; font-size: 12px; }

.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.badge-count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 4px;
  background: var(--bg-panel);
  border-radius: 999px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.tab-panel { flex: 1; overflow-y: auto; padding: 18px 20px 28px; }

.panel-placeholder { text-align: center; padding: 48px 10px; color: var(--text-muted); }
.placeholder-icon { font-size: 34px; opacity: 0.35; margin-bottom: 10px; }
.panel-placeholder p { margin: 0 0 6px; font-weight: 500; color: var(--text); }
.panel-placeholder small { font-size: 12.5px; }

/* category picker */

.category-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
}
.category-chip:hover { border-color: var(--border-strong); color: var(--text); }
.category-chip.active { color: var(--text); border-color: currentColor; }
.category-chip .dot { width: 9px; height: 9px; border-radius: 50%; }

/* photos */

.photos-block { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.photos-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.photos-head h3 { margin: 0; font-size: 14px; font-weight: 600; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.photo-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.photo-thumb:hover .photo-remove { opacity: 1; }
.photo-thumb.uploading { display: grid; place-items: center; }

/* annotation list */

.filter-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }

.annotation-list { display: flex; flex-direction: column; gap: 10px; }

.annotation-item {
  padding: 13px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}
.annotation-item:hover { border-color: var(--border-strong); }
.annotation-item.active { background: #1f2733; }

.annotation-item-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.annotation-item-head .plate-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.annotation-item-head strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.annotation-item p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.annotation-item-foot {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.plate-annotations { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.plate-annotations h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }

.item-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(75, 75, 75, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  backdrop-filter: blur(3px);
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; }

.dropzone {
  padding: 26px 16px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: #101c21; }
.dropzone-icon { font-size: 26px; color: var(--text-muted); margin-bottom: 8px; }
.dropzone p { margin: 0 0 4px; font-size: 13.5px; }
.dropzone small { color: var(--text-muted); font-size: 12px; }

.dropzone-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13.5px;
}
.dropzone-file .file-name { font-weight: 600; }

.progress {
  height: 5px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

/* ---------- lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 6, 0.93);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 40px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); }
.lightbox-close { position: absolute; top: 16px; right: 22px; font-size: 34px; color: #fff; }

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 11px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  max-width: 340px;
  animation: toast-in 0.18s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .viewer { flex-direction: column; }
  .canvas-wrap { height: 55vh; flex: none; }
  .sidebar { width: 100%; border-left: none; border-top: 1px solid var(--border); flex: 1; }
  .canvas-legend { display: none; }
  .breadcrumb { display: none; }
}

/* ---------- clients ---------- */

#clients-view { padding: 28px 24px 40px; max-width: 1120px; width: 100%; margin: 0 auto; }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }

.data-table { width: 100%; border-collapse: collapse; background: var(--bg-elevated); font-size: 14px; }
.data-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--text-muted); }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.pill-on { background: rgba(76, 175, 80, 0.14); color: #2e7d32; }
.pill-off { background: rgba(75, 75, 75, 0.08); color: var(--text-muted); }

/* registration code */

.created-name { margin: 0 0 6px; font-size: 16px; font-weight: 600; }

.code-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 20px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
}
.code-box code {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  letter-spacing: 0.09em;
  color: var(--accent);
  word-break: break-all;
}

/* ---------- report ---------- */

.sidebar-report { margin-top: 10px; }

.modal-wide { max-width: 860px; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; }

.report-body { max-height: 74vh; overflow-y: auto; }

.report-pick { display: flex; flex-direction: column; gap: 8px; }
.report-pick button {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.report-pick button:hover { border-color: var(--accent); }
.report-pick .when { color: var(--text-muted); font-size: 12.5px; margin-left: auto; }

.report-head { margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.report-head h3 { margin: 0 0 4px; font-size: 20px; font-weight: 650; }
.report-head p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.report-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}
.report-stat { background: var(--bg-panel); padding: 13px 15px; }
.report-stat strong { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.report-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

.report-plate {
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
  break-inside: avoid;
}
.report-plate:last-child { border-bottom: none; }
.report-plate-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.report-plate-head .num { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.report-plate-head .status { padding: 2px 9px; border-radius: 4px; font-size: 11.5px; font-weight: 700; color: #fff; }
.report-plate-head .done { margin-left: auto; font-size: 12px; color: #2e7d32; font-weight: 600; }
.report-plate-head .pending { margin-left: auto; font-size: 12px; color: var(--warning); font-weight: 600; }

.report-field { margin: 6px 0; font-size: 13.5px; }
.report-field b { color: var(--text-muted); font-weight: 600; margin-right: 6px; }

.report-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.report-photos img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
}

@media print {
  body * { visibility: hidden; }
  #report-modal, #report-modal * { visibility: visible; }
  #report-modal {
    position: absolute;
    inset: 0;
    background: #fff;
    padding: 0;
    display: block;
    backdrop-filter: none;
  }
  .modal, .modal-wide {
    max-width: none;
    border: none;
    box-shadow: none;
    background: #fff;
    color: #111;
  }
  .modal-head-actions, .icon-btn { display: none !important; }
  .report-body { max-height: none; overflow: visible; }
  .report-stat, .report-head, .report-plate { background: #fff; color: #111; }
  .report-stat span, .report-head p, .report-field b { color: #555; }
}

/* ---------- administration ---------- */

#admin-view { padding: 28px 24px 40px; max-width: 1120px; width: 100%; margin: 0 auto; }
.admin-tabs { border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.admin-h3 { font-size: 14px; font-weight: 700; margin: 0 0 10px; }
#admin-team section, #admin-team .table-scroll { margin-bottom: 26px; }
#pending-block { margin-bottom: 26px; }
.admin-actions { display: flex; justify-content: flex-end; margin-bottom: 14px; }

.role-select, .select-input {
  padding: 6px 9px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.select-input { width: 100%; padding: 10px 12px; font-size: 14px; }
.role-select:focus, .select-input:focus { outline: none; border-color: var(--fam-blue); }

.color-input {
  width: 64px;
  height: 38px;
  padding: 3px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.data-table td.right { text-align: right; }

/* ---------- topology tree ---------- */

.structures-layout {
  display: grid;
  grid-template-columns: 268px 1fr;
  gap: 22px;
  align-items: start;
}

.topology {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
.topology-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 4px;
}
.topology-head h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.topology-tree { font-size: 13.5px; }

.tnode { user-select: none; }
.tnode-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
}
.tnode-row:hover { background: var(--bg-panel); }
.tnode-row.selected { background: rgba(0, 157, 224, 0.14); color: var(--fam-blue-dark); font-weight: 600; }

.tnode-caret {
  width: 14px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.15s;
}
.tnode-caret.open { transform: rotate(90deg); }
.tnode-caret.leaf { visibility: hidden; }

.tnode-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnode-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
}
.tnode-children { margin-left: 13px; border-left: 1px solid var(--border); padding-left: 5px; }
.tnode-children.hidden { display: none; }

.tleaf .tnode-label { color: var(--text); }
.tleaf .tnode-row::before {
  content: '▪';
  color: var(--fam-blue);
  font-size: 11px;
}

.topology-empty { padding: 14px 6px; color: var(--text-muted); font-size: 13px; }
.topology-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  padding-left: 4px;
}

.admin-tree {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 12px;
  margin-bottom: 26px;
}
.admin-tree .tnode-row { justify-content: flex-start; }
.node-actions { display: flex; gap: 6px; margin-left: auto; opacity: 0; }
.tnode-row:hover .node-actions { opacity: 1; }
.node-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 3px;
}
.node-actions button:hover { background: var(--bg-panel); color: var(--text); }
.node-actions .danger:hover { color: var(--danger); }

.level-badge {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-panel);
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .structures-layout { grid-template-columns: 1fr; }
  .topology { position: static; max-height: 320px; }
}

/* ---------- embedded preparation guide ---------- */

.prep-guide {
  border: 1px solid var(--border);
  border-left: 3px solid var(--fam-orange);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  padding: 0;
  margin-bottom: 16px;
}
.prep-guide summary {
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.prep-guide summary::-webkit-details-marker { display: none; }
.prep-guide summary::before {
  content: '▶';
  display: inline-block;
  font-size: 9px;
  margin-right: 8px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.prep-guide[open] summary::before { transform: rotate(90deg); }

.prep-lede, .prep-check {
  margin: 0 14px 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.prep-check { padding-top: 10px; border-top: 1px solid var(--border); }

.prep-list { margin: 0 14px 12px; padding-left: 18px; font-size: 13px; }
.prep-list li { margin-bottom: 7px; color: var(--text-muted); }
.prep-list b { color: var(--text); font-weight: 600; }
.prep-list code { font-size: 11.5px; white-space: normal; }
.pill-provider { background: rgba(0, 157, 224, 0.14); color: var(--fam-blue-dark); }

/* ---------- mobile app download ---------- */

.page-head-actions { display: flex; align-items: center; gap: 10px; }
.dl-icon { font-size: 15px; line-height: 1; }
.dl-size { margin-left: 2px; }
#download-app { white-space: nowrap; }

/* ---------- requirement matrix ---------- */

/* The admin forms sit at 1120px; the matrix has two prose columns and needs more */
#requirements-view { padding: 28px 24px 40px; max-width: 1560px; width: 100%; margin: 0 auto; }

.req-lede { max-width: 78ch; margin: 0 0 18px; line-height: 1.6; }

.req-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.req-stat {
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
}
.req-stat strong { display: block; font-size: 22px; line-height: 1.2; }
.req-stat span { font-size: 11.5px; color: var(--text-muted); }
.req-stat-total { background: var(--bg-panel); }

.req-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.req-filter-group { display: flex; align-items: center; gap: 10px; }
.req-filter-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.req-filters .category-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.req-filters .category-chip { padding: 5px 10px; font-size: 12.5px; }

.req-group { margin-bottom: 30px; }

.req-table { font-size: 13px; }
.req-table td { vertical-align: top; padding: 14px 16px; }
.req-table th:nth-child(1), .req-table td:nth-child(1) { width: 96px; }
.req-table th:nth-child(2), .req-table td:nth-child(2) { width: 24%; }
.req-table th:nth-child(5), .req-table td:nth-child(5) { width: 118px; }

.req-id .mono { display: block; font-weight: 600; color: var(--text); font-size: 12.5px; }
.req-priority {
  display: inline-block;
  margin-top: 5px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  cursor: help;
}

.req-title strong { display: block; font-weight: 600; line-height: 1.45; }
.req-source {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.req-impl { line-height: 1.55; color: var(--text-muted); }
.req-status .pill { white-space: nowrap; }

@media (max-width: 900px) {
  #requirements-view { max-width: 100%; }
  .req-table { min-width: 900px; }
}

@media print {
  /* The default print rules target the report modal; the matrix opts in */
  body.printing-req * { visibility: hidden; }
  body.printing-req #requirements-view,
  body.printing-req #requirements-view * { visibility: visible; }
  body.printing-req #requirements-view {
    position: absolute;
    inset: 0;
    background: #fff;
    color: #111;
    padding: 0;
  }
  body.printing-req .req-filters { display: none !important; }
  body.printing-req .table-scroll { overflow: visible; border: none; }
  body.printing-req .req-group { break-inside: auto; }
  body.printing-req .req-table tr { break-inside: avoid; }
  body.printing-req .req-impl,
  body.printing-req .req-source { color: #555; }
}

/* ---------- condition layer (RF-014) ---------- */

.layer-switch { display: flex; gap: 2px; }
.layer-switch .tool-btn {
  width: auto;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.layer-switch .tool-btn:hover { color: var(--text); }
.layer-switch .tool-btn.active {
  color: var(--fam-blue-dark);
  background: rgba(0, 157, 224, 0.12);
}

.toolbar-select {
  max-width: 240px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}

.legend-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  max-width: 230px;
}
.legend-foot {
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}
.legend-row-muted { opacity: 0.75; }
.legend-dot-empty {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
}

/* inspection record in the selection panel */

.plate-condition {
  margin: 0 0 20px;
  padding: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.plate-condition h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
}

.condition-item {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.condition-item:first-of-type { border-top: none; padding-top: 0; }
.condition-item p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.condition-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.condition-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 7px;
}
.condition-item-empty { display: flex; align-items: center; gap: 8px; }

#condition-open-report { margin-top: 12px; }

@media (max-width: 900px) {
  /* The toolbar grew with the layer switch; let it wrap instead of overflowing
     the canvas on a tablet */
  .canvas-toolbar { flex-wrap: wrap; max-width: calc(100% - 28px); }
  .toolbar-select { max-width: 160px; }
}

/* ---------- editable condition scale (RF-021) ---------- */

.scale-note {
  max-width: 78ch;
  margin: 0 0 18px;
  padding: 10px 12px;
  background: var(--bg-panel);
  border-left: 3px solid var(--fam-orange);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}
.scale-note code, #scale-empty code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(75, 75, 75, 0.1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.scale-pt {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

#scale-rows .row-actions .btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* ---------- equipment properties (RF-044) ---------- */

.structure-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }

.structure-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.card .structure-tag { margin-bottom: 6px; }

.structure-description {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

.sidebar-head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- inspection task number and round notes (RF-024) ---------- */

.report-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.task-id {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.report-round-notes {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: var(--bg-panel);
  border-left: 3px solid var(--fam-blue);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.report-head .btn { margin-top: 10px; }

@media print {
  .no-print { display: none !important; }
}

/* ---------- equipment search (RF-060) ---------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 0 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-bar:focus-within { border-color: var(--accent); }
.search-icon { font-size: 17px; color: var(--text-muted); }
.search-bar input {
  flex: 1;
  padding: 11px 0;
  border: none;
  background: none;
  color: var(--text);
  font: inherit;
  outline: none;
}
.search-bar input::-webkit-search-cancel-button { display: none; }

.search-empty { padding: 18px 2px; }

.tnode-row.matched {
  background: rgba(0, 157, 224, 0.1);
  border-radius: var(--radius-sm);
}

/* ---------- viewport overview (RF-012) ---------- */

.canvas-overview {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 190px;
  height: 140px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: crosshair;
}
.canvas-overview canvas { width: 100%; height: 100%; display: block; }

.overview-frame {
  position: absolute;
  border: 1.5px solid var(--fam-blue);
  background: rgba(0, 157, 224, 0.12);
  pointer-events: none;
  min-width: 4px;
  min-height: 4px;
}

@media (max-width: 900px) {
  .canvas-overview { display: none; }
}

/* ---------- interface language (RF-080) ---------- */

.lang-select {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.lang-select:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- structures still being processed ---------- */

.card-queued, .card-processing { border-style: dashed; }
.card-failed { border-color: rgba(244, 67, 54, 0.4); }

.card-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 2px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.45;
}
.card-status b { font-size: 12.5px; }
.card-status span { color: var(--text-muted); flex-basis: 100%; }

.card-status-working { background: rgba(0, 157, 224, 0.08); }
.card-status-working b { color: var(--fam-blue-dark); }
.card-status-failed { background: rgba(244, 67, 54, 0.08); }
.card-status-failed b { color: #c62828; }

.spinner-sm {
  width: 13px;
  height: 13px;
  border-width: 2px;
  margin: 0;
}

/* ---------- inline guidance in forms ---------- */

.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.field-intro {
  margin: 0 0 18px;
  padding: 11px 13px;
  background: var(--bg-panel);
  border-left: 3px solid var(--fam-blue);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
}
.field-intro b { color: var(--text); }

.card-progress {
  flex-basis: 100%;
  height: 4px;
  margin-top: 6px;
  background: rgba(0, 157, 224, 0.18);
  border-radius: 2px;
  overflow: hidden;
}
.card-progress-bar {
  height: 100%;
  background: var(--fam-blue);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ---------- the guide ---------- */

#guide-view { padding: 28px 24px 40px; max-width: 1180px; width: 100%; margin: 0 auto; }
.guide-lede { max-width: 76ch; margin: 0 0 20px; line-height: 1.6; }

.guide-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.guide-role {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--role);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.guide-role-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--role); }

.guide-stage { margin-bottom: 34px; }
.guide-stage-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.guide-stage-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--fam-line);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
}
.guide-stage-head h3 { margin: 0 0 3px; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.guide-stage-head p { max-width: 74ch; }

.guide-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  padding-left: 44px;
}

.guide-step {
  display: flex;
  gap: 12px;
  padding: 16px 17px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--role);
  border-radius: var(--radius);
}
.guide-step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--role);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.guide-step-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.guide-step-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.guide-step-head h4 { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -0.005em; }
.guide-actor {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--role);
  white-space: nowrap;
}
.guide-where {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  color: var(--text-muted);
}
.guide-what { margin: 0; font-size: 13.5px; line-height: 1.55; }
.guide-result {
  margin: 4px 0 0;
  padding: 8px 10px;
  background: var(--bg-panel);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}
.guide-result b {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 2px;
}

@media (max-width: 900px) {
  .guide-steps { padding-left: 0; }
}

@media print {
  body.printing-req #guide-view { display: none !important; }
}

.guide-app-note { margin: -18px 0 26px; }
