:root {
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --line: #dcdce0;
  --bg: #f6f6f8;
  --card: #fff;
  --accent: #b8232f;      /* Mercy Me red */
  --accent-ink: #fff;
  --ok-bg: #e6f6ec; --ok-line: #a8d9bd;
  --err-bg: #fde8e8; --err-line: #f5b5b5;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 800; text-decoration: none; color: var(--accent); letter-spacing: .5px; font-size: 1.05rem; }
.brand span { color: var(--ink); font-weight: 600; }
.topbar nav { display: flex; align-items: center; gap: 1.1rem; margin-left: auto; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--ink); font-weight: 500; }
.topbar nav a:hover { color: var(--accent); }
.topbar .who { color: var(--muted); font-size: .85rem; }
.inline { display: inline; margin: 0; }
.linkbtn { background: none; border: 0; color: var(--ink); font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--accent); }

/* ---- layout ---- */
.wrap { max-width: 60rem; margin: 1.5rem auto; padding: 0 1.25rem; }
.narrow { max-width: 34rem; }

/* ---- flash ---- */
.flash { max-width: 60rem; margin: 1rem auto 0; padding: .7rem 1rem; border-radius: var(--radius); }
.flash-ok, .flash-success { background: var(--ok-bg); border: 1px solid var(--ok-line); }
.flash-error { background: var(--err-bg); border: 1px solid var(--err-line); }

/* ---- cards & forms ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
label { display: block; font-weight: 600; margin-top: 1rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], input[type=tel], select, textarea {
  width: 100%; padding: .55rem .65rem; font: inherit; margin-top: .3rem;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
textarea { resize: vertical; min-height: 5rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; }
.checkline { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; }
.checkline input { width: auto; margin: 0; }
.checkline label { margin: 0; }
.field-error { color: var(--accent); font-size: .85rem; margin-top: .25rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--accent); }

button.primary, .btn {
  display: inline-block; margin-top: 1.25rem; padding: .6rem 1.3rem;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
button.primary:hover, .btn:hover { filter: brightness(.94); }
.btn.secondary { background: #eee; color: var(--ink); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; background: var(--card); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafafa; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.inactive-tag { color: var(--muted); font-size: .8rem; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; background: #eee; }

/* ---- key/value tables (job show, diagnostics) ---- */
table.kv { background: transparent; }
table.kv th { background: transparent; text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--muted); width: 12rem; font-weight: 600; border-bottom: 1px solid var(--line); }
table.kv td { border-bottom: 1px solid var(--line); }

/* ---- history list ---- */
ul.history { list-style: none; padding: 0; margin: 0; }
ul.history > li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
ul.history > li:last-child { border-bottom: 0; }
ul.history ul { margin: .35rem 0 0 1rem; color: var(--muted); font-size: .9rem; }

/* ---- client search combobox ---- */
.combo { position: relative; margin-top: .3rem; }
.combo-input { width: 100%; padding: .55rem .65rem; font: inherit; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.combo-clear {
  position: absolute; right: .4rem; top: .35rem; border: 0; background: none;
  font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: .1rem .35rem;
}
.combo-clear:hover { color: var(--accent); }
.combo-invalid .combo-input { border-color: var(--accent); }
.combo-results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px);
  margin: 0; padding: .25rem 0; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); max-height: 16rem; overflow-y: auto;
}
.combo-option { padding: .45rem .7rem; cursor: pointer; }
.combo-option:hover, .combo-option.is-active { background: #f2f2f5; }
.combo-arrow { color: var(--muted); }
.combo-sub { font-weight: 600; }
.combo-msg { margin-top: .35rem; }

/* ---- admin nav ---- */
ul.admin-nav { list-style: none; padding: 0; margin: 0; }
ul.admin-nav li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
ul.admin-nav li:last-child { border-bottom: 0; }
ul.admin-nav a { font-weight: 600; }
