:root {
  --navy: #071727;
  --navy-800: #0b1f33;
  --gold: #c6a15b;
  --gold-soft: #dfc58e;
  --cream: #f7f4ee;
  --white: #ffffff;
  --text: #142433;
  --muted: #5d6b7a;
  --line: rgba(11, 31, 51, 0.1);
  --danger: #b42318;
  --ok: #0f7b4d;
  --shadow: 0 18px 50px rgba(7, 23, 39, 0.12);
  --radius: 18px;
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(198, 161, 91, 0.18), transparent 34%),
    linear-gradient(160deg, #fbfaf7 0%, #eef3f7 100%);
}

button, input, textarea { font: inherit; }
a { color: var(--gold); }

.auth-page {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.auth-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
  filter: saturate(1.05);
}

.auth-bg__veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(7, 23, 39, 0.82) 0%, rgba(11, 31, 51, 0.72) 45%, rgba(7, 23, 39, 0.78) 100%),
    radial-gradient(circle at 20% 20%, rgba(198, 161, 91, 0.28), transparent 42%);
}

.auth-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(2, 10, 18, 0.45);
  padding: 2.1rem 1.7rem 1.7rem;
  text-align: center;
  backdrop-filter: blur(16px) saturate(140%);
}

.auth-logo {
  width: 148px;
  height: auto;
  margin-inline: auto;
  display: block;
  border-radius: 16px;
  background: #f7f4ee;
  box-shadow: 0 8px 24px rgba(7, 23, 39, 0.12);
}

.auth-card h1 {
  margin: 1rem 0 0.35rem;
  font-size: 1.55rem;
  color: var(--navy-800);
}

.auth-lead {
  margin: 0 0 1.4rem;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 0.95rem;
  text-align: start;
}

.auth-form label {
  display: grid;
  gap: 0.4rem;
  font-weight: 650;
  color: var(--navy-800);
}

.auth-form input,
.panel input,
.panel textarea,
.panel__head input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  background: #fff;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-inline-end: 3rem;
}

.password-toggle {
  position: absolute;
  inset-inline-end: 0.35rem;
  inset-block-start: 50%;
  transform: translateY(-50%);
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle[aria-pressed="true"] {
  color: var(--navy-800);
  background: rgba(198, 161, 91, 0.14);
}

.password-toggle .icon-eye-off[hidden],
.password-toggle .icon-eye[hidden] {
  display: none;
}

.auth-form input:focus,
.panel input:focus,
.panel textarea:focus {
  outline: 2px solid rgba(198, 161, 91, 0.45);
  border-color: var(--gold);
}

.auth-form .btn-primary {
  margin-top: 0.25rem;
  width: 100%;
  padding: 0.9rem 1.15rem;
  font-size: 1rem;
}

.back-link {
  display: inline-block;
  margin-top: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 650;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.back-link:hover {
  color: var(--gold-soft);
}

@media (max-width: 560px) {
  .auth-card {
    padding: 1.6rem 1.2rem 1.35rem;
    border-radius: 22px;
  }

  .auth-logo {
    width: 120px;
  }
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.15rem;
  cursor: pointer;
  font-weight: 700;
}
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: var(--gold-soft); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn:disabled { opacity: 0.6; cursor: wait; }

.form-error, .status-line { color: var(--danger); margin: 0; }
.status-line.is-ok { color: var(--ok); }

.dashboard-page {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--navy-800), var(--navy));
  color: #fff;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.sidebar__brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.sidebar__brand img {
  width: 54px;
  height: auto;
  background: transparent;
}
.sidebar__brand small { display: block; color: var(--gold-soft); margin-top: 0.2rem; }

.sidebar__nav { display: grid; gap: 0.4rem; }
.nav-item {
  text-align: start;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.82);
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 650;
}
.nav-item:hover, .nav-item.is-active {
  background: rgba(198, 161, 91, 0.18);
  color: #fff;
}

.sidebar__footer {
  margin-top: auto;
  display: grid;
  gap: 0.55rem;
}
.sidebar__footer a, .sidebar__footer button {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}

.workspace { padding: 1.25rem 1.4rem 2rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.1rem;
}
.topbar h1 { margin: 0; font-size: 1.55rem; }
.topbar p { margin: 0.35rem 0 0; color: var(--muted); }

.view { display: none; }
.view.is-active { display: block; }

.help-banner, .stat-card, .panel {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.help-banner { padding: 1.25rem 1.35rem; margin-bottom: 1rem; }
.help-banner ol { margin: 0.6rem 0 0; padding-inline-start: 1.2rem; color: var(--muted); }
.help-banner li { margin: 0.35rem 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}
.stats-grid--wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card { padding: 1.1rem 1.2rem; }
.stat-card span { color: var(--muted); display: block; margin-bottom: 0.45rem; }
.stat-card strong { font-size: 1.35rem; }

.split {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  align-items: start;
}
.panel { padding: 1rem; min-height: 70vh; }
.panel__head {
  display: grid;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}
.panel__head h2 { margin: 0; font-size: 1.1rem; }

.articles-list {
  display: grid;
  gap: 0.65rem;
  max-height: calc(100vh - 220px);
  overflow: auto;
  padding-inline-end: 0.2rem;
}

.article-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem;
  background: #fff;
  cursor: pointer;
  text-align: start;
}
.article-item.is-active, .article-item:hover {
  border-color: rgba(198, 161, 91, 0.7);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.12);
}
.article-item img {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 10px;
  background: #e8eef4;
}
.article-item strong { display: block; font-size: 0.92rem; line-height: 1.35; }
.article-item small { color: var(--muted); }

