/* ============================================================
   Portal CSS — Partner Portal (Grants Platform)
   Zero-framework, plain CSS3 with custom properties.
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────── */
:root {
  /* Brand — sky-600 (warmer than indigo, utility-sector appropriate) */
  --colour-brand:           #0284c7;
  --colour-brand-dark:      #0369a1;
  --colour-brand-light:     #e0f2fe;  /* sky-100 — active nav bg, badges, ref-code */

  /* Sidebar — white, light enterprise style */
  --colour-sidebar-bg:      #ffffff;
  --colour-sidebar-text:    #64748b;
  --colour-sidebar-active:  #0284c7;

  /* Surfaces */
  --colour-surface:         #ffffff;
  --colour-bg:              #f0f4f8;  /* slightly blue-tinted grey */
  --colour-border:          #e2e8f0;

  /* Text */
  --colour-text-primary:    #1e293b;
  --colour-text-secondary:  #64748b;  /* 4.6:1 on white — AA */

  /* Semantic */
  --colour-success:         #16a34a;
  --colour-warning:         #b45309;
  --colour-error:           #dc2626;
  --colour-info:            #0284c7;

  /* System */
  --font-sans:              -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:              'SF Mono', 'Fira Code', Consolas, monospace;
  --radius:                 10px;
  --radius-lg:              14px;
  --shadow-sm:              0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:              0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:              0 10px 25px rgba(0,0,0,0.08);
  --transition:             150ms ease;
}

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

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--colour-bg);
  color: var(--colour-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell / Layout ─────────────────────────────────── */
#app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  background: var(--colour-sidebar-bg);
  border-right: 1px solid var(--colour-border);
  color: var(--colour-sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0;
}

.sidebar-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--colour-border);
}

.org-name {
  font-weight: 700;
  color: var(--colour-text-primary);
  font-size: 0.875rem;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-balance {
  padding: 20px 24px 12px;
}

.balance-display {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--colour-text-primary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-sans);
}

.balance-ok   { color: var(--colour-text-primary); }
.balance-low  { color: var(--colour-warning); }
.balance-zero { color: var(--colour-error); }

.balance-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  margin-top: 4px;
}

/* Nav section label — "Overview", "Account" etc */
.nav-section-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  padding: 16px 20px 6px;
  font-weight: 600;
  margin: 0;
}

.nav-links {
  list-style: none;
  padding: 0 10px;
  margin: 0;
}

