/* cycms admin — design system */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #ffffff;
  --bg-2: #f7f7f7;
  --bg-3: #efefef;
  --elev: #ffffff;
  --text: #141414;
  --text-2: #4a4a4a;
  --muted: #8a8a8a;
  --border: #e5e5e5;
  --border-2: #d4d4d4;
  --accent: #141414;
  --accent-text: #ffffff;
  --focus: #3b82f6;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warn: #ca8a04;
  --warn-bg: #fefce8;
  --info-bg: #eff6ff;
  --radius: 4px;
  --radius-lg: 8px;
  --gap: 20px;
  --nav-w: 250px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141414; --bg-2: #1c1c1c; --bg-3: #262626; --elev: #1f1f1f;
  --text: #f0f0f0; --text-2: #c4c4c4; --muted: #8c8c8c; --border: #2e2e2e; --border-2: #3d3d3d;
  --accent: #f0f0f0; --accent-text: #141414; --danger-bg: #2a1414; --success-bg: #11261a; --warn-bg: #2a2410; --info-bg: #111c2e;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --bg-2: #1c1c1c; --bg-3: #262626; --elev: #1f1f1f;
    --text: #f0f0f0; --text-2: #c4c4c4; --muted: #8c8c8c; --border: #2e2e2e; --border-2: #3d3d3d;
    --accent: #f0f0f0; --accent-text: #141414; --danger-bg: #2a1414; --success-bg: #11261a; --warn-bg: #2a2410; --info-bg: #111c2e;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; width: var(--nav-w); flex: 0 0 var(--nav-w); background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; transition: margin .2s ease; z-index: 30; }
