/* eastaustralis auth + hub UI - extends site.css tokens. White, minimal, compact.
   One type scale (--text-*), one spacing scale (--space-*), single maroon accent;
   the only non-maroon colours are --danger (errors) and --ok (success). */

.auth-wrap {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(2rem, 7vw, 4.5rem) var(--space-4);
}
.card {
  width: 100%;
  max-width: 22rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: var(--space-5);
  background: var(--ground);
}
.card.wide { max-width: 42rem; }

.auth-title { margin: 0 0 var(--space-1); font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.02em; }
.auth-sub { margin: 0 0 var(--space-5); color: var(--muted); font-size: var(--text-sm); }

.field { margin: 0 0 var(--space-4); }
.field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 var(--space-1);
}
.field input, .field select {
  width: 100%;
  font: inherit;
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: var(--space-2) var(--space-3);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
/* input error state */
.field.error input, .field.error select, .field.error textarea, .field input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-tint);
}

.btn {
  display: inline-block;
  width: 100%;
  font: inherit;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--on-accent);
  background: var(--accent-solid);
  border: 1px solid var(--accent-solid);
  border-radius: 6px;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  text-decoration: none;   /* <a class="btn"> must not inherit the anchor underline */
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:active { filter: brightness(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; }
/* loading state: aria-busy="true" set by the submit handlers */
.btn[aria-busy="true"] { color: transparent !important; position: relative; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 0.95rem; height: 0.95rem; margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid var(--on-accent); border-top-color: transparent; border-radius: 50%;
  animation: ea-spin 0.6s linear infinite;
}
.btn-ghost[aria-busy="true"]::after { border-color: var(--ink); border-top-color: transparent; }
@keyframes ea-spin { to { transform: rotate(360deg); } }
/* Respect reduced-motion: keep the busy cue but slow the spin so it doesn't strobe. */
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::after { animation-duration: 1.6s; }
}
.btn-ghost {
  width: auto;
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}
.btn-ghost:hover { background: transparent; border-color: var(--muted); }

/* Native file inputs render a grey, beveled, square OS "Choose file" button that clashes with
   the flat rounded site buttons. Style the button pseudo-element to match a ghost button so
   upload controls (issues, marketing, intake) stay on-brand. */
input[type="file"]::file-selector-button,
input[type="file"]::-webkit-file-upload-button {
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 6px;
  padding: var(--space-1) var(--space-3); margin-right: var(--space-3);
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover,
input[type="file"]::-webkit-file-upload-button:hover { border-color: var(--muted); }

.msg { margin: var(--space-4) 0 0; font-size: var(--text-sm); min-height: 1rem; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--ok); }

.note { color: var(--muted); font-size: var(--text-sm); margin: var(--space-4) 0 0; }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); }
.mono {
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  background: #f5f5f6;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
}
a.link { color: var(--accent); }
a.link:hover { color: var(--accent-strong); }

table.members { width: 100%; border-collapse: collapse; margin: var(--space-4) 0 0; font-size: var(--text-sm); }
table.members th, table.members td {
  text-align: left;
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--line);
}
table.members th { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }

/* admin members: inline row editors (role select + action button cluster) */
.row-select {
  font: inherit; font-size: var(--text-sm); color: var(--ink); background: var(--ground);
  border: 1px solid var(--line); border-radius: 6px; padding: var(--space-1) var(--space-2);
}
.row-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.row-actions { display: flex; gap: var(--space-1); flex-wrap: wrap; }

/* admin audit: sortable headers + horizontal scroll for the wide activity/session tables */
.table-scroll { overflow-x: auto; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable .sort-ind { color: var(--accent); }

.divider { height: 1px; background: var(--line); border: 0; margin: var(--space-5) 0; }
.h-sec { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 var(--space-3); }

/* ===== hub dashboard (tabs + data relays) ===== */
.hub-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--app-measure);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 4vw, 2rem) var(--space-8);
}
.hub-main.hub-wide { max-width: min(98vw, 100rem); }
.hub-head { margin: 0 0 var(--space-5); }
.hub-h1 { margin: var(--space-1) 0 var(--space-1); font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.025em; }
.hub-sub { margin: 0; color: var(--muted); font-size: var(--text-sm); }

