/* ═══════════════════════════════════════════════════════════════════
   ISTRAHA EXPENSES — Main Stylesheet
   RTL Arabic Design
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────────────── */
:root {
  --header-bg:    #1a1a2e;
  --header-text:  #ffffff;
  --accent:       #0f3460;
  --accent-light: #1e4976;
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-right:   env(safe-area-inset-right, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-left:    env(safe-area-inset-left, 0px);

  --hosam-bg:     #e8f5e9;
  --hosam-header: #2e7d32;
  --hosam-text:   #1b5e20;

  --khaled-bg:    #e3f2fd;
  --khaled-header:#1565c0;
  --khaled-text:  #0d47a1;

  --fund-bg:      #fff8e1;
  --fund-header:  #e65100;
  --fund-accent:  #FF9800;

  --paid-bg:      #e8f5e9;
  --remaining-bg: #ffebee;
  --remaining-text:#c62828;

  --text:         #212121;
  --text-muted:   #757575;
  --border:       #e0e0e0;
  --bg:           #f5f6fa;
  --surface:      #ffffff;
  --shadow:       0 2px 8px rgba(0,0,0,0.10);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.14);
  --radius:       10px;
  --radius-sm:    6px;

  --success:      #2e7d32;
  --warning:      #e65100;
  --danger:       #c62828;
  --info:         #1565c0;
}

/* ─── Reset & base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.istraha-app {
  font-family: 'Tajawal', Tahoma, Arial, sans-serif;
  direction: rtl;
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 152, 0, 0.13), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(15, 52, 96, 0.12), transparent 30%),
    linear-gradient(180deg, #f7f9fd 0%, #eef3f8 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: var(--safe-bottom);
}

body.istraha-login {
  direction: rtl;
  margin: 0;
}

/* ─── Header ─────────────────────────────────────────────────────────── */
.app-header {
  background: rgba(26, 26, 46, 0.94);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 10px 34px rgba(8,18,34,0.18);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(18px);
  padding-top: var(--safe-top);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left));
  height: 62px;
  max-width: 1400px;
  margin: 0 auto;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-weight: 900;
  font-size: 1.16rem;
  white-space: nowrap;
  cursor: pointer;
  min-width: 0;
  padding: 8px 16px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.header-icon { font-size: 1.4rem; }

.nav-tabs {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 4px;
  overflow-x: auto;
}
.nav-btn {
  background: transparent;
  color: rgba(255,255,255,0.75);
  border: none;
  padding: 10px 16px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn.active {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-weight: 700;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  min-width: 130px;
  justify-content: flex-end;
}
.btn-logout {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.menu-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; }

/* ─── Main ───────────────────────────────────────────────────────────── */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding:
    24px calc(20px + var(--safe-right))
    calc(112px + var(--safe-bottom))
    calc(20px + var(--safe-left));
  position: relative;
  min-height: calc(100dvh - 56px - var(--safe-top));
}

.page { display: block; }
.page.hidden { display: none; }

