:root {
  --brand-blue: #284192;
  --brand-pink: #fe5b98;
  --soft-pink: #edb1d0;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #68758b;
  --line: #e6e9f2;
  --green: #198754;
  --amber: #f59f00;
  --red: #c92a2a;
  --shadow: 0 18px 50px rgba(31, 43, 91, .12);
  --radius: 22px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: 'Cairo', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at 12% 8%, rgba(254,91,152,.16), transparent 28%), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(520px, 100%);
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-mark {
  width: 108px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-pink), var(--brand-blue));
  font-weight: 900;
  margin-bottom: 20px;
}
.login-card h1 { margin: 0 0 8px; font-size: 2rem; }
.login-card p { margin: 0 0 24px; color: var(--muted); line-height: 1.8; }
.login-form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; font-weight: 800; color: #27324a; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(254,91,152,.75);
  box-shadow: 0 0 0 4px rgba(254,91,152,.12);
}
.login-form button, .primary-btn, .secondary-btn, .danger-btn, .ghost-link, .upload-btn {
  border: 0;
  border-radius: 15px;
  padding: 12px 16px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-form button, .primary-btn {
  background: linear-gradient(135deg, var(--brand-pink), var(--brand-blue));
  color: #fff;
  box-shadow: 0 12px 26px rgba(40,65,146,.18);
}
.secondary-btn, .ghost-link, .upload-btn {
  background: #eef1f9;
  color: var(--brand-blue);
  border: 1px solid #dfe4f2;
}
.danger-btn { background: #ffe3e3; color: var(--red); }
.demo-users {
  margin-top: 22px;
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: #f6f7fb;
  color: var(--muted);
  font-size: .9rem;
}
.demo-users strong { color: var(--text); }

.dashboard {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: #111a3b;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: grid;
  gap: 2px;
  font-size: 1.7rem;
  font-weight: 900;
}
.brand span { color: var(--soft-pink); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase; }
.side-nav { display: grid; gap: 8px; }
.side-btn {
  border: 0;
  border-radius: 15px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.78);
  background: transparent;
  text-align: right;
  font-weight: 800;
}
.side-btn:hover, .side-btn.active { background: rgba(255,255,255,.1); color: #fff; }
.user-box {
  margin-top: auto;
  display: grid;
  gap: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 14px;
}
.user-box span { font-weight: 900; }
.user-box small { color: var(--soft-pink); }
.user-box button {
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  padding: 9px 12px;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-weight: 800;
}
.main-area { padding: 28px; min-width: 0; }
.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 24px;
}
.admin-header h2 { margin: 0; font-size: 2rem; }
.admin-header p, .muted { color: var(--muted); margin: 6px 0 0; }
.header-actions, .toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-view { display: none; }
.section-view.active { display: block; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(28,37,71,.06);
}
.kpi-card { padding: 20px; }
.kpi-card span { color: var(--muted); font-weight: 800; }
.kpi-card strong { display: block; margin-top: 10px; font-size: 1.75rem; color: var(--brand-blue); }
.kpi-card small { color: var(--muted); }
.split-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { padding: 20px; }
.panel h3 { margin: 0 0 14px; }
.alert-list, .mini-list, .movement-list { display: grid; gap: 10px; }
.alert-item, .mini-item, .movement-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  background: #f8f9fc;
  border: 1px solid #edf0f7;
  border-radius: 16px;
  padding: 12px;
}
.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-weight: 900;
  font-size: .78rem;
  white-space: nowrap;
}
.badge.green { background: #dcfce7; color: #166534; }
.badge.amber { background: #fff3bf; color: #8a5a00; }
.badge.red { background: #ffe3e3; color: #a61e1e; }
.badge.gray { background: #eef1f9; color: #46546f; }
.toolbar {
  background: #fff;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.toolbar input { max-width: 360px; }
.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(28,37,71,.06);
}
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
th { background: #f7f8fc; color: #46546f; font-size: .86rem; }
.product-cell { display: flex; gap: 12px; align-items: center; }
.product-cell img { width: 52px; height: 52px; border-radius: 14px; object-fit: cover; background: #f2f3f7; }
.product-cell strong { display: block; }
.product-cell span { display: block; color: var(--muted); font-size: .85rem; direction: ltr; text-align: right; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.row-actions button {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #eef1f9;
  color: var(--brand-blue);
  font-weight: 900;
}
.row-actions button.danger { background: #ffe3e3; color: var(--red); }
.compact-form { display: grid; gap: 13px; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; font-weight: 800; }
.check-row input { width: auto; }
.role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.role-card { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: #f8f9fc; }
.role-card h4 { margin: 0 0 8px; color: var(--brand-blue); }
.role-card ul { margin: 0; padding: 0 18px 0 0; color: var(--muted); }
.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(13, 20, 43, .44);
  display: none;
  justify-content: flex-start;
}
.drawer.open { display: flex; }
.drawer-panel {
  width: min(860px, 100%);
  height: 100vh;
  overflow: auto;
  background: #fff;
  box-shadow: -18px 0 60px rgba(0,0,0,.18);
  padding: 24px;
}
.drawer-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.drawer-head h3 { margin: 0; font-size: 1.65rem; }
.drawer-head p { margin: 4px 0 0; color: var(--muted); }
.icon-btn { border: 0; border-radius: 13px; width: 42px; height: 42px; background: #eef1f9; color: var(--brand-blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .wide { grid-column: 1 / -1; }
.drawer-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  max-width: 360px;
  background: #111a3b;
  color: #fff;
  padding: 13px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: .2s ease;
  pointer-events: none;
  z-index: 80;
  font-weight: 800;
}
.toast.show { opacity: 1; transform: translateY(0); }
.hidden-by-role { display: none !important; }
@media (max-width: 1100px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid, .role-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .main-area { padding: 16px; }
  .admin-header { align-items: stretch; flex-direction: column; }
  .kpi-grid, .form-grid { grid-template-columns: 1fr; }
  .drawer-panel { padding: 16px; }
}

/* Bubbles Local Admin v5 additions */
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}
.panel-head h3 { margin: 0; }
.wide-panel { margin-top: 16px; }
.table-wrap.flat { box-shadow: none; }
.inventory-top { margin-bottom: 16px; }
.table-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 10px;
  background: #eef1f9;
  color: var(--brand-blue);
  font-weight: 900;
}
.analytics-toolbar label {
  min-width: 180px;
}
.rank-list { display: grid; gap: 12px; }
.rank-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2fr minmax(85px, auto);
  gap: 12px;
  align-items: center;
  background: #f8f9fc;
  border: 1px solid #edf0f7;
  border-radius: 16px;
  padding: 12px;
}
.rank-title strong { display: block; }
.rank-title small { color: var(--muted); direction: ltr; }
.rank-bar {
  height: 11px;
  background: #e9edf7;
  border-radius: 999px;
  overflow: hidden;
}
.rank-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--brand-pink), var(--brand-blue));
}
.rank-value { font-weight: 900; color: var(--brand-blue); white-space: nowrap; }
.daily-grid, .profit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.day-card, .profit-card {
  background: #f8f9fc;
  border: 1px solid #edf0f7;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 5px;
}
.day-card strong, .profit-card strong { color: var(--brand-blue); }
.day-card span, .profit-card span { color: var(--text); font-weight: 800; }
.day-card small, .profit-card small { color: var(--muted); }
.permissions-matrix { display: grid; gap: 16px; }
.permission-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8f9fc;
  padding: 16px;
}
.permission-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.permission-card h4 { margin: 0; color: var(--brand-blue); }
.permission-card small { color: var(--muted); }
.perm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 10px;
  font-weight: 800;
  color: #27324a;
}
.perm-check input { width: auto; min-width: 18px; height: 18px; accent-color: var(--brand-pink); }
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.danger-btn.small { padding: 8px 10px; font-size: .86rem; }
.image-preview-box {
  display: grid;
  gap: 10px;
  align-content: start;
}
.image-preview-box img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #f8f9fc;
}
.toast { z-index: 200; }
.hidden-by-role { display: none !important; }
@media (max-width: 1200px) {
  .daily-grid, .profit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-row { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .daily-grid, .profit-grid, .perm-grid, .user-form { grid-template-columns: 1fr; }
  .panel-head { align-items: stretch; flex-direction: column; }
}

/* Bubbles Local Admin v6 additions: orders + audit trail */
.order-list { display: grid; gap: 12px; max-height: 610px; overflow: auto; padding-inline-end: 4px; }
.order-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #f8f9fc;
  display: grid;
  gap: 12px;
}
.order-card-head,
.order-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.order-card-head strong { color: var(--brand-blue); direction: ltr; display: block; }
.order-card-head small { color: var(--muted); }
.order-customer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  background: #fff;
  border: 1px solid #edf0f7;
  border-radius: 14px;
  padding: 11px;
  color: #33405a;
  font-size: .92rem;
}
.order-items { margin: 0; padding: 0 18px 0 0; color: var(--muted); }
.order-total {
  border-top: 1px dashed #dfe4f2;
  padding-top: 10px;
}
.order-total strong { color: var(--brand-pink); font-size: 1.1rem; }
.order-history-item { align-items: flex-start; }
.audit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.audit-toolbar input { max-width: 520px; }
.audit-timeline { display: grid; gap: 10px; }
.audit-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  background: #f8f9fc;
  border: 1px solid #edf0f7;
  border-radius: 16px;
  padding: 12px;
}
.audit-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-pink), var(--brand-blue));
}
.audit-icon.stock { background: #198754; }
.audit-icon.order, .audit-icon.sale { background: #f59f00; }
.audit-icon.permissions, .audit-icon.admin { background: #284192; }
.audit-icon.customer { background: #fe5b98; }
.audit-body { min-width: 0; }
.audit-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-title strong { color: var(--brand-blue); }
.audit-title span { color: var(--text); }
.audit-meta { color: var(--muted); font-size: .88rem; margin-top: 3px; }
.audit-details {
  margin-top: 7px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #edf0f7;
  padding: 8px 10px;
  color: #46546f;
  font-size: .88rem;
}
.address-modal-note { color: var(--text-muted); margin: -6px 0 18px; line-height: 1.8; }
.addr-form-group.wide { grid-column: 1 / -1; }
.customer-summary-box { border-style: dashed; }
@media (max-width: 720px) {
  .order-customer { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr; }
  .audit-row .badge { justify-self: start; }
}

/* Bubbles v7 - stock filters and product variants */
.inline-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.inline-filters input,
.inline-filters select,
.toolbar select,
.toolbar input {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-weight: 800;
  background: #fff;
  color: var(--text);
}
.variant-manager {
  border: 1px dashed #c9d2ea;
  background: #f8faff;
  border-radius: 18px;
  padding: 14px;
}
.variant-manager-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.variant-manager-head strong { display: block; color: var(--brand-blue); font-size: 1rem; }
.variant-manager-head small { display: block; color: var(--muted); line-height: 1.7; margin-top: 3px; }
.variant-list {
  display: grid;
  gap: 10px;
}
.variant-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr)) 42px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid #e5eaf6;
  background: #fff;
}
.variant-row label {
  display: grid;
  gap: 5px;
  font-size: .78rem;
  font-weight: 900;
  color: var(--muted);
}
.variant-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font-family: inherit;
  font-weight: 800;
}
.variant-remove { color: var(--red); background: #ffe3e3; }
@media (max-width: 1100px) {
  .variant-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .variant-remove { width: 100%; }
}

/* ===== M11 — Onboarding dashboard + empty states (additive) ===== */
.onboarding-card{background:linear-gradient(135deg,#eef2ff,#fdf2f8);border:1px solid var(--line);border-radius:var(--radius);padding:22px;margin-bottom:18px}
.onboarding-card .onb-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
.onboarding-card h2{margin:0 0 4px;font-size:20px;color:var(--text)}
.onboarding-card p{margin:0;color:var(--muted);font-size:13px}
.onb-pct{text-align:center;color:var(--brand-blue)}
.onb-pct strong{display:block;font-size:26px;line-height:1}
.onb-pct small{color:var(--muted)}
.onb-bar{height:10px;border-radius:999px;background:#e4e7f2;overflow:hidden;margin:16px 0}
.onb-bar span{display:block;height:100%;background:linear-gradient(90deg,var(--brand-blue),var(--brand-pink));transition:width .4s}
.onb-tasks{list-style:none;margin:0;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px}
.onb-task{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--line);border-radius:12px;padding:10px 12px;font-size:14px;color:var(--text)}
.onb-task i{color:#c3c9d8}
.onb-task.done{color:var(--muted)}
.onb-task.done i{color:var(--green)}
.empty-state{display:flex;flex-direction:column;align-items:center;gap:10px;padding:40px 16px;color:var(--muted)}
.empty-state i{font-size:32px;color:#c3c9d8}
.empty-state p{margin:0;font-size:15px}
