:root {
  color-scheme: light;
  --bg: #f6f4ed;
  --surface: #fffefa;
  --surface-muted: #f0eee7;
  --border: #dedbd2;
  --border-strong: #c9c5bb;
  --text: #17191f;
  --muted: #6f726f;
  --primary: #2359e8;
  --primary-hover: #1747c8;
  --primary-soft: #e9eeff;
  --success: #267351;
  --success-soft: #e8f4ec;
  --warning: #8c5b17;
  --warning-soft: #fff3dd;
  --danger: #aa4138;
  --danger-soft: #fff0ed;
  --shadow: 0 14px 34px rgba(23, 25, 31, .08);
  --shadow-xs: 0 1px 2px rgba(23, 25, 31, .04);
  --shadow-md: 0 14px 34px rgba(23, 25, 31, .1);
  --font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --leading-tight: 1.15;
  --leading-compact: 1.3;
  --leading-body: 1.45;
  --leading-reading: 1.6;
  --tracking-default: 0em;
  --tracking-caps: .04em;
  --tracking-caps-wide: .07em;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

html, body { background: var(--bg); }
body { overflow-wrap: anywhere; }
a, button, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible,
select:focus-visible, summary:focus-visible {
  outline: 3px solid #b8c7ff !important;
  outline-offset: 2px;
}

.bylo-login-mark { width: 58px; height: 58px; object-fit: contain; }
.portal-header { background: var(--surface); }
.portal-brand { min-width: 44px; max-width: 250px; }
.portal-brand > img:first-child, .link-brand > img:first-child {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
}
.portal-wordmark, .link-wordmark {
  width: 126px;
  height: 42px;
  object-fit: contain;
}
.portal-nav { background: var(--surface); }
.portal-content { max-width: 1180px; }
.page-heading h1, .detail-card h1, .bylo-role-heading h1,
.bylo-state-card h1 { font-size: var(--text-2xl); font-weight: var(--weight-semibold); line-height: var(--leading-tight); letter-spacing: var(--tracking-default); }
.eyebrow, .section-label {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-compact);
  letter-spacing: var(--tracking-caps-wide);
}

