/* =====================================================================
   Blog CMS — light editorial admin theme (v2)
   Styles the existing CMS class names (dashboard, tables, forms, login)
   plus the new studio editor, posts list and backups pages.
   ===================================================================== */
:root {
  --paper: #f7f5f0; --surface: #ffffff; --surface-2: #f2efe8; --ink: #1b1a18; --ink-2: #3d3a35; --muted: #77716a;
  --line: #e7e2d8; --line-2: #d9d2c4; --accent: #c8372d; --accent-ink: #a52a21; --accent-soft: #fbeae7;
  --ok: #217a4f; --ok-soft: #e6f4ec; --warn: #a86411; --warn-soft: #fdf1df; --info: #2b5fa6; --info-soft: #e8f0fb;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; --serif: "Newsreader", Georgia, serif; --mono: "JetBrains Mono", Consolas, monospace;
  --r: 12px; --shadow: 0 1px 2px rgba(27,26,24,.05), 0 6px 20px -10px rgba(27,26,24,.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
h1, h2, h3 { color: var(--ink); letter-spacing: -.01em; }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Shell ---------- */
.main-header { position: sticky; top: 0; z-index: 50; height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.main-header .logo { margin: 0; font: 600 19px var(--serif); display: flex; align-items: center; gap: 10px; }
.main-header .logo a { color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.main-header .logo img { width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 2px 8px -4px rgba(0,0,0,.35); }
.main-header .logo em { color: var(--accent); font-style: italic; font-weight: 500; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.user-name .av { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--paper); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.btn-logout, .hdr-link { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px; background: var(--surface); }
.btn-logout:hover, .hdr-link:hover { border-color: var(--ink); color: var(--ink); }
.dashboard-container { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface); overflow: auto; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar .sec { font: 600 11px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.sidebar a svg { width: 17px; height: 17px; opacity: .75; }
.sidebar a:hover { background: var(--surface-2); color: var(--ink); }
.sidebar a.active { background: var(--ink); color: var(--paper); } .sidebar a.active svg { opacity: 1; }
.sidebar .side-cta { margin: 14px 4px 0; display: flex; justify-content: center; background: var(--accent); color: #fff; font-weight: 600; }
.sidebar .side-cta:hover { background: var(--accent-ink); color: #fff; }
.main-content { padding: 28px 32px 60px; min-width: 0; }
@media (max-width: 900px) {
  .dashboard-container { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .sidebar ul { flex-direction: row; overflow-x: auto; } .sidebar .sec, .sidebar .side-cta { display: none; }
  .sidebar a { white-space: nowrap; } .main-content { padding: 20px 16px 48px; }
}

/* ---------- Page header + buttons ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h1 { margin: 0; font: 500 32px/1.1 var(--serif); letter-spacing: -.02em; }
.page-header p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-primary, .btn-secondary, .btn-small, .btn-danger, .btn-ghost, button.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 99px;
  font: 600 14px/1 var(--sans); text-decoration: none; cursor: pointer; border: 1px solid transparent; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary.red { background: var(--accent); border-color: var(--accent); color: #fff; } .btn-primary.red:hover { background: var(--accent-ink); }
.btn-secondary, .btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover, .btn-ghost:hover { border-color: var(--ink); }
.btn-small { height: 30px; padding: 0 12px; font-size: 12.5px; font-weight: 500; background: var(--surface); color: var(--ink-2); border-color: var(--line-2); }
.btn-small:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { color: var(--accent); } .btn-small.btn-danger:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
button[disabled], .is-busy { opacity: .55; pointer-events: none; }
.text-center { text-align: center; }

/* ---------- Messages ---------- */
.error-message, .success-message, .notice { padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; font-weight: 500; border: 1px solid; }
.error-message { background: var(--accent-soft); color: var(--accent-ink); border-color: #f2c7c2; }
.success-message { background: var(--ok-soft); color: var(--ok); border-color: #bfe3cf; }
.notice { background: var(--info-soft); color: var(--info); border-color: #c9daf3; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1d8b0; }

/* ---------- Stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card { padding: 18px 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat-value { font: 500 32px/1 var(--serif); letter-spacing: -.02em; color: var(--ink); }
.stat-label { margin-top: 8px; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat-card .trend { margin-top: 10px; font-size: 12.5px; color: var(--ok); font-weight: 600; }

/* ---------- Sections + tables ---------- */
.content-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--shadow); }
.content-section > h2, .content-section .sec-head h2 { margin: 0 0 14px; font: 600 17px var(--sans); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; } .sec-head h2 { margin: 0 !important; }
.posts-table { overflow-x: auto; margin: 0 -22px -20px; }
.posts-table table, table.cms-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.posts-table th, .posts-table td, .cms-table th, .cms-table td { padding: 12px 22px; text-align: left; border-top: 1px solid var(--line); vertical-align: middle; }
.posts-table th, .cms-table th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; border-top: 0; white-space: nowrap; }
.posts-table tbody tr:hover td, .cms-table tbody tr:hover td { background: #fcfbf8; }
.posts-table td .btn-small + .btn-small { margin-left: 6px; }
.t-title { font-weight: 600; color: var(--ink); text-decoration: none; } .t-title:hover { color: var(--accent); }
.t-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-published { background: var(--ok-soft); color: var(--ok); } .status-draft { background: var(--surface-2); color: var(--muted); }
.status-archived { background: #eee; color: #777; } .status-scheduled { background: var(--info-soft); color: var(--info); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label, .lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea, .inp {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-size: 14.5px; transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .inp:focus { outline: 0; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--surface-2); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.counter { float: right; font-weight: 500; color: var(--muted); font-size: 12px; } .counter.over { color: var(--accent); }

/* ---------- Modal ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(20,19,17,.45); padding: 24px; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-content { background: var(--surface); border-radius: 16px; padding: 24px; width: min(520px, 100%); max-height: calc(100vh - 48px); overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); position: relative; }
.modal-content h3 { margin: 0 0 16px; font: 600 18px var(--sans); }
.modal-content .close, .close-modal { position: absolute; right: 16px; top: 12px; font-size: 24px; cursor: pointer; color: var(--muted); background: none; border: 0; }

/* ---------- Login ---------- */
body.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(800px 400px at 100% 0%, rgba(200,55,45,.12), transparent 60%), radial-gradient(600px 400px at 0% 100%, rgba(232,131,58,.12), transparent 60%), var(--paper); }
.login-container { width: min(420px, 100%); }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 34px 32px 28px; box-shadow: 0 30px 70px -30px rgba(27,26,24,.35); }
.login-box h1 { margin: 0 0 6px; font: 500 30px/1.1 var(--serif); letter-spacing: -.02em; }
.login-box .subtitle { margin: 0 0 24px; color: var(--muted); }
.login-box .btn-primary { width: 100%; height: 46px; margin-top: 6px; font-size: 15px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font: 600 18px var(--serif); text-decoration: none; color: var(--ink); }
.login-brand img { width: 34px; height: 34px; border-radius: 50%; } .login-brand em { color: var(--accent); font-weight: 500; }
.login-footer { margin-top: 18px; display: flex; justify-content: space-between; font-size: 13.5px; }
.login-footer a { color: var(--muted); text-decoration: none; } .login-footer a:hover { color: var(--accent); }
.pw-wrap { position: relative; } .pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 600; padding: 6px; }

/* ---------- Posts list ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .inp { width: auto; min-width: 140px; height: 38px; padding: 0 12px; }
.filters .search-inp { flex: 1; min-width: 220px; }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.seg a { padding: 6px 14px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg a .n { opacity: .6; font-weight: 500; margin-left: 4px; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.pager a, .pager span { min-width: 34px; height: 34px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line-2); text-decoration: none; color: var(--ink-2); font-size: 13.5px; background: var(--surface); }
.pager .on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }

/* ---------- Mini bar chart ---------- */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.spark i { flex: 1; min-width: 4px; background: linear-gradient(180deg, var(--accent), #e8833a); border-radius: 3px 3px 0 0; opacity: .85; position: relative; }
.spark i:hover { opacity: 1; }
.spark-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; } @media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.top-list { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.top-list li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); counter-increment: t; font-size: 14px; }
.top-list li::before { content: counter(t); font: 600 12px var(--sans); color: var(--muted); }
.top-list li:first-child { border-top: 0; }
.top-list a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .top-list a:hover { color: var(--accent); }
.top-list b { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }

/* ---------- Backups ---------- */
.health { display: flex; gap: 16px; align-items: center; padding: 18px 20px; border-radius: var(--r); border: 1px solid; margin-bottom: 22px; }
.health.good { background: var(--ok-soft); border-color: #bfe3cf; color: var(--ok); } .health.bad { background: var(--accent-soft); border-color: #f2c7c2; color: var(--accent-ink); }
.health .dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 18%, transparent); flex: none; }
.health b { display: block; font-size: 16px; } .health span { font-size: 13.5px; opacity: .9; }
code.copyable { display: block; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 12.5px/1.5 var(--mono); word-break: break-all; color: var(--ink); }
.steps-list { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); } .steps-list li { margin: 4px 0; }

/* ---- Messages, website editor ---- */
.side-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font: 700 11px/20px var(--sans); text-align: center; }
.msg-table tr.unread td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.msg-table tr.unread .t-title { font-weight: 700; }
.msg-table tr.on td { background: var(--surface-2); }
.msg-table .new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.msg-snip { color: var(--ink-2); text-decoration: none; display: block; max-width: 560px; } .msg-snip:hover { color: var(--ink); }
.msg-open { border-left: 3px solid var(--accent); }
.msg-meta { color: var(--muted); font-size: 13.5px; margin: -6px 0 14px; } .msg-meta a { color: var(--ink); }
.msg-body { white-space: normal; font-size: 15px; line-height: 1.65; padding: 16px 18px; border-radius: 12px; background: var(--surface-2); margin-bottom: 16px; overflow-wrap: anywhere; }
.dash-msgs { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dash-msgs a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); }
.dash-msgs a:hover { border-color: var(--ink); } .dash-msgs b { font-weight: 600; } .dash-msgs small { color: var(--muted); } .dash-msgs span { grid-column: 1 / -1; color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-msgs a.unread { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.msg-reply { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.msg-reply textarea { width: 100%; min-height: 130px; resize: vertical; line-height: 1.55; } .msg-reply .inp { width: 100%; }
.msg-replied { margin: 0 0 14px; padding: 12px 16px; border-radius: 10px; background: var(--ok-soft); color: var(--ink-2); font-size: 14px; line-height: 1.55; } .msg-replied b { display: block; color: var(--ok); margin-bottom: 4px; }
