:root {
  --brand: #1e5f5f;
  --brand-dark: #143e3e;
  --brand-light: #e8f3f2;
  --accent: #d98e04;
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 68px;
  --bs-body-bg: #f4f6f7;
}

body {
  background: var(--bs-body-bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Top navbar */
.topbar {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* Layout shell */
.app-shell { min-height: calc(100vh - 56px); }

.app-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #e6e9ea;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  transition: width .2s ease, flex-basis .2s ease;
}
.sidebar-scroll { overflow-y: auto; height: 100%; padding: .75rem 0 5rem; }

/* Collapsed (icon-only) sidebar */
.app-sidebar.collapsed { width: var(--sidebar-w-collapsed); flex: 0 0 var(--sidebar-w-collapsed); }
.app-sidebar.collapsed .nav-section-title { display: none; }
.app-sidebar.collapsed .nav-link { justify-content: center; padding-left: .5rem; padding-right: .5rem; }
.app-sidebar.collapsed .nav-link span { display: none; }
.app-sidebar.collapsed .nav-link i { margin: 0; font-size: 1.15rem; }

.sidebar-toggle-btn {
  position: absolute;
  top: 22px;
  right: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  z-index: 20;
  padding: 0;
  transition: transform .2s ease, background .15s ease;
}
.sidebar-toggle-btn:hover { background: var(--brand-dark); }
.sidebar-toggle-btn i { font-size: .85rem; transition: transform .2s ease; }
.app-sidebar.collapsed .sidebar-toggle-btn i { transform: rotate(180deg); }

.app-sidebar-offcanvas { background: var(--brand-dark); width: 260px; }
.app-sidebar-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.12); }
.app-sidebar-offcanvas .nav-section-title { color: rgba(255,255,255,.55); }
.app-sidebar-offcanvas .nav-link { color: rgba(255,255,255,.85); }
.app-sidebar-offcanvas .nav-link:hover { background: rgba(255,255,255,.08); }
.app-sidebar-offcanvas .nav-link.active { background: var(--accent); color: #fff; }

.nav-section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8a97a0;
  font-weight: 600;
  padding: .9rem 1.1rem .3rem;
}

.app-sidebar .nav-link, .app-sidebar-offcanvas .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 1.1rem;
  font-size: .92rem;
  border-radius: 0;
}
.app-sidebar .nav-link { color: #445; }
.app-sidebar .nav-link i, .app-sidebar-offcanvas .nav-link i { font-size: 1.05rem; width: 1.2rem; }
.app-sidebar .nav-link:hover { background: var(--brand-light); color: var(--brand-dark); }
.app-sidebar .nav-link.active {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
  border-right: 3px solid var(--brand);
}

.app-main { min-width: 0; padding-bottom: 70px; }

/* Cards */
.stat-card {
  border: none;
  border-radius: .75rem;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.stat-card .stat-label { font-size: .78rem; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.bg-grad-teal   { background: linear-gradient(135deg,#1e5f5f,#2c8080); }
.bg-grad-amber  { background: linear-gradient(135deg,#c97a03,#e0a53a); }
.bg-grad-blue   { background: linear-gradient(135deg,#2a4d8f,#4c74c9); }
.bg-grad-plum   { background: linear-gradient(135deg,#6b2d5c,#9c4c85); }

.card { border: 1px solid #e6e9ea; border-radius: .65rem; }
.card-header { background: #fbfcfc; font-weight: 600; }

table.table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6b7680;
  border-bottom-width: 1px;
  white-space: nowrap;
}
.table-responsive-card table { min-width: 640px; }

.badge-status-draft { background: #adb5bd; }
.badge-status-posted { background: #2c8080; }
.badge-status-paid { background: #1e5f5f; }
.badge-status-partially_paid { background: #d98e04; }
.badge-status-cancelled { background: #b3413c; }
.badge-status-reversed { background: #6b4c9a; }

/* Mobile bottom nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e2e6e8;
  display: flex;
  z-index: 1030;
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.mobile-bottom-nav a, .mobile-bottom-nav button.bottom-nav-more {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: .5rem 0 .4rem;
  font-size: .68rem;
  color: #6b7680;
  text-decoration: none;
}
.mobile-bottom-nav a i, .mobile-bottom-nav button i { font-size: 1.2rem; }
.mobile-bottom-nav a.active { color: var(--brand); font-weight: 600; }

@media (min-width: 992px) {
  .mobile-bottom-nav { display: none !important; }
}

/* Forms */
.required-mark { color: #c0392b; }
.line-item-row { border-bottom: 1px solid #eef0f1; }
.line-item-row:last-child { border-bottom: none; }

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand) 60%, var(--accent));
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  border-radius: 1rem;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  border: none;
}

/* Settings tabs */
.settings-tabs { flex-wrap: nowrap; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.settings-tabs .nav-link { color: #5a6570; border: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.settings-tabs .nav-link i { margin-right: .3rem; }
.settings-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: none; font-weight: 600; }
.form-control-color { width: 100%; height: 42px; }

/* ------------------------------------------------------------------ */
/* Compact printable voucher - shared by every transaction detail page */
/* ------------------------------------------------------------------ */
.voucher {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #e6e9ea;
  border-radius: .5rem;
  padding: 1.5rem;
  font-size: .88rem;
}
.voucher-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #222;
  padding-bottom: .6rem;
  margin-bottom: .9rem;
}
.voucher-head img { max-height: 34px; margin-bottom: .25rem; }
.voucher-company { font-weight: 700; font-size: 1.05rem; }
.voucher-company-meta { font-size: .76rem; color: #666; }
.voucher-title { font-weight: 700; font-size: 1rem; text-transform: uppercase; letter-spacing: .03em; text-align: right; }
.voucher-meta { font-size: .8rem; color: #444; text-align: right; }
.voucher-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .15rem 1.5rem; margin-bottom: .9rem; font-size: .85rem; }
.voucher-info-grid dt { color: #777; font-weight: 500; }
.voucher-info-grid dd { margin: 0 0 .35rem; font-weight: 600; }
.voucher table.table-sm td, .voucher table.table-sm th { padding: .3rem .5rem; font-size: .82rem; }
.voucher-total-row { font-weight: 700; font-size: .95rem; border-top: 1px solid #ccc; }
.voucher-footer { margin-top: 1.25rem; padding-top: .6rem; border-top: 1px dashed #ccc; font-size: .72rem; color: #888; }
.voucher-status-stamp {
  display: inline-block;
  border: 2px solid;
  border-radius: .35rem;
  padding: .15rem .6rem;
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  transform: rotate(-6deg);
}

@media print {
  /* Isolate exactly one element for printing, regardless of what else is on the page. */
  body * { visibility: hidden; }
  .voucher, .voucher * { visibility: visible; }
  .voucher {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }
  .no-print { display: none !important; }
  /* Explicit belt-and-suspenders removal of fixed/sticky chrome — visibility:hidden
     alone can be inconsistent across browsers/print engines for position:fixed
     elements, so these are also fully removed from layout. */
  .topbar, .app-sidebar, .app-sidebar-offcanvas, .mobile-bottom-nav, .offcanvas {
    display: none !important;
  }
  @page { margin: 1.2cm; }
}
