/* ===========================================================================
   SoloCare — Mobile-first design system
   High contrast, large touch targets, card-based layouts
   =========================================================================== */

:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light: #dbeafe;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --violet: #7c3aed;
  --violet-dark: #6d28d9;
  --violet-light: #ede9fe;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --white: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 640px; margin: 0 auto; padding-bottom: 96px; }

/* ---------- App shell / header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.app-header .brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: none; color: #fff;
  display: grid; place-items: center; font-size: 18px;
}
.app-header .brand img.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: none;
  padding: 0;
  display: block;
  object-fit: contain;
}
.app-header .profile-chip {
  background: var(--gray-100); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--gray-700);
}

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: var(--white); border-top: 1px solid var(--gray-200);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
.bottom-nav button {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; font-size: 11px; font-weight: 600; color: var(--gray-500);
  border-radius: 12px; min-height: 52px;
}
.bottom-nav button.active { color: var(--green); }
.bottom-nav button svg { width: 24px; height: 24px; }

/* ---------- Icon sizing (all inline SVG icons) ---------- */
.section-title svg { width: 18px; height: 18px; }
.primary-cta svg { width: 20px; height: 20px; }
.action-banner .icon svg { width: 22px; height: 22px; }
.btn svg { width: 18px; height: 18px; }
.btn-sm svg, .btn-xs svg { width: 14px; height: 14px; }
.app-header .logo svg { width: 20px; height: 20px; }
.app-header .profile-chip svg { width: 16px; height: 16px; }
.hero-card .label svg { width: 14px; height: 14px; }
.empty .icon svg { width: 32px; height: 32px; }
.sheet .sheet-header svg { width: 20px; height: 20px; }

/* ---------- Layout / sections ---------- */
.section { padding: 16px; }
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.section-title .count {
  background: var(--gray-200); color: var(--gray-700);
  border-radius: 999px; padding: 2px 8px; font-size: 12px;
}

/* ---------- Dashboard hero ---------- */
.hero { padding: 16px 16px 8px; }
.hero .greeting { font-size: 14px; color: var(--gray-500); font-weight: 600; margin-bottom: 2px; }
.hero .greeting-name { font-size: 22px; font-weight: 800; margin-bottom: 14px; }

