/* The Ministry Lost Property. Black and white, squared, minimal, aligned to the member portal
   and theministry.com. Status colour is retained but refined: coloured text on hairline outline
   badges and coloured stat numbers, never loud filled blocks. See BRAND.md. */
:root {
  --bg: #000000;
  --surface-1: #0b0b0b;
  --surface-2: #161616;
  --surface-3: #1f1f1f;
  --border: #2a2a2a;
  --text: #ffffff;
  --text-muted: #9a9a9a;
  --text-faint: #6a6a6a;
  --green: #4bb98a;
  --amber: #d49a43;
  --red: #e0574f;
  --blue: #6aa3d8;
  --radius: 0;
  --sidebar-w: 236px;
  --topbar-h: 62px;
  --ticker-h: 40px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text); color-scheme: dark;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: "Space Grotesk", "Inter", sans-serif; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 0.5em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--text-muted); }
.muted { color: var(--text-muted); }
.mute { color: var(--text-faint); font-size: 13px; }
.hr { height: 1px; background: var(--border); border: 0; margin: 18px 0; }
.hide-sm { display: inline; }
.ico { width: 18px; height: 18px; flex-shrink: 0; }

/* Ticker */
.ticker { position: sticky; top: 0; z-index: 30; height: var(--ticker-h); background: var(--surface-2); border-bottom: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; }
.ticker-track { display: flex; align-items: center; width: max-content; animation: ticker 42s linear infinite; will-change: transform; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item { white-space: nowrap; color: var(--text); font-weight: 700; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.ticker-sep { color: var(--text-faint); padding: 0 1.5em; font-size: 11px; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* App shell */
.app { display: flex; min-height: calc(100vh - var(--ticker-h)); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: var(--ticker-h);
  height: calc(100vh - var(--ticker-h)); background: var(--bg); z-index: 25;
}
.brand { padding: 22px 22px 20px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.brand-mark { font-family: "Space Grotesk", sans-serif; font-weight: 700; letter-spacing: 0.22em; font-size: 15px; }
.brand-sub { color: var(--text-muted); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: var(--text-muted); font-size: 13px; letter-spacing: 0.04em; border-left: 2px solid transparent; transition: background .16s, color .16s, border-color .16s; }
.nav-link:hover { color: var(--text); background: var(--surface-1); }
.nav-link.is-active { color: var(--text); border-left-color: var(--text); background: var(--surface-1); }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.sidebar-user { font-size: 12px; color: var(--text-muted); }
.sidebar-user b { color: var(--text); font-weight: 600; display: block; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); border-bottom: 1px solid var(--border); position: sticky; top: var(--ticker-h); background: var(--bg); z-index: 20; display: flex; align-items: center; gap: 14px; padding: 0 32px; }
.topbar-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; letter-spacing: 0.02em; font-size: 15px; flex: 1; }
.menu-btn { display: none; background: transparent; border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; align-items: center; justify-content: center; cursor: pointer; }
.scrim { display: none; }

.content { padding: 30px 32px 72px; max-width: 1320px; width: 100%; margin: 0 auto; animation: page-in .3s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; }

/* Hero */
.hero { position: relative; border: 1px solid var(--border); overflow: hidden; margin-bottom: 24px; min-height: 200px; display: flex; align-items: flex-end; background: var(--surface-1); }
.hero::before { content: ""; position: absolute; inset: 0; background-image: var(--hero-img, none); background-size: cover; background-position: center; filter: brightness(0.5) saturate(1.05); z-index: 0; }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 120% at 15% 120%, rgba(0,0,0,0.85), rgba(0,0,0,0.35)); z-index: 0; }
.hero-inner { position: relative; z-index: 1; padding: 34px; max-width: 640px; }
.hero-kicker { text-transform: uppercase; letter-spacing: 0.18em; font-size: 11px; color: var(--text-muted); }
.hero-title { font-family: "Space Grotesk", sans-serif; font-size: 30px; margin: 10px 0 6px; letter-spacing: -0.01em; }
.hero-body { color: rgba(255,255,255,0.82); margin: 0; max-width: 520px; }

/* Stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); padding: 18px 20px; display: block; color: var(--text); transition: border-color .16s, transform .16s; }
a.tile:hover { border-color: var(--text-faint); transform: translateY(-2px); }
.tile .n { font-family: "Space Grotesk", sans-serif; font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .l { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; margin-top: 8px; }
.tile.amber .n { color: var(--amber); } .tile.red .n { color: var(--red); } .tile.green .n { color: var(--green); } .tile.blue .n { color: var(--blue); }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 26px; }
.qa { display: flex; flex-direction: column; gap: 16px; padding: 20px; background: var(--surface-1); border: 1px solid var(--border); color: var(--text); transition: background .16s, border-color .16s, transform .16s; }
.qa:hover { background: var(--surface-2); border-color: var(--text-faint); transform: translateY(-3px); }
.qa .ico { width: 24px; height: 24px; }
.qa-label { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: space-between; }

/* Cards */
.card { background: var(--surface-1); border: 1px solid var(--border); padding: 20px; }
.card + .card { margin-top: 20px; }
.panel { background: var(--surface-1); border: 1px solid var(--border); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.detail { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 20px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: "Inter", sans-serif; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; padding: 10px 16px; border: 1px solid var(--text); background: transparent; color: var(--text); cursor: pointer; border-radius: var(--radius); text-decoration: none; transition: background .16s, border-color .16s, color .16s, transform .12s; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: var(--text-muted); border-color: var(--text-muted); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.ghost { border-color: var(--border); color: var(--text-muted); }
.btn.ghost:hover { border-color: var(--text-faint); color: var(--text); }
.btn.sm { padding: 8px 12px; font-size: 12px; }
.btn.block { width: 100%; }
.btn .ico { width: 16px; height: 16px; }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; padding: 3px 8px; border: 1px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.chip.blue { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 50%, var(--border)); }
.chip.green { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, var(--border)); }
.chip.amber { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, var(--border)); }
.chip.red { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, var(--border)); }
.chip.dim { color: var(--text-faint); }

