:root {
  --admin-primary: #1769e0;
  --admin-primary-dark: #0e55bd;
  --admin-navy: #1e2735;
  --admin-bg: #f3f6fa;
  --admin-surface: #ffffff;
  --admin-border: #dde5ef;
  --admin-text: #243044;
  --admin-muted: #748096;
  --admin-radius: 14px;
  --admin-shadow: 0 8px 24px rgba(31, 48, 76, .07);
}

html {
  direction: rtl;
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--admin-bg);
  color: var(--admin-text);
  font-family: Arial, "Segoe UI", sans-serif;
  text-align: right;
}

.admin-shell { min-width: 320px; }
.admin-main { max-width: 1720px; margin-inline: auto; padding: 1.5rem; }

.admin-header {
  position: sticky;
  z-index: 1030;
  top: 0;
  background: var(--admin-navy);
  box-shadow: 0 3px 14px rgba(16, 24, 40, .18);
}

.admin-header .navbar { min-height: 68px; padding-block: .55rem; }
.admin-header__inner { padding-inline: clamp(1rem, 2vw, 2rem); }

.admin-brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: #fff;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: .01em;
}

.admin-brand:hover,
.admin-brand:focus { color: #fff; }

.admin-brand__mark,
.admin-login-brand__mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #3285f4, #1769e0);
  box-shadow: 0 5px 14px rgba(23, 105, 224, .34);
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
}

