:root {
  --forest: #173f27; --leaf: #6aa84f; --sage: #e8eee2; --cream: #f6f3eb; --paper: #fbfaf6;
  --ink: #1d2a21; --muted: #66736a; --line: #e0e5d8; --danger: #c0392b; --warn: #b7791f;
  --radius: 16px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.7 'Alexandria', Tahoma, sans-serif; color: var(--ink); background: var(--cream); }
a { color: var(--forest); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .6em; color: var(--forest); line-height: 1.4; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 1.4em; }
.muted { color: var(--muted); font-size: .9rem; margin: 0 0 1em; }
img { max-width: 100%; display: block; }

/* Layout */
.side { position: fixed; inset: 0 0 0 auto; width: 250px; background: var(--forest); color: #dce7d6; display: flex; flex-direction: column; padding: 22px 16px; z-index: 30; }
.side-logo { background: var(--paper); border-radius: 14px; padding: 10px; margin-bottom: 24px; }
.side-logo img { height: 52px; margin: 0 auto; }
.side nav { display: grid; gap: 4px; }
.side nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: #dce7d6; transition: .2s; }
.side nav a:hover { background: rgba(255,255,255,.08); }
.side nav a.on { background: var(--leaf); color: #fff; }
.side svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.side-foot a { color: #b7c8b0; font-size: .9rem; }
.main { margin-right: 250px; min-height: 100vh; padding: 0 32px 60px; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 18px 0; margin-bottom: 18px; background: var(--cream); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { margin: 0; flex: 1; }
.publish-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.menu-btn { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; width: 42px; height: 42px; font-size: 1.2rem; cursor: pointer; }

/* Components */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid2 > .card { margin-bottom: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--forest); font: 500 .92rem 'Alexandria', sans-serif; cursor: pointer; transition: .2s; }
.btn:hover { border-color: var(--leaf); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--forest); border-color: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--leaf); border-color: var(--leaf); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; padding: 13px; }
.link-btn { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 8px 0; margin-top: 10px; }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; color: var(--forest); font-size: .7rem; }
.icon-btn:disabled { opacity: .3; }
.pill { padding: 6px 14px; border-radius: 999px; font-size: .85rem; }
.pill-ok { background: var(--sage); color: var(--forest); }
.pill-warn { background: #fdf3e1; color: var(--warn); }
.pill-run { background: #e3f0fb; color: #1d5f99; }
.tag { color: var(--leaf); font-weight: 500; }
.err-text { color: var(--danger); }
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; background: var(--sage); color: var(--forest); }
.flash-err { background: #fbe9e7; color: var(--danger); }
.flash-warn { background: #fdf3e1; color: var(--warn); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--muted); }
.stat strong { display: block; font-size: 1.7rem; color: var(--forest); direction: ltr; text-align: right; }
.quick { display: grid; gap: 10px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .muted { margin: 0; }

.list { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 10px 10px; }
.row > img { width: 86px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-main small { color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions form { display: flex; gap: 4px; margin: 0; }

/* Forms */
.form .field, .field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 500; margin-bottom: 6px; font-size: .92rem; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; font: inherit; background: var(--paper); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(106,168,79,.35); border-color: var(--leaf); }
textarea { resize: vertical; }
.checks { display: grid; gap: 8px; margin: 6px 0 10px; }
.checks label { display: flex; gap: 10px; align-items: center; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 0; background: var(--cream); }
.narrow { max-width: 480px; }

.file-btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 16px; border-radius: 12px; border: 1px dashed var(--leaf); color: var(--forest); cursor: pointer; background: var(--sage); font-size: .9rem; }
.file-btn input { display: none; }
.file-btn-lg { width: 100%; padding: 22px; font-weight: 500; }
.img-pick { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.img-pick img { width: 160px; height: 110px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.noimg { width: 160px; height: 110px; display: grid; place-items: center; border-radius: 12px; background: var(--sage); color: var(--muted); font-size: .85rem; }
.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.img-card { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--sage); cursor: grab; }
.img-card:first-child { outline: 3px solid var(--leaf); }
.img-card:first-child::after { content: 'الغلاف'; position: absolute; top: 8px; right: 8px; background: var(--leaf); color: #fff; padding: 2px 10px; border-radius: 999px; font-size: .75rem; }
.img-card.dragging { opacity: .4; }
.img-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; pointer-events: none; }
.img-tools { display: flex; justify-content: space-between; gap: 6px; padding: 8px; background: #fff; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .78rem; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip-danger { color: var(--danger); }
.chip-danger input { margin: 0; }
.img-card:has(.chip-danger input:checked) img { opacity: .3; }
.upload-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.upload-list img { width: 90px; height: 68px; object-fit: cover; border-radius: 8px; }
.icons { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt { cursor: pointer; }
.icon-opt input { position: absolute; opacity: 0; }
.icon-opt img { width: 50px; height: 50px; padding: 11px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.icon-opt input:checked + img { border-color: var(--leaf); background: var(--sage); outline: 2px solid var(--leaf); }

/* Article editor */
.post-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.post-grid aside { position: sticky; top: 90px; }
.input-lg { font-size: 1.15rem !important; font-weight: 500; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--sage); }
.md-toolbar button, .md-img { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 12px; font: inherit; font-size: .85rem; cursor: pointer; color: var(--forest); }
.md-toolbar button:hover, .md-img:hover { border-color: var(--leaf); }
.md-img input { display: none; }
.md-img.busy { opacity: .5; pointer-events: none; }
.md-body { border-radius: 0 0 12px 12px !important; font-size: 1rem !important; line-height: 1.9 !important; min-height: 420px; }
.hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 6px; }
.switch { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.btn-block + .btn-block, .form-actions + .btn-block { margin-top: 10px; }

/* SEO */
.hint-ok { color: var(--leaf); }
.hint-warn { color: var(--warn); }
.checks-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.chk { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 10px; font-size: .9rem; align-items: center; }
.chk a { white-space: nowrap; font-weight: 500; }
.chk-err { background: #fbe9e7; color: var(--danger); }
.chk-warn { background: #fdf3e1; color: #8a5a12; }
.chk-info { background: #eef4fb; color: #1d4f7c; }
.tool-links { display: flex; flex-wrap: wrap; gap: 8px; }
.serp { display: grid; gap: 2px; padding: 16px 18px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-family: Arial, sans-serif; }
.serp small { color: var(--muted); font-family: 'Alexandria', sans-serif; margin-bottom: 6px; }
.serp-url { color: #202124; font-size: .85rem; }
.serp-title { color: #1a0dab; font-size: 1.2rem; line-height: 1.4; }
.serp-desc { color: #4d5156; font-size: .9rem; line-height: 1.6; }
.sub-card { padding: 16px; border: 1px dashed var(--line); border-radius: 12px; margin-bottom: 14px; }
.sub-card h3 { margin-top: 0; }
.switch.danger { color: var(--danger); }
.seo-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 6px 0 14px; background: var(--paper); }
.seo-box summary { cursor: pointer; font-weight: 500; color: var(--forest); }
.seo-box[open] summary { margin-bottom: 12px; }

.admin-video { width: 100%; max-width: 760px; border-radius: 14px; background: #000; margin-bottom: 18px; display: block; }
.noimg.wide { width: 100%; max-width: 760px; height: 200px; margin-bottom: 18px; }

/* Auth */
.guest-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 80% 0%, #e3ecda, transparent 70%), var(--cream); }
.auth { width: min(420px, 100%); padding: 34px; box-shadow: 0 30px 60px -30px rgba(23,63,39,.35); }
.auth-logo { height: 70px; margin: 0 auto 18px; }
.auth h2 { text-align: center; }

@media (max-width: 900px) {
  .side { transform: translateX(100%); transition: transform .25s; }
  .side-open .side { transform: none; box-shadow: -20px 0 40px rgba(0,0,0,.2); }
  .main { margin-right: 0; padding: 0 16px 40px; }
  .menu-btn { display: block; }
  .grid2, .stats { grid-template-columns: 1fr 1fr; }
  .post-grid { grid-template-columns: 1fr; }
  .post-grid aside { position: static; }
  .row { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-end; }
}
@media (max-width: 600px) {
  .grid2, .stats { grid-template-columns: 1fr; }
  .top h1 { font-size: 1.1rem; }
}
