:root {
  --bg: #f4f1ec;
  --card: #fffcf8;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e0d6;
  --accent: #0f766e;
  --accent-2: #115e59;
  --danger: #b91c1c;
  --shadow: 0 20px 50px rgba(28, 25, 23, 0.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, #d9f3ef 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #f6e7d8 0%, transparent 50%),
    var(--bg);
}
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.auth-card { width: min(420px, 100%); padding: 28px; }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.brand.compact { margin: 0; }
.brand h1, .brand strong { margin: 0; font-size: 1.15rem; }
.brand p, .brand span { margin: 2px 0 0; color: var(--muted); font-size: .9rem; display: block; }
.logo {
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #134e4a);
  color: white; font-weight: 700; letter-spacing: .02em;
}
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 8px; font-weight: 500; }
label span { font-size: .92rem; }
label small { color: var(--muted); font-weight: 400; font-size: .8rem; }
input[type="text"], input[type="password"], input[type="number"], input:not([type]) {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(15,118,110,.12); }
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px;
  font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn:disabled { opacity: .65; cursor: wait; }
.error { color: var(--danger); margin: 0; font-size: .9rem; }
.top {
  max-width: 820px; margin: 0 auto; padding: 22px 20px 0;
  display: flex; justify-content: space-between; align-items: center;
}
.shell { max-width: 820px; margin: 0 auto; padding: 18px 20px 40px; }
.panel { padding: 28px; }
.panel-head h1 { margin: 0 0 6px; font-size: 1.45rem; }
.panel-head p { margin: 0 0 22px; color: var(--muted); }
.grid-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.grid-form .full { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.upload {
  position: relative; border: 1.5px dashed #d6cfc4; border-radius: 16px;
  min-height: 160px; background: #fff; overflow: hidden;
}
.upload input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-ui {
  min-height: 160px; display: grid; place-items: center; text-align: center; padding: 16px; color: var(--muted);
}
.upload-ui span { font-size: .8rem; }
.upload-ui img { max-height: 140px; max-width: 100%; border-radius: 12px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #1c1917; color: #fff; padding: 12px 16px; border-radius: 999px;
  font-size: .92rem; z-index: 20;
}
dialog {
  border: 0; border-radius: 20px; padding: 0; width: min(420px, calc(100% - 32px));
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(28,25,23,.45); }
.modal { padding: 28px; text-align: center; }
.ok-badge {
  width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; background: #ccfbf1; color: var(--accent); font-weight: 700;
}
.modal h2 { margin: 0 0 8px; }
.modal p { color: var(--muted); margin: 0 0 18px; line-height: 1.6; }
.modal-actions { display: grid; gap: 10px; }
@media (max-width: 640px) {
  .grid-form { grid-template-columns: 1fr; }
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.mode-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.mode-btn.active {
  background: #ccfbf1;
  border-color: #99f6e4;
  color: var(--accent-2);
}
.contents { display: contents; }
.variants-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.variants-head small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.variants-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.variants-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
.variants-table th, .variants-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: .9rem;
}
.variants-table th {
  background: #faf7f2;
  font-weight: 600;
  color: var(--muted);
}
.variants-table input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
}
.variants-table .icon-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.simple-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}
@media (max-width:640px){.simple-grid{grid-template-columns:1fr}}

