/* ================================================================
   THEME — glassmorphism layer, loaded last on every page.
   Frosted translucent panels over a soft animated colour field,
   Archaic blues with violet/cyan accents. Remove this file to get the
   plain Loan-Tracker look back.
   ================================================================ */

:root {
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-soft: rgba(255, 255, 255, 0.38);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-edge: rgba(29, 111, 219, 0.10);
  --glass-blur: saturate(170%) blur(18px);
  --glass-shadow: 0 10px 40px rgba(30, 41, 90, 0.10), 0 2px 6px rgba(30, 41, 90, 0.05);
  --glass-shadow-hover: 0 18px 50px rgba(29, 111, 219, 0.18), 0 4px 10px rgba(30, 41, 90, 0.06);
  --violet: #7C3AED;
  --cyan: #06B6D4;
  --grad-primary: linear-gradient(135deg, #2563EB 0%, #1D6FDB 40%, #7C3AED 100%);
  --grad-text: linear-gradient(120deg, #1D4ED8 0%, #2B83F0 45%, #7C3AED 100%);
  --grad-good: linear-gradient(135deg, #10B981, #06B6D4);
  --grad-alert: linear-gradient(135deg, #F43F5E, #F97316);
  --grad-sidebar: linear-gradient(170deg, #0B1230 0%, #142057 48%, #23164F 100%);
  --radius-lg: 22px;
  --radius-md: 16px;
}

/* ---------- Background: colour field + floating blobs ---------- */
body {
  background:
    radial-gradient(1200px 700px at 8% -10%, rgba(59, 130, 246, 0.20), transparent 60%),
    radial-gradient(900px 600px at 105% 10%, rgba(124, 58, 237, 0.16), transparent 60%),
    radial-gradient(900px 700px at 60% 115%, rgba(6, 182, 212, 0.16), transparent 60%),
    linear-gradient(160deg, #EEF3FF 0%, #F5F3FF 50%, #ECFEFF 100%);
  background-attachment: fixed;
}
body::before, body::after {
  content: ''; position: fixed; z-index: -1; border-radius: 50%; filter: blur(70px); opacity: 0.55; pointer-events: none;
}
body::before { width: 420px; height: 420px; left: 30%; top: 18%; background: #93C5FD; animation: drift 22s ease-in-out infinite alternate; }
body::after { width: 360px; height: 360px; right: 6%; bottom: 8%; background: #C4B5FD; animation: drift 26s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(80px, -60px) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { body::before, body::after, .page-in > * { animation: none !important; } }

/* ---------- Glass surfaces ---------- */
.box, .card, .doc, .board-col, .auth-card, .empty-state, .table-wrap.glass, .print-preview {
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.box { border-radius: var(--radius-lg); }
.doc { border-radius: var(--radius-lg); background: var(--glass-strong); }
.empty-state { border-radius: var(--radius-lg); }
.box-head h2, .box > h2 { display: flex; align-items: center; gap: 8px; }
.box > h2::before, .box-head h2::before {
  content: ''; width: 8px; height: 8px; border-radius: 3px; background: var(--grad-primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Stat cards: frosted, with a soft coloured glow in the corner */
.card { border-radius: var(--radius-lg); padding: 20px 22px; }
.card::after {
  content: ''; position: absolute; width: 120px; height: 120px; right: -40px; top: -40px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.22), transparent 70%); pointer-events: none;
}
.card.good::after { background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 70%); }
.card.alert::after { background: radial-gradient(circle, rgba(244, 63, 94, 0.25), transparent 70%); }
.card.info::after { background: radial-gradient(circle, rgba(6, 182, 212, 0.25), transparent 70%); }
.card:hover { box-shadow: var(--glass-shadow-hover); border-color: rgba(255, 255, 255, 0.95); transform: translateY(-4px); }
.card .value { font-size: 27px; }
.card.good .value { background: var(--grad-good); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.card.alert { border-color: rgba(244, 63, 94, 0.35); }
.card.alert::before { background: var(--grad-alert); }
.card.alert .value { background: var(--grad-alert); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- Sidebar: deep frosted night ---------- */
.sidebar {
  background: var(--grad-sidebar);
  box-shadow: 8px 0 40px rgba(11, 18, 48, 0.25);
}
.sidebar::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(400px 300px at 0% 0%, rgba(59, 130, 246, 0.35), transparent 60%),
              radial-gradient(300px 300px at 100% 100%, rgba(124, 58, 237, 0.35), transparent 60%);
}
.sidebar > * { position: relative; }
.sidebar .brand img { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.18), 0 10px 32px rgba(59, 130, 246, 0.6); }
.nav-link { border: 1px solid transparent; }
.nav-link:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.08); }
.nav-link.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(124, 58, 237, 0.45));
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.nav-badge { background: var(--grad-alert); box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2); }
.nav-badge.soft { background: rgba(255, 255, 255, 0.18); box-shadow: none; }

/* ---------- Top bar ---------- */
.topbar {
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 24px rgba(30, 41, 90, 0.06);
}
.quick-menu, .toast {
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.quick-menu { background: var(--glass-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow-hover); }
.toast { background: rgba(15, 23, 42, 0.82); border: 1px solid rgba(255, 255, 255, 0.12); }

/* ---------- Headings ---------- */
.page-title { font-size: 28px; }
.page-head > div > .page-title:first-child {
  background: linear-gradient(120deg, #0F172A 0%, #1E3A8A 55%, #6D28D9 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.page-title .pill { -webkit-text-fill-color: initial; }

/* ---------- Buttons ---------- */
.btn { background: rgba(255, 255, 255, 0.65); border-color: rgba(29, 111, 219, 0.18); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.btn:hover { background: rgba(255, 255, 255, 0.95); }
.btn.primary { background: var(--grad-primary); box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.btn.primary:hover { box-shadow: 0 12px 34px rgba(124, 58, 237, 0.35); }
.btn.whatsapp { background: linear-gradient(135deg, #25D366, #128C7E); color: #fff; border-color: transparent; box-shadow: 0 8px 22px rgba(37, 211, 102, 0.35); }
.btn.whatsapp:hover { color: #fff; box-shadow: 0 12px 30px rgba(18, 140, 126, 0.4); }
.btn.success { background: var(--grad-good); color: #fff; border-color: transparent; box-shadow: 0 8px 22px rgba(16, 185, 129, 0.3); }
.btn.success:hover { color: #fff; }
.segmented, .subnav a, .subnav button { background: rgba(255, 255, 255, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.subnav .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px;
  background: rgba(29, 111, 219, 0.12); color: var(--primary); font-size: 11px; }
.subnav .active .count { background: rgba(255, 255, 255, 0.25); color: #fff; }
.subnav .count.alert { background: var(--grad-alert); color: #fff; }

/* ---------- Inputs ---------- */
.input, dialog input, dialog select, dialog textarea, .editor-grid .input, .lines .input, .editor-notes .input, .calc-form .input {
  background: rgba(255, 255, 255, 0.7) !important;
  border-color: rgba(29, 111, 219, 0.14) !important;
}
.input:focus, dialog input:focus, dialog select:focus, dialog textarea:focus {
  background: #fff !important; border-color: var(--primary) !important; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12) !important;
}

/* ---------- Tables ---------- */
.list thead th { background: rgba(255, 255, 255, 0.45); }
.list tbody tr:hover { background: rgba(255, 255, 255, 0.7); }
.list th, .list td { border-bottom-color: rgba(29, 111, 219, 0.08); }

/* ---------- Pills get a soft glow ---------- */
.pill { box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05); }

/* ---------- Dialogs ---------- */
dialog {
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(6px); }
dialog[open] { animation: pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ---------- Page entrance ---------- */
.page-in > * { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.page-in > *:nth-child(2) { animation-delay: 0.04s; }
.page-in > *:nth-child(3) { animation-delay: 0.08s; }
.page-in > *:nth-child(4) { animation-delay: 0.12s; }
.page-in > *:nth-child(5) { animation-delay: 0.16s; }
.page-in > *:nth-child(n+6) { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cards > .card { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.cards > .card:nth-child(2) { animation-delay: 0.05s; }
.cards > .card:nth-child(3) { animation-delay: 0.1s; }
.cards > .card:nth-child(4) { animation-delay: 0.15s; }
.cards > .card:nth-child(n+5) { animation-delay: 0.2s; }

/* ---------- Board ---------- */
.board-col { border-radius: var(--radius-md); }
.board-col.drop { background: rgba(219, 234, 254, 0.7); }
.lead-card { background: rgba(255, 255, 255, 0.85); border: 1px solid rgba(255, 255, 255, 0.9); box-shadow: 0 4px 14px rgba(30, 41, 90, 0.08); }
.lead-card:hover { transform: translateY(-2px); box-shadow: var(--glass-shadow-hover); }

/* ---------- Charts ---------- */
.bar-billed { background: linear-gradient(180deg, #60A5FA, #2563EB); box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.bar-received { background: linear-gradient(180deg, #34D399, #059669); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.funnel-bar { background: rgba(148, 163, 184, 0.18); }
.bar-inline { background: var(--grad-primary); }

/* ---------- Editor ---------- */
.editor-actions { background: rgba(255, 255, 255, 0.7); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border-top: 1px solid rgba(255, 255, 255, 0.8); border-radius: 18px 18px 0 0; padding: 14px 18px; }
.pay-panel { border: 1.5px dashed rgba(16, 185, 129, 0.45); background: linear-gradient(135deg, rgba(209, 250, 229, 0.55), rgba(207, 250, 254, 0.45)) !important; }
.pay-panel.off { border-color: rgba(29, 111, 219, 0.18); background: var(--glass) !important; }
.pay-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.pay-toggle input { width: 20px; height: 20px; accent-color: #10B981; }
.pay-note { margin-top: 10px; font-size: 13px; color: #065F46; font-weight: 500; }

/* ---------- Share / send sheet ---------- */
.share-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.10), rgba(124, 58, 237, 0.10)); border: 1px solid rgba(255, 255, 255, 0.8); }
.share-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; color: #fff;
  background: var(--grad-primary); font: 700 18px 'Space Grotesk', sans-serif; box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35); }
.share-head strong { display: block; font: 700 16px 'Space Grotesk', sans-serif; }
.share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.share-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border-radius: 16px; cursor: pointer; text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.85); background: rgba(255, 255, 255, 0.7); font: 600 13px 'Inter', sans-serif; color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 4px 14px rgba(30, 41, 90, 0.06);
}
.share-tile:hover { transform: translateY(-3px); box-shadow: var(--glass-shadow-hover); color: var(--text); }
.share-tile small { font-weight: 400; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.share-tile .t-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 16px; margin-bottom: 4px; }
.t-wa { background: linear-gradient(135deg, #25D366, #128C7E); }
.t-api { background: linear-gradient(135deg, #10B981, #0EA5E9); }
.t-file { background: linear-gradient(135deg, #F59E0B, #F97316); }
.t-mail { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.t-pdf { background: linear-gradient(135deg, #EF4444, #DB2777); }
.t-link { background: linear-gradient(135deg, #64748B, #334155); }
.share-tile.primary { background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(18, 140, 126, 0.12)); border-color: rgba(37, 211, 102, 0.35); }
.share-foot { font-size: 12px; color: var(--muted); margin-top: 8px; }
.done-hero { text-align: center; padding: 6px 0 14px; }
.done-check { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 30px;
  background: var(--grad-good); box-shadow: 0 12px 30px rgba(16, 185, 129, 0.4); animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4); }
.done-docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.done-doc { padding: 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.75); border: 1px solid rgba(255, 255, 255, 0.9); box-shadow: 0 4px 14px rgba(30, 41, 90, 0.06); }
.done-doc .cap { font: 700 10px 'Space Mono', monospace; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); }
.done-doc strong { display: block; font: 700 16px 'Space Grotesk', sans-serif; margin: 2px 0 10px; }
.done-doc .btn-row { margin-top: 0; }

/* ---------- Follow-ups ---------- */
.fu-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(255, 255, 255, 0.85); margin-bottom: 10px; box-shadow: 0 4px 14px rgba(30, 41, 90, 0.05);
  transition: transform 0.2s, box-shadow 0.2s; }
.fu-row:hover { transform: translateY(-2px); box-shadow: var(--glass-shadow-hover); }
.fu-row.overdue { border-left: 4px solid #F43F5E; }
.fu-row.today { border-left: 4px solid #2563EB; }
.fu-main { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.fu-title { font-weight: 700; color: var(--text); }
.fu-title:hover { color: var(--primary); }
.fu-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.fu-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.fu-when { font-weight: 700; font-size: 12px; padding: 2px 10px; border-radius: 100px; background: rgba(29, 111, 219, 0.1); color: var(--primary); }
.fu-when.late { background: rgba(244, 63, 94, 0.12); color: #E11D48; }
.fu-amount { font: 700 17px 'Space Grotesk', sans-serif; }
.snooze { display: inline-flex; border: 1px solid rgba(29, 111, 219, 0.18); border-radius: 100px; overflow: hidden; background: rgba(255, 255, 255, 0.7); }
.snooze button { border: 0; background: none; padding: 4px 10px; font: 600 12px 'Inter', sans-serif; color: var(--text-medium); cursor: pointer; }
.snooze button + button { border-left: 1px solid rgba(29, 111, 219, 0.12); }
.snooze button:hover { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.snooze span { padding: 4px 8px 4px 10px; font-size: 11px; color: var(--muted); align-self: center; }

/* ---------- Login ---------- */
.auth-page { background: transparent; }
.auth-card { border-radius: 28px; background: rgba(255, 255, 255, 0.62); }
.auth-intro h1 { font-size: clamp(32px, 4.8vw, 50px); }

@media (max-width: 700px) {
  .fu-row { grid-template-columns: minmax(0, 1fr); }
  .fu-actions { justify-content: flex-start; }
}

/* ---------- Settings → Templates ---------- */
.tpl-preview { padding: 12px; }
.tpl-preview img { display: block; width: 100%; height: auto; border-radius: 12px; background: #fff; cursor: zoom-in;
  box-shadow: 0 10px 34px rgba(30, 41, 90, 0.16); transition: transform 0.25s; }
.tpl-preview img:hover { transform: scale(1.01); }
.tpl-list { margin: 0 0 12px; padding-left: 18px; line-height: 1.9; color: var(--text-medium); }
.wa-chat { margin-top: 10px; padding: 16px 14px; border-radius: 16px;
  background: #E7DED4 radial-gradient(rgba(255,255,255,0.35) 1px, transparent 1px) 0 0 / 14px 14px; }
.wa-bubble { position: relative; max-width: 92%; margin-left: auto; padding: 8px 10px 18px; border-radius: 10px 0 10px 10px;
  background: #D9FDD3; color: #111B21; font: 13px/1.45 'Inter', system-ui, sans-serif; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.wa-bubble::after { content: '✓✓'; position: absolute; right: 8px; bottom: 3px; font-size: 10px; color: #53BDEB; letter-spacing: -2px; }

/* ---------- Settings → Signature & seal ---------- */
.sig-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: center; }
.sig-preview { text-align: center; padding: 16px; border-radius: 16px; background: #fff; border: 1.5px dashed rgba(29, 111, 219, 0.25); }
.sig-preview img { max-width: 100%; max-height: 120px; display: block; margin: 0 auto 6px; }
.sig-label { font-size: 11px; color: var(--muted); letter-spacing: 0.06em; }
.sig-toggles { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 6px; }
.settings-form .sig-toggles label.check { grid-column: auto; }
@media (max-width: 700px) { .sig-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Invoice screen hero ---------- */
.doc-hero { position: relative; overflow: hidden; border-radius: 24px; padding: 24px 26px; margin-bottom: 20px; color: #fff;
  background: linear-gradient(135deg, #0B1230 0%, #1E3A8A 50%, #6D28D9 100%); box-shadow: 0 24px 60px rgba(30, 27, 110, 0.3); }
.doc-hero::before { content: ''; position: absolute; width: 300px; height: 300px; right: -80px; top: -120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.14), transparent 65%); }
.doc-hero::after { content: ''; position: absolute; width: 240px; height: 240px; left: 30%; bottom: -160px; border-radius: 50%;
  background: radial-gradient(circle, rgba(6,182,212,0.28), transparent 65%); }
.doc-hero > * { position: relative; z-index: 1; }
.dh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; align-items: end; }
.dh-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: #A5B4FC; }
.dh-value { font: 700 22px 'Space Grotesk', sans-serif; }
.dh-big { font: 700 clamp(30px, 4vw, 42px) 'Space Grotesk', sans-serif; line-height: 1.1;
  background: linear-gradient(120deg, #fff 30%, #C7D2FE); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.dh-bar { height: 10px; border-radius: 10px; background: rgba(255,255,255,0.15); overflow: hidden; margin-top: 16px; }
.dh-bar > div { height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, #22D3EE, #A78BFA, #F0ABFC);
  transition: width 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s; box-shadow: 0 0 18px rgba(167, 139, 250, 0.8); }
.dh-foot { display: flex; justify-content: space-between; font-size: 12.5px; color: #C7D2FE; margin-top: 6px; }
.dh-chip { display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 100px; font: 700 11.5px 'Inter', sans-serif;
  letter-spacing: 0.05em; background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.22); }
.dh-chip i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.tpl-source { margin: 2px 4px 12px; font-size: 13px; font-weight: 600; color: var(--primary); }
.tpl-source:empty { display: none; }
