@charset "utf-8";

/* ==========================================================================
   GrantsMaster design system
   --------------------------------------------------------------------------
   One stylesheet, one set of tokens. Rules of the system:
   - Radii: 4px (small controls, badges) and 6px (cards, buttons, inputs).
   - Depth comes from 1px borders and background tints, never from shadows.
     The only shadow in the app is on floating menus (--gm-shadow-popover).
   - Accent borders (border-left stripes), gradients and emoji are not used.
   - One typeface (Inter) and five sizes: 12 / 13 / 14 / 16 / 20 px.
   - Cards are a single level deep: page background -> card -> content.
     Inside a card, use sections (.gm-section) and dividers, not more cards.
   - Status is shown with .gm-badge / .gm-dot colours, which are the only
     semantic colours on the page.
   ========================================================================== */

:root {
  --gm-font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gm-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --gm-text-xs: 12px;
  --gm-text-sm: 13px;
  --gm-text-md: 14px;
  --gm-text-lg: 16px;
  --gm-text-xl: 20px;

  --gm-radius-sm: 4px;
  --gm-radius-md: 6px;
  --gm-radius-lg: 8px;

  --gm-space-1: 4px;
  --gm-space-2: 8px;
  --gm-space-3: 12px;
  --gm-space-4: 16px;
  --gm-space-5: 20px;
  --gm-space-6: 24px;
  --gm-space-8: 32px;

  --gm-primary: #123456;
  --gm-primary-hover: #0d2740;
  --gm-primary-soft: #e8eef5;
  --gm-primary-text: #123456;
  --gm-gold: #d9a441;

  --gm-bg: #f4f6f8;
  --gm-surface: #ffffff;
  --gm-surface-2: #f8fafc;
  --gm-border: #e3e8ee;
  --gm-border-strong: #cbd5e1;

  --gm-text: #1f2937;
  --gm-text-2: #4b5563;
  --gm-text-3: #6b7280;
  --gm-text-4: #9ca3af;

  --gm-ok: #15803d;
  --gm-ok-bg: #ecfdf3;
  --gm-warn: #b45309;
  --gm-warn-bg: #fffbeb;
  --gm-bad: #b91c1c;
  --gm-bad-bg: #fef2f2;
  --gm-info: #1d4ed8;
  --gm-info-bg: #eff6ff;
  --gm-neutral: #475569;
  --gm-neutral-bg: #f1f5f9;

  --gm-focus: 0 0 0 3px rgba(18, 52, 86, 0.18);
  --gm-shadow-popover: 0 8px 24px rgba(15, 23, 42, 0.12);

  --gm-top-height: 56px;
  --gm-nav-width: 232px;

  /* Legacy aliases kept so older markup keeps rendering sensibly */
  --gm-primary-dark: var(--gm-primary-hover);
  --gm-primary-light: #1f4a74;
  --gm-card-bg: var(--gm-surface);
  --gm-border-light: var(--gm-border);
  --gm-text-main: var(--gm-text);
  --gm-text-muted: var(--gm-text-3);
  --gm-text-light: var(--gm-text-4);
  --gm-success: var(--gm-ok);
  --gm-success-bg: var(--gm-ok-bg);
  --gm-warning: var(--gm-warn);
  --gm-warning-bg: var(--gm-warn-bg);
  --gm-danger: var(--gm-bad);
  --gm-danger-bg: var(--gm-bad-bg);
  --gm-shadow-sm: none;
  --gm-shadow-md: none;
  --gm-shadow-lg: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.gm-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gm-bg);
  color: var(--gm-text);
  font-family: var(--gm-font);
  font-size: var(--gm-text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:where(.gm-body) h1,
:where(.gm-body) h2,
:where(.gm-body) h3,
:where(.gm-body) h4,
:where(.gm-body) h5,
:where(.gm-body) h6 {
  font-family: inherit;
  font-weight: 600;
  color: var(--gm-text);
  line-height: 1.3;
  margin: 0 0 var(--gm-space-2);
}

.gm-body h1 { font-size: var(--gm-text-xl); }
.gm-body h2 { font-size: var(--gm-text-lg); }
.gm-body h3 { font-size: var(--gm-text-md); }
:where(.gm-body) h4,
:where(.gm-body) h5,
.gm-body h6 { font-size: var(--gm-text-sm); }

:where(.gm-body) p {
  margin: 0 0 var(--gm-space-3);
}

:where(.gm-body) a {
  color: var(--gm-primary-text);
  text-decoration: none;
}

:where(.gm-body) a:hover {
  text-decoration: underline;
}

:where(.gm-body) code,
.gm-mono {
  font-family: var(--gm-font-mono);
  font-size: 0.92em;
  color: inherit;
}

:where(.gm-body) hr {
  border: 0;
  border-top: 1px solid var(--gm-border);
  margin: var(--gm-space-4) 0;
  opacity: 1;
}

/* ==========================================================================
   Top bar
   ========================================================================== */
.gm-top {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gm-space-4);
  height: var(--gm-top-height);
  padding: 0 var(--gm-space-6);
  background: var(--gm-primary);
  color: #ffffff;
}

.gm-brand {
  display: flex;
  align-items: center;
  gap: var(--gm-space-3);
  color: #ffffff;
  text-decoration: none;
  min-width: 0;
}

.gm-brand:hover {
  text-decoration: none;
  color: #ffffff;
}

.gm-brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 2px;
  background: #ffffff;
  border-radius: var(--gm-radius-sm);
}

.gm-brand-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.gm-brand-text {
  line-height: 1.2;
}

.gm-brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
}

.gm-brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--gm-gold);
}

.gm-user {
  display: flex;
  align-items: center;
  gap: var(--gm-space-2);
  min-width: 0;
}

.gm-user-identity {
  display: flex;
  align-items: center;
  gap: var(--gm-space-2);
  padding: 0 var(--gm-space-2);
  min-width: 0;
}

.gm-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-size: var(--gm-text-sm);
  font-weight: 600;
}

.gm-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.gm-user-name {
  font-size: var(--gm-text-sm);
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gm-role-badge {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

/* Ghost controls on the dark bar: icon button, profile link, logout */
.gm-top-btn,
.gm-logout,
.gm-btn-profile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 var(--gm-space-3);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--gm-radius-md);
  background: transparent;
  color: #ffffff;
  font-family: inherit;
  font-size: var(--gm-text-sm);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.gm-top-btn:hover,
.gm-logout:hover,
.gm-btn-profile:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
  text-decoration: none;
}

.gm-top-btn:focus-visible,
.gm-logout:focus-visible,
.gm-btn-profile:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.gm-top-btn-icon {
  width: 32px;
  padding: 0;
  position: relative;
}

.gm-top-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--gm-radius-sm);
  background: #dc2626;
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

/* Notification menu (the one place a shadow is allowed) */
.gm-notif-wrap {
  position: relative;
}

.gm-notif-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  box-shadow: var(--gm-shadow-popover);
  color: var(--gm-text);
  z-index: 1100;
  overflow: hidden;
}

