/* =========================================================
 * شاي بكر — ستايل لوحة الإدارة
 * الترتيب:
 *   1) المتغيرات والأزرار         :root / Buttons
 *   2) شاشة الدخول                Login
 *   3) هيكل اللوحة والترويسة      App shell / Header
 *   4) البطاقات والرسوم           Stats / Charts
 *   5) صفحة الزوار                Visitors
 *   6) الطلبات وصفحة الطلب        Orders / Order detail
 *   7) الجوال                     @media في آخر الملف
 * ========================================================= */

:root {
  --tea: #633a11;
  --tea-deep: #2a1810;
  --tea-mid: #8b5a2b;
  --sand: #f3ebe0;
  --sand-2: #e8d9c0;
  --sand-bar: #ead4bd;
  --gold: #c4a35a;
  --line: rgba(74, 50, 34, 0.12);
  --ink: #1a120c;
  --muted: #6a5240;
  --ok: #1f7a3f;
  --ok-bg: #e8f6ee;
  --err: #b42318;
  --err-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fff6e0;
  --wa: #128c7e;
  --white: #fffdf9;
  --radius: 1.15rem;
  --shadow: 0 16px 40px rgba(42, 24, 16, 0.12);
  --font-display: "Reem Kufi", "Tajawal", sans-serif;
  --font-body: "Tajawal", "Segoe UI", Tahoma, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(196, 163, 90, 0.14), transparent 55%),
    linear-gradient(180deg, #f7f1e8, #efe4d4 50%, #f7f1e8);
  line-height: 1.65;
  font-size: 1.02rem;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

[hidden],
.is-hidden {
  display: none !important;
}

button,
input {
  font: inherit;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--tea);
  font-weight: 700;
}

code {
  font-size: 0.88em;
  background: rgba(92, 58, 30, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 0.3rem;
}

/* Buttons — نفس روح موقع العملاء */
.btn {
  border: 1.5px solid transparent;
  border-radius: 999px;
  min-height: 2.85rem;
  padding: 0.5rem 1.25rem;
  font-weight: 800;
  font-size: 0.98rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary {
  background: var(--tea);
  color: #fff8ef;
  border-color: var(--tea);
  box-shadow: 0 10px 22px rgba(99, 58, 17, 0.22);
}

.btn-ghost {
  background: rgba(255, 253, 249, 0.7);
  color: var(--tea-deep);
  border-color: rgba(99, 58, 17, 0.18);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--white);
}

.btn-ok {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

.btn-delete {
  background: #fde8e6;
  color: #9b1c1c;
  border: 2px solid #d92d20;
  font-weight: 800;
}

.btn-delete:hover:not(:disabled) {
  background: #f97066;
  color: #fff;
  border-color: #d92d20;
}

.btn-err {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}

.btn-wa {
  background: var(--wa);
  color: #fff;
  border-color: var(--wa);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Login */
.login-view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(196, 163, 90, 0.18), transparent 55%),
    linear-gradient(180deg, #f7f1e8, #ead4bd 50%, #f7f1e8);
}

.login-card {
  width: min(400px, 100%);
  background: var(--white);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  padding: 1.7rem 1.35rem 1.45rem;
  display: grid;
  gap: 0.7rem;
  text-align: center;
  border: 1px solid rgba(99, 58, 17, 0.1);
}

.login-logo {
  width: 88px;
  margin-inline: auto;
}

.login-card h1 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.45rem;
  font-weight: 800;
  color: #4a2b19;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 0.3rem;
  text-align: start;
}

.field span {
  font-weight: 700;
  color: var(--tea-deep);
  font-size: 0.92rem;
}

.field input {
  width: 100%;
  min-height: 3rem;
  border: 1.5px solid rgba(99, 58, 17, 0.18);
  border-radius: 0.95rem;
  padding: 0.65rem 0.9rem;
  background: #fffaf3;
  outline: none;
}

.field input:focus {
  border-color: var(--tea-mid);
  box-shadow: 0 0 0 3px rgba(99, 58, 17, 0.1);
}

.login-error {
  color: var(--err);
  font-weight: 700;
  margin: 0;
}

.pin-field {
  position: relative;
  display: grid;
}

.pin-field input {
  width: 100%;
  min-height: 3rem;
  border: 1.5px solid rgba(99, 58, 17, 0.18);
  border-radius: 0.95rem;
  /* مساحة العين على اليمين */
  padding: 0.65rem 2.35rem 0.65rem 0.85rem;
  background: #fffaf3;
  outline: none;
  letter-spacing: 0.2em;
  font-size: 1.05rem;
  font-weight: 800;
}

.pin-field input:focus {
  border-color: var(--tea-mid);
  box-shadow: 0 0 0 3px rgba(99, 58, 17, 0.1);
}

.pin-field input::placeholder {
  letter-spacing: 0.22em;
  color: rgba(74, 43, 25, 0.35);
  font-weight: 800;
}

/* الدخول بالرمز المؤقت — يختفي بعد ضبط الحماية */
.login-alt {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 2.4rem;
}

.pin-block {
  display: grid;
  gap: 0.55rem;
  padding-top: 0.35rem;
  border-top: 1px dashed rgba(99, 58, 17, 0.18);
}

.login-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--warn);
}

