/* === DESIGN TOKENS === */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1f2a40;
  --bg-input: #0f1629;
  --border: #2a3550;
  --border-focus: #6366f1;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,0.3);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --yellow: #eab308;
  --yellow-bg: rgba(234,179,8,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --gradient: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: 'Inter', -apple-system, sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 64px;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* === PAGES === */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.625rem 1.25rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.875rem; border: none; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.btn-primary { background: var(--accent); color: white; box-shadow: 0 0 20px var(--accent-glow); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 30px var(--accent-glow); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--text-primary); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.85rem 1.75rem; font-size: 1rem; }
.btn-icon { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.25rem; font-size: 1rem; transition: color 0.2s; }
.btn-icon:hover { color: var(--red); }

/* === LANDING PAGE === */
.landing-nav { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 2rem; max-width: 1200px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.25rem; }
.logo-icon { width: 36px; height: 36px; background: var(--gradient); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }

.hero { text-align: center; padding: 5rem 2rem 4rem; max-width: 800px; margin: 0 auto; }
.hero-badge { display: inline-block; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 0.4rem 1.2rem; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 2rem; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); font-weight: 800; line-height: 1.15; margin-bottom: 1.5rem; letter-spacing: -0.02em; }
.gradient-text { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { font-size: 1.15rem; color: var(--text-secondary); max-width: 560px; margin: 0 auto 2.5rem; line-height: 1.7; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 3.5rem; }
.hero-stats { display: flex; justify-content: center; gap: 2rem; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-val { font-size: 1.5rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-divider { width: 1px; background: var(--border); }

.features { padding: 5rem 2rem; max-width: 1100px; margin: 0 auto; }
.features h2 { text-align: center; font-size: 2rem; margin-bottom: 3rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; transition: all 0.3s; }
.feature-card:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 8px 30px rgba(99,102,241,0.1); }
.feature-icon { font-size: 2rem; margin-bottom: 1rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-secondary); font-size: 0.9rem; }

.cta-section { text-align: center; padding: 5rem 2rem; background: linear-gradient(180deg, transparent, rgba(99,102,241,0.05)); }
.cta-section h2 { font-size: 1.8rem; margin-bottom: 1rem; }
.cta-section p { color: var(--text-secondary); margin-bottom: 2rem; max-width: 500px; margin-left: auto; margin-right: auto; }
.landing-footer { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--border); }

/* === APP LAYOUT === */
#app-page { display: none; }
#app-page.active { display: flex; }

.sidebar { width: var(--sidebar-w); height: 100vh; position: fixed; left: 0; top: 0; background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s; }
.sidebar-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }
.sidebar-nav { flex: 1; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm); background: none; border: none; color: var(--text-secondary); font-size: 0.9rem; cursor: pointer; transition: all 0.2s; width: 100%; text-align: left; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(99,102,241,0.1); color: var(--accent); font-weight: 600; }
.nav-icon { font-size: 1.1rem; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: 0 2rem; border-bottom: 1px solid var(--border); background: var(--bg-secondary); position: sticky; top: 0; z-index: 50; }
.topbar h2 { flex: 1; font-size: 1.15rem; }
.hamburger { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; }

/* === VIEWS === */
.view { display: none; padding: 2rem; max-width: 1000px; animation: fadeIn 0.3s; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* === CARDS === */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.75rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }
.card-title { font-size: 1.2rem; margin-bottom: 0.5rem; }
.card-desc { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* === DATA WARNING === */
.data-warning { display: flex; gap: 0.75rem; align-items: flex-start; background: rgba(234,179,8,0.08); border: 1px solid rgba(234,179,8,0.25); border-radius: var(--radius-sm); padding: 1rem 1.25rem; margin-bottom: 1.5rem; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; }
.data-warning-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 0.1rem; }
.data-warning strong { color: var(--yellow); }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-family: inherit; font-size: 0.85rem; font-weight: 600; padding: 0; text-decoration: underline; transition: color 0.2s; }
.btn-link:hover { color: var(--accent-hover); }

