:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #ccfbf1;
  --accent: #ea580c;
  --bg: #e2e8f0;
  --bg-elev: #f8fafc;
  --ink: #0f172a;
  --muted: #64748b;
  --danger: #b42318;
  --ok: #15803d;
  --card: #ffffff;
  --line: rgba(15, 23, 42, 0.12);
  --border: rgba(15, 23, 42, 0.16);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.1);
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --control-h: 44px;
  --sidebar-w: 264px;
  --font: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Cairo", "IBM Plex Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background:
    linear-gradient(180deg, #cbd5e1 0%, var(--bg) 40%, #dbe4ee 100%);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Login — split stage (واضح التغيّر عن الواجهة القديمة) */
.login-view {
  min-height: 100%;
  height: 100%;
  overflow: auto;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 480px at 0% 0%, rgba(234, 88, 12, 0.18), transparent 50%),
    linear-gradient(135deg, #020617 0%, #0f172a 45%, #134e4a 100%);
  padding: var(--space-6);
  position: relative;
}
.login-view::before { display: none; }
.login-stage {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: min(520px, 86vh);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255,255,255,0.12);
  animation: riseIn .45s ease both;
}
.login-hero {
  background:
    linear-gradient(160deg, rgba(15, 118, 110, 0.35), transparent 55%),
    linear-gradient(200deg, #020617, #0f172a 70%);
  color: #f8fafc;
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}
.login-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.45;
  pointer-events: none;
}
.login-hero-mark {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 7vw, 4.6rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #fff;
  text-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.login-hero-line {
  position: relative;
  margin: 14px 0 0;
  color: rgba(248, 250, 252, 0.72);
  font-size: 1rem;
  font-weight: 600;
}
.login-ver {
  position: relative;
  margin-top: 22px;
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #0f172a;
  background: #fb923c;
  padding: 6px 12px;
  border-radius: 999px;
}
.login-card {
  width: 100%;
  background: #fff;
  border-radius: 0;
  padding: 36px 34px 34px;
  box-shadow: none;
  position: relative;
  border: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.brand {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--ink);
  text-align: right;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.brand-sub {
  text-align: right;
  color: var(--muted);
  margin: 8px 0 22px;
  line-height: 1.55;
  font-size: 0.92rem;
}
@media (max-width: 820px) {
  .login-stage { grid-template-columns: 1fr; min-height: auto; }
  .login-hero { min-height: 180px; padding: 28px 24px; }
  .login-hero-mark { font-size: 3rem; }
}
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  min-height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  line-height: 1.35;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10, 107, 92, 0.16);
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  min-height: var(--control-h);
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--bg-elev); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #f97316, var(--accent));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(234, 88, 12, 0.32);
}
.btn.primary:hover { filter: brightness(1.05); background: linear-gradient(180deg, #fb923c, #ea580c); }
.btn.ghost { background: transparent; }
.btn.full { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 10px; }

/* App shell */
.app-view {
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
}
.sidebar {
  background:
    linear-gradient(180deg, #020617 0%, #0f172a 52%, #134e4a 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  border-left: 1px solid rgba(255,255,255,0.06);
  position: relative;
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: auto -40% -20% -20%;
  height: 180px;
  background: radial-gradient(circle, rgba(249,115,22,0.22), transparent 65%);
  pointer-events: none;
}
.sidebar-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
  padding: 6px 12px 16px;
  color: #fff;
}
.sidebar-brand::after {
  content: "منصة المكتب · 1.1.42";
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.65);
  margin-top: 4px;
  letter-spacing: 0;
  font-family: var(--font);
}
#nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: auto;
  flex: 1;
  padding-bottom: 8px;
  position: relative;
  z-index: 1;
}
.nav-btn {
  text-align: right;
  border: 0;
  background: transparent;
  color: rgba(232, 246, 243, 0.88);
  padding: 11px 14px;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-btn.active {
  background: rgba(249, 115, 22, 0.18);
  color: #fff;
  box-shadow: inset 3px 0 0 #fb923c;
}
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}
#user-chip {
  font-size: 0.85rem;
  color: rgba(232,246,243,0.75);
  margin-bottom: 8px;
  padding: 0 8px;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: transparent;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 250, 249, 0.86);
  backdrop-filter: blur(10px);
}
#page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border: 1px solid var(--line);
}
.content {
  flex: 1;
  overflow: auto;
  padding: 18px 22px 28px;
}

.card, .section-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.section-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--teal-dark);
}
.muted { color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: plaintext; }

