/* ============================================================================
   Sutton Studio harness v1 — library.css: the extended component kit
   (library.js) and the compound-view layouts (views.js). Linked after
   components.css. Tokens only, so light and dark both work.
   ============================================================================ */

/* ---- Shared bits --------------------------------------------------------------- */
.emoji { font-size: 15px; line-height: 1; display: inline-flex; }
.ui-input-row { display: flex; align-items: center; gap: var(--space-2); }
.ui-input-row > .input { flex: 1; min-width: 0; }
.ui-iconpick-trigger {
  flex: none; width: var(--control-height); height: var(--control-height); display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); cursor: pointer; color: var(--color-muted);
}
.ui-iconpick-trigger:hover { background: var(--color-hover); color: var(--color-text); }
.ui-iconpick-trigger .emoji { font-size: 17px; }
.ui-iconpick { width: 262px; padding: var(--space-2); }
.ui-iconpick-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.ui-iconpick-head .seg-btn { height: 24px; padding: 0 10px; font-size: var(--fs-sm); }
.ui-iconpick-grid { display: grid; grid-template-columns: repeat(8, 28px); gap: 2px; justify-content: space-between; }
.ui-iconpick-cell { width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--color-text); padding: 0; }
.ui-iconpick-cell:hover { background: var(--cream-100); }
.ui-iconpick-cell--on { background: var(--cream-200); }
.ui-iconpick-cell .emoji { font-size: 15px; }
.ui-iconpick-cell .icon { width: 15px; height: 15px; }
.ui-iconpick-cell .glyph-img { width: 18px; height: 18px; }
.ui-iconpick-search { width: 100%; height: 30px; margin-bottom: var(--space-2); font-size: var(--fs-sm); }
.ui-iconpick-grid--scroll { max-height: 196px; overflow-y: auto; align-content: start; }
.ui-iconpick-empty { grid-column: 1 / -1; padding: var(--space-4) 0; text-align: center; font-size: var(--fs-sm); color: var(--color-muted); }
.ui-iconpick-drop { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1.5px dashed var(--color-border); border-radius: var(--radius-input); background: var(--cream-25); cursor: pointer; font-size: var(--fs-sm); }
.ui-iconpick-drop:hover, .ui-iconpick-drop.is-over { border-color: var(--cream-500); background: var(--cream-50); }
.ui-iconpick-drop > span:not(.ui-iconpick-drop-ico) { display: flex; flex-direction: column; gap: 2px; }
.ui-iconpick-drop-ico { width: 36px; height: 36px; flex: none; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--color-bg); border: 1px solid var(--color-border); color: var(--color-label); }
.ui-iconpick-drop-ico .icon { width: 16px; height: 16px; }
.glyph-img.ui-iconpick-preview { width: 36px; height: 36px; border-radius: 8px; }
.ui-iconpick-link { display: flex; gap: 6px; margin-top: var(--space-2); }
.ui-iconpick-link .input { margin: 0; }
.ui-iconpick-hint { font-size: var(--fs-xs); color: var(--color-muted); margin-top: 4px; }
.glyph-img { display: block; flex: none; object-fit: cover; border-radius: 4px; }
.st-layout-btn .icon:first-child { color: var(--color-label); }

/* ---- Calendar grid (popover + inline + range) -------------------------------------- */
.ui-cal-day--range { background: var(--tone-range); border-radius: 0; }
.ui-range { display: flex; width: auto; gap: var(--space-2); }
.ui-range-presets { display: flex; flex-direction: column; min-width: 130px; padding-right: var(--space-2); border-right: 1px solid var(--color-border-faint); }
.ui-range .ui-calgrid { width: 248px; }
.calendar-card { display: inline-block; padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-bg); box-shadow: var(--shadow-sm); }
.calendar-card .ui-calgrid { width: 252px; }

/* ---- Card ------------------------------------------------------------------------------ */
.card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); overflow: hidden; }
.card--interactive { cursor: pointer; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.card--interactive:hover { box-shadow: var(--shadow-md); border-color: var(--cream-300); transform: translateY(-1px); }
.card-head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-4) 0; }
.card-titles { flex: 1; min-width: 0; }
.card-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.card-desc { font-size: var(--fs-sm); color: var(--color-label); margin-top: 2px; }
.card-actions { display: flex; gap: var(--space-2); }
.card-body { padding: var(--space-4); }
.card-body--flush { padding: 0; }
.card-head + .card-body--flush { margin-top: var(--space-3); }
.card-body--flush .table th:first-child, .card-body--flush .table td:first-child { padding-left: var(--space-4); }
.card-body--flush .table th:last-child, .card-body--flush .table td:last-child { padding-right: var(--space-4); }
.card-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-border-faint); background: var(--cream-25); }

/* ---- Accordion ------------------------------------------------------------------------- */
.accordion { border-top: 1px solid var(--color-border); }
.accordion-item { border-bottom: 1px solid var(--color-border); }
.accordion-head { width: 100%; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) 0; border: 0; background: none; cursor: pointer; font: inherit; font-weight: var(--fw-medium); color: var(--color-text); text-align: left; }
.accordion-head:hover .accordion-title { text-decoration: underline; text-underline-offset: 3px; }
.accordion-title { flex: 1; }
.accordion-chev { color: var(--color-muted); transition: transform .18s ease; }
.accordion-item.is-open .accordion-chev { transform: rotate(180deg); }
.accordion-body { display: none; padding: 0 0 var(--space-4); color: var(--color-label); }
.accordion-item.is-open .accordion-body { display: block; }