/* Forms */
.field { margin-bottom: 16px; }
label { display: block; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 7px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 11px 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-family: "Inter", sans-serif; font-size: 14px; border-radius: var(--radius); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text); }
textarea { min-height: 90px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); padding: 9px 12px; cursor: pointer; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 600; padding: 0 14px 12px; border-bottom: 1px solid var(--border); }
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[onclick]:hover, tbody tr.hoverable:hover { background: var(--surface-1); cursor: pointer; }

/* Item grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.item-card { background: var(--surface-1); border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; color: var(--text); transition: border-color .16s, transform .16s; }
.item-card:hover { border-color: var(--text-faint); transform: translateY(-2px); }
.item-card .thumb { aspect-ratio: 4/3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.item-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.item-card:hover .thumb img { transform: scale(1.04); }
.item-card .thumb .ph { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.item-card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.item-card .name { font-weight: 600; }
.item-card .ref { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Definition list */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 11px 16px; font-size: 14px; }
.dl dt { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.dl dd { margin: 0; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gallery img { width: 100%; border: 1px solid var(--border); display: block; }

/* Matcher candidates */
.candidate { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--border); background: var(--surface-1); margin-bottom: 8px; }
.candidate .cthumb { width: 66px; height: 50px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; border: 1px solid var(--border); }
.score { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 18px; font-variant-numeric: tabular-nums; }
.reasons { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* Toolbar */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.toolbar .field { margin: 0; }
.toolbar input, .toolbar select { min-width: 150px; }

/* Callout */
.callout { border: 1px solid var(--border); border-left: 2px solid var(--red); padding: 12px 16px; margin-bottom: 18px; color: var(--text-muted); font-size: 14px; }
.callout b { color: var(--text); }

/* Flash */
.flash { padding: 12px 16px; border: 1px solid var(--border); border-left-width: 2px; margin-bottom: 10px; font-size: 14px; }
.flash.success { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); }
.flash.info { border-left-color: var(--blue); }

/* Empty state */
.empty { border: 1px solid var(--border); background: var(--surface-1); padding: 46px 24px; text-align: center; }
.empty-mark { font-family: "Space Grotesk", sans-serif; font-size: 34px; color: var(--text-faint); }
.empty h3 { margin: 10px 0 6px; }
.empty p { margin: 0 0 18px; }

/* Timeline */
.timeline .row { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 12px; }
.timeline .row:last-child { border-bottom: 0; }

.signature-pad { width: 100%; height: 170px; background: #fff; touch-action: none; border: 1px solid var(--border); }

/* AI photo analysis banner on the log form */
.ai-banner { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-left: 2px solid var(--blue); background: var(--surface-2); font-size: 14px; color: var(--text); }
.ai-banner[hidden] { display: none; }
.ai-banner.done { border-left-color: var(--green); }
.ai-banner.error { border-left-color: var(--amber); color: var(--text-muted); }
.ai-spinner { width: 16px; height: 16px; border: 2px solid var(--text-faint); border-top-color: var(--text); border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0; }
.ai-banner.done .ai-spinner, .ai-banner.error .ai-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Public report form (site root, no staff chrome) */
.public-wrap { max-width: 620px; margin: 0 auto; padding: 44px 20px 64px; }
.public-head { display: flex; flex-direction: column; gap: 3px; padding-bottom: 26px; margin-bottom: 26px; border-bottom: 1px solid var(--border); }
.public-wrap h1 { font-size: 28px; margin-bottom: 8px; }
.public-wrap .card { margin-top: 22px; }
.public-foot { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 12px; line-height: 1.6; }
.public-foot p { margin: 0 0 8px; }
.public-foot a { color: var(--text-muted); }

/* Draggable reorder list (admin areas) */
.sort-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.sort-row:last-of-type { border-bottom: 0; }
.sort-row .sort-name { display: flex; gap: 6px; align-items: center; }
.sort-row .sort-name input[type=text] { min-width: 180px; }
.drag-handle { cursor: grab; color: var(--text-faint); font-size: 20px; line-height: 1; padding: 0 4px; user-select: none; transform: rotate(90deg); }
.drag-handle:active { cursor: grabbing; }
.sort-ghost { opacity: 0.4; background: var(--surface-2); }
#reorder-status { color: var(--text-muted); }

/* Signed out (sign in redirect / error) */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.auth-card { width: 100%; max-width: 400px; border: 1px solid var(--border); background: var(--surface-1); padding: 40px 32px; }
.auth-card .brand-mark { font-size: 18px; }

/* Mobile */
@media (max-width: 900px) {
  .detail { grid-template-columns: 1fr; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex; }
  .hide-sm { display: none; }
  .content { padding: 22px 18px 60px; }
  .topbar { padding: 0 18px; }
  .sidebar { position: fixed; top: var(--ticker-h); left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--ticker-h) 0 0 0; background: rgba(0,0,0,0.6); z-index: 24; }
  .form-actions .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .content, .ticker-track { animation: none; }
  * { transition: none !important; }
}

/* Print */
@media print {
  .ticker, .sidebar, .topbar, .form-actions, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .content { padding: 0; max-width: none; }
  .card, .panel { border-color: #ccc; }
}
