/* Landing page and the three dashboards (admin, GM, account), plus the
 * generator pages that share the .admin-shell header.
 *
 * Rim Edition interface system: every value here rides the theme variables
 * (see css/substrate-nav.css for the contract). 1px rules; 2px corners on
 * controls, none on cards and plates; striped tables with institutional
 * uppercase headers; no shadows, no lift. */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--sub-bg);
  color: var(--sub-text);
  font-family: var(--font-primary), sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.landing {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

/* ===== HOME PAGE LEAD PARAGRAPH ===== */
.hero-description {
  font-size: 15px;
  color: var(--sub-text);
  max-width: 72ch;
  margin: 0 0 1.75rem;
  line-height: 1.55;
  text-align: left;
}
.hero-description em { color: var(--sub-muted); font-style: italic; }

/* ===== SECTION HEADINGS ===== */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: var(--rule-weight, 1px) solid var(--sub-border);
  padding-bottom: 5px;
  margin-bottom: 12px;
  gap: 1rem;
}
.section-title {
  font-family: var(--font-institutional), sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sub-text);
}
.section-meta {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--sub-muted);
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
}

/* ===== NAV CARDS ===== */
.nav-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 2.5rem;
}
.nav-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  background: var(--sub-surface);
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-left: 3px solid var(--h2-color, var(--sub-teal));
  border-radius: var(--radius-plate, 0);
  padding: 14px 16px 12px;
  color: var(--sub-text);
}
.nav-card:hover {
  border-color: var(--sub-teal);
  border-left-color: var(--sub-teal);
  background: var(--sub-teal-light);
}
.nav-card-tag {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sub-muted);
}
.nav-card-title {
  font-family: var(--font-display, var(--font-primary)), sans-serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  color: var(--h2-color, var(--sub-text));
}
.nav-card:hover .nav-card-title { color: var(--sub-teal); }
.nav-card-desc {
  font-size: 13px;
  color: var(--sub-text);
  line-height: 1.45;
}
.nav-card-action {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sub-teal);
  font-weight: 700;
}

/* ===== SAVED CHARACTERS ===== */
.saved-section { margin-bottom: 2.5rem; }
.char-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.char-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--sub-bg);
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-plate, 0);
  padding: 12px 14px;
  text-decoration: none;
  color: var(--sub-text);
  position: relative;
}
.char-card:hover { border-color: var(--sub-teal); }
.char-card-name {
  font-family: var(--font-display, var(--font-primary)), sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  line-height: 1.1;
}
.char-card-detail {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  color: var(--sub-muted);
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
}
.char-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 6px;
}
.char-card-btn {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
  min-height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-control, 2px);
  background: var(--sub-surface);
  color: var(--sub-text);
  text-decoration: none;
  cursor: pointer;
}
.char-card-btn:hover { border-color: var(--sub-teal); color: var(--sub-teal); }
.char-card-btn.danger { color: var(--sub-ember); border-color: var(--sub-ember); background: var(--sub-bg); }
.char-card-btn.danger:hover { background: var(--sub-ember-light); }

.char-empty {
  grid-column: 1 / -1;
  padding: 2rem 1rem;
  text-align: center;
  background: var(--sub-surface);
  border: var(--rule-weight, 1px) dashed var(--sub-border);
  color: var(--sub-muted);
  font-size: 13px;
  line-height: 1.5;
}
.char-empty strong { color: var(--sub-text); font-weight: 600; }
.char-empty-sub {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
  color: var(--sub-muted);
  margin-top: 6px;
}

/* ===== BUTTONS (shared vocabulary) ===== */
/* .quick-btn is the standard control; .quick-btn.primary the Teal fill. */
.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  justify-content: flex-start;
}
.quick-btn,
.ghost-btn,
.row-btn,
.admin-shell .top-btn {
  font-family: var(--font-institutional), sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 14px;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-control, 2px);
  background: var(--sub-surface);
  color: var(--sub-text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}