.nav-links a {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 1px;
  color: var(--colour-sidebar-text);
  text-decoration: none;
  border-left: none;
  border-radius: 7px;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav-links a:hover,
.nav-links a:focus {
  background: #f8fafc;
  color: var(--colour-text-primary);
  outline: none;
}

.nav-links a.active {
  background: var(--colour-brand-light);
  color: var(--colour-brand);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.45;
  margin-right: 10px;
}

.nav-links a:hover .nav-icon { opacity: 0.7; }
.nav-links a.active .nav-icon { opacity: 1; }

.user-info {
  margin-top: auto;
  padding: 12px 20px;
  border-top: 1px solid var(--colour-border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--colour-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-email {
  color: var(--colour-text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 2px;
  word-break: break-all;
}

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--colour-brand-light);
  color: var(--colour-brand);
}

.role-badge-admin   { background: var(--colour-brand-light); color: var(--colour-brand); }
.role-badge-manager { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
.role-badge-viewer  { background: #f1f5f9; color: var(--colour-text-secondary); }

.btn-logout {
  background: none;
  border: 1px solid var(--colour-border);
  color: var(--colour-text-secondary);
  padding: 6px 10px;
  margin: 0 20px 16px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
  font-size: 0.75rem;
  border-radius: var(--radius);
  font-family: var(--font-sans);
}

.btn-logout:hover {
  background: var(--colour-bg);
  color: var(--colour-text-primary);
  border-color: var(--colour-border);
}

/* ── Main Content ────────────────────────────────────────── */
#content {
  overflow-y: auto;
  padding: 28px 36px 48px;
}

/* ── Portal Sections ─────────────────────────────────────── */
.portal-section {
  display: none;
}

.portal-section.active {
  display: block;
}

/* ── KPI Cards ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--colour-surface);
  border-radius: var(--radius);
  padding: 14px 16px 14px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--colour-border);
  position: relative;
  overflow: hidden;
}

/* Left accent bar */
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--colour-border);
}

.kpi-accent-blue::before   { background: var(--colour-brand); }
.kpi-accent-green::before  { background: #0d9488; }
.kpi-accent-amber::before  { background: #d97706; }
.kpi-accent-purple::before { background: #8b5cf6; }

.kpi-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--colour-text-secondary);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--colour-text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* KPI trend indicator */
.kpi-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  margin-top: 6px;
}
.kpi-trend-up   { color: var(--colour-success); }
.kpi-trend-down { color: var(--colour-error); }
.kpi-trend-flat { color: var(--colour-text-secondary); }

/* Clickable KPI card */
.kpi-card-link {
  cursor: pointer;
  transition: var(--transition);
}
.kpi-card-link:hover {
  border-color: var(--colour-brand);
  box-shadow: var(--shadow-md);
}
.kpi-card-link:focus-visible {
  outline: 2px solid var(--colour-brand);
  outline-offset: 2px;
}

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 10px 16px;
  border-bottom: 1px solid var(--colour-border);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  background: #fafbfc;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-submitted   { background: #dbeafe; color: #1e40af; }
.badge-confirmed   { background: #e0f2fe; color: #0369a1; }
.badge-processing  { background: #fef3c7; color: #92400e; }
.badge-fulfilled   { background: #d1fae5; color: #065f46; }
.badge-delivered   { background: #dcfce7; color: #14532d; }
.badge-failed      { background: #fee2e2; color: #991b1b; }
.badge-cancelled   { background: #f1f5f9; color: #475569; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-sizing: border-box;
  font-family: var(--font-sans);
  background: var(--colour-surface);
  color: var(--colour-text-primary);
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--colour-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--colour-brand);
  outline-offset: 1px;
}

.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--colour-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  background: var(--colour-surface);
  color: var(--colour-text-primary);
  resize: vertical;
  box-sizing: border-box;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--colour-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-error {
  font-size: 0.75rem;
  color: var(--colour-error);
  margin-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.btn:focus-visible {
  outline: 2px solid var(--colour-brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--colour-brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--colour-brand-dark);
}

.btn-secondary {
  background: var(--colour-bg);
  border: 1px solid var(--colour-border);
  color: var(--colour-text-primary);
}

.btn-secondary:hover {
  background: var(--colour-border);
}

.btn-danger {
  background: var(--colour-error);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Skeletons ───────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius);
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
}

.skeleton-kpi {
  height: 80px;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.toast-error   { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }
.toast-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.toast-warning { background: #fffbeb; border: 1px solid #fed7aa; color: #d97706; }

/* ── Modal ───────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#modal-overlay.hidden {
  display: none;
}

#modal-box {
  background: var(--colour-surface);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: var(--shadow-md);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  margin-top: 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Cards & Section Containers ─────────────────────────── */
.card {
  background: var(--colour-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--colour-border);
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  margin-top: 0;
  color: var(--colour-text-primary);
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--colour-text-secondary);
  margin-bottom: 16px;
}

/* ── Empty & Alert States ────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--colour-text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
}

.alert-warning { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ── In-Content Links ────────────────────────────────────── */
#content a {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--colour-brand);
}

/* ── Privacy Footer ──────────────────────────────────────── */
.privacy-notice {
  position: fixed;
  bottom: 0;
  left: 220px;
  right: 0;
  padding: 6px 28px;
  font-size: 0.6875rem;
  color: var(--colour-text-secondary);
  background: var(--colour-surface);
  border-top: 1px solid var(--colour-border);
  z-index: 100;
}

.privacy-notice a {
  color: var(--colour-brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.privacy-notice a:hover {
  color: var(--colour-brand-dark);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #app-shell {
    grid-template-columns: 1fr;
  }

  #sidebar {
    display: none;
  }

  #sidebar.open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    z-index: 200;
  }

  .privacy-notice {
    left: 0;
  }

  .menu-toggle {
    display: block;
  }
}

/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: #e2e8f0;
  }

  * {
    transition: none !important;
  }
}

/* ── Skip Link ────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--colour-brand);
  color: #fff;
  padding: 8px 16px;
  z-index: 1000;
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 0 0 var(--radius) 0;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* ── Screen Reader Only ───────────────────────────────────── */
.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;
}

/* ── Mobile Hamburger ─────────────────────────────────────── */
.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  background: var(--colour-sidebar-bg);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--colour-brand);
  outline-offset: 2px;
}

