/* ============================================================
   VicobaSmart — styles.css
   Mobile-first, brand: deep purple #5B2A86, system font stack.
   ============================================================ */

:root {
  --brand: #5B2A86;
  --brand-dark: #46206A;
  --brand-light: #7A4BAE;
  --brand-pale: #EFE7F7;
  --accent: #F2C94C;
  --green: #1E8E3E;
  --green-pale: #E6F4EA;
  --red: #C5221F;
  --red-pale: #FCE8E6;
  --amber: #B06000;
  --amber-pale: #FEF3E0;
  --ink: #22182E;
  --ink-soft: #5F5470;
  --line: #E4DCEE;
  --bg: #F5F2F8;
  --card: #FFFFFF;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(34, 24, 46, 0.10), 0 1px 2px rgba(34, 24, 46, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --tabbar-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 16px; }

/* ---------- Layout: mobile-first, desktop max width ---------- */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Header ---------- */

#app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 6px rgba(70, 32, 106, 0.35);
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  min-height: 58px;
}

.header-title { flex: 1; min-width: 0; }

.header-title .app-name {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.2px;
  line-height: 1.15;
}

.header-title .group-name {
  font-size: 12.5px;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-toggle {
  display: flex;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-toggle button {
  background: transparent;
  color: #fff;
  border: 0;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-width: 44px;
  min-height: 36px;
}

.lang-toggle button.active { background: #fff; color: var(--brand); }

.icon-btn {
  background: transparent;
  border: 0;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:active { background: rgba(255, 255, 255, 0.18); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Bottom tab bar ---------- */

#tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  height: var(--tabbar-h);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 4px 0;
}

.tab-btn svg { width: 24px; height: 24px; }
.tab-btn.active { color: var(--brand); }
.tab-btn.active .tab-label { font-weight: 800; }

/* ---------- Cards, headings ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--brand-dark);
}

.page-title {
  font-size: 20px;
  font-weight: 800;
  margin: 4px 0 12px;
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title .spacer { flex: 1; }

.muted { color: var(--ink-soft); font-size: 13px; }
.small { font-size: 12.5px; }

/* ---------- Stat grid (dashboard) ---------- */

.stat-hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.stat-hero .label { font-size: 13px; opacity: 0.9; }
.stat-hero .value { font-size: 30px; font-weight: 800; letter-spacing: 0.3px; }

.stat-hero .split {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.stat-hero .split > div {
  flex: 1;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
}

.stat-hero .split .k { font-size: 11.5px; opacity: 0.9; }
.stat-hero .split .v { font-size: 15px; font-weight: 700; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.stat .k { font-size: 12px; color: var(--ink-soft); }
.stat .v { font-size: 18px; font-weight: 800; color: var(--brand-dark); margin-top: 2px; }
.stat .sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- Tappable stats & drill-down doors ---------- */

.door { cursor: pointer; }

.door:focus-visible {
  outline: 2px solid var(--brand-light);
  outline-offset: 2px;
  border-radius: 8px;
}

.stat-chev svg { width: 18px; height: 18px; display: block; }

.stat.door { position: relative; padding-right: 30px; }

.stat.door .stat-chev {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  display: flex;
}

.stat.door:active { background: var(--brand-pale); }

.stat-hero .value.door {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
}

.stat-hero .value.door .stat-chev { display: flex; color: rgba(255, 255, 255, 0.85); }
.stat-hero .value.door:active { opacity: 0.8; }

.stat-hero .split > .door { position: relative; padding-right: 26px; }

.stat-hero .split > .door .stat-chev {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
}

.stat-hero .split > .door:active { background: rgba(255, 255, 255, 0.26); }

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

.filter-chips button {
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 13px;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  white-space: nowrap;
}

.filter-chips button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tbl tr.row-door { cursor: pointer; }
.tbl tr.row-door:active td { background: var(--brand-pale); }

.feed-item.door { cursor: pointer; }
.feed-item.door:active { background: var(--brand-pale); }
.feed-item .chevron { align-self: center; }
.feed-item .chevron svg { width: 18px; height: 18px; display: block; }

.v-door {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.v-door:active { opacity: 0.7; }

.badge.door:active { opacity: 0.7; }

.loan-card.focus-flash { outline: 2.5px solid var(--brand-light); outline-offset: 2px; }

.rep-bar { cursor: pointer; }
.rep-bar:focus-visible { outline: 2px solid var(--brand-light); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  text-align: center;
}

.btn:active { background: var(--brand-dark); }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--brand-pale); color: var(--brand-dark); }
.btn.secondary:active { background: #E2D3F2; }
.btn.danger { background: var(--red); }
.btn.ghost {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ---------- Lists ---------- */

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  border: 0;
  width: 100%;
  text-align: left;
  min-height: 64px;
}

.list-item .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-pale);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; font-size: 15px; }
.list-item .sub { font-size: 12.5px; color: var(--ink-soft); }
.list-item .end { text-align: right; flex-shrink: 0; }
.list-item .end .big { font-weight: 800; color: var(--brand-dark); font-size: 14px; }
.list-item .end .sub { font-size: 11.5px; }

.chevron { color: var(--ink-soft); flex-shrink: 0; }

/* ---------- Badges / chips ---------- */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-pale);
  color: var(--brand-dark);
}

.badge.green { background: var(--green-pale); color: var(--green); }
.badge.red { background: var(--red-pale); color: var(--red); }
.badge.amber { background: var(--amber-pale); color: var(--amber); }
.badge.gold { background: #FDF3D7; color: #8a6d00; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--red-pale);
  color: var(--red);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px 4px 10px;
  margin: 3px 4px 0 0;
}

.chip button {
  background: rgba(197, 34, 31, 0.12);
  border: 0;
  color: var(--red);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Forms ---------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="tel"],
.field select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  color: var(--ink);
  min-height: 48px;
}

.field input:focus, .field select:focus {
  outline: 2px solid var(--brand-light);
  border-color: var(--brand-light);
}

.field .hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 15px;
}