.login-note code {
  font-size: 0.76rem;
  word-break: break-all;
}

.conn-alert.is-warn {
  background: var(--warn-bg);
  border-color: rgba(154, 103, 0, 0.28);
}

.conn-alert.is-warn .setup-status {
  color: #7a5200;
}

.pin-eye {
  position: absolute;
  right: 0.4rem;
  left: auto;
  top: 50%;
  transform: translateY(-50%);
  width: 1.7rem;
  height: 1.7rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: rgba(74, 43, 25, 0.55);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.pin-eye:hover {
  background: rgba(99, 58, 17, 0.06);
  color: var(--tea-deep);
}

.pin-eye svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

/* App shell */
.app-view {
  min-height: 100svh;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem clamp(0.75rem, 2.5vw, 1.75rem);
  min-height: 4.85rem;
  background: #ead4bd;
  border-bottom: 1px solid rgba(74, 50, 34, 0.1);
}

.admin-brand {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
  padding: 0.15rem 0.2rem;
  margin: 0;
  border-radius: 0.85rem;
  cursor: pointer;
  text-align: right;
  font: inherit;
  color: inherit;
}

.admin-brand:hover {
  background: rgba(255, 253, 249, 0.35);
}

.admin-brand:focus-visible {
  outline: 2px solid rgba(99, 58, 17, 0.35);
  outline-offset: 2px;
}

.admin-brand img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  flex-shrink: 0;
}

.brand-mark {
  position: relative;
  flex-shrink: 0;
  width: 68px;
  height: 68px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.status-dot {
  position: absolute;
  top: 1px;
  inset-inline-start: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c4b5a5;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(44, 26, 16, 0.12);
}

.status-dot.is-ok {
  background: #1f9d55;
  box-shadow: 0 0 0 1px rgba(31, 157, 85, 0.25);
}

.status-dot.is-bad {
  background: #d92d20;
  box-shadow: 0 0 0 1px rgba(217, 45, 32, 0.25);
}

.admin-brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  min-width: 0;
}

.admin-brand strong {
  display: block;
  color: #4a2b19;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.2;
  font-family: var(--font-body);
}

.setup-status {
  margin: 0;
  font-weight: 700;
  color: var(--tea-deep);
  flex: 1;
  min-width: 0;
}

.setup-status.is-ok {
  color: var(--ok);
}

.setup-status.is-bad {
  color: var(--err);
}

.conn-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  background: var(--err-bg);
  border: 1px solid rgba(180, 35, 24, 0.22);
}

.conn-alert .setup-help {
  flex-basis: 100%;
  margin-top: 0.15rem;
  padding: 0;
  background: transparent;
  border: 0;
}

.setup-help {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
  background: var(--sand-2);
  border: 1px solid var(--line);
  font-size: 0.94rem;
}