/* ─── Page header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--header-bg);
}
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-light); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.88; }
.btn-warning   { background: var(--fund-header); color: #fff; }
.btn-warning:hover { opacity: 0.88; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.88; }
.btn-outline   { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.btn-outline:hover { background: var(--accent); color: #fff; }
.btn-sm        { padding: 5px 12px; font-size: 0.8rem; }
.btn-icon      { padding: 6px 10px; font-size: 0.9rem; }

/* ─── Cards ──────────────────────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.cards-grid-3 { grid-template-columns: repeat(3, 1fr); }
.cards-grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--border);
}
.card-label { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 6px; }
.card-value { font-size: 1.5rem; font-weight: 900; color: var(--text); }
.card-sub   { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.card-fund     { border-top-color: var(--fund-accent); }
.card-hosam    { border-top-color: var(--hosam-header); background: var(--hosam-bg); }
.card-hosam .card-value { color: var(--hosam-text); }
.card-khaled   { border-top-color: var(--khaled-header); background: var(--khaled-bg); }
.card-khaled .card-value { color: var(--khaled-text); }
.card-total    { border-top-color: var(--accent); }
.card-paid     { border-top-color: var(--success); background: var(--paid-bg); }
.card-remaining{ border-top-color: var(--danger); background: var(--remaining-bg); }
.card-remaining .card-value { color: var(--remaining-text); }

/* ─── Settlement banner ──────────────────────────────────────────────── */
.settlement-banner {
  background: linear-gradient(135deg, #1a1a2e, #0f3460);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 24px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.settlement-banner.equal  { background: linear-gradient(135deg, #1b5e20, #2e7d32); }
.settlement-banner.hosam-owes { background: linear-gradient(135deg, #0d47a1, #1565c0); }
.settlement-banner.khaled-owes{ background: linear-gradient(135deg, #b71c1c, #c62828); }

/* ─── Dashboard two-column layout ───────────────────────────────────── */
.dash-pair-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
  direction: rtl;
}
.dash-side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dash-pair-row .dash-section,
.dash-side-stack .dash-section { margin-bottom: 0; }
.dash-lower-row { align-items: stretch; }
.dash-chart-area,
.dash-settle-area { min-width: 0; }
.dash-settlement-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.dash-settlement-card .settlement-banner {
  margin-bottom: 10px;
  box-shadow: none;
}
.dash-settlement-meta {
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.6;
}
.dash-inst-area .cards-grid-3 {
  gap: 10px;
  margin-bottom: 12px;
}
.dash-inst-area .card {
  padding: 14px 12px;
}
.chart-wrap-horizontal {
  min-height: 300px;
}

.dash-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--header-bg);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

/* ─── Trends list ───────────────────────────────────────────────────── */
.trends-list { margin-bottom: 16px; }
.trend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.trend-row:last-child { border-bottom: none; }
.trend-name { font-weight: 600; color: var(--text); }
.trend-values { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.trend-current { font-weight: 700; }
.trend-arrow { font-size: 0.9rem; }
.trend-up   { color: var(--danger); }
.trend-down { color: var(--success); }
.trend-same { color: var(--text-muted); }
.trend-pct  { font-size: 0.78rem; color: var(--text-muted); }

/* ─── Chart ─────────────────────────────────────────────────────────── */
.chart-wrap { margin-top: 16px; }

/* ─── Obligation cards (upcoming) ──────────────────────────────────── */
.obligation-cards { display: flex; flex-direction: column; gap: 8px; }
.obl-due-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff3e0;
  border: 1px solid #ffe0b2;
  border-right: 4px solid var(--fund-header);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.obl-due-name  { font-weight: 600; }
.obl-due-meta  { font-size: 0.78rem; color: var(--text-muted); }
.obl-due-amount{ font-weight: 900; font-size: 1rem; color: var(--fund-header); }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 24px;
}
.expense-main-desc { font-weight: 700; color: var(--text); }
.expense-meta {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 700px;
}
.data-table th {
  background: var(--header-bg);
  color: #fff;
  padding: 12px 10px;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f9f9f9; }
.data-table tfoot td {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 11px 10px;
}
.row-fund   { background: var(--fund-bg) !important; }
.row-hosam  { }
.row-khaled { background: var(--khaled-bg) !important; }
.row-inactive { opacity: 0.5; }

/* ─── Filter bar ─────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.search-input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  direction: rtl;
}
.search-input:focus { outline: none; border-color: var(--accent); }
#btnSortExpenses { white-space: nowrap; }
.form-select-sm {
  padding: 7px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.86rem;
  background: #fff;
  direction: rtl;
  cursor: pointer;
}
.form-select-sm:focus { outline: none; border-color: var(--accent); }

/* ─── Settlement section ─────────────────────────────────────────────── */
.settlement-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}
.settlement-section table { width: 100%; border-collapse: collapse; }
.settlement-section td,
.settlement-section th { padding: 8px 12px; border: 1px solid var(--border); }
.settlement-section th { background: #f5f5f5; font-weight: 700; }

/* ─── Fund balance card ──────────────────────────────────────────────── */
.fund-balance-card {
  background: linear-gradient(135deg, #e65100, #FF9800);
  color: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.fund-balance-label  { font-size: 0.9rem; opacity: 0.85; margin-bottom: 6px; }
.fund-balance-amount { font-size: 2.8rem; font-weight: 900; line-height: 1.1; }
.fund-balance-sub    { font-size: 0.85rem; opacity: 0.8; margin-top: 6px; }

/* ─── Installment cards ───────────────────────────────────────────────── */
.installment-cards { display: flex; flex-direction: column; gap: 16px; }
.inst-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  border-right: 5px solid var(--accent);
}
.inst-card.person-hosam  { border-right-color: var(--hosam-header); }
.inst-card.person-khaled { border-right-color: var(--khaled-header); }
.inst-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.inst-card-name  { font-size: 1rem; font-weight: 700; }
.inst-card-person{
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
}
.person-badge-hosam  { background: var(--hosam-bg); color: var(--hosam-text); }
.person-badge-khaled { background: var(--khaled-bg); color: var(--khaled-text); }

.inst-card-amounts {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 0.86rem;
}
.inst-amt-item { display: flex; flex-direction: column; }
.inst-amt-label { color: var(--text-muted); font-size: 0.76rem; }
.inst-amt-value { font-weight: 700; font-size: 0.95rem; }

/* Progress bar */
.progress-wrap { margin-bottom: 10px; }
.progress-bar-bg {
  background: #e0e0e0;
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #81c784);
  border-radius: 8px;
  transition: width 0.6s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.inst-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.inst-card-actions { display: flex; gap: 6px; }

/* ─── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1850;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-img { max-width: 90vw; background: transparent; }
.modal-img img { display: block; max-width: 100%; border-radius: var(--radius); }
.modal-header {
  background: var(--header-bg);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(255,255,255,0.3); }
.modal-body { padding: 20px; }

/* ─── Forms inside modal ─────────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 5px;
  color: #444;
}
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  direction: rtl;
  background: #fafafa;
  transition: border-color 0.2s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.form-row textarea { resize: vertical; min-height: 70px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.advanced-fields {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
}
.advanced-fields summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 700;
  list-style: none;
}
.advanced-fields summary::-webkit-details-marker { display: none; }
.advanced-fields summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  border-radius: 50%;
  background: #e8eef8;
}
.advanced-fields[open] summary { margin-bottom: 12px; }
.advanced-fields[open] summary::before { content: "-"; }
.quick-duration-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 12px;
}
.quick-duration-row button {
  border: 1px solid #d9e2ee;
  background: #fff;
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}
.quick-duration-row button:hover {
  background: #edf4ff;
}
.prepaid-renewal-preview {
  margin: -4px 0 12px;
  padding: 10px 12px;
  border: 1px solid #cfe8df;
  border-radius: var(--radius-sm);
  background: #eef8f4;
  color: #0f766e;
  font-size: 0.84rem;
  font-weight: 800;
}
.obligation-split-preview {
  margin: -2px 0 12px;
  padding: 10px 12px;
  border: 1px solid #dbe7f5;
  border-radius: var(--radius-sm);
  background: #f5f8fc;
  color: #1f3a5f;
  font-size: 0.84rem;
  font-weight: 800;
}
.trash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fbfcfe;
}
.trash-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.trash-item-main strong {
  color: var(--text);
}
.trash-item-main span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.expense-card-list {
  display: none;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.expense-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.expense-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.expense-card-head strong {
  display: block;
  color: var(--text);
  font-size: 0.96rem;
}
.expense-card-head span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.expense-card-amount {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 900;
  white-space: nowrap;
}
.expense-card-tags,
.expense-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.expense-card-split {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.expense-card-note {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.followup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.followup-row:last-child { border-bottom: none; }
.followup-row strong { display: block; }
.followup-row span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}
.followup-side {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.tracking-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.tracking-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 1px 5px rgba(0,0,0,0.06);
}
.tracking-chip strong {
  display: block;
  color: var(--header-bg);
  font-size: 0.92rem;
}
.tracking-chip span {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.tracking-chip.warning { border-right-color: var(--warning); background: #fffaf2; }
.tracking-chip.danger { border-right-color: var(--danger); background: #fff5f5; }
.tracking-chip.success { border-right-color: var(--success); background: #f5fff6; }

/* Receipt upload */
.receipt-upload { margin-top: 6px; }
.receipt-upload input[type="file"] { font-size: 0.82rem; }
.receipt-preview { margin-top: 8px; }
.receipt-preview img { max-height: 80px; border-radius: 4px; border: 1px solid var(--border); }
.receipt-thumb {
  display: inline-block;
  cursor: pointer;
  max-height: 36px;
  border-radius: 4px;
  border: 1px solid var(--border);
  vertical-align: middle;
}

/* ─── Loading overlay ─────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 2300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #212121;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 2000;
  box-shadow: var(--shadow-md);
  transition: opacity 0.3s;
}
.toast.hidden { display: none; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--fund-header); }

/* ─── PWA shell ─────────────────────────────────────────────────────── */
.pwa-install-banner {
  position: fixed;
  left: max(14px, calc(14px + var(--safe-left)));
  right: max(14px, calc(14px + var(--safe-right)));
  bottom: max(14px, calc(14px + var(--safe-bottom)));
  z-index: 2100;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(15,52,96,0.12);
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(13, 24, 45, 0.22);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  backdrop-filter: blur(14px);
}
.pwa-install-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pwa-install-copy strong {
  color: var(--header-bg);
  font-size: 0.96rem;
}
.pwa-install-copy span {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}
.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-status-banner {
  position: fixed;
  top: max(12px, calc(12px + var(--safe-top)));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2200;
  background: rgba(198, 40, 40, 0.96);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.2);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  width: min(92vw, 520px);
}

body.istraha-standalone .app-header {
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}

body.istraha-standalone .pwa-install-banner {
  display: none !important;
}

.quick-action-sheet { display: none; }

.bottom-app-nav {
  position: fixed;
  right: max(14px, calc(14px + var(--safe-right)));
  left: max(14px, calc(14px + var(--safe-left)));
  bottom: max(14px, calc(14px + var(--safe-bottom)));
  z-index: 1600;
  display: grid;
  grid-template-columns: 1fr 1fr 64px 1fr 1fr;
  align-items: center;
  gap: 8px;
  max-width: 620px;
  margin: 0 auto;
  padding: 9px 10px;
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(15,52,96,0.11);
  border-radius: 24px;
  box-shadow: 0 18px 46px rgba(8,18,34,0.18);
  backdrop-filter: blur(18px);
}
.bottom-app-nav .nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 7px 5px;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 900;
  line-height: 1.15;
}
.bottom-app-nav .nav-btn span {
  display: block;
  font-size: 1.12rem;
  line-height: 1;
}
.bottom-app-nav .nav-btn.active {
  background: #edf4ff;
  color: var(--accent);
}
.quick-add-fab {
  position: static;
  transform: none;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fund-header), #ff9800);
  color: #fff;
  box-shadow: 0 12px 28px rgba(230,81,0,0.34);
  font-family: inherit;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.quick-add-fab:active { transform: scale(0.96); }

.quick-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 2150;
  background: rgba(7, 15, 30, 0.34);
  align-items: flex-end;
  padding:
    18px calc(14px + var(--safe-right))
    calc(110px + var(--safe-bottom))
    calc(14px + var(--safe-left));
}
.quick-action-sheet:not(.hidden) { display: flex; }
.quick-action-panel {
  width: min(520px, 100%);
  margin: 0 auto;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(15,52,96,0.14);
  border-radius: 22px;
  box-shadow: 0 22px 60px rgba(8, 18, 34, 0.28);
  padding: 16px;
  backdrop-filter: blur(16px);
}
.quick-action-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.quick-action-head strong {
  display: block;
  color: var(--header-bg);
  font-size: 1rem;
}
.quick-action-head span {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.quick-action-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: #eef2f7;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
}
.quick-action-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.quick-action-grid button {
  border: 1px solid #d9e2ee;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f7faff);
  color: var(--header-bg);
  font-family: inherit;
  font-weight: 800;
  padding: 13px 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15,52,96,0.08);
}
.quick-action-grid button:active { transform: scale(0.98); }

/* ─── Skeleton loaders ──────────────────────────────────────────────── */
.skeleton-line {
  height: 36px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  margin-bottom: 10px;
}
@keyframes shimmer { to { background-position: -400% 0; } }

/* ─── Utility ────────────────────────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--fund-header); }
.fw-bold      { font-weight: 700; }
.hidden       { display: none !important; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge-active   { background: #e8f5e9; color: var(--success); }
.badge-inactive { background: #f5f5f5; color: #999; }
.badge-fund     { background: var(--fund-bg); color: var(--fund-header); }
.badge-hosam    { background: var(--hosam-bg); color: var(--hosam-text); }
.badge-khaled   { background: var(--khaled-bg); color: var(--khaled-text); }
.badge-shared   { background: #f3e5f5; color: #6a1b9a; }
.badge-kash     { background: #e8f5e9; color: #2e7d32; }
.badge-aqsat    { background: #fff3e0; color: var(--fund-header); }
.toggle-label   { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.86rem; }

/* ─── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-pair-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .app-main {
    padding:
      16px calc(12px + var(--safe-right))
      calc(110px + var(--safe-bottom))
      calc(12px + var(--safe-left));
  }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .cards-grid-3 { grid-template-columns: 1fr; }

  /* ── Mobile header: brand center, hamburger on side ── */
  .header-inner {
    justify-content: center;
    position: relative;
    padding: 0 calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left));
  }
  .header-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
  }
  .header-user { display: none; }
  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.12);
    margin-right: auto; /* RTL: pushes to right side */
    font-size: 1.2rem;
    transition: background 0.2s;
  }
  .menu-toggle:hover { background: rgba(255,255,255,0.22); }

  /* Nav hidden by default on mobile, shown as dropdown */
  .nav-tabs {
    display: none;
    position: absolute;
    top: 100%;
    right: 0; left: 0;
    background: linear-gradient(160deg, #1a1a2e 0%, #0f3460 100%);
    flex-direction: column;
    z-index: 200;
    padding: 8px 12px 12px;
    border-top: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    gap: 2px;
  }
  .nav-tabs.open { display: flex; }
  .nav-btn {
    padding: 12px 16px;
    font-size: 0.95rem;
    text-align: center;
    border-radius: var(--radius-sm);
  }

  .form-row-2 { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .fund-balance-amount { font-size: 2rem; }
  #expensesCards { display: flex; }
  #expensesTableWrap { display: none; }
  .expense-card-split { flex-direction: column; }
  .tracking-summary { grid-template-columns: 1fr; }

  .bottom-app-nav {
    right: 8px;
    left: 8px;
    bottom: calc(8px + var(--safe-bottom));
    grid-template-columns: 1fr 1fr 58px 1fr 1fr;
    gap: 5px;
    max-width: none;
    padding:
      8px calc(8px + var(--safe-right))
      calc(8px + var(--safe-bottom))
      calc(8px + var(--safe-left));
  }
  .bottom-app-nav .nav-btn {
    min-height: 48px;
    padding: 6px 3px;
    font-size: 0.68rem;
  }
  .bottom-app-nav .nav-btn span {
    font-size: 1.05rem;
  }

  .quick-add-fab {
    width: 54px;
    height: 54px;
    font-size: 2rem;
  }
  .quick-add-fab:active {
    transform: scale(0.96);
  }
  .quick-action-sheet {
    padding-bottom: calc(112px + var(--safe-bottom));
  }
  .toast {
    right: calc(12px + var(--safe-right));
    left: calc(12px + var(--safe-left));
    bottom: calc(96px + var(--safe-bottom));
    text-align: center;
  }

  .pwa-install-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    bottom: calc(92px + var(--safe-bottom));
  }
  .pwa-install-actions {
    width: 100%;
    justify-content: stretch;
  }
  .pwa-install-actions .btn {
    flex: 1;
    justify-content: center;
  }
}
@media (max-width: 400px) {
  .cards-grid { grid-template-columns: 1fr; }
}

