/* ── SCAN & NAVIGATION BOXES ── */
.scan-box {
    border: 1px solid #bbb;
    border-radius: 6px;
    padding: 10px 14px;
    background: #f0f4ff;
    font-family: sans-serif;
    font-size: 13px;
    margin-top: 14px;
    max-width: 560px;
}

.origin-calibration h3 {
    margin: 0 0 8px;
    color: #1a237e;
    font-size: 1.15em;
}

.origin-calibration summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid #99aac2;
    border-radius: 4px;
    background: white;
    color: #254569;
    cursor: pointer;
    font-weight: 600;
}

.origin-calibration summary::-webkit-details-marker { display: none; }

.origin-calibration summary::before {
    content: "";
    width: 6px;
    height: 6px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: rotate(-45deg);
}

.origin-calibration details[open] > summary::before { transform: rotate(45deg); }

.scan-box b {
    color: #1a237e;
}

#scan_box .scannowbutton:disabled {
    background: #e4e8ee;
    color: #505b69;
    cursor: default;
}

#scan_box .scannowbutton.active-scan {
    background: #174b84;
    color: white;
    box-shadow: inset 0 -3px 0 #8cc8ff;
}

.scan-running {
    background: #fff8e1 !important;
    border-color: #f9a825 !important;
}

#scan_progress {
    color: #1565C0;
    font-style: italic;
    font-size: 12px;
    margin-top: 4px;
    min-height: 1.2em;
}

#schedule-next {
    margin: 0 0 12px;
    color: #163e69;
}
#schedule-remaining {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ── 6-WELL STAGE NAVIGATION ── */
#nav_box {
    background: #f8faf8;
    border-color: #a5d6a7;
    max-width: 620px;
}

.nav-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.nav-box-header b {
    color: #1b5e20;
}

.nav-box-header small {
    color: #555;
}

/* ── 6-WELL PLATE POSITION MAP ── */
#plate-map-wrapper {
    background: #ffffff;
    border: 1px solid #c5e1a5;
    border-radius: 6px;
    padding: 8px 10px 6px;
    margin-bottom: 8px;
}

.plate-map-stage {
    position: relative;
    width: 100%;
}

.plate-map-svg {
    width: 100%;
    height: auto;
    display: block;
}

.plate-map-svg text {
    user-select: none;
}

.pm-plot-bg {
    fill: #fafcff;
    stroke: #90a4ae;
    stroke-width: 1.2;
    stroke-dasharray: 5 3;
}

.pm-grid-line {
    stroke: #cfd8dc;
    stroke-width: 0.7;
    opacity: 0.7;
}

.pm-grid-axis {
    stroke: #90a4ae;
    stroke-width: 1;
    opacity: 0.85;
}

.pm-axis-tick {
    fill: #546e7a;
    font-size: 10px;
    font-family: monospace;
}

.pm-axis-label {
    fill: #607d8b;
    font-size: 10px;
    font-family: sans-serif;
}

.pm-well-circle {
    fill: #1565c0;
    fill-opacity: 0.08;
    stroke: #1565c0;
    stroke-width: 1.4;
    stroke-opacity: 0.65;
}

.pm-well-circle.is-scanning {
    fill-opacity: 0.04;
}

.pm-well-label {
    fill: #1a237e;
    font-size: 11px;
    font-weight: 700;
    font-family: sans-serif;
    opacity: 0.75;
}

.pm-tile {
    fill: #1976d2;
    fill-opacity: 0.14;
    stroke: #1976d2;
    stroke-width: 0.6;
    stroke-opacity: 0.35;
    cursor: pointer;
}

.pm-tile.is-center {
    fill: #f59e0b;
    fill-opacity: 0.52;
    stroke: #d97706;
    stroke-width: 1.1;
    stroke-opacity: 0.95;
}

.pm-tile.is-hovered {
    stroke-width: 1.8;
    stroke-opacity: 1;
}

.pm-tile.is-locked {
    cursor: default;
}

.pm-tile.is-upcoming {
    fill: #1976d2;
    fill-opacity: 0.10;
    stroke: #1976d2;
    stroke-opacity: 0.24;
}

.pm-tile.is-done {
    fill: #2e7d32;
    fill-opacity: 0.38;
    stroke: #2e7d32;
    stroke-opacity: 0.6;
}

.pm-tile.is-failed {
    fill: #d32f2f;
    fill-opacity: 0.65;
    stroke: #b71c1c;
    stroke-opacity: 0.95;
}

.pm-tile.is-active {
    fill: #1565c0;
    fill-opacity: 0.75;
    stroke: #0d47a1;
    stroke-opacity: 1;
}

.pm-tile-dot {
    fill: #1565c0;
    fill-opacity: 0.65;
}

.pm-tile-dot.is-center {
    fill: #b45309;
    fill-opacity: 1;
}

.pm-tile-dot.is-upcoming {
    fill: #1565c0;
    fill-opacity: 0.35;
}

.pm-tile-dot.is-done {
    fill: #1b5e20;
    fill-opacity: 0.9;
}

