:root {
  --bg: #f4efe5;
  --card: #fffaf1;
  --ink: #1f2a1f;
  --accent: #2f7f5f;
  --danger: #7f2f2f;
  --line: #d9ceb8;
}
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top left, #f7f3ea, var(--bg));
  color: var(--ink);
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.brand-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6f7b67;
  margin-bottom: 4px;
}
.brand-title {
  margin: 0;
  font-size: 28px;
  color: #223526;
}
.brand-subtitle {
  margin: 6px 0 0;
  color: #5b685d;
}
.wrap {
  max-width: 100%;
  margin: 24px auto;
  padding: 0 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
  margin-bottom: 16px;
}
.title {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--accent);
}
.muted {
  margin: 0 0 12px;
  color: #4e5d52;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.treatment-fields {
  display: block;
  margin-top: 10px;
}
.treatment-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.treatment-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}
.treatment-table th,
.treatment-table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: middle;
}
.treatment-table th {
  background: #f5f1e7;
  font-weight: 700;
}
.treatment-table td:first-child,
.treatment-table th:first-child {
  text-align: center;
}
.treatment-table.cols-4 th,
.treatment-table.cols-4 td {
  width: 25%;
}
.treatment-table.cols-5 th,
.treatment-table.cols-5 td {
  width: 20%;
}
.treatment-table input[type=text],
.treatment-table textarea,
.treatment-table input[type=file] {
  width: 100%;
  box-sizing: border-box;
  height: 42px;
  margin: 0;
}
.treatment-table textarea {
  min-height: 42px;
  resize: none;
  padding-top: 10px;
}
.treatment-table input[type=file] {
  padding: 6px 8px;
}
@media (max-width: 900px) {
  .treatment-table th,
  .treatment-table td {
    padding: 6px;
    font-size: 13px;
  }
  .treatment-table input[type=text],
  .treatment-table textarea,
  .treatment-table input[type=file] {
    height: 38px;
  }
  .treatment-table input[type=file] {
    font-size: 12px;
  }
}
@media (max-width: 640px) {
  .treatment-table-wrap {
    overflow-x: auto;
  }
  .treatment-table {
    min-width: 640px;
  }
}
input[type=file] {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
button {
  background: var(--accent);
  border: 0;
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
.secondary-btn,
.nav-link,
.google-login-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 10px 14px;
}
.secondary-btn,
.nav-link {
  background: #edf4ee;
  color: #214630;
}
.nav-link-cta,
.google-login-btn {
  background: var(--accent);
  color: #fff;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 6px;
}
.user-listing {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}
.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #d7eadb;
  color: #214630;
  font-weight: 700;
}
.user-name {
  font-weight: 700;
}
.user-email {
  color: #58675c;
  font-size: 13px;
}
.error {
  border: 1px solid #d9a5a5;
  background: #ffecec;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.flash {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.flash-info {
  background: #edf4ee;
  border-color: #bfd2c3;
  color: #214630;
}
.flash-success {
  background: #e8f7eb;
  border-color: #a6d5ad;
  color: #1f5a28;
}
.flash-warning {
  background: #fff5de;
  border-color: #e8cd7b;
  color: #745611;
}
.flash-error {
  background: #ffecec;
  border-color: #e2b3b3;
  color: #7f2f2f;
}
.login-card {
  max-width: 560px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-title {
  margin: 0;
  font-size: 22px;
  color: #223526;
}
.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-label {
  color: #627064;
  font-size: 13px;
}
.stat-value {
  font-size: 34px;
  font-weight: 700;
  color: #223526;
}
.table-scroll {
  overflow-x: auto;
}
.admin-table th,
.admin-table td {
  text-align: left;
  vertical-align: top;
}
.admin-actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}
.badge-admin {
  background: #d8ebdb;
  color: #1f5a28;
}
.badge-user {
  background: #ece5d5;
  color: #6f5417;
}
.badge-active {
  background: #e8f7eb;
  color: #1f5a28;
}
.badge-inactive {
  background: #f3dede;
  color: #7f2f2f;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: right;
}
th:first-child, td:first-child {
  text-align: center;
}
.result-object-table .object-id-col {
  text-align: center;
}
img {
  max-width: 520px;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.compare-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.compare-col img {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: contain;
}
.sync-processed {
  cursor: crosshair;
}
.sync-threshold {
  cursor: crosshair;
  -webkit-user-drag: none;
  user-select: none;
}
.sync-wrap {
  position: relative;
  display: block;
  width: 100%;
  flex: 1;
  min-height: 300px;
}
.click-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.click-corner-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.click-label-point {
  position: absolute;
  min-width: 14px;
  height: 11px;
  padding: 0 3px;
  border-radius: 7px;
  background: rgba(230, 32, 32, 0.96);
  border: 1px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.26);
  color: #fff;
  font-size: 8px;
  line-height: 1;
  text-align: center;
  font-weight: 600;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
}
.click-corner-point {
  position: absolute;
  min-width: 18px;
  height: 14px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(255, 170, 0, 0.95);
  border: 1px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.38);
  color: #111;
  font-size: 10px;
  line-height: 1;
  text-align: center;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  pointer-events: auto;
  cursor: grab;
  user-select: none;
}
.sync-cursor {
  position: absolute;
  width: 14px;
  height: 20px;
  transform: translate(-2px, -2px);
  display: none;
  pointer-events: none;
  z-index: 5;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 30'><path d='M3 2 L3 24 L9.6 18.2 L13.8 27.8 L17 26.3 L12.8 16.8 L21 16.8 Z' fill='white' stroke='%23777' stroke-width='1.6' stroke-linejoin='round' stroke-linecap='round'/></svg>");
}
@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
  }
  .topbar-actions {
    justify-content: flex-start;
  }
  .admin-summary-grid {
    grid-template-columns: 1fr;
  }
}
.threshold-drag-box {
  position: absolute;
  border: 2px dashed #e02020;
  background: rgba(224, 32, 32, 0.18);
  pointer-events: none;
  z-index: 6;
}
.threshold-drag-box.is-include {
  border-color: #1b8a4f;
  background: rgba(27, 138, 79, 0.18);
}
body.drag-selecting {
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.pre-top-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.pre-top-row > * {
  min-width: 0;
}
.compare-row {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(360px, 1.15fr) minmax(300px, 1fr) minmax(300px, 1fr);
  gap: 10px;
  align-items: stretch;
  min-width: 1380px;
  min-height: 360px;
}
.analysis-main-row {
  display: block;
  overflow-x: auto;
}
.visual-pane {
  min-width: 0;
}
.pre-controls-col {
  min-width: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}
.info-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.pane-caption {
  font-size: 12px;
  color: #4e5d52;
  margin-bottom: 4px;
}
.controls-pre {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pre-controls-col .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  min-width: 0;
}
.pre-controls-col .ctrl {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  justify-content: space-between;
}
.pre-controls-col .ctrl input[type=range] {
  min-width: 0;
}
.metrics {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.metrics-text {
  padding: 1px 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
a.download {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
}
.is-hidden {
  display: none;
}
.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}
.mode-select-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.mode-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.mode-item input[type=checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
}
.results-container {
  display: block;
}
.treatment-tabs-wrap {
  display: block;
}
.treatment-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.treatment-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
}
.treatment-tab.is-active {
  border-color: var(--accent);
  background: #eaf6f0;
  color: var(--accent);
  font-weight: 700;
}
.treatment-panel {
  display: none;
}
.treatment-panel.is-active {
  display: block;
}
.treatment-panel-head {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  margin-bottom: 10px;
}
.analysis-layout {
  display: block;
}
.image-pane {
  width: 100%;
  max-width: none;
}
.control-pane {
  flex: 1 1 360px;
  min-width: 320px;
  max-width: 460px;
}
.control-pane .ctrl {
  min-width: 200px;
  justify-content: space-between;
}
.control-pane input[type=range] {
  width: 120px;
}
.ml-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.ml-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}
.ml-label {
  font-size: 12px;
  color: #4e5d52;
  margin-bottom: 6px;
}
@media (max-width: 980px) {
  .compare-row {
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(260px, 1fr) minmax(260px, 1fr);
    min-height: 320px;
  }
}