@media (display-mode: standalone) {
  body.istraha-app,
  body.istraha-login {
    min-height: 100dvh;
  }
}

/* ── Obligation countdown cards ── */
.oblig-countdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.oblig-countdown-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-right: 4px solid var(--accent);
}
.oblig-cc-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.oblig-cc-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1.2; }
.oblig-cc-info { flex: 1; }
.oblig-cc-name { font-weight: 700; font-size: 0.95rem; line-height: 1.3; }
.oblig-cc-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.oblig-cc-amount { font-size: 1.1rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
.oblig-progress-wrap { margin-top: 10px; }

.badge-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 20px; padding: 2px 8px; font-size: 0.78rem;
  font-weight: 700; min-width: 24px;
}
.badge-urgent {
  display: inline-block; background: #ffebee; color: #c62828;
  border: 1px solid #ffcdd2; border-radius: 20px;
  padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}
.badge-soon {
  display: inline-block; background: #fff3e0; color: #e65100;
  border: 1px solid #ffe0b2; border-radius: 20px;
  padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}
.badge-ok {
  display: inline-block; background: #e8f5e9; color: #2e7d32;
  border: 1px solid #c8e6c9; border-radius: 20px;
  padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}

/* ── Provider badge (Tabby / Tamara) ── */
.provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.provider-tabby   { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.provider-tamara  { background: #e8d5f5; color: #5a1a8a; border: 1px solid #d6b8ee; }
.provider-other   { background: #e9ecef; color: #495057; border: 1px solid #dee2e6; }

/* ── Settlement section ── */
.settlement-section { margin-top: 24px; }
.settlement-recorded {
  background: var(--surface);
  border: 2px solid #c3e6cb;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.settlement-recorded .settle-info { flex: 1; min-width: 180px; }
.settlement-recorded .settle-date { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.settle-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}
.settle-proof-thumb {
  width: 60px; height: 60px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid #c3e6cb;
  transition: transform 0.15s;
}
.settle-proof-thumb:hover { transform: scale(1.08); }
.settle-empty {
  background: #f9f9f9;
  border: 2px dashed #dee2e6;
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
}
.btn-settle {
  background: linear-gradient(135deg, var(--hosam-header), #43a047);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 12px;
}
.btn-settle:hover { opacity: 0.88; }

/* ── v1.5.0 additions ─────────────────────────────────────────── */

/* Dashboard settlements list */
.settlement-row {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    margin-bottom: 6px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.settle-date { color: #555; }

/* Fund per-person mini cards */
.mini-row { display:flex; justify-content:space-between; font-size:0.85rem; margin-bottom:4px; }
.mini-label { color:#777; }
.mini-val { font-weight:600; }
.text-danger  { color: #c62828; }
.text-warning { color: #e65100; }

/* Loan rows */
.loan-row {
    padding: 7px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.88rem;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Person badges */
.badge-hosam  { background: #e3f2fd; color: #0d47a1; border-radius: 12px; padding: 2px 8px; font-size:0.78rem; font-weight:600; }
.badge-khaled { background: #e8f5e9; color: #1b5e20; border-radius: 12px; padding: 2px 8px; font-size:0.78rem; font-weight:600; }

/* Installment pay button */
.inst-pay-btn {
    font-size: 0.82rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    white-space: nowrap;
}

/* ── v1.5.2 additions ─────────────────────────────────────────── */

/* Dashboard installment upcoming card */
.inst-up-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-bottom: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.inst-up-name {
    font-weight: 600;
    font-size: 0.93rem;
    margin-bottom: 5px;
    color: var(--text);
}
.inst-up-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.inst-up-amount {
    font-size: 0.95rem;
    color: var(--accent);
}
.inst-up-rem {
    font-size: 0.80rem;
    color: var(--text-muted);
}
.badge-hosam-small {
    background: #e3f2fd;
    color: #0d47a1;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
}
.badge-khaled-small {
    background: #e8f5e9;
    color: #1b5e20;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-weight: 600;
}

/* ── v1.5.3 additions ─────────────────────────────────────────── */

/* Shrink donut chart — limit container width so circle isn't enormous */
.chart-wrap {
    max-width: 230px !important;
    margin: 4px auto !important;
}

/* Created-by badge in tables */
.badge-added-by {
    display: inline-block;
    font-size: 0.70rem;
    background: #f0f4ff;
    color: #1565c0;
    border-radius: 8px;
    padding: 2px 7px;
    white-space: nowrap;
    font-weight: 600;
}

/* Loan repay button — small, info-style */
.btn-loan-repay {
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: #1565c0;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}
.btn-loan-repay:hover { background: #0d47a1; }

/* ── Dashboard calm layout ───────────────────────────────────────────── */
#page-dashboard .dashboard-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#page-dashboard .dashboard-header {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: 22px;
  margin-bottom: 0;
  color: #fff;
  background:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,0.18), transparent 26%),
    linear-gradient(135deg, #101827 0%, #0f3460 58%, #1d5f7b 100%);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 18px 48px rgba(8,18,34,0.18);
}

#page-dashboard .dashboard-header::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  bottom: -95px;
  width: 230px;
  height: 230px;
  border-radius: 50%;
  background: rgba(255,152,0,0.18);
}

#page-dashboard .dashboard-title-block,
#page-dashboard .dash-month-switcher {
  position: relative;
  z-index: 1;
}

#page-dashboard .dashboard-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#page-dashboard .page-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1.2;
}

#page-dashboard .dashboard-title-block p {
  color: rgba(255,255,255,0.76);
  font-size: 0.88rem;
  font-weight: 600;
}

#page-dashboard .dashboard-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}

#page-dashboard .dash-month-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(14px);
}

#page-dashboard .dash-month-switcher .btn {
  min-width: 34px;
  height: 34px;
  justify-content: center;
  padding: 0 10px;
  border: 0;
  background: rgba(255,255,255,0.94);
  color: var(--accent);
}

#page-dashboard .dash-month-pill {
  min-width: 108px;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 900;
}

#page-dashboard .dash-summary-grid {
  grid-template-columns: minmax(250px, 1.35fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

#page-dashboard .dash-summary-grid .card {
  min-height: 118px;
  padding: 18px 18px 16px;
  border: 1px solid rgba(15,52,96,0.09);
  border-top: 0;
  border-radius: 24px;
  box-shadow: 0 10px 28px rgba(8,18,34,0.08);
  overflow: hidden;
  position: relative;
}

#page-dashboard .dash-summary-grid .card::before {
  content: "";
  position: absolute;
  inset-inline-end: 16px;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: rgba(15,52,96,0.08);
}

#page-dashboard .dash-summary-grid .card-total {
  background:
    radial-gradient(circle at 18% 10%, rgba(255,255,255,0.22), transparent 28%),
    linear-gradient(135deg, #0f3460 0%, #153f66 50%, #0f766e 100%);
  color: #fff;
}

#page-dashboard .dash-summary-grid .card-total::before {
  background: rgba(255,255,255,0.16);
}

#page-dashboard .dash-summary-grid .card-total .card-label,
#page-dashboard .dash-summary-grid .card-total .card-sub {
  color: rgba(255,255,255,0.78);
}

#page-dashboard .dash-summary-grid .card-total .card-value {
  color: #fff;
}

#page-dashboard .dash-summary-grid .card-label {
  font-weight: 800;
  margin-bottom: 8px;
}

#page-dashboard .dash-summary-grid .card-value {
  font-size: clamp(1.22rem, 2.1vw, 1.78rem);
  line-height: 1.1;
}

