:root {
  --bg: #eef2f6;
  --card: #f7f9fc;
  --line: #d5dee8;
  --ink: #1c2b3a;
  --muted: #5b6b7c;
  --brand: #0b6e8f;
  --brand-dark: #084e66;
  --gold: #c9a227;
  --ok: #1a7f4c;
  --bad: #c0392b;
  --warn: #c47b12;
  --white: #fff;
  --shadow: 0 10px 30px rgba(16, 40, 60, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  background: #e8edf3;
  color: var(--ink);
  direction: rtl;
}

a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.phone {
  display: flow-root;
  width: min(430px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px rgba(16, 40, 60, 0.08);
}
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 8px;
  padding: 12px 14px 6px;
  background: linear-gradient(180deg, #fde4f2 0%, #fdeef6 100%);
}
.app-title { grid-column: 2; grid-row: 1; text-align: center; font-weight: 800; font-size: 18px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.brand-dot {
  width: 22px; height: 22px; border-radius: 6px; background: #111; color: #fff;
  display: grid; place-items: center; font-size: 12px;
}
.app-tools { grid-column: 3; grid-row: 1; justify-self: end; display: flex; align-items: center; gap: 6px; }
.tool-ico { font-size: 16px; }
.icon-btn, .text-btn {
  border: 0; background: transparent; cursor: pointer; color: var(--ink);
  font: inherit; font-weight: 800;
}
.icon-btn { font-size: 28px; line-height: 1; }
.text-btn { font-size: 13px; color: var(--brand); }

.credit-hero {
  text-align: center;
  padding: 8px 20px 22px;
  background: linear-gradient(180deg, #fdeef6 0%, #e9fbf4 48%, #ffffff 100%);
}
.credit-label { color: #6b7280; font-size: 18px; font-weight: 600; }
.credit-num { font-size: 46px; font-weight: 800; letter-spacing: -0.04em; margin: 10px 0 8px; color: #111; }
.credit-limit {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 auto; padding: 6px 12px;
  border-radius: 999px; background: rgba(255,255,255,.72);
  color: #6b7280; font-size: 13px;
}

.status-card {
  margin: 6px 16px 16px;
  background: #fff;
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 10px 28px rgba(16, 40, 60, 0.08);
}
.status-card h3 { margin: 0 0 6px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.status-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.legal {
  margin: 0 18px 28px;
  color: #9aa3b2;
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}
.promo {
  margin: 8px 16px 28px;
  border-radius: 16px;
  padding: 18px 18px;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(90deg, #0b1220, #134e4a 50%, #0b1220);
}
.promo b { display: block; font-size: 16px; }
.promo span { font-size: 12px; opacity: .85; }
.promo .shop {
  background: #111; color: #7dd3c7; border: 1px solid #2dd4bf;
  border-radius: 999px; padding: 8px 14px; font-size: 12px; font-weight: 800;
  white-space: nowrap;
}

.menu-list { margin: 8px 4px 24px; }
.menu-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}
.menu-row .mi {
  width: 28px; font-size: 18px; text-align: center;
}
.menu-row .mt { flex: 1; font-weight: 700; }
.menu-row .chev { color: #c5cad3; font-size: 18px; }
.menu-row small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }

.section-h { margin: 18px 18px 6px; font-size: 16px; }
.hero {
  background: linear-gradient(135deg, #0b6e8f, #07364a);
  color: #fff; border-radius: 18px; padding: 22px 20px; margin: 12px 16px 16px;
  box-shadow: var(--shadow);
}
.hero h1 { margin: 0 0 8px; font-size: 24px; }
.hero p { margin: 0; opacity: .88; line-height: 1.7; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid #e4ebf2;
  border-radius: 16px;
  padding: 18px 16px 8px;
  margin: 0 16px 14px;
  box-shadow: var(--shadow);
}
.section-title {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  margin: 0 0 16px; font-size: 18px; color: var(--brand-dark);
}
.section-title .ico {
  width: 32px; height: 32px; border-radius: 10px;
  background: #dff1f6; color: var(--brand);
  display: grid; place-items: center; font-size: 16px;
}
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 14px; }

.field {
  display: grid;
  grid-template-columns: minmax(108px, 38%) minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
  margin-bottom: 12px;
}
.field > label {
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: start;
  unicode-bidi: isolate;
}
.req { color: #e11d48; margin-inline-start: 3px; font-weight: 800; }

.control {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.control input,
.control select,
.control textarea,
.control .file-box {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 1px solid #c9d3de;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.control textarea { min-height: 84px; resize: vertical; }
.control input::placeholder,
.control textarea::placeholder {
  color: #8a97a6;
}
.control input:focus,
.control select:focus,
.control textarea:focus,
.control .file-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11,110,143,.12);
}
.control select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%235b6b7c' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 38px;
  cursor: pointer;
}
.control input[type="date"] {
  position: relative;
  color: var(--ink);
}
.control input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.control input[type="date"]:invalid {
  color: transparent;
}
.control input[type="date"]:invalid::before {
  content: "اختر التاريخ";
  color: #8a97a6;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.addon {
  flex: 0 0 54px;
  width: 54px;
  max-width: 54px;
  min-height: 46px;
  border: 1px solid #c9d3de;
  background: #fff;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  color: #3d5266;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}
.addon svg {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
}
.addon.cc {
  flex-basis: 64px;
  width: 64px;
  max-width: 64px;
  cursor: default;
  font-size: 14px;
  font-weight: 800;
  gap: 0;
  color: var(--ink);
  direction: ltr;
  unicode-bidi: isolate;
}
.addon.cc small {
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
  font-weight: 700;
}

.file-box {
  display: flex;
  align-items: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.file-box .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  color: #8a97a6;
}
.file-box.has-file .file-name { color: var(--ink); }
.file-box input[type="file"] {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0;
  position: absolute;
}

.actions { display: flex; justify-content: center; margin: 18px 0 40px; }
.btn {
  border: 0; border-radius: 12px; padding: 13px 28px; cursor: pointer;
  font-weight: 800; font-size: 16px;
}
.btn-primary { background: linear-gradient(180deg, #1387ab, var(--brand)); color: #fff; min-width: 220px; }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }

.list { display: grid; gap: 12px; }
.item {
  background: #fff; border: 1px solid #e4ebf2; border-radius: 14px;
  padding: 16px; display: grid; gap: 8px; cursor: pointer;
}
.item:hover { border-color: #b9d5e2; }
.item-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 4px 10px; font-size: 12px; font-weight: 800;
}
.st-pending { background: #fff4d6; color: #8a5b00; }
.st-approved { background: #e4f8ec; color: #176b39; }
.st-rejected { background: #fde8e6; color: #a12616; }
.st-disbursed { background: #e3eefc; color: #1d4f91; }
.meta { color: var(--muted); font-size: 13px; line-height: 1.7; }
.reason { background: #fff6f5; color: #8d2418; border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.detail { background: #fff; padding: 8px 16px 28px; }
.bottom-bar {
  position: sticky; bottom: 0; background: #fff;
  padding: 12px 16px 18px; box-shadow: 0 -8px 20px rgba(0,0,0,.06);
}
.bottom-bar .btn { width: 100%; display: block; text-align: center; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; margin: 14px 0; font-size: 15px; }
.kv b { color: var(--muted); font-weight: 600; }
.amount-xl { font-size: 34px; font-weight: 800; color: var(--brand-dark); margin: 8px 0 18px; }
.loan-card { background: #f3f8fb; border-radius: 12px; padding: 14px; margin-top: 12px; }

.modal {
  position: fixed; inset: 0; background: rgba(8, 24, 36, .55);
  display: grid; place-items: center; padding: 16px; z-index: 40;
}
.modal-card {
  width: min(560px, 100%); background: #fff; border-radius: 16px;
  padding: 22px; max-height: 88vh; overflow: auto;
}
.modal-card h3 { margin: 0 0 12px; }
.contract { background: #f6f8fb; border-radius: 12px; padding: 12px 14px; line-height: 1.9; margin-bottom: 14px; }
.contract-modal { padding-bottom: 0; }
.contract-summary p { overflow-wrap: anywhere; }
.contract-summary dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px 12px; font-size: 13px; }
.contract-summary dt { color: var(--muted); }
.contract-summary dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.contract-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 8px; font-size: 13px; }
.contract-section h4 { font-size: 15px; margin: 8px 0; }
.contract-section ol { padding-inline-start: 24px; margin: 8px 0; }
.contract-section li { margin-bottom: 10px; }
.contract-formula { padding: 8px; background: #e7eef4; border-radius: 8px; margin-top: 6px; }
.contract-consent { position: sticky; bottom: 0; background: #fff; padding: 10px 0 16px; border-top: 1px solid var(--line); }
.contract-consent .agree { font-size: 13px; line-height: 1.6; }
.contract-consent .actions { gap: 8px; margin: 12px 0 0; }
.contract-consent .btn { min-width: 0; font-size: 13px; padding: 12px; }
.saved-contract { margin-top: 10px; }
.saved-contract summary { cursor: pointer; color: var(--brand); font-size: 13px; font-weight: 700; }
.saved-contract .contract { margin-top: 10px; }
.control input[readonly] { background: #edf3f7; font-weight: 700; }
.agree { display: flex; align-items: center; gap: 8px; margin: 10px 0 16px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #123; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50;
}
.login-card { width: min(420px, 92%); margin: 12vh auto; background: #fff; padding: 28px; border-radius: 18px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 16px; }
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--brand-dark); font-weight: 800; margin-bottom: 24px; }
.login-card .field { grid-template-columns: 1fr; gap: 8px; margin-bottom: 18px; }
.login-card .meta { margin-bottom: 24px; }
.login-card .btn-primary { width: 100%; min-width: 0; }
.auth-switch { text-align: center; font-size: 13px; margin: 22px 0 0; }
.auth-switch a { font-weight: 800; }
.auth-error { background: #fff1f0; color: var(--bad); border-radius: 10px; padding: 12px; font-size: 13px; }
.account-line { padding: 12px 18px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.menu-row .mt { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 360px) {
  .appbar { gap: 4px; padding-inline: 8px; }
  .app-title { font-size: 15px; gap: 4px; }
  .app-tools { gap: 4px; }
  .app-tools .tool-ico { display: none; }
}
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }

@media (max-width: 520px) {
  .topbar { padding: 12px 4%; }
  .field {
    grid-template-columns: minmax(96px, 36%) minmax(0, 1fr);
    gap: 8px;
  }
  .field > label { font-size: 12.5px; }
  .kv { grid-template-columns: 1fr; gap: 6px; }
  .addon { flex-basis: 48px; width: 48px; max-width: 48px; }
  .addon.cc { flex-basis: 58px; width: 58px; max-width: 58px; }
}
