:root {
  --bg: #f1f2f4;
  --paper: #ffffff;
  --ink: #1c2431;
  --ink-2: #5b6472;
  --ink-3: #8a919c;
  --line: #d9dde3;
  --line-soft: #e8ebef;
  --slate: #1c2431;
  --slate-2: #2b3544;
  --yellow: #f2b705;
  --yellow-ink: #6a4f00;
  --ok: #2f7d4f;    --ok-bg: #e6f3ea;
  --warn: #9a6700;  --warn-bg: #fff4d6;
  --bad: #b23a2e;   --bad-bg: #fbe9e6;
  --neutral-bg: #eceef1;
  --radius: 6px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--font); font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Top bar: the hoarding frame ---------- */
.topbar { background: var(--slate); color: #fff; border-bottom: 4px solid var(--yellow); }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; min-height: 54px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; white-space: nowrap; font-size: 15px; }
.brand-mark { width: 22px; height: 14px; background: var(--yellow); border: 2px solid #fff; border-radius: 2px; box-shadow: 0 5px 0 -2px #fff; }
.nav { display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: #c9d0da; text-decoration: none; padding: 16px 12px; font-weight: 500; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -4px;
}
.nav a:hover { color: #fff; }
.nav a.is-active { color: #fff; border-bottom-color: var(--yellow); }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 13px; color: #c9d0da; white-space: nowrap; }
.who a { color: #fff; }

/* ---------- Page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.panel-head .actions { margin-left: auto; }
.panel-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Summary strip ---------- */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.strip > div { background: var(--paper); padding: 12px 16px; }
.strip .v { font-size: 22px; font-weight: 600; line-height: 1.2; }
.strip .k { font-size: 13px; color: var(--ink-2); }
.strip .v.bad { color: var(--bad); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 500; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.rowlink:hover { background: #f7f8fa; cursor: pointer; }
td a.strong { font-weight: 600; text-decoration: none; }
td a.strong:hover { text-decoration: underline; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.empty { padding: 28px 16px; color: var(--ink-2); text-align: center; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 500; white-space: nowrap; line-height: 1.5; }
.pill-overdue { background: var(--bad-bg); color: var(--bad); }
.pill-due     { background: var(--warn-bg); color: var(--warn); }
.pill-ok      { background: var(--ok-bg); color: var(--ok); }
.pill-free, .pill-none, .pill-neutral { background: var(--neutral-bg); color: var(--ink-2); }
.pill-running { background: var(--ok-bg); color: var(--ok); }
.pill-vacant  { background: var(--warn-bg); color: var(--warn); }
.pill-closed  { background: var(--neutral-bg); color: var(--ink-2); }

/* ---------- Forms ---------- */
form.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
form.form .full { grid-column: 1 / -1; }
@media (max-width: 640px) { form.form { grid-template-columns: 1fr; } }
label.field { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label.field > span { display: block; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], input[type=tel], input[type=file], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; min-height: 42px;
}
input[type=file] { padding: 7px 10px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--yellow); outline-offset: 1px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; font-weight: 400; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.form-actions .spacer { flex: 1; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.filters label.field { min-width: 140px; flex: 1 1 140px; }
.filters .field-search { flex: 2 1 200px; }
.filters input, .filters select { min-height: 38px; padding: 6px 10px; }
.filters .btn { min-height: 38px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--font); padding: 0 14px; min-height: 40px; border-radius: var(--radius);
  border: 1px solid var(--slate); background: var(--slate); color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--slate-2); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-danger { background: #fff; color: var(--bad); border-color: #e4b8b2; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-yellow { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); }
.btn-yellow:hover { background: #ffc61a; }
button.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--bad); cursor: pointer; text-decoration: underline; }

/* ---------- Flash / notices ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash-ok    { background: var(--ok-bg); color: var(--ok); border-color: #bfe0c9; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: #efc4be; }
.flash-info  { background: var(--warn-bg); color: var(--warn); border-color: #f1dea1; }
.notice { padding: 12px 16px; border-left: 4px solid var(--yellow); background: #fffbea; border-radius: 0 var(--radius) var(--radius) 0; margin-bottom: 16px; }

/* ---------- Definition list (site / vendor info) ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dt { font-size: 12.5px; } .kv dd { margin-bottom: 8px; } }

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.login-wrap .panel-body { padding: 24px; }
.login-wrap .brand { color: var(--ink); margin-bottom: 18px; font-size: 18px; }
.login-wrap .brand-mark { border-color: var(--ink); box-shadow: 0 5px 0 -2px var(--ink); }

/* ---------- Misc ---------- */
.thumb { width: 64px; height: 48px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
.row-guess { background: #fffbea; }
code { font-size: 13px; background: var(--neutral-bg); padding: 1px 5px; border-radius: 3px; }
@media (max-width: 640px) {
  .who span { display: none; }
  .topbar-inner { gap: 12px; }
  .nav a { padding: 16px 9px; }
  th, td { padding: 9px 10px; }
  .page { padding: 14px 12px 48px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color .12s, color .12s; }
}

/* ---------- Phase 2 ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (max-width: 960px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
.site-hero { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; }
.photo-form { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 12px; align-items: end; margin-bottom: 16px; }
@media (max-width: 760px) { .photo-form { grid-template-columns: 1fr; } }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.shot { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.shot.is-current { border-color: var(--yellow); box-shadow: 0 0 0 2px var(--yellow); }
.shot img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.shot figcaption { padding: 8px 10px 10px; font-size: 13px; line-height: 1.45; }
.thumb-empty { background: var(--neutral-bg); }
.row-void td { color: var(--ink-3); text-decoration: line-through; }
.row-void td .pill, .row-void td a.strong { text-decoration: none; }
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-soft); background: #fafbfc; }
.bulk-bar select, .bulk-bar input { min-height: 36px; padding: 5px 10px; width: auto; }
.client-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.client-strip a { display: inline-flex; gap: 8px; align-items: baseline; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: #fff; }
.client-strip a:hover { border-color: var(--ink-3); }
.client-strip .n { font-weight: 600; }