.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand);
}

/* ---------- Wizard ---------- */

.wizard-steps {
  display: flex;
  gap: 6px;
  margin: 6px 0 16px;
}

.wizard-steps span {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}

.wizard-steps span.done { background: var(--brand); }

.wizard-hero {
  text-align: center;
  padding: 18px 8px 6px;
}

.wizard-hero .logo {
  width: 74px;
  height: 74px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.fine-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.fine-row input { flex: 1; min-width: 0; }
.fine-row input.amt { max-width: 120px; }

.fine-row .remove {
  background: var(--red-pale);
  color: var(--red);
  border: 0;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------- Meeting screen ---------- */

.meet-totals {
  position: sticky;
  top: 58px;
  z-index: 30;
  background: var(--brand-dark);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  text-align: center;
}

.meet-totals .k { font-size: 10.5px; opacity: 0.85; }
.meet-totals .v { font-size: 13.5px; font-weight: 800; }

.meet-row {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.meet-row .top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meet-row .name { font-weight: 700; font-size: 15px; }

.meet-row .controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.stepper {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.stepper button {
  width: 46px;
  height: 46px;
  border: 0;
  background: var(--brand-pale);
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

.stepper button:disabled { opacity: 0.35; }

.stepper .num {
  width: 44px;
  text-align: center;
  font-weight: 800;
  font-size: 17px;
}

/* ---------- Tables ---------- */

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.tbl th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  padding: 7px 6px;
  border-bottom: 2px solid var(--line);
}

.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--line); }

/* ---------- Activity feed ---------- */

.feed-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  align-items: flex-start;
}

.feed-item:last-child { border-bottom: 0; }

.feed-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-light);
  margin-top: 5px;
  flex-shrink: 0;
}

.feed-dot.green { background: var(--green); }
.feed-dot.red { background: var(--red); }
.feed-dot.gold { background: var(--accent); }

.feed-item .when { color: var(--ink-soft); font-size: 11.5px; }

/* ---------- Loans ---------- */

.loan-card { border-left: 5px solid var(--brand-light); }
.loan-card.overdue { border-left-color: var(--red); background: #FFF7F6; }
.loan-card.paid { border-left-color: var(--green); }

.loan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin: 8px 0;
  font-size: 13.5px;
}

.loan-grid .k { color: var(--ink-soft); font-size: 12px; }
.loan-grid .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.loan-grid .v.red { color: var(--red); }
.loan-grid .v.green { color: var(--green); }

.progress {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin: 6px 0 10px;
}

.progress > div { height: 100%; background: var(--green); border-radius: 4px; }

/* ---------- Chart ---------- */

.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

/* ---------- Premium / upgrade ---------- */

.premium-hero {
  background: linear-gradient(135deg, #7A4BAE 0%, #46206A 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 12px;
}

.premium-hero .price { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.premium-hero .per { font-size: 13px; opacity: 0.85; }

.feature-list { list-style: none; padding: 0; margin: 0; }

.feature-list li {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
  align-items: flex-start;
}

.feature-list li:last-child { border-bottom: 0; }
.feature-list .tick { color: var(--green); font-weight: 800; flex-shrink: 0; }

.pay-box {
  background: var(--amber-pale);
  border: 1.5px dashed var(--amber);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
  font-size: 14px;
}

.pay-box .lipa {
  font-size: 22px;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: 1px;
}

/* ---------- Settings ---------- */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}

.settings-row:last-child { border-bottom: 0; }
.settings-row .lbl { font-weight: 600; font-size: 14.5px; }
.settings-row .sub { font-size: 12px; color: var(--ink-soft); }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(34, 24, 46, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: slide-up 0.22s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h3 { margin: 0; font-size: 17px; color: var(--brand-dark); }

.modal-close {
  background: var(--brand-pale);
  border: 0;
  color: var(--brand-dark);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 90%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); }

/* ---------- Empty states ---------- */

.empty {
  text-align: center;
  padding: 34px 18px;
  color: var(--ink-soft);
}

.empty .big-icon { font-size: 44px; margin-bottom: 8px; }

/* ---------- Statement / print ---------- */

#print-area { display: none; }

.statement { font-size: 13.5px; color: #111; }
.statement h1 { font-size: 20px; margin: 0 0 2px; }
.statement h2 { font-size: 15px; margin: 14px 0 6px; border-bottom: 1px solid #999; padding-bottom: 3px; }
.statement .meta { color: #444; font-size: 12px; margin-bottom: 10px; }
.statement table { width: 100%; border-collapse: collapse; }
.statement th, .statement td { border: 1px solid #bbb; padding: 5px 7px; text-align: left; font-size: 12px; }
.statement th { background: #eee; }
.statement .num { text-align: right; }
.statement .sig { display: flex; gap: 40px; margin-top: 40px; }
.statement .sig div { flex: 1; border-top: 1px solid #333; padding-top: 4px; font-size: 11px; }

@media print {
  body.printing > #app-header,
  body.printing > #view,
  body.printing > #tabbar,
  body.printing > #modal-root,
  body.printing > #toast-root { display: none !important; }
  body.printing > #print-area { display: block !important; }
  body { background: #fff; }
}

/* ---------- Desktop tweaks ---------- */

@media (min-width: 700px) {
  body { background: #ECE6F2; }
  .container { padding-top: 20px; }
  #tabbar { border-top: 0; }
  .tabbar-inner {
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 14px 14px 0 0;
    background: #fff;
    box-shadow: 0 -2px 10px rgba(34, 24, 46, 0.08);
  }
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}