/* ---- Separator, breadcrumb, kbd, badges --------------------------------------------------- */
.separator { height: 1px; background: var(--color-border); margin: var(--space-3) 0; }
.separator--v { display: inline-block; width: 1px; height: 16px; margin: 0 var(--space-2); vertical-align: middle; }
.separator--label { display: flex; align-items: center; gap: var(--space-3); height: auto; background: none; color: var(--color-muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; }
.separator--label::before, .separator--label::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--color-label); flex-wrap: wrap; }
.breadcrumb-sep { width: 13px; height: 13px; color: var(--color-muted); }
.breadcrumb-item { padding: 2px 4px; border-radius: 4px; }
.breadcrumb-link { border: 0; background: none; font: inherit; color: var(--color-label); cursor: pointer; }
.breadcrumb-link:hover { background: var(--color-hover); color: var(--color-text); }
.breadcrumb-item.is-current { color: var(--color-text); font-weight: var(--fw-medium); }
.kbd-group { display: inline-flex; gap: 3px; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  font-family: var(--font-sans); font-size: var(--fs-2xs); font-weight: var(--fw-medium); color: var(--color-label);
  background: var(--color-bg); border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: 5px;
}
.bdg {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap; background: var(--color-surface-alt); color: var(--color-text);
}
.bdg .icon { width: 12px; height: 12px; }
.bdg-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bdg--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--color-border); }
.bdg--gradient { background: var(--grad-primary); color: var(--color-on-accent); }
.bdg--success { background: var(--pill-green-bg); color: var(--pill-green-text); }
.bdg--warn { background: var(--pill-amber-bg); color: var(--pill-amber-text); }
.bdg--danger { background: var(--pill-red-bg); color: var(--pill-red-text); }
.bdg--info { background: var(--pill-blue-bg); color: var(--pill-blue-text); }

/* ---- Callout --------------------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-bg); }
.alert-icon { margin-top: 1px; }
.alert-main { flex: 1; min-width: 0; }
.alert-title { font-weight: var(--fw-semibold); }
.alert-body { color: var(--color-label); font-size: var(--fs-sm); margin-top: 2px; }
.alert--info .alert-icon { color: var(--color-accent); }
.alert--success { background: var(--pill-green-bg); border-color: var(--color-success-border); } .alert--success .alert-icon { color: var(--pill-green-text); }
.alert--warn { background: var(--pill-amber-bg); border-color: var(--color-warn-border); } .alert--warn .alert-icon { color: var(--pill-amber-text); }
.alert--danger { background: var(--pill-red-bg); border-color: var(--color-danger-border); } .alert--danger .alert-icon { color: var(--pill-red-text); }

/* ---- Skeleton, code ---------------------------------------------------------------------- */
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--color-surface-alt) 25%, var(--cream-200) 50%, var(--color-surface-alt) 75%); background-size: 200% 100%; animation: skel 1.4s ease-in-out infinite; }
.skeleton--circle { border-radius: 50%; }
.skeleton-lines { display: flex; flex-direction: column; gap: 8px; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.codeblock { position: relative; border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--cream-50); overflow: hidden; }
.codeblock-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px var(--space-3); border-bottom: 1px solid var(--color-border-faint); font-size: var(--fs-xs); color: var(--color-label); }
.codeblock > .icon-ghost { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; }
.codeblock pre { margin: 0; padding: var(--space-3); overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; color: var(--color-text); }

/* ---- Stat card, sparkline, ring ---------------------------------------------------------- */
.stat { padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-bg); box-shadow: var(--shadow-sm); min-width: 200px; }
.stat-head { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: var(--fs-sm); color: var(--color-label); }
.stat-icon { color: var(--color-muted); }
.stat-value { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: -0.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-xs); }
.stat-foot .sparkline { margin-left: auto; }
.stat-delta { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: var(--radius-pill); font-weight: var(--fw-semibold); }
.stat-delta .icon { width: 11px; height: 11px; stroke-width: 2.5; }
.stat-delta--up { background: var(--pill-green-bg); color: var(--pill-green-text); }
.stat-delta--down { background: var(--pill-red-bg); color: var(--pill-red-text); }
.stat-delta--flat { background: var(--color-surface-alt); color: var(--color-label); }
.stat-hint { color: var(--color-label); }
.sparkline-line { fill: none; stroke: var(--tone-line); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.sparkline-fill { fill: var(--tone-fill); stroke: none; }
.ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring svg { position: absolute; inset: 0; }
.ring-track { fill: none; stroke: var(--color-surface-alt); }
.ring-fill { fill: none; stroke: var(--btn-primary-bg); stroke-linecap: round; transition: stroke-dashoffset .3s ease; }
.ring-label { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

/* ---- Stepper (neutral: done = filled check, current = ringed number, upcoming = muted) --- */
.stepper { display: flex; align-items: center; gap: var(--space-3); margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.stepper-step { flex: 0 1 auto; display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.stepper-step + .stepper-step::before { content: ''; flex: 0 0 32px; height: 1px; background: var(--color-border); margin-right: var(--space-1); }
.stepper-step.is-done + .stepper-step::before { background: var(--color-text); }
.stepper-dot {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); background: var(--color-bg); color: var(--color-muted); box-shadow: inset 0 0 0 1px var(--color-border);
}
.stepper-dot .icon { width: 12px; height: 12px; stroke-width: 2.75; }
.stepper-step.is-done .stepper-dot { background: var(--color-text); color: var(--color-bg); box-shadow: none; }
.stepper-step.is-current .stepper-dot { color: var(--color-text); box-shadow: inset 0 0 0 1.5px var(--color-text), 0 0 0 3px var(--cream-200); }
.stepper-text { display: flex; flex-direction: column; min-width: 0; }
.stepper-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--color-label); white-space: nowrap; }
.stepper-step.is-current .stepper-label { color: var(--color-text); font-weight: var(--fw-semibold); }
.stepper-step.is-done .stepper-label { color: var(--color-text); }
.stepper-detail { font-size: var(--fs-xs); color: var(--color-muted); }
.feed { margin: 0; padding: 0; list-style: none; }
.feed-item { position: relative; display: flex; gap: var(--space-3); padding-bottom: var(--space-4); }
.feed-item:not(:last-child)::before { content: ''; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 1px; background: var(--color-border); }
.feed-marker { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--cream-100); color: var(--color-label); }
.feed-marker .icon { width: 12px; height: 12px; }
.feed-text { font-size: var(--fs-sm); }
.feed-time { font-size: var(--fs-xs); color: var(--color-muted); margin-top: 1px; }
.avatar-group { display: inline-flex; align-items: center; }
.avatar-group .avatar { box-shadow: 0 0 0 2px var(--color-bg); }
.avatar-group .avatar + .avatar { margin-left: -6px; }
.avatar--more { background: var(--color-surface-alt); color: var(--color-label); font-size: 9px; }