.hero-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero-card {
  border-radius: var(--radius); padding: 12px; color: #fff;
  box-shadow: var(--shadow); min-height: 96px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0;
}
.hero-card.green { background: linear-gradient(135deg, var(--green), var(--green-dark)); }
.hero-card.blue { background: linear-gradient(135deg, var(--blue), var(--blue-dark)); }
.hero-card .label { font-size: 11px; font-weight: 600; opacity: 0.9; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-card .value { font-size: 21px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-card .sub { font-size: 10px; opacity: 0.85; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) {
  .hero-card { padding: 10px; min-height: 88px; }
  .hero-card .value { font-size: 18px; }
  .hero-card .label { font-size: 10px; }
  .hero-card .sub { font-size: 9px; }
}

/* ---------- Action banner ---------- */
.action-banner {
  margin: 12px 16px; border-radius: var(--radius);
  background: var(--amber-light); border: 2px solid var(--amber);
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.action-banner .icon { font-size: 24px; }
.action-banner .text { flex: 1; }
.action-banner .text .title { font-weight: 800; color: var(--amber); font-size: 15px; }
.action-banner .text .desc { font-size: 13px; color: var(--gray-700); }
.action-banner button {
  background: var(--amber); color: #fff; border: none; border-radius: 10px;
  padding: 10px 14px; font-weight: 700; font-size: 13px; min-height: 44px; cursor: pointer;
}
.action-banner.super { background: var(--violet-light); border-color: var(--violet); }
.action-banner.super .text .title { color: var(--violet); }
.action-banner.super button { background: var(--violet); }

/* ---------- Primary CTA ---------- */
.primary-cta {
  margin: 0 16px 16px;
  background: var(--green); color: #fff; border: none;
  border-radius: 14px; padding: 16px; width: calc(100% - 32px);
  font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px;
}
.primary-cta:active { transform: scale(0.98); }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-row .left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-row .left .avatar {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--gray-100); display: grid; place-items: center; color: var(--gray-500);
}
.card-row .left .avatar svg { width: 22px; height: 22px; }
.card-row .left .avatar-sm {
  width: 32px; height: 32px; border-radius: 8px;
}
.card-row .left .avatar-sm svg { width: 17px; height: 17px; }
.card-row .title { font-weight: 700; font-size: 15px; }
.card-row .subtitle { font-size: 12px; color: var(--gray-500); }
.card-row .amount { font-weight: 800; font-size: 16px; }

/* ---------- Clickable cards ---------- */
.card-link { cursor: pointer; }
.card-link:active { transform: scale(0.99); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.badge.draft { background: var(--gray-100); color: var(--gray-700); }
.badge.sent { background: var(--blue-light); color: var(--blue-dark); }
.badge.paid { background: var(--green-light); color: var(--green-dark); }
.badge.overdue { background: var(--red-light); color: var(--red); }
.badge.valid { background: var(--green-light); color: var(--green-dark); }
.badge.expiring { background: var(--amber-light); color: var(--amber); }
.badge.expired { background: var(--red-light); color: var(--red); }

.badge.km { background: var(--green-light); color: var(--green-dark); }
.badge.admin { background: var(--blue-light); color: var(--blue-dark); }

/* ---------- Breakdown card (Module 2) ---------- */
.breakdown { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.breakdown .total { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.breakdown .line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--gray-200); font-size: 14px; }
.breakdown .line .amt { font-weight: 700; }
.breakdown .line.ato .amt { color: var(--red); }
.breakdown .line.tax .amt { color: var(--amber); }
.breakdown .line.net { border-bottom: none; font-weight: 800; font-size: 16px; }
.breakdown .line.net .amt { color: var(--green-dark); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; padding: 14px; border: 1.5px solid var(--gray-200);
  border-radius: 12px; font-size: 16px; font-family: inherit;
  background: var(--white); color: var(--gray-900); min-height: 52px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--green); }
.form-group .hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 12px; padding: 14px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer; min-height: 48px;
  width: 100%;
}
.btn-green { background: var(--green); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-outline { background: var(--white); color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 13px; min-height: 40px; width: auto; }
.btn-xs { padding: 5px 9px; font-size: 12px; min-height: 30px; border-radius: 9px; width: auto; }

/* ---------- Modal / sheet ---------- */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-overlay.open { display: flex; }
.sheet {
  background: var(--white); width: 100%; max-width: 640px;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.sheet .sheet-header h2 { font-size: 18px; font-weight: 800; }
.sheet .close-btn {
  background: var(--gray-100); border: none; border-radius: 10px;
  width: 40px; height: 40px; font-size: 20px; cursor: pointer; color: var(--gray-700);
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 32px 16px; color: var(--gray-500);
}
.empty .icon { font-size: 40px; margin-bottom: 8px; }
.empty .title { font-weight: 700; color: var(--gray-700); font-size: 15px; }
.empty .desc { font-size: 13px; }

/* ---------- BAS summary ---------- */
.bas-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.bas-card .bas-field { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.bas-card .bas-field .code { font-weight: 800; color: var(--blue-dark); background: var(--blue-light); border-radius: 8px; padding: 2px 8px; font-size: 12px; }
.bas-card .bas-field .name { font-size: 14px; color: var(--gray-700); }
.bas-card .bas-field .val { font-weight: 700; }
.bas-card .bas-net { display: flex; justify-content: space-between; align-items: center; padding: 14px 0 0; }
.bas-card .bas-net .val { font-size: 20px; font-weight: 800; }
.bas-card .bas-net.pay .val { color: var(--red); }
.bas-card .bas-net.refund .val { color: var(--green-dark); }

/* ---------- BAS due date / period ---------- */
.bas-due {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--gray-100);
  font-size: 13px;
}
.bas-due.overdue { color: var(--red); }

/* ---------- Invoice PDF preview ---------- */
.pdf-preview { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 12px; font-size: 13px; }
.pdf-preview .tax-invoice { font-size: 22px; font-weight: 800; color: var(--gray-900); letter-spacing: 1px; margin-bottom: 4px; }
.pdf-preview .abn { font-size: 12px; color: var(--gray-500); margin-bottom: 16px; }
.pdf-preview .pdf-row { display: flex; justify-content: space-between; padding: 4px 0; }
.pdf-preview .pdf-row.bold { font-weight: 700; }
.pdf-preview .pdf-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.pdf-preview .pdf-table th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--gray-500); border-bottom: 2px solid var(--gray-200); padding: 6px 4px; }
.pdf-preview .pdf-table td { padding: 8px 4px; border-bottom: 1px solid var(--gray-100); }
.pdf-preview .pdf-table td.num, .pdf-preview .pdf-table th.num { text-align: right; }

/* ---------- Misc ---------- */
.muted { color: var(--gray-500); }
.divider { height: 1px; background: var(--gray-200); margin: 12px 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.text-center { text-align: center; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }

/* ---------- Tooltips (help for new users) ---------- */
.tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 999px; flex-shrink: 0;
  background: var(--gray-200); color: var(--gray-700);
  font-size: 12px; font-weight: 800; cursor: help; line-height: 1;
  vertical-align: middle; margin-left: 4px;
}
.tip svg { width: 12px; height: 12px; }
.tip .tip-bubble {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.45;
  padding: 10px 12px; border-radius: 10px; width: 220px; max-width: 80vw;
  opacity: 0; visibility: hidden; transition: opacity 0.15s ease; z-index: 120;
  box-shadow: 0 6px 20px rgba(15,23,42,0.25); text-align: left;
}
.tip .tip-bubble::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--gray-900);
}
.tip:hover .tip-bubble, .tip:focus .tip-bubble { opacity: 1; visibility: visible; }
.tip:focus { outline: none; }
/* Keep tooltips on small screens inside the viewport */
@media (max-width: 380px) { .tip .tip-bubble { width: 190px; } }