.grid {
  display: grid;
  gap: 12px;
}
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}
th {
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  background: var(--bg-elev);
  position: sticky;
  top: 0;
}
tr:hover td { background: rgba(10, 107, 92, 0.03); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #12332d;
  color: #fff;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 9999;
  font-weight: 700;
  max-width: min(480px, calc(100vw - 24px));
  text-align: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.stat-card {
  background: linear-gradient(180deg, #fff, var(--bg-elev));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .k { color: var(--muted); font-size: 0.85rem; }
.stat-card .v {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  margin-top: 6px;
  color: var(--teal-dark);
}

@media (max-width: 900px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }

.content.content-loading {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
/* لا content-visibility — يكسر ارتفاع التمرير في pywebview */
.topbar h1 { margin: 0; font-size: 1.28rem; font-weight: 800; line-height: 1.3; color: var(--teal-dark); }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge {
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.2;
}
button.badge-filter {
  border: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
button.badge-filter:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
}
button.badge-filter.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 2px 8px rgba(11, 110, 79, 0.25);
}
button.badge-filter-active:not(.is-active) {
  background: rgba(11, 110, 79, 0.12);
  color: #084c37;
}
button.badge-filter-disabled:not(.is-active) {
  background: rgba(140, 100, 30, 0.14);
  color: #6a4a10;
}
button.badge-filter-expired:not(.is-active) {
  background: rgba(180, 35, 24, 0.12);
  color: #8a1a12;
}
button.badge-filter-hold:not(.is-active) {
  background: rgba(30, 90, 160, 0.12);
  color: #1a4f8a;
}
button.badge-filter-renewed:not(.is-active) {
  background: rgba(120, 60, 170, 0.13);
  color: #5b2a86;
}
.content {
  padding: 22px 24px 28px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
}
.content > .toolbar + .card,
.content > .toolbar + .grid,
.content > .card + .toolbar,
.content > .card + .grid,
.content > .grid + .card {
  margin-top: 0;
}
.content > .card + .card {
  margin-top: var(--space-4);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 0.88rem; font-weight: 600; line-height: 1.4; }
.card .value { font-size: 1.4rem; font-weight: 800; margin-top: 8px; line-height: 1.25; letter-spacing: -0.01em; }

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  align-items: center;
}
.toolbar input {
  max-width: 340px;
  min-height: var(--control-h);
  flex: 1 1 200px;
}
.toolbar .btn { flex: 0 0 auto; }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.btn-sm {
  padding: 5px 10px;
  min-height: 30px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
.isp-panel { padding: 14px 16px; }
.isp-panel .section-title { margin: 0 0 10px; font-size: 1.02rem; }
.isp-setup-compact {
  padding: 8px 10px;
  margin-bottom: 0;
}
.isp-setup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.isp-setup-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--teal-dark);
  white-space: nowrap;
}
.isp-setup-row input {
  width: auto;
  min-width: 0;
  padding: 5px 8px;
  font-size: 0.82rem;
  border-radius: 8px;
  max-width: 130px;
}
.isp-setup-row #mt-host { max-width: 120px; }
.isp-setup-row #mt-port { max-width: 72px; }
.isp-setup-row #mt-user { max-width: 90px; }
.isp-setup-row #mt-pass { max-width: 110px; }
.isp-setup-row #mt-days { max-width: 64px; }
.isp-setup-full { padding: 16px 18px; }
.isp-setup-full .section-title { margin: 0 0 8px; font-size: 1.02rem; }
.isp-setup-full .muted { margin: 0 0 10px; font-size: 0.88rem; }
.isp-prices-card { margin-top: 12px; padding: 14px 16px; }
.isp-prices-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.isp-prices-head .section-title { margin: 0; font-size: 1.02rem; }
.isp-prices-card > .muted { margin: 0 0 12px; font-size: 0.88rem; }
.isp-prices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.isp-price-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-sizing: border-box;
}
.isp-price-name {
  flex: 1 1 70px;
  display: block;
  width: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: start;
  color: inherit;
}
.isp-profile-price {
  width: 110px;
  max-width: 110px;
  flex: 0 0 auto;
  text-align: start;
  font-variant-numeric: tabular-nums;
  direction: ltr;
}
.isp-prices-manual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.isp-prices-manual input { max-width: 160px; }
.wa-steps {
  margin: 10px 0 0;
  padding-inline-start: 1.25rem;
  line-height: 1.7;
  font-size: 0.9rem;
}
.wa-qr-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--line, #d0d7de);
  border-radius: 10px;
  text-align: center;
  background: #fafbfc;
}
.wa-qr-box img {
  width: min(260px, 70vw);
  height: auto;
  image-rendering: pixelated;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}