/* tab bar */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin: 0 0 var(--space-5); }
.tab {
  font: inherit; font-size: var(--text-sm); font-weight: 600;
  color: var(--muted); background: transparent; border: 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: var(--space-2) var(--space-4); cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel[hidden] { display: none; }

/* shared relay bits */
.relay-empty, .relay-loading { color: var(--muted); font-size: var(--text-sm); margin: 0; padding: var(--space-4); }
.relay-loading { font-style: italic; }
.muted { color: var(--muted); }

/* smartsheets: list + embedded view */
.relay { display: flex; gap: var(--space-4); align-items: flex-start; }
.relay-list {
  flex: 0 0 13rem; max-width: 13rem;
  display: flex; flex-direction: column; gap: var(--space-1);
  border: 1px solid var(--line); border-radius: 8px; padding: var(--space-2);
  max-height: 70vh; overflow-y: auto;
}
.relay-item {
  font: inherit; font-size: var(--text-sm); text-align: left;
  color: var(--ink); background: transparent; border: 0; border-radius: 6px;
  padding: var(--space-2) var(--space-2); cursor: pointer; line-height: 1.3;
}
.relay-item:hover { background: var(--accent-tint); }
.relay-item.is-active { background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; }
.relay-view { flex: 1 1 auto; min-width: 0; }
.relay-viewbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); margin: 0 0 var(--space-2); }
.relay-title { font-weight: 600; font-size: var(--text-base); }
.relay-frame-wrap {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #fafafa; min-height: 70vh;
}
.relay-frame { width: 100%; height: 70vh; border: 0; display: block; background: #fff; }
.relay-foot { color: var(--muted); font-size: var(--text-xs); margin: var(--space-2) 0 0; }

/* vfab: control bar + table */
.relay-bar { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; margin: 0 0 var(--space-4); }
.field.inline { margin: 0; }
.field.inline label { margin: 0 0 var(--space-1); }
.relay-search {
  flex: 1 1 14rem; min-width: 10rem; font: inherit; font-size: var(--text-sm);
  color: var(--ink); background: var(--ground); border: 1px solid var(--line);
  border-radius: 6px; padding: var(--space-2) var(--space-2); align-self: flex-end;
}
.relay-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.relay-table-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: 72vh; }
.relay-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.relay-table th, .relay-table td {
  text-align: left; padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--line);
  white-space: nowrap; max-width: 22rem; overflow: hidden; text-overflow: ellipsis;
  vertical-align: top;
}
.relay-table thead th {
  position: sticky; top: 0; background: var(--ground); z-index: 1;
  color: var(--muted); font-weight: 600; font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.relay-table .vfab-json { padding: var(--space-1) var(--space-2); font-size: var(--text-xs); }
.vfab-pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  font-size: var(--text-xs); color: var(--ink);
  background: #f5f5f6; border-radius: 6px; padding: var(--space-3);
}

/* admin: stacked cards (legacy; admin is now tabbed) */
.stack { width: 100%; max-width: 42rem; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-5); }

/* settings: read-only identity key/value rows */
.kv { display: grid; grid-template-columns: 7rem 1fr; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-2); font-size: var(--text-sm); }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }

@media (max-width: 640px) {
  .relay { flex-direction: column; }
  .relay-list { flex-basis: auto; max-width: none; width: 100%; flex-direction: row; flex-wrap: wrap; max-height: none; }
  .relay-frame, .relay-frame-wrap { min-height: 60vh; height: 60vh; }
}