/* ---------- Help page ---------- */
.help-card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.help-card h3 { font-size: 15px; font-weight: 800; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.help-card p, .help-card li { font-size: 13px; color: var(--gray-700); line-height: 1.55; }
.help-card ul { padding-left: 18px; margin-top: 6px; }
.help-card ol { padding-left: 18px; margin-top: 6px; }
.help-card li { margin-bottom: 4px; }
.help-card .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 999px; flex-shrink: 0;
  background: var(--green-light); color: var(--green-dark); font-weight: 800; font-size: 13px;
}

/* SOLOCARE_AUTH_V1 — login + logout */
.app-header .header-right { display: flex; align-items: center; gap: 8px; }
.btn-logout {
  border: 1px solid var(--gray-200, #e5e7eb);
  background: #fff;
  color: var(--gray-600, #4b5563);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-logout:hover { background: var(--gray-50, #f9fafb); color: var(--red, #dc2626); border-color: #fecaca; }
.btn-logout-full {
  width: 100%;
  border: 1px solid #fecaca;
  background: #fff;
  color: var(--red, #dc2626);
  font-weight: 700;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
}
.btn-logout-full:hover { background: #fef2f2; }
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #f0fdf4 0%, #f8fafc 60%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
  padding: 32px 28px 28px;
  text-align: center;
}
.login-logo { border-radius: 16px; margin-bottom: 12px; }
.login-card h1 { margin: 0; font-size: 24px; font-weight: 800; color: #0f172a; }
.login-sub { margin: 6px 0 20px; color: #64748b; font-size: 14px; }
.login-form { text-align: left; }
.login-form .form-group { margin-bottom: 14px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.login-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-size: 16px;
}
.login-btn { width: 100%; margin-top: 8px; padding: 14px; font-size: 16px; border-radius: 12px; border: none; cursor: pointer; }
.login-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 10px;
}
.login-msg {
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