.sync-panel { margin-top: 18px; }
.search-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr auto;
  gap: 12px;
  align-items: end;
}
.search-row .grow { min-width: 0; }
.search-row select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}
.search-actions { display: flex; }
.search-result {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 16px;
}
.search-result .meta {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.search-result .meta strong { font-size: 1.05rem; }
.search-result .meta span { color: var(--muted); font-size: .92rem; }
.search-result .badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f5f5f4;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
}
.search-result .badge.ok { background: #ccfbf1; color: var(--accent-2); }
.search-result .badge.warn { background: #ffedd5; color: #9a3412; }
@media (max-width: 640px) {
  .search-row { grid-template-columns: 1fr; }
}

.history-panel { margin-top: 18px; }
.history-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.history-list { display:grid; gap:10px; }
.history-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.history-item .top-row {
  display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap; align-items:center;
}
.history-item .when { color: var(--muted); font-size: .85rem; }
.history-item .details { color: var(--muted); font-size: .9rem; line-height: 1.5; }
.history-item .links { display:flex; gap:8px; flex-wrap:wrap; }
.muted { color: var(--muted); margin: 0; }
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f5f5f4;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  margin-inline-end: 6px;
}



.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
  background: transparent;
}
.brand.compact .brand-logo {
  width: 42px;
  height: 42px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 85% 0%, rgba(167, 139, 250, 0.18), transparent 55%),
    radial-gradient(700px 420px at 10% 100%, rgba(15, 118, 110, 0.10), transparent 50%),
    #f7f4ef;
}
.auth-card-v2 {
  width: min(420px, 100%);
  padding: 32px 28px 28px;
  border-radius: 28px;
  border: 1px solid rgba(28,25,23,0.08);
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.10);
}
.auth-brand {
  text-align: center;
  margin-bottom: 26px;
}
.auth-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 14px;
  display: block;
  background: transparent;
}
.auth-brand h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
}
.btn.wide { width: 100%; }
.auth-card-v2 label span { color: #44403c; }
.auth-card-v2 input {
  background: #fafaf9;
  border-color: #e7e5e4;
}
.auth-card-v2 input:focus {
  background: #fff;
}

/* ===== Dashboard ===== */
.dash-body {
  min-height: 100vh;
  background: #f7f4ef;
}
.dash {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: #f7f4ef;
}
.sidebar {
  background: #f7f4ef;
  color: #1c1917;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-inline-end: 1px solid #e4ddd2;
  box-shadow: none;
}
.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 8px 16px;
  border-bottom: 1px solid #e4ddd2;
}
.sidebar-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
  background: transparent;
}
.sidebar-brand strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.2;
  color: #1c1917;
}
.sidebar-brand span {
  display: block;
  color: #78716c;
  font-size: 0.78rem;
  margin-top: 3px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.nav-item {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: start;
  background: transparent;
  color: #57534e;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.nav-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: #efeae2;
  color: #78716c;
}
.nav-ico svg {
  width: 18px;
  height: 18px;
  display: block;
}
.nav-item:hover {
  background: #efeae2;
  color: #1c1917;
}
.nav-item:hover .nav-ico {
  background: #e7e0d6;
  color: #44403c;
}
.nav-item.active {
  background: #ecfdf5;
  color: #0f766e;
  box-shadow: inset -3px 0 0 #14b8a6;
}
html:not([dir="rtl"]) .nav-item.active {
  box-shadow: inset 3px 0 0 #14b8a6;
}
.nav-item.active .nav-ico {
  background: #ccfbf1;
  color: #0f766e;
}
.sidebar-foot {
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid #e4ddd2;
}
.sidebar-foot .btn.ghost {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: #57534e;
  border-color: #e7e0d6;
  border-radius: 12px;
}
.sidebar-foot .btn.ghost .nav-ico {
  background: #efeae2;
  color: #78716c;
}
.sidebar-foot .btn.ghost:hover {
  background: #efeae2;
  color: #1c1917;
}

.dash-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dash-shell {
  width: min(880px, 100%);
  padding: 0 24px 40px;
}
.dash-top {
  padding: 28px 0 10px;
  width: min(880px, 100%);
  padding-inline: 24px;
}
.dash-top h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}
.dash-top p {
  margin: 0;
  color: var(--muted);
}
.dash-content {
  width: min(880px, 100%);
  padding: 8px 24px 48px;
}
.page {
  display: none !important;
}
.page.active {
  display: block !important;
}
.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.dash .panel {
  padding: 24px;
  border-radius: 20px;
}
.dash .mode-btn.active {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

@media (max-width: 900px) {
  .dash {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    padding: 14px 12px;
    box-shadow: none;
    border-inline-end: 0;
    border-bottom: 1px solid #e7e0d6;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav-item {
    flex: 1 1 calc(33.333% - 6px);
    flex-direction: column;
    gap: 6px;
    text-align: center;
    padding: 10px 6px;
    font-size: 0.78rem;
    justify-content: center;
  }
  .nav-item.active {
    box-shadow: none;
  }
  .sidebar-foot .btn.ghost {
    justify-content: center;
  }
  .dash-top,
  .dash-content {
    padding-inline: 16px;
  }
  .dash-top { padding-top: 18px; }
}
