/* GoSignHere design system (p6a, 2026-10-09). Rebuilt from 30-reference/ghs-ui-reference/assets/css/shared.css.
   Section 1: tokens (shared.css verbatim, then the additions marked "p6a").  Section 2: shared components.
   Section 3: app-specific rules (shell, library, packages, settings, auth, admin chrome).
   Rulings: light by default, [data-theme="dark"] opts in; Inter for UI, Source Serif 4 only inside document previews,
   IBM Plex Mono for keys and hashes; radius 4/8/16/24; three shadows; type scale 12/13/15/17/22/28. */

/* ===== 1. Fonts ===== */
@font-face { font-family: 'Inter'; src: url(/assets/fonts/InterVariable.woff2) format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Source Serif 4'; src: url(/assets/fonts/SourceSerif4-Variable.woff2) format('woff2'); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'Source Serif 4'; src: url(/assets/fonts/SourceSerif4-Italic-Variable.woff2) format('woff2'); font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(/assets/fonts/IBMPlexMono-Regular.woff2) format('woff2'); font-weight: 400 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(/assets/fonts/IBMPlexMono-SemiBold.woff2) format('woff2'); font-weight: 600 700; font-style: normal; font-display: swap; }

/* ===== 1. Signly design tokens (shared.css verbatim) ===== */
:root {
  --surface-0: #F7F8FA;
  --surface-1: #FFFFFF;
  --surface-2: #FFFFFF;
  --surface-2-shade: #F3F4F7;
  --border: #E4E7EC;
  --border-strong: #D6DAE1;
  --text-primary: #1A1D23;
  --text-secondary: #6B7280;
  --text-tertiary: #9AA1AC;
  --accent: #4F5DFF;
  --accent-hover: #3F4CE0;
  --accent-soft: #EEF0FF;
  --accent-contrast: #FFFFFF;
  --attention: #F59E0B;
  --attention-soft: #FEF3E0;
  --success: #16A34A;
  --success-soft: #E9F8EE;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --field-sig: #4F5DFF;
  --field-init: #7C86FF;
  --field-date: #16A34A;
  --field-text: #F59E0B;
  --field-check: #9333EA;
  --signer-1: #2E7BD6;
  --signer-1-soft: #E9F1FC;
  --signer-2: #1F9D63;
  --signer-2-soft: #E7F7EF;
  --signer-3: #E07A2E;
  --signer-3-soft: #FCEEE1;
  --signer-4: #8B5CF6;
  --signer-4-soft: #F1ECFE;
  --prefill: #B07CE8;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(16,20,30,0.06);
  --shadow-md: 0 4px 16px rgba(16,20,30,0.10);
  --shadow-lg: 0 12px 32px rgba(16,20,30,0.16);
  --ribbon-h: 92px;
  --topbar-h: 44px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-doc: 'Source Serif 4', Georgia, serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* p6a additions. Signers 5-8 (distinct from 1-4 and from each other; every solid >= 4.0:1 on white, >= 6:1 in dark on surface-1). */
  --signer-5: #B8478C;
  --signer-5-soft: #FBEAF3;
  --signer-6: #0E8A9C;
  --signer-6-soft: #E3F5F8;
  --signer-7: #957600;
  --signer-7-soft: #FAF3DB;
  --signer-8: #5F6B7A;
  --signer-8-soft: #ECEFF2;
  /* Text-grade inks: shared.css success/danger/attention fail 4.5:1 as small text on their soft fills; these pass. */
  --accent-ink: #3F4CE0;
  --success-ink: #15803D;
  --danger-ink: #B91C1C;
  --attention-ink: #92400E;
  /* Document paper is always white and always dark ink, whatever the shell theme. */
  --doc-ink: #1A1D23;
  --doc-ink-muted: #475569;
  --doc-border: #CBD5E1;
  --overlay: rgba(16,20,30,0.55);
  --duration-fast: 100ms;
  --duration-base: 200ms;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --tag-blue: #4A90D9;
  --tag-green: #50B87A;
  --tag-orange: #E8A84A;
  --tag-purple: #9B6BD9;
  --tag-pink: #E06BA0;
  --tag-teal: #2DB8AF;
  --tag-red: #E05C5C;
  --tag-yellow: #E0C83C;
  color-scheme: light;
}

[data-theme="dark"] {
  --surface-0: #14161B;
  --surface-1: #1C1F26;
  --surface-2: #242832;
  --surface-2-shade: #1F232C;
  --border: #2E333D;
  --border-strong: #3A4049;
  --text-primary: #EDEFF3;
  --text-secondary: #9AA1AC;
  --text-tertiary: #6B7280;
  --accent: #7C86FF;
  --accent-hover: #929BFF;
  --accent-soft: #262A45;
  --accent-contrast: #0B0D12;
  --attention: #FBBF24;
  --attention-soft: #382A10;
  --success: #4ADE80;
  --success-soft: #123420;
  --danger: #F87171;
  --danger-soft: #3A1616;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);
  --signer-1: #5B9EE8;
  --signer-1-soft: #1A2A3D;
  --signer-2: #4ADE93;
  --signer-2-soft: #163524;
  --signer-3: #F0954D;
  --signer-3-soft: #3A2416;
  --signer-4: #A78BFA;
  --signer-4-soft: #2A2140;
  --prefill: #C79AF0;

  --signer-5: #E07FB5;
  --signer-5-soft: #3A1B2E;
  --signer-6: #3CC4D6;
  --signer-6-soft: #12313A;
  --signer-7: #E6C547;
  --signer-7-soft: #3A3014;
  --signer-8: #9AA7B5;
  --signer-8-soft: #262B32;
  --accent-ink: #929BFF;
  --success-ink: #4ADE80;
  --danger-ink: #F87171;
  --attention-ink: #FBBF24;
  color-scheme: dark;
}

/* Signer helpers: the 15% tint (placed-field fill) and 35% border derive from the solid, in both themes. */
:root {
  --signer-1-tint: color-mix(in srgb, var(--signer-1) 15%, transparent); --signer-1-border: color-mix(in srgb, var(--signer-1) 35%, transparent);
  --signer-2-tint: color-mix(in srgb, var(--signer-2) 15%, transparent); --signer-2-border: color-mix(in srgb, var(--signer-2) 35%, transparent);
  --signer-3-tint: color-mix(in srgb, var(--signer-3) 15%, transparent); --signer-3-border: color-mix(in srgb, var(--signer-3) 35%, transparent);
  --signer-4-tint: color-mix(in srgb, var(--signer-4) 15%, transparent); --signer-4-border: color-mix(in srgb, var(--signer-4) 35%, transparent);
  --signer-5-tint: color-mix(in srgb, var(--signer-5) 15%, transparent); --signer-5-border: color-mix(in srgb, var(--signer-5) 35%, transparent);
  --signer-6-tint: color-mix(in srgb, var(--signer-6) 15%, transparent); --signer-6-border: color-mix(in srgb, var(--signer-6) 35%, transparent);
  --signer-7-tint: color-mix(in srgb, var(--signer-7) 15%, transparent); --signer-7-border: color-mix(in srgb, var(--signer-7) 35%, transparent);
  --signer-8-tint: color-mix(in srgb, var(--signer-8) 15%, transparent); --signer-8-border: color-mix(in srgb, var(--signer-8) 35%, transparent);
}

/* ===== 2. Components (shared.css class names kept; the shell, ribbon and workzone classes arrive with p6b) ===== */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-ui);
  background: var(--surface-0);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
