/* =========================================================================
   CMS admin
   ========================================================================= */
.cms-app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; background: var(--surface); }

/* sidebar */
.cms-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--border); padding: 16px 14px; }
.cms-side-top { padding: 6px 8px 18px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.cms-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.cms-nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; background: transparent; border: 0; text-align: left; font-size: 14px; font-weight: 500; color: var(--text-muted); transition: background .14s, color .14s; }
.cms-nav-item:hover { background: var(--panel-2); color: var(--text); }
.cms-nav-item.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 560; }
.cms-nav-item.is-active svg { color: var(--brand); }
.cms-side-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.cms-newbtn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 40px; border-radius: 10px; background: var(--brand); color: var(--on-brand); border: 0; font-weight: 560; font-size: 14px; transition: background .14s; }
.cms-newbtn:hover { background: var(--brand-ink); }
.cms-back { display: flex; align-items: center; gap: 8px; padding: 6px 8px; font-size: 13px; color: var(--text-faint); transition: color .14s; }
.cms-back:hover { color: var(--text); }

/* main */
.cms-main { min-width: 0; display: flex; flex-direction: column; }
.cms-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 30px; background: color-mix(in oklab, var(--bg), transparent 12%); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.cms-topbar h1 { font-size: 21px; }
.cms-topbar p { font-size: 13.5px; margin-top: 3px; }
.cms-topbar-right { display: flex; align-items: center; gap: 14px; }
.cms-user { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--border); }
.cms-avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 13px; }
.cms-user-meta { display: flex; flex-direction: column; gap: 3px; }
.cms-user-meta strong { font-size: 13.5px; }
@media (max-width: 720px) { .cms-user-meta { display: none; } }

.cms-content { padding: 26px 30px 40px; }
@media (max-width: 640px) { .cms-content, .cms-topbar { padding-inline: 16px; } }

/* stats */
.cms-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .cms-stats { grid-template-columns: 1fr 1fr; } }
.cms-stat { padding: 18px; }
.cms-stat-head { display: flex; align-items: center; justify-content: space-between; min-height: 28px; }
.cms-stat-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); }
.cms-delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; font-family: var(--mono); }
.cms-delta.up { color: var(--green); }
.cms-stat-val { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-top: 14px; }
.cms-stat-label { font-size: 13px; margin-top: 2px; }

/* dash grid */
.cms-dash-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-top: 16px; align-items: start; }
.cms-panel-wide { grid-column: 1 / -1; }
@media (max-width: 1100px) { .cms-dash-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .cms-dash-grid { grid-template-columns: 1fr; } }
.cms-panel { padding: 18px; }
.cms-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cms-panel-head h3 { font-size: 15px; }
.cms-panel-head span { white-space: nowrap; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 1fr 2.2fr auto; gap: 12px; align-items: center; }
.hbar-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.hbar-val { font-size: 12px; color: var(--text-faint); }

/* query list */
.cms-querylist { display: flex; flex-direction: column; }
.cms-query { display: flex; align-items: center; gap: 9px; padding: 9px 0; font-size: 13.5px; }
.cms-query + .cms-query { border-top: 1px solid var(--border); }
.cms-query-q { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cms-query-n { color: var(--text-faint); font-size: 12.5px; }

/* device bar */
.device-bar { display: flex; height: 14px; border-radius: 99px; overflow: hidden; gap: 2px; }
.device-seg { display: block; height: 100%; }
.device-seg.seg-0, .device-dot.seg-0 { background: var(--brand); }
.device-seg.seg-1, .device-dot.seg-1 { background: var(--brand-2); }
.device-seg.seg-2, .device-dot.seg-2 { background: var(--accent); }
.device-legend { display: flex; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.device-leg { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.device-dot { width: 9px; height: 9px; border-radius: 3px; }

/* roles */
.cms-roles { display: flex; flex-direction: column; }
.cms-role { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 9px 0; font-size: 13px; }
.cms-role + .cms-role { border-top: 1px solid var(--border); }
.cms-role strong { font-weight: 560; white-space: nowrap; }
.cms-role-n { color: var(--text-faint); }

/* tables */
.cms-tablecard { overflow: hidden; padding: 0; }
.cms-table { width: 100%; border-collapse: collapse; }
.cms-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint); font-family: var(--mono); font-weight: 600; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.cms-table td { padding: 13px 16px; font-size: 13.5px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cms-table tbody tr:last-child td { border-bottom: 0; }
.cms-table tbody tr { transition: background .12s; }
.cms-table tbody tr:hover { background: var(--panel-2); }
.cms-td-title { font-weight: 540; color: var(--text); max-width: 360px; }
.cms-table.compact td, .cms-table.compact th { padding: 11px 14px; }
.cms-cat-chip { display: inline-flex; align-items: center; gap: 6px; }
.cms-rowactions { display: flex; gap: 4px; }
.cms-rowbtn { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: transparent; border: 1px solid transparent; color: var(--text-faint); transition: all .13s; }
.cms-rowbtn:hover { background: var(--bg); border-color: var(--border-strong); color: var(--brand-ink); }
.cms-empty { text-align: center; color: var(--text-faint); padding: 40px; }

/* toolbar */
.cms-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.cms-segmented { display: inline-flex; gap: 3px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 11px; }
.cms-seg { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 8px; background: transparent; border: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); transition: all .13s; }
.cms-seg.is-active { background: var(--brand-soft); color: var(--brand-ink); }
.cms-seg-n { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--panel-2); color: var(--text-faint); }
.cms-seg.is-active .cms-seg-n { background: var(--bg); }
.cms-toolbar-right { display: flex; align-items: center; gap: 10px; }
.cms-search-input { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--panel); }
.cms-search-input input { border: 0; background: transparent; outline: none; font: inherit; font-size: 13.5px; color: var(--text); width: 160px; }

