/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #0070f3;
  --blue-dark: #0051cc;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --grey: #6b7280;
  --grey-light: #f3f4f6;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: #fff;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 2.5rem; line-height: 1.2; font-weight: 800; }
h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 1.5rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: .4rem; }
p  { color: var(--text-muted); margin-bottom: .75rem; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn, button[type="submit"], button.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .65rem 1.4rem;
  font-size: .95rem; font-weight: 600;
  border: none; border-radius: var(--radius);
  cursor: pointer; transition: background .15s;
  background: var(--blue); color: #fff;
  text-decoration: none;
}
.btn:hover, button[type="submit"]:hover { background: var(--blue-dark); }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; font-weight: 600;
  border: none; border-radius: 6px; cursor: pointer; transition: background .15s; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-ghost   { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--grey-light); }
.btn-outline { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover { background: #eff6ff; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: var(--text); }
.form-input, .form-textarea, .form-select, input[type="text"], input[type="email"], input[type="date"], input[type="number"] {
  width: 100%; padding: .55rem .75rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; font-family: inherit; color: var(--text);
  background: #fff; transition: border-color .15s;
}
.form-input:focus, .form-textarea:focus, input[type="text"]:focus,
input[type="email"]:focus, input[type="date"]:focus, input[type="number"]:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,112,243,.12);
}
textarea.form-textarea { resize: vertical; min-height: 120px; }

/* ── Toast / error banner ─────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: .7rem 1.4rem;
  border-radius: 999px; font-size: .9rem; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 1000; white-space: nowrap;
}
.error-banner {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: .65rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  font-size: .9rem;
}
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════
   LANDING PAGE
   ══════════════════════════════════════════════════════════════════════════ */

