
:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7f9;
  color: #18212f;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow: hidden; }
button, input, textarea { font: inherit; }
button {
  border: 1px solid #cbd3df;
  background: #fff;
  color: #18212f;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
}
button:hover { border-color: #75849a; }
button.active { border-color: #175cd3; background: #e9f1ff; color: #0b4cb8; }
summary { cursor: pointer; }
.topbar {
  min-height: 68px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #d9dee7;
  background: #fff;
}
.top-title { min-width: 260px; }
.topbar h1 { margin: 0; font-size: 18px; letter-spacing: 0; }
.topbar p { margin: 3px 0 0; color: #637083; font-size: 12px; }
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.primary-button {
  border-color: #175cd3;
  background: #175cd3;
  color: #fff;
  font-weight: 700;
}
.primary-button:hover { border-color: #0b4cb8; background: #0b4cb8; }
.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 6px 9px;
  color: #18212f;
  background: #fff;
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.action-link:hover {
  border-color: #75849a;
  text-decoration: none;
}
.action-link.primary-link {
  border-color: #175cd3;
  background: #e9f1ff;
  color: #0b4cb8;
}
.filter-section > summary::-webkit-details-marker {
  display: none;
}
.release-line {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.data-version {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #637083;
  font-size: 11px;
}
.image-source-status {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #637083;
  font-size: 11px;
}
.layout {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr) 330px;
}
.case-panel,
.anno-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #d9dee7;
}
.anno-panel { border-right: 0; border-left: 1px solid #d9dee7; }
.toolbar {
  flex: 0 0 auto;
  padding: 10px;
  display: grid;
  gap: 8px;
  border-bottom: 1px solid #e4e8ef;
}
.toolbar input[type="search"] {
  width: 100%;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 8px 9px;
}
.toolbar label { font-size: 12px; color: #465366; display: flex; gap: 6px; align-items: center; }
.filter-section {
  flex: 0 0 auto;
  border-bottom: 1px solid #e4e8ef;
}
.filter-section > summary {
  padding: 9px 10px;
  color: #465366;
  font-size: 12px;
  font-weight: 700;
  background: #fbfcfe;
}
.filters,
.type-filters {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
}
.type-filters {
  max-height: 96px;
  overflow: auto;
  border-top: 1px solid #e4e8ef;
  border-bottom: 1px solid #e4e8ef;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #d5dce7;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  color: #465366;
  background: #fbfcfe;
}
.filter-chip input { margin: 0; }
.case-list,
.anno-list {
  overflow: auto;
  min-height: 0;
}
.case-row,
.anno-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef1f5;
  border-radius: 0;
  background: #fff;
  display: block;
  text-align: left;
  padding: 9px 10px;
}
.case-row:hover,
.anno-row:hover { background: #f7f9fc; }
.case-row.active,
.anno-row.active { background: #edf4ff; }
.case-name,
.anno-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.case-name strong,
.anno-main strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
}
.case-meta,
.anno-preview {
  margin-top: 3px;
  font-size: 11px;
  color: #687589;
  line-height: 1.35;
}
.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #c8d0dc;
}
.status-ok { background: #1a8f5b; }
.status-problem { background: #d92d20; }
.status-unsure { background: #d19200; }
.viewer-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #eef2f6;
}
.viewer-toolbar {
  min-height: 50px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d7dee8;
  background: #fff;
}
.case-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.viewer-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: #465366;
}
.viewer-controls input[type="range"] { width: 120px; vertical-align: middle; }
.stage-scroll {
  flex: 1 1 0;
  overflow: auto;
  min-height: 0;
  padding: 18px;
  cursor: grab;
  touch-action: none;
}
.stage-scroll.dragging { cursor: grabbing; }
.stage-scroll.dragging * { user-select: none; }
.stage {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 1px 9px rgba(20, 31, 46, 0.18);
  transform-origin: top center;
}
.stage.image-missing {
  background:
    linear-gradient(45deg, #f7f9fc 25%, transparent 25%),
    linear-gradient(-45deg, #f7f9fc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f7f9fc 75%),
    linear-gradient(-45deg, transparent 75%, #f7f9fc 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
#pageImage {
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
}
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.box {
  fill: transparent;
  stroke: #175cd3;
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
  shape-rendering: geometricPrecision;
  cursor: pointer;
}
.box.low { stroke: #d19200; stroke-dasharray: 16 10; }
.box.unmatched { stroke: #d92d20; stroke-dasharray: 8 8; }
.box.dimmed { opacity: 0.14; }
.box.cover {
  fill: #fff;
  fill-opacity: 1;
  stroke: #f2a900;
  stroke-width: 1.5;
}
.box.cover.low {
  fill: #fff8e1;
  stroke: #d19200;
}
.box.cover.unmatched {
  fill: #fff1f0;
  stroke: #d92d20;
}
.box.selected {
  stroke: #ffcf23 !important;
  stroke-dasharray: none;
  stroke-width: 2;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.28));
}
.box-label {
  font-size: 22px;
  font-weight: 700;
  paint-order: stroke;
  stroke: white;
  stroke-width: 4px;
  fill: #0b4cb8;
  pointer-events: none;
}
.resize-handle {
  fill: #fff;
  stroke: #175cd3;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  cursor: nwse-resize;
}
.side-section {
  flex: 0 0 auto;
  padding: 10px;
  border-bottom: 1px solid #e4e8ef;
}
.side-section h2,
.correction-panel h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0;
}
.details {
  flex: 0 0 auto;
  padding: 0;
  min-height: auto;
  max-height: 260px;
  overflow: auto;
}
.details h2 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0;
}
.details dl {
  margin: 0;
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 5px 8px;
  font-size: 12px;
}
.details dt { color: #687589; }
.details dd { margin: 0; min-width: 0; word-break: break-word; }
.details .text {
  margin-top: 10px;
  max-height: 96px;
  overflow: auto;
  padding: 8px;
  background: #f6f8fb;
  border: 1px solid #e0e6ee;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}
.type-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef4ff;
  color: #0b4cb8;
  font-size: 11px;
  font-weight: 700;
}
.quality-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #edf7f1;
  color: #1a8f5b;
  font-size: 11px;
  font-weight: 700;
}
.quality-badge.low { background: #fff6df; color: #9a6700; }
.quality-badge.unmatched { background: #fff0ed; color: #b42318; }
.correction-panel {
  flex: 1 1 auto;
  margin: 0;
  background: #fff;
}
.correction-panel label {
  display: block;
  margin-bottom: 6px;
  color: #465366;
  font-size: 11px;
  font-weight: 700;
}
#caseIssueInput {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
}
.correction-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.correction-actions .action-link {
  min-height: 38px;
  font-size: 12px;
}
.correction-actions a {
  color: #0b4cb8;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.correction-actions a:hover { text-decoration: underline; }
.image-warning {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(620px, calc(100% - 48px));
  transform: translate(-50%, -50%);
  z-index: 3;
  padding: 12px 14px;
  border: 1px solid #f2c94c;
  border-radius: 6px;
  background: #fff8dc;
  color: #704b00;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
