/* ═══════════════════════════════════════════════════════════
   LENTISCO — Design System
   Dark ocean theme, mobile-first
═══════════════════════════════════════════════════════════ */

/* ── Google Fonts fallback già incluso via HTML ── */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
  --bg:           #080f1e;
  --bg-1:         #0d1b2e;
  --bg-2:         #112038;
  --surface:      #162540;
  --surface-2:    #1c2f4f;
  --border:       rgba(14, 165, 233, 0.15);
  --border-hover: rgba(14, 165, 233, 0.35);

  --primary:      #0ea5e9;
  --primary-dark: #0284c7;
  --primary-glow: rgba(14, 165, 233, 0.25);
  --accent:       #f59e0b;
  --accent-glow:  rgba(245, 158, 11, 0.2);
  --success:      #10b981;
  --success-bg:   rgba(16, 185, 129, 0.12);
  --danger:       #ef4444;
  --danger-bg:    rgba(239, 68, 68, 0.12);
  --warning:      #f59e0b;
  --warning-bg:   rgba(245, 158, 11, 0.12);

  --text:         #f1f5f9;
  --text-2:       #94a3b8;
  --text-3:       #475569;

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;
  --radius-xl:    24px;

  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.3);
  --shadow-glow:  0 0 24px rgba(14, 165, 233, 0.2);

  --nav-height:   68px;
  --header-height: 60px;
  --transition:   0.2s ease;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img, svg { display: block; }

/* ── Splash Screen ──────────────────────────────────────── */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--bg);
  z-index: 9999;
  transition: opacity 0.4s ease;
}
.splash.hiding { opacity: 0; pointer-events: none; }
.splash-logo {
  animation: pulse-glow 2s ease-in-out infinite;
}
.splash-title {
  font-size: 1.6rem; font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(14,165,233,0.4)); }
  50% { filter: drop-shadow(0 0 20px rgba(14,165,233,0.8)); }
}

/* ── Page Container ─────────────────────────────────────── */
.page-container {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

/* ── App Header ─────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-height);
  background: rgba(8, 15, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
}
.app-header-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.app-header-title {
  font-weight: 600; font-size: 1rem; color: var(--text);
  flex: 1;
}
.app-header-action {
  margin-left: auto;
}

/* ── Bottom Navigation ──────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(13, 27, 46, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; align-items: flex-start;
  z-index: 200;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; padding: 10px 4px;
  color: var(--text-3);
  transition: color var(--transition);
  position: relative;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 0.65rem; font-weight: 500; }
.nav-item.active { color: var(--primary); }
.nav-item.active::before {
  content: '';
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  width: 32px; height: 2px;
  background: var(--primary);
  border-radius: 0 0 2px 2px;
}
.nav-item:active { opacity: 0.7; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-glass {
  background: rgba(22, 37, 64, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 24px;
  font-size: 0.9rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  transition: all var(--transition);
  white-space: nowrap; cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon {
  padding: 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2);
  max-width: 36px;
}
.brn-icon svg{
  margin:0 auto;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-hover); }
.btn-sm { padding: 8px 16px; font-size: 0.8rem; }
.btn-lg { padding: 16px 32px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* Floating action button */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  right: 20px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px var(--primary-glow);
  font-size: 1.5rem; cursor: pointer;
  transition: all var(--transition);
  z-index: 150;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px var(--primary-glow); }
.fab:active { transform: scale(0.95); }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 0.8rem; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em;
}
.form-input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  color: var(--text); font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-input::placeholder { color: var(--text-3); }
.form-input.error { border-color: var(--danger); }
select.form-input { appearance: none; cursor: pointer; }
.form-hint { font-size: 0.75rem; color: var(--text-3); }
.form-error { font-size: 0.78rem; color: var(--danger); }