.bylo-project-tools {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
}
.bylo-search { display: grid; gap: var(--space-2); color: var(--text); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.bylo-search input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}
.bylo-filter-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) var(--space-1) var(--space-2);
  scrollbar-width: thin;
}
.bylo-filter-row button, .bylo-disabled-filters button {
  min-width: max-content;
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.bylo-filter-row button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.bylo-decision-queue {
  display: grid;
  grid-template-columns: minmax(180px, .35fr) minmax(0, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  padding: var(--space-6);
  border: 1px solid #cdd6fa;
  border-radius: 18px;
  background: #f4f6ff;
}
.bylo-decision-queue h2 { margin: 0; font-size: var(--text-lg); line-height: var(--leading-compact); }
#bylo-decision-list { display: grid; gap: var(--space-2); }
.bylo-decision-row {
  min-width: 0;
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(110px, .3fr) minmax(0, 1fr) max-content;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.bylo-decision-row span { min-width: 0; color: var(--muted); font-size: var(--text-sm); line-height: var(--leading-body); }
.bylo-decision-row small { color: var(--primary); font-weight: var(--weight-semibold); }
.bylo-empty-copy { margin: 0; color: var(--muted); line-height: var(--leading-reading); }

.orders-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bylo-project-card { gap: var(--space-4); padding: var(--space-5); box-shadow: var(--shadow-xs); }
.bylo-project-card .order-card-top { display: grid; gap: var(--space-3); }
.bylo-project-card .order-card-top h2 { font-size: var(--text-lg); }
.bylo-project-message {
  display: -webkit-box;
  min-height: 4.4em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.bylo-status {
  justify-self: start;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.bylo-status.is-attention { background: var(--warning-soft); color: var(--warning); }
.bylo-status.is-ready { background: var(--success-soft); color: var(--success); }
.bylo-status.is-active { background: var(--primary-soft); color: var(--primary); }

.bylo-order-nav {
  display: flex;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  padding: var(--space-1);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.bylo-order-nav:empty { display: none; }
.bylo-order-nav a {
  min-width: max-content;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-4);
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-weight: var(--weight-semibold);
}
.bylo-order-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
body[data-bylo-route="settings"] #order-detail-view > .detail-card,
body[data-bylo-route="settings"] #final-publication,
body[data-bylo-route="settings"] #approval-dashboard,
body[data-bylo-route="settings"] #order-roster { display: none !important; }
body[data-bylo-route="overview"] #order-settings-form,
body[data-bylo-route="overview"] #membership-card { display: none !important; }

.bylo-route-view { display: grid; gap: var(--space-5); }
.bylo-role-heading { min-width: 0; display: grid; gap: var(--space-2); }
.bylo-role-heading p { max-width: 68ch; margin: 0; color: var(--muted); line-height: var(--leading-body); }
.bylo-exception-list { display: grid; gap: var(--space-3); }
.bylo-exception-card, .bylo-planned-card, .bylo-state-card {
  min-width: 0;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.bylo-exception-card { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: var(--space-4); }
.bylo-exception-dot { width: 10px; height: 10px; margin-top: var(--space-2); border-radius: 50%; background: var(--primary); }
.bylo-exception-card h2, .bylo-planned-card h2 { margin: 0; font-size: var(--text-lg); line-height: var(--leading-compact); }
.bylo-exception-card p, .bylo-planned-card p, .bylo-state-card p { margin: var(--space-2) 0 0; color: var(--muted); line-height: var(--leading-reading); }
.bylo-exception-action {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-3);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: var(--weight-semibold);
  text-align: left;
}
button.bylo-exception-action { cursor: pointer; }
.bylo-wave-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  margin-bottom: var(--space-3);
  padding: var(--space-1) var(--space-2);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.bylo-boundary-note { padding-top: var(--space-3); border-top: 1px solid var(--border); font-size: var(--text-sm); }
.bylo-disabled-filters { display: flex; gap: var(--space-2); overflow-x: auto; }
.bylo-disabled-filters button { opacity: .58; cursor: not-allowed; }
.bylo-bottom-nav { display: none; }

.link-header { border-bottom: 1px solid var(--border); }
.link-brand { max-width: 210px; }
.approval-app { padding-top: var(--space-8); }
.approval-layout { align-items: start; }
.approval-layout .proof-card { order: 0; }
.approval-layout .order-card { order: 1; }
.approval-layout .decision-card { order: 2; }
.content-card, .state-panel { background: var(--surface); }

#order-workspace label:has(input[type="checkbox"]),
#order-workspace label:has(input[type="radio"]) { min-height: 44px; }

@media (max-width: 980px) {
  .orders-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bylo-decision-queue { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .portal-header { min-height: 68px; padding: var(--space-2) var(--space-4); }
  .portal-wordmark { display: none; }
  .portal-profile-copy { display: none; }
  .portal-layout { display: block; }
  .portal-nav { display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-4); overflow-x: auto; border: 0; border-bottom: 1px solid var(--border); }
  .portal-nav button { min-width: max-content; padding: 0 var(--space-4); }
  .portal-content { padding: var(--space-8) var(--space-4); }
  .page-heading { align-items: center; margin-bottom: var(--space-5); }
  .orders-grid { grid-template-columns: minmax(0, 1fr); }
  .bylo-project-tools { padding: var(--space-4); }
  .bylo-decision-queue { padding: var(--space-4); }
  .bylo-decision-row { grid-template-columns: minmax(0, 1fr); }
  .bylo-decision-row small { justify-self: start; }
  .bylo-project-message { min-height: auto; }
  .order-card footer { align-items: flex-end; }
  .bylo-order-nav { position: sticky; z-index: 8; top: 76px; }
  .bylo-bottom-nav {
    position: sticky;
    z-index: 9;
    bottom: 8px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-1);
    margin-top: var(--space-8);
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .bylo-bottom-nav a, .bylo-bottom-nav span {
    min-width: 0;
    min-height: 44px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--muted);
    font-size: var(--text-xs);
    text-decoration: none;
  }
  .bylo-bottom-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: var(--weight-semibold); }
  .bylo-bottom-nav span { opacity: .55; }
  .link-shell { width: min(100% - 24px, 1040px); padding-bottom: var(--space-6); }
  .link-header { min-height: 68px; }
  .link-wordmark { width: 96px; }
  .approval-app { padding-top: var(--space-5); }
  .approval-heading { display: grid; gap: var(--space-3); }
  .approval-heading h1 { font-size: var(--text-2xl); }
  .decision-badge { justify-self: start; }
  .approval-layout { grid-template-columns: minmax(0, 1fr); }
  .approval-layout .proof-card { order: 0; }
  .approval-layout .order-card { order: 1; }
  .approval-layout .decision-card { order: 2; grid-column: auto; }
  .decision-actions { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
