/* BranchRadar (رادار الفروع) — Multi-Branch SaaS Dashboard & Control Center Design System */
[hidden] {
  display: none !important;
}

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --navy: #0f172a;
  --navy-soft: #1e293b;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --teal-accent: #14b8a6;
  --teal-soft: #ccfbf1;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --emerald: #059669;
  --emerald-soft: #d1fae5;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: "IBM Plex Sans Arabic", "Tajawal", "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.ltr-token {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

/* --- App Shell Grid (Sidebar + Main Workspace) --- */
.dash-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

/* --- Executive Navy Sidebar --- */
.dash-sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111c33 100%);
  color: #e2e8f0;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #ffffff;
  padding: 0.25rem 0.35rem;
}

.brand-mark-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f766e, #0d9488);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.brand-mark-svg {
  width: 24px;
  height: 24px;
}

.brand-title-col {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title-main {
  font-size: 0.96rem;
  font-weight: 800;
  color: #ffffff;
}

.brand-title-sub {
  font-size: 0.72rem;
  color: #5eead4;
  font-weight: 600;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.side-nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  width: 100%;
  padding: 0.68rem 0.8rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  text-align: start;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.side-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.side-nav-btn.active {
  background: rgba(20, 184, 166, 0.16);
  border-color: rgba(94, 234, 212, 0.35);
  color: #5eead4;
  font-weight: 700;
}

.side-nav-left {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.side-count-pill {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  direction: ltr;
  unicode-bidi: isolate;
}

.side-count-pill.pill-alert {
  background: #ef4444;
  color: #ffffff;
}

/* --- Infrastructure Telemetry Card in Sidebar --- */
.infra-status-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 0.75rem;
}

.infra-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 0.5rem;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
  display: inline-block;
}

.infra-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.infra-chip {
  font-size: 0.68rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(110, 231, 183, 0.25);
  direction: ltr;
  unicode-bidi: isolate;
}

/* --- Main Workspace & Sticky Topbar --- */
.dash-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dash-topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-tenant {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.tenant-badge {
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
}

.mode-status-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.26rem 0.7rem;
  border-radius: 999px;
  background: var(--amber-soft);
  color: #92400e;
  border: 1px solid #fcd34d;
  cursor: pointer;
}

.mode-status-pill.admin-unlocked {
  background: var(--emerald-soft);
  color: #065f46;
  border-color: #6ee7b7;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* --- Buttons & Inputs --- */
.dash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dash-btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.dash-btn-primary:hover {
  background: var(--primary-hover);
}

.dash-btn-outline {
  background: var(--surface);
  color: var(--navy);
  border-color: var(--border-strong);
}

.dash-btn-outline:hover {
  background: var(--surface-alt);
  border-color: var(--primary);
}

.dash-btn-danger {
  background: var(--danger-soft);
  color: #991b1b;
  border-color: #fca5a5;
}

.dash-btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.76rem;
}

.dash-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* --- Content Container & Toast --- */
.dash-content {
  padding: 1.5rem 1.6rem 3rem;
  max-width: 1360px;
  width: 100%;
  margin-inline: auto;
}

.dash-toast {
  background: #0f172a;
  color: #5eead4;
  border: 1px solid rgba(94, 234, 212, 0.4);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  margin-bottom: 1.1rem;
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.view-header h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
}

.view-header p {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* --- KPI Metric Grid --- */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.kpi-metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.kpi-metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-metric-val {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--navy);
  margin-block: 0.35rem 0.2rem;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

.kpi-metric-foot {
  font-size: 0.75rem;
  color: var(--emerald);
  font-weight: 700;
}

.kpi-metric-foot.foot-amber {
  color: var(--amber);
}

/* --- Cards, Panels & Branch Grid --- */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy);
}

.branches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.branch-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.branch-card:hover {
  border-color: var(--teal-accent);
  box-shadow: var(--shadow-sm);
}

.branch-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
}

.branch-name {
  font-weight: 800;
  font-size: 0.96rem;
  color: var(--navy);
  margin: 0 0 0.2rem;
}

.branch-meta {
  font-size: 0.77rem;
  color: var(--text-subtle);
}

.rank-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--primary);
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
}

.rank-badge.rank-warn {
  background: var(--amber-soft);
  color: #92400e;
}

.branch-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.branch-rating-big {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--navy);
  direction: ltr;
  unicode-bidi: isolate;
}

.meter-track {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
  border-radius: 999px;
}

.branch-rival-line {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-strong);
}

/* --- Review Inbox & Held Escalation Cards --- */
.filter-pills-bar {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-pill.active {
  background: var(--navy);
  color: #5eead4;
  border-color: var(--navy);
}

.reviews-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.review-item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
}

.review-item-card.held-escalation {
  border-inline-start: 4px solid var(--danger);
  background: #fffafa;
}

.review-item-card.auto-replied {
  border-inline-start: 4px solid var(--emerald);
}

.review-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.reviewer-line {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 0.92rem;
}

.stars-gold {
  color: #f59e0b;
  direction: ltr;
  unicode-bidi: isolate;
}

.status-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

.status-tag.tag-held {
  background: var(--danger-soft);
  color: #991b1b;
}

.status-tag.tag-replied {
  background: var(--emerald-soft);
  color: #065f46;
}

.review-comment-text {
  margin: 0.4rem 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

.order-match-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: 9px;
  padding: 0.5rem 0.75rem;
  font-size: 0.79rem;
  color: #78350f;
  margin-bottom: 0.7rem;
}

.ai-reply-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.approval-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.55rem;
}

.dash-textarea,
.dash-input,
.dash-select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  background: #ffffff;
  color: var(--text-main);
}

.dash-textarea {
  min-height: 74px;
  resize: vertical;
}

.editor-btn-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* --- Two-Column Split Layouts & Tables --- */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
}

.form-field {
  margin-bottom: 0.85rem;
}

.form-field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.3rem;
}

.endpoint-row {
  background: var(--navy);
  color: #e2e8f0;
  padding: 0.65rem 0.85rem;
  border-radius: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.data-table th,
.data-table td {
  padding: 0.68rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: start;
}

.data-table th {
  background: var(--surface-alt);
  font-weight: 800;
  color: var(--navy);
}

.code-preview-pre {
  background: #0f172a;
  color: #a7f3d0;
  padding: 0.85rem;
  border-radius: 10px;
  font-size: 0.75rem;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  margin: 0.65rem 0 0;
}

.branchradar-widget-mount {
  margin-top: 0.5rem;
}

/* --- Modal Dialog --- */
.dash-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 60;
}

.dash-modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-md);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.close-x-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-muted);
}

@media (max-width: 980px) {
  .dash-layout {
    grid-template-columns: 1fr;
  }
  .dash-sidebar {
    position: static;
    height: auto;
    padding: 0.9rem 1rem;
  }
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }
  .side-nav-btn {
    width: auto;
    white-space: nowrap;
  }
  .infra-status-box {
    display: none;
  }
  .kpi-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two-col-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .kpi-cards-grid {
    grid-template-columns: 1fr;
  }
  .dash-content {
    padding: 1rem;
  }
}
