:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1d2430; --muted: #6b7682;
  --line: #e3e7ec; --accent: #2d6cdf; --accent-ink: #fff;
  --green: #1a9c5b; --amber: #c98a00; --red: #d23b3b; --slate: #6b7682;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, "Segoe UI", "Sarabun", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: var(--red); }
.ok { color: var(--green); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 12px 24px; position: sticky; top: 0; z-index: 5;
}
.topbar .brand { font-weight: 700; color: var(--ink); }
.topbar nav { display: flex; gap: 18px; align-items: center; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }

table.grid { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.grid th { background: #fafbfc; color: var(--muted); font-weight: 600; }
.grid tr:last-child td { border-bottom: none; }
.truncate { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error-cell { color: var(--red); max-width: 280px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-pending, .run-queued { background: #eef1f5; color: var(--slate); }
.status-retry, .run-running { background: #fff3d6; color: var(--amber); }
.status-revise { background: #e7efff; color: var(--accent); }
.status-done, .run-succeeded { background: #e3f6ec; color: var(--green); }
.status-approve { background: #d8f0e2; color: var(--green); }
.run-failed { background: #fde6e6; color: var(--red); }
.run-deferred { background: #eef1f5; color: var(--slate); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-size: 13px; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

button, .btn, .primary {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.link { border: none; background: none; color: var(--accent); padding: 0; }
.inline { display: inline; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }

dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
code { background: #eef1f5; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

.form label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
.form input, .form select, .form textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--ink); }
.revise { margin-top: 14px; }
.revise textarea { width: 100%; margin: 8px 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }

ol.events { margin: 0; padding-left: 18px; max-height: 320px; overflow: auto; }
ol.events li { margin-bottom: 4px; font-size: 13px; }
.events .phase { font-weight: 600; }
.events .kw { color: var(--accent); }
.events .ts { font-size: 11px; margin-left: 6px; }
.ev-error { color: var(--red); }
.ev-warn { color: var(--amber); }

.login-card { max-width: 340px; margin: 80px auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login-card h1 { font-size: 18px; margin-bottom: 18px; }
.login-card label { display: block; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.login-card input { width: 100%; margin-top: 6px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login-card button { width: 100%; }

.paste-box { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font: 13px/1.4 ui-monospace, "SF Mono", Menlo, monospace; margin-bottom: 10px; }

.update-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.update-form label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.update-form select, .update-form textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.small { font-size: 12px; margin-top: 8px; }

.row-action { display: flex; gap: 6px; align-items: center; }
.row-action select { padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px; }
.row-action input[type=text] { width: 150px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 12px; }
.row-action button { padding: 5px 10px; font-size: 12px; white-space: nowrap; }
.report-cell a { margin-right: 8px; white-space: nowrap; }
.maps-thumb { display: block; width: 120px; height: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 6px; cursor: zoom-in; }
.run-sub { margin-top: 4px; font-size: 11px; }

.report { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.report img { max-width: 100%; height: auto; }
.report table { border-collapse: collapse; }
.report th, .report td { border: 1px solid var(--line); padding: 6px 10px; }