.wa-qr-box.hidden { display: none; }
.wa-qr-modal {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0 12px;
}
.wa-qr-modal img {
  width: min(320px, 78vw);
  height: auto;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  image-rendering: pixelated;
}
body.wa-local .wa-cloud-only { display: none; }
.isp-panel {
  display: flex;
  flex-direction: column;
}
.isp-panel .isp-table-wrap {
  flex: 1 1 auto;
}
.isp-table-wrap,
.neighbors-table-wrap {
  min-height: 480px;
  height: calc(100vh - 320px);
  max-height: calc(100vh - 220px);
  overflow: auto;
  border-radius: var(--radius-sm);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* أزرار نزول/صعود القائمة الطويلة */
.scroll-jumps {
  position: fixed;
  left: 18px;
  bottom: 24px;
  z-index: 60;
  display: none;
  flex-direction: column;
  gap: 8px;
}
.scroll-jumps.is-on { display: flex; }
.scroll-jump-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #0f766e, #115e59);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.22);
}
.scroll-jump-btn[data-scroll="top"] {
  background: linear-gradient(180deg, #334155, #0f172a);
}
.scroll-jump-btn:hover { filter: brightness(1.06); }
.isp-dense { font-size: 0.8rem; }
.isp-dense th,
.isp-dense td {
  padding: 5px 8px;
  line-height: 1.35;
  vertical-align: middle;
}
.isp-dense thead th {
  position: sticky;
  top: 0;
  background: #f7faf8;
  z-index: 1;
  font-size: 0.74rem;
  box-shadow: 0 1px 0 var(--line);
}

/* لوحة VPS — مشتركين / دفع / شبكات: صفوف أوضح وأكبر */
.admin-readable,
table.admin-readable {
  font-size: 1rem;
}
.admin-readable th,
.admin-readable td {
  padding: 12px 14px;
  line-height: 1.55;
  vertical-align: middle;
}
.admin-readable thead th {
  position: sticky;
  top: 0;
  background: #f0faf7;
  z-index: 1;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 1px 0 var(--line);
}
.admin-readable .mono { font-size: 0.95rem; }
.admin-readable .type-badge { font-size: 0.82rem; padding: 4px 10px; }
.admin-readable .row-actions .btn {
  padding: 6px 10px;
  font-size: 0.85rem;
}
.modal .admin-readable th,
.modal .admin-readable td {
  padding: 11px 12px;
  font-size: 1rem;
}
.isp-dense .isp-owner { font-weight: 700; max-width: 180px; }
.isp-dense .isp-pass { letter-spacing: 0.02em; }
.isp-traffic {
  color: #0f766e;
  font-weight: 700;
  white-space: nowrap;
}
.isp-filter-bar {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.isp-online,
.isp-offline {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
/* حلقة ثابتة بدل نبضة لا نهائية: مع ٥٢٧ صفاً كانت مئات العناصر تُعيد الرسم باستمرار */
.isp-online {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.22);
}
.isp-offline {
  background: #d1d5db;
  box-shadow: none;
}
.badge-online,
.badge-filter-online:not(.is-active) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(22, 163, 74, 0.12);
  color: #166534;
}
.badge-filter-online.is-active {
  background: #16a34a;
  color: #fff;
}
.isp-dense tr.isp-row-disabled td {
  opacity: 0.55;
  color: #6b7280;
  background: rgba(107, 114, 128, 0.08);
}
.isp-dense tr.isp-row-disabled .isp-owner { font-weight: 600; }
.isp-dense tr.isp-row-disabled .type-badge { opacity: 1; }
.isp-dense tr.isp-row-disabled .isp-online { opacity: 1; }
.isp-dense tr.isp-row-disabled .row-actions .btn { opacity: 0.95; }
.isp-dense .type-badge { font-size: 0.7rem; padding: 2px 6px; }
.isp-dense .row-actions .btn { white-space: nowrap; padding: 4px 8px; min-height: 28px; font-size: 0.74rem; }
.isp-dense .row-actions .btn.danger {
  background: rgba(180, 35, 24, 0.1);
  color: #8a1a12;
  border-color: rgba(180, 35, 24, 0.35);
}
.isp-dense .row-actions .btn.danger:hover {
  background: var(--danger);
  color: #fff;
}
.isp-panel .section-title { margin-bottom: 8px; }
.isp-setup-compact { margin-bottom: 8px; padding: 10px 12px; }
.isp-check-cell {
  width: 36px;
  text-align: center;
  vertical-align: middle;
}
.isp-check-cell input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.isp-bulk-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(11, 110, 79, 0.08);
  border: 1px solid rgba(11, 110, 79, 0.2);
}
.isp-bulk-bar.is-visible { display: flex; }
.isp-bulk-bar b { font-variant-numeric: tabular-nums; }
#isp-table tbody tr:has(.isp-row-check:checked) {
  background: rgba(11, 110, 79, 0.07);
}

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  line-height: 1.45;
  vertical-align: middle;
}
th { background: #f4faf7; font-weight: 700; font-size: 0.9rem; color: var(--teal-dark); }
.content > table {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}
.modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  overflow: hidden;
}
.modal h3 {
  margin: 0 0 6px;
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.3;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px 6px 2px;
}
.modal-body > label,
.modal .fx-box > label {
  margin: 6px 0 2px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.25;
}
.modal-body > label:first-child { margin-top: 0; }
.modal input,
.modal select,
.modal textarea {
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.92rem;
}
.modal textarea { min-height: 52px; max-height: 90px; resize: vertical; }
.modal .fx-box {
  margin: 6px 0;
  padding: 8px;
  border-radius: 10px;
}
.modal .fx-preview {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 0.82rem;
  line-height: 1.35;
}
.modal-hint {
  margin: 4px 0 0 !important;
  font-size: 0.75rem !important;
  text-align: right;
  line-height: 1.3;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  flex-shrink: 0;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
  position: relative;
  z-index: 2;
}
.modal-actions .btn {
  padding: 9px 14px;
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--teal-dark);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.section-card { padding: 20px 22px; }
.section-card + .section-card { margin-top: var(--space-4); }
.section-title {
  margin: 0 0 14px;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.35;
  color: var(--teal-dark);
}
.muted {
  color: var(--muted);
  margin: 0 0 10px;
  font-size: 0.92rem;
  line-height: 1.55;
}
.path-box {
  background: #f4faf7;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  direction: ltr;
  text-align: left;
  word-break: break-all;
  line-height: 1.5;
}
.mono { font-family: Consolas, "Courier New", monospace; font-size: 0.9rem; }
.copy-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.copy-row:last-child { border-bottom: 0; }
.copy-row-label {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 6px;
}
.copy-row-value {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.copy-row-value .copy-target {
  flex: 1 1 auto;
  min-width: 180px;
  display: block;
  direction: ltr;
  text-align: left;
  background: #f4faf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  word-break: break-all;
  font-size: 0.95rem;
}
.copy-row-value .copy-target:hover { border-color: #0f766e; }
.copy-row-hint { margin-top: 4px; font-size: 12px; line-height: 1.5; }
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
}
.ops-table { margin: 0; border-radius: 0; box-shadow: none; }
.ops-table th { white-space: nowrap; }
.ops-table th,
.ops-table td {
  padding: 10px 12px;
}
.ops-table td.num, .ops-table th.num { text-align: left; font-variant-numeric: tabular-nums; }
.ops-table td.desc { max-width: 260px; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.ops-table td.in { color: #0b6e4f; font-weight: 700; }
.ops-table td.out { color: #b42318; font-weight: 700; }
.type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}
.badge-in { background: rgba(11,110,79,0.12); color: #084c37; }
.badge-out { background: rgba(180,35,24,0.12); color: #8a1a12; }
.badge-neutral { background: rgba(92,107,99,0.12); color: #3d4842; }
.badge-transfer { background: rgba(30,90,160,0.12); color: #1a4f8a; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: var(--space-4); }
.chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.25;
}

.fx-box {
  margin: 12px 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: #f7fbf8;
}
.fx-preview {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--line);
  color: var(--teal-dark);
  font-size: 0.92rem;
  line-height: 1.55;
}
.fx-preview.warn { color: var(--danger); border-color: rgba(180,35,24,0.25); }

.statement-head { background: linear-gradient(135deg, #f7fbf8, #fff); }
.statement-brand {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: 14px;
  line-height: 1.3;
}
.statement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-3);
}
.statement-grid .strong { font-weight: 800; margin-top: 4px; line-height: 1.35; }
.bal-card .debt-line {
  margin-top: 8px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 700;
}
.statement-table td, .statement-table th { white-space: nowrap; }
.statement-table td.desc { white-space: normal; min-width: 160px; }

/* تقرير الشبكة — مدفوع / غير مدفوع */
.isp-report-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 14px 0 18px;
}
.isp-kpi {
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  border: 1px solid var(--border);
}
.isp-kpi-paid {
  background: rgba(11, 110, 79, 0.08);
  border-color: rgba(11, 110, 79, 0.22);
}
.isp-kpi-unpaid {
  background: rgba(180, 35, 24, 0.07);
  border-color: rgba(180, 35, 24, 0.2);
}
.isp-kpi-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}
.isp-kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 6px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.isp-kpi-paid .isp-kpi-value { color: #0b6e4f; }
.isp-kpi-unpaid .isp-kpi-value { color: #b42318; }
.isp-kpi-sub { margin-top: 4px; font-size: 0.85rem; color: var(--muted); line-height: 1.4; }
.isp-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  align-items: start;
}
.isp-report-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
.isp-report-simple .isp-kpi-label { font-size: 0.9rem; }
.isp-report-details {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(255,255,255,0.5);
}
.isp-report-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
  line-height: 1.4;
}
.isp-report-details summary::-webkit-details-marker { display: none; }
.isp-report-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(255, 255, 255, 0.55);
}
.isp-report-panel h4 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  line-height: 1.35;
}
.isp-report-panel-paid { border-top: 3px solid #0b6e4f; }
.isp-report-panel-unpaid { border-top: 3px solid #b42318; }
.isp-report-scroll { max-height: min(62vh, 720px); overflow: auto; }
.isp-report-panel tfoot th {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* توحيد مسافات الأقسام داخل الصفحات */
.content .section-card h3:not(.section-title) {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--teal-dark);
  line-height: 1.35;
}
.content .toolbar + .table-wrap,
.content .toolbar + table {
  margin-top: 0;
}
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 6px;
  font-weight: 500;
  font-size: 0.88rem;
  line-height: 1.4;
}
.remember-row input {
  width: auto;
  min-height: 0;
  padding: 0;
}

@media (max-width: 1100px) {
  .isp-report-grid, .isp-report-kpis { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .toolbar, .toast { display: none !important; }
  .app-view { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 900px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ==========================================================================
   طبقة التنسيق المهني — بصري فقط.
   لا أسماء أصناف جديدة مطلوبة في HTML ولا تغيير في أي data-action.
   ========================================================================== */

:root {
  /* سلّم خطوط واحد بدل أحجام متفرقة */
  --fs-xs: 0.78rem;
  --fs-sm: 0.86rem;
  --fs-md: 0.94rem;
  --fs-lg: 1.06rem;
  --fs-xl: 1.28rem;
  --fs-2xl: 1.55rem;

  --teal-050: #f2f9f6;
  --teal-100: #e2f1ea;
  --teal-600: #0b6e4f;
  --teal-700: #084c37;

  --ring: 0 0 0 3px rgba(11, 110, 79, 0.18);
  --shadow-sm: 0 1px 2px rgba(8, 76, 55, 0.06);
  --shadow-md: 0 2px 10px rgba(8, 76, 55, 0.07);
}

body { font-size: var(--fs-md); }

/* --- الشريط الجانبي: مؤشر نشط واضح وتباين أعلى --- */
.sidebar { padding: 18px 12px 12px; gap: 0; }
.sidebar-brand {
  font-size: var(--fs-xl);
  padding: 6px 12px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.nav-btn {
  position: relative;
  padding: 10px 14px;
  margin-bottom: 2px;
  font-size: var(--fs-sm);
  color: rgba(255, 255, 255, 0.82);
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.nav-btn.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 700;
}
.nav-btn.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: #fff;
}
.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin-top: auto;
  padding: 12px 6px 4px;
}
#user-chip { font-size: var(--fs-sm); opacity: 0.92; }
.sidebar .btn.ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
}
.sidebar .btn.ghost:hover { background: rgba(255, 255, 255, 0.16); }

/* --- الشريط العلوي --- */
.topbar {
  padding: 13px 24px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.topbar h1 { font-size: var(--fs-xl); letter-spacing: 0; }

/* --- البطاقات والأقسام --- */
.card,
.section-card,
.table-wrap {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.card { padding: 16px 18px; }
.section-card { padding: 18px 20px; }
.section-title {
  font-size: var(--fs-lg);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
/* عناوين داخل صفوف مرنة تبقى بلا خط فاصل */
.isp-prices-head .section-title,
.modal .section-title {
  border-bottom: 0;
  padding-bottom: 0;
}
.card .label { font-size: var(--fs-sm); }
.card .value { font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; }
.muted { font-size: var(--fs-sm); }

/* --- الأزرار --- */
.btn {
  padding: 8px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: none;
}
.btn:hover { filter: none; background: var(--teal-050); border-color: rgba(11, 110, 79, 0.3); }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.danger:hover { background: #8a1a12; border-color: #8a1a12; }
.btn.ghost:hover { background: rgba(11, 110, 79, 0.08); }
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn:disabled,
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-sm { font-size: var(--fs-xs); }

/* --- الحقول: حلقة تركيز بلا قفزة تخطيط --- */
input, select, textarea { font-size: var(--fs-md); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: var(--ring);
}
label { font-size: var(--fs-sm); }

/* --- الجداول --- */
table { box-shadow: none; }
th {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--teal-dark);
  background: var(--teal-050);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { font-size: var(--fs-sm); }
tbody tr:nth-child(even) > td { background: rgba(11, 110, 79, 0.022); }
tbody tr:hover > td { background: var(--teal-100); }
tbody tr:last-child > td { border-bottom: 0; }
.mono, td.num, th.num { font-variant-numeric: tabular-nums; }
.isp-dense thead th,
.admin-readable thead th { background: var(--teal-050); }
.isp-dense .isp-owner { font-weight: 700; }
#isp-table tbody tr:has(.isp-row-check:checked) > td {
  background: rgba(11, 110, 79, 0.09);
}

/* --- الشارات والرقائق --- */
.type-badge,
.badge,
.chip {
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.3;
  border-radius: 999px;
  white-space: nowrap;
}
.badge { background: var(--teal-100); color: var(--teal-dark); }
.chip { box-shadow: none; }
button.badge-filter { box-shadow: none; transition: background 0.12s ease, color 0.12s ease; }
button.badge-filter:hover { transform: none; background: var(--teal-100); }
button.badge-filter.is-active { box-shadow: none; }

/* --- النوافذ المنبثقة --- */
.modal-bg { background: rgba(12, 30, 24, 0.42); }
.modal {
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(8, 76, 55, 0.18);
  padding: 16px 18px 14px;
}
.modal h3 { font-size: var(--fs-lg); color: var(--teal-dark); }

/* --- الإشعار العائم --- */
.toast { font-size: var(--fs-sm); box-shadow: var(--shadow-md); }

/* --- أشرطة التمرير --- */
.content::-webkit-scrollbar,
.isp-table-wrap::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar { width: 10px; height: 10px; }
.content::-webkit-scrollbar-thumb,
.isp-table-wrap::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(11, 110, 79, 0.22);
  border-radius: 999px;
}
.content::-webkit-scrollbar-thumb:hover,
.isp-table-wrap::-webkit-scrollbar-thumb:hover { background: rgba(11, 110, 79, 0.35); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 999px; }

/* --- شاشة الدخول --- */
.login-card {
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 18px 44px rgba(6, 48, 34, 0.22);
}
.brand { font-size: var(--fs-2xl); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── صفحة الدفع التلقائي (شام كاش) ───────────────────────────────── */
.sc-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(11, 110, 79, .07);
  border: 1px solid rgba(11, 110, 79, .18);
}
.sc-hero > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sc-hero-label {
  font-size: .78rem; font-weight: 700; letter-spacing: .2px;
  color: var(--muted);
}
.sc-hero-value {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-weight: 700; font-size: .95rem;
}
.sc-hero-value > code, .sc-hero-value > a {
  min-width: 0; word-break: break-all; font-weight: 700;
}
.sc-hero-value a { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }

.sc-group {
  margin: 14px 0 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.sc-group > legend {
  padding: 0 8px;
  font-weight: 800;
  font-size: .86rem;
  color: var(--muted);
}
.sc-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 14px;
}
.sc-fields > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sc-fields label { font-size: .84rem; font-weight: 600; }
.sc-fields label .muted { font-weight: 400; }
.sc-fields input, .sc-fields select { width: 100%; }
.sc-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.sc-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed rgba(11, 110, 79, .35);
  background: rgba(11, 110, 79, .05);
}
.sc-preview.bad {
  border-color: rgba(200, 60, 40, .45);
  background: rgba(200, 60, 40, .06);
}
.sc-preview-title { font-weight: 800; font-size: .86rem; margin-bottom: 8px; }
.sc-preview.bad .sc-preview-title { color: #b3391f; }
.sc-preview-body {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  font-size: .9rem;
}
.sc-preview-body code {
  padding: 4px 10px; border-radius: 8px;
  background: var(--card); border: 1px solid var(--line);
  font-weight: 700; word-break: break-all;
}

/* ==========================================================================
   طبقة الضبط النهائية — أحجام موحّدة وقائمة مجمّعة.
   بصري فقط: لا تغيّر أي data-action ولا أي معرّف تعتمد عليه الشيفرة.
   ========================================================================== */

/* --- 1) مربّعات الاختيار كانت ترث ارتفاع الحقول (٤٤ بكسل) فتظهر عملاقة --- */
input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  min-height: 0;
  min-width: 0;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--teal-600);
  border-radius: 5px;
  cursor: pointer;
  vertical-align: -2px;
}
input[type="radio"] { border-radius: 50%; }

/* عنوان يحوي مربّع اختيار: صفّ أفقي مضبوط لا عمود متباعد */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  cursor: pointer;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  transition: border-color .12s ease, background .12s ease;
}
label:has(> input[type="checkbox"]:checked),
label:has(> input[type="radio"]:checked) {
  border-color: rgba(11, 110, 79, .45);
  background: var(--teal-050);
  color: var(--teal-700);
}
label:has(> input[type="checkbox"]):hover,
label:has(> input[type="radio"]):hover { border-color: rgba(11, 110, 79, .35); }
/* الاستثناءات: صفوف الجداول وسطر «حفظ الجلسة» تبقى بلا إطار */
td label:has(> input[type="checkbox"]),
th label:has(> input[type="checkbox"]),
label.remember-row:has(> input[type="checkbox"]) {
  border: 0;
  background: none;
  padding: 0;
}

/* صفّ حبّات اختيار متجاورة يلتفّ عند الضيق — بدل عمود طويل يمدّ القسم */
.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* --- 2) الحقول القصيرة لا تمتد بعرض الشاشة --- */
input[type="number"],
input[type="time"],
input[type="date"] { max-width: 220px; }
input[inputmode="numeric"] { max-width: 260px; }
/* الحقول القصيرة تبقى قصيرة أينما وُضعت — رقم من ٠ إلى ٢٣ لا يحتاج عرض الشاشة */

/* --- 3) القائمة الجانبية: مجموعات معنونة بدل ١٥ زراً متساوية --- */
.sidebar { padding: 16px 10px 10px; }
.sidebar-brand { padding: 4px 12px 14px; margin-bottom: 6px; }
.nav-group {
  margin: 9px 6px 3px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
  text-transform: uppercase;
}
.nav-group:first-child { margin-top: 2px; }
#nav .nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  margin-bottom: 0;
  font-size: 0.83rem;
  line-height: 1.35;
  border-radius: 8px;
  text-align: start;
}
#nav .nav-btn .nav-ico {
  flex: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1;
  text-align: center;
  opacity: 0.75;
  filter: grayscale(0.25);
}
#nav .nav-btn.active .nav-ico { opacity: 1; filter: none; }
#nav .nav-btn .nav-txt { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* --- 4) الشريط العلوي والمحتوى: إيقاع رأسي واحد --- */
.content { padding: 18px 22px 26px; }
.content > .card + .card,
.content > .card + .grid,
.content > .grid + .card,
.content > .toolbar + .card,
.content > .card + .toolbar { margin-top: 14px; }