body { font-size: 13px; line-height: 1.5; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent-soft); }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hidden { display: none !important; }

/* buttons */
.btn {
  border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface-1);
  padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--text-primary); display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2-shade); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2-shade); }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip-attention { background: var(--attention-soft); color: var(--attention-ink); }
.chip-success { background: var(--success-soft); color: var(--success-ink); }
.chip-danger { background: var(--danger-soft); color: var(--danger-ink); }
.chip-neutral { background: var(--surface-2-shade); color: var(--text-secondary); border: 1px solid var(--border); }

/* inputs */
.field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; display: block; }
.input {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* dropdown (custom select) */
.dd { position: relative; }
.dd-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 10px; border-radius: var(--radius-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.dd-trigger:hover { background: var(--surface-2-shade); }
.dd-menu {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 4px; z-index: 40; display: none; max-height: 220px; overflow-y: auto;
}
.dd.open .dd-menu { display: block; }
.dd-option { padding: 7px 9px; border-radius: var(--radius-sm); font-size: 13px; display: flex; align-items: center; justify-content: space-between; }
.dd-option:hover { background: var(--accent-soft); color: var(--accent-ink); }
.dd-option.selected { font-weight: 700; }

/* segmented control */
.segmented { display: flex; background: var(--surface-2-shade); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 2px; gap: 2px; }
.segmented button { flex: 1; border: none; background: transparent; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.segmented button.active { background: var(--surface-1); color: var(--accent-ink); box-shadow: var(--shadow-sm); }

/* toggle switch */
.switch { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .15s ease; box-shadow: var(--shadow-sm); }
.switch.on { background: var(--accent); }
.switch.on::after { left: 16px; }

/* cards (the base; the app's .card rules in section 3 add structure) */
.card:hover.hoverable { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }

/* scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-sm); }
::-webkit-scrollbar-track { background: transparent; }

/* key and hash text */
code, .mono, .key-badge { font-family: var(--font-mono); }

/* Document previews and the certificate: the only place the serif is used. */
.doc-body, .doc-preview, .certificate { font-family: var(--font-doc); color: var(--doc-ink); }
.doc-body p, .doc-body li, .doc-body td, .doc-body th { color: var(--doc-ink); }
.doc-body table { border-collapse: collapse; width: 100%; }
.doc-body th, .doc-body td { border: 1px solid var(--doc-border); padding: 6px 8px; text-align: left; }
.doc-body .small-print { font-size: 12px; color: var(--doc-ink-muted); }

/* Global reduced-motion guard — unchanged from crm-theme.css. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* App-wide button :active / :focus-visible states — unchanged pattern from crm-theme.css, reuses
   this file's own --accent. */
button:not(:disabled):active {
  opacity: 0.8;
}
button:not(:disabled):focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

/* htmx loading affordance — unchanged from crm-theme.css. */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Skeleton loader — unchanged from crm-theme.css. */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--border) 40%, transparent) 25%,
    color-mix(in srgb, var(--border) 70%, transparent) 37%,
    color-mix(in srgb, var(--border) 40%, transparent) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* Toast/notification — unchanged pattern from crm-theme.css. */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-contrast);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-base) var(--ease-out),
    transform var(--duration-base) var(--ease-out);
}
.toast.toast-show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success {
  background: var(--success);
}
.toast-warning {
  background: var(--attention-ink); /* filled surface + white text — must use the -ink token, see fork note above */
}
.toast-error {
  background: var(--danger-ink);
}
.toast-info {
  background: var(--accent);
}

/* Spacing ramp: unchanged from crm-theme.css — 4/8/12/16/24/32px, no half-steps or odd steps. */

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  flex-shrink: 0;
  background: currentColor;
}

.choice-group {
  columns: 11rem;
  column-gap: 1rem;
}
.choice-group label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  break-inside: avoid;
  padding: 0.25rem 0;
  min-height: 1.5rem;
}

.info-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 4px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}
.info-badge .tooltip-bubble {
  position: absolute;
  z-index: 40;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 260px;
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease-out;
  transition-delay: 300ms;
  pointer-events: none;
}
.info-badge:hover .tooltip-bubble,
.info-badge:focus .tooltip-bubble,
.info-badge:focus-visible .tooltip-bubble {
  opacity: 1;
  visibility: visible;
}
.info-badge:focus .tooltip-bubble,
.info-badge:focus-visible .tooltip-bubble {
  transition-delay: 0ms;
}
@media (prefers-reduced-motion: reduce) {
  .info-badge .tooltip-bubble {
    transition: none;
  }
}

/* Modals — native <dialog>, same pattern as crm-theme.css's §7.7-documented component, now also
   the target for GSH-GUI's Render Shell (currently a plain <div id="modal-root">, migrated in
   brief 2 of this phase — see gsh-design.md). Entry uses --ease-spring (GoSignHere's "arrival"
   easing) rather than crm-theme.css's plain ease-out, per gsh-design.md's motion notes. */
