/* =====================================================================
   ASSISTANCE GHANA HUB — Design system
   Brand: Blue #165F96 · Navy #0F3D5F · Gold #F3B94E
   ===================================================================== */

:root {
  --blue: #165F96;
  --navy: #0F3D5F;
  --navy-panel: #123A5C;
  --gold: #F3B94E;
  --gold-dark: #D89B2E;
  --light-blue-bg: #EAF2F8;
  --bg: #F4F7FA;
  --card: #FFFFFF;
  --text: #1B2733;
  --text-muted: #5A6B75;
  --border: #E1E8ED;
  --green: #2E9E6B;
  --red: #D9534F;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 61, 95, 0.06), 0 1px 1px rgba(15, 61, 95, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 61, 95, 0.12);
  --shadow-lg: 0 20px 48px rgba(15, 61, 95, 0.18);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; transition: color .15s var(--ease); }
a:hover { text-decoration: underline; color: var(--navy); }
h1, h2, h3, h4 { margin: 0 0 8px; color: var(--navy); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
::selection { background: rgba(22,95,150,0.18); }

/* ---------------------------------------------------------------------
   App shell: sidebar + main
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--blue) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar::before {
  content: ""; position: absolute; top: -90px; left: -70px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(243,185,78,0.20) 0%, transparent 72%);
  pointer-events: none; z-index: 0;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  position: relative; z-index: 1;
}
.sidebar-brand-row { display: flex; align-items: center; gap: 10px; }
.sidebar-close-btn {
  margin-left: auto; background: none; border: none; color: #DCE9F4; cursor: pointer;
  width: 30px; height: 30px; border-radius: 6px; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background-color .12s var(--ease);
}
.sidebar-close-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-close-btn svg { width: 18px; height: 18px; }
.sidebar-mark {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.28), 0 0 0 1px rgba(255,255,255,0.14);
}
.sidebar-brand-text { min-width: 0; }
.sidebar-brand .name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.25;
  white-space: nowrap;
}
.sidebar-brand .sub {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1px;
  white-space: nowrap;
}
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; position: relative; z-index: 1; }
.sidebar-nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: rgba(255,255,255,.45); padding: 14px 12px 6px;
}
.sidebar-nav-label:first-child { padding-top: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #DCE9F4;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 2px;
  text-decoration: none;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sidebar-nav a:hover .icon { opacity: 1; }
.sidebar-nav a.active { background: rgba(243,185,78,0.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar-nav a.active .icon { color: var(--gold); opacity: 1; }
.sidebar-nav .icon {
  width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .15s var(--ease), color .15s var(--ease);
}
.sidebar-nav .icon svg { width: 18px; height: 18px; display: block; }
.sidebar-footer {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.15);
  font-size: 12.5px;
  position: relative; z-index: 1;
}
.sidebar-footer .who { font-weight: 700; margin-bottom: 2px; }
.sidebar-footer .role { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-footer button {
  width: 100%;
}
.logout-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 2px;
  background: transparent; border-color: rgba(255,255,255,0.25); color: #DCE9F4;
}
.logout-btn svg { flex-shrink: 0; width: 15px; height: 15px; }
.logout-btn:hover {
  background: rgba(217,83,79,0.14); border-color: rgba(217,83,79,0.45); color: #fff; opacity: 1;
}
.sidebar-account {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px; margin-bottom: 10px;
  text-decoration: none; color: inherit;
  transition: background .15s var(--ease);
}
.sidebar-account:hover, .sidebar-account.active { background: rgba(255,255,255,0.1); text-decoration: none; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(243,185,78,0.55);
}
.sidebar-avatar-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--gold); color: var(--navy); font-weight: 800; font-size: 15px;
}

/* Mobile navigation: sidebar becomes an off-canvas drawer under 880px */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 60;
  width: 38px; height: 38px; border-radius: 8px;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-md);
  align-items: center; justify-content: center; cursor: pointer; color: var(--navy);
  padding: 0;
}
.mobile-menu-btn svg { width: 19px; height: 19px; }
.sidebar-backdrop { display: none; }
.sidebar-close-btn { display: none; }

