:root {
  --teal: #00897b; --teal-dark: #00695c; --bg: #f4f7f6; --card: #fff;
  --text: #1b2b28; --muted: #6b7f7a; --border: #dde6e3;
  --draft: #90a4ae; --review: #ffb300; --shariah: #8e24aa;
  --approved: #43a047; --published: #00897b; --archived: #757575;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.pad { padding: 20px; }
.error { color: #c62828; font-size: 13px; min-height: 18px; }

/* login */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--card); padding: 40px; border-radius: 20px; width: 360px;
  box-shadow: 0 8px 40px rgba(0,0,0,.08); text-align: center; }
.login-card h1 { margin: 0 0 4px; }
.login-card input { width: 100%; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; }
.login-card button { width: 100%; margin-top: 16px; }

/* layout */
header { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.studio-tag { background: var(--teal); color: #fff; font-size: 11px; padding: 2px 8px;
  border-radius: 999px; margin-inline-start: 6px; vertical-align: middle; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: none; border: none; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--muted); }
nav button.active, nav button:hover { background: #e0f2f1; color: var(--teal-dark); font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; }
.roles { font-size: 11px; background: #ede7f6; color: #5e35b1; padding: 2px 8px; border-radius: 999px; }

main { display: grid; grid-template-columns: 380px 1fr; gap: 0; min-height: calc(100vh - 57px); }
aside { background: var(--card); border-inline-end: 1px solid var(--border); padding: 14px; overflow-y: auto; }
section { padding: 24px; overflow-y: auto; }

/* tree */
.tree-item { padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 8px; }
.tree-item:hover { background: #f0f5f4; }
.tree-item.selected { background: #e0f2f1; font-weight: 600; }
.tree-indent-1 { margin-inline-start: 16px; }
.tree-indent-2 { margin-inline-start: 32px; }
.tree-indent-3 { margin-inline-start: 48px; }
.tree-head { display:flex; justify-content: space-between; align-items: center; margin: 12px 0 6px; }
.tree-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ar { font-family: 'Amiri', 'Traditional Arabic', serif; }

/* status pills */
.pill { font-size: 10.5px; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.pill.draft { background: var(--draft); } .pill.pedagogical_review { background: var(--review); }
.pill.shariah_review { background: var(--shariah); } .pill.approved { background: var(--approved); }
.pill.published { background: var(--published); } .pill.scheduled { background: #039be5; }
.pill.archived { background: var(--archived); }
.shariah-flag { font-size: 11px; color: var(--shariah); }

/* editor */
.editor-card { background: var(--card); border-radius: 16px; padding: 24px; max-width: 760px;
  box-shadow: 0 2px 12px rgba(0,0,0,.04); }
.editor-card h2 { margin-top: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; }
.field textarea { min-height: 80px; resize: vertical; }
.field [dir=rtl] { font-family: 'Amiri', 'Traditional Arabic', serif; font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.workflow { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }

button.primary { background: var(--teal); color: #fff; border: none; padding: 10px 20px;
  border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
button.primary:hover { background: var(--teal-dark); }
button.ghost { background: #eceff1; color: var(--text); border: none; padding: 9px 16px;
  border-radius: 10px; font-size: 13px; cursor: pointer; }
button.warn { background: #fff3e0; color: #e65100; }
button.publish { background: #00897b; color: white; }
button.approve { background: #43a047; color: white; }
button.shariah { background: #8e24aa; color: white; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
th, td { text-align: start; padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: #f0f5f4; color: var(--muted); font-size: 12px; }

#toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%);
  background: #263238; color: #fff; padding: 12px 22px; border-radius: 10px; font-size: 14px;
  opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 20; }
#toast.show { opacity: 1; }
@media (max-width: 900px) { main { grid-template-columns: 1fr; } aside { border: none; } }