/* ── Tab Navigation ───────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--colour-border);
  padding-bottom: 0;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: none;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--colour-text-secondary);
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--colour-text-primary);
  background: var(--colour-bg);
}

.tab-active {
  color: var(--colour-brand);
  border-bottom-color: var(--colour-brand);
  background: none;
}

.tab:focus-visible {
  outline: 2px solid var(--colour-brand);
  outline-offset: 2px;
}

.tab-content {
  /* container for tab panels — no visual style needed */
}

/* ── Filter Row ───────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-row label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--colour-text-primary);
  white-space: nowrap;
}

.filter-row .form-input {
  width: auto;
  min-width: 140px;
}

/* ── Table Alias (.table = .data-table) ───────────────────── */
/* JS modules emit .table; keep .data-table for backwards compat */
.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--colour-border);
  font-weight: 600;
  color: var(--colour-text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table td,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--colour-border);
  vertical-align: middle;
}

.table tr:last-child td,
.data-table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover,
.data-table tbody tr:hover {
  background: var(--colour-bg);
}

/* ── Fund Account Summary ─────────────────────────────────── */
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--colour-border);
}

.summary-row:last-of-type {
  border-bottom: none;
}

.summary-label {
  font-size: 0.875rem;
  color: var(--colour-text-secondary);
}

.summary-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--colour-text-primary);
  font-variant-numeric: tabular-nums;
}

/* ── Empty Table Cell ─────────────────────────────────────── */
.empty-cell {
  padding: 0 !important;
}

/* ── Order Layout (Place Order) ───────────────────────────── */
.order-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .order-layout {
    grid-template-columns: 1fr;
  }
}

.order-products {
  min-width: 0;
}

.order-summary-panel {
  background: var(--colour-surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--colour-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 24px;
}

/* ── Product Grid ─────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.product-card {
  background: var(--colour-surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--colour-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}

.product-card:hover {
  border-color: var(--colour-brand);
  box-shadow: var(--shadow-md);
}

.product-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--colour-text-primary);
}

.product-desc {
  font-size: 0.8125rem;
  color: var(--colour-text-secondary);
  flex: 1;
}

.product-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--colour-brand);
  font-variant-numeric: tabular-nums;
}

/* ── Order Summary Items ──────────────────────────────────── */
.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--colour-border);
  font-size: 0.875rem;
  gap: 8px;
}

.summary-total {
  display: flex;
  justify-content: space-between;
  padding: 12px 0 16px;
  font-size: 1rem;
  margin-top: 4px;
}

/* ── Quantity Controls ────────────────────────────────────── */
.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-qty {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--colour-border);
  background: var(--colour-surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-qty:hover {
  background: var(--colour-bg);
  border-color: var(--colour-brand);
}

/* ── Section Heading ──────────────────────────────────────── */
h1.section-title,
h2.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 24px;
  color: var(--colour-text-primary);
}

/* ── Text utilities ───────────────────────────────────────── */
.text-muted {
  color: var(--colour-text-secondary);
  font-size: 0.875rem;
}

/* ── Action Cards (Dashboard CTAs) ───────────────────────── */
.action-card {
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  display: block;
  box-shadow: var(--shadow-sm);
}

.action-card:hover {
  border-color: var(--colour-brand);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.action-card:focus-visible {
  outline: 3px solid var(--colour-brand);
  outline-offset: 2px;
}

.action-card-icon {
  width: 40px;
  height: 40px;
  background: var(--colour-brand-light);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--colour-brand);
}

.action-card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--colour-text-primary);
  margin: 0 0 4px;
}

.action-card-sub {
  font-size: 0.8125rem;
  color: var(--colour-text-secondary);
  margin: 0;
}

/* ── Reference Code Pill ──────────────────────────────────── */
.ref-code {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--colour-brand);
  background: var(--colour-brand-light);
  border-radius: 6px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* ── Badge Dot ────────────────────────────────────────────── */
.badge .badge-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
}

