:root {
  --brand: #82bc00;
  --brand-dark: #6a9a00;
  --brand-bright: #9ad41a;
  --brand-soft: rgba(130, 188, 0, 0.16);
  --ink: #f3f4f6;
  --muted: #9ca3af;
  --line: #2c2c30;
  --surface: #0b0b0d;
  --card: #141417;
  --card-elevated: #1b1b1f;
  --success: #82bc00;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --sidebar: #000000;
  --charcoal: #414042;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

h1, h2, h3, .brand-text, .display-font {
  font-family: Outfit, "DM Sans", sans-serif;
}

a { color: var(--brand-bright); }
a:hover { color: var(--brand); }

.text-muted { color: var(--muted) !important; }
.border-top { border-color: var(--line) !important; }
.bg-light { background: var(--card-elevated) !important; color: var(--ink) !important; }

/* ---------- Public / Landing ---------- */
.public-shell { min-height: 100vh; }

.landing {
  min-height: 100vh;
  background:
    radial-gradient(1000px 520px at 8% -8%, rgba(130, 188, 0, 0.22), transparent 55%),
    radial-gradient(800px 480px at 95% 5%, rgba(65, 64, 66, 0.45), transparent 50%),
    linear-gradient(180deg, #000000 0%, #121214 55%, #0b0b0d 100%);
  color: var(--ink);
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-logo.lg { height: 48px; }

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #000;
  font-weight: 800;
  font-size: .95rem;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}

.hero {
  padding: 4.5rem 0 5rem;
}

.hero-kicker {
  display: inline-block;
  padding: .35rem .75rem;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-bright);
  border: 1px solid rgba(130, 188, 0, 0.35);
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 14ch;
  margin-bottom: 1rem;
  color: #fff;
}

.hero p.lead {
  color: var(--muted);
  font-size: 1.15rem;
  max-width: 38rem;
  margin-bottom: 1.75rem;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.hero-panel {
  background: linear-gradient(160deg, #161618, #0f0f11);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  overflow: hidden;
}

.hero-stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.hero-stat span { display: block; color: var(--muted); font-size: .8rem; }
.hero-stat strong { font-size: 1.25rem; color: #fff; }

.feature-grid { padding: 1rem 0 4rem; }
.feature-card {
  height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.feature-card h5 { color: #fff; }
.feature-card i {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(800px 400px at 0% 0%, rgba(130, 188, 0, 0.18), transparent 60%),
    linear-gradient(160deg, #000000, #141417);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.auth-card.wide { max-width: 640px; }
.auth-card h1, .auth-card .h3 { color: #fff; }

.btn-brand {
  background: linear-gradient(135deg, var(--brand-bright), var(--brand));
  border: none;
  color: #0a0a0a;
  font-weight: 700;
  border-radius: 10px;
  padding: .65rem 1.15rem;
}
.btn-brand:hover {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #000;
}

.btn-outline-brand {
  border: 1.5px solid var(--brand);
  color: var(--brand-bright);
  font-weight: 600;
  border-radius: 10px;
  background: transparent;
}
.btn-outline-brand:hover {
  background: var(--brand-soft);
  color: #fff;
  border-color: var(--brand-bright);
}

.btn-outline-secondary {
  border-color: #3f3f46 !important;
  color: #d4d4d8 !important;
}
.btn-outline-secondary:hover {
  background: #27272a !important;
  color: #fff !important;
}
.btn-outline-danger {
  border-color: #7f1d1d !important;
  color: #fca5a5 !important;
}
.btn-light {
  background: #27272a !important;
  border-color: #3f3f46 !important;
  color: #e5e7eb !important;
}

/* ---------- App shell ---------- */
.app-body { background: var(--surface); }

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.app-sidebar {
  background: var(--sidebar);
  color: #e5e7eb;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #1f1f22;
}

.app-sidebar .brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  margin-bottom: 1.75rem;
  padding: 0 .5rem;
}

.side-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .85rem;
  border-radius: 10px;
  color: #a1a1aa;
  text-decoration: none;
  font-weight: 500;
}
.side-nav a:hover { background: rgba(130, 188, 0, 0.08); color: #fff; }
.side-nav a.active {
  background: rgba(130, 188, 0, 0.18);
  color: var(--brand-bright);
  border: 1px solid rgba(130, 188, 0, 0.28);
}

.side-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid #1f1f22; }
.company-chip { padding: .5rem; margin-bottom: .5rem; }
.company-chip strong { display: block; color: #fff; font-size: .9rem; }
.company-chip small { color: #71717a; }
.logout-link { color: #71717a; text-decoration: none; font-size: .9rem; padding: .5rem; display: inline-flex; gap: .4rem; align-items: center; }
.logout-link:hover { color: var(--brand); }

.logo-upload-box {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101013;
}
.logo-preview {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  background: #000;
  border: 1px solid #3f3f46;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
.logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  color: #71717a;
  font-size: .75rem;
}
.logo-placeholder i { font-size: 1.4rem; color: var(--brand); }
.logo-upload-meta { flex: 1; min-width: 0; }

.btn-mark-paid {
  color: var(--brand-bright) !important;
  border-color: rgba(130, 188, 0, 0.35) !important;
}
.btn-mark-paid:hover {
  background: rgba(130, 188, 0, 0.18) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}

.mark-paid-modal {
  background: #17171a;
  color: #f3f4f6;
  border: 1px solid #2c2c30;
  border-radius: 16px;
}
.mark-paid-modal .modal-title { color: #fff; }
.mark-paid-modal .modal-footer { justify-content: flex-end; gap: .5rem; }

.app-main { min-width: 0; background: var(--surface); }
.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem .5rem;
}
.page-heading {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: #fff;
}
.app-content { padding: .75rem 1.75rem 2rem; }

/* ---------- Forms / Bootstrap dark ---------- */
.form-label { color: #d4d4d8; }
.form-text { color: #71717a !important; }
.form-control, .form-select {
  border-radius: 10px;
  border-color: #3f3f46;
  background: #0f0f12;
  color: #f4f4f5;
  padding: .55rem .8rem;
}
.form-control::placeholder { color: #71717a; }
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  background: #0f0f12;
  color: #fff;
  box-shadow: 0 0 0 .2rem rgba(130, 188, 0, .18);
}
.form-select option { background: #17171a; color: #fff; }
.form-check-input {
  background-color: #27272a;
  border-color: #52525b;
}
.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}
.form-check-label { color: #d4d4d8; }

.alert {
  border-radius: 12px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(130,188,0,.12); color: #d9f99d; border-color: rgba(130,188,0,.3); }
.alert-danger { background: rgba(239,68,68,.12); color: #fecaca; border-color: rgba(239,68,68,.3); }
.alert-warning { background: rgba(245,158,11,.12); color: #fde68a; border-color: rgba(245,158,11,.3); }
.alert-info { background: rgba(130,188,0,.1); color: #e5e7eb; border-color: rgba(130,188,0,.25); }

.pagination .page-link {
  background: var(--card);
  border-color: var(--line);
  color: #d4d4d8;
}
.pagination .page-item.active .page-link {
  background: var(--brand);
  border-color: var(--brand);
  color: #000;
  font-weight: 700;
}
.pagination .page-link:hover {
  background: #27272a;
  color: #fff;
}

/* ---------- Cards / filters / table ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--ink);
}

.filter-row .form-label { font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: linear-gradient(160deg, #18181b, #121214);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.2rem;
  flex-shrink: 0;
  border: 1px solid rgba(130, 188, 0, 0.25);
}
.stat-card .label { color: var(--muted); font-size: .85rem; margin-bottom: .15rem; }
.stat-card .value { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; word-break: break-word; color: #fff; }
.stat-card.compact { margin-bottom: 1.25rem; max-width: 280px; }

.chart-wrap { min-height: 320px; }
.table-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.table { color: #e5e7eb; --bs-table-bg: transparent; --bs-table-color: #e5e7eb; --bs-table-border-color: #2c2c30; }
.table > :not(caption) > * > * { padding: .85rem .75rem; vertical-align: middle; border-bottom-color: #2c2c30; }
.table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--brand-bright);
  background: #0f0f12;
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table a { color: var(--brand-bright); text-decoration: none; font-weight: 600; }
.table a:hover { color: #fff; }

.badge-status {
  display: inline-block;
  padding: .3rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-paid { background: rgba(130,188,0,.18); color: #b8e63a; border: 1px solid rgba(130,188,0,.35); }
.badge-unpaid { background: rgba(245,158,11,.15); color: #fbbf24; border: 1px solid rgba(245,158,11,.3); }
.badge-partial { background: rgba(96,165,250,.15); color: #93c5fd; border: 1px solid rgba(96,165,250,.3); }
.badge-overdue { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.badge-draft { background: rgba(161,161,170,.12); color: #a1a1aa; border: 1px solid #3f3f46; }
.badge-cancelled { background: rgba(113,113,122,.15); color: #a1a1aa; border: 1px solid #3f3f46; }

.status-meta { display: block; font-size: .75rem; color: var(--muted); margin-top: .2rem; }

.row-actions { display: flex; gap: .35rem; }
.row-actions .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

/* ---------- Invoice create ---------- */
.invoice-editor .section-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}
.party-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: #101013;
  height: 100%;
}
.party-card h6 { font-weight: 700; margin-bottom: .75rem; color: var(--brand-bright); }
.party-meta { font-size: .9rem; color: #d4d4d8; line-height: 1.55; }

.line-items-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #0a0a0a;
  border-radius: 10px 10px 0 0;
  padding: .75rem 1rem;
  font-weight: 700;
  font-size: .9rem;
}
.line-item-row {
  border: 1px solid var(--line);
  border-top: none;
  padding: 1rem;
  background: #121215;
}
.line-item-row:last-child { border-radius: 0 0 10px 10px; }

.dashed-btn {
  border: 1.5px dashed rgba(130, 188, 0, 0.45);
  background: rgba(130, 188, 0, 0.08);
  color: var(--brand-bright);
  border-radius: 10px;
  padding: .85rem;
  width: 100%;
  font-weight: 600;
}
.dashed-btn:hover { background: rgba(130, 188, 0, 0.16); color: #fff; }

.totals-box {
  background: #101013;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
}
.totals-box .total-line {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
  color: var(--brand-bright);
}

.stepper {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-weight: 600;
}
.stepper .step { color: var(--muted); }
.stepper .step.active { color: var(--brand-bright); }
.stepper .step span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: .8rem;
  margin-right: .4rem;
}
.stepper .step.active span { background: var(--brand); color: #000; font-weight: 800; }

/* ---------- Invoice PDF / view ---------- */
.invoice-doc {
  max-width: 900px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2rem;
}
.invoice-doc .doc-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.invoice-doc table { width: 100%; }
.invoice-doc .items th {
  background: rgba(130, 188, 0, 0.15);
  color: var(--brand-bright);
  padding: .65rem;
  text-align: left;
  font-size: .85rem;
}
.invoice-doc .items td { padding: .65rem; border-bottom: 1px solid var(--line); }

@media (max-width: 991px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: relative;
    height: auto;
  }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575px) {
  .summary-grid { grid-template-columns: 1fr; }
  .app-content, .app-topbar { padding-left: 1rem; padding-right: 1rem; }
}

@media print {
  .app-sidebar, .app-topbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .app-content { padding: 0; }
  .invoice-doc { border: none; box-shadow: none; }
}