/* ---- Radio, choice cards, slider, steppers ---------------------------------------------------- */
.radio-group { display: flex; flex-direction: column; gap: var(--space-2); }
.radio { display: flex; align-items: flex-start; gap: var(--space-2); border: 0; background: none; padding: 2px 0; cursor: pointer; font: inherit; color: var(--color-text); text-align: left; }
.radio-dot { flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--color-border); background: var(--color-bg); transition: box-shadow .12s ease; }
.radio.is-on .radio-dot { box-shadow: inset 0 0 0 5px var(--btn-primary-bg); }
.radio-text { display: flex; flex-direction: column; }
.radio-desc { font-size: var(--fs-sm); color: var(--color-label); }
.radio-group--cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.radio-group--cards .radio { padding: var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-bg); align-items: center; gap: var(--space-3); }
.radio-group--cards .radio:hover { border-color: var(--cream-400); }
.radio-group--cards .radio.is-on { border-color: var(--btn-primary-bg); box-shadow: 0 0 0 1px var(--btn-primary-bg), var(--shadow-sm); background: var(--cream-25); }
.radio-icon { flex: none; width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--cream-100); }
.radio-group--cards .radio-text { flex: 1; }
.radio-dot--end { margin-top: 0; }
.slider-row { display: flex; align-items: center; gap: var(--space-3); }
.slider { -webkit-appearance: none; appearance: none; flex: 1; height: 6px; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--btn-primary-bg) var(--pct, 0%), var(--color-surface-alt) var(--pct, 0%)); outline: none; }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--color-bg); box-shadow: 0 0 0 1px var(--color-border), var(--shadow-md); cursor: pointer; }
.slider::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--color-bg); box-shadow: 0 0 0 1px var(--color-border), var(--shadow-md); cursor: pointer; }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--color-accent), var(--focus-ring); }
.slider-value { min-width: 36px; text-align: right; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--color-label); }
.num-stepper { align-self: flex-start; display: inline-flex; align-items: center; height: var(--control-height); border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); overflow: hidden; }
.num-stepper:focus-within { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.num-stepper-btn { width: 30px; height: 100%; border: 0; background: none; cursor: pointer; color: var(--color-label); display: inline-flex; align-items: center; justify-content: center; }
.num-stepper-btn:hover { background: var(--color-hover); color: var(--color-text); }
.num-stepper-btn .icon { width: 14px; height: 14px; }
.num-stepper-input { width: 56px; height: 100%; border: 0; border-left: 1px solid var(--color-border-faint); border-right: 1px solid var(--color-border-faint); text-align: center; font: inherit; color: var(--color-text); background: none; outline: none; }

/* ---- Tag input, input group, toggle, dropzone ------------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: var(--control-height); padding: 4px 6px; border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); cursor: text; }
.tags:focus-within { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.tags-input { flex: 1; min-width: 80px; border: 0; outline: none; background: none; font: inherit; color: var(--color-text); padding: 2px 4px; }
.tag { display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 2px 0 8px; border-radius: 6px; background: var(--color-surface-alt); font-size: var(--fs-sm); }
.tag-x { border: 0; background: none; padding: 2px; display: inline-flex; border-radius: 4px; cursor: pointer; color: inherit; opacity: .6; }
.tag-x:hover { opacity: 1; background: var(--color-border-faint); }
.tag-x .icon { width: 11px; height: 11px; }
.tags .pill { padding-right: 2px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); overflow: hidden; }
.input-group:focus-within { border-color: var(--color-accent); box-shadow: var(--focus-ring); }
.input-group > .input { border: 0; box-shadow: none !important; flex: 1; min-width: 0; border-radius: 0; }
.input-addon { display: inline-flex; align-items: center; padding: 0 var(--space-3); background: var(--cream-50); color: var(--color-label); font-size: var(--fs-sm); }
.input-addon:first-child { border-right: 1px solid var(--color-border-faint); }
.input-addon:last-child { border-left: 1px solid var(--color-border-faint); }
.toggle { height: var(--btn-height); display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-input); background: transparent; color: var(--color-label); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; }
.toggle:hover { background: var(--color-hover); color: var(--color-text); }
.toggle.is-on { background: var(--color-surface-alt); color: var(--color-text); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: var(--space-6); border: 1.5px dashed var(--cream-400); border-radius: var(--radius-card); background: var(--cream-25); color: var(--color-label); cursor: pointer; text-align: center; transition: background .15s ease, border-color .15s ease; }
.dropzone:hover, .dropzone.is-over { background: var(--cream-100); border-color: var(--btn-primary-bg); }
.dropzone-icon { width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--color-bg); box-shadow: var(--shadow-sm); color: var(--color-text); }
.dropzone-label { font-weight: var(--fw-medium); color: var(--color-text); }
.dropzone-hint { font-size: var(--fs-xs); }

/* ---- Tooltip, popover, command palette ---------------------------------------------------------- */
.tip { position: fixed; z-index: 10000; max-width: 260px; padding: 5px 8px; border-radius: 6px; background: #1c1917; color: #fafaf9; font-size: var(--fs-xs); line-height: 1.35; pointer-events: none; opacity: 0; transform: translateY(2px); transition: opacity .12s ease, transform .12s ease; box-shadow: var(--shadow-md); }
:root[data-theme="dark"] .tip { background: #f5f5f4; color: #1c1917; }
.tip--in { opacity: 1; transform: none; }
.ui-popover { padding: var(--space-3); }
.cmd-backdrop { position: fixed; inset: 0; z-index: 400; background: var(--color-scrim-soft); display: flex; justify-content: center; align-items: flex-start; padding-top: 14vh; }
.cmd { width: 600px; max-width: calc(100vw - 32px); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; animation: toast-in .16s ease; }
.cmd-search { display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); height: 50px; border-bottom: 1px solid var(--color-border); }
.cmd-search > .icon { color: var(--color-muted); }
.cmd-input { flex: 1; border: 0; outline: none; background: none; font: inherit; font-size: var(--fs-md); color: var(--color-text); }
.cmd-list { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmd-group { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); padding: 8px 8px 4px; }
.cmd-item { width: 100%; display: flex; align-items: center; gap: var(--space-2); padding: 8px; border: 0; border-radius: 8px; background: none; cursor: pointer; font: inherit; color: var(--color-text); text-align: left; }
.cmd-item > .icon { color: var(--color-label); }
.cmd-item.is-active { background: var(--color-surface-alt); }
.cmd-label { flex: 1; }
.cmd-hint { font-size: var(--fs-xs); color: var(--color-muted); }
.cmd-empty { padding: var(--space-6); text-align: center; color: var(--color-muted); }

/* ---- Pagination, sidebar ------------------------------------------------------------------------ */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn { height: 30px; min-width: 30px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 0; border-radius: var(--radius-input); background: none; color: var(--color-text); font: inherit; font-size: var(--fs-sm); cursor: pointer; }
.page-btn:hover:not(:disabled) { background: var(--color-hover); }
.page-btn:disabled { color: var(--color-muted); cursor: default; }
.page-btn .icon { width: 14px; height: 14px; }
.page-num.is-current { background: var(--color-bg); box-shadow: inset 0 0 0 1px var(--color-border), var(--shadow-sm); font-weight: var(--fw-semibold); }
.page-gap { color: var(--color-muted); padding: 0 4px; }
.sidebar { width: 240px; flex: none; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); background: var(--cream-50); border-right: 1px solid var(--color-border); min-height: 100%; }
.sidebar-title { font-weight: var(--fw-semibold); padding: 6px 8px; }
.sidebar-list { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar-section { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); padding: 12px 8px 4px; }
.sidebar-item { display: flex; align-items: center; gap: var(--space-2); height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--color-label); font: inherit; font-size: var(--fs-base); cursor: pointer; text-align: left; }
.sidebar-item:hover { background: var(--cream-100); color: var(--color-text); }
.sidebar-item.is-active { background: var(--color-bg); color: var(--color-text); font-weight: var(--fw-medium); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--color-border-faint); }
.sidebar-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-count { font-size: var(--fs-xs); color: var(--color-muted); }
.sidebar-foot { border-top: 1px solid var(--color-border); padding-top: var(--space-2); }