.modal-panel {
  background: var(--surface-1);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 90vw;
  max-width: 640px;
  /* FIX (card 111, 2026-08-26): Tailwind Play CDN's Preflight ships `*, ::before, ::after {
     margin: 0 }`, which -- being an author-origin rule -- overrides the native `dialog { margin:
     auto }` UA default that centers a `showModal()`'d <dialog> in the viewport (author styles beat
     UA styles regardless of selector specificity). Undiscovered until this round because no live
     GSH page had actually wired a real htmx request to #modal-root before (found while building the
     card 111 delete-confirm dialogs, which are the first). Without this, every native-<dialog>
     confirm on GSH-GUI renders pinned to the top-left corner instead of centered. */
  margin: auto;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity var(--duration-base) var(--ease-spring),
    transform var(--duration-base) var(--ease-spring),
    display var(--duration-base) allow-discrete,
    overlay var(--duration-base) allow-discrete;
}
.modal-panel[open] {
  opacity: 1;
  transform: translateY(0) scale(1);
}
@starting-style {
  .modal-panel[open] {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}
.modal-panel::backdrop {
  background: transparent;
  transition: background var(--duration-base) var(--ease-out),
    display var(--duration-base) allow-discrete,
    overlay var(--duration-base) allow-discrete;
}
.modal-panel[open]::backdrop {
  background: var(--overlay); /* GoSignHere's overlay convention is a touch darker/blurred vs. CRM's plain 0.5 black */
}
@starting-style {
  .modal-panel[open]::backdrop {
    background: transparent;
  }
}

.sortable-th {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
.sortable-th:hover {
  color: var(--text-primary);
}

/* Print: force the light tokens regardless of the active theme, hide chrome. */
@media print {
  :root, [data-theme="dark"] {
    --surface-0: #FFFFFF; --surface-1: #FFFFFF; --surface-2: #FFFFFF; --border: #CBD5E1;
    --text-primary: #1A1D23; --text-secondary: #64748B;
    --success-soft: #E9F8EE; --attention-soft: #FEF3E0; --danger-soft: #FDECEC; --accent-soft: #EEF0FF;
  }
  html, body, body > div { height: auto !important; max-height: none !important; overflow: visible !important; }
  button, input, select, textarea, .no-print { display: none !important; }
  table, tr, h1, h2, h3 { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}

/* ===== 3. App rules (shell, library, packages, settings, auth, admin chrome) ===== */
body { margin: 0; background: var(--surface-0); color: var(--text-primary); line-height: 1.5; }
.container { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); color: var(--text-primary); font: inherit; cursor: pointer; text-decoration: none; transition: background var(--duration-fast) var(--ease-out); }
.btn:hover { background: var(--surface-0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.field { display: block; width: 100%; box-sizing: border-box; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); color: var(--text-primary); font: inherit; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.error { padding: 8px 12px; border-radius: var(--radius-md); background: var(--danger-soft); color: var(--danger-ink); }

/* ops portal (plain tables and tiles; no inline styles anywhere) */
.ops-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ops-section { margin: 24px 0; }
.ops-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.ops-tile { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); }
.ops-tile-label { font-size: 12px; color: var(--text-secondary); }
.ops-tile-value { font-size: 22px; font-weight: 600; }
.ops-tile-sub { font-size: 12px; color: var(--text-secondary); }
.ops-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ops-table th, .ops-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.ops-muted { color: var(--text-secondary); }
.ops-inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.ops-num { width: 96px; }


body { font-size: 15px; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm);
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
code, .mono { font-family: var(--font-mono); font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-secondary); }
.skip { position: absolute; left: 8px; top: -48px; z-index: 100; padding: 8px 12px; background: var(--accent); color: var(--accent-contrast); border-radius: var(--radius-md); }
.skip:focus { top: 8px; }
.ico { width: 20px; height: 20px; flex: none; }
.ico-brand { color: var(--accent); }
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 0; }

/* buttons */
.btn { min-height: 40px; font-size: 15px; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-icon { padding: 4px 8px; min-width: 40px; }
.btn-danger { background: var(--danger-ink); border-color: var(--danger-ink); color: var(--accent-contrast); }
.btn-danger:hover { background: var(--danger-ink); filter: brightness(0.92); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; background: transparent; border-style: dashed; border-color: var(--border); color: var(--text-secondary); filter: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); text-decoration: underline; cursor: pointer; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.phase-wrap { display: inline-flex; align-items: center; gap: 8px; }
.phase-tag { font-size: 12px; color: var(--text-secondary); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 2px 8px; white-space: nowrap; }

/* forms */
.stack { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.row { display: flex; flex-direction: column; gap: 6px; }
.row > label, .lbl { font-weight: 600; font-size: 15px; }
.helper { margin: 0; font-size: 13px; color: var(--text-secondary); }
.narrow { max-width: 560px; }
.short { max-width: 260px; }
.field-sm { min-height: 32px; padding: 2px 8px; font-size: 13px; width: auto; }
.field[disabled] { opacity: 1; background: var(--surface-0); color: var(--text-secondary); cursor: not-allowed; }
.field[aria-invalid="true"] { border-color: var(--danger); outline: 1px solid var(--danger); }
textarea.field { resize: vertical; font-family: inherit; }
.form-error:empty { display: none; }
.form-error:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--text-primary); border: 1px solid var(--danger); border-left-width: 4px; background: var(--danger-soft); }
.error .ico { color: var(--danger); margin-top: 2px; }
.notice, .success { margin: 0; padding: 8px 12px; border: 1px solid var(--success); border-left-width: 4px; border-radius: var(--radius-md); background: var(--success-soft); color: var(--text-primary); }
.success p { margin: 0 0 8px; }
.toast-success { background: var(--success-ink); }
.toast { pointer-events: auto; max-width: 360px; }

/* auth */
body.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-top { display: flex; justify-content: flex-end; padding: 12px 16px; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; box-sizing: border-box; padding: 32px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 22px; }
.auth-card p { margin: 0; }
.auth-links { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0; }
.wordmark { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text-primary); text-decoration: none; }
.wordmark-static { margin: 0; }

/* theme toggle: shows the action (switch to the other theme) */
:root[data-theme="dark"] .t-to-dark, :root:not([data-theme="dark"]) .t-to-light { display: none; }