/* --- 5) شريط الأدوات: ارتفاع موحّد لكل عناصره --- */
.toolbar {
  align-items: center;
  gap: 8px;
  row-gap: 8px;
}
.toolbar .btn,
.toolbar input,
.toolbar select { min-height: 38px; }
.toolbar input,
.toolbar select { padding-top: 7px; padding-bottom: 7px; }
.btn { min-height: 38px; }
.btn.primary { box-shadow: none; }
input, select { min-height: 38px; padding: 8px 12px; }
textarea { padding: 10px 12px; }
label { margin: 12px 0 5px; }

/* --- 6) بطاقات المؤشرات: شبكة منتظمة لا بطاقة يتيمة --- */
.stat-grid,
.content > .grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.card .value { font-size: 1.42rem; }

/* --- 7) مجموعات الحقول داخل الأقسام --- */
fieldset.sc-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin: 0 0 14px;
  min-width: 0;
}
fieldset.sc-group > legend {
  padding: 0 8px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--teal-700);
}
fieldset.sc-group:last-of-type { margin-bottom: 0; }


/* --- النائب النصّي داخل حقول JSON يبقى بخط الواجهة لا بالخط الأحادي --- */
textarea.mono::placeholder,
input.mono::placeholder {
  font-family: var(--font);
  letter-spacing: 0;
  opacity: 0.62;
}