/* My Account page */
.account-photo-preview {
  width: 84px; height: 84px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: var(--light-blue-bg); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 30px; overflow: hidden;
}
.account-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.account-readonly {
  margin: 0; padding: 9px 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; font-size: 13.5px; color: var(--text-muted);
}

.main { flex: 1; min-width: 0; }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(15,61,95,0.035);
}
.topbar h1 { margin: 0; }
.topbar .crumb { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }

/* Dashboard Today/Month toggle — a chunky pill so it reads as a real
   switch, not another small button, without competing with the title. */
.period-toggle {
  display: inline-flex; background: var(--light-blue-bg); border-radius: 999px;
  padding: 4px; gap: 2px; flex-shrink: 0;
}
.period-toggle button {
  border: none; background: none; padding: 10px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--text-muted); cursor: pointer;
  font-family: inherit; transition: background-color .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.period-toggle button:hover:not(.active) { color: var(--navy); }
.period-toggle button.active { background: var(--card); color: var(--blue); box-shadow: var(--shadow); }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 55%);
  opacity: 0.55; pointer-events: none;
}
.content { padding: 26px 28px 60px; max-width: 1280px; }

/* ---------------------------------------------------------------------
   Cards, grids, KPIs
   --------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  transition: box-shadow .18s var(--ease);
}
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 16px; }
.grid > .card + .card,
.kpi-grid > .card + .card,
.kpi-featured-grid > .card + .card { margin-top: 0; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) {
  .grid-4, .grid-3, .grid-2, .grid-5 { grid-template-columns: 1fr 1fr; }
}

/* Adaptive KPI grid — always fills the row evenly regardless of how many
   cards are shown (permissions can hide some), avoiding uneven/dead space. */
.kpi-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Featured KPI row — always exactly 2 equal cards (Total Clients /
   Active Dossiers), styled larger and in gold to stand out from the
   rest of the (mostly blue) dashboard. */
.kpi-featured-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 640px) {
  .kpi-featured-grid { grid-template-columns: 1fr; }
}
.kpi-lg {
  padding: 26px 24px;
  background: linear-gradient(135deg, #FFFBF3 0%, #FDF1DC 100%);
  border-color: #F3DFAE;
}
.kpi-lg::before { opacity: 1; }
.kpi-lg .label { color: var(--gold-dark); font-size: 12px; }
.kpi-lg .value { font-size: 38px; color: var(--gold-dark); }

.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  opacity: 0; transition: opacity .18s var(--ease);
}
.kpi:hover::before { opacity: 1; }
.kpi .label { color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin-bottom: 8px; }
.kpi .value { font-size: 27px; font-weight: 800; color: var(--navy); line-height: 1.15; }
.kpi .value.gold { color: var(--gold-dark); }
.kpi .delta { font-size: 12px; color: var(--green); margin-top: 4px; }
.kpi .delta.warn { color: var(--red); }
.kpi-clickable { cursor: pointer; transition: box-shadow .15s var(--ease), transform .15s var(--ease); }
.kpi-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-clickable .hint-icon { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity .15s var(--ease), transform .12s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
.btn:hover { opacity: 0.92; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; box-shadow: 0 1px 2px rgba(22,95,150,0.25); }
.btn-primary:hover { box-shadow: 0 4px 10px rgba(22,95,150,0.28); }
.btn-gold { background: var(--gold); color: var(--navy); box-shadow: 0 1px 2px rgba(217,155,46,0.3); }
.btn-gold:hover { box-shadow: 0 4px 10px rgba(217,155,46,0.32); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--navy); }
.btn-outline:hover { border-color: var(--blue); background: var(--light-blue-bg); opacity: 1; }
.btn-danger { background: #fdecec; color: var(--red); border-color: #f6cbc9; }
.btn-danger:hover { background: #fbdcdb; opacity: 1; }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------------
   Kebab menu ("...") — compact action menu, e.g. category edit/delete
   --------------------------------------------------------------------- */
.kebab-menu { position: relative; }
.kebab-menu-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--navy); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; line-height: 1; letter-spacing: 1px; padding: 0 0 8px;
}
.kebab-menu-btn:hover { border-color: var(--blue); background: var(--light-blue-bg); }
.kebab-menu-list {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  min-width: 150px; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 6px; flex-direction: column; gap: 2px;
}
.kebab-menu.open .kebab-menu-list { display: flex; }
.kebab-menu-list button {
  all: unset; box-sizing: border-box; width: 100%; padding: 8px 10px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--navy); cursor: pointer;
}
.kebab-menu-list button:hover { background: var(--light-blue-bg); }
.kebab-menu-list button.danger { color: var(--red); }
.kebab-menu-list button.danger:hover { background: #fdecec; }

/* ---------------------------------------------------------------------
   Invoice dossier picker (client profile — new invoice modal)
   --------------------------------------------------------------------- */
.invoice-picker-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}
.invoice-picker-row label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; font-weight: 500; color: var(--text); cursor: pointer; }
.invoice-picker-row input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; }
.invoice-picker-price { font-size: 12.5px; font-weight: 700; color: var(--navy); white-space: nowrap; text-align: right; }