.quick-btn:hover, .ghost-btn:hover, .row-btn:hover, .admin-shell .top-btn:hover {
  border-color: var(--sub-teal);
  color: var(--sub-teal);
}
.quick-btn.primary { background: var(--sub-teal); color: var(--sub-bg); border-color: var(--sub-teal); }
.quick-btn.primary:hover { background: var(--sub-text); border-color: var(--sub-text); color: var(--sub-bg); }
.quick-btn.danger { border-color: var(--sub-danger); background: var(--sub-bg); color: var(--sub-danger); }
.quick-btn.danger:hover { background: var(--sub-danger-light); color: var(--sub-danger); }
.quick-btn:disabled, .ghost-btn:disabled, .row-btn:disabled, .row-btn[disabled] {
  color: var(--sub-border); border-color: var(--sub-border); background: var(--sub-surface);
  cursor: not-allowed; opacity: 1;
}
.ghost-btn { background: transparent; border-color: transparent; color: var(--sub-muted); }
.ghost-btn:hover { border-color: var(--sub-border); }
.row-btn { min-height: 26px; padding: 0 8px; margin: 0 2px; font-size: 10px; background: var(--sub-bg); }
.row-btn.danger { border-color: var(--sub-danger); color: var(--sub-danger); }
.row-btn.danger:hover { background: var(--sub-danger-light); }

/* ===== FOOTER (running foot) ===== */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 6px 0 0;
  border-top: var(--rule-weight, 1px) solid var(--sub-border);
  margin-top: 2.5rem;
}
.footer-text {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: var(--sub-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-style: normal;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .nav-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .landing { padding: 0 1rem 2rem; }
  .hero-description { font-size: 14px; }
  .nav-cards { grid-template-columns: 1fr; }
}

/* ===== DASHBOARD SHELL (admin, GM, account, generator pages) ============ */
.admin-shell { max-width: 1400px; }

/* Top bar: the wordmark, a role tag, and role-scoped links. These pages do
   not mount substrate-nav.js, so this is their header band. */
.admin-shell .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: var(--rule-weight, 1px) solid var(--sub-border);
  padding: 0.85rem 0 0.7rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-shell .brand a {
  color: var(--sub-text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.admin-shell .brand-name {
  font-family: var(--font-display, var(--font-primary)), sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--h1-color, var(--sub-text));
}
.admin-shell .brand a:hover .brand-name { color: var(--sub-teal); }
.admin-shell .brand-tag {
  font-family: var(--font-institutional), sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sub-muted);
}
.admin-shell .top-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.admin-shell .top-btn { min-height: 30px; padding: 0 12px; }

/* Dashboard section heading — the same institutional band as the landing. */
.admin-shell .saved-section { padding: 0; }
.admin-shell .section-head {
  padding-bottom: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.admin-shell .section-title {
  font-family: var(--font-display, var(--font-primary)), sans-serif;
  font-size: 20px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--h2-color, var(--sub-text));
}
.admin-shell .section-meta {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
  color: var(--sub-muted);
}

/* Tabs: the active tab inverts to Ink and sits on the rule. */
.admin-tabs {
  display: flex;
  gap: 2px;
  margin: 1rem 0 0;
  border-bottom: var(--rule-weight, 1px) solid var(--sub-text);
  flex-wrap: wrap;
}
.admin-tab {
  background: transparent;
  border: var(--rule-weight, 1px) solid transparent;
  border-bottom: 0;
  min-height: 34px;
  padding: 0 14px;
  font-family: var(--font-institutional), sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
  color: var(--sub-muted);
  cursor: pointer;
}
.admin-tab:hover { color: var(--sub-text); }
.admin-tab.active {
  color: var(--sub-bg);
  background: var(--sub-text);
  border-color: var(--sub-text);
}
.admin-tab-panel[hidden] { display: none; }

/* Toolbar: labelled controls, 32px tall, 1px borders, 2px corners. */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0;
}
.admin-toolbar input[type="text"],
.admin-toolbar input[type="email"],
.admin-toolbar input[type="search"],
.admin-toolbar select,
.chars-pager-size select,
.user-form-row input,
.user-form-row select,
.admin-modal-prompt input {
  font-family: inherit;
  font-size: 14px;
  min-height: 32px;
  padding: 0 10px;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-control, 2px);
  background: var(--sub-bg);
  color: var(--sub-text);
}
.admin-toolbar input:focus,
.admin-toolbar select:focus,
.user-form-row input:focus,
.user-form-row select:focus,
.admin-modal-prompt input:focus {
  outline: none;
  border-color: var(--sub-teal);
}
.admin-toolbar input[type="search"] { min-width: 260px; }
.admin-toolbar input[id="invite-url"] { flex: 1; min-width: 240px; }
.admin-toolbar-spacer { flex: 1; }

