:root {
  /* Brand gradient measured from the TR monogram */
  --brand-1: #6173e9;
  --brand-2: #3e93d2;
  --brand-3: #1ab2b9;
  --brand-gradient: linear-gradient(135deg, var(--brand-1), var(--brand-2) 50%, var(--brand-3));
  --accent: #2f7fc4;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #17203a;
  --muted: #5b6680;
  --border: #dbe1ec;
  --good: #11806a;
  --warn: #9a6a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 32, 58, 0.06), 0 4px 14px rgba(23, 32, 58, 0.06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #6fb6f0;
    --bg: #0f1424;
    --surface: #171e33;
    --surface-2: #1f2840;
    --text: #e8ecf6;
    --muted: #a3adc4;
    --border: #2c3653;
    --good: #4fd1b3;
    --warn: #f0c060;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.topbar { background: var(--brand-gradient); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.topbar img { width: 40px; height: 40px; border-radius: 50%; background: #fff; padding: 2px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.brand small { display: block; font-weight: 400; font-size: 12px; opacity: 0.9; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: #fff; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.topbar a:hover, .topbar button.link:hover { background: rgba(255, 255, 255, 0.15); }
.topbar form { margin: 0; }
@media (max-width: 640px) {
  .topbar-inner { gap: 6px; padding: 10px 12px; }
  .topbar img { width: 32px; height: 32px; }
  .brand { font-size: 15px; white-space: nowrap; }
  .brand small, .topbar .site-link { display: none; }
  .topbar a, .topbar button.link { padding: 6px 4px; font-size: 14px; }
}

/* Layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 20px 16px 48px; }
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Filters */
.filters { padding: 16px; position: sticky; top: 12px; }
@media (max-width: 860px) { .filters { position: static; } .filters[data-collapsed="true"] .filter-body { display: none; } }
.filters h2 { font-size: 15px; margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; }
.btn.filter-toggle { display: none; }
@media (max-width: 860px) { .btn.filter-toggle { display: inline-flex; } }
.field { margin: 12px 0; }
.field label, .field .label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.field input[type="text"], .field input[type="number"], .field input[type="search"], .field select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; background: var(--surface); cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--text); }
.btn-primary { background: var(--brand-gradient); border: 0; color: #fff; font-weight: 600; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.6; cursor: default; }

/* Results */
.searchbar { display: flex; gap: 8px; padding: 12px; margin-bottom: 12px; }
.searchbar input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.result-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; margin: 4px 2px 10px; }
.job { padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.job:hover, .job:focus-visible { border-color: var(--brand-2); outline: none; }
.job-head { display: flex; justify-content: space-between; gap: 12px; }
.job-title { font-weight: 650; font-size: 16px; margin: 0; }
.job-company { color: var(--muted); margin: 2px 0 8px; }
.salary { font-weight: 600; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.tag-new { background: var(--brand-gradient); color: #fff; font-weight: 600; }
.tag-code { color: var(--warn); }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Job detail */
dialog.detail { width: min(860px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
dialog.detail::backdrop { background: rgba(10, 16, 32, 0.55); }
.detail-head { background: var(--brand-gradient); color: #fff; padding: 18px 20px; position: relative; }
.detail-head h2 { margin: 0 40px 2px 0; font-size: 20px; }
.detail-head .close { position: absolute; top: 12px; right: 12px; background: rgba(255, 255, 255, 0.2); border: 0; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.detail-body { padding: 16px 20px 24px; }
.detail-body h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin: 20px 0 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.fact { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fact b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.req { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.req:last-child { border-bottom: 0; }
.req-type { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; height: fit-content; background: var(--surface-2); color: var(--muted); }
.req-type.required { background: #fde8e8; color: #9b1c1c; }
.req-type.preferred { background: #e5f0fd; color: #1d4f91; }
@media (prefers-color-scheme: dark) { .req-type.required { background: #4a1d1d; color: #ffb4b4; } .req-type.preferred { background: #1b3152; color: #a9cdfa; } }
.verified { display: inline-flex; gap: 6px; align-items: center; color: var(--good); font-weight: 600; font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.note { font-size: 13px; color: var(--muted); }
ul.clean { margin: 0; padding-left: 18px; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--brand-gradient); }
.auth .card { width: min(420px, 100%); padding: 28px; text-align: center; }
.auth img { width: 72px; height: 72px; }
.auth h1 { font-size: 22px; margin: 10px 0 4px; }
.auth p { color: var(--muted); }
.auth form { display: grid; gap: 10px; margin-top: 16px; text-align: left; }
.auth input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.msg { margin-top: 12px; font-size: 14px; }
.msg.error { color: #b42318; }

/* Admin */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-section { padding: 16px 18px; margin-bottom: 16px; }
.admin-section h2 { margin: 0 0 10px; font-size: 17px; }
.table-scroll { overflow-x: auto; }
.mt { margin-top: 18px; }