/* --- الشريط الجانبي: لا تمرير، الأقسام كلها ظاهرة --- */
.sidebar-brand { font-size: 1.14rem; padding: 2px 12px 11px; margin-bottom: 4px; }
#nav { gap: 0; overflow-y: auto; padding-bottom: 4px; }
.sidebar-foot { padding: 10px 6px 2px; }
.sidebar .btn.ghost { min-height: 34px; padding: 6px 12px; }
#user-chip { font-size: 0.78rem; margin-bottom: 6px; }

/* --- الجداول: كثافة أعلى، فالصف كان ٥٩ بكسل بسبب ارتفاع الزر داخله --- */
th, td { padding: 8px 12px; }
td .btn,
th .btn {
  min-height: 30px;
  padding: 4px 11px;
  font-size: var(--fs-xs);
}
td .btn + .btn { margin-inline-start: 5px; }
/* أحجام الملفات والأرقام تبقى بترتيب لاتيني داخل نص عربي */
td .size, td.num, .mono { direction: ltr; unicode-bidi: isolate; }

/* --- شريط الأدوات أعلى القوائم: سطر واحد مرتب --- */
.toolbar > .btn,
.toolbar > input,
.toolbar > select { margin: 0; }
.toolbar input[type="search"],
.toolbar input:not([type]),
.toolbar input[type="text"] { min-width: 220px; max-width: 340px; }

