/* RegDesk — stylesheet
   Design note: this is a compliance ledger, not a marketing page.
   Dense, legible, quiet. Colour is reserved for urgency only. */

:root {
  --ink:        #14181f;
  --ink-2:      #414d5e;
  --ink-3:      #6b7787;
  --paper:      #f6f7f8;
  --surface:    #ffffff;
  --rule:       #dfe3e8;
  --rule-soft:  #edf0f3;
  --accent:     #1f6feb;
  --accent-dim: #e8f0fe;

  --ok:        #067647;
  --ok-bg:     #e7f6ee;
  --warning:   #92400e;
  --warning-bg:#fdf3e3;
  --critical:  #b54708;
  --critical-bg:#fdeadb;
  --overdue:   #b42318;
  --overdue-bg:#fdeceb;
  --none:      #6b7787;
  --none-bg:   #eff1f4;

  --radius: 6px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-size: 15px;
}
.brand span { color: var(--ink-3); font-weight: 400; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 6px 11px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-weight: 500;
}
.nav a:hover { background: var(--rule-soft); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: var(--accent); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink-3);
  font-size: 13px;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.page-head .sub { color: var(--ink-3); font-size: 13px; }
.page-head .spacer { margin-left: auto; }

/* ---------- Banner ---------- */
.banner {
  background: var(--warning-bg);
  border-bottom: 1px solid #f0dcc0;
  color: var(--warning);
  padding: 8px 20px;
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.banner strong { font-weight: 650; }

/* ---------- Flash ---------- */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid;
}
.flash-ok    { background: var(--ok-bg);      color: var(--ok);      border-color: #bfe5d1; }
.flash-error { background: var(--overdue-bg); color: var(--overdue); border-color: #f3c9c5; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule-soft);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.card-body { padding: 16px; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
table.data tbody tr:hover { background: #fbfcfd; }
table.data tbody tr:last-child td { border-bottom: none; }

.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok       { background: var(--ok-bg);       color: var(--ok); }
.pill-warning  { background: var(--warning-bg);  color: var(--warning); }
.pill-critical { background: var(--critical-bg); color: var(--critical); }
.pill-overdue  { background: var(--overdue-bg);  color: var(--overdue); }
.pill-none     { background: var(--none-bg);     color: var(--none); }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field .lbl {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password],
input[type=date], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-block;
  padding: 8px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
}
.btn:hover { background: var(--paper); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #1a5fd0; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box { width: 100%; max-width: 360px; }
.login-box .brand { font-size: 22px; display: block; margin-bottom: 4px; }
.login-box .tag { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }
.login-box .card-body { padding: 20px; }
.login-box .btn { width: 100%; text-align: center; }
.login-foot { text-align: center; margin-top: 16px; font-size: 12px; color: var(--ink-3); }

@media (max-width: 640px) {
  .wrap { padding: 16px 12px 40px; }
  .nav a { padding: 6px 8px; }
  table.data th, table.data td { padding: 9px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Filter bar ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.filters select,
.filters input[type=text] { width: auto; min-width: 140px; }
.filters .filter-search { min-width: 230px; flex: 1 1 230px; max-width: 320px; }

/* ---------- Validity bar ----------
   The signature element: time remaining shown as a track that fills up.
   Colour comes from urgency(), so it matches the pill beside it. */
.validity { display: flex; flex-direction: column; gap: 5px; }

.validity-bar {
  height: 5px;
  background: var(--rule-soft);
  border-radius: 100px;
  overflow: hidden;
}
.validity-fill {
  display: block;
  height: 100%;
  border-radius: 100px;
}
.fill-ok       { background: var(--ok); }
.fill-warning  { background: var(--warning); }
.fill-critical { background: var(--critical); }
.fill-overdue  { background: var(--overdue); }
.fill-none     { background: var(--none); }

.validity-text {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

/* ---------- Detail page ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.page-head h1 { margin-top: 2px; }

/* Key-value list in the side panel */
dl.kv { margin: 0; display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 9px 12px; }
dl.kv dt {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  font-weight: 600;
  padding-top: 1px;
}
dl.kv dd { margin: 0; font-size: 13.5px; }
dl.kv dd .muted { font-size: 12px; }

/* Checklist */
ul.checklist { list-style: none; margin: 0; padding: 0; }
ul.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule-soft);
}
ul.checklist li:last-child { border-bottom: none; }
ul.checklist form { display: contents; }

.chk-box {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 1.5px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.chk-box:hover { border-color: var(--accent); }
.chk-box.static { cursor: default; }

ul.checklist li.is-done .chk-box {
  background: var(--ok);
  border-color: var(--ok);
}
ul.checklist li.is-done .chk-label { color: var(--ink-3); }

.chk-label { flex: 1; font-size: 13.5px; }

/* Activity feed */
ul.activity { list-style: none; margin: 0; padding: 0; }
ul.activity li {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 13px;
}
ul.activity li:last-child { border-bottom: none; }
ul.activity li .muted { font-size: 11.5px; }

/* ---------- Form layout ---------- */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
}

.hint {
  display: block;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-top: 4px;
  min-height: 14px;
}

textarea { resize: vertical; min-height: 80px; }

/* ---------- Stat cards ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 780px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: block;
  color: var(--ink);
}
.stat:hover { text-decoration: none; border-color: var(--rule); background: #fbfcfd; }

.stat-num {
  display: block;
  font-size: 27px;
  font-weight: 640;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  margin-top: 4px;
}
.stat-note { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

.stat-ok       { border-left-color: var(--ok); }
.stat-warning  { border-left-color: var(--warning); }
.stat-overdue  { border-left-color: var(--overdue); }
.stat-none     { border-left-color: var(--none); }
.stat-ok .stat-num      { color: var(--ok); }
.stat-warning .stat-num { color: var(--warning); }
.stat-overdue .stat-num { color: var(--overdue); }

/* ---------- Checkbox row ---------- */
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
label.check input[type=checkbox] { width: auto; margin: 0; }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }

.banner-stop {
  background: var(--overdue-bg);
  border-bottom-color: #f3c9c5;
  color: var(--overdue);
}

/* ---------- Sortable headings ---------- */
a.sort-link {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
a.sort-link:hover { color: var(--accent); text-decoration: none; }
a.sort-link.is-active { color: var(--ink); }
.sort-arrow { font-size: 10px; color: var(--accent); }

/* ---------- Top bar search ---------- */
.topbar-search { margin: 0; }
.topbar-search input[type=search] {
  width: 190px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 100px;
  font-size: 13px;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
  -webkit-appearance: none;
}
.topbar-search input[type=search]:focus {
  background: var(--surface);
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
  width: 250px;
}
@media (max-width: 900px) {
  .topbar-search { display: none; }
}

/* A form button that should read as a link. */
.btn-link {
  background: none;
  border: none;
  padding: 0 0 0 10px;
  color: var(--overdue);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }

input[type=file] {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
}

/* ---------- Branding ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { height: 26px; width: auto; max-width: 130px; display: block; }
.brand-app { font-weight: 650; }

.login-logo {
  display: block;
  max-height: 46px;
  max-width: 190px;
  width: auto;
  margin-bottom: 14px;
}

.logo-preview {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
}
.logo-preview img { max-height: 56px; max-width: 100%; width: auto; }

.app-foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 26px;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
}
.app-foot a { color: var(--ink-3); }
.app-foot a:hover { color: var(--accent); }

/* ---------- Settings sub-navigation ---------- */
.subnav {
  display: flex;
  gap: 2px;
  margin: -4px 0 18px;
  border-bottom: 1px solid var(--rule);
}
.subnav a {
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
@media (max-width: 520px) {
  .subnav { overflow-x: auto; }
  .subnav a { white-space: nowrap; padding: 8px 11px; }
}