:root {
  --bg: #F7F7F5;
  --panel: #FFFFFF;
  --sidebar: #1A1A1A;
  --sidebar-hi: #232323;
  --sidebar-txt: #B8B8B0;
  --sidebar-active: #F5A623;
  --ink: #1A1A1A;
  --ink-2: #2B2B2B;
  --ink-3: #545454;
  --muted: #8B8B8B;
  --line: #E9E6DE;
  --line-soft: #F1EEE6;
  --accent: #F5A623;
  --accent-2: #E77C22;
  --accent-soft: #FFF3D9;
  --accent-softer: #FFFAEC;
  --danger: #D0433E;
  --success: #159F5D;
  --info: #3B82C4;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 8px 24px -12px rgba(0,0,0,.14);
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; margin-top: 8px; }
.p-0 { padding: 0 !important; }
.p-4 { padding: 20px !important; }
.link { color: var(--accent-2); font-weight: 600; font-size: 13px; }
.link:hover { text-decoration: underline; }
code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ── SIDEBAR ───────────────────────────────────────────────────────── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar); color: var(--sidebar-txt);
  padding: 18px; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 6px 22px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { color: #767670; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--sidebar-txt); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item i { width: 18px; text-align: center; font-size: 13px; }
.nav-item:hover { background: var(--sidebar-hi); color: #fff; }
.nav-item.active { background: var(--sidebar-hi); color: var(--sidebar-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--sidebar-active); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.site-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--sidebar-hi); color: var(--sidebar-txt); font-size: 12.5px; }
.site-link:hover { color: #fff; }
.who { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-top: 1px solid #2C2C2C; }
.who .avatar { width: 32px; height: 32px; border-radius: 999px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.who-name { color: #fff; font-weight: 600; font-size: 13px; }
.who-out { color: var(--sidebar-txt); font-size: 11px; cursor: pointer; }
.who-out:hover { color: var(--accent); }

/* ── CONTENT ──────────────────────────────────────────────────────── */
.content { flex: 1; min-width: 0; padding: 32px 40px 60px; max-width: 1400px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; gap: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.page-head p { margin: 0; }
.head-actions { display: flex; gap: 10px; }

/* ── BUTTONS ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  font-family: inherit; font-weight: 600; font-size: 13px;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s, color .15s, transform .12s, box-shadow .15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); box-shadow: 0 6px 16px -6px rgba(231,124,34,.45); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover { background: #FDECEB; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-block { display: flex; justify-content: center; width: 100%; }
.icon-btn { background: transparent; border: 0; padding: 8px; border-radius: 6px; cursor: pointer; color: var(--ink-3); font-size: 15px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }

/* ── STAT GRID ────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-softer); color: var(--accent-2); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.stat-num { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.stat-lbl { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }

/* ── CARDS ────────────────────────────────────────────────────────── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 20px; overflow: hidden; }
.card-head { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

/* ── PROVIDER SWITCH ───────────────────────────────────────────────── */
.provider-switch { display: flex; gap: 10px; flex-wrap: wrap; }
.ps-opt { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; transition: all .15s; }
.ps-opt input { accent-color: var(--accent-2); width: 16px; height: 16px; }
.ps-opt span { font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.ps-opt i { color: var(--muted); }
.ps-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-softer); }
.ps-opt:has(input:checked) i { color: var(--accent-2); }

/* ── TABLE ────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th { text-align: left; padding: 14px 18px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--bg); border-bottom: 1px solid var(--line); font-weight: 700; }
.tbl tbody td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); vertical-align: middle; }
.tbl tbody tr:hover td { background: #FCFCF9; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td strong { color: var(--ink); font-weight: 600; }
.row-actions { display: inline-flex; gap: 4px; }

/* ── TABS ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tab { background: none; border: 0; padding: 10px 16px; font-family: inherit; font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }

/* ── PILLS ────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.pill i { font-size: 6px; }
.pill-live { background: #E5F5EC; color: var(--success); }
.pill-draft { background: #FDF3E1; color: #A76B0C; }
.pill-info { background: #E5EEF7; color: var(--info); }
.pill-warn { background: #FDF3E1; color: #A76B0C; }
.pill-err { background: #FDECEB; color: var(--danger); }
.pill-neutral { background: var(--bg); color: var(--ink-3); }

/* ── AUTH ─────────────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; padding: 40px; background: radial-gradient(ellipse 60% 50% at 50% 0%, var(--accent-softer) 0%, transparent 65%), var(--bg); }
.auth-card { max-width: 420px; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 34px; box-shadow: var(--shadow-md); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand .brand-name { color: var(--ink); }
.auth-brand .brand-sub { color: var(--muted); }
.auth-card h1 { font-size: 22px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.01em; }
.auth-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.auth-card input { padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-family: inherit; font-size: 14px; background: #fff; transition: border-color .15s; }
.auth-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }

/* ── MODAL ────────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: var(--r-lg); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.modal-body input[type="text"], .modal-body input[type="email"], .modal-body input[type="password"], .modal-body input[type="number"], .modal-body select, .modal-body textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; color: var(--ink); font-weight: 400; text-transform: none; letter-spacing: 0;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }
.modal-body textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 22px; border-top: 1px solid var(--line-soft); background: var(--bg); margin: 22px -22px -22px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { flex-direction: row !important; align-items: center; gap: 10px !important; text-transform: none !important; letter-spacing: 0 !important; font-size: 14px !important; font-weight: 500 !important; color: var(--ink-2) !important; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent-2); }
.interval-set { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.interval-set legend { padding: 0 8px; font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--ink-3); letter-spacing: .04em; }

/* ── INLINE FORM ──────────────────────────────────────────────────── */
.inline-form { display: flex; gap: 10px; }
.inline-form input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; }
.inline-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }

/* ── TOAST ────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md); z-index: 200; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ── POST EDITOR ──────────────────────────────────────────────────── */
.editor-shell { max-width: 1300px; margin: 0 auto; }
.ed-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; margin: -32px -40px 20px;
  background: rgba(247,247,245,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.ed-back { color: var(--ink-3); font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.ed-back:hover { color: var(--accent-2); }
.ed-status { flex: 1; display: flex; align-items: center; gap: 12px; }
.ed-autosave { font-size: 12px; }
.ed-actions { display: flex; gap: 8px; }

.ed-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.ed-main { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.ed-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 76px; }

.ed-title { width: 100%; border: 0; outline: none; padding: 4px 0; font-size: 40px; font-weight: 800; letter-spacing: -.02em; background: transparent; color: var(--ink); font-family: inherit; }
.ed-title::placeholder { color: #CFCFC8; }
.ed-sub { width: 100%; border: 0; outline: none; padding: 2px 0; font-size: 18px; color: var(--ink-3); background: transparent; font-family: inherit; }
.ed-sub::placeholder { color: #CFCFC8; }

.ed-slugbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; font-family: var(--mono); color: var(--muted); }
.slug-prefix { color: var(--muted); flex-shrink: 0; }
.ed-slug { flex: 1; border: 0; outline: none; background: transparent; font-family: var(--mono); font-size: 12.5px; color: var(--ink); padding: 2px 4px; min-width: 0; }
.ed-slug:focus { color: var(--accent-2); }

.cover-drop { border: 2px dashed var(--line); border-radius: var(--r-md); background: var(--bg); cursor: pointer; overflow: hidden; transition: border-color .15s, background .15s; position: relative; min-height: 100px; }
.cover-drop:hover { border-color: var(--accent); background: var(--accent-softer); }
.cover-empty { padding: 44px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cover-empty i { font-size: 28px; color: var(--accent-2); }
.cover-empty span { font-weight: 600; font-size: 14px; color: var(--ink-3); }
.cover-empty small { font-size: 12px; }
.cover-preview { position: relative; }
.cover-preview img { width: 100%; max-height: 380px; object-fit: cover; display: block; }
.cover-remove { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; border: 0; width: 30px; height: 30px; border-radius: 999px; cursor: pointer; }
.cover-remove:hover { background: rgba(0,0,0,.85); }

.ed-body-wrap { border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; overflow: hidden; }
#edToolbar.ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line-soft) !important; padding: 8px 12px; background: var(--bg); position: sticky; top: 66px; z-index: 5; }
#edBody { min-height: 420px; padding: 4px; }
.ql-container.ql-snow { border: 0; font-family: 'Fraunces', Georgia, serif; font-size: 18px; line-height: 1.7; color: #292929; }
.ql-editor { padding: 18px 22px; min-height: 400px; }
.ql-editor.ql-blank::before { color: #B8B8B0; font-style: normal; font-size: 18px; }
.ql-editor h1 { font-family: 'Fraunces', serif; font-weight: 900; font-size: 32px; letter-spacing: -.02em; }
.ql-editor h2 { font-family: 'Fraunces', serif; font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.ql-editor h3 { font-family: 'Fraunces', serif; font-weight: 700; font-size: 22px; }
.ql-editor blockquote { border-left: 3px solid var(--accent) !important; padding-left: 20px !important; font-style: italic; color: var(--ink-2); }
.ql-editor pre.ql-syntax { background: #1A1A1A !important; color: #F5F5F5 !important; padding: 16px; border-radius: 8px; font-family: var(--mono); font-size: 14px; }
.ql-editor code { background: var(--bg); color: var(--accent-2); padding: 1px 6px; border-radius: 4px; font-family: var(--mono); font-size: .85em; }
.ql-editor img { border-radius: 8px; margin: 1em 0; max-width: 100%; }
.ql-snow .ql-tooltip { z-index: 20; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-lbl { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; display: flex; justify-content: space-between; align-items: baseline; }
.field-lbl .small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.small { font-size: 11.5px; }
.field-input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff; color: var(--ink); width: 100%; }
.field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-softer); }
textarea.field-input { font-family: inherit; resize: vertical; }
.counter { font-size: 11px; color: var(--muted); text-align: right; }

/* Side cards */
.side-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.side-card h4 { margin: 0 0 12px; font-size: 12px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.side-card .field { margin-bottom: 8px; }
.side-card .field-lbl { margin-top: 10px; }
.divider { height: 1px; background: var(--line-soft); margin: 14px -18px; }
.chk-row { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.chk-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent-2); flex-shrink: 0; }
.chk-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.chk-sub { margin-top: 2px; }

/* SEO */
.seo-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.seo-head h4 { margin: 0; }
.seo-score { font-family: var(--mono); font-weight: 700; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); min-width: 40px; text-align: center; }
.seo-score.good { background: #E5F5EC; color: var(--success); }
.seo-score.ok { background: #FDF3E1; color: #A76B0C; }
.seo-score.weak { background: #FDECEB; color: var(--danger); }

.serp-preview { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 10px; font-family: arial, sans-serif; }
.serp-url { color: #4d5156; font-size: 12px; margin-bottom: 3px; word-break: break-all; }
.serp-title { color: #1a0dab; font-size: 16px; line-height: 1.3; margin-bottom: 3px; font-weight: 400; }
.serp-desc { color: #545454; font-size: 12.5px; line-height: 1.45; }

.og-picker { display: flex; gap: 6px; }

.danger-card { border-color: #F4CFCF; background: #FDF6F5; }
.danger-card .btn { width: 100%; justify-content: center; }

@media (max-width: 1100px) {
  .ed-grid { grid-template-columns: 1fr; }
  .ed-side { position: static; }
  .ed-topbar { flex-wrap: wrap; }
}

/* ── RESPONSIVE ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 12px; flex-direction: row; align-items: center; overflow-x: auto; }
  .nav { flex-direction: row; overflow-x: auto; }
  .side-foot { display: none; }
  .content { padding: 20px; }
  .row-2 { grid-template-columns: 1fr; }
}