/* ============================================================================
   Compound-view layouts (views.js)
   ============================================================================ */
.st-layout { position: relative; }

/* Board */
.bv { display: flex; gap: var(--space-3); overflow-x: auto; align-items: flex-start; padding-bottom: var(--space-3); }
.bv-col { flex: 0 0 280px; display: flex; flex-direction: column; max-height: 100%; border-radius: var(--radius-card); background: var(--cream-50); border: 1px solid var(--color-border-faint); transition: background .12s ease, box-shadow .12s ease; }
.bv-col--over { background: var(--cream-100); box-shadow: inset 0 0 0 2px var(--color-accent); }
.bv-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-3) var(--space-2); }
.bv-none { font-weight: var(--fw-medium); color: var(--color-label); }
.bv-count { color: var(--color-muted); font-size: var(--fs-sm); font-weight: var(--fw-regular); }
.bv-list { display: flex; flex-direction: column; gap: var(--space-2); padding: 0 var(--space-2) var(--space-2); overflow-y: auto; min-height: 40px; }
.bv-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-input); padding: var(--space-3); box-shadow: var(--shadow-sm); cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: box-shadow .12s ease, border-color .12s ease; }
.bv-card:hover, .bv-card.is-menu-open { box-shadow: var(--shadow-md); border-color: var(--cream-300); }
.bv-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.bv-card--drag { opacity: .45; }
.bv-title { font-weight: var(--fw-medium); }
.bv-fields { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: var(--fs-sm); color: var(--color-label); }
.bv-foot { padding-top: 2px; font-size: var(--fs-sm); }

/* Calendar */
.cv-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.cv-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.cv-undated { font-size: var(--fs-sm); color: var(--color-muted); }
.cv-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.cv-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--color-border-faint); border-left: 1px solid var(--color-border-faint); margin: 0 calc(-1 * var(--space-8)); }
.cv-dow { padding: 6px 8px; font-size: var(--fs-xs); color: var(--color-label); border-right: 1px solid var(--color-border-faint); border-bottom: 1px solid var(--color-border-faint); }
.cv-day { min-height: 112px; padding: 4px; border-right: 1px solid var(--color-border-faint); border-bottom: 1px solid var(--color-border-faint); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cv-grid--week .cv-day { min-height: 420px; }
.cv-day--weekend { background: var(--cream-25); }
.cv-day--dim .cv-num { color: var(--color-muted); }
.cv-day--over { background: var(--color-accent-soft); }
.cv-num { font-size: var(--fs-xs); color: var(--color-label); padding: 2px 4px; }
.cv-day--today .cv-num span { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--grad-primary); color: var(--color-on-accent); font-weight: var(--fw-semibold); }
.cv-chip { display: flex; align-items: center; gap: 5px; height: 24px; padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--chip) 35%, var(--color-bg)); font-size: var(--fs-xs); cursor: pointer; min-width: 0; }
.cv-chip:hover, .cv-chip.is-menu-open { background: color-mix(in srgb, var(--chip) 55%, var(--color-bg)); }
.cv-chip-dot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--chip); filter: saturate(1.4) brightness(.85); }
.cv-chip-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-medium); }
.cv-chip .avatar { width: 16px; height: 16px; font-size: 8px; }
.cv-more { border: 0; background: none; text-align: left; font: inherit; font-size: var(--fs-xs); color: var(--color-label); padding: 2px 6px; cursor: pointer; border-radius: 4px; }
.cv-more:hover { background: var(--color-hover); color: var(--color-text); }