.gm-notif-menu[hidden] {
  display: none;
}

.gm-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px var(--gm-space-3);
  border-bottom: 1px solid var(--gm-border);
  font-size: var(--gm-text-sm);
  font-weight: 600;
}

.gm-notif-head a {
  font-size: var(--gm-text-xs);
  font-weight: 500;
}

.gm-notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.gm-notif-item {
  display: block;
  padding: 10px var(--gm-space-3);
  border-bottom: 1px solid var(--gm-border);
  color: var(--gm-text);
  text-decoration: none;
}

.gm-notif-item:last-child {
  border-bottom: 0;
}

.gm-notif-item:hover {
  background: var(--gm-surface-2);
  text-decoration: none;
}

.gm-notif-item.is-unread {
  background: var(--gm-info-bg);
}

.gm-notif-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--gm-text-sm);
  font-weight: 600;
}

.gm-notif-text {
  font-size: var(--gm-text-xs);
  color: var(--gm-text-2);
  line-height: 1.4;
}

.gm-notif-time {
  margin-top: 2px;
  font-size: 11px;
  color: var(--gm-text-4);
}

.gm-notif-empty {
  padding: var(--gm-space-6);
  text-align: center;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

/* ==========================================================================
   Shell: sidebar + main
   ========================================================================== */
.gm-shell {
  display: flex;
  align-items: flex-start;
  gap: var(--gm-space-6);
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--gm-space-6);
}

.gm-nav-toggle {
  display: none;
  align-items: center;
  gap: var(--gm-space-2);
  margin-bottom: var(--gm-space-3);
  padding: 8px 12px;
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  color: var(--gm-text);
  font-family: inherit;
  font-size: var(--gm-text-sm);
  font-weight: 500;
  cursor: pointer;
}

.gm-nav {
  flex-shrink: 0;
  width: var(--gm-nav-width);
  position: sticky;
  top: calc(var(--gm-top-height) + var(--gm-space-6));
  max-height: calc(100vh - var(--gm-top-height) - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.gm-nav-inner {
  padding: 0;
}

.gm-nav-section {
  margin-bottom: var(--gm-space-4);
}

.gm-nav-section:last-child {
  margin-bottom: 0;
}

.gm-nav-label {
  margin: 0 var(--gm-space-3) 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gm-text-4);
}

.gm-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gm-nav li {
  margin-bottom: 1px;
}

.gm-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px var(--gm-space-3);
  border-radius: var(--gm-radius-md);
  color: var(--gm-text-2);
  font-size: var(--gm-text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.gm-nav a:hover {
  background: #e9edf2;
  color: var(--gm-text);
  text-decoration: none;
}

.gm-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--gm-text-4);
}

.gm-nav-icon svg {
  width: 16px;
  height: 16px;
}

.gm-nav-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gm-nav-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 0 6px;
  border-radius: var(--gm-radius-sm);
  background: var(--gm-primary);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.gm-nav li.is-active a {
  background: var(--gm-primary-soft);
  color: var(--gm-primary-text);
  font-weight: 600;
}

.gm-nav li.is-active .gm-nav-icon,
.gm-nav a:hover .gm-nav-icon {
  color: currentColor;
}

/* The main column is a plain container: page content supplies its own cards. */
.gm-main {
  flex: 1;
  min-width: 0;
}

/* Legacy pages that print bare tables or forms get a surface automatically. */
.gm-main:not(:has(.gm-card, .gm-panel, .gm-page-head, .gm-hero, .gm-surface, .gm-kpis, .card, .gm-pw, .gm-message-page, .gm-empty-state, .gm-alert)) {
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  padding: var(--gm-space-5);
}

.gm-surface {
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  padding: var(--gm-space-5);
}

/* ==========================================================================
   Page header & toolbars
   ========================================================================== */
.gm-page-head,
.gm-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gm-space-3) var(--gm-space-4);
  margin-bottom: var(--gm-space-5);
}

.gm-page-head > div:first-child,
.gm-hero > div:first-child {
  min-width: 0;
}

.gm-page-head h1,
.gm-hero h1 {
  margin: 0 0 2px;
  font-size: var(--gm-text-xl);
  font-weight: 600;
  color: var(--gm-text);
}

.gm-page-head p,
.gm-hero p {
  margin: 0;
  font-size: var(--gm-text-md);
  color: var(--gm-text-3);
}

.gm-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gm-space-2);
}

.gm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gm-space-2);
  margin-bottom: var(--gm-space-4);
}

.gm-toolbar form {
  display: contents;
}

.gm-toolbar .gm-grow {
  flex: 1 1 240px;
  min-width: 200px;
}

.gm-toolbar input[type="text"],
.gm-toolbar input[type="search"],
.gm-toolbar input[type="date"],
.gm-toolbar select {
  width: auto;
}

.gm-toolbar .gm-grow input,
.gm-toolbar .gm-grow select {
  width: 100%;
}

.gm-toolbar-note {
  margin-left: auto;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

/* ==========================================================================
   Cards, panels & sections
   ========================================================================== */
.gm-card,
.gm-panel {
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  margin-bottom: var(--gm-space-4);
}

.gm-card:last-child,
.gm-panel:last-child {
  margin-bottom: 0;
}

.gm-panel {
  padding: var(--gm-space-4);
}

.gm-card-header,
.gm-panel-h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gm-space-2) var(--gm-space-4);
  padding: var(--gm-space-3) var(--gm-space-4);
  border-bottom: 1px solid var(--gm-border);
}

.gm-panel-h {
  margin: calc(-1 * var(--gm-space-4)) calc(-1 * var(--gm-space-4)) var(--gm-space-4);
}

.gm-card-header h1,
.gm-card-header h2,
.gm-card-header h3,
.gm-panel-h h2 {
  margin: 0;
  font-size: var(--gm-text-md);
  font-weight: 600;
  color: var(--gm-text);
}

.gm-card-header p {
  margin: 2px 0 0;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
  flex-basis: 100%;
}

.gm-card-header > div:first-child,
.gm-card-title {
  min-width: 0;
}

.gm-card-title h2,
.gm-card-title h3 {
  margin: 0;
  font-size: var(--gm-text-md);
  font-weight: 600;
}

.gm-card-title p {
  margin: 2px 0 0;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gm-space-2);
  margin-left: auto;
}

.gm-panel-h a {
  font-size: var(--gm-text-sm);
  font-weight: 500;
}

.gm-card-body {
  padding: var(--gm-space-4);
}

.gm-card-body > :last-child {
  margin-bottom: 0;
}

.gm-card-footer {
  padding: var(--gm-space-3) var(--gm-space-4);
  border-top: 1px solid var(--gm-border);
  background: var(--gm-surface-2);
  border-radius: 0 0 var(--gm-radius-md) var(--gm-radius-md);
}

/* A card inside a card is flattened to a section: no second frame */
.gm-card .gm-card,
.gm-card .gm-panel {
  border: 0;
  border-top: 1px solid var(--gm-border);
  border-radius: 0;
  margin: 0;
}