.empty-editor {
  min-height: 50vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  padding: 2rem;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}
.editor-toolbar h2 { margin: 0; }
.muted { color: var(--muted); margin: 0.3rem 0 0; }
.editor-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.image-box {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  padding: 1rem;
  border: 1px dashed rgba(198, 161, 91, 0.55);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(198,161,91,0.08), rgba(255,255,255,0.6));
  margin-bottom: 1rem;
}
.image-box__preview img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  background: #e8eef4;
}
.image-box__help h3 { margin: 0 0 0.4rem; }
.image-box__help p { margin: 0 0 0.7rem; color: var(--muted); }
.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-800);
  color: #fff;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-weight: 700;
}

.lang-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}
.lang-tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  font-weight: 700;
}
.lang-tab.is-active {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
}
.lang-panel { display: none; }
.lang-panel.is-active { display: block; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.field-grid label {
  display: grid;
  gap: 0.35rem;
  font-weight: 650;
  font-size: 0.92rem;
}
.field-grid .full { grid-column: 1 / -1; }
.field-grid textarea { resize: vertical; line-height: 1.55; }

.toast {
  position: fixed;
  inset-inline-start: 50%;
  inset-block-end: 1.2rem;
  transform: translateX(-50%);
  background: var(--navy-800);
  color: #fff;
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.analytics-block {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.3rem 1.35rem;
  margin-bottom: 1rem;
}
.analytics-block--actual {
  background:
    linear-gradient(180deg, rgba(11, 31, 51, 0.05), rgba(255,255,255,0.96) 90px);
}
.analytics-heading h2, .analytics-block h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.analytics-heading--row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.analytics-heading p, .analytics-block > .muted { margin: 0 0 1rem; color: var(--muted); line-height: 1.7; }
.analytics-kicker {
  display: inline-flex;
  margin-bottom: 0.45rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: rgba(198, 161, 91, 0.2);
  color: #6d5424;
  font-size: 0.78rem;
  font-weight: 800;
}
.analytics-kicker--navy { background: rgba(11, 31, 51, 0.08); color: var(--navy-800); }
.analytics-hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.9rem;
}
.hero-metric {
  display: grid;
  gap: 0.35rem;
  padding: 1.25rem 1.35rem;
  border-radius: 18px;
  background: linear-gradient(145deg, #071727, #16324d);
  color: #fff;
}
.hero-metric span { color: rgba(255,255,255,0.72); }
.hero-metric strong { font-size: 2.5rem; line-height: 1; color: #fff; }
.hero-metric small { color: rgba(255,255,255,0.78); line-height: 1.6; }
.hero-metric--soft {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.hero-metric--soft span, .hero-metric--soft small { color: var(--muted); }
.hero-metric--soft strong { color: var(--navy-800); }
.stat-card small { display: block; margin-top: 0.45rem; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.delta {
  display: inline-flex;
  width: fit-content;
  margin-top: 0.55rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: rgba(11, 31, 51, 0.06);
  font-weight: 700;
}
.delta.is-up { background: rgba(15, 123, 77, 0.12); color: var(--ok); }
.delta.is-down { background: rgba(180, 35, 24, 0.1); color: var(--danger); }
.comparison-grid, .distribution-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 0.9rem;
}
.distribution-grid article {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.95rem 1rem;
}
.distribution-grid h3 { margin: 0 0 0.7rem; font-size: 0.98rem; }
.metric-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.metric-list li { display: flex; justify-content: space-between; gap: 0.7rem; color: var(--muted); }
.metric-list strong { color: var(--text); }
.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-top: 1.2rem;
}
.chart-head h3 { margin: 0; }
.chart-legend { display: flex; gap: 0.9rem; color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 99px; display: inline-block; }
.swatch--visitors { background: var(--gold); }
.swatch--visits { background: var(--navy-800); }
.analytics-chart {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.55rem;
  align-items: end;
  min-height: 210px;
  margin-top: 0.4rem;
  padding: 0.8rem 0.4rem 0.2rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(198,161,91,0.08), transparent 42%);
}
.chart-col { display: grid; gap: 0.35rem; justify-items: center; }
.chart-bars { display: flex; align-items: end; justify-content: center; gap: 0.28rem; height: 140px; width: 100%; }
.chart-bar { display: block; width: 14px; border-radius: 8px 8px 3px 3px; min-height: 3px; }
.chart-bar--visitors { background: linear-gradient(180deg, #e2c27a, var(--gold)); }
.chart-bar--visits { background: linear-gradient(180deg, #245072, var(--navy-800)); }
.chart-col strong { font-size: 0.82rem; color: var(--navy-800); }
.chart-col span { font-size: 0.75rem; color: var(--muted); text-align: center; }

@media (max-width: 1100px) {
  .dashboard-page { grid-template-columns: 1fr; }
  .sidebar { position: sticky; inset-block-start: 0; z-index: 20; }
  .sidebar__nav { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .split, .image-box, .stats-grid, .field-grid, .comparison-grid, .distribution-grid, .analytics-hero { grid-template-columns: 1fr; }
  .chart-head, .analytics-heading--row { align-items: start; flex-direction: column; }
  .analytics-chart { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel { min-height: auto; }
  .articles-list { max-height: 320px; }
}