/* ---------------------------------------------------------------------
   Payment amount rows (client profile — record payment modal)
   One editable "remaining balance" row per component owed, across
   every checked dossier.
   --------------------------------------------------------------------- */
.payment-amount-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px;
}
.payment-amount-row-paid { background: #F7FBF9; }
.payment-amount-row input.p-component-amount { width: 120px; margin: 0; text-align: right; }

/* ---------------------------------------------------------------------
   Invoice document — shared between the standalone print page
   (invoice-print.html) and the in-modal preview on the client profile
   --------------------------------------------------------------------- */
.invoice-print-body { background: #eef1f3; }
.invoice-toolbar { max-width: 780px; margin: 0 auto; padding: 16px 16px 8px; display: flex; justify-content: flex-end; gap: 10px; }
.invoice-page { max-width: 780px; margin: 0 auto 32px; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); padding: 48px; }
.invoice-preview-wrap { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 32px; background: #fff; }
.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; gap: 20px; }
.invoice-brand { font-size: 20px; font-weight: 800; color: var(--navy); letter-spacing: 0.02em; }
.invoice-brand span { display: block; font-size: 11px; font-weight: 600; color: var(--gold-dark); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.invoice-brand-contact { margin-top: 10px; font-size: 11px; font-weight: 400; color: var(--text-muted); line-height: 1.7; }
.invoice-meta { text-align: right; flex-shrink: 0; }
.invoice-meta h1 { margin: 0 0 6px; font-size: 22px; color: var(--navy); letter-spacing: 0.04em; }
.invoice-meta div { font-size: 13px; color: var(--text-muted); }
.invoice-meta strong { color: var(--text); }
.invoice-billto { margin-bottom: 28px; }
.invoice-billto h3 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.invoice-billto div { font-size: 14px; color: var(--text); line-height: 1.5; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.invoice-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 2px solid var(--border); padding: 10px 6px; }
.invoice-table td { padding: 12px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }
.invoice-table td:last-child, .invoice-table th:last-child { text-align: right; }
.invoice-totals { display: flex; justify-content: flex-end; margin-top: 12px; }
.invoice-totals table { border-collapse: collapse; }
.invoice-totals td { padding: 4px 0 4px 24px; font-size: 14px; }
.invoice-totals td:first-child { color: var(--text-muted); }
.invoice-totals td:last-child { text-align: right; font-weight: 700; color: var(--navy); }
.invoice-notes { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.invoice-footer { margin-top: 36px; text-align: center; font-size: 12.5px; color: var(--text-muted); }
@media print {
  body.invoice-print-body { background: #fff; }
  .invoice-toolbar { display: none; }
  .invoice-page { box-shadow: none; margin: 0; padding: 0; max-width: none; }
}

/* Invoices and receipts are opened by clients from their phone (an
   email link) as often as by an admin at a desk — the 48px desktop
   padding and side-by-side header leave almost no room for the
   3-column table on a narrow screen, wrapping "Assistance Ghana" and
   every service name onto several lines. */
@media (max-width: 600px) {
  .invoice-page, .invoice-preview-wrap { padding: 24px 16px; }
  .invoice-header { flex-direction: column; gap: 14px; }
  .invoice-meta { text-align: left; }
  .invoice-brand { font-size: 17px; }
  .invoice-table th, .invoice-table td { padding: 9px 4px; font-size: 12.5px; }
  .invoice-totals { justify-content: flex-start; }
}

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--navy); margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input-invalid { border-color: var(--red) !important; }
textarea { resize: vertical; min-height: 70px; }
input:hover, select:hover, textarea:hover { border-color: #c7d3db; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(22,95,150,0.12);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
/* Price + currency pairs: currency only needs room for "GHS"/"USD"/"XOF", so
   it shouldn't take up half the row like a normal two-field row. */
.price-field-row { grid-template-columns: 1fr 92px; }
.hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ---------------------------------------------------------------------
   Tables
   --------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  padding: 11px 12px;
  white-space: nowrap;
  background: #fbfcfd;
}
tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background-color .12s var(--ease); }
tbody tr:hover { background: var(--light-blue-bg); }
tbody tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.row-click { cursor: pointer; }

/* ---------------------------------------------------------------------
   Badges / status pills
   --------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-blue { background: var(--light-blue-bg); color: var(--blue); }
.badge-gold { background: #FDF1DC; color: var(--gold-dark); }
.badge-green { background: #E4F5EC; color: var(--green); }
.badge-red { background: #FBEAEA; color: var(--red); }
.badge-grey { background: #EEF1F3; color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,61,95,0.5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
  animation: backdrop-in .15s var(--ease);
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: modal-in .18s var(--ease);
}
.modal.modal-lg { max-width: 780px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98);} to { opacity:1; transform:translateY(0) scale(1);} }
.modal-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); border-radius: 6px; width: 30px; height: 30px; transition: background-color .12s var(--ease); }
.modal-close:hover { background: var(--light-blue-bg); color: var(--navy); }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(243,185,78,0.10) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(243,185,78,0.08) 0%, transparent 40%),
    linear-gradient(160deg, var(--navy) 0%, var(--blue) 60%, var(--blue) 100%);
  padding: 20px;
}
.login-wrap::before, .login-wrap::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none;
}
.login-wrap::before { width: 440px; height: 440px; background: rgba(243,185,78,0.20); top: -160px; left: -160px; }
.login-wrap::after { width: 380px; height: 380px; background: rgba(255,255,255,0.09); bottom: -170px; right: -130px; }
.login-decor-dots {
  position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(circle at 50% 42%, black, transparent 72%);
  mask-image: radial-gradient(circle at 50% 42%, black, transparent 72%);
}
.login-card {
  background: #fff; border-radius: 16px; width: 100%; max-width: 400px;
  padding: 36px 34px; position: relative; z-index: 1;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28), 0 0 0 1px rgba(243,185,78,0.16);
  border-top: 3px solid var(--gold);
  animation: login-card-in .55s var(--ease) both;
}
@keyframes login-card-in { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.login-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.login-logo { display: block; height: 22px; width: auto; }
.login-brand { text-align: center; margin-bottom: 4px; }
.login-brand .sub { color: var(--text-muted); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 600; }
.login-title { text-align: center; margin-bottom: 22px; margin-top: 6px; color: var(--navy); font-size: 18px; font-weight: 800; }
.login-error {
  background: #FBEAEA; color: var(--red); border: 1px solid #f6cbc9;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; display: none;
}
.login-success {
  background: #E4F5EC; color: var(--green); border: 1px solid #cdebd9;
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; display: none;
}
.input-icon-wrap { position: relative; }
.input-icon-wrap input { padding-left: 36px; }
.input-icon-wrap .input-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; display: flex;
}
.login-invite-hint { display: flex; align-items: center; justify-content: center; gap: 6px; }
.login-invite-hint svg { flex-shrink: 0; color: var(--gold-dark); }

/* ---------------------------------------------------------------------
   Misc
   --------------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; }
.mt-0 { margin-top: 0; } .mt-10 { margin-top: 10px; } .mt-18 { margin-top: 18px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title-left { display: flex; align-items: center; gap: 10px; }
.section-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.section-icon svg { width: 16px; height: 16px; }
.section-icon.icon-blue { background: var(--light-blue-bg); color: var(--blue); }
.section-icon.icon-gold { background: #FDF1DC; color: var(--gold-dark); }
.section-icon.icon-red { background: #FBEAEA; color: var(--red); }
.section-icon.icon-green { background: #E4F5EC; color: var(--green); }

/* Compact two-column list rows (dashboard alerts, mini-lists) */
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 8px; margin: 0 -8px; border-bottom: 1px solid var(--border);
  border-radius: 6px; transition: background-color .12s var(--ease);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--light-blue-bg); }