#page-dashboard .dash-summary-grid .card-sub {
  margin-top: 8px;
  line-height: 1.35;
}

#page-dashboard .dash-summary-grid .card-settlement {
  border-right: 0;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

#page-dashboard .dash-pair-row {
  gap: 16px;
  margin-bottom: 0;
}

#page-dashboard .dash-lower-row {
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
}

#page-dashboard .dash-section,
#page-dashboard .dash-settlement-card {
  border: 1px solid rgba(15,52,96,0.08);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(8,18,34,0.07);
  background: rgba(255,255,255,0.94);
}

#page-dashboard .dash-side-stack {
  gap: 16px;
}

#page-dashboard .dash-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

#page-dashboard .dash-section-head .section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

#page-dashboard .dash-section-head p {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

#page-dashboard .badge-count {
  min-width: 26px;
  height: 24px;
  padding: 0 8px;
  font-size: 0.76rem;
  box-shadow: 0 6px 14px rgba(15,52,96,0.16);
}

#page-dashboard .dash-mini-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

#page-dashboard .dash-mini-metrics .card {
  min-height: 86px;
  padding: 12px;
  border-radius: 18px;
  box-shadow: none;
  border: 1px solid rgba(15,52,96,0.08);
}

#page-dashboard .dash-mini-metrics .card-value {
  font-size: 1.08rem;
}