/* category cards */
.cms-catcard { display: flex; gap: 14px; padding: 16px; align-items: flex-start; }
.cms-catcard-body { flex: 1; min-width: 0; }
.cms-catcard-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.cms-catcard-top strong { font-size: 15px; }
.cms-catcard-body p { font-size: 13px; margin: 6px 0 8px; }

/* media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media-drop { height: 130px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.media-item { display: flex; flex-direction: column; gap: 7px; }
.media-thumb { height: 110px; }
.media-name { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* vbars (analytics) */
.vbars { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.vbar { flex: 1; background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-radius: 5px 5px 0 0; min-height: 4px; transition: opacity .14s; }
.vbar:hover { opacity: .8; }

/* ===== editor ===== */
.cms-editor { padding-top: 20px; }
.cms-editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.cms-back-link { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0; color: var(--text-muted); font-size: 13.5px; font-weight: 500; }
.cms-back-link:hover { color: var(--text); }
.cms-editor-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cms-editor-grid { display: grid; grid-template-columns: 1fr 312px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .cms-editor-grid { grid-template-columns: 1fr; } }

.cms-title-input { width: 100%; border: 0; background: transparent; font: inherit; font-size: 28px; font-weight: 680; letter-spacing: -0.03em; color: var(--text); outline: none; padding: 4px 0; }
.cms-title-input::placeholder { color: var(--text-faint); }
.cms-slug { font-size: 12.5px; margin: 4px 0 18px; color: var(--brand-ink); }
.cms-editor-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.cms-editor-tabs button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 7px; background: transparent; border: 0; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.cms-editor-tabs button.is-active { background: var(--brand-soft); color: var(--brand-ink); }

.cms-md { border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; background: var(--panel); }
.cms-md-toolbar { display: flex; gap: 2px; padding: 7px 8px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.cms-md-toolbar button { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: transparent; border: 0; color: var(--text-muted); transition: all .12s; }
.cms-md-toolbar button:hover { background: var(--bg); color: var(--brand-ink); }
.cms-md-area { width: 100%; min-height: 440px; border: 0; background: transparent; padding: 18px; font-size: 13.5px; line-height: 1.75; color: var(--text); resize: vertical; outline: none; }
.cms-md-preview { border: 1px solid var(--border); border-radius: 12px; padding: 22px 26px; background: var(--panel); min-height: 440px; max-width: none; }
.cms-md-preview > :first-child { margin-top: 0; }
.cms-md-preview h1 { font-size: 26px; margin: 20px 0 12px; }
.cms-md-preview h2 { font-size: 20px; margin: 24px 0 10px; }
.cms-md-preview h3 { font-size: 17px; margin: 18px 0 8px; }
.cms-md-preview p, .cms-md-preview li { font-size: 14.5px; line-height: 1.7; margin: 8px 0; }
.md-pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 10px; font-size: 13px; overflow-x: auto; margin: 14px 0; }

/* editor side */
.cms-editor-side { display: flex; flex-direction: column; gap: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.cms-field { display: flex; flex-direction: column; gap: 7px; }
.cms-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: flex; justify-content: space-between; align-items: center; }
.cms-count { font-family: var(--mono); font-size: 11px; color: var(--text-faint); font-weight: 500; }
.cms-count.over { color: var(--red); }
.cms-radio { display: inline-flex; gap: 3px; padding: 3px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; }
.cms-radio button { flex: 1; padding: 7px 8px; border-radius: 6px; background: transparent; border: 0; font-size: 12.5px; font-weight: 500; color: var(--text-muted); }
.cms-radio button.is-active { background: var(--brand); color: var(--on-brand); }
.cms-select, .cms-input { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--bg); font: inherit; font-size: 13.5px; color: var(--text); outline: none; }
.cms-select:focus, .cms-input:focus { border-color: var(--brand); }
textarea.cms-input { resize: vertical; line-height: 1.5; }
.cms-fakeinput { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.cms-tagedit { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--bg); }
.cms-tagchip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 6px 0 10px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-ink); font-size: 12.5px; font-family: var(--mono); }
.cms-tagchip button { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; background: transparent; border: 0; color: inherit; opacity: .7; }
.cms-tagchip button:hover { opacity: 1; background: rgba(0,0,0,.08); }
.cms-tagedit input { flex: 1; min-width: 60px; border: 0; background: transparent; outline: none; font: inherit; font-size: 13px; color: var(--text); }
.cms-cover { height: 120px; }
.cms-seo { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.cms-seo-head { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-ink); font-family: var(--mono); }