.app--nav-closed .nav { margin-left: calc(-1 * var(--nav-w)); }
.nav-brand { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: var(--accent-text); font-size: 12px; }
.nav-close { display: none; }
.nav-scroll { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }
.nav-group { margin-top: 14px; }
.nav-group-label { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0; padding: 4px 8px; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; font-family: inherit; }
.nav-link { display: block; padding: 5px 8px; border-radius: var(--radius); text-decoration: none; color: var(--text-2); font-size: 13.5px; }
.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link.active { background: var(--bg-3); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav-link--top { font-weight: 500; }
.nav-footer { display: flex; gap: 6px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.nav-footer form { margin: 0; }
.caret { display: inline-block; transition: transform .15s; font-size: 10px; }
.caret--closed { transform: rotate(-90deg); }
.nav-backdrop { display: none; }
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; color: var(--muted); font-size: 13px; }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs > span:last-child { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--border-2); }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-3); text-decoration: none; font-weight: 600; font-size: 12px; overflow: hidden; border: 1px solid var(--border); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.main { flex: 1; }
.page-pad { padding: 28px 40px 60px; max-width: 1600px; }
.page-pad-x { padding: 0 40px 40px; }
@media (max-width: 1024px) {
  .nav { position: fixed; left: 0; top: 0; bottom: 0; box-shadow: var(--shadow); }
  .app--nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .nav-close { display: inline-grid; }
  .page-pad { padding: 20px 16px 48px; }
  .page-pad-x { padding: 0 16px 32px; }
  .topbar { padding: 0 16px; }
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; transition: opacity .15s, background .15s; }
.btn:hover { opacity: .88; }
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn--ghost:hover, .btn--ghost.active { background: var(--bg-3); opacity: 1; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn--pill { border-radius: 999px; height: 28px; padding: 0 12px; font-size: 12.5px; background: var(--bg-3); color: var(--text); border-color: var(--border); }
.btn--block { width: 100%; }
.btn--icon { width: 34px; padding: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text-2); cursor: pointer; font-size: 14px; }
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn--danger:hover { color: var(--danger); background: var(--danger-bg); }
.chip-btn { height: 26px; padding: 0 9px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.chip-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.link-btn { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; padding: 0; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.hamburger { font-size: 16px; }

/* ---------- forms ---------- */
.field { margin-bottom: var(--gap); min-width: 0; }
.field-row { display: flex; flex-wrap: wrap; gap: var(--gap); }
.field-row > .field { flex: 1 1 200px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
.required { color: var(--danger); }
.field-description { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.field-error-msg { margin-top: 6px; font-size: 12.5px; color: var(--danger); }
.field--error .input, .field--error .rel, .field--error .rte, .field--error .tags-input { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.input { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.input:disabled, .field--readonly .input { background: var(--bg-2); color: var(--muted); }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.code { font-family: var(--mono); font-size: 12.5px; tab-size: 2; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-prefix { position: absolute; left: 10px; color: var(--muted); }
.input-prefix + .input { padding-left: 26px; }
.input--inline { height: 26px; width: 180px; font-size: 12.5px; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; user-select: none; }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-box { width: 18px; height: 18px; border: 1px solid var(--border-2); border-radius: 3px; display: inline-grid; place-items: center; background: var(--bg); transition: all .15s; }
.checkbox input:checked + .checkbox-box { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked + .checkbox-box::after { content: "✓"; color: var(--accent-text); font-size: 12px; }
.checkbox input:focus-visible + .checkbox-box { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent); }
.radio-group { display: flex; flex-wrap: wrap; gap: 16px; }
.radio-group--vertical { flex-direction: column; gap: 8px; }
.radio { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.radio input { position: absolute; opacity: 0; }
.radio-dot { width: 16px; height: 16px; border: 1px solid var(--border-2); border-radius: 50%; display: inline-grid; place-items: center; }
.radio input:checked + .radio-dot { border-color: var(--accent); }
.radio input:checked + .radio-dot::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.multi-select, .column-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-check { position: relative; cursor: pointer; }
.pill-check input { position: absolute; opacity: 0; }
.pill-check span { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border: 1px solid var(--border-2); border-radius: 999px; font-size: 12.5px; color: var(--text-2); background: var(--bg); }
.pill-check input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.pill-check input:checked + span::before { content: "✓ "; margin-right: 3px; }
.color-input { display: flex; gap: 8px; align-items: center; }
.color-input input[type=color] { width: 38px; height: 38px; border: 1px solid var(--border-2); border-radius: var(--radius); padding: 2px; background: var(--bg); }
.slug-input { display: flex; gap: 6px; align-items: center; }
.tags-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px; padding: 4px 8px; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--bg); }
.tags-entry { flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; height: 28px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 9px; border-radius: 999px; background: var(--bg-3); font-size: 12.5px; }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; }
.chip-x:hover { color: var(--danger); }
.group { border: 0; border-left: 2px solid var(--border); padding: 0 0 0 16px; margin: 0 0 var(--gap); }
.group-label { font-size: 15px; font-weight: 600; margin-bottom: 12px; padding: 0; }
.group-fields { margin-top: 12px; }
.collapsible { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); }
.collapsible-head { padding: 10px 14px; cursor: pointer; font-weight: 600; background: var(--bg-2); border-radius: var(--radius-lg); list-style: none; }
.collapsible[open] .collapsible-head { border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.collapsible-body { padding: 16px 16px 0; }
.tabs-field { margin-bottom: var(--gap); }
.tabs-nav { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; }
.tab-btn { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; font-size: 10.5px; border-radius: 3px; background: var(--bg-3); color: var(--muted); font-weight: 500; vertical-align: middle; }

/* arrays & blocks */
.array { border: 0; }
.array-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.array-head .field-label { margin: 0; font-size: 15px; font-weight: 600; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bg-3); font-size: 11px; color: var(--muted); margin-left: 6px; }
.array-head-actions { display: flex; gap: 12px; }
.array-rows { display: flex; flex-direction: column; gap: 8px; }
.array-row { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg); }
.array-row.sortable-ghost { opacity: .4; }
.array-row-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 6px; background: var(--bg-2); border-radius: var(--radius-lg); }
.array-row-body { padding: 16px 16px 0; border-top: 1px solid var(--border); }
.drag-handle { cursor: grab; color: var(--muted); padding: 2px 6px; letter-spacing: -3px; user-select: none; }
.array-row-toggle { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: none; border: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; padding: 4px; min-width: 0; }
.row-label { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-label:empty::before { content: attr(data-default); color: var(--muted); }
.array-row-actions { display: flex; gap: 2px; }
.add-row { margin-top: 10px; }
.block-chooser-wrap { position: relative; }
.block-chooser { position: absolute; z-index: 15; top: 44px; left: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; width: min(560px, 90vw); padding: 12px; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.block-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.block-card:hover { border-color: var(--text); }
.block-icon { font-size: 22px; }

/* relationship */
.rel { position: relative; }
.rel-items { display: flex; flex-direction: column; gap: 6px; }
.rel-items:not(:empty) { margin-bottom: 6px; }
.rel-items--upload { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.rel-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-2); min-width: 0; }
.rel-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 3px; background: var(--bg-3); flex: 0 0 auto; }
.rel-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-title a { text-decoration: none; }
.rel-title a:hover { text-decoration: underline; }
.rel-search { position: relative; display: flex; gap: 6px; }
.rel-dropdown { position: absolute; z-index: 15; top: 42px; left: 0; right: 0; max-height: 300px; overflow-y: auto; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.rel-option { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 12px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.rel-option:hover { background: var(--bg-3); }
.rel-option small { margin-left: auto; color: var(--muted); }
.rel-empty { padding: 12px; color: var(--muted); }
.upload-inline { flex: 0 0 auto; }

/* rich text */
.rte { border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--bg); }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--bg-2); border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 56px; z-index: 5; }
.rte-btn { min-width: 30px; height: 28px; padding: 0 6px; border: 0; border-radius: 3px; background: none; color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.rte-btn:hover { background: var(--bg-3); color: var(--text); }
.rte-content { min-height: 180px; padding: 14px 16px; outline: none; }
.rte .textarea { border: 0; border-radius: 0 0 var(--radius) var(--radius); }
.prose h2 { font-size: 1.5em; margin: 1em 0 .5em; } .prose h3 { font-size: 1.25em; margin: 1em 0 .5em; } .prose h4 { font-size: 1.1em; margin: 1em 0 .5em; }
.prose p { margin: 0 0 .8em; } .prose blockquote { margin: 0 0 .8em; padding-left: 14px; border-left: 3px solid var(--border-2); color: var(--text-2); }
.prose pre { background: var(--bg-2); padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; }
.prose img { max-width: 100%; height: auto; } .prose a { color: var(--focus); }

/* ---------- list view ---------- */
.list-header { margin-bottom: 16px; }
.list-title { display: flex; align-items: center; gap: 14px; }
.list-title h1 { font-size: 26px; }
.list-desc { color: var(--muted); margin: 6px 0 0; }
.status-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
.status-tab { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.status-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.list-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 280px; }
.search-icon { position: absolute; left: 12px; top: 8px; color: var(--muted); font-size: 16px; }
.search .input { padding-left: 34px; }
.list-panel { flex: 1 1 100%; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); }
.where-row { display: grid; grid-template-columns: 1fr 1fr 2fr 28px; gap: 8px; margin-bottom: 8px; align-items: center; }
.where-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-2); }
.col-check { width: 36px; }
.row-link { font-weight: 500; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.sort-link { text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.sort-ind { opacity: .5; font-size: 11px; }
.sort-link.asc .sort-ind, .sort-link.desc .sort-ind { opacity: 1; }
.cell-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; vertical-align: middle; background: var(--bg-3); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 12px; flex-wrap: wrap; }
.pagination-pages, .per-page { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.page-btn { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: var(--radius); border: 1px solid var(--border); text-decoration: none; color: var(--text-2); font-size: 12.5px; }
.page-btn:hover { background: var(--bg-3); }
.page-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.page-info { padding: 0 6px; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--border-2); border-radius: var(--radius-lg); }
.empty-state h1 { font-size: 48px; color: var(--text); }

/* pills */
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--bg-3); color: var(--text-2); white-space: nowrap; }
.pill--green, .pill--published, .pill--active, .pill--completed, .pill--captured, .pill--authorized, .pill--fulfilled, .pill--shipped, .pill--delivered, .pill--received, .pill--success { background: var(--success-bg); color: var(--success); }
.pill--yellow, .pill--draft, .pill--pending, .pill--requires_action, .pill--awaiting, .pill--not_paid, .pill--not_fulfilled, .pill--partially_fulfilled, .pill--partially_shipped, .pill--requested, .pill--open, .pill--proposed { background: var(--warn-bg); color: var(--warn); }
.pill--red, .pill--canceled, .pill--rejected, .pill--failed, .pill--inactive, .pill--refunded, .pill--archived, .pill--error { background: var(--danger-bg); color: var(--danger); }