.setup-help ol {
  margin: 0.4rem 0 0.55rem;
  padding-inline-start: 1.25rem;
}

.setup-help a {
  text-decoration: underline;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  align-items: center;
  margin-inline-start: auto;
}

.admin-actions .btn {
  min-height: 2.85rem;
  min-width: 6.2rem;
  padding: 0.5rem 1.2rem;
  font-size: 0.98rem;
  font-weight: 800;
}

.admin-actions .btn-refresh {
  background: var(--tea);
  color: #fff8ef;
  border-color: var(--tea);
  box-shadow: 0 8px 18px rgba(99, 58, 17, 0.2);
}

.admin-actions .btn-refresh:hover:not(:disabled) {
  background: #4a2b19;
  border-color: #4a2b19;
}

.admin-actions .btn-logout {
  background: transparent;
  color: var(--err);
  border-color: rgba(180, 35, 24, 0.35);
}

.admin-actions .btn-logout:hover:not(:disabled) {
  background: var(--err-bg);
}

.admin-main {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 0;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
}

.conn-alert,
.order-detail-view,
.stats-panel,
.visitors-panel,
.orders-panel {
  width: min(1100px, calc(100% - 1.5rem));
  margin-inline: auto;
}

/* يمنع تمدد عناصر الشبكة أكثر من الشاشة على الجوال */
.admin-main > *,
#dashboardView > * {
  min-width: 0;
}

.conn-alert {
  margin-top: 1rem;
}

.stats-panel,
.visitors-panel,
.orders-panel {
  margin-top: 1.15rem;
}

.panel {
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(99, 58, 17, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(42, 24, 16, 0.07);
  padding: 1rem 1.05rem 1.15rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(99, 58, 17, 0.1);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: #4a2b19;
  font-family: var(--font-body);
}

.range-tabs,
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  background: rgba(99, 58, 17, 0.06);
  padding: 0.28rem;
  border-radius: 999px;
  border: 0;
}

.range-tab,
.filter-tab {
  border: 0;
  background: transparent;
  min-height: 2.1rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-weight: 800;
  color: var(--tea-deep);
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.range-tab.is-on,
.filter-tab.is-on {
  background: var(--tea);
  color: #fff8ef;
}

.filter-tab.has-new {
  position: relative;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.28rem;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 248, 239, 0.95);
}

.filter-tab.is-on .filter-badge {
  background: #ff5a4f;
  box-shadow: 0 0 0 2px rgba(99, 58, 17, 0.25);
}

.filter-badge[hidden] {
  display: none !important;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.stat-card {
  background: linear-gradient(180deg, #fffdf8, #f6ecdc);
  border: 1px solid rgba(99, 58, 17, 0.1);
  border-radius: 1rem;
  padding: 0.9rem 0.95rem;
  display: grid;
  gap: 0.2rem;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--tea);
}

.stat-card.is-visit::before {
  background: #8b5a2b;
}
.stat-card.is-orders::before {
  background: #633a11;
}
.stat-card.is-pending::before {
  background: #9a6700;
}
.stat-card.is-money::before {
  background: #1f7a3f;
}
.stat-card.is-total::before {
  background: #c4a35a;
}

/* مسار الحجز — أين يتوقف الزوار */
.funnel-list {
  display: grid;
  gap: 0.4rem;
}

.funnel-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
}

.funnel-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--tea-deep);
}

.funnel-bar {
  height: 0.85rem;
  border-radius: 999px;
  background: rgba(99, 58, 17, 0.09);
  overflow: hidden;
}

.funnel-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b5a2b, #633a11);
  min-width: 2px;
}

.funnel-value {
  font-weight: 800;
  color: var(--tea);
  text-align: end;
  font-size: 0.92rem;
}

.funnel-card .funnel-list {
  margin-top: 0.35rem;
}

@media (max-width: 430px) {
  .funnel-row {
    grid-template-columns: 6rem 1fr 2rem;
    gap: 0.4rem;
  }

  .funnel-label {
    font-size: 0.78rem;
  }
}

