/* Administration */
.page-actions { margin-bottom: 16px; }
.table-spaced { margin-bottom: 20px; }
.narrow-form { max-width: 440px; }
.signature-preview { display: block; max-width: 180px; max-height: 54px; background: #fff; }
.row-actions form { display: inline; margin: 0 0 0 10px; }
.link-button { padding: 0; margin-right: 8px; background: none; border: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.danger-zone .signature-preview { margin-bottom: 10px; }
.account a { color: var(--muted); }
.check-field { align-self: center; }

/* Audit trail */
.audit-card { max-width: 1100px; }
.audit-card .table-wrap { max-height: 60vh; }
.audit-details { white-space: pre-line; min-width: 260px; }
.link-button.danger-link { color: var(--danger); }
.pager { display: flex; gap: 10px; margin-top: 12px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }

:root {
  --ink: #1c2733;
  --muted: #5b6875;
  --line: #d8dee4;
  --surface: #ffffff;
  --background: #f3f5f7;
  --accent: #0f5c7a;
  --accent-dark: #0b4660;
  --danger: #b3261e;
  --success-bg: #e5f4ea;
  --success-ink: #17592f;
  --error-bg: #fdecea;
  --error-ink: #8c1d18;
  --info-bg: #e7f1f7;
  --info-ink: #0b4660;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); }

h1 { margin: 0 0 16px; font-size: 24px; line-height: 1.25; }
h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 16px 0 4px; font-size: 15px; }
ul { margin: 4px 0; padding-left: 20px; }

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.brand img { height: 38px; width: auto; }
.nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}
.nav a:hover { background: var(--background); }
.nav a.active { background: var(--accent); color: #fff; }
.account { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.account form { margin: 0; }

/* Page */
.content { max-width: 1400px; margin: 0 auto; padding: 24px; }
.footer { padding: 16px 24px 24px; color: var(--muted); font-size: 13px; text-align: center; }
.card {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.form-card { max-width: 820px; }

body.centered {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.narrow { width: 100%; max-width: 400px; margin: 0; }
.narrow h1 { font-size: 20px; }
.login-logo { display: block; max-width: 180px; height: auto; margin: 0 auto 16px; }

/* Dashboard figures */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat {
  display: block;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
a.stat:hover { border-color: var(--accent); }
.stat strong { display: block; font-size: 28px; line-height: 1.2; }
.stat span { color: var(--muted); }

/* Forms */
label { display: block; font-weight: 600; }
label small { color: var(--muted); font-weight: 400; }
input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid #aeb8c2;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid #aeb8c2;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  resize: vertical;
}
.tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  background: var(--error-bg);
  border-radius: 10px;
  color: var(--error-ink);
  font-size: 12px;
  font-weight: 600;
}
.tag-info { background: var(--info-bg); color: var(--info-ink); }
.tag-reason { display: block; color: var(--muted); font-size: 13px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.stack > * + * { margin-top: 14px; }
.stack .button { width: 100%; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; }
.form-actions form { margin: 0; }
.field-error { margin: 4px 0 0; color: var(--error-ink); font-size: 13px; font-weight: 400; }
.readonly-field { font-weight: 600; }
.readonly-field strong { display: block; padding-top: 11px; font-weight: 400; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form label { flex: 0 1 260px; }

.button {
  display: inline-block;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid #aeb8c2;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--background); }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.danger:hover { background: var(--error-bg); }
.button.subtle { padding: 4px 10px; font-weight: 400; }

/* Messages */
.notice { margin: 0 0 16px; padding: 10px 14px; border-radius: 6px; }
.notice.success { background: var(--success-bg); color: var(--success-ink); }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.notice.info { background: var(--info-bg); color: var(--info-ink); }

/* Tabs and filters */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a {
  margin-bottom: -1px;
  padding: 8px 14px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-decoration: none;
}
.tabs a.active { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.filters { margin-bottom: 12px; }
.filters label { flex-basis: 200px; }
.result-count { margin: 0 0 8px; color: var(--muted); }
.intro { margin: -8px 0 16px; color: var(--muted); }

/* Inside the portal's frame, the portal supplies the header and footer. */
.in-frame .topbar, .in-frame .footer { display: none; }
.in-frame .content { padding: 12px; }

/* Tables */
.table-wrap {
  overflow: auto;
  max-height: 72vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  position: sticky;
  top: 0;
  padding: 9px 10px;
  background: #e9edf1;
  text-align: left;
  white-space: nowrap;
}
table.data td { padding: 7px 10px; border-top: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:hover { background: #f7f9fb; }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; }
.actions a + a { margin-left: 10px; }
.empty { padding: 24px; color: var(--muted); text-align: center; }

.details { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .topbar, .content { padding-left: 14px; padding-right: 14px; }
  .nav { order: 3; flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; }
  .details dd { margin-bottom: 8px; }
}

@media print {
  body { background: #fff; }
  .topbar, .footer, .no-print { display: none; }
  .content { max-width: none; padding: 0; }
  .table-wrap { overflow: visible; max-height: none; border: 0; }
  table.data { font-size: 11px; }
  table.data th { position: static; }
}

/* User guide */
.guide { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.guide-video { padding: 0; overflow: hidden; background: #000; }
.guide-video video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; }
.guide-chapters ol { margin: 0; padding-left: 22px; }
.guide-chapters li { padding: 4px 0; }
.guide-chapters .link-button { text-align: left; }
.guide-time { color: var(--muted); font-size: 13px; }
.guide-promo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.guide-promo p { margin: 0; color: var(--muted); }
@media (max-width: 900px) { .guide { grid-template-columns: 1fr; } }