/* Timeline */
.tv { position: relative; display: grid; grid-template-columns: 240px max-content; grid-template-rows: auto auto; overflow: auto; margin: 0 calc(-1 * var(--space-8)); border-top: 1px solid var(--color-border-faint); }
.tv-corner { position: sticky; left: 0; top: 0; z-index: 6; background: var(--color-bg); padding: 0 var(--space-3) 0 var(--space-8); display: flex; align-items: flex-end; padding-bottom: 6px; font-size: var(--fs-xs); color: var(--color-label); border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border-faint); }
.tv-head { position: sticky; top: 0; z-index: 5; background: var(--color-bg); border-bottom: 1px solid var(--color-border-faint); }
.tv-tier { position: relative; height: 26px; }
.tv-tier--units { height: 22px; }
.tv-cell { position: absolute; top: 0; height: 100%; display: flex; align-items: center; font-size: var(--fs-xs); color: var(--color-label); border-left: 1px solid var(--color-border-faint); padding-left: 4px; overflow: hidden; white-space: nowrap; }
.tv-tier:not(.tv-tier--units) .tv-cell { font-weight: var(--fw-semibold); color: var(--color-text); }
.tv-cell-label { position: sticky; left: 248px; }
.tv-cell--weekend { background: var(--cream-25); }
.tv-names { position: sticky; left: 0; z-index: 4; background: var(--color-bg); border-right: 1px solid var(--color-border); }
.tv-name { height: 36px; display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3) 0 var(--space-8); border-bottom: 1px solid var(--color-border-faint); cursor: pointer; min-width: 0; }
.tv-name:hover, .tv-name.is-menu-open { background: var(--color-hover); }
.tv-name-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-name--group, .tv-row--group { background: var(--table-group-bg); font-weight: var(--fw-semibold); cursor: default; }
.tv-canvas { position: relative; }
.tv-grid { position: absolute; inset: 0; pointer-events: none; }
.tv-line { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--color-border-faint); }
.tv-line--month { background: var(--color-border); }
.tv-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--color-accent); z-index: 0; }
.tv-today::before { content: ''; position: absolute; top: -1px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-accent); }
.tv-body { position: relative; z-index: 1; }
.tv-row { position: relative; height: 36px; border-bottom: 1px solid var(--color-border-faint); }
.tv-bar {
  position: absolute; top: 6px; height: 24px; border-radius: 7px; display: flex; align-items: center;
  background: color-mix(in srgb, var(--bar) 70%, var(--color-bg)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bar) 80%, var(--color-text) 8%), var(--shadow-sm);
  color: var(--opt-ink); font-size: var(--fs-xs); font-weight: var(--fw-medium); cursor: pointer; overflow: hidden; user-select: none;
}
.tv-bar:hover, .tv-bar.is-menu-open { background: var(--bar); }
.tv-bar--edit { cursor: grab; }
.tv-bar-label { flex: 1; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-grip { flex: none; width: 7px; height: 100%; cursor: ew-resize; }
.tv-grip:hover { background: color-mix(in srgb, var(--color-text) 12%, transparent); }
body.tv-dragging, body.tv-dragging * { cursor: grabbing !important; user-select: none; }
.tv-nodate { position: absolute; left: 8px; top: 9px; font-size: var(--fs-xs); color: var(--color-muted); }

/* Gallery */
.gv { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.gv--small { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.gv--large { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.gv-card { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-card); overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm); transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.gv-card:hover, .gv-card.is-menu-open { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--cream-300); }
.gv-card:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.gv-cover { height: 64px; background: linear-gradient(135deg, var(--cover), color-mix(in srgb, var(--cover) 45%, var(--color-bg))); }
.gv--large .gv-cover { height: 110px; }
.gv-body { padding: var(--space-3) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.gv-title { font-weight: var(--fw-semibold); font-size: var(--fs-md); }
.gv-fields { display: flex; flex-direction: column; gap: 4px; }
.gv-field { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); min-width: 0; }
.gv-label { width: 70px; flex: none; color: var(--color-muted); font-size: var(--fs-xs); }
.gv-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gv-foot { border-top: 1px solid var(--color-border-faint); padding-top: var(--space-2); font-size: var(--fs-sm); }

/* List */
.lv { margin: 0 calc(-1 * var(--space-8)); border-top: 1px solid var(--color-border-faint); }
.lv-group { width: 100%; display: flex; align-items: center; gap: var(--space-2); height: 38px; padding: 0 var(--space-8); border: 0; border-bottom: 1px solid var(--color-border-faint); background: var(--table-group-bg); font: inherit; font-weight: var(--fw-semibold); color: var(--color-text); cursor: pointer; text-align: left; }
.lv-group > .icon { width: 14px; height: 14px; color: var(--color-muted); }
.lv-row { display: flex; align-items: center; gap: var(--space-3); height: 40px; padding: 0 var(--space-8); border-bottom: 1px solid var(--color-border-faint); cursor: pointer; }
.lv-row:hover, .lv-row.is-menu-open { background: var(--color-hover); }
.lv-row:focus-visible { outline: none; background: var(--color-hover); box-shadow: inset 2px 0 0 var(--color-accent); }
.lv-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; }
.lv-title { flex: 1; min-width: 0; font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lv-meta { display: flex; align-items: center; gap: var(--space-3); color: var(--color-label); font-size: var(--fs-sm); }
.lv-noone { width: 20px; }

/* ---- View editor dropdown (create / edit a saved view, table.js) ------------------------- */
.ui-viewedit { width: 312px; max-height: none; padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); }
.ui-viewedit-name { display: flex; align-items: center; gap: var(--space-2); }
.ui-viewedit-name .ui-iconpick-trigger { width: 32px; height: 32px; }
.ui-viewedit-name .input { flex: 1; min-width: 0; height: 32px; }
.ui-viewedit-picker { border: 1px solid var(--color-border-faint); border-radius: var(--radius-input); padding: var(--space-2); background: var(--cream-25); }
.ui-viewedit-hint { font-size: var(--fs-xs); color: var(--color-muted); margin-top: 6px; }
.ui-viewedit-label { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); margin-bottom: 6px; }
.ui-viewedit-layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ui-viewedit-layout {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 52px;
  border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); cursor: pointer;
  font: inherit; font-size: var(--fs-xs); color: var(--color-label);
}
.ui-viewedit-layout .icon { width: 16px; height: 16px; }
.ui-viewedit-layout:hover { background: var(--cream-50); color: var(--color-text); }
.ui-viewedit-layout.is-on { background: var(--cream-100); border-color: var(--cream-500); color: var(--color-text); font-weight: var(--fw-medium); }
.ui-viewedit .seg { width: 100%; }
.ui-viewedit-tones { display: flex; gap: 6px; margin-top: 8px; }
.ui-viewedit-tone { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 28px; border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg); cursor: pointer; }
.ui-viewedit-tone:hover { background: var(--cream-50); }
.ui-viewedit-tone.is-on { border-color: var(--cream-500); background: var(--cream-100); box-shadow: inset 0 0 0 1px var(--cream-500); }
.ui-viewedit .seg-btn { flex: 1; justify-content: center; white-space: nowrap; padding: 0 6px; }
.ui-viewedit-foot { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-3); margin: 0 calc(-1 * var(--space-3)); padding-left: var(--space-3); padding-right: var(--space-3); border-top: 1px solid var(--color-border-faint); }
.ui-viewedit-foot .spacer { flex: 1; }
.ui-viewedit-foot .btn--ghost-danger { background: none; border: 0; box-shadow: none; color: var(--color-danger-text); padding: 0 6px; }
.ui-viewedit-foot .btn--ghost-danger:hover { background: var(--pill-red-bg); }