.list-row-primary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-secondary { flex-shrink: 0; white-space: nowrap; font-size: 13px; }

/* Icon inside "+ X" buttons */
.btn svg { flex-shrink: 0; }
.actions-equal .btn { min-width: 96px; justify-content: center; }

/* ---------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------- */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding-top: 18px; margin-top: 4px; border-top: 1px solid var(--border);
}
.pagination-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.pagination-input {
  width: 52px; text-align: center; padding: 6px 4px; -moz-appearance: textfield;
}
.pagination-input::-webkit-outer-spin-button, .pagination-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.empty-state {
  text-align: center; padding: 50px 20px; color: var(--text-muted);
}
.empty-state .icon {
  width: 56px; height: 56px; line-height: 56px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--light-blue-bg); font-size: 26px;
}
.spinner {
  width: 18px; height: 18px; border: 2.5px solid rgba(22,95,150,0.2);
  border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: #fff;
  padding: 13px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 200; max-width: 340px;
  animation: toast-in .2s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.tag-input-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.access-denied { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.permission-grid { display: grid; grid-template-columns: 1fr repeat(3, 80px); gap: 8px; align-items: center; }
.permission-grid .head { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; text-align: center; }

/* ---------------------------------------------------------------------
   Searchable dropdown (nationality, phone country code)
   --------------------------------------------------------------------- */
.searchable-wrap { position: relative; }
.searchable-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 50;
}
.searchable-panel.open { display: block; }
.searchable-option { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.searchable-option:hover { background: var(--light-blue-bg); }

/* Phone field: country-code combobox + national number, side by side */
.phone-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; }

/* Form sections (Services & Pricing modal, and reusable elsewhere) */
.form-section {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px;
}
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
  margin: 0 0 12px; font-size: 12px; font-weight: 700; color: var(--navy);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-section .field-row:last-child,
.form-section label:last-child { margin-bottom: 0; }
.toggle-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; cursor: pointer; user-select: none; }
.toggle-row input { width: auto; margin: 0; flex-shrink: 0; }
.toggle-row span { font-size: 13px; color: var(--text); font-weight: 500; }