.gm-card .gm-card:first-child {
  border-top: 0;
}

.gm-section {
  padding: var(--gm-space-4) 0;
  border-top: 1px solid var(--gm-border);
}

.gm-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.gm-section:last-child {
  padding-bottom: 0;
}

.gm-section-title {
  margin: 0 0 var(--gm-space-3);
  font-size: var(--gm-text-md);
  font-weight: 600;
  color: var(--gm-text);
}

.gm-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gm-space-1) var(--gm-space-4);
  margin-bottom: var(--gm-space-3);
}

.gm-section-head .gm-section-title {
  margin: 0;
}

.gm-section-meta {
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-label {
  margin: 0 0 var(--gm-space-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gm-text-3);
}

/* ==========================================================================
   Dashboard widgets
   ========================================================================== */
.gm-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--gm-space-3);
  margin-bottom: var(--gm-space-4);
}

.gm-kpi {
  padding: var(--gm-space-4);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
}

.gm-kpi-label {
  margin: 0 0 var(--gm-space-1);
  font-size: var(--gm-text-xs);
  font-weight: 500;
  color: var(--gm-text-3);
}

.gm-kpi-value {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--gm-text);
  font-variant-numeric: tabular-nums;
}

.gm-kpi-hint {
  margin: var(--gm-space-1) 0 0;
  font-size: var(--gm-text-xs);
  color: var(--gm-text-4);
}

.gm-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gm-space-4);
}

@media (min-width: 1024px) {
  .gm-grid {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

.gm-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gm-space-4);
}

.gm-chart-panel canvas {
  width: 100% !important;
  max-height: 260px;
}

/* ==========================================================================
   Forms
   ========================================================================== */
.gm-form-group {
  margin-bottom: var(--gm-space-4);
  min-width: 0;
}

.gm-form-label,
:where(.gm-body) label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--gm-text-sm);
  font-weight: 500;
  color: var(--gm-text);
}

:where(.gm-body) label.gm-check,
:where(.gm-body) label.gm-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.gm-required {
  color: var(--gm-bad);
  font-weight: 600;
}

.gm-optional {
  font-weight: 400;
  color: var(--gm-text-3);
}

:where(.gm-body) input[type="text"],
:where(.gm-body) input[type="password"],
:where(.gm-body) input[type="email"],
:where(.gm-body) input[type="tel"],
:where(.gm-body) input[type="number"],
:where(.gm-body) input[type="date"],
:where(.gm-body) input[type="search"],
:where(.gm-body) input[type="url"],
:where(.gm-body) input[type="file"],
:where(.gm-body) select,
:where(.gm-body) textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: var(--gm-text-sm);
  line-height: 1.4;
  color: var(--gm-text);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border-strong);
  border-radius: var(--gm-radius-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:where(.gm-body) select {
  padding-right: 28px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

:where(.gm-body) select[multiple],
:where(.gm-body) select[size] {
  background-image: none;
  padding-right: 10px;
  min-height: auto;
}

:where(.gm-body) textarea {
  min-height: 88px;
  resize: vertical;
}

:where(.gm-body) input[type="file"] {
  padding: 5px 10px;
}

:where(.gm-body) input:focus,
:where(.gm-body) select:focus,
:where(.gm-body) textarea:focus {
  border-color: var(--gm-primary);
  box-shadow: var(--gm-focus);
}

:where(.gm-body) input[readonly],
:where(.gm-body) input[disabled],
:where(.gm-body) select[disabled],
:where(.gm-body) textarea[readonly],
.gm-input-readonly,
.gm-pw-form .gm-input-readonly,
.gm-pw-form .gm-input-readonly:focus {
  background: var(--gm-surface-2);
  color: var(--gm-text-3);
  box-shadow: none;
  cursor: default;
}

:where(.gm-body) input[aria-invalid="true"],
:where(.gm-body) select[aria-invalid="true"] {
  border-color: var(--gm-bad);
}

:where(.gm-body) input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
}

:where(.gm-body) input[type="checkbox"],
:where(.gm-body) input[type="radio"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--gm-primary);
  vertical-align: middle;
}

.gm-form-hint,
.gm-form-help {
  margin: 6px 0 0;
  font-size: var(--gm-text-xs);
  color: var(--gm-text-3);
}

.gm-form-hint {
  min-height: 1.2em;
}

.gm-form-hint.is-ok {
  color: var(--gm-ok);
}

.gm-form-hint.is-ok::before {
  content: "\2713\00a0";
}

.gm-form-hint.is-bad {
  color: var(--gm-bad);
}

.gm-form-grid,
.gm-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 var(--gm-space-4);
}

.gm-form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 var(--gm-space-4);
}

.gm-form-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 var(--gm-space-4);
}

.gm-form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--gm-space-3);
}

.gm-form-inline .gm-form-group {
  margin-bottom: 0;
  flex: 0 1 auto;
}

.gm-form-inline input,
.gm-form-inline select {
  width: auto;
  min-width: 160px;
}

.gm-fieldset {
  margin: 0 0 var(--gm-space-4);
  padding: var(--gm-space-4) 0 0;
  border: 0;
  border-top: 1px solid var(--gm-border);
  min-width: 0;
}

.gm-fieldset legend {
  float: left;
  width: 100%;
  margin: 0 0 var(--gm-space-3);
  padding: 0;
  font-size: var(--gm-text-md);
  font-weight: 600;
  line-height: 1.3;
  color: var(--gm-text);
}

.gm-fieldset legend + * {
  clear: both;
}

.gm-fieldset-help {
  margin: -6px 0 var(--gm-space-3);
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-space-2) var(--gm-space-5);
  margin-bottom: var(--gm-space-4);
}

.gm-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gm-space-2);
  margin-top: var(--gm-space-4);
  padding-top: var(--gm-space-4);
  border-top: 1px solid var(--gm-border);
}

.gm-stack-form .gm-form-group {
  margin-bottom: var(--gm-space-3);
}

.gm-stack-form .gm-btn {
  margin-top: var(--gm-space-1);
}

.gm-input-wrap {
  position: relative;
}

.gm-input-wrap input {
  padding-right: 64px;
}

.gm-pw-toggle,
.gm-pw-toggle:hover {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 3px 8px;
  background: transparent;
  border: 0;
  border-radius: var(--gm-radius-sm);
  box-shadow: none;
  color: var(--gm-primary-text);
  font-size: var(--gm-text-xs);
  font-weight: 500;
}

.gm-pw-toggle:hover {
  background: var(--gm-primary-soft);
}

.gm-pw-toggle:focus-visible,
.gm-btn:focus-visible,
:where(.gm-body) button:focus-visible {
  outline: 2px solid var(--gm-primary);
  outline-offset: 2px;
}

.gm-copy-field {
  display: flex;
  align-items: center;
  gap: var(--gm-space-2);
}