/* صفحة الزوار */
.visitors-lead {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.visitors-grid {
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  margin-bottom: 1rem;
}

.stat-card span {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 700;
}

.stat-card strong {
  font-size: clamp(1.25rem, 2.4vw, 1.55rem);
  color: var(--tea-deep);
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-card em {
  font-style: normal;
  font-size: 0.78rem;
  color: #8a7363;
  font-weight: 600;
}

.period-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 1rem;
  background: #f7f1e8;
  border: 1px solid rgba(99, 58, 17, 0.1);
}

.period-btn {
  min-width: 6.5rem;
  font-size: 0.92rem;
}

.period-btn:disabled {
  opacity: 0.4;
}

.period-label-wrap {
  display: grid;
  gap: 0.15rem;
  justify-items: center;
  text-align: center;
}

.period-label-wrap strong {
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  font-weight: 800;
  color: #4a2b19;
}

.period-today {
  border: 0;
  background: transparent;
  color: var(--tea);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stat-grid-hero {
  grid-template-columns: 1.35fr 1fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.stat-card.is-hero {
  background: linear-gradient(145deg, #633a11, #4a2b19);
  color: #fff8ef;
  border-color: transparent;
  box-shadow: 0 12px 28px rgba(99, 58, 17, 0.22);
}

.stat-card.is-hero::before {
  display: none;
}

.stat-card.is-hero span,
.stat-card.is-hero em {
  color: rgba(255, 248, 239, 0.82);
}

.stat-card.is-hero strong {
  color: #fffdf9;
  font-size: clamp(1.45rem, 3vw, 1.9rem);
}

@media (max-width: 900px) {
  .stat-grid-hero {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card.is-hero {
    grid-column: 1 / -1;
  }

  .period-nav {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .period-btn {
    width: 100%;
  }
}

.charts-grid {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.chart-card {
  background: #fffdf9;
  border: 1px solid rgba(99, 58, 17, 0.1);
  border-radius: 1rem;
  padding: 0.95rem 1rem 1rem;
  box-shadow: 0 8px 20px rgba(42, 24, 16, 0.05);
}

.chart-card.chart-wide {
  grid-column: 1 / -1;
}

.chart-card h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: #4a2b19;
}

.chart-hint {
  margin: 0.2rem 0 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.chart-canvas-wrap {
  position: relative;
  height: 220px;
  overflow: hidden;
}

/* Chart.js يكتب عرضاً مباشراً على العنصر — نمنعه من تجاوز الشاشة */
.chart-canvas-wrap canvas {
  max-width: 100% !important;
}

.chart-canvas-wide {
  height: 260px;
}

.chart-empty {
  margin: 0;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

.bar-list {
  display: grid;
  gap: 0.45rem;
}

.bar-row {
  display: grid;
  gap: 0.2rem;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--tea-deep);
}

.bar-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(92, 58, 30, 0.1);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--tea);
}

.empty-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Compact order rows */
.orders-list {
  display: grid;
  gap: 0.85rem;
}

body.admin-detail-open #dashboardView {
  display: none !important;
}

body.admin-detail-open #orderDetailView {
  display: grid !important;
}

.admin-page {
  display: none;
}

.admin-page.is-page-on,
.admin-page:not([hidden]) {
  display: block;
}

.admin-welcome.is-page-on,
.admin-welcome:not([hidden]) {
  display: block;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-nav h2 {
  margin: 0;
}

.orders-head {
  align-items: flex-start;
}

.orders-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-end;
}

.orders-lead {
  margin: -0.25rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.ext-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.1rem 0.5rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(99, 58, 17, 0.1);
  color: var(--tea);
}

.order-row {
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0;
  border: 1.5px solid rgba(99, 58, 17, 0.14);
  border-right: 5px solid rgba(99, 58, 17, 0.22);
  border-radius: 1rem;
  background: #fffdf9;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(42, 24, 16, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.order-row.tone-b {
  background: #f3ebe0;
}

.order-row.is-pending {
  border-right-color: #c9a227;
  background: #fff8e8;
}

.order-row.is-pending.tone-b {
  background: #fff1d4;
}

.order-row.is-accepted {
  border-right-color: #1f7a3f;
  background: #f3faf5;
}

.order-row.is-accepted.tone-b {
  background: #e7f5ec;
}

.order-row.is-rejected {
  border-right-color: #b42318;
  background: #fdf4f3;
}

.order-row.is-rejected.tone-b {
  background: #f8e8e6;
}

.order-row.is-open {
  border-right-color: #c9a227;
  background: #fff8e8;
}

.order-row.is-resolved {
  border-right-color: #1f7a3f;
  background: #f3faf5;
}

.issue-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--tea-mid);
}

.order-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(42, 24, 16, 0.1);
}