/* ============================================================================
   Detail page (detail.js) — the Sutton record layout: breadcrumb bar, a
   document card on the cream canvas, and a collapsible right sidebar.
   ============================================================================ */
.content--flush { padding: 0; }
.detail { min-height: 100vh; display: flex; align-items: stretch; background: var(--color-canvas); }
.detail-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.detail-bar {
  position: sticky; top: 0; z-index: 20; height: 48px; flex: none; display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-4) 0 var(--space-5); background: var(--color-bg); border-bottom: 1px solid var(--color-border);
}
/* On the document page the bar sits on the canvas: same color, no rule. */
.detail-col > .detail-bar { background: var(--color-canvas); border-bottom: 0; }
.detail-bar .icon-ghost { width: 30px; height: 30px; }
.detail-bar-spacer { flex: 1; }
.detail-bar-actions { display: flex; align-items: center; gap: var(--space-2); }
/* "Open in" switcher (openRecord): side panel, center, full page */
.rec-mode { display: inline-flex; align-items: center; gap: 1px; padding: 2px; border-radius: var(--radius-input); background: var(--cream-100); }
.rec-mode-btn { width: 26px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: none; color: var(--color-label); cursor: pointer; padding: 0; }
.rec-mode-btn .icon { width: 14px; height: 14px; }
.rec-mode-btn:hover { color: var(--color-text); }
.rec-mode-btn.is-on { background: var(--color-bg); color: var(--color-text); box-shadow: var(--shadow-sm); }
.peek-head-actions .rec-mode { margin-right: var(--space-1); }
.detail-show { display: none !important; }
.detail--side-closed .detail-show { display: inline-flex !important; }
.detail-main { flex: 1; min-width: 0; padding: var(--space-2) var(--space-6) var(--space-6); }

/* The document card */
.doc-card {
  max-width: 1120px; margin: 0 auto; background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: 12px; box-shadow: var(--shadow-sm); padding: var(--space-6) var(--space-8) var(--space-2);
}
.doc-head { padding-bottom: var(--space-5); }
.doc-title { margin: 0; font-size: 22px; line-height: 1.3; font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.doc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-3); }
.doc-meta .ui-select { width: 150px; }
.doc-meta .ui-select-trigger { height: 30px; }
/* Sections: each starts with a hairline that runs to the card's edges. */
.doc-sec, .doc-card > .doc-grid {
  margin: 0 calc(-1 * var(--space-8)); padding: var(--space-5) var(--space-8); border-top: 1px solid var(--color-border-faint);
}
.doc-grid { display: grid; gap: var(--space-4) var(--space-8); }
.doc-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.doc-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.doc-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.doc-grid > .doc-sec { margin: 0; padding: 0; border-top: 0; }
.doc-sec .doc-grid { margin: 0; padding: 0; border-top: 0; }
@media (max-width: 900px) { .doc-grid--2, .doc-grid--3, .doc-grid--4 { grid-template-columns: 1fr; } }
.doc-sec-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); min-height: 28px; }
.doc-sec-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.doc-sec-caption { font-size: var(--fs-xs); color: var(--color-muted); }
.doc-sec-spacer { flex: 1; }
.doc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.doc-label { font-size: var(--fs-sm); color: var(--color-label); font-weight: var(--fw-medium); }
.doc-label .req { color: var(--color-danger-text); }
.doc-field > .ui-select, .doc-field > .input, .doc-sec > .ui-select { width: 100%; }
.doc-sec > .ui-select { display: block; }
/* A section that ends in a line-items grid: the grid's last row meets the next divider. */
.doc-sec:has(> .lines) { padding-bottom: 0; }
.lines-add td { border-bottom: 0; }
.address { margin-top: var(--space-2); font-size: var(--fs-sm); color: var(--color-label); line-height: 1.5; }
.doc-switch { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--color-label); }
.status-menu { border: 0; cursor: pointer; font-family: inherit; height: 24px; padding: 0 4px 0 8px; }
.status-menu .icon { width: 12px; height: 12px; opacity: .7; }
.status-menu:hover { filter: brightness(.97); }