#page-dashboard .oblig-countdown-grid {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 0;
  max-height: 430px;
  overflow: auto;
  padding-inline-end: 2px;
}

#page-dashboard .oblig-countdown-card,
#page-dashboard .inst-up-card {
  border-radius: 18px;
  box-shadow: none;
  border: 1px solid rgba(15,52,96,0.08);
  border-right: 4px solid var(--accent);
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

#page-dashboard .oblig-countdown-card {
  padding: 12px 13px;
}

#page-dashboard .oblig-cc-name {
  font-size: 0.92rem;
}

#page-dashboard .oblig-cc-meta {
  line-height: 1.45;
}

#page-dashboard .oblig-cc-amount {
  font-size: 0.98rem;
}

#page-dashboard .inst-up-card {
  padding: 12px;
  margin-bottom: 10px;
}

#page-dashboard .inst-up-card:last-child {
  margin-bottom: 0;
}

#page-dashboard .inst-up-name {
  margin-bottom: 8px;
  line-height: 1.35;
}

#page-dashboard .inst-up-meta {
  gap: 7px;
}

#page-dashboard .inst-up-rem {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(15,52,96,0.12);
}

#page-dashboard .settlement-banner {
  margin-bottom: 10px;
  border-radius: 20px;
  padding: 16px;
  font-size: 1rem;
  line-height: 1.55;
}