.order-row-main {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 0.25rem;
  padding: 0.95rem 1rem;
}

.order-row-main:hover {
  background: transparent;
}

.order-row-side {
  flex-shrink: 0;
  display: grid;
  gap: 0.35rem;
  justify-items: end;
  align-content: center;
  padding: 0.75rem 0.9rem;
  border-inline-start: 1px solid var(--line);
  background: #fcfaf7;
  min-width: 8.5rem;
}

.order-row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm {
  min-height: 2.15rem;
  padding: 0.3rem 0.75rem;
  font-size: 0.86rem;
  border-radius: 999px;
}

.booking-card {
  text-align: right;
  width: min(100%, 28rem);
}

.booking-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.booking-form .field {
  text-align: start;
}

.booking-form select,
.booking-form input {
  width: 100%;
  min-height: 2.85rem;
  border: 1.5px solid rgba(99, 58, 17, 0.18);
  border-radius: 0.85rem;
  padding: 0.55rem 0.85rem;
  background: #fffaf3;
  font: inherit;
}

.order-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.order-row-title strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--tea-deep);
}

.order-row-meta,
.order-row-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}

.order-row-total {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--tea-deep);
  white-space: nowrap;
}

.order-row-hint {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.order-row-hint.pending-hint {
  color: #9a6700;
}

.order-decide-hint {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #6b5344;
  background: #fff6e0;
  border-bottom: 1px solid rgba(154, 103, 0, 0.18);
}

.order-detail-view {
  display: grid;
  gap: 0.75rem;
}

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.order-delete-box {
  margin: 0.85rem 1rem 1.1rem;
  padding: 0;
  border: none;
  background: transparent;
  display: grid;
}

.order-delete-box .btn-delete {
  width: 100%;
  min-height: 2.85rem;
  font-size: 1rem;
}

.detail-panel {
  padding: 0;
  overflow: visible;
}

.detail-panel .order-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.95rem 1rem;
  background: var(--sand-2);
  border-bottom: 1px solid var(--line);
}

.detail-panel .order-top h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--tea-deep);
}

.detail-panel .order-top p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

#dashboardView {
  display: grid;
  gap: 0;
}

/* هيرو الإدارة — شاشة واحدة بدون سكرول */
.admin-welcome {
  position: relative;
  width: 100%;
  background: #ead4bd;
  overflow: hidden;
  height: calc(100svh - 4.85rem);
  max-height: calc(100svh - 4.85rem);
}

.welcome-landing {
  position: relative;
  isolation: isolate;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #ead4bd;
  overflow: hidden;
}

.welcome-landing::before {
  content: "";
  display: block;
  position: absolute;
  inset: -20% -10% -30% -15%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      ellipse 55% 70% at 0% 35%,
      rgba(255, 236, 190, 0.75) 0%,
      rgba(255, 220, 160, 0.3) 32%,
      transparent 68%
    ),
    conic-gradient(
      from 210deg at -5% 28%,
      transparent 0deg,
      rgba(255, 244, 210, 0.5) 8deg,
      transparent 16deg,
      transparent 28deg,
      rgba(255, 236, 190, 0.4) 36deg,
      transparent 48deg,
      transparent 360deg
    );
  mix-blend-mode: soft-light;
  opacity: 0.95;
  animation: adminSunGlow 10s ease-in-out infinite alternate;
}