.badge-pending .badge-dot  { background: #f59e0b; }
.badge-active .badge-dot   { background: #10b981; }
.badge-success .badge-dot,
.badge-complete .badge-dot,
.badge-confirmed .badge-dot,
.badge-fulfilled .badge-dot { background: #10b981; }
.badge-error .badge-dot,
.badge-failed .badge-dot,
.badge-cancelled .badge-dot { background: #ef4444; }
.badge-info .badge-dot,
.badge-submitted .badge-dot { background: #0284c7; }
.badge-credit .badge-dot   { background: #10b981; }
.badge-debit .badge-dot    { background: #6366f1; }

/* ── Breadcrumb ───────────────────────────────────────────── */
nav.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--colour-text-secondary);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

nav.breadcrumb a {
  color: var(--colour-brand);
  text-decoration: none;
  font-weight: 500;
}

nav.breadcrumb a:hover {
  text-decoration: underline;
}

nav.breadcrumb .breadcrumb-sep {
  color: #cbd5e1;
  user-select: none;
}

nav.breadcrumb [aria-current="page"] {
  color: var(--colour-text-primary);
  font-weight: 500;
}

/* ── Detail Grid ──────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--colour-surface);
  border: 1px solid var(--colour-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 24px;
}

.detail-grid > div {
  padding: 16px 20px;
  border-right: 1px solid var(--colour-border);
  border-bottom: 1px solid var(--colour-border);
}

.detail-grid > div:nth-child(3n) {
  border-right: none;
}

.detail-grid > div:nth-last-child(-n+3) {
  border-bottom: none;
}

.detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--colour-text-secondary);
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--colour-text-primary);
}

/* ── Timeline ─────────────────────────────────────────────── */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 22px;
  bottom: 0;
  width: 1px;
  background: var(--colour-border);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--colour-surface);
  border: 2px solid var(--colour-brand);
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 0 0 3px var(--colour-brand-light);
  z-index: 1;
}

.timeline-dot.dot-muted {
  border-color: var(--colour-border);
  box-shadow: none;
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--colour-text-secondary);
  margin-bottom: 2px;
}

.timeline-event {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--colour-text-primary);
}

.timeline-note {
  font-size: 0.8125rem;
  color: var(--colour-text-secondary);
  margin-top: 2px;
}

/* ── Percentage Bar Row ───────────────────────────────────── */
.pct-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.8125rem;
}

.pct-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--colour-text-secondary);
}

.pct-bar {
  flex: 1;
  height: 8px;
  background: var(--colour-bg);
  border-radius: 4px;
  overflow: hidden;
}

.pct-fill {
  height: 100%;
  background: var(--colour-brand);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.pct-val {
  width: 40px;
  text-align: right;
  font-weight: 600;
  color: var(--colour-text-primary);
  font-size: 0.8125rem;
}

/* ── Step Indicator ───────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
}

.step-indicator .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--colour-text-secondary);
}

.step-indicator .step.active {
  color: var(--colour-brand);
  font-weight: 600;
}

.step-indicator .step.complete {
  color: var(--colour-success);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--colour-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--colour-surface);
  color: var(--colour-text-secondary);
  flex-shrink: 0;
}

.step-indicator .step.active .step-num {
  border-color: var(--colour-brand);
  background: var(--colour-brand);
  color: #fff;
}

.step-indicator .step.complete .step-num {
  border-color: var(--colour-success);
  background: var(--colour-success);
  color: #fff;
}

.step-conn {
  flex: 1;
  max-width: 60px;
  height: 1px;
  background: var(--colour-border);
  margin: 0 4px;
}

/* ── Alert / Success Banner ───────────────────────────────── */
.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--colour-success);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: #166534;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* ── Product Card Selected State ──────────────────────────── */
.product-card-selected {
  border-color: var(--colour-brand) !important;
  background: var(--colour-brand-light);
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--colour-border);
}

.qty-val {
  font-size: 1rem;
  font-weight: 600;
  color: var(--colour-text-primary);
  min-width: 20px;
  text-align: center;
}

/* ── Date Cell ────────────────────────────────────────────── */
.date-cell {
  white-space: nowrap;
  color: var(--colour-text-secondary);
  font-size: 0.8125rem;
}

/* ── Filter Row ───────────────────────────────────────────── */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-row label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--colour-text-secondary);
  white-space: nowrap;
}

.filter-row .form-select {
  min-width: 140px;
  max-width: 200px;
  padding: 7px 12px;
  font-size: 0.8125rem;
}

/* ── Utility — Font Weight ────────────────────────────────── */
.fw-600 { font-weight: 600; }
.fw-500 { font-weight: 500; }
.fw-400 { font-weight: 400; }

/* ── Utility — Font Size ──────────────────────────────────── */
.text-sm  { font-size: 0.8125rem; }
.text-xs  { font-size: 0.75rem; }
.text-base { font-size: 0.9375rem; }

/* ── Utility — Colour ─────────────────────────────────────── */
.text-brand   { color: var(--colour-brand); }
.text-success { color: var(--colour-success); }
.text-danger  { color: var(--colour-error); }
.text-warning { color: #d97706; }