/* app shell */
body.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; box-sizing: border-box; display: flex; flex-direction: column; gap: 24px; padding: 16px 12px; background: var(--surface-1); border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar .wordmark { padding: 0 8px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; box-sizing: border-box; padding: 8px 12px; border-radius: var(--radius-md); color: var(--text-primary); text-decoration: none; font-weight: 600; }
.nav-item:hover { background: var(--surface-0); }
.nav-item.is-active { background: var(--accent); color: var(--accent-contrast); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.side-who { display: flex; flex-direction: column; padding: 0 8px; min-width: 0; }
.side-account { font-weight: 700; overflow-wrap: anywhere; }
.side-user { font-size: 13px; color: var(--text-secondary); overflow-wrap: anywhere; }
.side-actions { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.side-actions .btn, .side-actions form { justify-content: flex-start; }
.side-actions form .btn { width: 100%; }
.main { padding: 24px 32px 48px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1:focus { outline: none; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* cards */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2:focus { outline: none; }
.card-head h2:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.card-sub { margin: 4px 0 0; font-size: 13px; color: var(--text-secondary); }
.card-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.card-danger { border-color: var(--danger); }
.settings { display: flex; flex-direction: column; gap: 24px; max-width: 960px; }
.settings .card-body { gap: 16px; }
.sub-h { margin-top: 8px; }
.count-badge { display: inline-block; min-width: 20px; padding: 0 8px; margin-left: 4px; border-radius: 9999px; background: var(--accent); color: var(--accent-contrast); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px; }
.empty { margin: 0; padding: 12px 0; color: var(--text-primary); }
.empty.small { padding: 4px 8px; font-size: 13px; color: var(--text-secondary); }
.empty-state { padding: 24px 0; }

/* dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.scroll-y { max-height: 400px; overflow-y: auto; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: 0; }
.row-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 9999px; flex: none; }
.tone-warning { background: var(--attention-soft); color: var(--attention); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--accent-soft); color: var(--accent); }
.tone-neutral { background: color-mix(in srgb, var(--border) 50%, transparent); color: var(--text-secondary); }
:root.dark .tone-info, :root[data-theme="dark"] .tone-info { color: var(--accent-ink); }
.row-main { flex: 1; min-width: 0; }
.row-title, .row-title-plain { font-weight: 600; overflow-wrap: anywhere; }
.row-title-plain { color: var(--text-primary); }
.row-meta, .row-text { font-size: 13px; overflow-wrap: anywhere; }
.row-meta { color: var(--text-secondary); }
.row-text { font-size: 15px; }
.doc-link { font-weight: 600; }

/* chips and tags */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 9999px; font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.chip-dot { width: 8px; height: 8px; border-radius: 9999px; background: var(--text-secondary); }
.chip-draft, .chip-invited { background: var(--attention-soft); border-color: var(--attention); } .chip-draft .chip-dot, .chip-invited .chip-dot { background: var(--attention); }
.chip-ready, .chip-active { background: var(--success-soft); border-color: var(--success); } .chip-ready .chip-dot, .chip-active .chip-dot { background: var(--success); }
.chip-processing { background: var(--accent-soft); border-color: var(--accent); } .chip-processing .chip-dot { background: var(--accent); }
.chip-disabled, .chip-failed { background: var(--danger-soft); border-color: var(--danger); } .chip-disabled .chip-dot, .chip-failed .chip-dot { background: var(--danger); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; background: var(--surface-0); color: var(--text-primary); }
.tag-dot { width: 10px; height: 10px; border-radius: 9999px; flex: none; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text-primary) 40%, transparent); }
.tag-blue { background: var(--tag-blue); } .tag-green { background: var(--tag-green); } .tag-orange { background: var(--tag-orange); } .tag-purple { background: var(--tag-purple); }
.tag-pink { background: var(--tag-pink); } .tag-teal { background: var(--tag-teal); } .tag-red { background: var(--tag-red); } .tag-yellow { background: var(--tag-yellow); }

/* workspaces */
.ws-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.ws-side { display: flex; flex-direction: column; gap: 24px; padding: 16px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.ws-side h2 { font-size: 13px; text-transform: none; color: var(--text-secondary); margin-bottom: 8px; padding: 0 8px; }
.ws-side h2:focus { outline: none; }
.ws-side h2:focus-visible { outline: 2px solid var(--accent); }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-item { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-md); }
.side-item.is-active { background: var(--surface-0); box-shadow: inset 3px 0 0 var(--accent); }
.side-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; color: var(--text-primary); text-decoration: none; overflow-wrap: anywhere; }
.side-item.is-active .side-link { font-weight: 700; }
.count { margin-left: auto; font-size: 12px; color: var(--text-secondary); }
.inline-add { margin-top: 8px; }
.inline-add > summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; cursor: pointer; color: var(--accent-ink); font-weight: 600; list-style: none; }
.inline-add > summary::-webkit-details-marker { display: none; }
.inline-add form { padding: 8px; }
.ws-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.ws-main-head h2 { font-size: 17px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 0; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-box .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.search-box .field { padding-left: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.chip-choice { position: relative; }
.chip-choice input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip-choice span { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; box-sizing: border-box; padding: 4px 14px; border: 1px solid var(--border); border-radius: 9999px; font-size: 13px; font-weight: 600; background: var(--surface-1); color: var(--text-primary); }
.chip-choice span .ico { display: none; width: 14px; height: 14px; }
.chip-choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.chip-choice input:checked + span .ico { display: inline-block; }
.chip-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.filter-note { margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* tables */
.dtable { width: 100%; border-collapse: collapse; font-size: 15px; }
.dtable th { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-secondary); padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.dtable td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.dtable .cell-actions { text-align: right; white-space: nowrap; }
.row-forms .inline-form, .row-forms .tip { margin-left: 8px; vertical-align: middle; }
.dtable td[data-label="Role"], .dtable td[data-label="Status"] { white-space: nowrap; }
.page-head h1:focus-visible { outline: none; }
a.row-title { text-decoration: none; }
a.row-title:hover { text-decoration: underline; }
.tip { display: inline-flex; }
#doc-results { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px 16px; min-width: 0; }

/* row menus */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); text-align: left; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; box-sizing: border-box; padding: 6px 12px; background: none; border: 0; border-radius: var(--radius-sm); color: var(--text-primary); font: inherit; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-0); }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.menu-danger { color: var(--text-primary); }
.menu-danger .ico { color: var(--danger); }

/* dialogs */
.modal-panel h2 { font-size: 17px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.checks { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 36px; }
.check input { width: 18px; height: 18px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .field { flex: 1; min-width: 0; }

/* settings widgets */
.toggle { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; position: relative; }
.toggle input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
.toggle-ui { position: relative; flex: none; width: 44px; height: 24px; box-sizing: border-box; border-radius: 9999px; border: 2px solid var(--text-secondary); background: var(--surface-0); transition: background var(--duration-fast) var(--ease-out); }
.toggle-ui::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 9999px; background: var(--text-secondary); transition: transform var(--duration-fast) var(--ease-out); }
.toggle input:checked + .toggle-ui { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-ui::after { transform: translateX(20px); background: var(--accent-contrast); }
.toggle input:focus-visible + .toggle-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text { display: flex; flex-direction: column; }
.toggle-label { font-weight: 600; }
.toggle-desc { font-size: 13px; color: var(--text-secondary); }
.var-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.var-chip { font-family: var(--font-mono); font-size: 13px; min-height: 32px; padding: 2px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-0); color: var(--text-primary); cursor: pointer; }
.var-chip:hover { border-color: var(--accent); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0 0 16px; }
.facts dt { color: var(--text-secondary); } .facts dd { margin: 0; }
.facts-inline { display: flex; gap: 24px; }
.fi-label { color: var(--text-secondary); min-width: 56px; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--border); }
.danger-row:last-child { border-bottom: 0; }
.danger-title { font-weight: 700; } .danger-desc { font-size: 13px; color: var(--text-secondary); }