.gm-copy-field input {
  font-family: var(--gm-font-mono);
  font-weight: 600;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.gm-btn,
:where(.gm-body) button,
:where(.gm-body) input[type="submit"],
:where(.gm-body) input[type="button"],
:where(.gm-body) input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--gm-border-strong);
  border-radius: var(--gm-radius-md);
  background: var(--gm-surface);
  color: var(--gm-text);
  font-family: inherit;
  font-size: var(--gm-text-sm);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.gm-btn:hover,
:where(.gm-body) button:hover,
:where(.gm-body) input[type="button"]:hover,
:where(.gm-body) input[type="reset"]:hover {
  background: var(--gm-surface-2);
  border-color: var(--gm-text-4);
  color: var(--gm-text);
  text-decoration: none;
}

.gm-btn svg,
:where(.gm-body) button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.gm-btn-primary,
.gm-btn-gold,
:where(.gm-body) button[type="submit"]:not([class*="gm-btn-"]),
:where(.gm-body) input[type="submit"]:not([class*="gm-btn-"]) {
  background: var(--gm-primary);
  border-color: var(--gm-primary);
  color: #ffffff;
}

.gm-btn-primary:hover,
.gm-btn-gold:hover,
:where(.gm-body) button[type="submit"]:not([class*="gm-btn-"]):hover,
:where(.gm-body) input[type="submit"]:not([class*="gm-btn-"]):hover {
  background: var(--gm-primary-hover);
  border-color: var(--gm-primary-hover);
  color: #ffffff;
}

.gm-btn-secondary,
.gm-btn-outline,
:where(.gm-body) button.gm-btn-secondary,
:where(.gm-body) button.gm-btn-outline {
  background: var(--gm-surface);
  border-color: var(--gm-border-strong);
  color: var(--gm-text);
}

.gm-btn-secondary:hover,
.gm-btn-outline:hover {
  background: var(--gm-surface-2);
}

.gm-btn-ghost,
:where(.gm-body) button.gm-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--gm-primary-text);
}

.gm-btn-ghost:hover,
:where(.gm-body) button.gm-btn-ghost:hover {
  background: var(--gm-primary-soft);
  border-color: transparent;
}

.gm-btn-danger,
:where(.gm-body) button.gm-btn-danger {
  background: var(--gm-surface);
  border-color: #fca5a5;
  color: var(--gm-bad);
}

.gm-btn-danger:hover,
:where(.gm-body) button.gm-btn-danger:hover {
  background: var(--gm-bad-bg);
  border-color: var(--gm-bad);
  color: var(--gm-bad);
}

.gm-btn-danger-solid,
:where(.gm-body) button.gm-btn-danger-solid {
  background: var(--gm-bad);
  border-color: var(--gm-bad);
  color: #ffffff;
}

.gm-btn-danger-solid:hover {
  background: #991b1b;
  border-color: #991b1b;
  color: #ffffff;
}

.gm-btn-ok,
:where(.gm-body) button.gm-btn-ok {
  background: var(--gm-ok);
  border-color: var(--gm-ok);
  color: #ffffff;
}

.gm-btn-ok:hover,
:where(.gm-body) button.gm-btn-ok:hover {
  background: #166534;
  border-color: #166534;
  color: #ffffff;
}

.gm-btn-sm,
:where(.gm-body) button.gm-btn-sm {
  min-height: 28px;
  padding: 3px 10px;
  font-size: var(--gm-text-xs);
}

.gm-btn-block {
  width: 100%;
}

.gm-btn[disabled],
:where(.gm-body) button[disabled],
:where(.gm-body) input[type="submit"][disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.gm-btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--gm-space-2);
}

.gm-link-btn,
:where(.gm-body) button.gm-link-btn {
  min-height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gm-primary-text);
  font-weight: 500;
}

.gm-link-btn:hover,
:where(.gm-body) button.gm-link-btn:hover {
  background: none;
  text-decoration: underline;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.gm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  background: var(--gm-surface);
}

.gm-card .gm-table-wrap,
.gm-card-body > .gm-table-wrap {
  border: 0;
  border-radius: 0;
}

.gm-card > .gm-table-wrap:last-child {
  border-radius: 0 0 var(--gm-radius-md) var(--gm-radius-md);
}

.gm-card-body > .gm-table-wrap {
  margin: calc(-1 * var(--gm-space-4));
  margin-top: 0;
}

.gm-card-body > .gm-table-wrap:first-child {
  margin-top: calc(-1 * var(--gm-space-4));
}

:where(.gm-body) table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: var(--gm-text-sm);
  text-align: left;
  border: 0;
}

:where(.gm-body) table caption {
  caption-side: top;
  padding: 0 0 var(--gm-space-2);
  font-size: var(--gm-text-sm);
  font-weight: 600;
  color: var(--gm-text);
  text-align: left;
}

:where(.gm-body) th {
  padding: 9px var(--gm-space-3);
  background: var(--gm-surface-2);
  border: 0;
  border-bottom: 1px solid var(--gm-border);
  color: var(--gm-text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}

:where(.gm-body) td {
  padding: 9px var(--gm-space-3);
  border: 0;
  border-bottom: 1px solid var(--gm-border);
  color: var(--gm-text);
  vertical-align: middle;
}

:where(.gm-body) tbody tr:last-child td {
  border-bottom: 0;
}

:where(.gm-body) tbody tr:hover td {
  background: var(--gm-surface-2);
}

:where(.gm-body) tfoot td {
  background: var(--gm-surface-2);
  border-top: 1px solid var(--gm-border);
  font-weight: 600;
}

:where(.gm-body) table[border],
:where(.gm-body) table[border] td,
:where(.gm-body) table[border] th {
  border-color: var(--gm-border);
}

.gm-table-compact td,
.gm-table-compact th {
  padding: 6px 10px;
}

.gm-table-fixed {
  table-layout: fixed;
}

.gm-num,
:where(.gm-body) td.gm-num,
:where(.gm-body) th.gm-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

:where(.gm-body) td.gm-num {
  font-weight: 500;
}

:where(.gm-body) td.gm-actions,
:where(.gm-body) th.gm-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

:where(.gm-body) td.gm-actions .gm-btn + .gm-btn,
:where(.gm-body) td.gm-actions form + form,
:where(.gm-body) td.gm-actions form + .gm-btn {
  margin-left: var(--gm-space-1);
}

:where(.gm-body) td.gm-actions form {
  display: inline;
}

:where(.gm-body) td.gm-check,
:where(.gm-body) th.gm-check {
  width: 1%;
  text-align: center;
}

:where(.gm-body) td.gm-cell-primary {
  font-weight: 500;
}

.gm-cell-sub {
  display: block;
  margin-top: 1px;
  font-size: var(--gm-text-xs);
  color: var(--gm-text-3);
}

:where(.gm-body) tr.gm-table-group td {
  padding: 7px var(--gm-space-3);
  background: var(--gm-surface-2);
  font-size: var(--gm-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gm-text-2);
}

:where(.gm-body) tr.gm-table-group:hover td {
  background: var(--gm-surface-2);
}

:where(.gm-body) tr.gm-row-muted td {
  color: var(--gm-text-3);
}

:where(.gm-body) td.gm-empty-cell,
.gm-empty-cell {
  padding: var(--gm-space-6);
  text-align: center;
  color: var(--gm-text-3);
}

/* Legacy layout tables (no data) keep their cells quiet */
:where(.gm-body) table.gm-plain,
:where(.gm-body) table.gm-plain td,
:where(.gm-body) table.gm-plain th {
  border: 0;
  background: transparent;
  padding: 4px 8px 4px 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--gm-text-sm);
  color: var(--gm-text);
}

