* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #0e7490;
  --brand-d: #155e75;
  --brand-l: #ecfeff;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --radius: 10px;
}
body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
.err { color: #b91c1c; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ورود */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #0f2027;
  background: linear-gradient(160deg, #0f2027 0%, #16414a 55%, var(--brand-d) 100%);
}
.login-box {
  background: var(--card); padding: 44px 40px; border-radius: 14px; width: 340px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.06);
}
.login-box h1 { color: var(--text); font-size: 22px; font-weight: 600; letter-spacing: .2px; }
.login-box p { color: var(--muted); margin: 6px 0 24px; font-size: 13px; }
.login-box input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; margin-bottom: 14px; text-align: center; font-size: 14px;
  background: #f8fafc;
}
.login-box input:focus { outline: none; border-color: var(--brand); background: #fff; }
.login-box button {
  width: 100%; padding: 11px; background: var(--brand); color: #fff; border: 0;
  border-radius: 8px; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.login-box button:hover { background: var(--brand-d); }

/* چیدمان اصلی */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0b1f2b; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; border-left: 1px solid rgba(255,255,255,.04);
}
.brand {
  font-size: 17px; font-weight: 600; color: #fff; padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: .3px;
}
.sidebar nav { flex: 1; padding: 10px 10px; }
.sidebar nav a {
  display: block; padding: 10px 14px; color: #94a3b8; cursor: pointer; font-size: 13.5px;
  border-radius: 7px; margin-bottom: 2px; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.sidebar nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 16px 22px; font-size: 11px; color: #475569; }

.content { flex: 1; padding: 30px 34px; overflow-y: auto; }
h2.page-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.subtitle { color: var(--muted); margin-bottom: 22px; font-size: 13px; }

/* کارت‌ها */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.stat .num { font-size: 24px; font-weight: 700; color: var(--brand-d); }
.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* جدول */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.panel > summary { font-size: 14.5px; font-weight: 600; cursor: pointer; color: var(--text); list-style: none; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸ "; color: var(--muted); font-size: 11px; }
.panel[open] > summary::before { content: "▾ "; }
.settings-block { padding: 16px 0; border-top: 1px solid var(--line); }
.settings-block:first-of-type { border-top: none; margin-top: 14px; }
.settings-block h4 { font-size: 13px; font-weight: 600; color: var(--brand-d); margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8fafc; text-align: right; padding: 10px; color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* فرم */
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
input, select, textarea {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; font-family: inherit;
  font-size: 13px; flex: 1; min-width: 120px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { width: 100%; min-height: 90px; resize: vertical; margin-bottom: 12px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; font-weight: 500; }
.field { flex: 1; min-width: 160px; margin-bottom: 12px; }
.field > input, .field > select { width: 100%; }

button.btn {
  padding: 9px 18px; background: var(--brand); color: #fff; border: 0; border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
button.btn:hover { background: var(--brand-d); }
button.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
button.btn.ghost:hover { background: var(--brand-l); }
button.btn.sm { padding: 5px 11px; font-size: 12px; font-weight: 500; }
button.btn.danger { background: #dc2626; }
button.btn.danger:hover { background: #b91c1c; }
button.btn.gray { background: #64748b; }
button.btn.gray:hover { background: #475569; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dbeafe; color: #1e40af; }
.badge.sent, .badge.published, .badge.active { background: #dcfce7; color: #166534; }
.badge.rejected, .badge.removed { background: #fee2e2; color: #991b1b; }
.badge.draft, .badge.lead, .badge.low_views, .badge.new { background: #f1f5f9; color: #475569; }
.badge.imported { background: #dcfce7; color: #166534; }
.badge.generating, .badge.generating_image { background: #e0f2fe; color: #0369a1; }

.note {
  background: #f0f9ff; border-right: 3px solid var(--brand); padding: 13px 16px; border-radius: 8px;
  font-size: 12.5px; color: #155e75; margin-bottom: 18px; line-height: 1.8;
}
.hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.hint-inline { font-size: 12px; color: var(--muted); }
.err-inline { color: #991b1b; }
.status-line { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.status-line b { color: var(--text); }

.img-list { display: flex; flex-direction: column; gap: 6px; }
.img-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.img-row a { color: var(--brand-d); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 12px; max-width: 640px; width: 100%; max-height: 82vh;
  overflow-y: auto; padding: 30px; position: relative; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; left: 14px; top: 10px; border: none; background: none; font-size: 22px;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-box h3 { font-size: 17px; margin-bottom: 12px; padding-left: 24px; }
.modal-box h4 { font-size: 14px; margin: 18px 0 8px; color: var(--brand-d); }
.modal-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.8; }
.modal-text { font-size: 13.5px; line-height: 2; white-space: pre-wrap; }

.toast {
  position: fixed; bottom: 24px; left: 24px; background: #0b1f2b; color: #fff;
  padding: 12px 20px; border-radius: 9px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(10px); transition: .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }
