/* Assistant Workbench on Keycaps.
   Visual-only layer: behavior contracts remain in auth.js/workbench-view.js. */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--surface);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2 {
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings:
    "opsz" 11,
    "SOFT" 80;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.45rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

h2 {
  margin: 34px 0 12px;
  font-size: 1.25rem;
  line-height: 1.3;
}

h3 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.highlight {
  padding: 0 0.14em;
  border-radius: 5px;
  background: var(--highlight-bg);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.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;
}

.mono,
.eyebrow,
.entry-date,
.feed-time,
.order-date,
.order-meta,
.approval-meta,
.card-meta,
.due,
.metric-value,
.figure,
.bill-amount strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* App masthead */

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px 28px;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 24px 28px 0;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid var(--chip-edge);
  border-bottom-width: 3px;
  border-radius: 9px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 0.78rem;
  font-weight: 700;
}

.brand-mark svg {
  width: 18px;
  height: 18px;
}

.brand-name {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-variation-settings: "opsz" 12;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--success-border);
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill svg {
  width: 14px;
  height: 14px;
}

.primary-nav {
  display: flex;
  grid-column: 1 / -1;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  padding: 6px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--surface-raised);
  scrollbar-width: none;
}

.primary-nav::-webkit-scrollbar {
  display: none;
}

.primary-nav a {
  flex: 0 0 auto;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a:hover {
  background: var(--key-face-neutral-hover);
  color: var(--ink);
}

.primary-nav a[aria-current="page"] {
  background: var(--chip-bg);
  color: var(--chip-text);
}

.operator-menu,
.icon-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 9px;
  background: var(--surface-raised);
  color: var(--ink);
  font-weight: 700;
  transition:
    transform var(--dur-press) ease,
    border-bottom-width var(--dur-press) ease,
    background-color var(--dur-press) ease;
}

.topbar-actions {
  display: flex;
  grid-row: 1;
  grid-column: 2;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.theme-toggle {
  min-width: 42px;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle-icon svg {
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.operator-menu:hover,
.icon-button:hover {
  background: var(--key-face-neutral-hover);
}

.operator-menu:active,
.icon-button:active {
  transform: translateY(2px);
  border-bottom-width: 1px;
}

.operator-menu svg,
.icon-button svg {
  width: 16px;
  height: 16px;
}

.theme-toggle-floating {
  position: fixed;
  z-index: 2;
  top: 20px;
  right: 20px;
}

/* Page scaffold */

.page {
  display: flex;
  width: min(100%, 1180px);
  flex-direction: column;
  gap: 32px;
  margin: 0 auto;
  padding: 42px 28px 72px;
}

.page-header,
.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 28px;
}

.page-header > div,
.hero-copy {
  min-width: 0;
}

.page-header h1,
.hero h1 {
  margin: 0;
}

.summary,
.lede {
  max-width: 66ch;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.hero-actions,
.card-actions,
.approval-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard,
.layout,
.stack {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 24px;
}

.page .dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.9fr);
  align-items: start;
}

.page aside.stack[aria-label="Assistant status"] {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  background: var(--surface-raised);
}

.toolbar p {
  margin: 0;
}

#approvalsSummary,
#activitySummary,
#ordersSummary,
#billsSummary {
  font-weight: 700;
}

.muted,
.empty-note {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Plates */

.panel,
.approval-card,
.activity-day,
.order-section,
.bill-section,
.empty-state,
.sign-in-shell > .sign-in-card {
  border: 0;
  border-radius: var(--radius-plate);
  background: var(--surface-raised);
  box-shadow: var(--shadow-plate);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 26px;
}

.panel-header,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title h2,
.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-variation-settings:
    "opsz" 11,
    "SOFT" 80;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.mini-icon {
  display: inline-grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 8px;
  background: var(--info-bg);
  color: var(--info-text);
}

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

.ok-icon {
  background: var(--success-bg);
  color: var(--success-text);
}

#needs-jaime {
  border-top: 4px solid var(--warning-border);
}

#handled-quietly {
  border-top: 4px solid var(--success-border);
}

#needsTitle {
  color: var(--ink);
}

#quietTitle {
  color: var(--ink);
}

.panel-intro {
  max-width: 64ch;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 18px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
}