/* Tables: institutional uppercase heads on Surface, 1px rules, even-row
   stripe. The wrap frames the table with a single 1px rule. */
.admin-table-wrap {
  overflow-x: auto;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-plate, 0);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.35;
}
.admin-table thead th {
  text-align: left;
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
  color: var(--sub-muted);
  padding: 6px 10px;
  background: var(--sub-surface);
  border-bottom: var(--rule-weight, 1px) solid var(--sub-border);
  white-space: nowrap;
  vertical-align: bottom;
}
/* Sortable column headers: the active sort column shows a solid arrow;
   idle sortables carry a faint ↕ so sortability is visible without hovering. */
.admin-table thead th[data-sort] { cursor: pointer; user-select: none; }
.admin-table thead th[data-sort]::after { content: "↕"; margin-left: 4px; opacity: 0.3; }
.admin-table thead th[data-sort]:hover { color: var(--sub-text); }
.admin-table thead th[data-sort]:hover::after { opacity: 0.6; }
.admin-table thead th[data-sort].sorted-asc,
.admin-table thead th[data-sort].sorted-desc { color: var(--sub-text); }
.admin-table thead th[data-sort].sorted-asc::after  { content: "▲"; opacity: 1; }
.admin-table thead th[data-sort].sorted-desc::after { content: "▼"; opacity: 1; }
.admin-table tbody td {
  padding: 6px 10px;
  border-top: var(--rule-weight, 1px) solid var(--sub-border);
  vertical-align: middle;
}
.admin-table tbody tr:nth-child(even) td { background: var(--sub-surface); }
.admin-table tbody tr:hover td { background: var(--sub-teal-light); }
.admin-table td.actions { white-space: nowrap; }
.admin-table .small { font-size: 11.5px; }
.admin-table .muted.small { color: var(--sub-muted); }

/* Pager strip beneath a table. */
.chars-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: var(--rule-weight, 1px) solid var(--sub-border);
  font-size: 12px;
}
.chars-pager-range {
  color: var(--sub-muted);
  flex: 1;
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
}
.chars-pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--sub-muted);
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--track-inst, 0.06em);
}
.chars-pager-size select { min-height: 28px; padding: 0 6px; font-size: 12px; }

/* Multi-select column. */
.admin-checkbox-col {
  width: 32px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}
.admin-checkbox-col input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--sub-teal);
}
.admin-table-selectable tbody tr.row-selected td,
.admin-table-selectable tbody tr.row-selected:hover td {
  background: var(--sub-teal-light);
}

/* Bulk-action bar — an Amber callout strip above the table when rows are
   selected: the system warning that an action will apply to a set. */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: var(--sub-amber-light);
  border-left: 3px solid var(--sub-amber);
  border-radius: 0 6px 6px 0;
}
.bulk-bar-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--sub-text);
  margin-right: auto;
}

/* Audit log: payload column truncates to one institutional line; the bulk
   badge sits next to action names that came from a bulk endpoint. */
.audit-payload {
  display: inline-block;
  font-family: var(--font-institutional), sans-serif;
  font-size: 11px;
  color: var(--sub-muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
}
.audit-payload:hover { color: var(--sub-text); }
.audit-bulk-badge {
  display: inline-block;
  padding: 0 5px;
  margin-left: 4px;
  font-family: var(--font-institutional), sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: var(--rule-weight, 1px) solid var(--sub-muted);
  border-radius: var(--radius-control, 2px);
  color: var(--sub-muted);
  vertical-align: middle;
}

/* User create/edit form modal. */
.user-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0.7rem;
}
.user-form-row label,
.user-form-checkbox,
.admin-modal-prompt label {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
  color: var(--sub-muted);
}
.user-form-row input:disabled,
.user-form-row select:disabled,
.user-form-checkbox input:disabled { opacity: 0.5; cursor: not-allowed; }
.user-form-checkbox:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }
.user-form-row-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.user-form-row-inline label[for] { margin-right: 0.3rem; }
.user-form-row-inline select { min-width: 100px; }
.user-form-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}
.user-form-checkbox input { accent-color: var(--sub-teal); }
.user-form-error {
  min-height: 1.2em;
  margin-top: 0.4rem;
  font-size: 12px;
  color: var(--sub-danger);
}