/* ---------- document view ---------- */
.doc { min-height: calc(100vh - 56px); display: flex; flex-direction: column; }
.doc-header { padding: 24px 40px 0; }
.doc-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.doc-title { font-size: 28px; line-height: 1.2; word-break: break-word; }
.doc-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
.doc-tab { padding: 9px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 13.5px; }
.doc-tab:hover { color: var(--text); }
.doc-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.doc-controls { position: sticky; top: 56px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 40px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-meta { display: flex; gap: 18px; font-size: 12.5px; flex-wrap: wrap; }
.meta-item .muted { margin-right: 4px; }
.doc-buttons { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.locale-switch { display: flex; gap: 4px; }
.doc-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.doc-main { padding: 28px 40px 60px; min-width: 0; }
.doc-sidebar { padding: 28px 28px 60px; border-left: 1px solid var(--border); background: var(--bg); min-width: 0; }
.doc-body--live { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.doc-body--live .doc-sidebar { display: none; }
.live-preview { position: sticky; top: 113px; height: calc(100vh - 113px); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.live-preview-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.live-preview iframe { flex: 1; border: 0; width: 100%; background: #fff; }
.sidebar-meta { margin-top: 24px; font-size: 12.5px; }
.id-code { word-break: break-all; }
.sidebar-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 16px; background: var(--bg); }
.sidebar-card h3 { font-size: 13px; margin-bottom: 10px; }
.tab-content { padding: 24px 40px 60px; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: 40px; z-index: 20; min-width: 190px; padding: 6px; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.dropdown-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.dropdown-item:hover { background: var(--bg-3); }
.dropdown-item.danger { color: var(--danger); }
.json-view { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; overflow: auto; max-height: 75vh; margin-top: 20px; }
.diff { margin-top: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.diff-head, .diff-row { display: grid; grid-template-columns: 180px 1fr 1fr; }
.diff-head { background: var(--bg-2); font-weight: 500; font-size: 12.5px; color: var(--muted); }
.diff-head span, .diff-row > * { padding: 8px 12px; border-bottom: 1px solid var(--border); margin: 0; white-space: pre-wrap; word-break: break-word; }
.diff-row--changed .diff-old { background: var(--danger-bg); }
.diff-row--changed .diff-new { background: var(--success-bg); }
.diff-field { font-weight: 500; }
@media (max-width: 1100px) {
  .doc-body { grid-template-columns: 1fr; }
  .doc-sidebar { border-left: 0; border-top: 1px solid var(--border); }
  .doc-header, .doc-controls, .doc-main, .doc-sidebar, .tab-content { padding-left: 16px; padding-right: 16px; }
  .diff-head, .diff-row { grid-template-columns: 1fr; }
}

/* ---------- dashboard ---------- */
.dash-title { font-size: 28px; margin-bottom: 24px; }
.dash-group { margin-bottom: 28px; }
.dash-group-title { font-size: 15px; margin-bottom: 12px; color: var(--text-2); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; background: var(--bg); }
.card--link { display: flex; justify-content: space-between; align-items: center; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.card--link:hover { border-color: var(--text); box-shadow: var(--shadow); }
.card-title { font-weight: 500; }
.card-plus { color: var(--muted); }
.widgets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; margin-bottom: 32px; }
.widget { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; background: var(--bg); min-width: 0; }
.widget--full { grid-column: span 6; } .widget--half { grid-column: span 3; } .widget--third { grid-column: span 2; }
@media (max-width: 900px) { .widget--half, .widget--third { grid-column: span 6; } }
.stat-label { color: var(--muted); font-size: 12.5px; }
.stat-value { font-size: 28px; font-weight: 600; margin-top: 4px; letter-spacing: -0.02em; }
.stat-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.widget h3 { font-size: 14px; margin-bottom: 12px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.mini-table tr:last-child td { border-bottom: 0; }
.mini-table td:last-child { text-align: right; }

/* ---------- misc ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: var(--radius-lg); background: var(--elev); border: 1px solid var(--border); box-shadow: var(--shadow); min-width: 240px; max-width: 420px; font-size: 13.5px; }
.toast--success { border-left: 3px solid var(--success); }
.toast--error { border-left: 3px solid var(--danger); }
.banner { padding: 10px 14px; border-radius: var(--radius); margin: 12px 40px; font-size: 13.5px; }
.banner--error { background: var(--danger-bg); color: var(--danger); }
.banner--success { background: var(--success-bg); color: var(--success); }
.banner--info { background: var(--info-bg); }
.banner--warn { background: var(--warn-bg); color: var(--warn); }
body.bare { background: var(--bg-2); }
.bare-wrap { max-width: 400px; margin: 0 auto; padding: 10vh 16px 40px; }
.bare-wrap .banner { margin: 0 0 16px; }
.bare-brand { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 20px; margin-bottom: 28px; }
.auth-card { padding: 32px; box-shadow: var(--shadow); }
.auth-title { font-size: 22px; margin-bottom: 24px; }
.auth-link { display: block; margin-top: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.bare-lang { justify-content: center; display: flex; gap: 6px; margin-top: 20px; }
.lang-switch { display: flex; gap: 4px; }
.section { margin-bottom: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; }
.section-head h2 { font-size: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.totals { width: 100%; max-width: 360px; margin-left: auto; font-size: 13.5px; }
.totals td { padding: 4px 0; } .totals td:last-child { text-align: right; }
.totals tr.total td { font-weight: 600; border-top: 1px solid var(--border); padding-top: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 20px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-2); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 88vh; overflow-y: auto; background: var(--elev); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; background: var(--bg-2); }
.media-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.media-tile span { display: block; padding: 6px 8px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-zone { border: 2px dashed var(--border-2); border-radius: var(--radius-lg); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; }
.upload-zone.dragover { border-color: var(--focus); background: var(--info-bg); }
.upload-preview { display: flex; gap: 16px; align-items: flex-start; margin-bottom: var(--gap); }
.upload-preview img { width: 160px; height: 160px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.focal { position: relative; display: inline-block; cursor: crosshair; }
.focal-dot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5); background: var(--focus); pointer-events: none; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0 0 0 22px; padding: 0; }
.tree-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); margin: 4px 0; background: var(--bg); }
.variant-matrix td .input { height: 32px; min-width: 90px; }

/* ---------- Extended CMS features ---------- */
.modal--wide { width: min(880px, 100%); }
.modal-head h3 { font-size: 16px; }
.plain-list { list-style: none; margin: 6px 0 0; padding: 0; }
.plain-list li { margin: 2px 0; }
.input--sm { height: 30px; font-size: 13px; }
.btn--danger-text { color: var(--danger); }
.status-tab--end { margin-left: auto; }

/* document form states (locking, trash) */
.doc-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; flex: 1; display: flex; flex-direction: column; }
.doc-fieldset > .doc-body { flex: 1; }
.doc--readonly .doc-main, .doc-fieldset[disabled] .doc-main { opacity: .85; }
.lock-modal { z-index: 70; }
.lock-ind { font-size: 12px; cursor: help; }
.row--locked td { background: var(--warn-bg); }

/* rich text editor */
.rte-toolbar { align-items: center; }
.rte-toolbar--off { opacity: .4; pointer-events: none; }
.rte-select { height: 28px; border: 1px solid var(--border-2); border-radius: 3px; background: var(--bg); color: var(--text); font: inherit; font-size: 12.5px; padding: 0 6px; }
.rte-sep { width: 1px; height: 18px; background: var(--border-2); margin: 0 4px; }
.rte-btn.active { background: var(--bg-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }
.rte-btn--wide { padding: 0 10px; }
.rte-table-tools { display: inline-flex; gap: 2px; padding-left: 4px; border-left: 1px dashed var(--border-2); }
.rte-table-tools[hidden] { display: none; }
.rte-insert { position: relative; }
.rte-menu { position: absolute; z-index: 25; top: 32px; left: 0; min-width: 220px; padding: 6px; background: var(--elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.rte-menu[hidden] { display: none; }
.rte-menu-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.rte-menu-item:hover { background: var(--bg-3); }
.rte-source { font-size: 12px; }
.rte-content { line-height: 1.6; }
.rte-content:focus { outline: none; }
.rte-block { position: relative; margin: 10px 0; padding: 10px 12px; border: 1px solid var(--border-2); border-left: 3px solid var(--focus); border-radius: var(--radius-lg); background: var(--bg-2); user-select: none; cursor: default; }
.rte-block.rte-sel { box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 40%, transparent); }
.rte-block-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rte-block-icon { font-size: 16px; }
.rte-block-sum { flex: 1; min-width: 0; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rte-block-actions { display: inline-flex; gap: 2px; }
.rte-block-thumb { display: block; max-height: 90px; max-width: 160px; margin-top: 8px; border-radius: 3px; }
.rte--readonly .rte-content { background: var(--bg-2); }
.prose h1 { font-size: 1.8em; margin: 1em 0 .5em; } .prose h5 { font-size: 1em; margin: 1em 0 .5em; } .prose h6 { font-size: .9em; margin: 1em 0 .5em; text-transform: uppercase; letter-spacing: .04em; }
.prose code { background: var(--bg-3); padding: 1px 4px; border-radius: 3px; font-size: .92em; }
.prose pre code { background: none; padding: 0; }
.prose hr { margin: 1.2em 0; }
.prose ul, .prose ol { padding-left: 1.6em; margin: 0 0 .8em; }
.prose table { border-collapse: collapse; margin: 0 0 1em; width: 100%; }
.prose th, .prose td { border: 1px solid var(--border-2); padding: 6px 8px; min-width: 40px; vertical-align: top; }
.prose th { background: var(--bg-2); font-weight: 600; text-align: left; }
.prose ul.rt-checklist { list-style: none; padding-left: .4em; }
.prose ul.rt-checklist > li { position: relative; padding-left: 26px; }
.prose ul.rt-checklist > li::before { content: ""; position: absolute; left: 0; top: .25em; width: 15px; height: 15px; border: 1px solid var(--border-2); border-radius: 3px; background: var(--bg); cursor: pointer; }
.prose ul.rt-checklist > li[data-checked="true"]::before { content: "\2713"; background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-size: 11px; line-height: 15px; text-align: center; }
.prose ul.rt-checklist > li[data-checked="true"] { color: var(--muted); text-decoration: line-through; }
.prose img[data-cms-media] { outline: 1px dashed transparent; }
.prose img[data-cms-media]:hover { outline-color: var(--focus); }
.prose a[data-cms-link] { text-decoration-style: dotted; }

/* media browser & document picker */
.media-browser .modal-body { min-height: 360px; }
.mb-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.mb-bar .btn { flex: 0 0 auto; height: 38px; }
.is-busy { opacity: .5; pointer-events: none; }
.media-grid .media-tile { display: block; padding: 0; border: 1px solid var(--border); cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.media-tile--picked { box-shadow: 0 0 0 2px var(--focus); }
.media-tile-file { aspect-ratio: 1; display: grid; place-items: center; font-size: 36px; }
.doc-results { max-height: 260px; overflow-y: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.doc-results .rel-option.active { background: var(--info-bg); }
.modal .tabs-nav { margin-bottom: 14px; }

/* folders */
.folder-bar { margin-bottom: 14px; }
.folder-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 13px; }
.folder-crumbs a { text-decoration: none; padding: 2px 6px; border-radius: var(--radius); }
.folder-crumbs a:hover { background: var(--bg-3); }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-bottom: 8px; }
.folder-grid[hidden], .folder-crumbs[hidden] { display: none; }
.folder-tile { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 42px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); color: var(--text); text-decoration: none; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.folder-tile a { flex: 1; min-width: 0; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-tile:hover { border-color: var(--text); }
.folder-tile--new { border-style: dashed; color: var(--muted); background: var(--bg); justify-content: center; }
.folder-tile--up { color: var(--muted); }
.folder-actions { display: none; }
.folder-tile:hover .folder-actions { display: inline-flex; }
.drop-over { border-color: var(--focus) !important; background: var(--info-bg) !important; }
tr[draggable="true"] { cursor: grab; }

/* bulk upload & edit many */
.bulk-folder { margin-top: 12px; }
.bulk-files { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.bulk-file { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.bulk-file--done { border-color: var(--success); }
.bulk-file--error { border-color: var(--danger); }
.bulk-file-thumb { flex: 0 0 56px; height: 56px; display: grid; place-items: center; background: var(--bg-3); border-radius: 3px; overflow: hidden; font-size: 24px; }
.bulk-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.bulk-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.bulk-file-name { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-file-msg { font-size: 12px; color: var(--muted); }
.bulk-file--error .bulk-file-msg { color: var(--danger); }
.progress { height: 4px; border-radius: 2px; background: var(--bg-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--focus); transition: width .2s; }
.bulk-file--done .progress span { background: var(--success); }
.bulk-fields { margin-bottom: 16px; }
.bulk-field { border: 0; margin: 0; padding: 0; min-width: 0; }
.modal-result:not(:empty) { margin-top: 10px; }
.modal-result .banner { margin: 0; }
.modal-foot .muted { margin-right: auto; font-size: 12.5px; }
.column-chip { display: inline-flex; align-items: center; }
.col-grip { cursor: grab; color: var(--muted); padding: 0 2px; letter-spacing: -3px; font-size: 11px; user-select: none; }
.pill-check span.col-grip { border: 0; background: none; height: auto; padding: 0 3px 0 0; color: var(--muted); }

/* role-based read-only pages */
.rbac-readonly .doc-buttons > .btn, .rbac-readonly .doc-buttons .dropdown, .rbac-readonly .list-title .btn--pill,
.rbac-readonly .bulk-bar, .rbac-readonly .col-check, .rbac-readonly .add-row, .rbac-readonly .array-row-actions,
.rbac-readonly .block-chooser-wrap, .rbac-readonly .rte-toolbar, .rbac-readonly [data-write] { display: none !important; }
.rbac-readonly .doc-main, .rbac-readonly .doc-sidebar { position: relative; }
.rbac-readonly .doc-controls::after { content: attr(data-readonly-label); font-size: 12px; color: var(--muted); }

/* multi-site: top bar site switcher, list site filter, global site header */
.site-switch { display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; }
.site-switch-icon { color: var(--muted); font-size: 14px; }
.site-switch .site-switch-select { height: 30px; padding-top: 0; padding-bottom: 0; max-width: 220px; font-size: 13px; }
.site-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; font-size: 13px; }
.site-filter .muted { margin-right: 4px; }
.site-filter .chip-btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.global-site, .global-site strong { overflow-wrap: anywhere; }
.global-site { margin: 8px 0 0; font-size: 13px; }
.inquiry-card .cell-thumb { vertical-align: middle; }
@media (max-width: 640px) { .site-switch .site-switch-select { max-width: 130px; } }