/* Line items (full bleed to the card edges) */
.lines-scroll { margin: 0 calc(-1 * var(--space-8)); overflow-x: auto; }
.lines-table { table-layout: fixed; }
.lines-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lines-itemcell { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.lines-itemcell .lines-item { flex: 1; min-width: 0; }
.lines-table th:first-child, .lines-table td:first-child { padding-left: var(--space-8); }
.lines-table th:last-child, .lines-table td:last-child { padding-right: var(--space-4); }
.lines-table thead th { position: static; }
.lines-table td { height: 44px; }
.lines-item { width: 100%; }
.lines-item .ui-select-trigger { border-color: transparent; background: transparent; padding-left: 6px; margin-left: -6px; font-weight: var(--fw-medium); }
.lines-item .ui-select-trigger:hover { border-color: var(--color-border); background: var(--color-bg); }
.lines-item .ui-select-caret { opacity: 0; transition: opacity .12s ease; }
.lines-table tr:hover .lines-item .ui-select-caret, .lines-item .ui-select-trigger[aria-expanded="true"] .ui-select-caret { opacity: 1; }
.lines-uom { flex: none; font-size: var(--fs-xs); color: var(--color-muted); }
.lines-input {
  width: 100%; height: 30px; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 0 6px;
  font: inherit; color: var(--color-text); font-variant-numeric: tabular-nums; outline: none;
}
.lines-input.num { text-align: right; }
.lines-input:hover { border-color: var(--color-border); }
.lines-input:focus { border-color: var(--color-accent); box-shadow: var(--focus-ring); background: var(--color-bg); }
.lines-money { display: flex; align-items: center; gap: 2px; }
.lines-cur { color: var(--color-muted); font-size: var(--fs-sm); }
.lines-total { font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.lines-x-col { width: 68px; }
.lines-x { white-space: nowrap; }
.lines-x .icon-ghost { width: 26px; height: 26px; opacity: 0; }
.lines-table tr:hover .lines-x .icon-ghost, .lines-table tr.is-menu-open .lines-x .icon-ghost { opacity: 1; }
.lines-table tr.is-menu-open > td { background: var(--color-hover); }
.lines-add td { height: auto; padding-top: 6px; padding-bottom: 6px; }
.lines-add-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 8px; margin-left: -8px; border-radius: 6px; font: inherit; font-size: var(--fs-sm); color: var(--color-label); cursor: pointer; }
.lines-add-btn:hover { background: var(--cream-100); color: var(--color-text); }
.lines-add-btn .icon { width: 14px; height: 14px; }

/* Totals (payment summary) */
.totals { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--cream-25); }
.totals-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--fs-sm); }
.totals-row--input .input-group { width: 150px; }
.totals-row--input .input { height: 30px; text-align: right; }
.totals-label { color: var(--color-label); }
.totals-amount { font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.totals-sep { height: 1px; background: var(--color-border-faint); margin: 2px 0; }
.totals-row--total { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.totals-amount--total { font-weight: var(--fw-semibold); }
.split { display: inline-flex; }
.split .btn--split-caret { padding: 0 6px; }

/* The right sidebar */
.detail-side {
  width: 360px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--color-bg); border-left: 1px solid var(--color-border);
}
.detail--side-closed .detail-side { display: none; }
.detail-side-top { flex: none; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); height: 48px; padding: 0 var(--space-4); }
.detail-side-top .icon-ghost { width: 30px; height: 30px; }
.detail-side-actions { display: flex; align-items: center; gap: var(--space-1); }
.detail-side-tabs { padding: 0 var(--space-4); }
.detail-side-body { flex: 1; overflow-y: auto; padding: 0 var(--space-4) var(--space-4); }
.detail-side-body--chat { display: flex; flex-direction: column; overflow: hidden; padding-top: var(--space-3); }
@media (max-width: 1000px) {
  .detail { flex-direction: column; }
  .detail-side { width: auto; position: static; height: auto; border-left: 0; border-top: 1px solid var(--color-border); }
}

/* ============================================================================
   App shell + side nav (appNav): Sutton's left navigation, on cream.
   ============================================================================ */