.pm-tile-dot.is-failed {
    fill: #b71c1c;
    fill-opacity: 0.95;
}

.pm-tile-dot.is-active {
    fill: #ffffff;
    fill-opacity: 1;
}

.pm-path-planned {
    stroke: #1565c0;
    stroke-width: 1.1;
    stroke-opacity: 0.32;
}

.pm-path-traveled {
    stroke: #2e7d32;
    stroke-width: 1.7;
    stroke-opacity: 0.95;
}

.pm-origin-ring {
    fill: none;
    stroke: #2e7d32;
    stroke-width: 2;
}

.pm-goto-pin line,
.pm-goto-pin circle {
    stroke: #1565c0;
    stroke-width: 1.5;
    fill: none;
}

.pm-goto-pin circle {
    stroke-dasharray: 2 1.5;
}

@keyframes pm-cam-pulse-anim {
    0%, 100% { r: 7; opacity: 0.9; }
    50% { r: 14; opacity: 0.15; }
}

.pm-cam-pulse {
    fill: none;
    stroke: #d32f2f;
    stroke-width: 2;
    animation: pm-cam-pulse-anim 1.5s ease-in-out infinite;
}

.pm-cam-dot {
    fill: #d32f2f;
    stroke: #ffffff;
    stroke-width: 1.5;
}

.pm-cam-marker.is-uncertain .pm-cam-pulse {
    stroke: #ef6c00;
    stroke-dasharray: 3 2;
}

.pm-cam-marker.is-uncertain .pm-cam-dot {
    fill: #ef6c00;
}

.pm-uncertain-label {
    fill: #e65100;
    font-size: 11px;
    font-weight: 700;
    font-family: sans-serif;
}

#plate-map-tooltip {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    background: rgba(24, 33, 45, 0.92);
    color: #ffffff;
    padding: 3px 7px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.plate-map-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 10px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #e0e8e0;
    font-size: 11px;
    color: #455a64;
}

#plate-map-legend-items {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.pm-leg-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.pm-leg-hint {
    color: #607d8b;
    font-style: italic;
}

.pm-dot,
.pm-swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
}

.pm-dot {
    border-radius: 50%;
}

.pm-swatch {
    border-radius: 2px;
}

.pm-dot-cam {
    background: #d32f2f;
}

.pm-dot-uncertain {
    background: #ef6c00;
}

.pm-dot-origin {
    border: 2px solid #2e7d32;
    box-sizing: border-box;
}

.pm-swatch-done {
    background: rgba(46, 125, 50, 0.55);
    border: 1px solid #2e7d32;
}

.pm-swatch-todo {
    background: rgba(25, 118, 210, 0.2);
    border: 1px solid rgba(25, 118, 210, 0.5);
}

.pm-swatch-fail {
    background: rgba(211, 47, 47, 0.7);
    border: 1px solid #b71c1c;
}

.pm-swatch-center {
    background: rgba(245, 158, 11, 0.6);
    border: 1px solid #d97706;
}

#plate-map-cam-readout {
    font-family: monospace;
    font-weight: 600;
    color: #1b5e20;
}

#plate-map-cam-readout.is-uncertain {
    color: #e65100;
}

#nav-bookmark-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.bm-card {
    border: 1px solid #c5e1a5;
    background: #ffffff;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
}

.bm-card.is-current {
    border-color: #2e7d32;
    background: #e8f5e9;
}

.bm-title {
    font-weight: bold;
    color: #1b5e20;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bm-coords {
    font-family: monospace;
    font-size: 11px;
    color: #555;
    margin-bottom: 4px;
}

.bm-actions {
    display: flex;
    gap: 3px;
}

.bm-go-btn,
.bm-sync-btn,
.bm-set-btn {
    flex: 1;
    padding: 2px 0;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
}

.bm-go-btn {
    border: none;
    background: #1565C0;
    color: #fff;
}

.bm-go-btn:hover {
    background: #0d47a1;
}

.bm-sync-btn {
    border: 1px solid #ef6c00;
    background: #fff3e0;
    color: #e65100;
}

.bm-sync-btn:hover {
    background: #ffe0b2;
}

.bm-set-btn {
    border: 1px solid #888;
    background: #f5f5f5;
    color: #333;
}

.bm-set-btn:hover {
    background: #e0e0e0;
}

/* Direct Coordinate Goto & Set Current Position */
.nav-goto-row,
.nav-set-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #ccc;
}

.nav-goto-label {
    font-size: 12px;
    min-width: 62px;
    font-weight: 600;
    color: #1b5e20;
}

#btn-nav-set-xy {
    padding: 4px 10px;
    border: 1px solid #d97706;
    border-radius: 4px;
    background: #fffbeb;
    color: #92400e;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
}

#btn-nav-set-xy:hover {
    background: #fef3c7;
}

#nav-set-status {
    font-size: 11px;
    color: #2e7d32;
}

.nav-coord-input {
    width: 72px;
    padding: 2px 5px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

#btn-nav-goto-xy {
    padding: 3px 10px;
    border: none;
    border-radius: 4px;
    background: #1565C0;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
}