:where(.gm-body) table.gm-plain tr:hover td {
  background: transparent;
}

/* ==========================================================================
   Badges, dots, chips, tags
   ========================================================================== */
.gm-badge,
.gm-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--gm-radius-sm);
  background: var(--gm-neutral-bg);
  color: var(--gm-neutral);
  font-size: var(--gm-text-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  text-transform: none;
}

.gm-badge-ok,
.gm-pill-ok,
.gm-badge-active {
  background: var(--gm-ok-bg);
  color: var(--gm-ok);
}

.gm-badge-warn,
.gm-pill-warn,
.gm-badge-pending {
  background: var(--gm-warn-bg);
  color: var(--gm-warn);
}

.gm-badge-bad,
.gm-pill-bad {
  background: var(--gm-bad-bg);
  color: var(--gm-bad);
}

.gm-badge-info,
.gm-badge-wait,
.gm-pill-wait {
  background: var(--gm-info-bg);
  color: var(--gm-info);
}

.gm-badge-neutral {
  background: var(--gm-neutral-bg);
  color: var(--gm-neutral);
}

.gm-badge-primary {
  background: var(--gm-primary-soft);
  color: var(--gm-primary-text);
}

.gm-badge-outline {
  background: transparent;
  border-color: var(--gm-border-strong);
  color: var(--gm-text-2);
}

.gm-dot {
  display: inline-block;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gm-text-4);
}

.gm-dot-ok { background: var(--gm-ok); }
.gm-dot-warn { background: var(--gm-warn); }
.gm-dot-bad { background: var(--gm-bad); }
.gm-dot-info { background: var(--gm-info); }
.gm-dot-neutral { background: var(--gm-text-4); }

.gm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-sm);
  background: var(--gm-surface);
  color: var(--gm-text);
  font-size: var(--gm-text-xs);
  font-weight: 500;
  text-decoration: none;
}

.gm-chip:hover {
  background: var(--gm-surface-2);
  border-color: var(--gm-border-strong);
  text-decoration: none;
}

.gm-chip svg {
  width: 13px;
  height: 13px;
  color: var(--gm-text-3);
}

.gm-chip-meta {
  color: var(--gm-text-4);
  font-weight: 400;
}

.gm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-space-2);
}

.gm-dl code,
.gm-tag {
  padding: 1px 6px;
  border-radius: var(--gm-radius-sm);
  background: var(--gm-neutral-bg);
  font-family: var(--gm-font-mono);
  font-size: var(--gm-text-xs);
  font-weight: 500;
  color: var(--gm-text-2);
}

/* ==========================================================================
   Status strip, definition lists, meta grids
   ========================================================================== */
.gm-status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gm-space-3) var(--gm-space-6);
  padding: var(--gm-space-3) var(--gm-space-4);
  border-bottom: 1px solid var(--gm-border);
  background: var(--gm-surface-2);
}

.gm-status-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.gm-status-item .gm-label {
  margin: 0;
}

.gm-status-value {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--gm-text-sm);
  font-weight: 600;
  color: var(--gm-text);
}

.gm-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px var(--gm-space-5);
  margin: 0;
  font-size: var(--gm-text-sm);
}

.gm-dl dt {
  color: var(--gm-text-3);
  font-weight: 400;
}

.gm-dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--gm-text);
}

.gm-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--gm-space-3) var(--gm-space-5);
  margin: 0;
}

.gm-meta > div {
  min-width: 0;
}

.gm-meta dt,
.gm-meta-label {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gm-text-3);
}

.gm-meta dd,
.gm-meta-value {
  margin: 0;
  font-size: var(--gm-text-sm);
  color: var(--gm-text);
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Stepper (approval ladders)
   ========================================================================== */
.gm-stepper {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  gap: 0;
}

.gm-step {
  position: relative;
  flex: 1 1 0;
  min-width: 90px;
  padding: 0 6px 0 0;
}

.gm-step::before {
  content: "";
  position: absolute;
  top: 11px;
  left: 24px;
  right: 0;
  height: 2px;
  background: var(--gm-border);
}

.gm-step:last-child::before {
  display: none;
}

.gm-step.is-done::before {
  background: var(--gm-ok);
}

.gm-step-marker {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-bottom: var(--gm-space-2);
  border: 2px solid var(--gm-border-strong);
  border-radius: 50%;
  background: var(--gm-surface);
  color: var(--gm-text-3);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.gm-step-marker svg {
  width: 12px;
  height: 12px;
}

.gm-step.is-done .gm-step-marker {
  background: var(--gm-ok);
  border-color: var(--gm-ok);
  color: #ffffff;
}

.gm-step.is-current .gm-step-marker {
  background: var(--gm-surface);
  border-color: var(--gm-primary);
  color: var(--gm-primary-text);
  box-shadow: 0 0 0 3px var(--gm-primary-soft);
}

.gm-step.is-blocked .gm-step-marker {
  background: var(--gm-bad);
  border-color: var(--gm-bad);
  color: #ffffff;
}

.gm-step-title {
  font-size: var(--gm-text-xs);
  font-weight: 600;
  color: var(--gm-text-2);
  line-height: 1.3;
}

.gm-step.is-done .gm-step-title,
.gm-step.is-current .gm-step-title {
  color: var(--gm-text);
}

.gm-step-sub {
  font-size: 11px;
  color: var(--gm-text-3);
  line-height: 1.3;
}

.gm-step-note {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--gm-text-3);
}

.gm-step.is-done .gm-step-note { color: var(--gm-ok); }
.gm-step.is-current .gm-step-note { color: var(--gm-primary-text); }
.gm-step.is-blocked .gm-step-note { color: var(--gm-bad); }

/* ==========================================================================
   Timeline list (audit trails)
   ========================================================================== */
.gm-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.gm-timeline li {
  position: relative;
  padding: 0 0 var(--gm-space-3) var(--gm-space-5);
}

.gm-timeline li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gm-border-strong);
}

.gm-timeline li::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: -2px;
  width: 2px;
  background: var(--gm-border);
}

.gm-timeline li:last-child::after {
  display: none;
}

.gm-timeline li.is-ok::before { background: var(--gm-ok); }
.gm-timeline li.is-bad::before { background: var(--gm-bad); }
.gm-timeline li.is-warn::before { background: var(--gm-warn); }

.gm-timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px var(--gm-space-2);
  font-size: var(--gm-text-sm);
}

.gm-timeline-head strong {
  font-weight: 600;
}

.gm-timeline-time {
  font-size: var(--gm-text-xs);
  color: var(--gm-text-4);
}

.gm-timeline-body {
  margin-top: 2px;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-2);
}