/* narrow screens: sidebar becomes a top bar, tables become stacked rows */
@media (max-width: 860px) {
  body.app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .side-nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .nav-item { min-height: 44px; padding: 8px 12px; }
  .side-foot { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; margin-left: auto; gap: 8px; }
  .side-who { display: none; }
  .side-actions { flex-direction: row; }
  .side-actions .btn { padding: 8px 10px; }
  .main { padding: 16px; }
  .dash-grid, .ws-layout { grid-template-columns: minmax(0, 1fr); }
  .dtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; }
  .dtable tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .dtable td { display: flex; justify-content: space-between; gap: 16px; border-bottom: 0; padding: 4px 0; text-align: right; }
  .dtable td::before { content: attr(data-label); color: var(--text-secondary); font-weight: 600; text-align: left; flex: none; }
  .dtable td.cell-actions::before { content: none; }
  .dtable td.cell-actions { justify-content: flex-end; }
  .menu-list { right: 0; }
  .auth-card { padding: 24px 16px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .copy-row { flex-wrap: wrap; }
}

.dtable td[data-label="Tags"] { min-width: 140px; }
.tag-chip { overflow-wrap: normal; word-break: normal; }

/* ---- p3b: upload modal, document detail ---- */
.ico-lg { width: 36px; height: 36px; }
.spinner { display: inline-block; width: 14px; height: 14px; flex: none; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 9999px; animation: gsh-spin 0.8s linear infinite; }
@keyframes gsh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.upload-modal { max-width: 580px; width: 92vw; max-height: 88vh; overflow-y: auto; }
.up-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.up-head h2 { display: flex; align-items: center; gap: 8px; }
.up-ws select { max-width: 320px; }
.up-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; box-sizing: border-box; padding: 32px 24px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius-lg); color: var(--text-primary); transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out); }
.up-drop:hover, .up-drop:focus-within { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.up-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.up-drop.is-over { border-style: solid; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.up-drop .ico-lg { color: var(--text-secondary); }
.up-drop-main { font-weight: 700; font-size: 15px; }
.up-drop-more { display: none; font-weight: 700; }
.up-drop-hint { font-size: 13px; color: var(--text-secondary); }
.up-browse { color: var(--accent-ink); font-weight: 600; text-decoration: underline; }
.up-formats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 4px; }
.up-format { padding: 1px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-secondary); }
.up-drop.has-files { flex-direction: row; padding: 12px 16px; border-style: solid; }
.up-drop.has-files .up-drop-main, .up-drop.has-files .up-drop-hint, .up-drop.has-files .up-formats, .up-drop.has-files .ico-lg { display: none; }
.up-drop.has-files .up-drop-more { display: inline; }
.up-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.up-list:empty { display: none; }
.up-card { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); }
.up-card.is-uploading { border-color: var(--accent); }
.up-card.is-done { border-color: var(--success); }
.up-card.is-failed { border-color: var(--danger); border-left-width: 4px; }
.up-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--surface-0); color: var(--text-secondary); }
.is-done .up-icon { background: var(--success-soft); color: var(--success); }
.is-failed .up-icon { background: var(--danger-soft); color: var(--danger); }
.up-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.up-name { font-weight: 600; overflow-wrap: anywhere; }
.up-meta { font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.up-status { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--text-primary); }
.up-bar { width: 100%; height: 6px; appearance: none; border: 0; border-radius: 9999px; overflow: hidden; background: var(--border); }
.up-bar::-webkit-progress-bar { background: var(--border); }
.up-bar::-webkit-progress-value { background: var(--accent); transition: width 0.2s ease-out; }
.up-bar::-moz-progress-bar { background: var(--accent); }
.up-actions { display: flex; align-items: center; gap: 4px; }
.up-next { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.up-next-label { font-size: 12px; color: var(--text-secondary); }
.up-foot { align-items: center; }
.up-summary { flex: 1; margin: 0; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }

.doc-detail { display: flex; flex-direction: column; gap: 24px; max-width: 960px; }
.doc-detail .card-body { gap: 16px; }
.short-grow { flex: 1; min-width: 200px; width: auto; }
.doc-state-line { display: flex; align-items: center; gap: 8px; margin: 0; }
.doc-actions { align-items: center; }
.thumbs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.thumb { display: flex; flex-direction: column; gap: 6px; align-items: center; min-width: 0; }
.thumb a { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; line-height: 0; }
.thumb img { display: block; width: 100%; height: auto; max-width: 240px; }
.thumb-n { font-size: 12px; color: var(--text-secondary); }

/* p4a: package and signer status chips, signer progress */
.chip-sent, .chip-in_progress, .chip-completing, .chip-notified, .chip-viewed { background: var(--accent-soft); border-color: var(--accent); } .chip-sent .chip-dot, .chip-in_progress .chip-dot, .chip-completing .chip-dot, .chip-notified .chip-dot, .chip-viewed .chip-dot { background: var(--accent); }
.chip-completed, .chip-signed { background: var(--success-soft); border-color: var(--success); } .chip-completed .chip-dot, .chip-signed .chip-dot { background: var(--success); }
.chip-declined { background: var(--danger-soft); border-color: var(--danger); } .chip-declined .chip-dot { background: var(--danger); }
.chip-expired { background: var(--attention-soft); border-color: var(--attention); } .chip-expired .chip-dot { background: var(--attention); }
.chip-voided, .chip-revoked, .chip-waiting { background: color-mix(in srgb, var(--border) 35%, transparent); } 
.pkg-progress { appearance: none; -webkit-appearance: none; width: 120px; height: 8px; border: 0; border-radius: 9999px; background: var(--border); overflow: hidden; vertical-align: middle; }
.pkg-progress::-webkit-progress-bar { background: var(--border); }
.pkg-progress::-webkit-progress-value { background: var(--success); }
.pkg-progress::-moz-progress-bar { background: var(--success); }
.pkg-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pkg-row { align-items: center; }
.pkg-signers { display: flex; flex-direction: column; gap: 10px; }
.pkg-signer { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.pkg-signer:last-child { border-bottom: 0; }
.pkg-signer-name { font-weight: 600; }
.pkg-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pkg-timeline li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; font-size: 15px; }
.pkg-timeline time { color: var(--text-secondary); font-size: 13px; }
.send-rows { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.send-row { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px; align-items: center; }
.send-role { font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.send-dot { width: 10px; height: 10px; border-radius: 9999px; background: var(--border); }
.send-row-1 .send-dot { background: var(--signer-1); } .send-row-2 .send-dot { background: var(--signer-2); } .send-row-3 .send-dot { background: var(--signer-3); } .send-row-4 .send-dot { background: var(--signer-4); }
.send-row-5 .send-dot { background: var(--signer-5); } .send-row-6 .send-dot { background: var(--signer-6); } .send-row-7 .send-dot { background: var(--signer-7); } .send-row-8 .send-dot { background: var(--signer-8); }
@media (max-width: 640px) { .send-row { grid-template-columns: 1fr; } .pkg-timeline li { grid-template-columns: 1fr; gap: 0; } }

/* p3d: Documents library — folder tree groups, subfolders, share dialog, status-chip counts */
.side-name { min-width: 0; }
.side-group { margin: 16px 0 4px; padding: 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); }
.side-sub { margin-left: 20px; }
.side-badge { padding: 0 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.ws-main-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-count { font-size: 13px; }
.chip-count { margin-left: 4px; font-size: 12px; font-weight: 600; opacity: .8; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; align-items: center; }
.share-name { font-weight: 600; }
.side-name { flex: 1 1 auto; overflow-wrap: break-word; }
.side-link { overflow-wrap: normal; }
.dtable td[data-label="Folder"], .dtable td[data-label="Updated"], .dtable td[data-label="Status"] { white-space: nowrap; }
.side-shared { display: inline-flex; color: var(--text-secondary); } .side-shared .ico { width: 14px; height: 14px; }

/* ops "Open as owner" banner (p2c): spans the whole shell, always visible */
.imp-banner { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 8px 16px; background: var(--attention-ink); color: var(--accent-contrast); font-weight: 600; }
.imp-banner .btn { color: var(--text-primary); }
.imp-banner .inline-form { margin: 0; }
/* a muted chip for read-only access (p3d loose end) */
.chip-view-only { color: var(--text-secondary); font-weight: 500; }

/* ===== p6b: the original shell (topbar, ribbon, workzone, status bar). Ported from ghs-ui-reference shared.css. ===== */
body.app-body { margin: 0; height: 100vh; overflow: hidden; }
.app-shell { display: flex; flex-direction: column; height: 100vh; width: 100%; overflow: hidden; }
.app-shell > .imp-banner { flex: none; }
.topbar { flex: none; height: var(--topbar-h); box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 16px; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text-primary); text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--accent), var(--signer-4)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; }
.topbar-search { position: relative; flex: 1 1 auto; max-width: 420px; margin: 0 auto; }
.topbar-search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.topbar-search .field { padding: 5px 12px 5px 34px; min-height: 30px; background: var(--surface-0); border-radius: 999px; }
.icon-btn.theme-toggle { width: 32px; height: 32px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; cursor: pointer; list-style: none; }
.avatar::-webkit-details-marker { display: none; }
.user-menu { position: relative; }
.user-menu .menu-list { right: 0; left: auto; min-width: 220px; }
.user-who { display: flex; flex-direction: column; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.user-list .inline-form { display: block; } .user-list .menu-item { width: 100%; text-decoration: none; color: var(--text-primary); }
.panel-toggle { display: none; }

.ribbon { flex: none; height: var(--ribbon-h); box-sizing: border-box; background: var(--surface-1); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.ribbon-tabs { display: flex; align-items: flex-end; gap: 2px; padding: 2px 12px 0; flex: none; }
.ribbon-tab { border: 1px solid transparent; border-bottom: 0; background: transparent; padding: 5px 14px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-radius: var(--radius-sm) var(--radius-sm) 0 0; cursor: pointer; }
.ribbon-tab:hover { color: var(--text-primary); }
.ribbon-tab.active { color: var(--accent-ink); background: var(--surface-0); border-color: var(--border); }
.ribbon-tab.contextual { color: #fff; background: var(--signer-6); margin-left: 8px; }
.ribbon-tab.contextual.active { background: var(--signer-6); border-color: var(--signer-6); }
:root[data-theme="dark"] .ribbon-tab.contextual { color: #0B0D12; }
.ribbon-spacer { flex: 1; }
.ribbon-collapse { border: 0; background: transparent; color: var(--text-secondary); width: 28px; height: 26px; border-radius: var(--radius-sm); cursor: pointer; }
.ribbon-collapse:hover { background: var(--surface-0); }
.ribbon-body { display: flex; align-items: stretch; flex: 1 1 auto; min-height: 0; padding: 2px 12px 0; background: var(--surface-0); border-top: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
.ribbon-panels { flex: 1 1 auto; display: flex; min-width: 0; }
.ribbon-panel { display: flex; align-items: stretch; }
.ribbon-panel[hidden] { display: none; }
.ribbon-group { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 14px; border-right: 1px solid var(--border); }
.ribbon-group-controls { display: flex; align-items: center; gap: 2px; flex: 1; }
.ribbon-group-caption { font-size: 11px; color: var(--text-secondary); line-height: 1.2; }
.ribbon-util { border-right: 0; border-left: 1px solid var(--border); margin-left: auto; flex: none; }
.rbtn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 2px 8px; min-width: 52px; min-height: 38px; box-sizing: border-box; color: var(--text-primary); font: inherit; font-size: 11px; font-weight: 500; cursor: pointer; text-decoration: none; list-style: none; }
.rbtn::-webkit-details-marker { display: none; }
.rbtn .ic { width: 16px; height: 16px; }
.rbtn:hover:not(:disabled) { background: var(--surface-1); border-color: var(--border); }
.rbtn:disabled { opacity: .45; cursor: not-allowed; }
.rbtn.is-on { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.rbtn.primary { background: var(--accent); color: var(--accent-contrast); }
.rbtn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.rbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.rbtn-icon { min-width: 36px; } .rbtn-zoom { min-width: 48px; font-size: 12px; font-weight: 600; }
.ribbon-sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--border); }
.ribbon-note { margin: 0; max-width: 360px; white-space: normal; font-size: 12px; color: var(--text-secondary); align-self: center; }
.ribbon .phase-wrap { flex-direction: column; }
.help-menu { position: relative; } .help-menu .menu-list { right: 0; left: auto; top: 100%; min-width: 280px; padding: 12px; white-space: normal; z-index: 60; }
.help-title { margin: 0 0 6px; font-weight: 700; } .help-foot { margin: 8px 0 0; font-size: 12px; color: var(--text-secondary); }
.help-keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 12px; } .help-keys dt { font-family: var(--font-mono); } .help-keys dd { margin: 0; color: var(--text-secondary); }
body.ribbon-collapsed .ribbon { height: 34px; } body.ribbon-collapsed .ribbon-body { display: none; }
body.ribbon-collapsed .ribbon-collapse .ico { transform: rotate(180deg); }

.workzone { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 280px minmax(0, 1fr) auto; overflow: hidden; }
.panel-left, .panel-right { background: var(--surface-1); overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.panel-left { width: 280px; border-right: 1px solid var(--border); }
.panel-right { width: 320px; border-left: 1px solid var(--border); }
.panel-right:empty { display: none; }
.panel-view { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.panel-view.panel-swap, .panel-swap > .panel-view { animation: panelIn .18s ease both; }
@keyframes panelIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
.panel-switcher { display: flex; gap: 4px; padding: 8px 10px 4px; }
.panel-switcher button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-0); color: var(--text-secondary); font: inherit; font-size: 12px; font-weight: 700; padding: 6px 4px; border-radius: var(--radius-sm); cursor: pointer; }
.panel-switcher button.active { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.panel-switcher button:disabled { opacity: .5; cursor: not-allowed; }
.panel-header { padding: 8px 14px; display: flex; flex-direction: column; gap: 2px; }
.panel-crumb { font-size: 12px; color: var(--text-secondary); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.panel-crumb:hover { color: var(--accent-ink); text-decoration: underline; }
.panel-title { font-size: 13px; font-weight: 700; }
.panel-body { padding: 4px 8px 16px; flex: 1 1 auto; overflow-y: auto; }
.canvas-area { background: var(--surface-0); overflow: auto; position: relative; min-width: 0; min-height: 0; outline: none; padding: 0; }
.canvas-area > .page { padding: 24px 32px 48px; }
.nav-section { margin: 12px 6px 4px; font-size: 11px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; }
h2.nav-section { font-size: 11px; } h2.nav-section:focus { outline: none; }
.nav-item { min-height: 36px; font-weight: 500; font-size: 13px; }
.nav-item .ic { color: var(--text-secondary); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); } .nav-item.active .ic { color: var(--accent-ink); }
.nav-actions { padding: 8px 6px; } .nav-actions .btn { width: 100%; }
.panel-left .side-item.is-active { background: var(--accent-soft); box-shadow: none; }
.panel-left .side-link { min-height: 34px; font-size: 13px; }
.statusbar { flex: none; height: 28px; box-sizing: border-box; background: var(--surface-1); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; font-size: 12px; color: var(--text-secondary); gap: 16px; }
.statusbar .seg { display: flex; align-items: center; gap: 16px; min-width: 0; }
.st-doc { display: inline-flex; align-items: center; gap: 6px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .save-state { min-width: 0; }
.drop-zone { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 16px; padding: 20px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-secondary); cursor: pointer; }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); outline: none; }
.ico-lg { width: 24px; height: 24px; }
.hint { font-size: 12px; color: var(--text-secondary); margin: 8px 10px; }
.canvas-area > #lib { padding: 24px 32px 48px; }
.canvas-area > #lib .ws-main-head { margin-bottom: 12px; }

@media (max-width: 860px) {
  body.app-body { height: auto; overflow: auto; } .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .topbar { padding: 0 8px; gap: 8px; } .topbar-search { max-width: none; } .brand { font-size: 0; gap: 0; } .brand-mark { font-size: 12px; }
  .panel-toggle { display: inline-flex; }
  .workzone { display: flex; flex-direction: column; overflow: visible; }
  .panel-left { display: none; width: auto; border-right: 0; border-bottom: 1px solid var(--border); max-height: 60vh; }
  body.panel-open .panel-left { display: flex; }
  .panel-right { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  .canvas-area { overflow: visible; } .canvas-area > .page, .canvas-area > #lib { padding: 16px; }
  .ed, .ed-main { height: 70vh; }
  .statusbar { height: auto; min-height: 28px; flex-wrap: wrap; padding: 4px 12px; }
  .ribbon-collapse { display: none; }
}
.ribbon-panels { flex: 1 0 auto; } .ribbon-panel, .ribbon-group { flex: none; }
.ribbon-util { margin-left: auto; padding-left: 14px; }
.drop-zone { width: 100%; box-sizing: border-box; background: transparent; font: inherit; }

/* ===== p4c: package assembly workspace (ported from pages/package-assembly.html + shared.css; module: packages/assembly) ===== */
.sig-1 { --sc: var(--signer-1); --sc-soft: var(--signer-1-soft); } .sig-2 { --sc: var(--signer-2); --sc-soft: var(--signer-2-soft); }
.sig-3 { --sc: var(--signer-3); --sc-soft: var(--signer-3-soft); } .sig-4 { --sc: var(--signer-4); --sc-soft: var(--signer-4-soft); }
.sig-5 { --sc: var(--signer-5); --sc-soft: var(--signer-5-soft); } .sig-6 { --sc: var(--signer-6); --sc-soft: var(--signer-6-soft); }
.sig-7 { --sc: var(--signer-7); --sc-soft: var(--signer-7-soft); } .sig-8 { --sc: var(--signer-8); --sc-soft: var(--signer-8-soft); }
.asm-side { overflow-y: auto; }
.sidebar-form-section { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.sidebar-form-section:last-child { border-bottom: 0; }
.sidebar-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); margin-bottom: 8px; }
.asm-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.signer-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 9px 10px; margin-bottom: 8px; background: var(--surface-1); }
.signer-card[data-kind="cc"] { background: var(--surface-0); }
.signer-card-top { display: flex; align-items: center; gap: 8px; }
.signer-card .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--sc); }
.signer-card-name, .signer-card-email { min-width: 0; border: 1px solid transparent; background: transparent; color: var(--text-primary); font: inherit; border-radius: var(--radius-sm); padding: 2px 4px; margin: 0 -4px; }
.signer-card-name { flex: 1; font-size: 13px; font-weight: 700; }
.signer-card-email { display: block; width: calc(100% + 8px); font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.signer-card-name:hover, .signer-card-email:hover { border-color: var(--border); }
.signer-card-name:focus, .signer-card-email:focus { outline: 2px solid var(--accent); outline-offset: 0; background: var(--surface-1); }
.order-pill { flex: none; font-size: 11px; font-weight: 700; background: var(--surface-2-shade); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; color: var(--text-secondary); white-space: nowrap; }
.signer-card-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.signer-card-foot .field-sm { flex: 1; width: auto; }
.role-tag { font-size: 11px; color: var(--text-secondary); }
.asm-add-signer > summary { list-style: none; width: 100%; justify-content: center; cursor: pointer; }
.asm-add-signer > summary::-webkit-details-marker { display: none; }
.asm-add-form { display: grid; gap: 6px; margin-top: 8px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); }
.asm-add-form .field-sm { width: 100%; }
.asm-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.asm-switch-label { font-size: 13px; font-weight: 600; }
.asm-switch-input:checked + .switch { background: var(--accent); }
.asm-switch-input:checked + .switch::after { left: 16px; }
.asm-switch-input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.row-flex { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.assembly-main { display: flex; flex-direction: column; min-height: 100%; }
.breadcrumb-strip { font-size: 12px; color: var(--text-secondary); padding: 10px 22px 0; }
.breadcrumb-strip a { text-decoration: none; color: var(--text-secondary); } .breadcrumb-strip a:hover { color: var(--accent-ink); text-decoration: underline; }
.breadcrumb-strip b { color: var(--text-primary); }
.asm-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; padding: 6px 22px 12px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.asm-head h1 { font-size: 20px; min-width: 0; overflow-wrap: anywhere; } .asm-head h1:focus { outline: none; }
.asm-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asm-actions .form-error { flex-basis: 100%; order: 9; }
.asm-actions .btn.is-blocked { opacity: .7; }
.asm-config-toggle { display: none; }
.assembly-scroll { flex: 1 1 auto; padding: 18px 22px; max-width: 960px; width: 100%; box-sizing: border-box; }
.assembly-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 14px; }
.assembly-toolbar h2 { font-size: 16px; } .assembly-toolbar .count { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin-left: 6px; }
.asm-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.asm-layout { width: 120px; }
.asm-layout button { min-height: 28px; }
label.btn { cursor: pointer; }
.asm-cards { display: flex; flex-direction: column; }
.asm-docs[data-layout="grid"] .asm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.pkg-doc-card { display: grid; grid-template-columns: 24px 24px 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); margin-bottom: 8px; transition: box-shadow .15s ease, border-color .15s ease; }
.asm-docs[data-layout="grid"] .pkg-doc-card { margin-bottom: 0; grid-template-columns: 24px 52px minmax(0, 1fr); } .asm-docs[data-layout="grid"] .pkg-doc-card .order-badge { display: none; } .asm-docs[data-layout="grid"] .pkg-doc-actions { grid-column: 2 / -1; }
.pkg-doc-card:hover { box-shadow: var(--shadow-sm); }
.pkg-doc-card.is-dragging { opacity: .45; } .pkg-doc-card.drop-before { box-shadow: 0 -3px 0 var(--accent); } .pkg-doc-card.drop-after { box-shadow: 0 3px 0 var(--accent); }
.drag-handle { border: 0; background: transparent; color: var(--text-secondary); cursor: grab; display: flex; align-items: center; justify-content: center; padding: 4px 0; border-radius: var(--radius-sm); }
.drag-handle:hover { color: var(--text-primary); } .drag-handle:active { cursor: grabbing; }
.order-badge { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.doc-thumb { width: 52px; height: 68px; border-radius: 4px; background: var(--surface-2-shade); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); position: relative; overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.doc-thumb .pagecount { position: absolute; bottom: 2px; right: 3px; font-size: 10px; font-weight: 700; color: var(--text-primary); background: var(--surface-1); padding: 0 4px; border-radius: 3px; border: 1px solid var(--border); }
.pkg-doc-main { min-width: 0; }
.pkg-doc-name { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.pkg-doc-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
.pkg-doc-signers { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.signer-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 2px 10px 2px 6px; border-radius: 999px; background: var(--sc-soft); color: var(--text-primary); border: 1px solid transparent; }
.signer-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sc); }
.signer-chip.none { background: var(--surface-2-shade); color: var(--text-secondary); border-color: var(--border); padding-left: 10px; }
.pkg-doc-note { display: flex; gap: 6px; align-items: flex-start; margin: 8px 0 0; font-size: 12px; color: var(--danger-ink); }
.pkg-doc-actions { display: flex; gap: 6px; }
.pkg-doc-actions > a, .pkg-doc-actions > button { width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-1); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); text-decoration: none; padding: 0; }
.pkg-doc-actions > a:hover, .pkg-doc-actions > button:hover { background: var(--surface-2-shade); color: var(--text-primary); }
.pkg-doc-actions > .edit-fields { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.pkg-doc-actions > button:disabled { opacity: .5; cursor: not-allowed; }
.chip-attention .ico, .chip-success .ico, .chip-danger .ico, .chip-neutral .ico { flex: none; }
.add-doc-zone { display: flex; align-items: center; justify-content: center; gap: 6px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); padding: 16px; text-align: center; font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; margin-top: 8px; }
.add-doc-zone:hover, .add-doc-zone:focus-visible, .add-doc-zone.is-over { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); outline: none; }
.asm-uploads { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; color: var(--text-secondary); }
.asm-uploads li { display: flex; gap: 8px; align-items: center; padding: 4px 0; } .asm-uploads .err { color: var(--danger-ink); }
.asm-empty { color: var(--text-secondary); padding: 24px 8px; text-align: center; }
.flow-strip { display: flex; align-items: flex-start; padding: 16px 20px; overflow-x: auto; background: var(--surface-1); border-top: 1px solid var(--border); position: sticky; bottom: 0; margin-top: auto; }
.flow-step { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 144px; max-width: 144px; position: relative; flex: none; }
.flow-step:not(:last-of-type)::after { content: ""; position: absolute; top: 15px; left: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.flow-icon { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-1); border: 2px solid var(--sc, var(--accent)); color: var(--sc, var(--accent-ink)); display: flex; align-items: center; justify-content: center; z-index: 1; }
.flow-notify .flow-icon { border-color: var(--attention); color: var(--attention-ink); }
.flow-complete .flow-icon { border-color: var(--success); color: var(--success-ink); background: var(--success-soft); }
.flow-send .flow-icon { border-color: var(--accent); }
.flow-label { font-size: 12px; font-weight: 700; text-align: center; max-width: 136px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-sub { font-size: 11px; color: var(--text-secondary); text-align: center; max-width: 136px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-cc, .flow-empty { font-size: 12px; color: var(--text-secondary); align-self: center; margin: 0 0 0 16px; }
.flow-empty { margin: 0 16px 0 0; }
.asm-lib { width: min(560px, 94vw); }
.asm-lib-filters { display: flex; gap: 8px; } .asm-lib-filters .field-sm { flex: 1; }
.asm-lib-results { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow-y: auto; }
.asm-lib-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-1); cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; box-sizing: border-box; }
.asm-lib-row:hover { background: var(--accent-soft); } .asm-lib-row.is-taken { opacity: .6; cursor: default; }
.asm-lib-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; } .asm-lib-meta { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.asm-problems, .asm-confirm { margin: 0; padding-left: 20px; } .asm-problems { list-style: none; padding: 0; display: grid; gap: 6px; } .asm-problems li { display: flex; gap: 6px; align-items: flex-start; color: var(--danger-ink); }
.st-back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-ink); font-weight: 700; text-decoration: none; } .st-back:hover { text-decoration: underline; }
@media (max-width: 860px) {
  .panel-left[data-view="assembly"] { width: auto; max-height: none; }
  .asm-config-toggle { display: inline-flex; }
  .asm-head, .breadcrumb-strip, .assembly-scroll { padding-left: 16px; padding-right: 16px; }
  .pkg-doc-card { grid-template-columns: 24px 52px minmax(0, 1fr); } .pkg-doc-card .order-badge { display: none; } .pkg-doc-actions { grid-column: 2 / -1; }
  .flow-strip { position: static; }
}
@media (prefers-reduced-motion: reduce) { .pkg-doc-card { transition: none; } }
label.btn:focus-within, .add-doc-zone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- p9a: billing panel (settings module) ---- */
.usage-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.usage-label { min-width: 220px; color: var(--text-secondary); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--border-strong); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.plan-card.is-current { border-width: 2px; }
.plan-actions { display: flex; flex-direction: column; gap: 6px; }
.plan-name { font-weight: 600; }
.plan-list { margin: 0; padding-left: 18px; }
.plan-strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