#page-dashboard .card-settlement .settlement-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin: 6px 0 6px;
  padding: 10px 12px;
  border-radius: 16px;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
  box-shadow: none;
}

#page-dashboard .dash-settlement-meta {
  padding: 0 2px;
}

#page-dashboard .card-settlement .dash-settlement-meta {
  padding: 0;
  font-size: 0.72rem;
  line-height: 1.35;
}

#page-dashboard .followup-row {
  padding: 11px 0;
}

#page-dashboard .followup-side {
  align-items: flex-end;
  flex-direction: column;
  gap: 4px;
}

#page-dashboard .chart-wrap-horizontal {
  width: 100%;
  max-width: none !important;
  min-height: 310px;
  margin: 0 !important;
}

#page-dashboard .chart-wrap-horizontal canvas {
  width: 100% !important;
}

@media (max-width: 1100px) {
  #page-dashboard .dash-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #page-dashboard .dash-summary-grid .card-total {
    grid-column: 1 / -1;
  }

  #page-dashboard .dash-lower-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #page-dashboard .dashboard-shell {
    gap: 12px;
  }

  #page-dashboard .dashboard-header {
    align-items: stretch;
    padding: 18px;
    border-radius: 24px;
  }

  #page-dashboard .dashboard-title-block p {
    max-width: 280px;
  }

  #page-dashboard .dash-month-switcher {
    width: 100%;
    justify-content: space-between;
  }

  #page-dashboard .dash-month-pill {
    flex: 1;
    min-width: 0;
  }

  #page-dashboard .dash-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  #page-dashboard .dash-summary-grid .card {
    min-height: 104px;
    padding: 14px 13px;
    border-radius: 20px;
  }

  #page-dashboard .dash-summary-grid .card-value {
    font-size: 1.12rem;
  }

  #page-dashboard .dash-summary-grid .card-label,
  #page-dashboard .dash-summary-grid .card-sub {
    font-size: 0.74rem;
  }

  #page-dashboard .dash-section,
  #page-dashboard .dash-settlement-card {
    padding: 15px;
    border-radius: 21px;
  }

  #page-dashboard .dash-section-head {
    margin-bottom: 12px;
  }

  #page-dashboard .dash-section-head .section-title {
    font-size: 0.94rem;
  }

  #page-dashboard .dash-section-head p {
    font-size: 0.76rem;
  }

  #page-dashboard .dash-mini-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  #page-dashboard .dash-mini-metrics .card {
    min-height: 74px;
    padding: 10px 7px;
    text-align: center;
  }

  #page-dashboard .dash-mini-metrics .card-label {
    font-size: 0.68rem;
  }

  #page-dashboard .dash-mini-metrics .card-value {
    font-size: 0.86rem;
  }

  #page-dashboard .oblig-countdown-grid {
    max-height: none;
    overflow: visible;
  }

  #page-dashboard .oblig-cc-header {
    align-items: flex-start;
  }

  #page-dashboard .oblig-cc-amount {
    font-size: 0.9rem;
  }

  #page-dashboard .inst-up-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  #page-dashboard .inst-up-amount {
    font-size: 0.9rem;
  }

  #page-dashboard .followup-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  #page-dashboard .followup-side {
    width: 100%;
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (max-width: 400px) {
  #page-dashboard .dash-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #page-dashboard .dash-summary-grid .card-total {
    grid-column: 1 / -1;
  }
}

