@font-face {
  font-family: "Montserrat114";
  src: url("/admin/assets/Montserrat-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat114";
  src: url("/admin/assets/Montserrat-SemiBold.ttf") format("truetype");
  font-weight: 600 800;
  font-display: swap;
}

@font-face {
  font-family: "KFGQPC";
  src: url("/admin/assets/KFGQPC-Uthmanic-Hafs.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080b08;
  --surface: #101510;
  --surface-raised: #151b15;
  --surface-soft: #0c110c;
  --text: #f2f3ed;
  --muted: #9ca59d;
  --subtle: #687169;
  --accent: #8db38f;
  --accent-strong: #b8d2b9;
  --danger: #e29b96;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.34), 0 2px 8px rgba(0, 0, 0, 0.28);
  font-family: "Montserrat114", "SF Pro Text", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea { font: inherit; }

button { color: inherit; }

button, a, input, textarea { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

h1, h2, h3, p { margin-top: 0; }

h1, h2 { text-wrap: balance; letter-spacing: 0; }

p { text-wrap: pretty; }

.auth-layout {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(141, 179, 143, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(141, 179, 143, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
}

.auth-panel {
  width: min(100%, 460px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 21, 16, 0.96);
  box-shadow: var(--shadow);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 42px;
}

.brand-lockup img {
  object-fit: contain;
  border-radius: 8px;
  outline: 1px solid rgba(255, 255, 255, 0.1);
  outline-offset: -1px;
}

.brand-lockup strong,
.brand-lockup span { display: block; }

.brand-lockup strong { font-size: 17px; line-height: 1.25; }
.brand-lockup span { margin-top: 3px; color: var(--muted); font-size: 13px; }

.brand-lockup.compact { margin-bottom: 30px; }

.auth-step h1 { margin-bottom: 10px; font-size: 27px; line-height: 1.15; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.supporting-copy {
  margin-bottom: 26px;
  color: var(--muted);
  line-height: 1.6;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #cdd2cd;
  font-size: 13px;
  font-weight: 600;
}

input, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  transition-property: border-color, box-shadow, background-color;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

input { padding: 0 13px; }

textarea {
  min-height: 112px;
  padding: 12px 13px;
  line-height: 1.6;
  resize: vertical;
}

input:hover, textarea:hover { border-color: var(--line-strong); }

input:focus, textarea:focus {
  border-color: rgba(141, 179, 143, 0.72);
  background: #0f150f;
  box-shadow: 0 0 0 3px rgba(141, 179, 143, 0.1);
  outline: none;
}

.input-with-icon { position: relative; margin-bottom: 14px; }
.input-with-icon svg { position: absolute; left: 13px; top: 12px; color: var(--muted); }
.input-with-icon input { padding-left: 43px; }
.code-input input { font-variant-numeric: tabular-nums; font-size: 20px; }

.button,
.icon-button,
.nav-item,
.segment,
.image-picker {
  border: 0;
  cursor: pointer;
  transition-property: transform, background-color, color, box-shadow, opacity;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.button:active,
.icon-button:active,
.nav-item:active,
.segment:active,
.image-picker:active { transform: scale(0.96); }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
}

.button:disabled { cursor: wait; opacity: 0.55; }
.button.full { width: 100%; margin-top: 6px; }
.button.primary { background: var(--accent-strong); color: #091009; box-shadow: 0 8px 24px rgba(90, 126, 92, 0.18); }
.button.primary:hover { background: #c8dcc8; }
.button.secondary { background: var(--surface-raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.button.secondary:hover { background: #1a221a; }
.button.quiet { background: transparent; color: var(--muted); }
.button.quiet:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.form-error {
  margin: 16px 0 0;
  padding: 11px 13px;
  border-radius: 6px;
  background: rgba(226, 155, 150, 0.09);
  color: #efb5b0;
  font-size: 13px;
  line-height: 1.5;
}

.admin-layout {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #0b0f0b;
}

.sidebar nav { display: grid; gap: 6px; }

.nav-item {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-item.selected { color: var(--accent-strong); background: rgba(141, 179, 143, 0.1); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.admin-email {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.icon-button:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.workspace {
  width: min(100%, 1500px);
  margin: 0 auto;
  padding: 30px 34px 54px;
}

.workspace-header,
.editor-toolbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.workspace-header { margin-bottom: 24px; }
.workspace-header h1 { margin-bottom: 0; font-size: 28px; line-height: 1.2; }

.connection-status {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(141, 179, 143, 0.58); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metrics article {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), 0 8px 22px rgba(0, 0, 0, 0.16);
}

.metrics article > svg { color: var(--accent); }
.metrics strong, .metrics span { display: block; }
.metrics strong { margin-bottom: 4px; font-size: 20px; font-variant-numeric: tabular-nums; }
.metrics span { color: var(--muted); font-size: 11px; }
.metrics .warning strong { color: #e5c28c; font-size: 13px; }

.editor-section,
.users-section {
  border-radius: 8px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow);
}

.editor-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.segment {
  min-width: 142px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segment:hover { color: var(--text); }
.segment.selected { background: var(--surface-raised); color: var(--accent-strong); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28); }

.publication-meta { display: flex; align-items: center; gap: 10px; color: var(--subtle); font-size: 11px; }
.state-badge { padding: 5px 8px; border-radius: 5px; color: var(--accent-strong); background: rgba(141, 179, 143, 0.1); }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr); }

.content-form { min-width: 0; padding: 24px; border-right: 1px solid var(--line); }
.form-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.form-heading h2, .preview-heading h2, .section-heading h2 { margin-bottom: 5px; font-size: 18px; }
.form-heading p { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.save-indicator { color: var(--subtle); font-size: 11px; white-space: nowrap; }
.save-indicator.dirty { color: #e5c28c; }
.save-indicator.saved { color: var(--accent); }

.field-grid.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { margin-bottom: 17px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.label-row span { color: var(--subtle); font-size: 10px; font-variant-numeric: tabular-nums; }
#content-arabic { font-family: "KFGQPC", "Times New Roman", serif; font-size: 23px; line-height: 1.8; }

.image-picker {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
}

.image-picker:hover { color: var(--text); border-color: rgba(141, 179, 143, 0.5); background: #101610; }
.image-picker span, .image-picker strong, .image-picker small { display: block; text-align: left; }
.image-picker strong { margin-bottom: 4px; color: var(--text); font-size: 13px; }
.image-picker small { color: var(--subtle); font-size: 10px; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 5px; }

.preview-column { min-width: 0; padding: 24px; background: rgba(8, 11, 8, 0.36); }
.preview-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.preview-heading h2 { margin-bottom: 0; }
.preview-heading span { color: var(--subtle); font-size: 11px; }

.phone-preview {
  overflow: hidden;
  border-radius: 8px;
  background: #090c09;
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 22px 60px rgba(0, 0, 0, 0.35);
}

.preview-topbar { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; color: var(--muted); font-size: 11px; box-shadow: inset 0 -1px var(--line); }
.preview-topbar span:first-child { color: var(--text); font-weight: 700; }
.preview-image-wrap { aspect-ratio: 1 / 1; overflow: hidden; background: #050705; }
.preview-image-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; outline: 1px solid rgba(255, 255, 255, 0.1); outline-offset: -1px; }
.preview-copy { max-height: 560px; overflow: auto; padding: 18px; }
.preview-copy h3 { margin: 20px 0 7px; color: var(--accent); font-size: 10px; text-transform: uppercase; }
.preview-copy p { margin-bottom: 0; color: #d7dbd7; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.preview-copy .preview-source { color: var(--muted); font-size: 11px; }
.preview-copy .preview-arabic { margin-top: 18px; color: var(--text); font-family: "KFGQPC", "Times New Roman", serif; font-size: 23px; line-height: 1.9; }

.users-section { padding: 24px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin-bottom: 0; }
.table-wrap { overflow-x: auto; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--subtle); font-size: 10px; text-transform: uppercase; }
td { color: var(--muted); }
td strong { display: block; margin-bottom: 3px; color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
.user-status { color: var(--accent); }
.empty-state { margin: 0; padding: 40px; color: var(--muted); text-align: center; }

.confirm-dialog {
  width: min(calc(100% - 32px), 430px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}

.confirm-dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(6px); }
.confirm-dialog form { padding: 24px; }
.dialog-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 17px; border-radius: 6px; color: var(--accent-strong); background: rgba(141, 179, 143, 0.12); }
.confirm-dialog h2 { margin-bottom: 8px; font-size: 20px; }
.confirm-dialog p { margin-bottom: 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  z-index: 20;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 7px;
  background: #182019;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow);
  font-size: 12px;
  transform: translateY(0);
  opacity: 1;
  transition-property: transform, opacity;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.toast svg { color: var(--accent); }
.toast.exiting { transform: translateY(8px); opacity: 0; }
.toast.error svg { color: var(--danger); }

.is-loading svg { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .content-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .phone-preview { max-width: 520px; margin: 0 auto; }
}

@media (max-width: 760px) {
  .admin-layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand-lockup { margin: 0 auto 0 0; }
  .sidebar .brand-lockup span, .sidebar nav span, .admin-email { display: none; }
  .sidebar nav { display: flex; }
  .nav-item { width: 42px; padding: 0; justify-content: center; }
  .sidebar-footer { margin: 0; padding: 0; border: 0; }
  .workspace { padding: 22px 14px 40px; }
  .workspace-header { align-items: flex-start; }
  .workspace-header h1 { font-size: 23px; }
  .connection-status span:last-child { display: none; }
  .connection-status { min-width: 40px; justify-content: center; padding: 0; }
  .editor-toolbar { align-items: stretch; flex-direction: column; }
  .segmented-control { width: 100%; }
  .segment { min-width: 0; }
  .publication-meta { justify-content: space-between; }
  .content-form, .preview-column, .users-section { padding: 17px; }
  .field-grid.two-columns { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .form-heading { display: block; }
  .save-indicator { display: inline-block; margin-top: 9px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

@media (max-width: 480px) {
  .auth-layout { padding: 12px; }
  .auth-panel { padding: 22px 18px; }
  .metrics { gap: 7px; }
  .metrics article { min-height: 76px; padding: 12px; gap: 9px; }
  .metrics strong { font-size: 17px; }
  .metrics span { font-size: 10px; }
  .segment { font-size: 12px; padding: 0 8px; }
  .segment svg { width: 17px; height: 17px; }
  .publication-meta { font-size: 10px; }
  .preview-column { padding-left: 10px; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