.welcome-landing::after {
  content: "";
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(105deg, rgba(255, 248, 230, 0.42) 0%, transparent 44%),
    radial-gradient(ellipse 42% 55% at 100% 70%, rgba(196, 163, 90, 0.16), transparent 70%);
  mix-blend-mode: overlay;
  opacity: 0.9;
}

@keyframes adminSunGlow {
  0% { transform: rotate(-5deg) translateX(0); opacity: 0.82; }
  100% { transform: rotate(-2deg) translateX(1.2%); opacity: 1; }
}

@keyframes adminFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes adminFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-intro {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 320px);
  align-items: center;
  gap: clamp(1rem, 3vw, 2rem);
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 0.75rem 0 0.5rem;
  flex: 1;
  min-height: 0;
  animation: adminFadeUp 0.45s ease both;
}

.welcome-brand-block {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(0.75rem, 1.8vw, 1.25rem);
  min-width: 0;
}

.welcome-logo-wrap {
  flex-shrink: 0;
  filter: drop-shadow(0 10px 24px rgba(42, 24, 16, 0.16));
  animation: adminFloat 5.5s ease-in-out infinite;
}

.welcome-logo {
  display: block;
  width: clamp(120px, 18vw, 180px);
  height: auto;
  object-fit: contain;
}

.welcome-copy {
  display: grid;
  gap: 0.15rem;
  text-align: start;
  justify-items: start;
  max-width: 24rem;
  min-width: 0;
}

.welcome-name {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1.7rem, 3.5vw, 2.45rem);
  font-weight: 800;
  line-height: 1.15;
  color: #4a2b19;
}

.welcome-copy h1 {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  font-weight: 800;
  color: #2a1810;
}

.welcome-tag {
  margin: 0.1rem 0 0;
  font-size: clamp(0.92rem, 1.5vw, 1.05rem);
  color: #4a2b19;
  font-weight: 700;
  opacity: 0.9;
}

.welcome-sub {
  margin: 0.05rem 0 0;
  font-size: 0.88rem;
  color: #6a5240;
  font-weight: 500;
}

.welcome-side {
  position: relative;
  display: grid;
  gap: 0.65rem;
  justify-items: stretch;
  align-content: center;
  width: min(100%, 18rem);
  justify-self: end;
  min-height: 0;
}

.welcome-art-wrap {
  width: 100%;
  max-height: 28vh;
  line-height: 0;
  pointer-events: none;
  filter: drop-shadow(0 12px 28px rgba(42, 24, 16, 0.14));
  animation: adminFloat 6.5s ease-in-out infinite;
  animation-delay: 0.4s;
  overflow: hidden;
}