/* === STATS GRID === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.stat-card-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card-value { font-size: 1.75rem; font-weight: 800; }
.stat-card.accent .stat-card-value { color: var(--accent); }
.stat-card.warn .stat-card-value { color: var(--yellow); }

/* === FORMS === */
.form-section { margin-bottom: 2rem; }
.form-section h4 { font-size: 0.95rem; color: var(--text-secondary); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); }
input, select, textarea { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 1rem; color: var(--text-primary); font-size: 0.9rem; transition: border-color 0.2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { resize: vertical; }
select { cursor: pointer; }

/* === INVOICE ITEMS === */
.item-row { display: grid; grid-template-columns: 1fr 80px 120px 100px 40px; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.item-total { font-weight: 600; text-align: right; font-size: 0.9rem; }
.invoice-summary { margin: 1.5rem 0; padding: 1.25rem; background: var(--bg-input); border-radius: var(--radius-sm); }
.summary-row { display: flex; justify-content: space-between; }
.summary-row.total { font-size: 1.25rem; font-weight: 700; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* === INVOICE LIST === */
.invoice-list { display: flex; flex-direction: column; gap: 0.5rem; }
.invoice-row { display: grid; grid-template-columns: 1fr 1fr auto auto auto; gap: 1rem; align-items: center; padding: 1rem 1.25rem; background: var(--bg-input); border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: all 0.2s; }
.invoice-row:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.invoice-id { font-weight: 600; font-size: 0.9rem; }
.invoice-client { color: var(--text-secondary); font-size: 0.85rem; }
.invoice-amount { font-weight: 700; text-align: right; }
.status-badge { display: inline-flex; padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.status-pending { background: var(--yellow-bg); color: var(--yellow); }
.status-paid { background: var(--green-bg); color: var(--green); }
.status-overdue { background: var(--red-bg); color: var(--red); }

.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { margin-bottom: 0.5rem; }
.empty-state p { color: var(--text-secondary); margin-bottom: 1.5rem; }

/* === FILTER === */
.filter-group { display: flex; gap: 0.25rem; }
.filter-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.8rem; cursor: pointer; transition: all 0.2s; }
.filter-btn.active, .filter-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* === PAYMENT PAGE === */
.payment-container { max-width: 600px; margin: 0 auto; padding: 2rem 1rem; }
.payment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.payment-badge { padding: 0.35rem 1rem; background: var(--yellow-bg); color: var(--yellow); border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.payment-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.payment-from { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--text-secondary); }
.payment-to { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border); }
.payment-to h2 { font-size: 1.3rem; }
.pay-client { color: var(--text-secondary); margin-top: 0.25rem; }
.pay-items { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border); }
.pay-item { display: flex; justify-content: space-between; padding: 0.5rem 0; font-size: 0.9rem; }
.pay-item-desc { color: var(--text-secondary); }
.pay-total-row { display: flex; justify-content: space-between; padding: 1.25rem 2rem; background: var(--bg-input); font-size: 1.3rem; font-weight: 800; }
.pay-instructions { padding: 2rem; text-align: center; }
.pay-instructions h3 { margin-bottom: 1rem; }
.pay-chain-info { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1rem; }
.chain-badge, .token-badge { padding: 0.3rem 0.8rem; background: rgba(99,102,241,0.1); color: var(--accent); border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.wallet-display { display: flex; align-items: center; gap: 0.5rem; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 1rem 0; word-break: break-all; }
.wallet-display code { flex: 1; font-size: 0.82rem; color: var(--text-primary); }
.qr-container { display: flex; justify-content: center; margin: 1.5rem 0; }
.qr-container canvas { border-radius: var(--radius-sm); border: 4px solid white; }
.pay-note { color: var(--text-muted); font-size: 0.85rem; font-style: italic; margin-top: 1rem; }
.pay-footer { padding: 1.25rem 2rem; border-top: 1px solid var(--border); text-align: center; font-size: 0.8rem; color: var(--text-muted); }
.pay-disclaimer { font-size: 0.7rem; margin-top: 0.5rem; }
.verify-notice { display: flex; gap: 0.65rem; align-items: flex-start; background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25); border-radius: var(--radius-sm); padding: 0.85rem 1rem; margin: 1.25rem 0 0.5rem; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.55; text-align: left; }
.verify-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }
.verify-notice strong { color: var(--green); }

/* === LEGAL DISCLAIMER === */
.legal-disclaimer { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.75rem; max-width: 600px; margin-left: auto; margin-right: auto; line-height: 1.5; opacity: 0.7; }
.footer-links { margin-top: 1rem; }
.footer-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.8rem; font-family: inherit; text-decoration: underline; opacity: 0.8; }
.footer-link:hover { opacity: 1; }
.legal-section { max-width: 700px; margin: 1.5rem auto 0; text-align: left; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.legal-block { margin-bottom: 1.5rem; }
.legal-block:last-child { margin-bottom: 0; }
.legal-block h4 { font-size: 1rem; margin-bottom: 0.75rem; color: var(--text-primary); }
.legal-block p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6; margin-bottom: 0.5rem; }
.legal-block ul { list-style: none; padding: 0; }
.legal-block li { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.6; padding: 0.3rem 0 0.3rem 1rem; border-left: 2px solid var(--border); margin-bottom: 0.4rem; }

/* === TOAST === */
.toast { position: fixed; bottom: 2rem; right: 2rem; padding: 0.85rem 1.5rem; background: var(--bg-card); border: 1px solid var(--green); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 0.9rem; transform: translateY(120%); opacity: 0; transition: all 0.3s; z-index: 999; box-shadow: var(--shadow); }
.toast.show { transform: translateY(0); opacity: 1; }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; animation: fadeIn 0.2s; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .hamburger { display: block; }
  .main-content { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .view { padding: 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 60px 90px 70px 32px; gap: 0.5rem; font-size: 0.85rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .invoice-row { grid-template-columns: 1fr auto; gap: 0.5rem; }
  .invoice-row .invoice-client, .invoice-row .invoice-date { display: none; }
  .hero { padding: 3rem 1.25rem 2.5rem; }
  .hero h1 { font-size: 2rem; }
  .features { padding: 3rem 1.25rem; }
  .features-grid { grid-template-columns: 1fr; }
  .payment-container { padding: 1rem 0.5rem; }
}
