:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c1f23;
  --muted: #6b7280;
  --line: #d8dce2;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f7;
  --warn: #b45309;
  --ok: #15803d;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

header.site {
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
}

header.site h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

nav.site {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

nav.site a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

nav.site a:hover {
  background: var(--accent-soft);
}

main {
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}

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

h2 {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.field {
  margin-bottom: 0.75rem;
}

.grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

button {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--accent);
}

button.danger {
  background: #fff;
  color: #b91c1c;
  border-color: #f3c0c0;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.4rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

td input,
td select {
  padding: 0.3rem;
}

.table-scroll {
  overflow-x: auto;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.viewer {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 78vh;
}

.viewer img {
  display: block;
  width: 100%;
}

.viewer.measuring {
  cursor: crosshair;
}

/* Author display rules beat the UA stylesheet's [hidden] rule, so restate it. */
[hidden] {
  display: none !important;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 0;
}

.toolbar button {
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.inline-check input {
  width: auto;
}

#loupe {
  position: fixed;
  z-index: 50;
  width: 180px;
  height: 180px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.viewer img {
  max-width: none;
}

/* Overlays are positioned against this wrapper so they scroll with a zoomed drawing. */
.canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.viewer svg.trace-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.viewer svg.trace-overlay polygon,
.viewer svg.trace-overlay polyline {
  fill: rgba(31, 95, 139, 0.18);
  stroke: #1f5f8b;
  stroke-width: 2;
}

.viewer svg.trace-overlay circle {
  fill: #1f5f8b;
}

.viewer svg.trace-overlay polygon.saved {
  fill: rgba(21, 128, 61, 0.15);
  stroke: #15803d;
}

.viewer .marker {
  position: absolute;
  border: 2px solid #d97706;
  background: rgba(217, 119, 6, 0.15);
  pointer-events: none;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.draft {
  background: #fef3c7;
  color: var(--warn);
}

.badge.confirmed {
  background: #dcfce7;
  color: var(--ok);
}

.notice {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: #fef3c7;
  color: var(--warn);
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
}

.notice.error {
  background: #fee2e2;
  color: #b91c1c;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.gantt-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.gantt-track {
  position: relative;
  height: 22px;
  background: #eef1f4;
  border-radius: 4px;
}

.gantt-bar {
  position: absolute;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  opacity: 0.85;
}

.gantt-bar.done {
  background: var(--ok);
}

.gantt-bar.in-progress {
  background: #d97706;
}

.photo-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.summary-cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem;
}

.summary-card .value {
  font-size: 1.15rem;
  font-weight: 600;
}

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

  .viewer {
    max-height: 50vh;
  }

  .gantt-row {
    grid-template-columns: 110px 1fr;
  }
}

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

header.site .account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

header.site .account .muted {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
}