.welcome-art {
  width: 100%;
  height: 100%;
  max-height: 28vh;
  display: block;
  object-fit: contain;
  object-position: center bottom;
  mask-image: linear-gradient(180deg, #000 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 50%, transparent 100%);
}

.welcome-choices {
  display: grid;
  gap: 0.55rem;
  position: relative;
  z-index: 1;
}

.welcome-choice {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 3rem;
  padding: 0.65rem 1.1rem;
  display: grid;
  gap: 0.1rem;
  justify-items: stretch;
  text-align: center;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.welcome-choice:hover { transform: translateY(-2px); }

.welcome-choice.is-primary {
  background: #633a11;
  color: #fff8ef;
  box-shadow: 0 10px 22px rgba(99, 58, 17, 0.24);
}

.welcome-choice.is-primary strong,
.welcome-choice.is-primary span { color: #fff8ef; }

.welcome-choice.is-secondary {
  background: rgba(255, 253, 249, 0.72);
  color: #4a2b19;
  border: 1.5px solid rgba(99, 58, 17, 0.28);
  backdrop-filter: blur(6px);
}

.welcome-choice strong {
  font-size: 1.05rem;
  font-weight: 800;
}

.welcome-choice > span:last-child {
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 0.9;
}

.welcome-choice.is-secondary > span:last-child { color: #6a5240; }

.welcome-choice.is-visitors {
  background: #f1e2c6;
  color: #4a2b19;
  border: 1.5px solid rgba(196, 163, 90, 0.75);
}

.welcome-choice.is-visitors > span:last-child { color: #6a5240; }

.welcome-choice.is-issues {
  background: #fdf1e0;
  color: #7a3a12;
  border: 1.5px solid rgba(201, 162, 39, 0.6);
}

.welcome-choice.is-issues > span:last-child { color: #8a6a3d; }

.welcome-end-line {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 10px;
  flex-shrink: 0;
  margin-top: auto;
  background: linear-gradient(180deg, #3a2418 0%, #4a3222 45%, #2a1810 100%);
  box-shadow: 0 -2px 0 rgba(74, 50, 34, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  .welcome-landing::before,
  .welcome-logo-wrap,
  .welcome-art-wrap,
  .welcome-intro {
    animation: none !important;
  }
}

@media (max-height: 720px) {
  .welcome-art-wrap { display: none; }
  .welcome-logo { width: clamp(100px, 14vw, 140px); }
  .welcome-sub { display: none; }
}


.stats-panel,
.orders-panel {
  scroll-margin-top: 5.5rem;
}

.admin-page {
  display: none;
}

.admin-page.is-page-on {
  display: block;
}

.admin-welcome.is-page-on {
  display: block;
}

body:has(#adminHome.is-page-on) {
  overflow: hidden;
}

body:has(#adminHome.is-page-on) .admin-main {
  padding-bottom: 0;
}

.admin-page[hidden],
.admin-welcome[hidden] {
  display: none !important;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-nav h2 { margin: 0; }

.orders-head { align-items: flex-start; }

.orders-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  justify-content: flex-end;
}

.orders-lead {
  margin: -0.25rem 0 0.85rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.ext-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.55rem;
  padding: 0.1rem 0.5rem;
  border-radius: 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(99, 58, 17, 0.1);
  color: var(--tea);
}

.order-phone {
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 700;
  color: var(--tea-deep);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.85rem;
  padding: 0.2rem 0.75rem;
  border-radius: 0.45rem;
  font-size: 0.84rem;
  font-weight: 800;
}

.status-pill.pending { background: var(--warn-bg); color: var(--warn); }
.status-pill.accepted { background: var(--ok-bg); color: var(--ok); }
.status-pill.rejected { background: var(--err-bg); color: var(--err); }
.status-pill.open { background: var(--warn-bg); color: var(--warn); }
.status-pill.resolved { background: var(--ok-bg); color: var(--ok); }

.order-section {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.order-section-title {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
}

.order-kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
}

.order-kv .item {
  display: grid;
  gap: 0.12rem;
  padding: 0.55rem 0.65rem;
  background: #f7f1e8;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  min-width: 0;
}

.order-kv .item.span-2 { grid-column: 1 / -1; }
.order-kv .item.total {
  background: #f3ebe0;
  border-color: rgba(92, 58, 30, 0.18);
}

.order-kv .lbl {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.order-kv .val {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--tea-deep);
  word-break: break-word;
  line-height: 1.4;
}

.addon-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.addon-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: #f7f1e8;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--tea-deep);
}

.addon-list .qty { color: var(--muted); white-space: nowrap; }

.order-notes {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border-radius: 0.55rem;
  background: var(--warn-bg);
  border: 1px solid rgba(154, 103, 0, 0.2);
  font-size: 0.94rem;
  color: var(--tea-deep);
  font-weight: 600;
  line-height: 1.55;
}

.order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.9rem 1rem 1rem;
  background: #fcfaf7;
}

.order-actions .btn { min-height: 2.7rem; width: 100%; }

.order-detail-view {
  display: grid;
  gap: 0.75rem;
  width: 100%;
  max-width: 920px;
  margin-inline: auto;
  padding-bottom: 2rem;
}

.order-detail-view .map-url {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  word-break: break-all;
}

/* رابط الخريطة: زر بمساحة لمس واضحة بدل نص صغير */
.order-kv .val a {
  display: inline-flex;
  align-items: center;
  min-height: 2.4rem;
  padding-inline: 0.65rem;
  border-radius: 0.6rem;
  background: rgba(99, 58, 17, 0.07);
  border: 1px solid rgba(99, 58, 17, 0.16);
  font-weight: 800;
  color: var(--tea);
}

.detail-panel .order-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.detail-panel .order-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  padding: 0.95rem 1rem;
  background: #f7f1e8;
  border-bottom: 1px solid var(--line);
}

.detail-panel .order-top h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--tea-deep);
}

.detail-panel .order-top p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.admin-toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: calc(1.15rem + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  max-width: min(92vw, 26rem);
  padding: 0.8rem 1.1rem;
  border-radius: 0.7rem;
  background: var(--tea-deep);
  color: var(--white);
  font-weight: 700;
  font-size: 0.94rem;
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.admin-toast.is-on {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.admin-toast[data-tone="warn"] { background: #6b4a12; }
.admin-toast[data-tone="ok"] { background: #1f4d32; }

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(31, 22, 16, 0.5);
  backdrop-filter: blur(3px);
}

.share-card {
  width: min(100%, 26rem);
  background: var(--white);
  border-radius: 1rem;
  padding: 1.25rem 1.15rem 1.1rem;
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--line);
}

.share-logo {
  width: 3.8rem;
  height: 3.8rem;
  margin: 0 auto 0.45rem;
  object-fit: contain;
  border-radius: 0.75rem;
  background: #f7f1e8;
}

.share-card h3 {
  margin: 0;
  color: var(--tea-deep);
  font-size: 1.2rem;
  font-weight: 800;
}

.share-card > p {
  margin: 0.4rem 0 0.65rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.share-steps {
  margin: 0 0 0.95rem;
  padding: 0.7rem 1rem 0.7rem 0.45rem;
  text-align: right;
  background: #f7f1e8;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.65;
}

.share-actions { display: grid; gap: 0.45rem; }
.share-actions .btn { width: 100%; }

.share-note {
  margin: 0.8rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .stat-grid:not(.stat-grid-hero) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card.chart-wide { grid-column: auto; }
  .welcome-intro {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .welcome-brand-block {
    flex-direction: row;
    justify-content: center;
  }
  .welcome-copy { text-align: center; justify-items: center; }
  .welcome-side { justify-self: center; }
}

@media (max-width: 640px) {
  .admin-header {
    min-height: 4.4rem;
    padding-inline: 0.7rem;
    gap: 0.45rem;
  }

  /* الشعار يتقلّص أولاً حتى لا يزحف على أزرار تحديث/خروج */
  .admin-brand {
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .admin-brand img,
  .brand-mark {
    width: 58px;
    height: 58px;
  }

  .admin-brand strong {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .admin-actions {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .admin-actions .btn {
    min-height: 2.35rem;
    padding-inline: 0.7rem;
    font-size: 0.88rem;
  }

  .orders-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filter-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .filter-tab {
    flex: 1;
    justify-content: center;
    padding-inline: 0.45rem;
    font-size: 0.84rem;
  }

  .pin-eye {
    width: 34px;
    height: 34px;
  }

  .period-today {
    min-height: 2rem;
  }

  .welcome-art-wrap { display: none; }
  .welcome-brand-block { flex-direction: column; }
  .stat-grid:not(.stat-grid-hero) { grid-template-columns: 1fr 1fr; }
  .order-kv { grid-template-columns: 1fr; }
  .order-actions { grid-template-columns: 1fr; }
  .order-row { flex-direction: column; }
  .order-row-side {
    width: 100%;
    border-inline-start: 0;
    border-top: 1px solid var(--line);
    min-width: 0;
    justify-items: stretch;
  }
  .order-row-actions .btn { flex: 1; }
  .orders-head-actions { width: 100%; }
  .orders-head-actions .btn-primary { width: 100%; }
}

/* جوال ضيق: الشعار وحده يكفي في الترويسة */
@media (max-width: 430px) {
  .admin-brand-text {
    display: none;
  }

  .visitors-grid {
    grid-template-columns: 1fr 1fr;
  }
}