.panel-link {
  color: var(--link);
  font-size: 0.9rem;
  font-weight: 700;
}

button.panel-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--link);
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 700;
}

.attention-count {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.attention-count[data-state="loading"] {
  background: var(--surface);
  color: var(--muted);
}

/* Status tags */

.tag,
.impact-pill,
.expiry {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-label,
.impact-pill {
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

.tag-info {
  border-color: var(--info-border);
  background: var(--info-bg);
  color: var(--info-text);
}

.tag-attention,
.expiry {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.tag-critical {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* Neutral facts stay gray; mint is reserved for verified/healthy states. */
.tag-neutral {
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

.tag-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--color-mint);
}

.dot[data-tone="muted"] {
  background: var(--muted);
}

.dot[data-tone="danger"] {
  background: var(--danger-text);
}

/* Keycap controls */

.button,
.action-button {
  display: inline-flex;
  width: auto;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-bottom-width: var(--edge-w);
  border-radius: var(--radius-key);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    transform var(--dur-press) ease,
    border-bottom-width var(--dur-press) ease,
    background-color var(--dur-press) ease;
}

.button:hover,
.action-button:hover {
  background: var(--key-face-neutral-hover);
  color: var(--ink);
  text-decoration: none;
}

.button:active:not(:disabled),
.action-button:active:not(:disabled) {
  transform: translateY(3px);
  border-bottom-width: 1px;
}

.button-primary,
.action-button[data-tone="primary"] {
  border-color: var(--key-face-primary);
  border-bottom-color: var(--key-edge-primary);
  background: var(--key-face-primary);
  color: var(--key-text-primary);
}

.button-primary:hover,
.action-button[data-tone="primary"]:hover {
  border-color: var(--key-face-primary-hover);
  border-bottom-color: var(--key-edge-primary);
  background: var(--key-face-primary-hover);
  color: var(--key-text-primary);
}

.button-secondary {
  border-color: var(--border);
  border-bottom-color: var(--border);
  background: var(--surface-raised);
  color: var(--ink);
}

.button-destructive,
.action-button[data-tone="destructive"] {
  border-color: var(--danger-border);
  border-bottom-color: var(--danger-text);
  background: var(--surface-raised);
  color: var(--danger-text);
}

.button svg,
.action-button svg {
  width: 16px;
  height: 16px;
}

button:disabled,
.action-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.approval-card:not(:first-child) .button-primary {
  border-color: var(--border);
  border-bottom-color: var(--border);
  background: var(--surface-raised);
  color: var(--ink);
}

/* Dashboard summary */

.folio {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  color: var(--muted);
  text-align: right;
}

.runline {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.runline .ok {
  color: var(--success-text);
  font-weight: 700;
}

.runline .warn {
  color: var(--danger-text);
  font-weight: 700;
}

.runline .dim {
  color: var(--muted);
}

.balance,
.digest-grid,
.page .metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--divider);
  border-radius: var(--radius-plate);
  background: var(--divider);
  box-shadow: var(--shadow-plate);
}

.balance > div,
.digest-grid .metric,
.page .metric-grid .metric {
  min-width: 0;
  padding: 18px 20px;
  border: 0;
  background: var(--surface-raised);
}

.balance > div + div,
.digest-grid .metric + .metric,
.page .metric-grid .metric + .metric {
  padding-left: 20px;
  border: 0;
}

/* Inside a panel the metric grid is not a floating plate, and the sidebar
   is too narrow for side-by-side timestamps. */
.panel .metric-grid {
  grid-template-columns: 1fr;
  box-shadow: none;
}

.balance .label,
.metric-label {
  display: block;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.balance .figure,
.metric-value {
  display: block;
  margin: 0;
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.25;
}

.balance .figure[data-tone="attention"] {
  color: var(--warning-text);
}

.balance .note,
.metric-note {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.pulse-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--divider);
  color: var(--muted);
  font-size: 0.85rem;
}

.operator-alert {
  padding: 16px 18px;
  border: 1px solid var(--danger-border);
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.operator-alert h2 {
  margin: 0 0 4px;
  color: inherit;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
}

.operator-alert p {
  margin: 0 0 8px;
}

.entry-what,
.feed-copy,
.order-copy,
.bill-copy {
  min-width: 0;
}

/* Every pending approval renders as a full, actionable card on the
   overview. Inside a panel the cards flatten to bordered sub-cards
   rather than stacked floating plates. */
.approval-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel .approval-card {
  padding: 18px;
  border: 1px solid var(--divider);
  border-radius: 12px;
  box-shadow: none;
}

.panel .approval-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.panel .approval-card .tag-row {
  margin-top: 8px;
}

.card-reason {
  padding: 12px 15px;
  border-left: 3px solid var(--warning-border);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--warning-bg) 45%, transparent);
}

.card-reason h4 {
  margin: 0 0 4px;
  color: var(--warning-text);
  font-size: 0.82rem;
}

.card-reason p {
  margin: 0;
  font-size: 0.9rem;
}

.card-note {
  padding: 18px;
  border: 1px solid var(--divider);
  border-radius: 12px;
}

.card-note[data-tone="success"] {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.card-note h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.card-note p {
  margin: 0;
  font-size: 0.9rem;
}

.card-note .loading-block {
  margin-top: 12px;
}

.approval-copy {
  max-width: 66ch;
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.approval-meta,
.card-meta,
.order-meta {
  display: flex;
  gap: 5px 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.ledger-entry h3,
.feed-entry h3,
.order-entry h3,
.bill-entry h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.entry-what p,
.feed-copy p,
.order-copy p,
.bill-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Lists and loading states */

.loading-block,
.order-loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loading-line {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--divider);
  animation: loading-pulse 1.4s ease-in-out infinite;
}

.loading-line.medium {
  width: 70%;
}

.loading-line.short {
  width: 40%;
}

@keyframes loading-pulse {
  50% {
    opacity: 0.45;
  }
}

.ledger-entries,
.feed-list,
.order-list,
.bill-list {
  display: flex;
  flex-direction: column;
}

.ledger-entry,
.feed-entry,
.order-entry,
.bill-entry {
  border-bottom: 1px solid var(--divider);
}

.ledger-entry:last-child,
.feed-entry:last-child,
.order-entry:last-child,
.bill-entry:last-child {
  border-bottom: 0;
}

.ledger-entry {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 8px 18px;
  padding: 15px 0;
}

.entry-date,
.feed-time,
.order-date {
  color: var(--muted);
  font-size: 0.75rem;
}

.entry-side {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  flex-direction: column;
}

.entry-notes {
  color: var(--muted) !important;
}

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.activity-day {
  padding: 22px;
}

/* Date groups reused inside a panel flatten out: plates do not stack. */
.panel .activity-day {
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.panel .activity-day + .activity-day {
  margin-top: 20px;
}

.date-heading {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 1.1rem;
}

.feed-entry {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 8px 16px;
  padding: 14px 0;
}

.feed-outcome {
  width: min(220px, 24vw);
  align-self: start;
  padding-top: 1px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.feed-outcome-label {
  display: block;
  margin-bottom: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.feed-outcome-text {
  display: block;
  font-weight: 600;
}

.run-followup {
  margin: 0;
  padding: 11px 14px;
  border-left: 3px solid var(--success-border);
  border-radius: 0 8px 8px 0;
  background: var(--success-bg);
  color: var(--success-text);
}

.run-followup[data-tone="warning"] {
  border-left-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* Tables */

.data-table,
.quiet-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.quiet-table th {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-align: left;
}

.data-table td,
.quiet-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--divider);
  font-size: 0.9rem;
  vertical-align: top;
}

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

.health-list {
  display: flex;
  flex-direction: column;
}

.health-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
}

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

.health-copy {
  min-width: 0;
}

.source-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  color: var(--ink);
  font-weight: 700;
}

.health-icon[data-tone="success"] {
  border: 1px solid var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.health-icon[data-tone="attention"] {
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.health-icon[data-tone="critical"] {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.health-icon[data-tone="neutral"] {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

.health-row-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.health-item[data-tone="success"] .health-row-status,
.health-status[data-tone="success"] {
  color: var(--success-text);
}

.health-item[data-tone="attention"] .health-row-status,
.health-status[data-tone="attention"] {
  color: var(--warning-text);
}

.health-item[data-tone="critical"] .health-row-status,
.health-status[data-tone="critical"] {
  color: var(--danger-text);
}

.health-value,
.health-status {
  color: var(--muted);
  font-size: 0.85rem;
}

.health-value {
  margin: 4px 0 0;
  line-height: 1.45;
}

.health-action,
.dialog-action,
.approval-resource {
  margin: 8px 0 0;
}

.health-action a,
.dialog-action a,
.approval-resource a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--link);
  font-size: 0.82rem;
  font-weight: 750;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.health-action svg,
.dialog-action svg,
.approval-resource svg {
  width: 14px;
  height: 14px;
}

#handled-quietly .ledger-entry {
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px 16px;
  padding: 17px 0;
}

#handled-quietly .entry-what p {
  max-width: 62ch;
  margin-top: 5px;
  line-height: 1.45;
}

/* Queue, order, bill, and run plates */

.approval-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
}

.approval-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
}

.approval-card h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.approval-card > p {
  max-width: 66ch;
  margin: 0;
  color: var(--muted);
}

.empty-state {
  padding: 30px 24px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 6px;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.order-section,
.bill-section {
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.order-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--divider);
}

.order-section-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.order-section-header p {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.bill-section-urgent {
  border-top: 4px solid var(--danger-border);
}

.bill-section-urgent .order-section-header h2 {
  color: var(--danger-text);
}

.order-entry {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 8px 20px;
  align-items: start;
  padding: 16px 0;
}

.order-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-date span,
.order-merchant {
  color: var(--ink);
  font-weight: 700;
}

.order-items {
  margin-top: 12px;
}

.order-items-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.order-items ul {
  display: grid;
  gap: 5px;
  margin: 5px 0 0;
  padding: 0;
  list-style: none;
}

.order-items li {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.order-item-quantity,
.order-item-detail {
  color: var(--muted);
}

.order-side {
  display: flex;
  min-width: 120px;
  align-items: flex-end;
  gap: 8px;
  flex-direction: column;
}

.button-compact {
  min-height: 38px;
  padding: 7px 11px;
  font-size: 0.8rem;
}

.order-action-status {
  max-width: 24ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: right;
}

.orders-notice {
  margin: -12px 0 0;
  padding: 11px 14px;
  border-left: 3px solid var(--success-border);
  border-radius: 0 8px 8px 0;
  background: var(--success-bg);
  color: var(--success-text);
  font-size: 0.875rem;
  font-weight: 600;
}

.orders-notice[data-tone="error"] {
  border-left-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.orders-notice[data-tone="progress"] {
  border-left-color: var(--info-border);
  background: var(--info-bg);
  color: var(--info-text);
}

.order-links {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex-direction: column;
  font-size: 0.85rem;
  font-weight: 700;
}

.bill-entry {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto auto;
  gap: 10px 18px;
  align-items: start;
  padding: 16px 0;
}

.bill-entry-overdue {
  box-shadow: inset 3px 0 var(--danger-border);
  padding-left: 14px;
}

.bill-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bill-payment-history {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
}

.bill-payment-history div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
}

.bill-payment-history dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.bill-payment-history dd {
  margin: 0;
  font-size: 0.85rem;
}

.bill-recurring {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--info-text);
  font-size: 0.78rem;
  font-weight: 700;
}

.bill-recurring svg {
  width: 14px;
  height: 14px;
}

.bill-amount {
  display: flex;
  min-width: 110px;
  align-items: flex-end;
  gap: 3px;
  flex-direction: column;
  text-align: right;
}

.bill-variance {
  color: var(--muted);
  font-size: 0.75rem;
}

.bill-variance-up {
  color: var(--danger-text);
}

.bill-variance-down {
  color: var(--success-text);
}

/* Dialogs */

.dialog-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(21 24 29 / 0.68);
}

.dialog-panel,
.dialog {
  width: min(100%, 600px);
  max-height: min(85vh, 760px);
  overflow-y: auto;
  padding: 24px;
  border: 0;
  border-radius: var(--radius-plate);
  background: var(--surface-raised);
  box-shadow: var(--shadow-plate);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--divider);
}

.dialog-header h2,
.dialog h2 {
  margin: 0;
  font-size: 1.25rem;
}

.dialog-body {
  padding: 18px 0;
}

.dialog-body p {
  margin: 0 0 12px;
}

.dialog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dialog-row {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--ink);
  text-align: left;
}

.dialog-row:hover {
  background: var(--key-face-neutral-hover);
}

.dialog-row p {
  margin: 3px 0 0;
  color: var(--muted);
}

.dialog-row > span:first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.dialog-row > .tag {
  margin-left: auto;
  justify-content: flex-end;
  text-align: right;
}

.technical-detail {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.technical-detail summary {
  width: fit-content;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.technical-detail[open] summary {
  margin-bottom: 7px;
}

.technical-detail p {
  padding-left: 10px;
  border-left: 2px solid var(--divider);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) 1fr;
  gap: 12px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Sign in */

.sign-in-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.sign-in-shell > .sign-in-card {
  width: min(100%, 440px);
  padding: 32px 30px 28px;
}

.sign-in-shell > .sign-in-card .brand-mark {
  width: 44px;
  height: 44px;
}

.sign-in-shell > .sign-in-card h1 {
  margin: 22px 0 8px;
}

.sign-in-shell > .sign-in-card p {
  color: var(--muted);
}

.sign-in-shell > .sign-in-card .button {
  width: 100%;
  margin-top: 20px;
}

.sign-in-status {
  min-height: 1.5em;
  margin: 14px 0 0;
  color: var(--danger-text) !important;
}

@media (max-width: 860px) {
  .page .dashboard {
    grid-template-columns: 1fr;
  }

  .balance,
  .digest-grid,
  .page .metric-grid {
    grid-template-columns: 1fr;
  }

  .page-header,
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .folio {
    align-items: flex-start;
    text-align: left;
  }

  .bill-entry {
    grid-template-columns: 100px minmax(0, 1fr) auto;
  }

  .bill-entry .order-side {
    grid-column: 2 / -1;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 18px 18px 0;
  }

  .brand {
    gap: 9px;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .status-pill {
    display: none;
  }

  .operator-menu {
    min-width: 42px;
    padding-inline: 10px;
  }

  .operator-menu span,
  .theme-toggle > span:last-child {
    display: none;
  }

  .primary-nav {
    margin-inline: -2px;
  }

  .page {
    gap: 26px;
    padding: 30px 18px 52px;
  }

  .panel,
  .activity-day,
  .approval-card,
  .order-section,
  .bill-section {
    padding: 20px;
  }

  .panel-header,
  .order-section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions,
  .card-actions,
  .approval-actions {
    width: 100%;
  }

  .hero-actions .button,
  .card-actions .button,
  .approval-actions .button,
  .approval-actions .action-button {
    width: 100%;
  }

  .ledger-entry {
    grid-template-columns: 1fr;
  }

  .entry-side {
    align-items: center;
    flex-direction: row;
  }

  .feed-entry {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px 12px;
  }

  .feed-outcome {
    grid-column: 2;
    width: auto;
    justify-self: start;
  }

  .order-entry {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
  }

  .order-date {
    grid-column: 1;
    grid-row: 1;
    flex-direction: row;
    align-items: baseline;
    gap: 7px;
  }

  .order-side {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }

  .order-side .button-compact {
    width: auto;
  }

  .order-action-status {
    text-align: left;
  }

  .order-copy {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .bill-entry {
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px 12px;
  }

  .bill-entry .order-date {
    grid-column: 1;
    grid-row: 1;
    align-items: flex-start;
    flex-direction: column;
  }

  .bill-copy {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .bill-amount {
    grid-column: 2;
    grid-row: 3;
    min-width: 0;
    align-items: flex-start;
    text-align: left;
  }

  .bill-entry .order-side {
    grid-column: 2;
    grid-row: 4;
  }

  .bill-payment-history div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .detail-list div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

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

  .button:active:not(:disabled),
  .action-button:active:not(:disabled),
  .operator-menu:active,
  .icon-button:active {
    transform: none;
    border-bottom-width: var(--edge-w);
  }

  .operator-menu:active,
  .icon-button:active {
    border-bottom-width: 3px;
    background: var(--key-face-neutral-hover);
  }

  .button-primary:active:not(:disabled),
  .action-button[data-tone="primary"]:active:not(:disabled) {
    background: var(--key-edge-primary);
  }
}