/* ==========================================================================
   Collapsible details (closed by default)
   ========================================================================== */
.gm-details {
  border-top: 1px solid var(--gm-border);
}

.gm-details summary {
  display: flex;
  align-items: center;
  gap: var(--gm-space-2);
  padding: var(--gm-space-3) var(--gm-space-4);
  font-size: var(--gm-text-sm);
  font-weight: 500;
  color: var(--gm-text-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.gm-details summary::-webkit-details-marker {
  display: none;
}

.gm-details summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  margin: 0 4px 0 2px;
}

.gm-details[open] summary::before {
  transform: rotate(45deg);
}

.gm-details summary:hover {
  color: var(--gm-text);
  background: var(--gm-surface-2);
}

.gm-details-body {
  padding: var(--gm-space-2) var(--gm-space-4) var(--gm-space-4);
}

/* ==========================================================================
   Alerts, notes, empty states
   ========================================================================== */
.gm-alert {
  display: flex;
  gap: var(--gm-space-2);
  align-items: flex-start;
  margin-bottom: var(--gm-space-4);
  padding: 10px var(--gm-space-3);
  border: 1px solid transparent;
  border-radius: var(--gm-radius-md);
  background: var(--gm-neutral-bg);
  color: var(--gm-text);
  font-size: var(--gm-text-sm);
  line-height: 1.45;
}

.gm-alert > svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.gm-alert p {
  margin: 0;
}

.gm-alert p + p,
.gm-alert ul {
  margin-top: var(--gm-space-1);
}

.gm-alert ul {
  margin-bottom: 0;
  padding-left: 18px;
}

.gm-alert-bad {
  background: var(--gm-bad-bg);
  border-color: #fecaca;
  color: #7f1d1d;
}

.gm-alert-warn {
  background: var(--gm-warn-bg);
  border-color: #fde68a;
  color: #78350f;
}

.gm-alert-ok {
  background: var(--gm-ok-bg);
  border-color: #bbf7d0;
  color: #14532d;
}

.gm-alert-info {
  background: var(--gm-info-bg);
  border-color: #bfdbfe;
  color: #1e3a8a;
}

.gm-note {
  padding: var(--gm-space-3);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  background: var(--gm-surface-2);
  font-size: var(--gm-text-sm);
  color: var(--gm-text-2);
}

.gm-empty,
.gm-empty-state {
  padding: var(--gm-space-8) var(--gm-space-4);
  text-align: center;
  color: var(--gm-text-3);
  font-size: var(--gm-text-sm);
}

.gm-empty-state svg {
  width: 28px;
  height: 28px;
  margin-bottom: var(--gm-space-2);
  color: var(--gm-text-4);
}

.gm-empty-state h3 {
  margin: 0 0 var(--gm-space-1);
  font-size: var(--gm-text-md);
  color: var(--gm-text);
}

.gm-empty-state p {
  max-width: 440px;
  margin: 0 auto;
}

.gm-empty-state .gm-btn {
  margin-top: var(--gm-space-4);
}

/* ==========================================================================
   Access denied / message pages
   ========================================================================== */
.gm-message-page {
  max-width: 520px;
  margin: var(--gm-space-8) auto;
  padding: var(--gm-space-8) var(--gm-space-6);
  text-align: center;
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
}

.gm-message-page svg {
  width: 28px;
  height: 28px;
  margin-bottom: var(--gm-space-3);
  color: var(--gm-text-3);
}

.gm-message-page.is-bad svg {
  color: var(--gm-bad);
}

.gm-message-page h1,
.gm-message-page h3 {
  margin: 0 0 var(--gm-space-2);
  font-size: var(--gm-text-lg);
}

.gm-message-page p {
  margin: 0 0 var(--gm-space-4);
  color: var(--gm-text-3);
}

/* ==========================================================================
   Password pages & profile
   ========================================================================== */
.gm-pw {
  max-width: 420px;
  margin: var(--gm-space-4) auto;
  padding: var(--gm-space-6);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
}

.gm-pw-form .gm-form-group {
  margin-bottom: var(--gm-space-3);
}

.gm-pw-form .gm-btn-block {
  margin-top: var(--gm-space-2);
}

.gm-pw-head {
  text-align: center;
  margin-bottom: var(--gm-space-5);
}

.gm-pw-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--gm-space-3);
  border-radius: 50%;
  background: var(--gm-primary-soft);
  color: var(--gm-primary-text);
}

.gm-pw-head h1 {
  margin: 0 0 4px;
  font-size: var(--gm-text-lg);
}

.gm-pw-head p {
  margin: 0;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-pw-alt {
  margin: var(--gm-space-4) 0 0;
  text-align: center;
  font-size: var(--gm-text-sm);
}

.gm-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  column-gap: var(--gm-space-8);
}

.gm-profile-grid > .gm-section {
  border-top: 0;
  padding-top: 0;
}

.gm-profile-id {
  display: flex;
  align-items: center;
  gap: var(--gm-space-3);
  margin-bottom: var(--gm-space-4);
}

.gm-profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gm-primary);
  color: #ffffff;
  font-size: var(--gm-text-lg);
  font-weight: 600;
}

.gm-profile-name {
  font-size: var(--gm-text-md);
  font-weight: 600;
}

.gm-profile-handle {
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

/* ==========================================================================
   Login splash (shown once after signing in)
   ========================================================================== */
.gm-splash {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gm-space-5);
  background: rgba(15, 23, 42, 0.72);
  transition: opacity 0.3s ease;
}

.gm-splash.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.gm-splash-card {
  width: 100%;
  max-width: 440px;
  padding: var(--gm-space-6);
  background: var(--gm-surface);
  border-radius: var(--gm-radius-lg);
  text-align: center;
}

.gm-splash-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--gm-space-4);
  border-radius: 50%;
  background: var(--gm-primary);
  color: #ffffff;
}

.gm-splash-card h2 {
  margin: 0 0 var(--gm-space-1);
  font-size: var(--gm-text-lg);
}

.gm-splash-card p {
  margin: 0 0 var(--gm-space-4);
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-splash-bar {
  height: 4px;
  margin-bottom: var(--gm-space-3);
  border-radius: var(--gm-radius-sm);
  background: var(--gm-border);
  overflow: hidden;
}

.gm-splash-bar > div {
  height: 100%;
  width: 0;
  background: var(--gm-primary);
  transition: width 0.1s linear;
}

.gm-splash-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gm-space-3);
  font-size: var(--gm-text-xs);
  color: var(--gm-text-3);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.gm-foot {
  margin-top: auto;
  padding: var(--gm-space-4) var(--gm-space-6);
  border-top: 1px solid var(--gm-border);
  background: var(--gm-surface);
  font-size: var(--gm-text-xs);
  color: var(--gm-text-3);
}

.gm-foot-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--gm-space-3);
}

