/* CCMS authoring + admin UI */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --border-strong: #c4cad3;
  --text: #1c2330;
  --text-muted: #5b6575;
  --primary: #2453c7;
  --primary-hover: #1c43a6;
  --primary-soft: #e8eefc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --success: #17803d;
  --success-soft: #e6f4ea;
  --warning: #9a6200;
  --warning-soft: #fff4dc;
  --info-soft: #e8f3fb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --topbar-h: 56px;
  --sidenav-w: 232px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 .8em; }
code, pre, kbd { font-family: var(--mono); font-size: .92em; }
:focus-visible { outline: 3px solid #7aa2f7; outline-offset: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.skip-link:focus { left: 8px; }
.icon { vertical-align: -3px; flex-shrink: 0; }
.muted { color: var(--text-muted); }
.small { font-size: .86em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }
.hidden { display: none !important; }

/* ---------- top bar & navigation */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #141b2d; color: #e9edf5; }
.topbar a { color: inherit; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #4f7cff, #2453c7); color: #fff; font-weight: 800; }
.topsearch { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.topsearch .icon { position: absolute; left: 10px; color: #9aa6bd; }
.topbar .topsearch input { width: 100%; height: 36px; border-radius: 18px; border: 1px solid #2b3550; background: #1e2740; color: #fff; padding: 0 14px 0 34px; font: inherit; }
.topsearch input::placeholder { color: #8d99b3; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: inherit; cursor: pointer; position: relative; list-style: none; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.bell .count { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #e5484d; color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.nav-toggle { display: none; }
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.user-menu > summary:hover { background: rgba(255,255,255,.08); }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #3a4a72; font-weight: 700; font-size: 13px; }
.menu-body { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.menu-body a, .menu-body .linklike { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.menu-body a:hover, .menu-body .linklike:hover { background: var(--surface-2); text-decoration: none; }
.menu-meta { padding: 6px 10px 8px; color: var(--text-muted); font-size: .85em; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }

.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidenav { width: var(--sidenav-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px 40px; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.nav-section { margin-bottom: 14px; }
.nav-heading { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); padding: 4px 10px; font-weight: 650; }
.sidenav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 6px; color: var(--text); }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-badge { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.main:focus { outline: none; }
body.full-width .sidenav { display: none; }
body.full-width .main { padding: 0; }

/* ---------- generic components */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { margin-left: auto; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.layout-left { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-end { justify-content: flex-end; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #f1b7b1; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: .88em; }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 7px 7px 0; }
form.inline { display: inline; }

.field { display: block; }
.field > span, .field-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .92em; }
.field small, .hint { display: block; color: var(--text-muted); font-size: .84em; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], input:not([type]), select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6c9f6; border-color: var(--primary); }
select[multiple] { min-height: 120px; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
legend { font-weight: 650; padding: 0 6px; }

.flash { position: relative; padding: 11px 40px 11px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash-success { background: var(--success-soft); border-color: #b5dfc3; color: #0f5a2b; }
.flash-error { background: var(--danger-soft); border-color: #f3c0ba; color: #8a1c13; }
.flash-info, .flash-token { background: var(--info-soft); border-color: #b9dbf2; color: #0b4f7a; }
.flash-warning { background: var(--warning-soft); border-color: #f1d79a; color: #6b4500; }
.flash-close { position: absolute; right: 8px; top: 7px; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted); white-space: nowrap; border: 1px solid transparent; }
.status-draft { background: #eef0f3; color: #4a5465; }
.status-in_review { background: #fff4dc; color: #8a5a00; }
.status-changes_requested { background: #fdecea; color: #a1281d; }
.status-approved { background: #e3f1fd; color: #0b5c99; }
.status-published { background: #e6f4ea; color: #17803d; }
.status-archived { background: #f0f0f0; color: #777; text-decoration: line-through; }
.badge-outline { background: transparent; border-color: var(--border-strong); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 4px; background: var(--primary-soft); color: #23418f; font-size: .8rem; margin: 0 4px 4px 0; }
.tag .tax { opacity: .65; }
.lang { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; padding: 0 5px; border-radius: 3px; background: #e9ebef; color: #4a5465; letter-spacing: .03em; }

table.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 650; background: #fafbfc; position: sticky; top: var(--topbar-h); z-index: 1; }
.table tr:hover td { background: #fafbfd; }
.table td.check-col, .table th.check-col { width: 34px; }
.table .title-cell a { font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-wrap .table th { position: static; }
.empty { padding: 30px; text-align: center; color: var(--text-muted); }

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--text-muted); font-size: .82rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; }
.stat a.value { display: block; color: inherit; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
dl.meta { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
dl.meta dt { color: var(--text-muted); font-size: .88em; }
dl.meta dd { margin: 0; }

/* folder tree */
.tree { list-style: none; margin: 0; padding: 0; }
.tree a { display: flex; justify-content: space-between; padding: 5px 8px; border-radius: 6px; color: var(--text); }
.tree a:hover { background: var(--surface-2); text-decoration: none; }
.tree a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.tree .count { color: var(--text-muted); font-size: .82em; }

/* bulk bar */
.bulkbar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin-top: 12px; background: #141b2d; color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.bulkbar select, .bulkbar input { width: auto; min-height: 30px; padding: 3px 8px; }
.bulkbar[hidden] { display: none; }

/* topic preview / content */
.content { font-size: 15.5px; line-height: 1.65; max-width: 860px; }
.content h2 { font-size: 1.35rem; margin: 1.6em 0 .5em; }
.content h3 { font-size: 1.12rem; margin: 1.4em 0 .4em; }
.content img { max-width: 100%; height: auto; }
.content table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.content th, .content td { border: 1px solid var(--border-strong); padding: 6px 9px; text-align: left; vertical-align: top; }
.content th { background: var(--surface-2); }
.content td p, .content th p, .content li p { margin: 0; }
.content pre { background: #0f172a; color: #e2e8f0; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
.content code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.content pre code { background: none; padding: 0; }
.content blockquote { margin: 1em 0; padding: 4px 16px; border-left: 4px solid var(--border-strong); color: var(--text-muted); }
.content figure { margin: 1em 0; }
.content figcaption { color: var(--text-muted); font-size: .9em; margin-top: 4px; }
.content .table-wrap { border: 0; overflow-x: auto; }
.content .embed { position: relative; padding-top: 56.25%; margin: 1em 0; }
.content .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.callout, .content .note, .content .tip, .content .warning, .content .caution, .content .important { border-left: 4px solid; border-radius: 6px; padding: 10px 14px; margin: 1em 0; }
.content .note { background: #eef4fe; border-color: #3b74e0; }
.content .tip { background: #eaf7ef; border-color: #2f9e5b; }
.content .important { background: #f3edfd; border-color: #7a4cd9; }
.content .warning { background: #fff5e0; border-color: #d48806; }
.content .caution { background: #fdecea; border-color: #c4321f; }
.callout-label { display: block; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.content .heading-anchor { margin-left: 8px; opacity: 0; color: var(--text-muted); font-weight: 400; }
.content h2:hover .heading-anchor, .content h3:hover .heading-anchor { opacity: 1; }
.ccms-included { display: block; position: relative; outline: 2px dashed #8fb0f0; outline-offset: 4px; border-radius: 4px; margin: 1.2em 0; background: #f7faff; }
span.ccms-included { display: inline; margin: 0; }
.ccms-included::before { content: attr(data-include-title); display: block; font-size: 11px; font-weight: 600; color: #2a58c4; margin-bottom: 4px; }
span.ccms-included::before { display: none; }
.ccms-cond { position: relative; box-shadow: inset 3px 0 0 #d4a017; padding-left: 10px !important; }
.ccms-cond::after { content: "if " attr(data-cond); position: absolute; right: 0; top: 0; font-size: 10px; background: #fff4d0; color: #7a5a00; padding: 0 5px; border-radius: 3px; font-family: var(--mono); }
.ccms-problem { display: inline-block; background: var(--danger-soft); color: var(--danger); border: 1px dashed var(--danger); padding: 2px 8px; border-radius: 4px; font-size: .88em; }
.ccms-broken-link { color: var(--danger); text-decoration: underline wavy; }

/* diff */
.diff { font-family: var(--mono); font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.diff div { padding: 3px 12px 3px 34px; white-space: pre-wrap; word-break: break-word; position: relative; border-bottom: 1px solid #f0f1f3; }
.diff div::before { position: absolute; left: 12px; color: var(--text-muted); }
.diff .eq { color: #4a5465; }
.diff .del { background: #fdecea; }
.diff .del::before { content: "−"; color: var(--danger); }
.diff .ins { background: #e6f4ea; }
.diff .ins::before { content: "+"; color: var(--success); }
.diff .chg { background: #fffaeb; }
.diff .chg::before { content: "~"; color: var(--warning); }
.diff del { background: #f8c9c3; text-decoration: line-through; }
.diff ins { background: #b9e4c6; text-decoration: none; }
.diff .gap { color: var(--text-muted); text-align: center; background: var(--surface-2); padding-left: 12px; font-style: italic; }

/* comments */
.comment { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.comment.resolved { opacity: .65; }
.comment .who { font-weight: 600; }
.comment .quote { border-left: 3px solid #d4a017; background: #fffbea; padding: 4px 8px; margin: 6px 0; font-size: .9em; color: #5d4a00; }
.comment .suggestion { border-left: 3px solid var(--success); background: var(--success-soft); padding: 4px 8px; margin: 6px 0; font-size: .9em; }
.comment .replies { margin: 8px 0 0 16px; }
.selection-comment { position: absolute; z-index: 20; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; border-left: 2px solid var(--border); margin-left: 5px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; background: #6b8fe8; border-radius: 2px 2px 0 0; min-height: 1px; position: relative; }
.bars .bar:hover { background: var(--primary); }
.hbar { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.hbar .track { flex: 1; height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hbar .fill { height: 100%; background: #6b8fe8; }
.hbar .lbl { width: 140px; flex-shrink: 0; font-size: .88em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .num { width: 50px; text-align: right; font-size: .88em; }

/* media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; color: var(--text); display: flex; flex-direction: column; }
.media-item:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.media-thumb { aspect-ratio: 4 / 3; background: var(--surface-2) center / contain no-repeat; display: grid; place-items: center; font-weight: 700; color: var(--text-muted); font-size: 1.1rem; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-meta { padding: 8px 10px; font-size: .85em; }
.media-meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--text-muted); background: var(--surface); }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }

/* map editor */
.map-tree, .map-tree ol { list-style: none; margin: 0; padding: 0; }
.map-tree ol { padding-left: 26px; }
.map-node > .node-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 3px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.map-node > .node-row:hover { border-color: var(--border-strong); }
.map-node.dragging > .node-row { opacity: .4; }
.map-node.drop-before > .node-row { box-shadow: 0 -3px 0 var(--primary); }
.map-node.drop-after > .node-row { box-shadow: 0 3px 0 var(--primary); }
.map-node.drop-inside > .node-row { background: var(--primary-soft); border-color: var(--primary); }
.node-row .grip { cursor: grab; color: var(--text-muted); user-select: none; padding: 0 2px; }
.node-row .node-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-row .node-title input { min-height: 28px; padding: 2px 8px; }
.node-row .node-actions { display: flex; gap: 2px; }
.node-row .node-actions button { width: 26px; height: 26px; border: 1px solid transparent; background: none; border-radius: 5px; cursor: pointer; color: var(--text-muted); }
.node-row .node-actions button:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.node-heading .node-title { font-weight: 650; }

/* dialogs */
dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 60px); color: var(--text); }
dialog::backdrop { background: rgba(15, 20, 35, .45); }
.dialog-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-head .close { margin-left: auto; }
.dialog-body { padding: 16px 18px; overflow-y: auto; max-height: calc(100vh - 200px); }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); background: #fafbfc; }
.picker-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.picker-list li { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.picker-list li:hover, .picker-list li.selected { background: var(--primary-soft); }
.picker-list li:last-child { border-bottom: 0; }

/* toasts */
.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1c2330; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; animation: toast-in .2s ease; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* plain pages (login, errors) */
body.plain { min-height: 100vh; background: linear-gradient(160deg, #eef2fb, #f6f7f9 60%); }
.plain-main { max-width: 760px; margin: 0 auto; padding: 48px 16px; }
.plain-userbar { display: flex; gap: 14px; justify-content: flex-end; align-items: center; margin-bottom: 16px; font-size: .92em; }
.login-card { max-width: 400px; margin: 6vh auto 0; padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 18px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); margin: 16px 0; font-size: .85em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.error-card { text-align: center; padding: 40px 24px; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--border-strong); margin: 0; }

@media (max-width: 1100px) {
  .layout-side { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .nav-toggle { display: inline-grid; }
  .sidenav { position: fixed; left: 0; top: var(--topbar-h); z-index: 25; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidenav { transform: none; }
  .main { padding: 16px; }
  .grid-2, .grid-3, .grid-4, .form-grid, .layout-left { grid-template-columns: 1fr; }
  .user-name, .topsearch { display: none; }
  .table th { position: static; }
}