#btn-nav-stop {
    padding: 5px 10px;
    border: 1px solid #a62626;
    border-radius: 4px;
    color: #952020;
    background: white;
    cursor: pointer;
}

#btn-nav-stop:hover {
    background: #ffeded;
}

#btn-nav-goto-xy:hover {
    background: #0d47a1;
}

/* ── CIRCULAR WELL SCAN & LANDMARK VERIFICATION ── */
.scan-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0;
}

.scan-config-row label {
    margin: 0;
    font-weight: normal;
}

#scan-well-select {
    padding: 2px 5px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

#scan-geom-r {
    width: 62px;
    padding: 2px 4px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

#scan-geom-sx,
#scan-geom-sy {
    width: 54px;
    padding: 2px 4px;
    border: 1px solid #bbb;
    border-radius: 4px;
}

.scan-actions-row {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#scan-verify-banner {
    display: none;
    margin-top: 10px;
    padding: 8px 10px;
    background: #e8f5e9;
    border: 1px solid #4caf50;
    border-radius: 6px;
}

#scan-verify-text {
    font-weight: bold;
    color: #1b5e20;
    margin-bottom: 6px;
}

#btn-verify-yes,
#btn-verify-no {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
}

#btn-verify-yes {
    background: #2e7d32;
    margin-right: 6px;
}

#btn-verify-yes:hover {
    background: #1b5e20;
}

#btn-verify-no {
    background: #e65100;
}

#btn-verify-no:hover {
    background: #bf360c;
}

/* ── LIVE ACTION LOG ── */
.action-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.action-log-header p {
    font-size: large;
    margin: 0;
}

#btn-clear-log {
    padding: 2px 8px;
    font-family: sans-serif;
    font-size: 12px;
    border: 1px solid #888;
    border-radius: 4px;
    background: #eee;
    cursor: pointer;
}

#btn-clear-log:hover {
    background: #ddd;
}

#action-log {
    height: 220px;
    overflow-y: auto;
    background: #111;
    color: #00ff99;
    font-family: monospace;
    font-size: 12px;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #333;
    margin-bottom: 12px;
}

.log-row {
    padding: 1px 0;
    border-bottom: 1px solid #1e1e1e;
    white-space: pre-wrap;
}

.log-ok    { color: #00ff99; }
.log-error { color: #ff5252; }
.log-warn  { color: #ffd54f; }
.log-scan  { color: #4dd0e1; }

#scan_box {
    border-top: 1px solid #d0d7de;
    padding-top: 8px;
    margin-top: 8px;
    font-family: sans-serif;
    font-size: 13px;
}

.scan-meta-inline {
    color: #555;
    font-size: 12px;
}

.scan-schedule { margin-top: 10px; border-top: 1px solid #ccd6e0; padding-top: 8px; }
.scan-schedule > summary { cursor: pointer; color: #174b84; font-weight: 600; }
#focus-actions { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; align-items: center; }
#focus-actions button {
    padding: 5px 10px;
    border: 1px solid #2463a5;
    border-radius: 4px;
    background: #1565c0;
    color: white;
    font-family: sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
#focus-actions button:disabled { opacity: .55; cursor: default; }
#z-origin-heading { margin-top: 12px; padding-top: 10px; border-top: 1px solid #ccd6e0; }
#focus-hint { max-width: 16em; margin-top: 4px; font-size: 12px; line-height: 1.4; text-align: center; }
#focus-actions p { margin: 8px 0; }
#focus-status:not(:empty) { display: block; margin-top: 4px; font-family: sans-serif; font-size: 11px; color: #174b84; text-align: center; }

#scan_box .scan-section-title {
    margin: 2px 0 10px;
    color: #1a237e;
    font: bold 16px/1.3 sans-serif;
}
#scan_box label,
#scan_box select,
#scan_box input,
#scan_box button {
    font: inherit;
}
.scan-mode-hint {
    margin: 6px 0;
    color: #414e61;
}

.scan-schedule-fields label { display: grid; gap: 3px; font-size: 14px; }
.scan-schedule-fields input { padding: 4px 7px; font: inherit; }
.scan-schedule [hidden] { display: none; }
#schedule-summary { margin: 4px 0 8px; }
.scan-schedule fieldset { margin: 8px 0; padding: 8px 0; border: 0; }
.scan-schedule-fields { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.scan-schedule-fields input[type=number] { width: 5em; }
.scan-schedule small { display: block; margin-bottom: 8px; }

.circular-settings { margin: 8px 0 12px; padding: 6px 10px 10px; border: 1px solid #c6d1df; border-radius: 5px; min-width: 0; }
.circular-settings legend { font-size: inherit; font-weight: 600; width: auto; margin: 0; padding: 0 4px; border: 0; }
.circular-settings .scan-config-row { align-items: end; margin: 0 0 6px; }
.circular-settings label { display: grid; gap: 3px; }

.schedule-options { display: flex; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap; }
.schedule-options summary { cursor: pointer; padding: 4px 0; color: #174b84; }
