/* News Portal SaaS - admin panel */
:root {
  --bg: #f4f6fb; --panel: #fff; --text: #1d2433; --muted: #6b7385; --line: #e4e8f0;
  --brand: #c8102e; --brand-2: #a00c24; --brand-soft: #fde8eb;
  --side: #121826; --side-text: #b7bfd1; --side-active: #fff;
  --ok: #0f9d58; --ok-soft: #e6f6ee; --warn: #b7791f; --warn-soft: #fdf3e1; --bad: #d93025; --bad-soft: #fde9e7;
  --info: #2563eb; --info-soft: #e8efff;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
img { max-width: 100%; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .88em; }

/* layout */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; transition: grid-template-columns .2s ease; }
.side { background: var(--side); color: var(--side-text); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.side .side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 12px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.06); }
.side .brand img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; background: #fff; }
.side .brand .logo-dot { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-weight: 800; color: #fff; }
.side .brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 11.5px; }
.side .group { padding: 14px 18px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #6f7a91; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 7px 18px; color: var(--side-text); border-left: 3px solid transparent; }
.side a.nav:hover { color: #fff; background: rgba(255,255,255,.04); text-decoration: none; }
.side a.nav.active { color: var(--side-active); background: rgba(255,255,255,.07); border-left-color: var(--brand); }
.side a.nav svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: .85; }
.side .badge { margin-left: auto; }
.main { min-width: 0; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; background: none; border: 0; cursor: pointer; padding: 6px; }
.topbar .user { display: flex; align-items: center; gap: 8px; }
.topbar .user img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.content { padding: 24px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 200px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }
.impersonating { background: #7c2d12; color: #fff; text-align: center; padding: 6px; font-size: 13px; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 14px 18px 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.with-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--bad); }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfd; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbff; }
.table .thumb { width: 64px; height: 42px; object-fit: cover; border-radius: 6px; background: #eef1f6; display: block; }
.table .title { font-weight: 600; color: var(--text); }
.table .meta { color: var(--muted); font-size: 12.5px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* forms */
.field { margin-bottom: 14px; }
.field label, .label-text { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field .error { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid #cfd5e1; border-radius: 8px; font: inherit; color: inherit; background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 90px; resize: vertical; }
input[type=color] { width: 46px; height: 36px; padding: 2px; border: 1px solid #cfd5e1; border-radius: 8px; background: #fff; cursor: pointer; }
input[type=file] { font-size: 13px; }
.is-invalid { border-color: var(--bad) !important; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }
.row > .shrink { flex: 0 0 auto; min-width: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 150px; padding: 7px 10px; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type=text] { width: 110px; }
.image-preview { margin-top: 8px; display: flex; gap: 10px; align-items: center; }
.image-preview img { max-height: 90px; border-radius: 8px; border: 1px solid var(--line); background: #f1f3f7; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfd5e1; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: #f5f7fb; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.dark { background: #1d2433; border-color: #1d2433; color: #fff; }
.btn.danger { color: var(--bad); border-color: #f2c4bf; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.link { border: 0; background: none; color: var(--info); padding: 0; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; }

/* badges & alerts */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eef1f6; color: #4a5368; white-space: nowrap; }
.badge.published, .badge.running, .badge.active, .badge.approved, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.draft, .badge.paused, .badge.inactive { background: #eef1f6; color: #4a5368; }
.badge.pending, .badge.upcoming, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.scheduled, .badge.info { background: var(--info-soft); color: var(--info); }
.badge.spam, .badge.expired, .badge.suspended, .badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.side .badge { background: var(--brand); color: #fff; }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert.success { background: var(--ok-soft); border-color: #b9e5cd; color: #0b6b3c; }
.alert.error { background: var(--bad-soft); border-color: #f4c7c2; color: #a3251b; }
.alert.info { background: var(--info-soft); border-color: #c9d8fb; color: #1e4fbf; }
.alert.warn { background: var(--warn-soft); border-color: #f2dcb0; color: #8a5a12; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; } .mt { margin-top: 14px; }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 9px 14px; color: var(--muted); border: 0; background: none; border-bottom: 2px solid transparent; font: inherit; font-weight: 600; cursor: pointer; }
.tabs a.active, .tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tab-panel { display: none; } .tab-panel.active { display: block; }

/* pagination */
.pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 14px 18px; align-items: center; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: #fff; font-size: 13px; }
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled { color: #b0b6c3; }

/* bars (analytics) */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { position: relative; display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; margin-bottom: 4px; border-radius: 6px; overflow: hidden; font-size: 13px; }
.bars li .fill { position: absolute; inset: 0 auto 0 0; background: var(--brand-soft); z-index: 0; border-radius: 6px; }
.bars li span { position: relative; z-index: 1; }
.bars li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-box { position: relative; height: 280px; }

/* builder */
.builder { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.palette button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 11px; margin-bottom: 6px; border: 1px dashed #c4cbd8; border-radius: 8px; background: #fafbfd; cursor: pointer; font: inherit; text-align: left; }
.palette button:hover { border-color: var(--brand); background: var(--brand-soft); }
.sections { list-style: none; margin: 0; padding: 0; }
.section-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; box-shadow: var(--shadow); }
.section-item.dragging { opacity: .45; }
.section-item.drop-before { box-shadow: 0 -3px 0 var(--brand); }
.section-item.drop-after { box-shadow: 0 3px 0 var(--brand); }
.section-item.off { opacity: .6; }
.section-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.section-bar .handle { cursor: grab; color: #9aa3b5; font-size: 18px; user-select: none; padding: 0 4px; }
.section-bar .name { flex: 1; font-weight: 600; }
.section-bar .type { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.section-body { border-top: 1px solid var(--line); padding: 14px; display: none; }
.section-item.open .section-body { display: block; }

/* menu editor */
.menu-list { list-style: none; padding: 0; margin: 0; }
.menu-list li { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.menu-list li.child { margin-left: 32px; background: #fafbfd; }
.menu-list li input { flex: 1; }

/* themes */
.theme-card { border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.theme-card.active { border-color: var(--brand); }
.theme-card .preview { aspect-ratio: 16/10; background: #eef1f6; display: block; width: 100%; object-fit: cover; }
.theme-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }

/* matrix */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, #121826, #2b1320); }
.auth .box { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }

/* editor */
.editor-wrap .ql-toolbar { border-radius: 8px 8px 0 0; border-color: #cfd5e1 !important; background: #fafbfd; }
.editor-wrap .ql-container { border-radius: 0 0 8px 8px; border-color: #cfd5e1 !important; font-size: 16px; font-family: Georgia, serif; }
.editor-wrap .ql-editor { min-height: 420px; line-height: 1.7; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.gallery-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.gallery-grid img { aspect-ratio: 4/3; object-fit: cover; width: 100%; display: block; }
.gallery-grid figcaption { padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.serp { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; font-family: Arial, sans-serif; }
.serp .u { color: #1a0dab; font-size: 18px; }
.serp .l { color: #006621; font-size: 13px; }
.serp .d { color: #4d5156; font-size: 13px; }
.counter { float: right; font-weight: 400; color: var(--muted); font-size: 12px; }

dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(10,14,25,.5); }
dialog.modal .m-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
dialog.modal .m-head h3 { margin: 0; flex: 1; }
dialog.modal .m-body { padding: 18px; }
dialog.modal .m-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .with-side, .builder { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 248px; z-index: 50; transition: left .2s; }
  body.nav-open .side { left: 0; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .topbar .menu-btn { display: block; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .hide-sm { display: none; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } }

/* demo portal */
.auth .box.box-wide { max-width: 520px; }
.demo-accounts { background: #fff8e6; border: 1px solid #f2dcb0; border-radius: 10px; padding: 12px; margin-bottom: 18px; }
.demo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.demo-roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; margin-bottom: 8px; }
.demo-role { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border: 1px solid #e6d3a7; border-radius: 8px; background: #fff; cursor: pointer; font: inherit; text-align: left; }
.demo-role span { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.demo-role:hover, .demo-role.active { border-color: var(--brand); background: var(--brand-soft); }
.demo-bar { position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: calc(100vw - 32px);
  background: #1d2433; color: #fff; border-radius: 12px; padding: 8px 10px 8px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 13px; }
.demo-bar .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.demo-bar .btn:hover { background: rgba(255,255,255,.22); }
.demo-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; }
.demo-drafts { border: 1px dashed #e6c46d; background: #fffbeb; border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.demo-drafts ul { margin: 6px 0 0; padding-left: 18px; }
.demo-restored { font-size: 12px; color: #8a5a12; background: #fdf3e1; border-radius: 6px; padding: 6px 10px; margin-bottom: 10px; }
.demo-journal { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow: auto; }
.demo-journal li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }

/* sidebar collapse (desktop): icons-only rail, labels as tooltips */
.side-foot { border-top: 1px solid rgba(255,255,255,.06); padding: 8px; }
.side-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--side-text); font: inherit; cursor: pointer; }
.side-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-toggle svg { width: 17px; height: 17px; flex: 0 0 17px; transition: transform .2s; }
.side .brand-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side a.nav .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-tip { position: fixed; z-index: 200; transform: translateY(-50%); background: #1d2433; color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.side-tip::before { content: ""; position: absolute; left: -4px; top: 50%; margin-top: -4px; border: 4px solid transparent; border-left: 0; border-right-color: #1d2433; }
@media (min-width: 861px) {
  html.side-collapsed .shell { grid-template-columns: 68px 1fr; }
  html.side-collapsed .side .brand { justify-content: center; padding: 18px 0 14px; }
  html.side-collapsed .side .brand-text,
  html.side-collapsed .side a.nav .label,
  html.side-collapsed .side-toggle .label { display: none; }
  html.side-collapsed .side .group { font-size: 0; padding: 10px 16px 6px; }
  html.side-collapsed .side .group::before { content: ""; display: block; border-top: 1px solid rgba(255,255,255,.09); }
  html.side-collapsed .side a.nav { justify-content: center; padding: 10px 0; position: relative; }
  html.side-collapsed .side a.nav svg { width: 19px; height: 19px; flex-basis: 19px; }
  html.side-collapsed .side a.nav .badge { position: absolute; top: 3px; right: 10px; margin: 0; padding: 0 5px; min-width: 16px; font-size: 10px; line-height: 16px; text-align: center; }
  html.side-collapsed .side-toggle { justify-content: center; }
  html.side-collapsed .side-toggle svg { transform: rotate(180deg); }
}
@media (max-width: 860px) { .side-foot { display: none; } }
/* keep the demo bar clear of the sidebar (and its collapse button) */
@media (min-width: 861px) {
  .demo-bar { left: calc(248px + 16px); transition: left .2s ease; }
  html.side-collapsed .demo-bar { left: calc(68px + 16px); }
  body:not([data-demo]) .demo-bar { display: none; }
}

/* Additions: picker, grids, alerts */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; list-style: none; padding: 0; margin: 0; }
.thumb-pick { padding: 0; border: 2px solid transparent; background: none; cursor: pointer; border-radius: 6px; overflow: hidden; aspect-ratio: 1; }
.thumb-pick:hover, .thumb-pick:focus-visible { border-color: var(--brand); }
.thumb-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; background: #fff7e6; border: 1px solid #f5d48a; color: #6b4e00; }
.alert.danger { background: #fdecea; border-color: #f3b5ae; color: #8a1c13; }
.alert.info { background: #e8f1fe; border-color: #b5d0f7; color: #123f7a; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.widget-list { list-style: none; margin: 0; padding: 0; }
.inline-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.bell { position: relative; }
.bell .badge { position: absolute; top: -6px; right: -6px; font-size: 10px; padding: 1px 5px; }
dialog.modal { border: 0; border-radius: 10px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: 86vh; }
dialog.modal::backdrop { background: rgba(0, 0, 0, .45); }
.m-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line, #e5e7eb); }
.m-head h3 { margin: 0; }
.m-body { padding: 16px; overflow: auto; }