/* Badges: labelled 2px chips. Color never carries the state alone — the
   text does — so every tone keeps the same shape. */
.badge {
  display: inline-block;
  padding: 1px 7px;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-control, 2px);
  background: var(--sub-surface);
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
  line-height: 1.6;
  color: var(--sub-muted);
}
.badge-admin    { color: var(--sub-teal); border-color: var(--sub-teal); background: var(--sub-teal-light); }
.badge-active   { color: var(--sub-success); border-color: var(--sub-success); background: var(--sub-bg); }
.badge-disabled { color: var(--sub-danger); border-color: var(--sub-danger); background: var(--sub-danger-light); }
.badge-lapsed   { color: var(--sub-amber); border-color: var(--sub-amber); background: var(--sub-amber-light); }
.badge-neutral  { color: var(--sub-iron); border-color: var(--sub-border); background: var(--sub-surface); }

/* ---- Admin: Agreements tab ------------------------------------------- */
.agreement-summary {
  padding: 8px 12px;
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-bottom: none;
  background: var(--sub-surface);
  font-size: 12.5px;
}
.agreement-summary strong { color: var(--sub-text); }

.agreement-card {
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-left: 3px solid var(--sub-border);
  background: var(--sub-bg);
  padding: 12px 14px;
  margin: 0 0 10px;
}
.agreement-card.is-current { border-left-color: var(--sub-success); }

.agreement-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.3rem 1rem;
  margin: 0;
  font-size: 12.5px;
}
.agreement-facts dt {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
  color: var(--sub-muted);
  white-space: nowrap;
}
.agreement-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.agreement-facts .mono,
.agreement-card .mono { font-family: var(--font-institutional), sans-serif; }
.agreement-facts .small { font-size: 11.5px; }
.agreement-prior { margin-top: 0.9rem; }
.agreement-prior-head {
  font-family: var(--font-institutional), sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--track-inst, 0.06em);
  text-transform: uppercase;
  color: var(--sub-muted);
  margin-bottom: 0.45rem;
}
@media (max-width: 640px) {
  .agreement-facts { grid-template-columns: minmax(0, 1fr); gap: 0.1rem; }
  .agreement-facts dt { margin-top: 0.4rem; }
}

/* Confirm modal: a ruled plate on the Ground. */
.admin-modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
/* The HTML [hidden] attribute resolves to display:none via the UA
   stylesheet, but the author display:flex above outranks it. */
.admin-modal-backdrop[hidden] { display: none; }
.admin-modal {
  background: var(--sub-bg);
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: var(--radius-plate, 0);
  padding: 0;
  max-width: 520px;
  width: 100%;
}
.admin-modal-title {
  font-family: var(--font-display, var(--font-primary)), sans-serif;
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--h1-color, var(--sub-text));
  padding: 14px 18px 10px;
  border-bottom: var(--rule-weight, 1px) solid var(--sub-border);
  margin: 0;
}
.admin-modal-body { font-size: 14px; line-height: 1.5; padding: 14px 18px 0; }
.admin-modal-body p { margin: 0.3rem 0; }
.admin-modal-body .confirm-id {
  display: inline-block;
  padding: 1px 8px;
  font-family: var(--font-institutional), sans-serif;
  font-size: 12px;
  background: var(--sub-surface);
  border: var(--rule-weight, 1px) solid var(--sub-border);
  border-radius: 3px;
  color: var(--sub-text);
  user-select: all;
}
.admin-modal-prompt { margin: 0.7rem 18px 0; }
.admin-modal-prompt label { display: block; margin-bottom: 4px; }
.admin-modal-prompt input { width: 100%; }
.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 14px 0 0;
  padding: 12px 18px 16px;
  border-top: var(--rule-weight, 1px) solid var(--sub-border);
}
