:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e3e8f0;
  --text: #12233a;
  --muted: #5b6b82;
  --primary: #2b6de8;
  --primary-2: #1f56c4;
  --danger: #c0392b;
  --ok: #137a41;
  --shadow: 0 8px 24px rgba(18, 35, 58, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.view { min-height: 100vh; }

[hidden] { display: none !important; }

/* ---- login ---- */
#view-login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}
.brand { font-size: 26px; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 16px; }
.brand.small { font-size: 18px; }
.login-card h1 { font-size: 22px; margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.form-foot { margin-top: 16px; font-size: 12px; }

form label { display: block; margin: 14px 0 4px; font-size: 13px; font-weight: 600; }
form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fbfcfe;
}
form input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
form select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fbfcfe;
}
form select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---- registration (panel inside the single sign-in page) ---- */
.auth-panel {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.register-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 30px;
}
.register-card h1 { font-size: 22px; margin: 6px 0; }
.register-card form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 16px;
}
.register-card form .btn.primary { grid-column: 1 / -1; }
.success-card { text-align: center; max-width: 440px; }
.success-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #e7f5ec;
  color: var(--ok);
  font-size: 28px;
  line-height: 52px;
  font-weight: 800;
}

/* ---- link buttons ---- */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.link-btn:hover { color: var(--primary-2); }

.btn {
  display: inline-block;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn.primary {
  width: 100%;
  margin-top: 18px;
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-2); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: #eef2f8; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.alert {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  background: #fdecea;
  color: #8c1f16;
  border: 1px solid #f5c6bf;
}
.alert.ok { background: #e7f5ec; color: var(--ok); border-color: #bfe6cd; }

/* ---- dashboard ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.userbar { display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; }
.user-name { font-weight: 700; }
.user-id { font-size: 12px; color: var(--muted); }

/* ---- role switch bar (server-authoritative /api/roles/me) ---- */
.role-switch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role-switch button.role-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.role-switch button.role-btn:hover { background: var(--primary-2); color: #fff; }
.role-switch button.role-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- in-page quick navigation (links only to existing sections) ---- */
.dash-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.dash-nav-link {
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.dash-nav-link:hover { background: #eef2f8; color: var(--primary-2); }
h2[id] { scroll-margin-top: 72px; }

.content { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px;
  margin-bottom: 16px;
}
.card h2 { font-size: 17px; margin: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.pill {
  background: #eef2f8;
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.wallet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.wallet-item { background: #f7f9ff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.wallet-value { font-size: 26px; font-weight: 800; color: var(--primary); }
.profile-value { font-size: 18px; font-weight: 700; color: var(--primary); }
.wallet-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile {
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tile h3 { font-size: 15px; margin: 0; }
.tile .tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--primary); }
.tile .desc { font-size: 13px; color: var(--muted); margin: 0; }
.tile .meta { font-size: 12px; color: var(--muted); }
.badge-flat {
  align-self: flex-start;
  background: #e7f5ec;
  color: var(--ok);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
}

.loading { color: var(--muted); font-size: 14px; padding: 8px 0; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; border: 1px dashed var(--border); border-radius: 10px; text-align: center; }

.foot { text-align: center; padding: 16px; font-size: 12px; }

@media (max-width: 480px) {
  .content { padding: 12px 10px 30px; }
  .topbar { padding: 10px 12px; }
  .wallet-value { font-size: 22px; }
  .register-card form { grid-template-columns: 1fr; }
  .register-card { padding: 24px 18px; }
}

/* ---- RTL forms (owner login / MFA) ---- */
[dir="rtl"] { text-align: right; }
[dir="rtl"] form label { text-align: right; }
.muted-link { color: var(--muted); text-decoration: none; }
.muted-link:hover { color: var(--primary); }

/* ---- administrator shell ---- */
.admin-view { background: var(--bg); }
.admin-layout { min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.admin-body { display: flex; flex: 1; min-height: 0; }
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: none;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: right;
}
.admin-nav-item:hover { background: #eef2f8; }
.admin-nav-item.active { background: #e7effe; color: var(--primary-2); }
.soon-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #eef2f8;
  border-radius: 999px;
  padding: 2px 8px;
}
.admin-content { flex: 1; padding: 18px 20px 40px; max-width: 1040px; margin: 0 auto; width: 100%; }
.admin-soon-grid .tile { position: relative; }
.admin-soon-grid .tile .soon-badge { align-self: flex-start; }

@media (max-width: 720px) {
  .admin-body { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }
  .admin-nav-item { white-space: nowrap; }
}

/* ---- admin data panels ---- */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-top: 10px; }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.stat-tile .st-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-tile .stat-value { display: block; font-size: 26px; font-weight: 800; color: var(--primary); margin-top: 4px; }
.stat-tile .st-sub { color: var(--muted); font-size: 12px; }
.status-select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  background: #fbfcfe;
}
.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.admin-table th { color: var(--muted); font-weight: 700; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-row-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfe;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.admin-row-card > div:first-child { flex: 1 1 220px; }
.row-actions { display: flex; gap: 8px; }
.btn.small { padding: 6px 12px; font-size: 13px; width: auto; margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 16px;
}
.form-grid label { display: block; margin: 14px 0 4px; font-size: 13px; font-weight: 600; }
.form-grid input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fbfcfe;
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ---- capture agent: merchant service entry ---- */
.service-row { padding: 4px; }
.service-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  text-align: right;
  font: inherit;
  border-radius: 12px;
}
.service-entry:hover { background: #f0f3f8; }
.service-icon { font-size: 26px; line-height: 1; }
.service-entry-main { display: flex; flex-direction: column; align-items: flex-start; flex: 1; gap: 2px; }
.service-title { font-size: 16px; font-weight: 700; }
.service-sub { font-size: 12px; }
.chevron { font-size: 22px; color: var(--muted); }