/* ── Full app polish ────────────────────────────────────────────────── */
.btn-secondary { background: #334155; color: #fff; }
.btn-secondary:hover { background: #1f2937; }
.btn-info { background: #0f766e; color: #fff; }
.btn-info:hover { background: #115e59; }

.app-page-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-page-hero {
  position: relative;
  overflow: hidden;
  align-items: stretch;
  margin-bottom: 0;
  padding: 20px;
  border: 1px solid rgba(15,52,96,0.09);
  border-radius: 26px;
  background:
    radial-gradient(circle at 8% 12%, rgba(255,152,0,0.10), transparent 26%),
    linear-gradient(135deg, rgba(255,255,255,0.98), rgba(248,251,255,0.94));
  box-shadow: 0 14px 36px rgba(8,18,34,0.08);
}

.app-page-hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  bottom: -95px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(15,52,96,0.06);
  pointer-events: none;
}

.page-title-block,
.app-page-hero .header-actions {
  position: relative;
  z-index: 1;
}

.page-title-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
}

.page-title-block .page-title {
  font-size: 1.28rem;
  line-height: 1.25;
}

.page-title-block p {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.55;
}

.app-page-hero .header-actions {
  justify-content: flex-end;
  padding: 6px;
  border: 1px solid rgba(15,52,96,0.08);
  border-radius: 20px;
  background: rgba(255,255,255,0.72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
  backdrop-filter: blur(14px);
}

.app-page-hero .header-actions .btn,
.app-page-hero .header-actions .form-select-sm {
  min-height: 36px;
  border-radius: 14px;
}

.app-page-hero .header-actions .btn {
  justify-content: center;
}

.filter-panel,
.app-section-card,
.app-page-shell .table-wrap,
.app-page-shell .settlement-section {
  border: 1px solid rgba(15,52,96,0.08);
  border-radius: 24px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 10px 28px rgba(8,18,34,0.07);
}

.filter-panel {
  padding: 16px;
}

.filter-panel-head,
.table-title-row,
.section-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.filter-panel-head strong {
  display: block;
  color: var(--header-bg);
  font-size: 0.96rem;
}

.filter-panel-head span,
.table-title-row p,
.section-head-row p {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.filter-panel .filter-bar {
  margin-bottom: 0;
}

.filter-panel .search-input,
.filter-panel .form-select-sm,
.app-page-hero .form-select-sm {
  border-color: rgba(15,52,96,0.12);
  background: #fff;
  box-shadow: 0 2px 8px rgba(8,18,34,0.04);
}

.app-page-shell .tracking-summary {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  margin: 0;
}

.app-page-shell .tracking-chip {
  border: 1px solid rgba(15,52,96,0.08);
  border-right-width: 4px;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: 0 8px 22px rgba(8,18,34,0.05);
}

.page-summary-grid {
  gap: 12px;
  margin-bottom: 0;
}

.page-summary-grid .card,
.app-page-shell .card {
  border: 1px solid rgba(15,52,96,0.08);
  border-top: 0;
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(8,18,34,0.07);
}

.page-summary-grid .card {
  min-height: 112px;
  padding: 16px;
}

.page-summary-grid .card-label {
  font-weight: 800;
}

.page-summary-grid .card-value {
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.15;
}

.compact-summary-grid .card {
  min-height: 92px;
  padding: 13px 14px;
}

.helper-note {
  margin: -4px 2px 0;
  padding: 10px 14px;
  border: 1px solid rgba(230,81,0,0.14);
  border-radius: 16px;
  background: #fffaf2;
  color: #8a4b0a;
  font-size: 0.83rem;
  line-height: 1.55;
}

.app-section-card {
  padding: 18px;
  margin: 0 !important;
}

.app-section-card .section-title,
.table-title-row .section-title,
.section-head-row .section-title {
  margin: 0;
  padding: 0;
  border: 0;
  line-height: 1.3;
}

.section-head-row .btn {
  flex-shrink: 0;
}

.section-head-clickable {
  cursor: pointer;
  user-select: none;
}

.section-toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 12px;
  border-radius: 999px;
  background: #edf4ff;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.app-page-shell .table-wrap {
  margin-bottom: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.app-page-shell .table-panel {
  padding: 0;
}

.titled-table .table-title-row {
  margin: 0;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(15,52,96,0.08);
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.app-page-shell .data-table {
  min-width: 760px;
}

.app-page-shell .data-table th {
  background: #111827;
  padding: 12px;
  font-size: 0.82rem;
}

.app-page-shell .data-table td {
  padding: 12px;
  border-bottom-color: rgba(15,52,96,0.08);
}

.app-page-shell .data-table tbody tr:nth-child(even) {
  background: rgba(248,250,252,0.72);
}

.app-page-shell .data-table tbody tr:hover {
  background: #edf4ff;
}

.app-page-shell .settlement-section {
  margin: 0;
  padding: 18px;
}

.app-page-shell .settlement-section table {
  overflow: hidden;
  border-radius: 16px;
}

.obligations-page .obligation-cards {
  gap: 10px;
}

.obligations-page .obl-due-card {
  border: 1px solid rgba(230,81,0,0.14);
  border-right-width: 4px;
  border-radius: 18px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fffaf2, #fff);
  box-shadow: 0 6px 18px rgba(230,81,0,0.06);
}

.obligations-page .installments-panel .installment-cards,
.installments-page .installment-cards {
  gap: 12px;
}

.app-page-shell .inst-card {
  border: 1px solid rgba(15,52,96,0.08);
  border-right-width: 5px;
  border-radius: 22px;
  box-shadow: 0 10px 26px rgba(8,18,34,0.07);
}

.app-page-shell .inst-card-header {
  gap: 10px;
}

.app-page-shell .inst-card-amounts {
  gap: 10px;
}

.app-page-shell .inst-amt-item {
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid rgba(15,52,96,0.08);
  border-radius: 14px;
  background: rgba(248,250,252,0.88);
}

.fund-page .fund-balance-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 18% 15%, rgba(255,255,255,0.22), transparent 28%),
    linear-gradient(135deg, #c2410c 0%, #f97316 46%, #f59e0b 100%);
  box-shadow: 0 18px 48px rgba(194,65,12,0.22);
}

.fund-page .fund-balance-card::after {
  content: "";
  position: absolute;
  inset-inline-end: -80px;
  bottom: -95px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
}

.fund-page .fund-balance-label,
.fund-page .fund-balance-amount,
.fund-page .fund-balance-sub {
  position: relative;
  z-index: 1;
}

.fund-page .person-balance-grid {
  margin-bottom: 0 !important;
}

.fund-page .mini-row {
  padding: 8px 0;
  border-bottom: 1px dashed rgba(15,52,96,0.12);
}

.fund-page .mini-row:last-child {
  border-bottom: 0;
}

.fund-page #fundOpenLoansWrap {
  margin-bottom: 0 !important;
}

.expense-card-list .expense-card {
  border-color: rgba(15,52,96,0.08);
  border-right-width: 5px;
  border-radius: 20px;
  box-shadow: 0 8px 22px rgba(8,18,34,0.06);
}

.modal {
  border-radius: 24px;
}

.modal-header {
  border-radius: 24px 24px 0 0;
}

@media (max-width: 900px) {
  .app-page-hero {
    flex-direction: column;
  }

  .app-page-hero .header-actions {
    justify-content: flex-start;
  }

  .page-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-page-shell {
    gap: 12px;
  }

  .app-page-hero {
    padding: 16px;
    border-radius: 22px;
  }

  .page-title-block {
    min-width: 0;
  }

  .page-title-block .page-title {
    font-size: 1.14rem;
  }

  .page-title-block p {
    font-size: 0.78rem;
  }

  .app-page-hero .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    gap: 7px;
    padding: 7px;
  }

  .app-page-hero .header-actions .btn,
  .app-page-hero .header-actions .form-select-sm,
  .filter-panel .form-select-sm,
  .filter-panel .search-input {
    width: 100%;
    justify-content: center;
  }

  .filter-panel,
  .app-section-card,
  .app-page-shell .settlement-section {
    padding: 14px;
    border-radius: 20px;
  }

  .filter-panel-head,
  .table-title-row,
  .section-head-row {
    flex-direction: column;
    gap: 8px;
  }

  .section-head-row .btn,
  .section-toggle-pill {
    width: 100%;
  }

  .filter-panel .filter-bar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .app-page-shell .tracking-summary {
    grid-template-columns: 1fr;
  }

  .page-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .page-summary-grid .card {
    min-height: 96px;
    padding: 13px;
  }

  .page-summary-grid .card-label {
    font-size: 0.74rem;
  }

  .page-summary-grid .card-value {
    font-size: 1.02rem;
  }

  .compact-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .compact-summary-grid .card {
    min-height: 76px;
    padding: 10px 7px;
    text-align: center;
  }

  .compact-summary-grid .card-label {
    font-size: 0.66rem;
  }

  .compact-summary-grid .card-value {
    font-size: 0.86rem;
  }

  .titled-table .table-title-row {
    padding: 14px;
  }

  .app-page-shell .data-table th,
  .app-page-shell .data-table td {
    padding: 10px;
  }

  .fund-page .fund-balance-card {
    padding: 24px 18px;
    border-radius: 24px;
  }

  .fund-page .fund-balance-amount {
    font-size: 2.15rem;
  }

  .app-page-shell .inst-card {
    padding: 15px;
  }

  .app-page-shell .inst-card-header,
  .app-page-shell .inst-card-footer {
    flex-direction: column;
    gap: 10px;
  }

  .app-page-shell .inst-card-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}

@media (max-width: 400px) {
  .page-summary-grid,
  .compact-summary-grid {
    grid-template-columns: 1fr;
  }
}
