:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --text: #1c1c1e;
  --muted: #6b7280;
  --line: #e3e3e6;
  --accent: #1f6feb;
  --warn: #b45309;
  --bad: #b91c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --panel: #1f2023;
    --text: #e8e8ea;
    --muted: #9aa0a6;
    --line: #2e3034;
    --accent: #5b9cf8;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  letter-spacing: 0.02em;
}

.top nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 64px;
}

h1 {
  font-size: 22px;
  margin: 16px 0 20px;
}

h2 {
  font-size: 17px;
  margin: 28px 0 10px;
}

.muted {
  color: var(--muted);
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-value {
  font-size: 26px;
  font-weight: 600;
}

.card-label {
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

th,
td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

.props {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 16px;
  margin: 0 0 8px;
}

.props dt {
  color: var(--muted);
}

.props dd {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: inherit;
}

.tile:hover {
  text-decoration: none;
  border-color: var(--accent);
}

.tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg);
}

.tile-drawing {
  object-fit: contain;
  padding: 6px;
  background: var(--panel);
}

.tile-pending {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

.tile-caption {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer {
  height: min(70vh, 640px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 12px 0 8px;
}

.viewer canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  color: var(--text);
}

.preview {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.row-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin: 12px 0;
}

.row-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

input {
  min-width: 240px;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
}

.dropzone {
  margin: 12px 0;
  padding: 28px 16px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: var(--panel);
}

.dropzone-active {
  border-color: var(--accent);
  color: var(--accent);
}

.upload-list {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr 120px 110px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}

.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-status {
  color: var(--muted);
  text-align: right;
}

.upload-failed .upload-status {
  color: var(--bad);
}

.upload-skipped .upload-status {
  color: var(--warn);
}

.upload-done {
  padding: 6px 10px;
  font-size: 13px;
}

progress {
  width: 100%;
  height: 6px;
}

.notes {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notes li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 6px;
}

.badge-issue {
  color: var(--warn);
  border-color: var(--warn);
}

.pager {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

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

  .upload-row {
    grid-template-columns: 1fr 70px;
  }

  .upload-row progress {
    display: none;
  }
}

.me {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.me form {
  margin: 0;
}

.link-button {
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent);
}

.copy-field {
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
}