.admin-header .navbar-collapse { align-items: center; }
.admin-nav { gap: .25rem; margin-inline: 2.25rem auto; }
.admin-nav .nav-link {
  position: relative;
  padding: .65rem .9rem !important;
  border-radius: 9px;
  color: rgba(255,255,255,.72);
  font-size: .93rem;
  font-weight: 600;
}
.admin-nav .nav-link:hover,
.admin-nav .nav-link:focus { color: #fff; background: rgba(255,255,255,.07); }
.admin-nav .nav-link.active { color: #fff; background: rgba(50,133,244,.18); }

.admin-user-box {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .35rem .45rem .35rem .35rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 11px;
  background: rgba(255,255,255,.05);
}
.admin-user-box__avatar {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: #3285f4;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}
.admin-user-box__name { max-width: 180px; overflow: hidden; color: #fff; font-size: .87rem; text-overflow: ellipsis; white-space: nowrap; }
.admin-logout { padding-inline: .75rem; border-color: rgba(255,255,255,.36); white-space: nowrap; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.45rem;
}
.page-heading h1 { margin: 0 0 .3rem; color: #172033; font-size: clamp(1.45rem, 2vw, 1.8rem); font-weight: 750; }
.page-heading p { margin: 0; color: var(--admin-muted); }
.page-eyebrow { display: block; margin-bottom: .25rem; color: var(--admin-primary); font-size: .75rem; font-weight: 700; letter-spacing: .04em; }
.record-count { padding: .48rem .8rem; border: 1px solid var(--admin-border); border-radius: 999px; background: #fff; color: #57637a; font-size: .82rem; font-weight: 600; white-space: nowrap; }

.card {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--admin-surface);
  box-shadow: var(--admin-shadow);
}

.btn { border-radius: 9px; font-weight: 600; }
.btn-primary { border-color: var(--admin-primary); background: var(--admin-primary); }
.btn-primary:hover,
.btn-primary:focus { border-color: var(--admin-primary-dark); background: var(--admin-primary-dark); }
.form-control,
.form-select { min-height: 42px; border-color: #d7e0eb; border-radius: 9px; }
.form-control:focus,
.form-select:focus { border-color: #79aef5; box-shadow: 0 0 0 .22rem rgba(23,105,224,.12); }
.form-label { margin-bottom: .45rem; color: #46536a; font-size: .87rem; font-weight: 600; }
.document-text-card { max-width: 1100px; }
.document-text-area { min-height: 220px; line-height: 1.65; resize: vertical; white-space: pre-wrap; }
.inventory-import-preview { max-height: 620px; }
.inventory-import-preview thead th { position: sticky; top: 0; z-index: 1; background: #f7f9fc; white-space: nowrap; }
.inventory-import-summary { display: grid; grid-template-columns: repeat(6, minmax(100px, 1fr)); gap: .65rem; background: #f8fafc; }
.inventory-import-summary div { display: flex; flex-direction: column; gap: .15rem; }
.inventory-import-summary strong { font-size: 1.25rem; color: #172033; }
.inventory-import-summary span { color: #6b7588; font-size: .78rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.summary-card { min-height: 126px; overflow: hidden; box-shadow: 0 6px 20px rgba(31,48,76,.055); transition: transform .16s ease, box-shadow .16s ease; }
.summary-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(31,48,76,.1); }
.summary-card .card-body { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; }
.summary-icon { display: grid; flex: 0 0 47px; place-items: center; width: 47px; height: 47px; border-radius: 13px; font-size: 1rem; font-weight: 800; }
.summary-copy { min-width: 0; }
.summary-label { margin-bottom: .25rem; overflow: hidden; color: var(--admin-muted); font-size: .83rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.summary-value { color: #172033; font-size: 1.8rem; font-weight: 750; line-height: 1.05; }
.summary-card--blue .summary-icon { background: #e9f2ff; color: #1769e0; }
.summary-card--green .summary-icon { background: #e8f8f0; color: #18875a; }
.summary-card--gray .summary-icon { background: #edf0f4; color: #677286; }
.summary-card--violet .summary-icon { background: #f1ecff; color: #7252c8; }
.summary-card--cyan .summary-icon { background: #e6f7fa; color: #168096; }
.summary-card--amber .summary-icon { background: #fff3dc; color: #ad6b00; }

.dashboard-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 2fr); gap: 1rem; }
.dashboard-panel--full { grid-column: 1 / -1; }
.dashboard-panel .card-body,
.dashboard-list-card .card-body { padding: 1.2rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin: 0 0 .2rem; color: #263248; font-size: 1rem; font-weight: 750; }
.panel-heading p { margin: 0; color: var(--admin-muted); font-size: .78rem; }
.chart-wrap { position: relative; min-height: 260px; }
.chart-wrap--doughnut { max-width: 290px; margin-inline: auto; }
.dashboard-tenant-row { display: flex; align-items: center; gap: .75rem; padding: .8rem .15rem; border-inline: 0; }
.dashboard-tenant-row:first-child { border-top: 0; }
.dashboard-tenant-row strong,
.dashboard-tenant-row small { display: block; }
.dashboard-tenant-row strong { color: #2d394e; font-size: .86rem; }
.dashboard-tenant-row small { margin-top: .15rem; color: var(--admin-muted); font-size: .75rem; }
.tenant-avatar { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: #e9f2ff; color: var(--admin-primary); font-size: .82rem; font-weight: 800; }
.empty-state { padding: 2rem 1rem !important; color: var(--admin-muted); text-align: center; }

.filter-card,
.table-card { box-shadow: 0 3px 14px rgba(31,48,76,.045); }
.filter-card .card-body { padding: 1.15rem; }
.table-card { overflow: hidden; }
.admin-table { --bs-table-hover-bg: #f7faff; }
.admin-table th { padding: .85rem .8rem; border-bottom-width: 1px; background: #f7f9fc; color: #536078; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.admin-table td { padding: .83rem .8rem; border-color: #edf1f6; color: #334057; font-size: .85rem; white-space: nowrap; }
.admin-table th a { color: inherit; text-decoration: none; }
.admin-table th a:hover { color: var(--admin-primary); }
.status-badge { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .58rem; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.status-badge > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge--active,
.status-badge--enabled { background: #e8f8f0; color: #16754e; }
.status-badge--inactive { background: #edf0f4; color: #626e80; }
.status-badge--neutral { background: #f3f5f8; color: #748096; }
.details-button { min-width: 64px; white-space: nowrap; }
.pagination { --bs-pagination-border-radius: 9px; gap: .25rem; }
.page-link { border-radius: 8px !important; }

.admin-login-page {
  display: grid;
  min-width: 320px;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 10% 10%, rgba(23,105,224,.09), transparent 32%),
    linear-gradient(145deg, #edf3fa, #f8fafc 58%, #eef3f8);
}
.admin-login-wrap { width: min(100%, 430px); }
.admin-login-card { overflow: hidden; border: 0; box-shadow: 0 20px 54px rgba(31,48,76,.14); }
.admin-login-card::before { display: block; height: 5px; background: linear-gradient(90deg, #1769e0, #45a1ff); content: ""; }
.admin-login-card .card-body { padding: clamp(1.6rem, 5vw, 2.55rem); }
.admin-login-brand { margin-bottom: 2rem; text-align: center; }
.admin-login-brand__mark { width: 52px; height: 52px; margin-bottom: .9rem; border-radius: 15px; font-size: .95rem; }
.admin-login-brand h1 { margin: 0 0 .35rem; color: #172033; font-size: 1.65rem; font-weight: 800; }
.admin-login-brand p { margin: 0; color: var(--admin-muted); font-size: .94rem; }
.form-field { margin-bottom: 1.1rem; }
.admin-login-card .form-control-lg { min-height: 49px; padding: .65rem .85rem; font-size: 1rem; }
.admin-remember-me { margin: .3rem 0 1.45rem; }
.admin-login-submit { min-height: 49px; font-size: .95rem; }
.admin-login-footer { margin: 1.15rem 0 0; color: #8994a6; font-size: .76rem; text-align: center; }
.admin-validation-summary { margin-bottom: 1.15rem; padding: .75rem .9rem; font-size: .84rem; }
.validation-summary-valid { display: none; }
.field-validation-valid { display: none; }
.field-validation-error { display: block; margin-top: .35rem; color: #c63737; font-size: .78rem; }
.input-validation-error { border-color: #dc6a6a; }
.admin-form-card { max-width: 880px; margin-inline: auto; }
.admin-form-card .card-body { padding: clamp(1.2rem, 3vw, 2rem); }
.password-field { position: relative; }
.password-field .form-control { padding-inline-end: 2.9rem; }
.password-toggle { position: absolute; inset-inline-end: .35rem; top: 50%; transform: translateY(-50%); width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #536078; }
.password-toggle:hover, .password-toggle:focus-visible { background: #edf4ff; color: var(--admin-primary); outline: 2px solid transparent; }

.card-header { border-bottom-color: var(--admin-border); }
.details-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: .85rem; }
.detail-item { min-width: 0; padding: .9rem 1rem; border: 1px solid var(--admin-border); border-radius: 10px; background: #fbfcfe; }
.detail-label { display: block; margin-bottom: .28rem; color: var(--admin-muted); font-size: .76rem; font-weight: 600; }
.detail-value { color: #2f3b50; font-size: .9rem; font-weight: 650; overflow-wrap: anywhere; }
.nav-tabs { gap: .15rem; border-bottom: 0; }
.nav-tabs .nav-link { padding: .7rem .85rem; border: 0; border-bottom: 2px solid transparent; color: #667289; font-size: .84rem; font-weight: 600; white-space: nowrap; }
.nav-tabs .nav-link:hover { color: var(--admin-primary); }
.nav-tabs .nav-link.active { border-bottom-color: var(--admin-primary); background: transparent; color: var(--admin-primary); }
.tab-pane > .table-responsive { border: 1px solid var(--admin-border); border-radius: 10px; }
.tab-pane .table { margin-bottom: 0; }
.tab-pane .table th { background: #f7f9fc; color: #536078; font-size: .78rem; white-space: nowrap; }
.tab-pane .table td { font-size: .83rem; white-space: nowrap; }

.theme-management-card { overflow: hidden; font-family: Tahoma, Arial, sans-serif; }
.theme-management-card .card-body { padding: clamp(1.25rem, 3vw, 2rem); }
.theme-management-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.theme-management-heading p { color: var(--admin-muted); }
.theme-management-heading > span {
  padding: .45rem .75rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #526076;
  font-size: .76rem;
  font-weight: 700;
  white-space: nowrap;
}
.theme-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
  padding: .85rem;
  border-radius: 18px;
  background: #0b0c0d;
}
.theme-preset-option { min-width: 0; cursor: pointer; }
.theme-preset-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}
.theme-preset-card {
  position: relative;
  display: grid;
  gap: .7rem;
  min-height: 190px;
  padding: 1rem;
  border: 1px solid #34373b;
  border-radius: 14px;
  background: #18191a;
  color: #f7f5f2;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.theme-preset-option:hover .theme-preset-card { transform: translateY(-2px); border-color: var(--theme-primary); }
.theme-preset-option > input:focus-visible + .theme-preset-card {
  outline: 3px solid color-mix(in srgb, var(--theme-secondary) 70%, white);
  outline-offset: 3px;
}
.theme-preset-option > input:checked + .theme-preset-card {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-primary) 34%, transparent), 0 14px 34px rgba(0,0,0,.28);
}
.theme-preset-accent { height: 7px; border-radius: 999px; background: var(--theme-primary); }
.theme-preset-title { font-size: 1rem; font-weight: 800; }
.theme-preset-colors { color: #aaa7a3; font-size: .76rem; direction: ltr; text-align: right; }
.theme-preset-preview { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.theme-preset-preview > span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 9px;
  font-size: .76rem;
  font-weight: 800;
}
.theme-preview-primary { border: 1px solid var(--theme-primary); background: var(--theme-primary); color: var(--theme-on-accent); }
.theme-preview-outline { border: 1px solid var(--theme-primary); background: #111; color: #fff; }
.theme-preset-selected { color: var(--theme-secondary); font-size: .72rem; font-weight: 700; }
.theme-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
}
.theme-save-row p { margin: 0; color: var(--admin-muted); font-size: .84rem; }
.website-preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .65rem;
  font-family: Tahoma, Arial, sans-serif;
}
.website-preview-actions small {
  max-width: 280px;
  color: var(--admin-muted);
  line-height: 1.35;
}
.website-preview-button { min-width: 112px; }

@media (max-width: 767.98px) {
  .theme-management-heading,
  .theme-save-row { align-items: flex-start; flex-direction: column; }
  .theme-preset-grid { grid-template-columns: 1fr; }
  .theme-save-row .btn { width: 100%; }
  .website-preview-actions { align-items: flex-start; flex-direction: column; width: 100%; }
  .website-preview-button { width: 100%; }
}

.tenant-wizard { max-width: 1080px; margin-inline: auto; }
.wizard-progress { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0 0 1rem; padding: 0; list-style: none; }
.wizard-progress li { position: relative; display: grid; justify-items: center; gap: .35rem; color: #8a96a8; font-size: .76rem; text-align: center; }
.wizard-progress li::before { position: absolute; top: 17px; inset-inline-start: -50%; z-index: 0; width: 100%; height: 2px; background: #dce3ed; content: ""; }
.wizard-progress li:first-child::before { display: none; }
.wizard-progress span { z-index: 1; display: grid; width: 34px; height: 34px; place-items: center; border: 2px solid #dce3ed; border-radius: 50%; background: #fff; font-weight: 750; }
.wizard-progress .active,
.wizard-progress .complete { color: var(--admin-primary); }
.wizard-progress .active span,
.wizard-progress .complete span { border-color: var(--admin-primary); background: var(--admin-primary); color: #fff; }
.wizard-progress .complete::before { background: var(--admin-primary); }
.wizard-step { min-height: 405px; }
.wizard-step[hidden] { display: none !important; }
.wizard-step .card-body { padding: clamp(1.25rem, 3vw, 2rem); }
.wizard-step h2 { margin: 0; color: #1e2a3d; font-size: 1.25rem; font-weight: 750; }
.wizard-step__hint { margin: .35rem 0 1.5rem; color: var(--admin-muted); }
.wizard-actions { display: flex; align-items: center; gap: .65rem; padding-top: 1rem; }
.wizard-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }

@media (max-width: 1199.98px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
  .admin-header .navbar-collapse { padding-top: .8rem; }
  .admin-nav { gap: .15rem; margin: 0; }
  .admin-user-box { justify-content: flex-start; margin-top: .6rem; }
  .admin-user-box__name { max-width: none; }
  .admin-main { padding: 1.15rem; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-panel--full { grid-column: auto; }
  .page-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 575.98px) {
  .inventory-import-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-main { padding: 1rem .75rem; }
  .kpi-grid { grid-template-columns: 1fr; gap: .75rem; }
  .summary-card { min-height: 105px; }
  .summary-card .card-body { padding: 1rem; }
  .filter-card .card-body { padding: 1rem; }
  .admin-login-page { padding: .75rem; }
  .admin-login-card .card-body { padding: 1.45rem 1.15rem 1.6rem; }
  .wizard-progress small { display: none; }
  .wizard-progress span { width: 30px; height: 30px; }
  .wizard-progress li::before { top: 15px; }
  .wizard-summary { grid-template-columns: 1fr; }
  .wizard-step { min-height: auto; }
}