/* ==========================================================================
   الشريط الجانبي لا يختفي أبداً.
   كانت قاعدتان تضعان `.sidebar { display: none }` تحت 900 بكسل فيبقى
   المستخدم بلا أي وسيلة تنقّل — وهذا سبب «الضياع» داخل التطبيق.
   نستبدل الإخفاء بشريط أيقونات مضغوط.
   ========================================================================== */
@media (max-width: 1180px) {
  :root { --sidebar-w: 208px; }
  #nav .nav-btn { font-size: 0.79rem; padding: 6px 9px; gap: 7px; }
  .content { padding: 14px 16px 22px; }
  .topbar { padding: 11px 16px; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 62px; }
  .app-view { grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar { display: flex; padding: 10px 6px 8px; }
  .sidebar-brand {
    font-size: 0.9rem;
    padding: 2px 0 8px;
    text-align: center;
    letter-spacing: 0;
  }
  .sidebar-brand::after { display: none; }
  /* عناوين المجموعات تصير خطاً فاصلاً */
  .nav-group {
    height: 1px;
    margin: 7px 8px;
    padding: 0;
    overflow: hidden;
    text-indent: -999px;
    background: rgba(255, 255, 255, 0.16);
  }
  #nav .nav-btn {
    justify-content: center;
    padding: 9px 0;
    gap: 0;
  }
  #nav .nav-btn .nav-txt { display: none; }
  #nav .nav-btn .nav-ico { flex: 0 0 auto; font-size: 1.1rem; opacity: 0.9; }
  #nav .nav-btn.active::before { inset-inline-start: 0; width: 2px; }
  #user-chip { display: none; }
  .sidebar-foot { padding: 8px 2px 2px; }
  .sidebar .btn.ghost { padding: 6px 0; font-size: 0.72rem; }
  .topbar { padding: 10px 14px; }
  #page-title { font-size: 1.06rem; }
  .content { padding: 12px 14px 20px; }
}

/* --- زر الخطر كان أحمر مصمتاً بجوار البرتقالي الأساسي فيختلطان --- */
.btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.42);
  font-weight: 700;
}
.btn.danger:hover {
  background: rgba(180, 35, 24, 0.08);
  border-color: var(--danger);
  color: var(--danger);
}
/* الحذف النهائي داخل النوافذ يبقى مصمتاً — فعل مقصود لا اختصار */
.modal .btn.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.modal .btn.danger:hover { background: #8a1a12; color: #fff; }

/* --- عمود «ينتهي» وحده لا يُكسر على سطرين. تعميم nowrap على بقية
   الخلايا وسّع الجدول فخرجت أزرار «تعديل/نسخ» خارج الإطار. --- */
#isp-table td:nth-child(8),
#isp-table th:nth-child(8) { white-space: nowrap; }
/* الأزرار على سطر واحد في جداول سطح المكتب فقط — لوحة المنصة تلتفّ بأزرارها
   في صفّين ضمن عرض محدود، وفرض nowrap عليها يمدّ صفوفها بلا داعٍ. */
.isp-dense td.row-actions,
.neighbors-table-wrap td.row-actions { white-space: nowrap; }

/* --- سطر «صيغة التعليق»: العربي بخط الواجهة والرموز فقط بالخط الأحادي --- */
.muted .mono { letter-spacing: 0; font-weight: 600; }

/* --- عمود الإجراءات يبقى ملتصقاً بحافة الجدول عند التمرير الأفقي،
   فالجداول العريضة كانت تُخفي «تعديل/نسخ» و«كلاود/محلي» خارج الإطار --- */
/* التثبيت للقوائم العريضة فقط — في جدول ضيق لا يمرّر أفقياً كان العمود
   ينفصل عن الجدول ويلتصق بحافة الغلاف. */
/* أُلغي تثبيت عمود الإجراءات.
   الخلية المثبّتة تحتاج خلفية معتمة تغطّي ما يمرّ تحتها، وألوان صفوف هذا
   الجدول شفافة (المعطّل بشفافية ٥٥٪ فوق رمادي) — فأي لون معتم يخالف لون
   الصف وتظهر حافة تُقرأ كخط تحت «إجراءات». الجدول هنا يسع أعمدته أصلاً،
   ولو ضاقت النافذة يُمرَّر أفقياً كأي جدول. النظافة أولى من ميزة نادرة. */
td.row-actions { padding-inline: 10px; }

/* الجدول كان `overflow:hidden` (لقصّ الزوايا) فصار هو حاوية التمرير
   لـ position:sticky وأبطله. ننقل القصّ إلى الغلاف الذي يمرّر فعلاً. */
.content table { overflow: visible; }
.table-wrap,
.isp-table-wrap {
  border-radius: 0;
  overflow: auto;
}

/* خلية الإجراءات تتبع صفها في الشفافية والخلفية معاً — أي استثناء لها يجعلها
   تبدو كطبقة منفصلة فوق الجدول. أزرارها وحدها تُخفَّت في الصف المعطّل. */
.isp-dense tr.isp-row-disabled td.row-actions .btn { opacity: 0.9; }

/* ==========================================================================
   تنسيق داخل الأقسام — إيقاع واحد لكل البطاقات والحقول والأشرطة.
   كانت كل صفحة تبني حقولها بأسلوبها فتختلف الأحجام والمسافات بين قسم وآخر.
   ========================================================================== */

/* عنوان القسم: مقاس واحد ومسافة واحدة في كل الصفحات */
.content .section-card > .section-title {
  font-size: 1.02rem;
  margin: 0 0 12px;
  padding-bottom: 9px;
}
.content .section-card > .section-title + .muted { margin-top: -4px; }

/* الوصف تحت العنوان: مسافة موحّدة قبل أول عنصر تفاعلي */
.content .section-card > .muted:first-of-type { margin: 0 0 14px; }

/* شبكات الحقول: نفس العرض الأدنى والفراغ أينما استُعملت */
.content .section-card .grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 12px;
  align-items: end;
}
.content .section-card .grid > div { min-width: 0; }
.content .section-card .grid label {
  margin: 0 0 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content .section-card .grid input,
.content .section-card .grid select { width: 100%; }

/* شريط الأزرار داخل بطاقة: مسافة علوية واحدة ومحاذاة واحدة */
.content .section-card > .toolbar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  gap: 8px;
}
.content .section-card > .toolbar:first-child,
.content .section-card > .toolbar.isp-filter-bar {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

/* بطاقة داخل بطاقة: إطار أخف حتى لا يبدو إطاران متساويان */
.content .section-card .section-card {
  box-shadow: none;
  background: var(--teal-050);
  border-color: rgba(11, 110, 79, 0.14);
}

/* جدول يلي شريط أدوات: مسافة واحدة */
.content .section-card .toolbar + .table-wrap,
.content .section-card .toolbar + table { margin-top: 12px; }

/* رأس أسعار البروفايلات */
.isp-prices-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

/* --- بطاقة مطويّة: تفاصيل ثانوية لا تزيح المحتوى الرئيسي --- */
.fold-card > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  margin: 0;
}
.fold-card > summary::-webkit-details-marker { display: none; }
.fold-card > summary .section-title {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--teal-dark);
  border: 0;
  padding: 0;
  margin: 0;
}
.fold-card > summary::after {
  content: "▾";
  margin-inline-start: auto;
  font-size: 0.8rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.fold-card[open] > summary::after { transform: rotate(180deg); }
.fold-card[open] > summary {
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

/* ==========================================================================
   عرض المحتوى داخل الأقسام.
   المشكلة: كل جدول يمتد بعرض الصفحة مهما قلّت أعمدته، فتتباعد الأرقام عن
   عناوينها وتصير القراءة متعبة؛ وبعض الأقسام بلا عنوان أصلاً.
   ========================================================================== */

/* 1) رأس القسم: العنوان والوصف يميناً والفعل الرئيسي يساراً على سطر واحد */
.sec-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.sec-head > div { min-width: 0; flex: 1 1 260px; }
.sec-head .section-title {
  margin: 0 0 4px;
  padding: 0;
  border: 0;
}
.sec-head .muted { margin: 0; }
.sec-head > .btn { flex: 0 0 auto; }

/* 2) جدول قليل الأعمدة يأخذ عرض محتواه لا عرض الصفحة */
.fit-table {
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.fit-table > table { width: auto; min-width: min(100%, 520px); }

/* 3) الأعمدة الرقمية: محاذاة واحدة وأرقام متساوية العرض */
th.num, td.num {
  text-align: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.num { font-weight: 700; }

/* 4) عمود الإجراءات في جداول سطح المكتب الطويلة: لا يتمدّد ولا ينكمش دون
   عرض أزراره. `width: 1%` وحده كان يضغط الخلية إلى 20 بكسل — وهي حاوية flex
   فأقل عرض لها صفر — فتخرج الأزرار من الجدول وتُرسم على خلفية الصفحة.
   لا نطبّقه على لوحة المنصة: أزرارها كثيرة وتلتفّ في صفّين ضمن عرض محدود،
   وضغط الخلية هناك يجعلها زراً في كل سطر. */
.isp-dense th.row-actions,
.isp-dense td.row-actions,
.neighbors-table-wrap th.row-actions,
.neighbors-table-wrap td.row-actions {
  width: 1%;
  min-width: max-content;
  white-space: nowrap;
}

/* 5) المحتوى الطويل لا يتجاوز عرض القراءة المريح */
.content .section-card > .muted,
.content .section-card > p { max-width: 92ch; }

/* 6) بطاقة بلا محتوى كافٍ لا تُمدَّد فارغة */
.content .section-card > .table-wrap { max-height: none; }

/* صف الشارات تحت رأس القسم */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

/* شعار «راوتر X» فوق اسم المكتب في شاشة الدخول — نفس الأيقونة التي على الجوال */
.login-hero-logo {
  display: block;
  margin: 0 auto 14px;
  width: 96px;
  height: 96px;
  object-fit: contain;
  filter: drop-shadow(0 8px 20px rgba(15, 118, 110, .30));
}

/* ── لغة الدفتر: «له» مالٌ للعميل عندنا، «عليه» مالٌ عند العميل يجب أن يعود.
   اللون وحده لا يكفي لمن لا يميّزه، فالكلمة مكتوبة دائماً بجانب الرقم. */
.bal-due   { color: var(--success, #1b7f4b); font-weight: 800; }
.bal-owed  { color: var(--danger, #a3221a); font-weight: 800; }
.bal-zero  { color: var(--muted, #6b7280); font-weight: 600; }

/* زرّ صغير داخل صفوف كشف الحساب — لا يزاحم الأرقام */
.btn.sm {
  padding: 3px 10px;
  font-size: 12px;
  min-height: 26px;
  border-radius: 8px;
}

/* عمودا الدفتر — «له» يدخل و«عليه» يخرج، لونٌ خفيف يفصلهما بلا صخب */
.col-due  { color: var(--success, #1b7f4b); font-weight: 700; }
.col-owed { color: var(--danger,  #a3221a); font-weight: 700; }
th.col-due, th.col-owed { font-weight: 900; }

/* الحساب الرئيسي — يُقرأ من نظرة، ولا أزرار إلى جانبه */
.owner-badge {
  background: var(--teal, #0f766e);
  color: #fff;
  font-weight: 800;
  margin-inline-start: 6px;
}

/* صفّ الحساب الرئيسي — يتقدّم الجدول ويُقرأ أنه ليس كبقيّة الصفوف */
.owner-row { background: rgba(15, 118, 110, 0.06); }
.owner-row td { font-weight: 700; }

/* صفّ «مفتاح: قيمة» في نوافذ لوحة المنصة */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.kv > span { color: var(--muted, #5B716C); }
.kv > b { text-align: end; word-break: break-all; }

/* ===== بطاقة شبكة في نافذة «شبكات الحساب» =====
   العناوين تُكتب يساراً والتسميات يميناً؛ خلطهما في سطر واحد كان يقلب
   الأرقام على الشاشة فتُقرأ المنافذ خطأً. لكلٍّ صفّه واتجاهه. */
.net-card { border: 1px solid var(--line, #DCE5E2); border-radius: 14px; padding: 0; margin-bottom: 14px; overflow: hidden; background: var(--card, #fff); }
.net-card > header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; background: rgba(15, 118, 110, 0.05); border-bottom: 1px solid var(--line, #DCE5E2); }
.net-card > header h4 { margin: 0; font-size: 15px; font-weight: 800; }
.net-body { padding: 12px 16px; }
.net-sec { margin-top: 14px; }
.net-sec:first-child { margin-top: 0; }
.net-sec > h5 { margin: 0 0 7px; font-size: 12px; font-weight: 800; letter-spacing: .2px; color: var(--muted, #5B716C); text-transform: none; }
.net-row { display: grid; grid-template-columns: minmax(96px, auto) 1fr auto; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line, #E6EDEB); }
.net-sec > .net-row:first-of-type { border-top: 0; }
.net-row > .k { color: var(--muted, #5B716C); font-size: 13px; }
.net-row > .v { direction: ltr; unicode-bidi: isolate; text-align: left; font-family: Consolas, "Courier New", monospace; font-size: 13px; font-weight: 700; word-break: break-all; }
.net-row > .v.plain { font-family: inherit; direction: rtl; text-align: right; font-weight: 700; }
.net-copy { border: 1px solid var(--line, #DCE5E2); background: transparent; border-radius: 8px; padding: 3px 9px; font-size: 12px; cursor: pointer; color: var(--muted, #5B716C); white-space: nowrap; }
.net-copy:hover { background: rgba(15, 118, 110, 0.08); color: inherit; }
.net-meter { height: 8px; border-radius: 99px; background: #E3EAE8; overflow: hidden; margin-top: 8px; border: 1px solid var(--line, #DCE5E2); }
.net-meter > i { display: block; height: 100%; min-width: 3px; background: var(--brand, #0F766E); border-radius: 99px; }
.net-note { margin: 8px 0 0; font-size: 12px; color: var(--muted, #5B716C); }

/* ===== الجوال: لوحة المنصّة من المتصفّح ===== */
@media (max-width: 900px) {
  /* الصفحة تتمرّر: overflow:hidden كان لنافذة سطح المكتب لا للهاتف */
  html, body {
    overflow: auto;
    height: auto;
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
  }
  .app-view {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  /* القائمة: شريط أفقي أعلى الصفحة بدل إخفائها */
  .sidebar {
    display: block;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 6px 8px;
    overflow: visible;
  }
  .sidebar-brand, .sidebar-foot, .nav-group { display: none; }
  #nav {
    display: flex;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  #nav::-webkit-scrollbar { display: none; }
  #nav .nav-btn {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
  /* الأسماء تظهر مع الأيقونة — قاعدة لاحقة في الملف تُخفيها بـellipsis */
  #nav .nav-btn .nav-txt {
    display: inline !important;
    overflow: visible !important;
    text-overflow: clip !important;
    flex: 0 0 auto !important;
    min-width: max-content !important;
  }
  #nav .nav-btn .nav-ico { font-size: 0.95rem; }
  #nav .nav-btn .nav-badge, #nav .nav-btn .nav-count { display: none; }

  /* المحتوى والجداول */
  .content { padding: 12px 10px 28px; overflow: visible; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar h1 { font-size: 1.05rem; }
  .topbar-actions { flex-wrap: wrap; }
  .card, .panel { padding: 12px; }
  .table-wrap, .isp-table-wrap, .statement-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { font-size: 0.82rem; }
  th, td { padding: 7px 8px; white-space: nowrap; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 4px; }
  .btn, .btn.btn-sm { min-height: 36px; }

  /* الدخول: البطاقة تملأ العرض ولا تُقصّ */
  .login-view { padding: 14px; height: auto; min-height: 100vh; }
  .login-stage { width: 100%; max-width: 100%; border-radius: 18px; }
  .login-hero { min-height: 120px; padding: 18px 16px; }
  .login-hero-mark { font-size: 2.2rem; }
  .modal, .modal-card { width: min(94vw, 520px); max-height: 86vh; overflow: auto; }
}

/* مخارج الإيثرنت */
.ethernet-table-wrap { }
.eth-cable { font-weight:700; font-size:0.92rem; }
.eth-cable-on { color:#0a7a2e; }
.eth-cable-off { color:#b45309; }
.eth-row-running { background: rgba(16,185,129,0.06); }

.badge-paid { background:#10b981; color:#fff; border:none; padding:2px 6px; border-radius:8px; font-size:0.78rem; margin-inline-start:6px; }

.badge-quota { background:#0ea5e9; color:#fff; border:none; padding:2px 6px; border-radius:8px; font-size:0.78rem; margin-inline-start:6px; }