.gm-foot-divider {
  color: var(--gm-border-strong);
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.gm-muted { color: var(--gm-text-3); }
.gm-faint { color: var(--gm-text-4); }
.gm-strong { font-weight: 600; }
.gm-small { font-size: var(--gm-text-xs); }
.gm-nowrap { white-space: nowrap; }
.gm-right { text-align: right; }
.gm-center { text-align: center; }
.gm-ok-text { color: var(--gm-ok); }
.gm-bad-text { color: var(--gm-bad); }
.gm-warn-text { color: var(--gm-warn); }
.gm-flex { display: flex; align-items: center; gap: var(--gm-space-2); }
.gm-flex-wrap { flex-wrap: wrap; }
.gm-flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--gm-space-2); flex-wrap: wrap; }
.gm-stack { display: flex; flex-direction: column; gap: var(--gm-space-4); }
.gm-stack-sm { display: flex; flex-direction: column; gap: var(--gm-space-2); }
.gm-mt-0 { margin-top: 0 !important; }
.gm-mt-2 { margin-top: var(--gm-space-2) !important; }
.gm-mt-4 { margin-top: var(--gm-space-4) !important; }
.gm-mb-0 { margin-bottom: 0 !important; }
.gm-mb-2 { margin-bottom: var(--gm-space-2) !important; }
.gm-mb-4 { margin-bottom: var(--gm-space-4) !important; }
.gm-w-auto { width: auto !important; }
.gm-maxw-sm { max-width: 480px; }
.gm-maxw-md { max-width: 720px; }
.gm-maxw-lg { max-width: 960px; }
.gm-hidden { display: none !important; }
.gm-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.gm-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ==========================================================================
   Bootstrap pages rendered inside the shell: bring them onto the same system
   ========================================================================== */
.gm-body .card {
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  box-shadow: none !important;
  transition: none;
}

.gm-body .card:hover,
.gm-body .card-stat:hover {
  transform: none;
  box-shadow: none !important;
}

.gm-body .card.border-start,
.gm-body .card.border-4 {
  border-left: 1px solid var(--gm-border) !important;
}

.gm-body .card-header {
  background: transparent;
  border-bottom: 1px solid var(--gm-border);
  padding: var(--gm-space-3) var(--gm-space-4);
  font-weight: 600;
}

.gm-body .shadow,
.gm-body .shadow-sm,
.gm-body .shadow-lg {
  box-shadow: none !important;
}

.gm-body .rounded-pill,
.gm-body .rounded-3,
.gm-body .rounded-4 {
  border-radius: var(--gm-radius-md) !important;
}

.gm-body .btn {
  font-size: var(--gm-text-sm);
  font-weight: 500;
  border-radius: var(--gm-radius-md);
  padding: 6px 12px;
  box-shadow: none !important;
}

.gm-body .btn-primary {
  background: var(--gm-primary);
  border-color: var(--gm-primary);
}

.gm-body .btn-primary:hover {
  background: var(--gm-primary-hover);
  border-color: var(--gm-primary-hover);
}

.gm-body .btn-sm {
  padding: 3px 10px;
  font-size: var(--gm-text-xs);
}

.gm-body .badge {
  border-radius: var(--gm-radius-sm);
  font-weight: 500;
  font-size: var(--gm-text-xs);
  padding: 3px 8px;
}

.gm-body .table {
  font-size: var(--gm-text-sm);
  margin-bottom: 0;
}

.gm-body .table > :not(caption) > * > * {
  padding: 9px var(--gm-space-3);
  border-bottom-color: var(--gm-border);
}

.gm-body .table thead th {
  background: var(--gm-surface-2);
  border-bottom: 1px solid var(--gm-border);
  color: var(--gm-text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.gm-body .table-gams {
  box-shadow: none;
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
}

.gm-body .form-control,
.gm-body .form-select {
  font-size: var(--gm-text-sm);
  border-radius: var(--gm-radius-md);
  border-color: var(--gm-border-strong);
  min-height: 34px;
}

.gm-body .form-control:focus,
.gm-body .form-select:focus {
  border-color: var(--gm-primary);
  box-shadow: var(--gm-focus);
}

.gm-body .form-label {
  font-size: var(--gm-text-sm);
  font-weight: 500;
}

.gm-body .alert {
  border-radius: var(--gm-radius-md);
  font-size: var(--gm-text-sm);
}

.gm-body .progress {
  border-radius: var(--gm-radius-sm);
}

.gm-body .list-group-item {
  font-size: var(--gm-text-sm);
}

.gm-body .text-primary {
  color: var(--gm-primary-text) !important;
}

.gm-body .bg-primary {
  background-color: var(--gm-primary) !important;
}

.gm-body .fs-3 { font-size: 20px !important; }
.gm-body .fs-4 { font-size: 18px !important; }
.gm-body .fs-5 { font-size: 16px !important; }
.gm-body .fs-6 { font-size: 14px !important; }
:where(.gm-body) h3.fw-bold,
.gm-body .h3 { font-size: var(--gm-text-xl); }
:where(.gm-body) h5.fw-bold,
.gm-body .h5 { font-size: var(--gm-text-md); }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .gm-shell {
    flex-direction: column;
    gap: var(--gm-space-3);
    padding: var(--gm-space-4);
  }

  .gm-nav-toggle {
    display: inline-flex;
  }

  .gm-nav {
    display: none;
    position: static;
    width: 100%;
    max-height: none;
    padding: var(--gm-space-3);
    background: var(--gm-surface);
    border: 1px solid var(--gm-border);
    border-radius: var(--gm-radius-md);
  }

  .gm-nav.is-open {
    display: block;
  }

  .gm-main {
    width: 100%;
  }

  .gm-top {
    padding: 0 var(--gm-space-4);
  }

  .gm-user-info,
  .gm-btn-profile span,
  .gm-logout span {
    display: none;
  }

  .gm-btn-profile,
  .gm-logout {
    width: 32px;
    padding: 0;
  }

  .gm-page-head,
  .gm-hero {
    margin-bottom: var(--gm-space-4);
  }

  .gm-card-body,
  .gm-panel {
    padding: var(--gm-space-3);
  }

  .gm-card-body > .gm-table-wrap {
    margin: calc(-1 * var(--gm-space-3));
    margin-top: 0;
  }

  .gm-status-strip {
    padding: var(--gm-space-3);
  }
}

@media print {
  .gm-top,
  .gm-nav,
  .gm-nav-toggle,
  .gm-foot,
  .gm-page-actions,
  .gm-toolbar,
  .gm-splash {
    display: none !important;
  }

  .gm-shell {
    padding: 0;
  }

  .gm-card,
  .gm-panel {
    break-inside: avoid;
  }
}

/* Column sizing helpers for tables */
:where(.gm-body) th.gm-col-xs,
.gm-body td.gm-col-xs { width: 1%; white-space: nowrap; }
.gm-body th.gm-col-sm { width: 12%; }
.gm-body th.gm-col-md { width: 20%; }
.gm-body th.gm-col-lg { width: 32%; }

/* ==========================================================================
   Sign-in page
   ========================================================================== */
.gm-top-note {
  font-size: var(--gm-text-xs);
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.gm-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gm-space-6) var(--gm-space-4);
}