.shell { display: flex; align-items: stretch; min-height: 100vh; }
.shell-main { flex: 1; min-width: 0; }
.appnav {
  position: sticky; top: 0; height: 100vh; width: 248px; flex: none; z-index: 60;
  display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-2) var(--space-3);
  background: var(--cream-50); border-right: 1px solid var(--color-border); transition: width .16s ease;
}
.appnav-head { display: flex; align-items: center; gap: 2px; padding: 2px 0 var(--space-2); }
.appnav-org, .appnav-user {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--space-2); height: 40px; padding: 0 6px;
  border: 0; border-radius: var(--radius-input); background: none; cursor: pointer; font: inherit; color: var(--color-text); text-align: left;
}
.appnav-org:hover, .appnav-user:hover { background: var(--cream-100); }
.appnav-logo { flex: none; width: 26px; height: 26px; border-radius: 7px; object-fit: cover; }
.appnav-logo--mark { display: inline-flex; align-items: center; justify-content: center; background: var(--grad-primary); color: var(--color-on-accent); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.appnav-org-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.appnav-org-name { font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appnav-org-sub { font-size: var(--fs-xs); color: var(--color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appnav-org-caret { width: 14px; height: 14px; color: var(--color-muted); flex: none; }
.appnav-toggle { flex: none; width: 30px !important; height: 30px !important; }
.appnav-search {
  display: flex; align-items: center; gap: var(--space-2); height: 32px; margin: 0 0 var(--space-2); padding: 0 8px;
  border: 1px solid var(--color-border); border-radius: var(--radius-input); background: var(--color-bg);
  font: inherit; font-size: var(--fs-sm); color: var(--color-muted); cursor: pointer; box-shadow: var(--shadow-sm);
}
.appnav-search:hover { border-color: var(--cream-400); color: var(--color-label); }
.appnav-search .icon { width: 15px; height: 15px; flex: none; }
.appnav-search .appnav-label { text-align: left; }
.appnav-keys { margin-left: auto; }
.appnav-keys .kbd { height: 18px; min-width: 18px; }
.appnav-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -2px; padding: 0 2px; }
.appnav-section { display: flex; align-items: center; gap: 2px; margin-top: var(--space-3); padding: 0 2px 2px 8px; }
.appnav-section-btn { flex: 1; display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 0; font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--color-muted); cursor: pointer; text-align: left; }
.appnav-section-btn:disabled { cursor: default; color: var(--color-muted); }
.appnav-section-btn:not(:disabled):hover { color: var(--color-text); }
.appnav-section-chev { width: 12px; height: 12px; opacity: 0; transition: opacity .12s ease, transform .15s ease; }
.appnav-section:hover .appnav-section-chev { opacity: 1; }
.appnav-section.is-closed .appnav-section-chev { transform: rotate(-90deg); opacity: 1; }
.appnav-section-action { width: 22px !important; height: 22px !important; opacity: 0; }
.appnav-section-action .icon { width: 14px; height: 14px; }
.appnav-section:hover .appnav-section-action { opacity: 1; }
.appnav-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-input);
  background: none; color: var(--color-label); font: inherit; font-size: var(--fs-base); cursor: pointer; text-align: left; flex: none;
}
.appnav-item:hover { background: var(--cream-100); color: var(--color-text); }
.appnav-item.is-active { background: var(--color-bg); color: var(--color-text); font-weight: var(--fw-medium); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--color-border-faint); }
.appnav-ico { flex: none; width: 18px; display: inline-flex; align-items: center; justify-content: center; }
.appnav-ico .icon { width: 16px; height: 16px; }
.appnav-item.is-active .appnav-ico .icon { color: var(--color-text); }
.appnav-ico .emoji { font-size: 14px; }
.appnav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appnav-count { font-size: var(--fs-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.appnav .bdg { height: 18px; padding: 0 6px; font-size: var(--fs-2xs); }
.appnav-foot { display: flex; flex-direction: column; gap: 1px; padding-top: var(--space-2); border-top: 1px solid var(--color-border); }
.appnav-user { height: 44px; margin-top: 2px; }

/* Glyphs: icon, emoji or uploaded image */
.appnav-ico .glyph-img { width: 18px; height: 18px; border-radius: 4px; }
.appnav-item.is-hidden { opacity: .45; }

/* Customize mode (appNav editable) */
.appnav--editing { width: 288px; }
.appnav-edit-head { display: flex; flex-direction: column; gap: 2px; margin: var(--space-2) 2px var(--space-2); padding: 10px 12px; border-radius: var(--radius-input); background: var(--color-bg); border: 1px solid var(--color-border); font-size: var(--fs-xs); color: var(--color-label); }
.appnav-edit-head strong { font-size: var(--fs-sm); color: var(--color-text); font-weight: var(--fw-semibold); }
.appnav-item--edit { cursor: default; gap: 4px; padding: 0 4px; }
.appnav-item--edit:hover { background: var(--cream-100); }
.appnav-item--edit.is-lifted { display: none; }
.appnav-edit-section { margin-top: var(--space-3); }
.appnav-grip { width: 18px; height: 24px; flex: none; display: inline-flex; align-items: center; justify-content: center; color: var(--color-muted); cursor: grab; touch-action: none; border-radius: 4px; }
.appnav-grip:hover { color: var(--color-text); background: var(--cream-200); }
.appnav-grip .icon { width: 14px; height: 14px; }
.appnav-ico-btn { width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; cursor: pointer; padding: 0; }
.appnav-ico-btn:hover { background: var(--color-bg); box-shadow: inset 0 0 0 1px var(--color-border); }
.appnav-edit-input { flex: 1; min-width: 0; height: 26px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: none; font: inherit; font-size: var(--fs-base); color: var(--color-text); outline: none; }
.appnav-edit-input:hover { border-color: var(--color-border); background: var(--color-bg); }
.appnav-edit-input:focus { border-color: var(--color-accent); background: var(--color-bg); box-shadow: var(--focus-ring); }
.appnav-edit-input--section { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--color-label); text-transform: none; }
.appnav-edit-btn { width: 26px !important; height: 26px !important; flex: none; opacity: .55; }
.appnav-item--edit:hover .appnav-edit-btn { opacity: 1; }
.appnav-placeholder { flex: none; border: 1.5px dashed var(--cream-400); border-radius: var(--radius-input); background: var(--cream-100); }
.appnav-edit-add { display: flex; align-items: center; gap: 6px; height: 32px; margin-top: var(--space-2); padding: 0 8px; border: 1px dashed var(--color-border); border-radius: var(--radius-input); background: none; font: inherit; font-size: var(--fs-sm); color: var(--color-label); cursor: pointer; flex: none; }
.appnav-edit-add:hover { color: var(--color-text); border-color: var(--cream-500); background: var(--cream-100); }
.appnav-edit-add .icon { width: 14px; height: 14px; }
.appnav-edit-foot { display: flex; justify-content: space-between; gap: var(--space-2); padding: 4px 2px; }

/* Rail (collapsed): icons only, labels in tooltips */
.appnav--rail { width: 56px; }
.appnav--rail .appnav-head { flex-direction: column; gap: 4px; }
.appnav--rail .appnav-org, .appnav--rail .appnav-user { flex: none; width: 40px; justify-content: center; padding: 0; }
.appnav--rail .appnav-org-text, .appnav--rail .appnav-org-caret, .appnav--rail .appnav-label, .appnav--rail .appnav-count,
.appnav--rail .appnav-keys, .appnav--rail .bdg, .appnav--rail .appnav-section-btn, .appnav--rail .appnav-section-action { display: none; }
.appnav--rail .appnav-search { width: 40px; padding: 0; justify-content: center; margin-left: auto; margin-right: auto; }
.appnav--rail .appnav-item { width: 40px; padding: 0; justify-content: center; margin: 0 auto; }
.appnav--rail .appnav-section { margin: var(--space-2) 8px 4px; padding: 0; height: 1px; background: var(--color-border); }
.appnav--rail .appnav-list { align-items: stretch; }
@media (max-width: 760px) { .appnav:not(.appnav--rail) { position: fixed; left: 0; box-shadow: var(--shadow-lg); } }

/* A title-only page header (no tab row) carries the full-bleed divider itself. */
.app-header--flat { padding-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); }