/* ── Progress Bar ───────────────────────────────────────── */
.progress-wrap {
  background: var(--bg-1);
  border-radius: 999px; height: 8px; overflow: hidden;
}
.progress-bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  position: relative;
}
.progress-bar.full {
  background: linear-gradient(90deg, var(--success), #34d399);
}
.progress-bar.over {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

/* ── Stat / Summary Cards ───────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-label {
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.2rem; font-weight: 800;
  letter-spacing: -0.02em;
}
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }

/* ── Expense Item Card ──────────────────────────────────── */
.expense-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color var(--transition);
}
.expense-card:hover { border-color: var(--border-hover); }
.expense-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.expense-name {
  font-weight: 700; font-size: 1rem; color: var(--text);
}
.expense-total {
  font-size: 0.9rem; color: var(--text-2); font-weight: 500;
}
.expense-stats {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  font-size: 0.8rem;
}
.expense-paid { color: var(--success); font-weight: 600; }
.expense-remaining { color: var(--accent); font-weight: 600; }

/* ── Payment List ───────────────────────────────────────── */
.payment-list { display: flex; flex-direction: column; gap: 10px; }
.payment-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  transition: border-color var(--transition);
}
.payment-item:hover { border-color: var(--border-hover); }
.payment-icon {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--primary-glow);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
  font-size: 1.1rem; font-weight: 700;
}
.payment-info { flex: 1; min-width: 0; }
.payment-name { font-weight: 600; font-size: 0.9rem; }
.payment-meta { font-size: 0.75rem; color: var(--text-2); margin-top: 2px; }
.payment-amount {
  font-weight: 700; font-size: 1rem;
  color: var(--success); white-space: nowrap;
}
.payment-actions { display: flex; gap: 6px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.badge-admin   { background: rgba(245,158,11,0.15); color: var(--accent); }
.badge-reader  { background: var(--primary-glow); color: var(--primary); }
.badge-viewer  { background: var(--surface-2); color: var(--text-2); }
.badge-active  { background: var(--success-bg); color: var(--success); }
.badge-inactive{ background: var(--danger-bg); color: var(--danger); }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex; background: var(--surface);
  border-radius: var(--radius); padding: 4px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1; padding: 10px 8px;
  font-size: 0.8rem; font-weight: 600;
  text-align: center; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
  color: var(--text-2); border: none; background: none;
}
.tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ── Divider ────────────────────────────────────────────── */
.divider {
  height: 1px; background: var(--border); margin: 20px 0;
}
.divider-text {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-3); font-size: 0.8rem;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9000; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.88rem; font-weight: 500;
  max-width: 320px;
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.hiding { animation: toast-out 0.3s ease forwards; }
@keyframes toast-in {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
  animation: modal-bg-in 0.2s ease;
}
@media (min-width: 480px) {
  .modal-overlay { align-items: center; justify-content: center; }
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  width: 100%; max-height: 90dvh; overflow-y: auto;
  animation: modal-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@media (min-width: 480px) {
  .modal-box {
    border-radius: var(--radius-xl);
    max-width: 440px;
    padding: 28px;
  }
}
.modal-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border-hover); margin: 0 auto 20px;
}
.modal-title {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 20px;
}
@keyframes modal-bg-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── Section Layouts ────────────────────────────────────── */
.page-content { padding: 16px 16px 0; display: flex; flex-direction: column; gap: 16px; }
.section-title {
  font-size: 0.72rem; font-weight: 700;
  color: var(--text-2); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 12px;
}

/* ── Auth / Setup Pages ─────────────────────────────────── */
.auth-page {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 20px;
  background: radial-gradient(ellipse at top, rgba(14,165,233,0.08) 0%, transparent 60%), var(--bg);
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; margin-bottom: 36px;
}
.auth-logo-title {
  font-size: 2rem; font-weight: 800; letter-spacing: 0.05em;
  background: linear-gradient(135deg, #0ea5e9, #38bdf8, #7dd3fc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-logo-sub {
  font-size: 0.85rem; color: var(--text-2); text-align: center;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  box-shadow: var(--shadow), var(--shadow-glow);
  display: flex; flex-direction: column; gap: 20px;
}
.auth-title {
  font-size: 1.2rem; font-weight: 700; text-align: center;
  margin-bottom: -4px;
}

/* ── Setup Wizard Steps ─────────────────────────────────── */
.setup-step-indicator {
  display: flex; align-items: center; gap: 8px;
  justify-content: center; margin-bottom: 8px;
}
.setup-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
  transition: background var(--transition);
}
.setup-dot.active { background: var(--primary); }

/* ── Dashboard totals strip ─────────────────────────────── */
.totals-strip {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* ── Cycle selector ─────────────────────────────────────── */
.cycle-selector {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 14px;
  cursor: pointer; transition: border-color var(--transition);
}
.cycle-selector:hover { border-color: var(--border-hover); }
.cycle-selector-name { font-weight: 600; font-size: 0.9rem; }
.cycle-selector svg { color: var(--text-2); width: 16px; height: 16px; }
.cycle-active-pill {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  background: var(--success-bg); color: var(--success);
  padding: 2px 8px; border-radius: 999px;
}

/* ── Users list ─────────────────────────────────────────── */
.user-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}
.user-item:hover { border-color: var(--border-hover); }
.user-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; color: white;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-username { font-size: 0.75rem; color: var(--text-2); }

/* ── Biometric button ───────────────────────────────────── */
.btn-biometric {
  background: linear-gradient(135deg, rgba(14,165,233,0.1), rgba(56,189,248,0.1));
  border: 1px solid var(--border-hover);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 14px 24px;
  border-radius: var(--radius);
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer; width: 100%;
  transition: all var(--transition);
}
.btn-biometric:hover {
  background: linear-gradient(135deg, rgba(14,165,233,0.18), rgba(56,189,248,0.18));
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}
.btn-biometric svg { width: 22px; height: 22px; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; gap: 12px;
  color: var(--text-2); text-align: center;
}
.empty-state svg { opacity: 0.3; width: 48px; height: 48px; }
.empty-state p { font-size: 0.9rem; }

/* ── Skeleton loader ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

/* ── Utilities ──────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 0.85rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-2); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.sr-only { position: absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.mb-12{margin-bottom: 12px;}