.gm-login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--gm-space-6);
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
}

.gm-login-card h1 {
  margin: 0 0 var(--gm-space-1);
  font-size: var(--gm-text-xl);
}

.gm-login-card > p {
  margin: 0 0 var(--gm-space-5);
  font-size: var(--gm-text-sm);
  color: var(--gm-text-3);
}

.gm-login-card .gm-form-group {
  margin-bottom: var(--gm-space-3);
}

.gm-login-card .gm-btn-block {
  margin-top: var(--gm-space-2);
}

.gm-login-help {
  margin: var(--gm-space-4) 0 0;
  font-size: var(--gm-text-xs);
  color: var(--gm-text-3);
  text-align: center;
}

/* Small layout helpers reported missing during the page refactors */
.gm-ml-auto { margin-left: auto !important; }
.gm-page-head p { max-width: 72ch; }
.gm-form-actions + .gm-fieldset { border-top: 0; padding-top: 0; }
.gm-fieldset:first-child { border-top: 0; padding-top: 0; }
.gm-card-body > .gm-fieldset:first-child { border-top: 0; padding-top: 0; }

/* ==========================================================================
   Searchable Select Dropdown
   ========================================================================== */
.gm-searchable-select {
  position: relative;
  width: 100%;
}

.gm-searchable-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--gm-surface, #ffffff);
  border: 1px solid var(--gm-border, #d1d5db);
  border-radius: var(--gm-radius-sm, 6px);
  font-family: inherit;
  font-size: var(--gm-text-base, 14px);
  color: var(--gm-text-1, #111827);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gm-searchable-select-trigger:focus,
.gm-searchable-select.is-open .gm-searchable-select-trigger {
  outline: none;
  border-color: var(--gm-primary, #0d6efd);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.gm-searchable-select-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
  flex: 1 1 auto;
}

.gm-searchable-select-arrow {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--gm-text-3, #6b7280);
}

.gm-searchable-select.is-open .gm-searchable-select-arrow {
  transform: rotate(180deg);
}

.gm-searchable-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--gm-surface, #ffffff);
  border: 1px solid var(--gm-border, #d1d5db);
  border-radius: var(--gm-radius-sm, 6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow: hidden;
}

.gm-searchable-select-search {
  padding: 8px;
  background: var(--gm-surface-2, #f9fafb);
  border-bottom: 1px solid var(--gm-border, #e5e7eb);
  position: relative;
}

.gm-searchable-select-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--gm-border, #d1d5db);
  border-radius: var(--gm-radius-xs, 4px);
  outline: none;
  box-sizing: border-box;
}

.gm-searchable-select-input:focus {
  border-color: var(--gm-primary, #0d6efd);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.gm-searchable-select-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  max-height: 220px;
}

.gm-searchable-select-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--gm-text-1, #111827);
  transition: background 0.15s;
}

.gm-searchable-select-item:hover,
.gm-searchable-select-item.is-focused {
  background: var(--gm-surface-2, #f3f4f6);
  color: var(--gm-primary, #0d6efd);
}

.gm-searchable-select-item.is-selected {
  font-weight: 600;
  background: rgba(13, 110, 253, 0.08);
  color: var(--gm-primary, #0d6efd);
}

.gm-searchable-select-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--gm-text-3, #6b7280);
  text-align: center;
}


/* ==========================================================================
   Modal dialog (hidden attribute toggles it; no inline styles needed)
   ========================================================================== */
.gm-modal-backdrop,
.gm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--gm-space-8) var(--gm-space-4);
  background: rgba(15, 23, 42, 0.55);
  overflow-y: auto;
}

.gm-modal-backdrop[hidden],
.gm-modal[hidden] {
  display: none;
}

.gm-modal-backdrop > .gm-modal,
.gm-modal-dialog {
  position: static;
  inset: auto;
  display: block;
  width: 100%;
  max-width: 520px;
  padding: 0;
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius-md);
  overflow: visible;
  z-index: auto;
}

.gm-modal-dialog.gm-modal-lg,
.gm-modal-backdrop > .gm-modal.gm-modal-lg {
  max-width: 760px;
}

.gm-modal-content {
  display: contents;
}

.gm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gm-space-3);
  padding: var(--gm-space-3) var(--gm-space-4);
  border-bottom: 1px solid var(--gm-border);
}

.gm-modal-header h2,
.gm-modal-header h3 {
  margin: 0;
  font-size: var(--gm-text-md);
  font-weight: 600;
}

.gm-modal-close,
:where(.gm-body) button.gm-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--gm-radius-sm);
  background: transparent;
  color: var(--gm-text-3);
  font-size: 18px;
  line-height: 1;
}

.gm-modal-close:hover,
:where(.gm-body) button.gm-modal-close:hover {
  background: var(--gm-surface-2);
  color: var(--gm-text);
}

.gm-modal-body {
  padding: var(--gm-space-4);
}

.gm-modal-body > :last-child {
  margin-bottom: 0;
}

.gm-modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--gm-space-2);
  padding: var(--gm-space-3) var(--gm-space-4);
  border-top: 1px solid var(--gm-border);
  background: var(--gm-surface-2);
  border-radius: 0 0 var(--gm-radius-md) var(--gm-radius-md);
}

.gm-modal-body .gm-form-actions {
  margin-top: var(--gm-space-4);
}

body.gm-modal-open {
  overflow: hidden;
}

/* Small aliases used by newer pages */
.gm-btn-xs,
:where(.gm-body) button.gm-btn-xs {
  min-height: 26px;
  padding: 2px 8px;
  font-size: var(--gm-text-xs);
}

.gm-input,
.gm-form-control {
  width: 100%;
}

.gm-list {
  margin: 0;
  padding-left: 18px;
  font-size: var(--gm-text-sm);
  color: var(--gm-text-2);
}

.gm-list li + li {
  margin-top: var(--gm-space-1);
}

.gm-page-title {
  margin: 0 0 2px;
  font-size: var(--gm-text-xl);
  font-weight: 600;
}

.gm-page-subtitle {
  margin: 0;
  font-size: var(--gm-text-md);
  color: var(--gm-text-3);
}

.gm-inline-form {
  display: inline;
}

.gm-inline-form + .gm-inline-form,
.gm-inline-form + .gm-btn {
  margin-left: var(--gm-space-1);
}

.gm-search-wrap {
  position: relative;
  flex: 1 1 280px;
  max-width: 440px;
}

tr.gm-row-clickable {
  cursor: pointer;
}

tr.gm-row-detail > td {
  background: var(--gm-surface-2);
  padding: var(--gm-space-4);
}

.gm-chevron {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: var(--gm-text-4);
  transition: transform 0.15s ease;
}

.gm-chevron.is-open {
  transform: rotate(90deg);
}

.gm-amount-due {
  color: var(--gm-bad);
  font-weight: 600;
}

.gm-session-countdown {
  font-weight: 600;
  color: var(--gm-bad);
}

.gm-alert > div {
  flex: 1;
  min-width: 0;
}
