:root {
  --red: #c8102e;
  --ink: #1d1d1f;
  --muted: #666;
  --line: #d9d9d9;
  --soft: #f5f5f5;
  --bg: #fff;
  --hit: #fff1b8;
  --target: #ffe3e7;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

#topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 24px; border-bottom: 3px solid var(--red); background: #000; color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand img { width: 42px; height: 42px; background: #fff; border-radius: 50%; padding: 2px; }
nav { display: flex; gap: 20px; align-items: center; }
nav a, nav .link { color: #ddd; font-size: 14px; }
nav a.active { color: #fff; font-weight: 600; border-bottom: 2px solid var(--red); }
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; }

button, .btn { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink); cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: var(--soft); text-decoration: none; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; }
button.primary:hover { background: #a50d26; }
button.danger { color: var(--red); }
button.link { border: none; background: none; padding: 0; color: var(--red); }
button.link:hover { text-decoration: underline; background: none; }
button:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; }
input:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin: 10px 0; background: #fff; }

/* login */
.login { max-width: 340px; margin: 12vh auto; text-align: center; }
.login img { width: 140px; }
.login form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.error { color: var(--red); min-height: 1.4em; }

/* tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr.archived td { color: var(--muted); }
.sheets { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--muted); }
.sheets li { margin: 2px 0; }
.sheets input { width: 64px; padding: 2px 6px; font-size: 12px; }

/* search */
.searchbar { display: flex; gap: 8px; margin: 12px 0; }
.searchbar input { flex: 1; font-size: 16px; padding: 10px 12px; }
.jobpick { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 12px; background: var(--soft); border-radius: 6px; }
.jobpick label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.group { border: 1px solid var(--line); border-radius: 6px; margin: 14px 0; }
.group > .ghead { padding: 8px 12px; background: var(--soft); border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; }
.group > .ghead strong { font-size: 15px; }
.hitrow { padding: 8px 12px; border-bottom: 1px solid #eee; }
.hitrow:last-child { border-bottom: none; }
.hitsrc { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.hitsrc b { color: var(--ink); }
.hitsrc a { display: inline-block; padding: 6px 10px; margin: 3px 0; border: 1px solid #175cd3; border-radius: 4px; background: #175cd3; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; }
.hitsrc a:hover { background: #124aa7; border-color: #124aa7; text-decoration: none; }
.hitsrc a:focus-visible { outline: 2px solid #175cd3; outline-offset: 3px; }
.x { border: none; background: none; color: #999; font-size: 18px; line-height: 1; padding: 0 4px; cursor: pointer; }
.x:hover { color: var(--red); background: none; }
.scroll { overflow-x: auto; }
table.cells { border-collapse: collapse; font-size: 12.5px; }
table.cells th, table.cells td { border: 1px solid #e3e3e3; padding: 3px 8px; white-space: nowrap; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.cells th { background: #fafafa; font-weight: 600; color: #444; }
td.hit { background: var(--hit); font-weight: 600; }
.excluded-bar { margin: 8px 0; font-size: 13px; color: var(--muted); }

/* viewer */
.tabs { display: flex; gap: 4px; margin: 12px 0 0; border-bottom: 1px solid var(--line); }
.tabs button { border-radius: 4px 4px 0 0; border-bottom: none; }
.tabs button.on { background: var(--red); color: #fff; border-color: var(--red); }
.grid-wrap { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--line); }
table.grid { border-collapse: collapse; font-size: 12.5px; }
table.grid th, table.grid td { border: 1px solid #e3e3e3; padding: 2px 8px; white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
table.grid thead th { position: sticky; top: 0; background: #f0f0f0; z-index: 2; color: #555; }
table.grid td.rn { position: sticky; left: 0; background: #f0f0f0; color: #555; text-align: right; z-index: 1; }
table.grid tr.header-row td { font-weight: 600; background: #fafafa; }
table.grid tr.target td { background: var(--target); }
table.grid tr.target td.rn { background: var(--red); color: #fff; }
table.grid tr.target td.hit { background: var(--hit); outline: 2px solid var(--red); outline-offset: -2px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 10; max-width: 90vw; }
#toast.err { background: var(--red); }
.spinner { color: var(--muted); padding: 20px 0; }