/* Hero */
.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: #fff; padding: 5rem 1.5rem 4rem;
  text-align: center;
}
.hero-inner { max-width: 640px; margin: 0 auto; }
.logo-mark {
  display: inline-block; font-size: .9rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: #93c5fd; margin-bottom: 1.5rem;
}
.hero h1 { color: #fff; font-size: clamp(2rem, 5vw, 3.2rem); }
.hero-sub { font-size: 1.1rem; color: #cbd5e1; margin: 1.25rem auto 2rem; max-width: 520px; }
.hero-form { display: flex; gap: .5rem; max-width: 440px; margin: 0 auto; }
.hero-form input { flex: 1; background: rgba(255,255,255,.1); border: 1.5px solid rgba(255,255,255,.25); color: #fff; }
.hero-form input::placeholder { color: rgba(255,255,255,.5); }
.hero-form input:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(147,197,253,.2); }
.hero-form button { white-space: nowrap; flex-shrink: 0; }
.hero-note { font-size: .8rem; color: #94a3b8; margin-top: .75rem; }

/* Steps */
.steps-section { max-width: 900px; margin: 0 auto; padding: 4rem 1.5rem; text-align: center; }
.steps { display: flex; align-items: flex-start; justify-content: center; gap: 0; flex-wrap: wrap; }
.step { flex: 1; min-width: 200px; max-width: 260px; padding: 0 1rem; }
.step-num {
  display: inline-flex; width: 2.5rem; height: 2.5rem; align-items: center; justify-content: center;
  background: var(--blue); color: #fff; border-radius: 50%;
  font-weight: 700; font-size: 1rem; margin-bottom: .75rem;
}
.step h3 { color: var(--text); }
.step-arrow { font-size: 1.4rem; color: #d1d5db; padding-top: .8rem; flex-shrink: 0; align-self: center; }

/* Features */
.features-section { background: var(--grey-light); padding: 4rem 1.5rem; text-align: center; }
.features-section h2 { text-align: center; }
.features-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem; max-width: 900px; margin: 0 auto;
}
.feature-card { background: #fff; border-radius: 12px; padding: 1.5rem; text-align: left; box-shadow: var(--shadow); }
.feature-icon { font-size: 1.6rem; margin-bottom: .5rem; }

/* Pricing */
.pricing-section { padding: 4rem 1.5rem; text-align: center; }
.pricing-card {
  display: inline-block; border: 2.5px solid var(--blue); border-radius: 16px;
  padding: 2rem 2.5rem; text-align: center; min-width: 320px;
  box-shadow: var(--shadow-md);
}
.pricing-badge {
  display: inline-block; background: #eff6ff; color: var(--blue);
  font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .25rem .7rem; border-radius: 999px; margin-bottom: .75rem;
}
.price { font-size: 3rem; font-weight: 800; color: var(--text); margin: .5rem 0; }
.price-period { font-size: 1.1rem; font-weight: 400; color: var(--text-muted); }
.pricing-features { list-style: none; text-align: left; margin: 1rem 0 1.5rem; }
.pricing-features li { padding: .3rem 0; font-size: .95rem; color: var(--text); }
.pricing-form { display: flex; flex-direction: column; gap: .5rem; }
.pricing-form input { width: 100%; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem; text-align: center; }
.footer-inner { display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; font-size: .875rem; color: var(--text-muted); }
.footer-brand { font-weight: 700; color: var(--text); }
.footer-sep { color: var(--border); }

/* ══════════════════════════════════════════════════════════════════════════
   DASHBOARD LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex; height: 100vh; overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 220px; flex-shrink: 0; background: #0f172a; color: #e2e8f0;
  display: flex; flex-direction: column; padding: 0; overflow-y: auto;
}
.sidebar-logo {
  padding: 1.25rem 1.25rem .75rem;
  font-size: .95rem; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: #93c5fd; border-bottom: 1px solid #1e293b;
}
.sidebar-nav { flex: 1; padding: .75rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1.25rem; font-size: .9rem; font-weight: 500;
  color: #94a3b8; text-decoration: none; border-radius: 0; transition: all .15s;
  cursor: pointer;
}
.sidebar-nav a:hover { background: #1e293b; color: #f1f5f9; }
.sidebar-nav a.active { background: #1e3a5f; color: #93c5fd; border-left: 3px solid #3b82f6; }
.sidebar-user {
  padding: 1rem 1.25rem; border-top: 1px solid #1e293b;
  font-size: .82rem; color: #64748b;
}
.sidebar-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: .35rem; }
.sidebar-user a { font-size: .82rem; color: #94a3b8; }
.sidebar-user a:hover { color: #f1f5f9; }

/* Main content */
.dashboard-main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; background: #f8fafc;
}
.section-inner { flex: 1; overflow-y: auto; padding: 2rem; max-width: 1100px; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h2 { margin-bottom: 0; }

/* ── Status badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-pending   { background: #f1f5f9; color: #475569; }
.badge-overdue   { background: #fff7ed; color: #c2410c; }
.badge-paid      { background: #f0fdf4; color: #15803d; }
.badge-cancelled { background: #fef2f2; color: #b91c1c; }

/* ── Invoice list ─────────────────────────────────────────────────────────── */
.invoice-grid {
  display: grid; gap: 1rem;
}
.invoice-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 1.1rem 1.25rem; box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
}
.invoice-card:hover { box-shadow: var(--shadow-md); border-color: #bfdbfe; }
.invoice-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(0,112,243,.15); }
.invoice-row-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.invoice-num { font-weight: 700; font-size: .95rem; }
.invoice-client { font-size: .9rem; color: var(--text-muted); }
.invoice-row-bot { display: flex; align-items: center; justify-content: space-between; margin-top: .5rem; flex-wrap: wrap; gap: .4rem; }
.invoice-amount { font-weight: 700; font-size: 1rem; color: var(--text); }
.invoice-due { font-size: .82rem; color: var(--text-muted); }
.invoice-step-label { font-size: .78rem; color: var(--grey); font-style: italic; }
.invoice-actions { display: flex; gap: .4rem; margin-top: .75rem; flex-wrap: wrap; }

.empty-state {
  background: #fff; border: 2px dashed var(--border); border-radius: 12px;
  padding: 3rem; text-align: center; color: var(--text-muted);
}
.empty-state h3 { font-size: 1rem; margin-bottom: .4rem; color: var(--text); }

/* ── Invoice detail panel ─────────────────────────────────────────────────── */
.detail-panel {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  margin-top: 1rem; padding: 1.5rem; box-shadow: var(--shadow);
}
.detail-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.detail-header h3 { margin-bottom: 0; font-size: 1.1rem; }
.btn-close {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--grey); padding: 0 .3rem; line-height: 1;
}
.btn-close:hover { color: var(--text); }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1.5rem; margin-bottom: 1.25rem; }
.detail-meta-item label { display: block; font-size: .78rem; font-weight: 600; color: var(--grey); text-transform: uppercase; letter-spacing: .04em; }
.detail-meta-item span { font-size: .95rem; color: var(--text); }
.detail-actions { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* Activity log */
.activity-section h4 { font-size: .9rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .75rem; }
.activity-list { position: relative; padding-left: 1.2rem; }
.activity-list::before { content: ''; position: absolute; left: .35rem; top: .4rem; bottom: .4rem; width: 2px; background: var(--border); }
.activity-item { position: relative; padding-bottom: .9rem; }
.activity-dot {
  position: absolute; left: -1.05rem; top: .35rem;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid var(--blue); z-index: 1;
}
.activity-desc { font-size: .9rem; color: var(--text); }
.activity-time { font-size: .78rem; color: var(--text-muted); }
.no-activity { font-size: .88rem; color: var(--text-muted); font-style: italic; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: #fff; border-radius: 14px; padding: 1.75rem; width: 100%; max-width: 480px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2); max-height: 90vh; overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-header h3 { font-size: 1.1rem; margin-bottom: 0; }

/* ── Templates ────────────────────────────────────────────────────────────── */
.template-step {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.template-step h3 { margin-bottom: 1rem; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: .75rem; }
.template-vars { margin: .75rem 0; font-size: .82rem; color: var(--text-muted); }
.template-vars code { background: var(--grey-light); padding: .1rem .35rem; border-radius: 4px; font-size: .8rem; margin-right: .25rem; }
.template-preview {
  background: var(--grey-light); border-radius: var(--radius); padding: .9rem 1rem;
  font-size: .85rem; white-space: pre-wrap; font-family: 'Courier New', monospace;
  color: var(--text); max-height: 180px; overflow-y: auto;
}
.preview-label { font-size: .78rem; font-weight: 600; color: var(--grey); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; margin-top: .75rem; }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 1.75rem; max-width: 520px; box-shadow: var(--shadow);
}
.settings-card h3 { margin-bottom: 1.25rem; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.status-ok   { color: var(--green); font-size: .85rem; font-weight: 600; }
.status-warn { color: var(--orange); font-size: .85rem; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════════════════
   AUTH PAGES (login, success, cancel)
   ══════════════════════════════════════════════════════════════════════════ */
.auth-page {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; background: var(--grey-light); padding: 1.5rem;
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 2.25rem; width: 100%; max-width: 420px;
  box-shadow: var(--shadow-md);
}
.auth-brand { font-size: .9rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); margin-bottom: 1.5rem; display: block; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.auth-card .sub { font-size: .9rem; color: var(--text-muted); margin-bottom: 1.75rem; }
.auth-divider { border: none; border-top: 1px solid var(--border); margin: 1.75rem 0; }
.auth-footer { margin-top: 1rem; font-size: .85rem; text-align: center; color: var(--text-muted); }
.success-icon { font-size: 3rem; margin-bottom: 1rem; }
.token-display {
  background: var(--grey-light); border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; font-family: 'Courier New', monospace; font-size: .85rem;
  word-break: break-all; margin: .75rem 0;
}

/* ── Notification bar ─────────────────────────────────────────────────────── */
.notify-bar {
  background: #fefce8; border-bottom: 1px solid #fde68a;
  padding: .6rem 1.5rem; font-size: .85rem; color: #92400e;
  display: flex; align-items: center; gap: .5rem;
}
