/* ===== Static CMS design system =====
   Views should use these classes/variables rather than inventing new colors.
   Module-specific styles go in /css/views/<module>.css and are loaded by the view. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cdd2da;
  --text: #1a1d23;
  --text-2: #5b6370;
  --text-3: #8a919c;
  --accent: #2f4bd8;
  --accent-hover: #2539b8;
  --accent-soft: #eaeefe;
  --danger: #c9302c;
  --danger-soft: #fdecea;
  --success: #1f8a4c;
  --success-soft: #e6f5ec;
  --warning: #b7791f;
  --warning-soft: #fdf4e3;
  --sidebar-bg: #15181e;
  --sidebar-text: #c3c8d1;
  --sidebar-active: #262b35;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sidebar-w: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.hidden, [hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { flex: none; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--text-2); }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar-slot { width: var(--sidebar-w); flex: none; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 8px; overflow-y: auto; z-index: 20; }
.main-wrap { flex: 1; min-width: 0; }
.main { padding: 28px 32px 48px; max-width: 1280px; margin: 0 auto; }
.main.full, .main:has(> .full-bleed) { max-width: none; padding: 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: #fff; padding: 4px 8px 12px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  background-image: linear-gradient(#fff,#fff), linear-gradient(#fff,#fff), linear-gradient(#fff,#fff);
  background-size: 14px 2.5px, 14px 2.5px, 9px 2.5px; background-position: 6px 8px, 6px 12px, 6px 16px; background-repeat: no-repeat; }
.brand-lg { color: var(--text); font-size: 18px; padding: 0 0 20px; }
.sidebar-section { padding: 0 4px 8px; }
.sidebar-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7c8492; margin: 0 4px 6px; }
.site-switcher { width: 100%; background: #20242c; color: #fff; border: 1px solid #323844; border-radius: var(--radius-sm); padding: 7px 8px; font: inherit; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--sidebar-text); }
.nav-link:hover { background: #1e222a; color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-spacer { flex: 1; }
.sidebar-user { display: flex; align-items: center; gap: 6px; border-top: 1px solid #272c35; padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; padding: 4px; border-radius: var(--radius-sm); }
.user-chip:hover { background: #1e222a; text-decoration: none; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: #7c8492; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #3a4150; color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }
.sidebar .icon-btn { color: var(--sidebar-text); }
.sidebar .icon-btn:hover { background: #1e222a; color: #fff; }
.main-wrap > .menu-toggle { display: none; }
@media (max-width: 860px) {
  .sidebar-slot { width: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; position: fixed; top: 10px; left: 10px; z-index: 15; background: var(--surface); box-shadow: var(--shadow); }
  .main { padding: 56px 16px 32px; }
}

/* ---- Page header ---- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

/* ---- Cards / grid ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.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)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
@media (max-width: 1000px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 26px; font-weight: 650; }
.stat-label { color: var(--text-2); font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  font: 500 14px/1.2 var(--font); border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; text-decoration: none !important; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a92723; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid currentColor; border-color: var(--text-3) transparent var(--text-3) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-primary.is-busy::after, .btn-danger.is-busy::after { border-color: #fff transparent #fff transparent; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-weight: 500; font-size: 13px; }
.req { color: var(--danger); }
.help { color: var(--text-3); font-size: 12px; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font: inherit; color: inherit; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 70px; }
textarea.input.code, .code-input { font-family: var(--mono); font-size: 13px; }
.field-check { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-check .help { flex-basis: 100%; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: var(--radius-sm); margin: 0; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--surface-2); padding: 9px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #fafbfc; }
.table .actions { text-align: right; white-space: nowrap; }

/* ---- Badges ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; }
.tab { background: none; border: 0; padding: 9px 14px; font: 500 14px var(--font); color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,18,24,.5); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-sm { max-width: 420px; } .modal-md { max-width: 560px; } .modal-lg { max-width: 820px; } .modal-xl { max-width: 1140px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ---- Toasts ---- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1f232b; color: #fff; padding: 11px 16px; border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 380px; animation: slide .2s; transition: opacity .3s, transform .3s; }
.toast-success { background: var(--success); } .toast-error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- States ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--text-2); }
.spin { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: #23308a; }
.callout-warning { background: var(--warning-soft); color: #7a5112; }
.callout-danger { background: var(--danger-soft); color: #8b201d; }
pre.log { background: #14171c; color: #d5dae2; padding: 14px; border-radius: var(--radius-sm); overflow: auto; max-height: 420px; white-space: pre-wrap; }

/* ---- Auth ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); padding: 32px; border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .form { margin-top: 18px; }
.auth-card .btn { width: 100%; padding: 10px; }

/* ---- Full-bleed editor layouts (e.g. visual editor) ---- */
.full-bleed { height: 100vh; display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.split { display: flex; flex: 1; min-height: 0; }
.split > .pane { overflow: auto; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }
