@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap");

:root {
  --navy-950: #021024;
  --navy-800: #052659;
  --blue-500: #5483b3;
  --blue-300: #7da0ca;
  --blue-100: #c1e8ff;
  --bg: #f3f8fc;
  --surface: #ffffff;
  --surface-soft: #f7fbfe;
  --ink: #021024;
  --muted: #51677e;
  --line: #d5e5f1;
  --line-strong: #a9c6dc;
  --teal: #052659;
  --teal-strong: #021024;
  --teal-soft: #e4f4fd;
  --blue: #5483b3;
  --blue-soft: #eaf5fc;
  --red: #d92d20;
  --red-soft: #fee2e2;
  --amber: #b86b00;
  --amber-soft: #fff4d8;
  --green: #168052;
  --green-soft: #dcfce7;
  --sidebar: #021024;
  --sidebar-soft: #052659;
  --sidebar-muted: #c1e8ff;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(2, 16, 36, 0.12);
  --shadow-soft: 0 8px 24px rgba(5, 38, 89, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% 0%, rgba(193, 232, 255, 0.7), transparent 30rem),
    linear-gradient(180deg, #f8fcff 0%, var(--bg) 100%);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.login-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  padding: 32px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 10%, rgba(125, 160, 202, 0.28), transparent 28rem),
    radial-gradient(circle at 92% 88%, rgba(84, 131, 179, 0.24), transparent 26rem),
    var(--navy-950);
}

.login-shell {
  width: min(1180px, 100%);
  min-height: min(760px, calc(100vh - 64px));
  display: grid;
  grid-template-columns: minmax(390px, 0.86fr) minmax(500px, 1.34fr);
  direction: ltr;
  background: #fff;
  border: 1px solid rgba(193, 232, 255, 0.28);
  border-radius: 28px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.34);
  overflow: hidden;
}

.login-panel,
.login-showcase {
  direction: rtl;
}

.login-panel {
  display: flex;
  flex-direction: column;
  padding: 42px clamp(32px, 4vw, 58px) 30px;
  background: #fff;
}

.login-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-logo {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 15px;
  background: linear-gradient(145deg, var(--navy-950), var(--navy-800));
  color: var(--blue-100);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(5, 38, 89, 0.2);
}

.login-panel-head strong,
.login-panel-head span {
  display: block;
}

.login-panel-head strong { font-size: 16px; color: var(--navy-950); }
.login-panel-head span { margin-top: 1px; color: var(--muted); font-size: 11px; }

.login-welcome { margin: clamp(42px, 7vh, 72px) 0 26px; }
.login-eyebrow { color: var(--blue-500); font-size: 12px; font-weight: 800; }
.login-welcome h1 { margin: 7px 0 8px; font-size: clamp(25px, 3vw, 32px); line-height: 1.3; color: var(--navy-950); }
.login-welcome p { margin: 0; color: var(--muted); font-size: 13px; }

.login-form { display: grid; gap: 17px; }
.login-form label { display: grid; gap: 7px; }
.login-form label > span:first-child { color: var(--navy-950); font-size: 13px; font-weight: 800; }
.login-input-wrap { position: relative; display: block; }
.login-input-wrap input {
  width: 100%;
  height: 52px;
  padding: 0 43px 0 68px;
  border: 1px solid #ccdeeb;
  border-radius: 14px;
  background: #f8fbfd;
  font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.login-input-wrap input:focus { background: #fff; border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(84, 131, 179, .13); outline: none; }
.login-input-icon { position: absolute; z-index: 1; right: 16px; top: 50%; transform: translateY(-50%); color: var(--blue-500); font-size: 14px; pointer-events: none; }
.password-toggle {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 32px;
  padding: 4px 9px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--blue-500);
  font-size: 11px;
}
.password-toggle:hover { background: var(--blue-soft); border: 0; box-shadow: none; }
.login-submit {
  width: 100%;
  min-height: 52px;
  justify-content: space-between;
  margin-top: 3px;
  padding: 11px 20px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(125deg, var(--navy-950), var(--navy-800) 60%, var(--blue-500));
  color: #fff;
  box-shadow: 0 12px 26px rgba(5, 38, 89, .23);
}
.login-submit:hover { border: 0; color: #fff; transform: translateY(-1px); box-shadow: 0 15px 32px rgba(5, 38, 89, .3); }

.login-demo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.login-demo-title { grid-column: 1 / -1; color: var(--muted); font-size: 11px; font-weight: 700; }
.demo-account {
  min-height: 48px;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  box-shadow: none;
  text-align: right;
}
.demo-account span:first-child { display: grid; }
.demo-account strong { font-size: 11px; color: var(--navy-950); }
.demo-account small { font-size: 9px; color: var(--muted); direction: ltr; }
.demo-account > span:last-child { color: var(--blue-500); font-size: 10px; }
.login-secure { margin: auto 0 0; padding-top: 22px; color: #7890a6; text-align: center; font-size: 10px; }
.login-secure span { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 4px; border-radius: 50%; background: var(--green-soft); color: var(--green); font-weight: 800; }

.login-showcase {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(48px, 6vw, 78px);
  color: #fff;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(84, 131, 179, .16), transparent 42%),
    linear-gradient(160deg, var(--navy-950) 0%, var(--navy-800) 58%, #174f87 100%);
}
.login-showcase::after { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .12; background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px); background-size: 54px 54px; mask-image: linear-gradient(to bottom, #000, transparent 75%); }
.showcase-glow { position: absolute; z-index: -1; border-radius: 50%; filter: blur(2px); }
.glow-one { width: 360px; height: 360px; top: -180px; left: -100px; background: rgba(193,232,255,.14); }
.glow-two { width: 280px; height: 280px; bottom: -150px; right: -80px; background: rgba(84,131,179,.25); }
.showcase-content { max-width: 560px; }
.showcase-badge { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid rgba(193,232,255,.22); border-radius: 99px; background: rgba(193,232,255,.08); color: var(--blue-100); font-size: 11px; font-weight: 700; }
.showcase-badge i { width: 7px; height: 7px; border-radius: 50%; background: #7ee0b2; box-shadow: 0 0 0 5px rgba(126,224,178,.1); }
.showcase-content h2 { margin: 24px 0 16px; font-size: clamp(40px, 5.2vw, 65px); line-height: 1.14; letter-spacing: -1.5px; }
.showcase-content h2 em { color: var(--blue-100); font-style: normal; }
.showcase-content > p { max-width: 510px; margin: 0; color: #bcd9ed; font-size: 15px; line-height: 1.9; }
.showcase-features { display: flex; flex-wrap: wrap; gap: 18px 26px; margin-top: 33px; }
.showcase-features article { display: flex; align-items: center; gap: 9px; min-width: 145px; }
.showcase-features article > span { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(193,232,255,.2); border-radius: 10px; color: var(--blue-100); font-size: 9px; }
.showcase-features strong,.showcase-features small { display: block; }
.showcase-features strong { font-size: 11px; }.showcase-features small { margin-top: 2px; color: #99bad3; font-size: 8px; }

.showcase-preview { width: min(470px, 88%); margin: 46px auto -108px; padding: 17px; border: 1px solid rgba(193,232,255,.2); border-radius: 20px 20px 0 0; background: rgba(2,16,36,.48); box-shadow: 0 -10px 50px rgba(0,0,0,.18); backdrop-filter: blur(14px); transform: perspective(900px) rotateX(4deg); transform-origin: bottom; }
.preview-top { display: flex; align-items: center; justify-content: space-between; color: #cbe8f8; font-size: 10px; }
.preview-top span { display: flex; gap: 4px; }.preview-top i { width: 6px; height: 6px; border-radius: 50%; background: var(--blue-300); opacity: .55; }
.preview-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.preview-metrics span { padding: 11px; border: 1px solid rgba(193,232,255,.12); border-radius: 11px; background: rgba(193,232,255,.06); }
.preview-metrics small,.preview-metrics strong { display: block; }.preview-metrics small { color: #9cbcd3; font-size: 8px; }.preview-metrics strong { margin-top: 3px; color: #fff; font-size: 17px; }
.preview-chart { height: 90px; display: flex; align-items: end; gap: 8px; margin-top: 12px; padding: 14px 11px 0; border-radius: 11px; background: rgba(193,232,255,.04); }
.preview-chart i { flex: 1; border-radius: 4px 4px 0 0; background: linear-gradient(to top, var(--blue-500), var(--blue-100)); opacity: .78; }

@media (max-width: 920px) {
  .login-body { padding: 18px; }
  .login-shell { width: min(560px, 100%); min-height: auto; grid-template-columns: 1fr; }
  .login-panel { padding: 32px; }
  .login-showcase { display: none; }
  .login-welcome { margin: 38px 0 24px; }
}

@media (max-width: 520px) {
  .login-body { padding: 0; place-items: stretch; background: #fff; }
  .login-shell { min-height: 100vh; border: 0; border-radius: 0; box-shadow: none; }
  .login-panel { padding: 26px 22px 20px; }
  .login-demo { grid-template-columns: 1fr; }
  .login-welcome h1 { font-size: 25px; }
}

a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 700;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(84, 131, 179, 0.13), transparent 32%),
    var(--sidebar);
  color: #fff;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 10px 0 32px rgba(2, 16, 36, 0.18);
  z-index: 30;
}

.sidebar-toggle,
.sidebar-close,
.sidebar-backdrop {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  padding: 6px 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--blue-100), var(--blue-300));
  color: var(--navy-950);
  font-weight: 800;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--sidebar-muted);
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 5px;
  margin-top: 12px;
}

.nav a {
  color: #d9f2ee;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-weight: 800;
  border: 1px solid transparent;
}

.nav a:hover,
.nav a.active {
  background: linear-gradient(135deg, var(--sidebar-soft), rgba(84, 131, 179, 0.52));
  border-color: rgba(193, 232, 255, 0.22);
  color: #fff;
  text-decoration: none;
}

.main {
  min-width: 0;
  padding: 28px;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.site-footer {
  margin-top: auto;
  padding: 26px 12px 4px;
  color: var(--muted);
  text-align: center;
  direction: ltr;
  font-size: 12px;
}

.site-footer a {
  color: inherit;
  font-weight: 700;
}

.login-footer {
  width: 100%;
  padding: 18px 12px 0;
  color: var(--blue-100);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.button,
button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.button:hover,
button:hover {
  text-decoration: none;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-soft);
}

.button.primary,
button.primary {
  background: linear-gradient(135deg, var(--navy-800), var(--blue-500));
  color: #fff;
  border-color: var(--teal);
}

.button.primary:hover,
button.primary:hover {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  border-color: var(--teal-strong);
}

.button.danger,
button.danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.button.whatsapp {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.button.mini,
button.mini {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.button:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.flash {
  position: fixed;
  top: 22px;
  left: 22px;
  z-index: 1000;
  width: min(420px, calc(100vw - 44px));
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid #86efac;
  background: var(--green-soft);
  color: #14532d;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  animation: toast-away 0.35s ease 5.5s forwards;
}

@keyframes toast-away {
  to { opacity: 0; transform: translateY(-12px); visibility: hidden; }
}

.flash.error {
  border-color: #fecaca;
  background: var(--red-soft);
  color: #991b1b;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metrics-grid.compact {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.metric {
  background: linear-gradient(145deg, #ffffff, #f6fbff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 800;
}

.metric strong {
  font-size: 25px;
  line-height: 1.2;
  color: var(--ink);
}

.metric.danger {
  border-color: #fecaca;
  background: #fff8f8;
}

.metric.warning {
  border-color: #f4d58a;
  background: #fffbeb;
}

.toolbar,
.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filters {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.filters label {
  flex: 1 1 170px;
}

.filters label:first-of-type {
  flex-basis: 260px;
}

.filters label,
.stack-form label,
.grid-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(14, 124, 113, 0.14);
  border-color: var(--teal);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.split.single {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel.narrow {
  max-width: 880px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.panel-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.panel-note {
  margin: 0;
  padding: 16px;
  color: var(--muted);
  line-height: 1.8;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #e7edf4;
  text-align: center;
  vertical-align: middle;
}

th {
  color: #475467;
  background: var(--surface-soft);
  font-size: 13px;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  color: #1d2939;
  background: #fff;
}

tr:hover td {
  background: #f8fcfb;
}

table.compact-table {
  min-width: 0;
  font-size: 13px;
}

.compact-table th,
.compact-table td {
  padding: 8px 9px;
  line-height: 1.35;
}

.compact-table th {
  font-size: 12px;
}

.customers-table td:nth-child(2),
.customers-table td:nth-child(5) {
  min-width: 110px;
  max-width: 220px;
  white-space: normal;
}

.customers-table .badge {
  padding: 5px 8px;
  font-size: 11px;
}

.customers-table .button.mini,
.customers-table button.mini {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

.overdue-table {
  table-layout: fixed;
}

.overdue-table th,
.overdue-table td {
  padding: 7px 7px;
  font-size: 12.5px;
  line-height: 1.35;
}

.overdue-table th:nth-child(1),
.overdue-table td:nth-child(1) {
  width: 58px;
}

.overdue-table th:nth-child(2),
.overdue-table td:nth-child(2) {
  width: 25%;
}

.overdue-table th:nth-child(3),
.overdue-table td:nth-child(3) {
  width: 13%;
  direction: ltr;
  text-align: left;
}

.overdue-table th:nth-child(4),
.overdue-table td:nth-child(4) {
  width: 105px;
}

.overdue-table th:nth-child(5),
.overdue-table td:nth-child(5) {
  width: 72px;
}

.overdue-table th:nth-child(6),
.overdue-table td:nth-child(6) {
  width: 105px;
}

.overdue-table th:nth-child(7),
.overdue-table td:nth-child(7) {
  width: 190px;
}

.employee-overdue-table th:nth-child(6),
.employee-overdue-table td:nth-child(6) {
  width: 190px;
}

.stack-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

.stack-cell small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.overdue-actions {
  gap: 5px;
  flex-wrap: wrap;
}

.overdue-actions .button.mini {
  min-height: 27px;
  padding: 4px 7px;
  font-size: 11px;
}

.installment-table,
.payment-events-table {
  table-layout: fixed;
}

.installment-table th,
.installment-table td,
.payment-events-table th,
.payment-events-table td {
  padding: 7px 8px;
  font-size: 12.5px;
}

.installment-table th:nth-child(1),
.installment-table td:nth-child(1) {
  width: 44px;
}

.installment-table th:nth-child(2),
.installment-table td:nth-child(2),
.installment-table th:nth-child(3),
.installment-table td:nth-child(3) {
  width: 105px;
}

.installment-table th:nth-child(7),
.installment-table td:nth-child(7) {
  width: 92px;
}

.installment-table .badge {
  padding: 5px 7px;
  font-size: 11px;
}

.payment-events-table th:nth-child(1),
.payment-events-table td:nth-child(1) {
  width: 120px;
}

.payment-events-table th:nth-child(2),
.payment-events-table td:nth-child(2) {
  width: 70px;
}

.payment-events-table th:nth-child(3),
.payment-events-table td:nth-child(3) {
  width: 120px;
}

.payment-events-table td:nth-child(4) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.num {
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.danger-text {
  color: var(--red);
  font-weight: 800;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  color: #087443;
  background: var(--green-soft);
}

.badge.danger {
  color: #b42318;
  background: var(--red-soft);
}

.badge.warning {
  color: #93370d;
  background: var(--amber-soft);
}

.badge.neutral {
  color: #344054;
  background: #eef2f6;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
  padding: 14px;
}

.source-grid a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--surface-soft);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.source-grid a:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  text-decoration: none;
}

.customer-hub-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.customer-hub-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
  position: relative;
  overflow: hidden;
}

.customer-hub-card:hover {
  text-decoration: none;
  border-color: var(--teal);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.11);
}

.customer-hub-card::before {
  content: "";
  width: 5px;
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  background: var(--teal);
}

.customer-hub-card.red::before {
  background: var(--red);
}

.customer-hub-card.amber::before {
  background: var(--amber);
}

.customer-hub-card.blue::before {
  background: var(--blue);
}

.customer-hub-card span {
  color: var(--muted);
  font-weight: 800;
}

.customer-hub-card strong {
  font-size: 36px;
  line-height: 1;
}

.customer-hub-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.customer-hub-card b {
  align-self: end;
  color: var(--teal-strong);
}

.reports-page {
  display: grid;
  gap: 18px;
}

.report-section {
  margin-bottom: 0;
}

.report-section .panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.report-metrics {
  padding: 16px;
  margin-bottom: 0;
}

.report-metrics .metric {
  box-shadow: none;
  background: #fbfdff;
}

.period-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 13px 16px;
  border: 1px solid #b7d9ee;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #eff9ff, #f9fcff);
  color: var(--navy-800);
}

.period-notice strong,
.period-notice span { display: block; }
.period-notice span { margin-top: 2px; color: var(--blue-500); font-size: 12px; direction: ltr; text-align: right; }
.period-notice small { color: var(--muted); }

.report-empty {
  display: grid;
  gap: 5px;
  margin: 0 16px 16px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.report-empty strong { color: var(--navy-800); }
.report-empty span { color: var(--muted); font-size: 12px; }

.audit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.audit-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.audit-item span { color: var(--muted); font-size: 12px; font-weight: 800; }
.audit-item strong { font-size: 22px; line-height: 1; }
.audit-item small { grid-column: 1 / -1; color: var(--muted); font-size: 10px; }
.audit-item.ok { border-color: #b7e3cc; background: #f5fcf8; }
.audit-item.ok strong { color: var(--green); }
.audit-item.needs-review { border-color: #f1cf85; background: #fffaf0; }
.audit-item.needs-review strong { color: var(--amber); }

.settings-page { display: grid; gap: 18px; }
.settings-top-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.settings-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-card-title h2 { margin: 0; font-size: 16px; }
.settings-card-title p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.settings-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--blue-soft);
  color: var(--navy-800);
  font-size: 18px;
  font-weight: 800;
}

.settings-count { margin-inline-start: auto; padding: 5px 9px; border-radius: 99px; background: var(--blue-soft); color: var(--blue-500); font-size: 10px; font-weight: 800; }
.settings-form { display: grid; gap: 15px; padding: 18px; }
.settings-form > .button { justify-self: start; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-fields label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.settings-fields input { min-height: 40px; border-radius: 11px; }
.settings-fields .settings-wide { grid-column: 1 / -1; }

.employee-list { display: grid; gap: 9px; padding: 14px; background: #f8fbfd; }
.employee-row { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.employee-row summary { display: flex; align-items: center; gap: 11px; padding: 12px 14px; cursor: pointer; list-style: none; }
.employee-row summary::-webkit-details-marker { display: none; }
.employee-row[open] { border-color: var(--blue-300); box-shadow: 0 8px 22px rgba(5,38,89,.07); }
.employee-row[open] summary { border-bottom: 1px solid var(--line); background: #fbfdff; }
.employee-avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; background: linear-gradient(145deg, var(--navy-800), var(--blue-500)); color: #fff; font-weight: 800; }
.employee-avatar.add { background: var(--blue-soft); color: var(--blue-500); font-size: 20px; }
.employee-summary { display: grid; margin-inline-end: auto; }
.employee-summary strong { font-size: 13px; }.employee-summary small { color: var(--muted); font-size: 10px; direction: ltr; text-align: right; }
.details-arrow { color: var(--blue-500); font-size: 18px; transition: transform .16s ease; }
.employee-row[open] .details-arrow { transform: rotate(180deg); }
.employee-edit-form { display: grid; gap: 15px; padding: 16px; }
.permissions-box { display: grid; gap: 8px; }
.permissions-box > strong { font-size: 11px; color: var(--muted); }
.permission-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.permission-pills label { position: relative; cursor: pointer; }
.permission-pills input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.permission-pills span { display: inline-flex; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; background: #fff; color: var(--muted); font-size: 10px; font-weight: 800; transition: .15s ease; }
.permission-pills input:checked + span { border-color: var(--blue-500); background: var(--blue-soft); color: var(--navy-800); }
.permission-pills input:focus + span { outline: 3px solid rgba(84,131,179,.16); }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.add-employee { border-style: dashed; }

.template-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.template-tags span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  font-weight: 800;
  direction: ltr;
}

.inventory-page {
  display: grid;
  gap: 16px;
}

.inventory-page .inventory-summary {
  margin-bottom: 0;
}

.inventory-period-filter {
  margin-bottom: 0;
}

.inventory-period-filter .filter-help {
  flex: 1 1 100%;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.inventory-category-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.inventory-category-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.inventory-category-nav a:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-strong);
  text-decoration: none;
}

.inventory-category-nav strong {
  min-width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
}

.inventory-section {
  overflow: hidden;
  margin-bottom: 0;
}

.inventory-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  border-inline-start: 4px solid var(--teal);
}

.inventory-section-head h2 {
  margin: 0;
  font-size: 18px;
}

.inventory-section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.inventory-section-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.inventory-section-summary div {
  padding: 12px 16px;
  border-inline-start: 1px solid var(--line);
}

.inventory-section-summary div:first-child {
  border-inline-start: 0;
}

.inventory-section-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.inventory-section-summary strong {
  font-size: 18px;
}

.inventory-table th {
  background: #f3f7fb;
}

.inventory-table td:first-child {
  min-width: 220px;
}

.pagination {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 16px;
}

.pagination a {
  min-width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.pagination a.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.customer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.customer-head h2 {
  margin: 10px 0 4px;
  font-size: 22px;
  line-height: 1.35;
}

.customer-head p {
  margin: 0;
  color: var(--muted);
}

.actions,
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions form {
  margin: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.row-actions form {
  margin: 0;
}

.details {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px 14px;
  padding: 16px;
  margin: 0;
}

.details dt {
  color: var(--muted);
  font-weight: 800;
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.stack-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.grid-form .wide,
.form-actions {
  grid-column: 1 / -1;
}

.warning-text {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid #f0cf85;
  border-radius: 12px;
  background: var(--amber-soft);
  color: var(--amber);
  font-weight: 700;
}

.calculated-box {
  background: var(--teal-soft);
  border: 1px solid #b8e5df;
  color: var(--teal-strong);
  border-radius: var(--radius);
  padding: 13px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: min(86vw, 350px);
    height: 100dvh;
    padding: 74px 18px 22px;
    overflow-y: auto;
    box-shadow: -16px 0 45px rgba(2, 16, 36, 0.28);
    transform: translateX(105%);
    transition: transform .24s ease;
  }

  .nav {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 11px 14px;
    border-radius: 14px;
  }

  .sidebar-toggle,
  .sidebar-close {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    color: var(--navy-800);
    box-shadow: var(--shadow-soft);
    font-size: 24px;
  }

  .sidebar-close {
    position: absolute;
    top: 16px;
    left: 16px;
    border-color: rgba(255,255,255,.2);
    background: var(--blue-500);
    color: #fff;
    font-size: 32px;
    line-height: 1;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(2, 16, 36, .58);
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
  }

  .sidebar-open {
    overflow: hidden;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .metrics-grid,
  .metrics-grid.compact,
  .customer-hub-grid,
  .split,
  .inventory-section-summary {
    grid-template-columns: 1fr;
  }

  .settings-top-grid,
  .audit-grid { grid-template-columns: 1fr; }

  .settings-fields.three { grid-template-columns: 1fr; }

  .inventory-section-summary div,
  .inventory-section-summary div:first-child {
    border-inline-start: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .customer-head {
    display: grid;
  }

  .topbar {
    padding: 14px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .topbar h1 {
    font-size: 22px;
  }

  .grid-form,
  .details {
    grid-template-columns: 1fr;
  }

  .filters label {
    width: 100%;
    flex-basis: 100%;
  }

  .filters > .button,
  .filters > button { flex: 1 1 100%; width: 100%; }

  .period-notice { display: grid; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-card-title { align-items: flex-start; }
  .settings-count { white-space: nowrap; }

  .inventory-category-nav a,
  .inventory-section-head {
    width: 100%;
  }

  .inventory-section-head {
    display: grid;
  }

  .overdue-table {
    display: block;
    width: 100%;
  }

  .overdue-table thead {
    display: none;
  }

  .overdue-table tbody {
    display: grid;
  }

  .overdue-table tr {
    display: block;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .overdue-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    width: 100% !important;
    padding: 6px 0;
    border-bottom: 0;
    text-align: right;
    white-space: normal;
  }

  .overdue-table td::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .overdue-table td:nth-child(1)::before {
    content: "ID";
  }

  .overdue-table td:nth-child(2)::before {
    content: "العميل";
  }

  .overdue-table td:nth-child(3)::before {
    content: "الهاتف";
  }

  .overdue-table td:nth-child(4)::before {
    content: "أقدم استحقاق";
  }

  .overdue-table td:nth-child(5)::before {
    content: "الأقساط";
  }

  .admin-overdue-table td:nth-child(6)::before {
    content: "المبلغ";
  }

  .admin-overdue-table td:nth-child(7)::before,
  .employee-overdue-table td:nth-child(6)::before {
    content: "التحصيل";
  }

  .overdue-table .stack-cell small {
    grid-column: 2;
  }

  .overdue-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 420px) {
  body { font-size: 14px; }
  .main { padding: 10px; }
  .sidebar { width: min(88vw, 340px); padding: 72px 14px 18px; }
  .brand { padding-inline: 4px; }
  .brand-mark { width: 38px; height: 38px; }
  .nav { grid-template-columns: 1fr; gap: 4px; }
  .nav a { padding: 8px 10px; }
  .topbar { gap: 10px; padding: 12px; }
  .topbar h1 { font-size: 19px; }
  .topbar .button { width: 100%; }
  .metric { padding: 14px; }
  .metric strong { font-size: 21px; }
  .panel-head { align-items: flex-start; padding: 13px; }
  .grid-form { padding: 13px; }
  .button, button { white-space: normal; text-align: center; }
  .inventory-category-nav { padding: 9px; }
  .inventory-section-head { padding: 13px; }
  .inventory-section-summary div { padding: 10px 13px; }
  .flash { top: 10px; left: 10px; width: calc(100vw - 20px); }
}