/* Inline notice inside a form section (e.g. "these fields aren't used") */
.notice-inline {
  background: #FDF1DC; color: var(--gold-dark); border: 1px solid #F3DFAE;
  border-radius: 8px; padding: 8px 12px; font-size: 12px; font-weight: 600;
  margin: 0 0 14px;
}
/* Fields a notice-inline is explaining are de-emphasised, not hidden — the
   admin can still see/edit them, just clearly not the active price. */
.form-section-inactive #svc-base-fields-wrap { opacity: 0.5; }

/* Price option rows (Services & Pricing) */
.price-option-row {
  border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  margin-bottom: 10px; background: var(--card);
}
.price-option-row-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.price-option-row-top input { flex: 1; }
.price-option-index {
  width: 22px; height: 22px; border-radius: 50%; background: var(--light-blue-bg); color: var(--blue);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.price-option-row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.price-option-field-group { display: grid; grid-template-columns: 1fr 74px; gap: 6px; }
.price-option-field-group label { margin: 0 0 3px; font-size: 11px; }
.price-option-remove { background: none; border: none; color: var(--red); font-size: 18px; cursor: pointer; font-weight: 700; padding: 0 4px; flex-shrink: 0; }
.price-option-profit { font-size: 12px; color: var(--green); font-weight: 600; margin-top: 8px; margin-bottom: 0; }

/* ---------------------------------------------------------------------
   Language switcher (sidebar)
   --------------------------------------------------------------------- */
.lang-switch { display: flex; gap: 6px; margin-bottom: 12px; }
.lang-switch button {
  flex: 1; padding: 6px 0; border-radius: 6px; border: 1px solid rgba(255,255,255,0.25);
  background: transparent; color: #DCE9F4; font-size: 11.5px; font-weight: 700; cursor: pointer;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.lang-switch button:hover { border-color: rgba(255,255,255,0.5); color: #fff; }
.lang-switch button.active { background: rgba(243,185,78,0.22); border-color: var(--gold); color: #fff; }

/* ---------------------------------------------------------------------
   Toggle switch (Automations on/off)
   --------------------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background-color: #ccd3d8; transition: background-color .18s var(--ease);
}
.switch .slider::before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform .18s var(--ease);
}
.switch input:checked + .slider { background-color: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:disabled + .slider { opacity: 0.45; cursor: not-allowed; }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(22,95,150,0.25); }

/* ---------------------------------------------------------------------
   Automations list (Marketing / CRM > Automations tab)
   --------------------------------------------------------------------- */
.automation-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 18px 0; border-bottom: 1px solid var(--border);
}
.automation-row:last-child { border-bottom: none; }
.automation-row-main { flex: 1; min-width: 0; }
.automation-warning {
  background: #FDF1DC; border: 1px solid #F3DFAE; color: #8A6116;
  border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.automation-howitworks {
  display: flex; gap: 18px; flex-wrap: wrap;
  background: var(--light-blue-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-bottom: 16px;
}
.automation-howitworks .step { display: flex; gap: 10px; flex: 1; min-width: 200px; }
.automation-howitworks .step-num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.automation-howitworks strong { display: block; font-size: 13px; color: var(--navy); margin-bottom: 2px; }
.automation-howitworks p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.automation-activity-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.automation-activity-row:last-child { border-bottom: none; }
.danger-warning {
  background: #FBEAEA; border: 1px solid #F3C6C4; color: #97302C;
  border-radius: 8px; padding: 12px 14px; font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px;
}
.delete-target-list { margin: 8px 0 0; padding-left: 20px; font-size: 13px; max-height: 200px; overflow-y: auto; }
.delete-target-list li { margin-bottom: 4px; }

/* =======================================================================
   Responsive — tablet & mobile
   ======================================================================= */
@media (max-width: 880px) {
  .mobile-menu-btn { display: flex; }
  .sidebar-close-btn { display: flex; }
  .topbar { padding-left: 62px; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
    z-index: 200;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 190;
    background: rgba(15,61,95,0.45); animation: backdrop-in .15s var(--ease);
  }
  body.sidebar-open { overflow: hidden; }
}

@media (max-width: 680px) {
  .topbar {
    flex-wrap: wrap; align-items: flex-start; row-gap: 12px;
    padding: 16px 16px 16px 62px;
  }
  .topbar > *:last-child:not(:only-child) { width: 100%; flex-wrap: wrap; }
  .period-toggle button { flex: 1; text-align: center; }
  .content { padding: 18px 16px 40px; }
  h1 { font-size: 20px; }
  .card { padding: 16px; }
  .modal-body { padding: 18px; }
  .modal-header, .modal-footer { padding: 14px 18px; }
  .section-title { flex-wrap: wrap; row-gap: 10px; }
  .section-title > *:last-child:not(:only-child) { width: 100%; }
  .section-title > *:last-child:not(:only-child).flex { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2, .grid-5, .kpi-featured-grid { grid-template-columns: 1fr !important; }
  .field-row, .price-option-row-fields { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr repeat(3, 56px); font-size: 12.5px; }
  .phone-row { grid-template-columns: 100px 1fr; }
  /* Full width, but sized to content (not forced to fill the whole
     screen height) — a 3-line confirmation dialog shouldn't stretch
     into a mostly-empty full-screen sheet just because a long form
     modal also uses this same class. */
  .modal-backdrop { padding: 16px; align-items: flex-start; }
  .modal { max-width: 100%; border-radius: 12px; }
  .modal.modal-lg { max-width: 100%; }
}

/* ---------------------------------------------------------------------
   Documentation page — searchable topic list + accordion panel
   --------------------------------------------------------------------- */
.docs-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.docs-nav {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; position: sticky; top: 26px;
  max-height: calc(100vh - 52px); overflow-y: auto;
}
.docs-search {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; margin-bottom: 12px;
}
.docs-category { margin-bottom: 14px; }
.docs-category:last-child { margin-bottom: 0; }
.docs-category-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 0 8px 6px;
}
.docs-topic-link {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; border-radius: 8px; padding: 9px 8px; margin-bottom: 2px;
  cursor: pointer; font-family: inherit; transition: background-color .12s var(--ease);
}
.docs-topic-link:hover { background: var(--light-blue-bg); }
.docs-topic-link.active { background: var(--light-blue-bg); }
.docs-topic-link.active .docs-topic-title { color: var(--blue); }
.docs-topic-icon { font-size: 16px; line-height: 1.3; flex-shrink: 0; }
.docs-topic-text { flex: 1; min-width: 0; }
.docs-topic-title { display: block; font-size: 13px; font-weight: 700; color: var(--navy); }
.docs-topic-summary {
  display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.docs-read-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; margin-top: 5px; }

.docs-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; min-height: 300px;
}
.docs-panel-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.docs-panel-icon {
  font-size: 26px; width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px;
  background: var(--light-blue-bg); display: flex; align-items: center; justify-content: center;
}
.docs-panel-category { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.docs-panel-header h2 { margin: 2px 0 0; }
.docs-empty-state { padding: 60px 20px; text-align: center; }

.docs-section {
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; overflow: hidden;
}
.docs-section:last-child { margin-bottom: 0; }
.docs-section summary {
  cursor: pointer; list-style: none; padding: 13px 16px; font-weight: 700; color: var(--navy);
  font-size: 14px; background: #FAFCFD; display: flex; align-items: center; justify-content: space-between;
  transition: background-color .12s var(--ease);
}
.docs-section summary:hover { background: var(--light-blue-bg); }
.docs-section summary::-webkit-details-marker { display: none; }
.docs-section summary::after {
  content: "+"; font-size: 18px; font-weight: 400; color: var(--text-muted); flex-shrink: 0; margin-left: 10px;
  transition: transform .15s var(--ease);
}
.docs-section[open] summary::after { content: "–"; }
.docs-section-body { padding: 14px 16px 16px; font-size: 13.5px; color: var(--text); line-height: 1.6; }
.docs-section-body p:last-child { margin-bottom: 0; }
.docs-steps, .docs-list { margin: 0; padding-left: 20px; }
.docs-steps li, .docs-list li { margin-bottom: 8px; }
.docs-steps li:last-child, .docs-list li:last-child { margin-bottom: 0; }
.docs-callout {
  border-radius: 8px; padding: 10px 14px; font-size: 13px; font-weight: 500; line-height: 1.5;
}
.docs-callout-tip { background: var(--light-blue-bg); color: var(--blue); }
.docs-callout-warning { background: #FDF1DC; color: var(--gold-dark); }

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; max-height: none; }
}

