:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1c2733;
  --muted: #5c6b7a;
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --danger: #d33;
  --warn-bg: #fff6e5;
  --warn-border: #f0d9a8;
  --info-bg: #eaf2ff;
  --info-border: #c5dcff;
  --err-bg: #fdeaea;
  --err-border: #f2b8b8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

.topbar {
  background: #12263a;
  color: #fff;
  padding: 18px 28px;
}

.brand { display: flex; align-items: center; gap: 14px; max-width: 1200px; margin: 0 auto; }
.logo { font-size: 28px; }
.brand h1 { margin: 0; font-size: 20px; }
.tagline { margin: 2px 0 0; font-size: 13px; opacity: 0.8; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

h2 { margin: 0 0 14px; font-size: 17px; }
h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.hint { font-size: 12px; color: var(--muted); margin: 8px 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; }
.divider { border-top: 1px solid var(--border); margin: 16px 0; }
.scope { font-size: 13px; margin: 0 0 12px; }
.warning {
  font-size: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 10px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--info-bg); }
.dropzone p { margin: 4px 0; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 0; }
.thumb {
  position: relative;
  width: 130px;
  height: 130px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .rm {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.thumb .cap {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 16px;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 14px;
}

.error {
  color: var(--danger);
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  border-radius: 6px;
  padding: 10px;
  margin-top: 12px;
  font-size: 13px;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 18px; height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
@media (max-width: 700px) { .metrics { grid-template-columns: 1fr; } }
.metric {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 18px; font-weight: 700; }

.info {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 14px;
}
.card .title { font-weight: 700; margin-bottom: 4px; }
.card .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .body { font-size: 13px; }
.card .cap { font-size: 12px; color: var(--muted); margin-top: 6px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge.high { background: #fdeaea; color: #b02a2a; }
.badge.moderate { background: #fff6e5; color: #a05c00; }
.badge.low { background: #e9f7ec; color: #1e7a34; }
.badge.indeterminate { background: #eef1f4; color: #55606b; }
.badge.observation_only { background: #eef1f4; color: #55606b; }
.badge.immediate { background: #fdeaea; color: #b02a2a; }
.badge.normal { background: #eef1f4; color: #55606b; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 8px 0 16px;
}
th, td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
}
th { background: #f8fafc; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }

.plain { margin: 8px 0 16px; padding-left: 20px; }
.plain li { margin-bottom: 4px; font-size: 14px; }

.path {
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 2px;
}
.qual { font-size: 12px; color: var(--muted); margin-bottom: 10px; }

details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 10px 0;
}
summary { cursor: pointer; font-size: 14px; color: var(--accent); }

#actionPriority { margin-top: 16px; }
.action {
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 15px;
}
.action.immediate { background: var(--err-bg); color: #b02a2a; border: 1px solid var(--err-border); }
.action.prompt { background: var(--warn-bg); color: #a05c00; border: 1px solid var(--warn-border); }
.action.routine { background: var(--info-bg); color: #0d4ea8; border: 1px solid var(--info-border); }
.action.none { background: #eef1f4; color: #55606b; border: 1px solid var(--border); }

#fieldReport { font-size: 14px; }
#fieldReport h2 { margin-bottom: 14px; }
#fieldReport h3 { margin-top: 20px; }
#fieldReport .action { margin-top: 12px; }
.metric .v.small { font-size: 14px; font-weight: 600; line-height: 1.4; }

#techDetails { border: none; padding: 0; margin: 0 0 20px; }
#techDetails > summary {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 14px;
  margin-bottom: 16px;
}
#techDetails .tech-body { padding-top: 4px; }
#techDetails .panel { border: 1px solid var(--border); }