@media (prefers-color-scheme: dark) {
  .mono { background: #1a1a1d; }
  .relay-frame-wrap { background: #161618; }
  .relay-frame { background: #fff; }   /* smartsheet pages are light; keep a white canvas */
  .vfab-pre { background: #1a1a1d; }
}

/* ===========================================================================
   v2 app components - dashboard, data tables, registers, issues.
   Token-driven; white ground, hairline borders, one type scale, single maroon
   accent + the two functional colours where they carry meaning.
   =========================================================================== */

/* page header (reused across dashboard / issues / registers) */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin: 0 0 var(--space-5); }
.page-head .titles { min-width: 0; }
.page-h1 { margin: var(--space-1) 0 var(--space-1); font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.025em; }
.page-sub { margin: 0; color: var(--muted); font-size: var(--text-sm); }
/* align-items:flex-end so a label+control field lines up with a bare button on
   its bottom edge (plain center pushes the select below the button, because the
   field's label stacks above the control). Matches .toolbar. */
.page-actions { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.page-actions .field { margin: 0; }

/* dashboard: a responsive card grid that fills the width (auto-fit variant) */
.dash-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); margin: 0 0 var(--space-5); }
.dash-section { margin: 0 0 var(--space-5); }
.stat {
  border: 1px solid var(--line); border-radius: 10px; padding: var(--space-4) var(--space-4);
  background: var(--ground); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0;
}
.stat .stat-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.stat .stat-num { font-size: var(--text-xl); font-weight: 650; line-height: 1; letter-spacing: -0.02em; }
.stat .stat-foot { font-size: var(--text-xs); color: var(--muted); }
.stat.attn .stat-num { color: var(--accent); }       /* maroon = needs attention */
.stat-link, .stat a.stat-link { text-decoration: none; }   /* the whole stat tile is the <a> — must not underline its label/number */
.dash-panel { border: 1px solid var(--line); border-radius: 10px; padding: var(--space-4) var(--space-4); background: var(--ground); }
.dash-panel > h2 { margin: 0 0 var(--space-2); font-size: var(--text-base); font-weight: 650; }
.dash-cols { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }

/* dashboard roll-up bar (issues by status) - monochrome, maroon for attention */
.statbar { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-1) 0 0; }
.statbar-row { display: grid; grid-template-columns: 6.5rem 1fr 2rem; gap: var(--space-3); align-items: center; font-size: var(--text-xs); }
.statbar-track { background: var(--line); border-radius: 999px; height: 0.5rem; overflow: hidden; }
.statbar-fill { background: var(--muted); height: 100%; border-radius: 999px; }
.statbar-row.attn .statbar-fill { background: var(--accent); }
.statbar-row .statbar-n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* a generic data table for issues / units / lines / people */
.data-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 74vh; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th, .data-table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table thead th {
  position: sticky; top: 0; background: var(--ground); z-index: 1;
  color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table tbody tr { cursor: default; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--accent-tint); }
.data-table tbody tr.inactive { opacity: 0.55; }   /* shaded archived/closed rows */
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.trunc { max-width: 24rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table .t-empty { color: var(--muted); padding: var(--space-5); text-align: center; }
.data-key { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; white-space: nowrap; }
.data-title-cell { font-weight: 600; }
/* Keyboard-reachable row link: looks native in the cell, but is a real focusable anchor
   (whole row stays mouse-clickable via JS). Gives list rows keyboard + screen-reader access. */
.data-table a.rowlink { color: inherit; text-decoration: none; }
.data-table a.rowlink:hover { color: var(--accent-strong); text-decoration: underline; }

/* sub-tab strip (registers: Lines / Units / People) */
.subtabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin: 0 0 var(--space-5); flex-wrap: wrap; }
.subtab {
  font: inherit; font-size: var(--text-sm); font-weight: 600; text-decoration: none;
  color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent;
  margin-bottom: -1px; padding: var(--space-2) var(--space-3); cursor: pointer;
}
.subtab:hover { color: var(--ink); }
.subtab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* status / severity badges (chips) - greyscale by default; maroon for attention */
.badge {
  display: inline-block; font-size: var(--text-xs); font-weight: 600; line-height: 1.4;
  padding: var(--space-1) var(--space-2); border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: var(--ground); white-space: nowrap;
}
.badge.ink { color: var(--ink); border-color: var(--muted); }
.badge.attn { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-tint); }

/* filter / action toolbar */
.toolbar { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; margin: 0 0 var(--space-4); }
.toolbar .field { margin: 0; }
.toolbar .field label { margin: 0 0 var(--space-1); }
.toolbar select, .toolbar input {
  font: inherit; font-size: var(--text-sm); color: var(--ink); background: var(--ground);
  border: 1px solid var(--line); border-radius: 6px; padding: var(--space-2) var(--space-2);
}
.toolbar select:focus, .toolbar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.toolbar .grow { flex: 1 1 12rem; min-width: 9rem; }
.toolbar .spacer { flex: 1 1 auto; }

/* small + secondary buttons (reuse .btn tokens) */
.btn-sm { width: auto; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }

/* wide form layout for create/edit (data pages, not the narrow auth cards) */
.form-grid { display: grid; gap: var(--space-4) var(--space-4); grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.form-grid .field { margin: 0; }
.form-grid .field.full { grid-column: 1 / -1; }
.field textarea {
  width: 100%; font: inherit; font-size: var(--text-base); color: var(--ink); background: var(--ground);
  border: 1px solid var(--line); border-radius: 6px; padding: var(--space-2) var(--space-3); resize: vertical; min-height: 6rem;
}
.field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.form-actions { display: flex; gap: var(--space-2); align-items: center; margin: var(--space-4) 0 0; flex-wrap: wrap; }

/* issue detail: main column + meta sidebar */
.detail-grid { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr); align-items: start; }
.detail-main, .detail-side { border: 1px solid var(--line); border-radius: 10px; padding: var(--space-4) var(--space-4); background: var(--ground); }
.detail-body { white-space: pre-wrap; word-break: break-word; margin: var(--space-2) 0 0; }
.timeline { list-style: none; margin: var(--space-2) 0 0; padding: 0; }
.timeline li { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); font-size: var(--text-sm); }
.timeline li:last-child { border-bottom: 0; }
.timeline .t-meta { color: var(--muted); font-size: var(--text-xs); }
.linklist { list-style: none; margin: var(--space-1) 0 0; padding: 0; }
.linklist li { padding: var(--space-1) 0; }

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* relay (Hub): let embeds fill the screen instead of a fixed 70vh */
.hub-wide .relay-frame-wrap, .hub-wide .relay-frame { min-height: calc(100dvh - 16rem); height: calc(100dvh - 16rem); }
.relay-list.collapsible { flex: 0 0 16rem; max-width: 16rem; }

@media (prefers-color-scheme: dark) {
  .stat, .dash-panel, .detail-main, .detail-side { background: #141416; }
  .data-table thead th { background: #141416; }
}
