@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
  --brand: #20104d;
  --brand-mid: #2d1868;
  --brand-soft: #ece8f5;
  --accent: #0d9f8a;
  --accent-soft: #e6f7f4;
  --warn: #c47a12;
  --warn-soft: #fff4e5;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --info: #2a6fdb;
  --info-soft: #e8f0fc;
  --success: #1a7f4b;
  --success-soft: #e8f6ee;
  --bg: #eef1f6;
  --surface: #ffffff;
  --text: #1a1d26;
  --muted: #5c6578;
  --border: #d8dee9;
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 76px;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(32, 16, 77, 0.08);
  --font-display: 'Sora', sans-serif;
  --font-body: 'Source Sans 3', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Thin scrollbars across the app */
* {
  scrollbar-width: thin;
  scrollbar-color: #b8c0d0 transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: #b8c0d0;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #9aa3b5;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--brand-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #20104d 0%, #160a36 100%);
  color: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.85rem 1.5rem;
  z-index: 40;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.65rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 1rem;
  position: relative;
}

.brand-text { min-width: 0; flex: 1; }

.sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.35);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0d9f8a, #3dd6c0);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  opacity: 0.7;
}

.nav-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
  padding: 0.85rem 0.75rem 0.35rem;
  font-weight: 600;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: rgba(255,255,255,0.78);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(13, 159, 138, 0.28); color: #fff; }

.nav .icon {
  width: 18px;
  text-align: center;
  opacity: 0.85;
  font-size: 0.85rem;
}

.tenant-chip {
  margin-top: auto;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 0.85rem;
  font-size: 0.8rem;
}

.tenant-chip strong { display: block; font-size: 0.9rem; margin-bottom: 0.15rem; }
.tenant-chip span { opacity: 0.7; }
.tenant-chip-actions { margin-top: 0.65rem; }

.org-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.org-switcher-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.org-switcher select {
  max-width: min(280px, 42vw);
  font-size: 0.85rem;
  font-weight: 600;
}

.multi-org-toggle {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.multi-org-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.1rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.multi-org-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.ar-aging-chart {
  margin: 0 0 1.25rem;
}

.ar-aging-chart .chart-bars {
  height: 200px;
  align-items: flex-end;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.sidebar-expand-btn { display: none; }
.mobile-menu-btn { display: none; }

body.sidebar-collapsed .sidebar-expand-btn { display: none; }

/* Collapsed desktop sidebar — icons only */
body.sidebar-collapsed {
  --sidebar-w: var(--sidebar-collapsed-w);
}

body.sidebar-collapsed .brand {
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.35rem 0.25rem 1rem;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .tenant-chip-title,
body.sidebar-collapsed .tenant-chip-meta {
  display: none;
}

body.sidebar-collapsed .nav a {
  justify-content: center;
  padding: 0.7rem 0.35rem;
}

body.sidebar-collapsed .nav .icon {
  width: auto;
  font-size: 1rem;
}

body.sidebar-collapsed .tenant-chip {
  padding: 0.55rem 0.35rem;
  text-align: center;
}

body.sidebar-collapsed .tenant-chip-actions {
  margin-top: 0;
}

body.sidebar-collapsed .tenant-chip-actions .btn {
  width: 100%;
  padding: 0.4rem 0.25rem;
  font-size: 0;
  line-height: 0;
}

body.sidebar-collapsed .tenant-chip-actions .btn::after {
  content: '⇄';
  font-size: 0.95rem;
  line-height: 1;
}

body.sidebar-collapsed .sidebar-expand-btn { display: none; }

.topbar {
  background: rgba(255,255,255,0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar .meta { color: var(--muted); font-size: 0.88rem; }

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.quick-create { position: relative; }
.quick-create-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
}
.quick-create-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(32, 16, 77, 0.16);
  padding: 0.45rem;
  z-index: 50;
}
.quick-create-menu a,
.quick-create-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  text-decoration: none;
}
.quick-create-menu a:hover,
.quick-create-menu button:hover {
  background: var(--brand-soft);
  text-decoration: none;
}
.quick-create-label {
  padding: 0.35rem 0.7rem 0.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.quick-create-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.4rem;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-toggle button {
  border: 0;
  background: #fff;
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.view-toggle button.active {
  background: var(--brand);
  color: #fff;
}

.pie-chart-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1.25rem;
  align-items: center;
  padding: 1rem 1.15rem;
}

.pie-svg {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.pie-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
}

.pie-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.pie-legend-item strong {
  display: block;
  font-size: 0.88rem;
}

.pie-legend-item small {
  color: var(--muted);
  font-size: 0.78rem;
}

.pie-center-label {
  font-size: 11px;
  fill: #5c6578;
  font-family: inherit;
}

.pie-center-value {
  font-size: 14px;
  font-weight: 700;
  fill: #1a1f2e;
  font-family: inherit;
}

.pie-slice {
  cursor: pointer;
  transition: opacity 0.15s;
}
.pie-slice:hover { opacity: 0.88; }

@media (max-width: 720px) {
  .pie-chart-layout {
    grid-template-columns: 1fr;
  }
}


.xero-line-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.xero-line-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0.55rem 0.35rem;
  border-bottom: 1px solid var(--border);
  background: #f7f8fb;
  white-space: nowrap;
}
.xero-line-table td {
  padding: 0.3rem 0.3rem;
  border-bottom: 1px solid #eef1f6;
  vertical-align: top;
  text-align: left;
}
.xero-line-table input,
.xero-line-table select,
.xero-line-table textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 0.35rem 0.3rem;
  font: inherit;
  border-radius: 6px;
  resize: vertical;
  text-align: left;
}
.xero-line-table input:focus,
.xero-line-table select:focus,
.xero-line-table textarea:focus {
  outline: none;
  border-color: var(--brand-mid);
  background: #fff;
}
.xero-line-table .col-item { width: 170px; }
.xero-line-table .col-desc { min-width: 180px; }
.xero-line-table .col-qty { width: 58px; }
.xero-line-table .col-price { width: 88px; }
.xero-line-table .col-disc { width: 58px; }
.xero-line-table .col-account { width: 120px; }
.xero-line-table .col-taxrate { width: 120px; }
.xero-line-table .col-taxamt { width: 90px; }
.xero-line-table .col-amt { width: 100px; }
.xero-line-table .col-act { width: 36px; text-align: center; }
.xero-line-table .readonly-cell {
  display: block;
  padding: 0.4rem 0.3rem;
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.xero-line-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.doc-type-tabs {
  display: inline-flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.doc-type-tabs .chip.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.attach-box {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  background: #fafbfd;
}
.attach-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
}
.attach-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  border-bottom: 1px solid #eef1f6;
}

.pay-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.pay-invoice-picker {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfd;
  overflow: hidden;
}

.pay-invoice-toolbar,
.pay-invoice-actions,
.pay-invoice-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
}

.pay-invoice-toolbar {
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-wrap: nowrap;
}

.pay-invoice-toolbar .search {
  flex: 1;
  min-width: 0;
}

.pay-invoice-toolbar select {
  flex-shrink: 0;
}

.pay-invoice-actions {
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.pay-invoice-pager {
  justify-content: space-between;
  border-top: 1px solid var(--border);
  background: #fff;
}

.pay-invoice-table-wrap {
  max-height: 320px;
  overflow: auto;
  background: #fff;
}

.pay-invoice-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pay-invoice-table thead th {
  position: sticky;
  top: 0;
  background: #f3f5f9;
  z-index: 1;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.pay-invoice-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid #eef1f6;
  vertical-align: middle;
}

.pay-invoice-table tr:hover td { background: var(--brand-soft); }
.pay-invoice-table .num { text-align: right; }
.pay-invoice-table input[type="checkbox"] { margin: 0; }

.invoice-check-list {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.35rem;
}
.invoice-check-list label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.invoice-check-list label:hover { background: var(--brand-soft); }
.invoice-check-list .mono { margin-left: auto; font-weight: 600; }

.ledger-tabs { margin-bottom: 1rem; }
.ar-ap-toolbar {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.85rem;
}
.statement-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.acct-chart-wrap {
  min-height: 260px;
  background: #f6f7fa;
  border-radius: 10px;
  padding: 0.75rem;
}
.acct-chart-wrap svg { width: 100%; height: auto; display: block; }

.xero-plan-hero {
  background: linear-gradient(135deg, #20104d 0%, #3a2580 55%, #0d9f8a 140%);
  color: #fff;
  border-radius: 14px;
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
}
.xero-plan-hero h3 { margin: 0 0 0.35rem; font-family: var(--font-display); }
.xero-plan-hero p { margin: 0; opacity: 0.88; }
.plan-billing-toggle {
  display: inline-flex;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 0.2rem;
  margin-top: 0.9rem;
}
.plan-billing-toggle button {
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.plan-billing-toggle button.active { background: #fff; color: var(--brand); }
.plan .plan-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}
.plan .plan-includes {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0.75rem;
}

.content { padding: 1.5rem 1.75rem 2.5rem; }

.page-intro {
  margin-bottom: 1.35rem;
  max-width: 62rem;
}

.page-intro p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: rise 0.45s ease both;
}

.kpi:nth-child(2) { animation-delay: 0.05s; }
.kpi:nth-child(3) { animation-delay: 0.1s; }
.kpi:nth-child(4) { animation-delay: 0.15s; }
.kpi:nth-child(5) { animation-delay: 0.2s; }
.kpi:nth-child(6) { animation-delay: 0.25s; }
.kpi:nth-child(7) { animation-delay: 0.3s; }
.kpi:nth-child(8) { animation-delay: 0.35s; }

.kpi::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brand-soft);
  opacity: 0.55;
}

.kpi .label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
  position: relative;
  z-index: 1;
}

.kpi .value {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
}

.kpi .delta {
  font-size: 0.8rem;
  margin-top: 0.35rem;
  position: relative;
  z-index: 1;
  color: var(--success);
  font-weight: 600;
}

.kpi .delta.down { color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
  animation: rise 0.5s ease both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.panel-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.panel-body { padding: 1.15rem 1.25rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.95rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn[hidden],
[hidden] {
  display: none !important;
}

.btn:hover { background: var(--brand-mid); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-accent { background: var(--accent); }
.btn-accent:hover { background: #0b8a78; }

.btn-ghost {
  background: transparent;
  color: var(--brand);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--brand-soft); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a33024; }

input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(13, 159, 138, 0.35);
  border-color: var(--accent);
}

.search {
  min-width: 220px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235c6578' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 0.7rem center no-repeat;
  padding-left: 2.1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  background: #f7f8fb;
}

tr:hover td { background: #fafbfe; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space:nowrap;
}

.badge-draft { background: #eef0f4; color: #4a5160; }
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-approved { background: var(--info-soft); color: var(--info); }
.badge-issued { background: var(--brand-soft); color: var(--brand); }
.badge-partial { background: #fff0e0; color: #b35c00; }
.badge-paid { background: var(--success-soft); color: var(--success); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled { background: #eee; color: #666; }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-plan { background: var(--accent-soft); color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-2-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.form-grid .full { grid-column: 1 / -1; }

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field input, .field select, .field textarea { width: 100%; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  height: 160px;
  padding-top: 0.5rem;
}

.chart-bars .bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  height: 100%;
  justify-content: flex-end;
}

.chart-bars .bar {
  width: 100%;
  max-width: 36px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #0d9f8a, #20104d);
  animation: grow 0.7s ease both;
  transform-origin: bottom;
}

.chart-bars span {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  min-height: 1.6em;
}

.chart-bars.dense {
  gap: 0.18rem;
}

.chart-bars.dense .bar {
  max-width: 12px;
  border-radius: 3px 3px 1px 1px;
}

.chart-bars.dense span {
  font-size: 0.62rem;
}

.chart-bars .bar.compare-prev {
  opacity: 0.45;
}

/* Dashboard clickable widgets + area statistics chart */
.stat-widgets {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-widget {
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  font-family: var(--font-body);
  color: var(--text);
}

.stat-widget:hover {
  transform: translateY(-2px);
  border-color: #c5cde0;
}

.stat-widget.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13, 159, 138, 0.18), var(--shadow);
}

.stat-widget-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.stat-widget-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.55rem;
}

.stat-widget-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-widget-sub span {
  color: var(--success);
  font-weight: 700;
}

.stats-panel .panel-head {
  align-items: flex-start;
}

.stats-meta {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stats-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
}

.chip:hover { border-color: #c5cde0; color: var(--text); }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #0a6f60;
}

.compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.stats-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stats-range input[type="month"],
.stats-range input[type="date"],
.table-date-range input[type="date"] {
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
}

.table-date-range {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.chart-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.chart-summary > div {
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}

.chart-summary .muted {
  display: block;
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}

.chart-summary strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.chart-summary .delta { color: var(--success); }
.chart-summary .delta.down { color: var(--danger); }

.area-chart-wrap {
  position: relative;
  width: 100%;
  min-height: 300px;
  background: #f6f7fa;
  border-radius: 10px;
  padding: 0.35rem 0.25rem 0.15rem;
}

.area-chart-wrap.spline-chart {
  background: linear-gradient(180deg, #f4f5f8 0%, #fafbfc 100%);
}

.area-chart-wrap.bar-chart {
  background: linear-gradient(180deg, #f4f5f8 0%, #fafbfc 100%);
}

.area-chart-wrap.chart-flash #areaChart {
  animation: chartIn 0.35s ease;
}

@keyframes chartIn {
  from { opacity: 0.35; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

#areaChart {
  width: 100%;
  height: auto;
  display: block;
}

#areaChart .grid-line {
  stroke: #d8dde8;
  stroke-width: 1;
}

#areaChart .grid-line.dashed {
  stroke: #d0d5e0;
  stroke-dasharray: 4 5;
  stroke-width: 1;
}

#areaChart .avg-line {
  stroke: #9aa3b5;
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

#areaChart .hover-guide {
  stroke: rgba(155, 140, 255, 0.35);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

#areaChart .axis-label {
  fill: #9aa3b5;
  font-size: 11px;
  font-family: var(--font-body);
}

#areaChart .area-fill {
  fill: rgba(155, 140, 255, 0.2);
}

#areaChart .area-fill.spline {
  fill: url(#splineFill);
}

#areaChart .area-line {
  stroke: #9b8cff;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

#areaChart .area-line.spline {
  stroke: #8f7cff;
  stroke-width: 2.75;
}

#areaChart .area-line.prior {
  stroke: #9aa3b5;
  stroke-width: 2;
  stroke-dasharray: 6 5;
  opacity: 0.9;
}

#areaChart .area-dot {
  fill: #fff;
  stroke: #8f7cff;
  stroke-width: 2.5;
  cursor: pointer;
}

#areaChart .area-dot:hover {
  fill: #8f7cff;
  r: 7;
}

#areaChart .area-hit {
  fill: transparent;
  stroke: none;
  cursor: crosshair;
}

#areaChart .bar-rect {
  fill: url(#barFill);
  cursor: pointer;
  transition: opacity 0.15s;
}

#areaChart .bar-rect:hover {
  opacity: 0.88;
}

#multiOrgChart .bar-rect {
  cursor: pointer;
  transition: opacity 0.15s;
}

#multiOrgChart .bar-rect:hover {
  opacity: 0.88;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  background: #3d2f6b;
  color: #fff;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(61, 47, 107, 0.28);
  min-width: 130px;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 0.15rem;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  background: #8f7cff;
}

.legend-swatch.spline {
  background: linear-gradient(90deg, #9b8cff, #c4b7ff);
  height: 4px;
  border-radius: 3px;
}

.legend-swatch.bar {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, #8f7cff, #c4b7ff);
}

.legend-swatch.prior {
  background: #9aa3b5;
  background-image: repeating-linear-gradient(90deg, #9aa3b5 0 4px, transparent 4px 7px);
}

.legend-swatch.avg {
  background: #9aa3b5;
  height: 0;
  border-top: 2px dashed #9aa3b5;
  width: 18px;
}

.rank-mini {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.rank-mini-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-width: 0;
}

.rank-mini-item strong {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-mini-item small {
  color: var(--muted);
  font-size: 0.75rem;
}

.rank-pos {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--brand-soft);
  color: var(--brand);
}

@media (max-width: 1280px) {
  .stat-widgets { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1100px) {
  .stat-widgets { grid-template-columns: repeat(2, 1fr); }
  .rank-mini { grid-template-columns: repeat(2, 1fr); }
  .chart-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .stat-widgets { grid-template-columns: 1fr; }
  .rank-mini { grid-template-columns: 1fr; }
  .chart-summary { grid-template-columns: 1fr; }
  .stats-controls { justify-content: flex-start; }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
}

.invoice-paper {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 860px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.invoice-builder-layout .invoice-paper {
  max-width: none;
  width: 100%;
  margin: 0;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--brand);
}

.invoice-logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
}

.invoice-logo small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.25rem;
}

.invoice-meta { text-align: right; font-size: 0.9rem; }
.invoice-meta strong { font-family: var(--font-display); font-size: 1.15rem; }

.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.parties h4 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.totals {
  margin-left: auto;
  width: 280px;
  font-size: 0.92rem;
}

.totals .row {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0;
}

.totals .grand {
  border-top: 2px solid var(--brand);
  margin-top: 0.4rem;
  padding-top: 0.55rem;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.xero-calc {
  margin-left: auto;
  margin-top: 1.25rem;
  width: min(320px, 100%);
  font-size: 0.95rem;
  color: var(--text);
}
.xero-calc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.2rem 0;
}
.xero-calc-gst {
  padding-left: 0.85rem;
  color: #5e6c84;
  font-size: 0.86rem;
}
.xero-calc-gst .mono {
  color: #5e6c84;
  min-width: 4.5rem;
  text-align: right;
}
.xero-calc-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  margin-top: 0.55rem;
  padding: 0.65rem 0;
  border-top: 1px solid #d8dee9;
  border-bottom: 1px solid #d8dee9;
  font-weight: 700;
}
.xero-calc-total span:last-child {
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.lifecycle .step {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #eef0f4;
  color: #6a7385;
}

.lifecycle .step.on { background: var(--brand); color: #fff; }
.lifecycle .step.done { background: var(--accent-soft); color: var(--accent); }

.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.1rem;
}

.plan {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  background: #fff;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.plan:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.plan.featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(13,159,138,0.2);
}

.plan h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.plan .price {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin: 0.6rem 0;
  letter-spacing: -0.03em;
}

.plan .price small { font-size: 0.85rem; font-weight: 500; color: var(--muted); }

.plan ul {
  margin: 0 0 1.1rem;
  padding: 0 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.plan ul li { margin-bottom: 0.35rem; }

.timeline { list-style: none; margin: 0; padding: 0; }

.timeline li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.timeline time { color: var(--muted); font-weight: 600; font-size: 0.82rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 12, 36, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 14px;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  animation: rise 0.25s ease;
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.modal .body { padding: 1.25rem; }
.modal .footer {
  padding: 0.85rem 1.25rem 1.15rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--border);
}

.modal.modal-lg {
  width: min(860px, 100%);
}

.dealer-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

.dealer-location-field {
  grid-column: 1 / -1;
}

.phone-input {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.phone-input select {
  width: auto;
  min-width: 6.5rem;
  flex: 0 0 auto;
}

.phone-input input {
  flex: 1;
  min-width: 0;
}

.dealer-map {
  position: relative;
  margin-top: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  height: 240px;
  background: #dfe7ef;
}

.dealer-map iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.dealer-map-pin {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -22px 0 0 -9px;
  border-radius: 50% 50% 50% 0;
  background: #e53935;
  transform: rotate(-45deg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.dealer-map-pin::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #fff;
}

.pricing-type-block {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.pricing-type-block h4 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 600;
}

.pricing-type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.pricing-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-weight: 500;
}

.pricing-option input {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--info);
}

@media (max-width: 720px) {
  .dealer-form-grid { grid-template-columns: 1fr; }
}

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  overflow-x: auto;
}

.tabs button {
  border: none;
  background: transparent;
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button.active {
  color: var(--brand);
  border-bottom-color: var(--accent);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.alert-info { background: var(--info-soft); color: #1a4a9c; }
.alert-warn { background: var(--warn-soft); color: #8a5508; }
.alert-ok { background: var(--success-soft); color: var(--success); }

.split-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

.login-hero {
  background:
    linear-gradient(145deg, rgba(32,16,77,0.88), rgba(13,159,138,0.55)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.06'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E"),
    #20104d;
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.login-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.login-hero p {
  margin: 0;
  max-width: 36ch;
  opacity: 0.9;
  font-size: 1.05rem;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #f7f8fb;
}

.login-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.login-card h2 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.login-card > p { margin: 0 0 1.35rem; color: var(--muted); font-size: 0.92rem; }

.role-pick {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.role-pick label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.role-pick label:hover,
.role-pick input:checked + .role-text,
.role-pick label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.role-pick input { margin-top: 0.2rem; }

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.55rem;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  background: #fff;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}

.perm-item:hover { border-color: #c5cde0; }
.perm-item:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.perm-item input { margin: 0; }

.role-text strong { display: block; font-size: 0.95rem; }
.role-text span { font-size: 0.8rem; color: var(--muted); }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.92rem;
}

.stat-row:last-child { border-bottom: none; }
.stat-row strong { font-family: var(--font-display); }

.progress {
  height: 8px;
  background: #e8ecf3;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--brand));
  border-radius: 99px;
}

.muted { color: var(--muted); }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

.empty {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes grow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}

/* Xero-style report library */
.report-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: start;
}

.report-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.5rem 1rem;
  position: sticky;
  top: 0.5rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
}

.report-nav-head {
  padding: 0.35rem 0.5rem 0.75rem;
  display: grid;
  gap: 0.5rem;
}

.report-nav-head strong {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.report-nav-head .search {
  min-width: 0;
  width: 100%;
  font-size: 0.85rem;
  padding: 0.4rem 0.55rem 0.4rem 2rem;
}

.report-nav-section {
  margin: 0.85rem 0.5rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.report-nav-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.report-nav-item:hover { background: #f3f5f9; }
.report-nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
}
.report-nav-item .star {
  color: #c4a035;
  font-size: 0.75rem;
}
.report-nav-item:not(.fav) .star { display: none; }

.report-main { min-width: 0; }

.report-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 0.65rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.report-controls .field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.25rem;
  display: block;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-left: auto;
  align-items: center;
}

.export-menu { position: relative; }
.export-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(20, 24, 40, 0.14);
  min-width: 140px;
  z-index: 20;
  overflow: hidden;
}
.export-dropdown button {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.export-dropdown button:hover { background: #f3f5f9; }
.export-dropdown label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}
.export-dropdown label:hover { background: #f3f5f9; }

.report-meta {
  margin: 0 0 1rem;
  font-size: 0.85rem;
}

.report-paper { animation: rise 0.4s ease both; }

.report-title {
  margin-bottom: 1rem;
}
.report-title h3 {
  margin: 0 0 0.25rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.report-title .muted { font-size: 0.88rem; }

.report-table th.num,
.report-table td.num,
.report-table .num { text-align: right; }

.report-table tfoot td {
  background: #f7f8fb;
  border-top: 2px solid var(--border);
}

.pnl-table .section-row td {
  background: #f3f5f9;
  padding-top: 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: none;
}
.pnl-table .indent { padding-left: 1.75rem; }
.pnl-table .total-row td {
  border-top: 1px solid var(--border);
  font-weight: 600;
}
.pnl-table .grand-row td {
  background: var(--brand-soft);
  border-top: 2px solid var(--brand);
  font-weight: 700;
}
.pnl-table .pos { color: var(--success); }
.pnl-table .neg { color: var(--danger); }

.report-bullets {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
}
.report-bullets li { margin-bottom: 0.45rem; }

@media print {
  .sidebar, .topbar, .toolbar, .no-print, .report-nav { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .invoice-paper { box-shadow: none; border: none; max-width: none; }
  .report-shell { display: block; }
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-2-equal, .plan-cards { grid-template-columns: 1fr; }
  .report-shell { grid-template-columns: 1fr; }
  .report-nav {
    position: static;
    max-height: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.25rem;
  }
  .report-nav-head { grid-column: 1 / -1; }
  .report-nav-section { grid-column: 1 / -1; margin-top: 0.5rem; }
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    transform: none;
    transition: width 0.2s ease;
    width: var(--sidebar-w);
  }
  .main { margin-left: var(--sidebar-w); }
  .mobile-menu-btn,
  .sidebar-expand-btn { display: none !important; }
  .sidebar-toggle { display: inline-flex !important; }

  body.sidebar-collapsed .brand {
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.35rem 0.25rem 1rem;
  }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-section,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .tenant-chip-title,
  body.sidebar-collapsed .tenant-chip-meta {
    display: none;
  }
  body.sidebar-collapsed .nav a {
    justify-content: center;
    padding: 0.7rem 0.35rem;
  }
  body.sidebar-collapsed .tenant-chip {
    padding: 0.55rem 0.35rem;
    text-align: center;
  }
  body.sidebar-collapsed .tenant-chip-actions { margin-top: 0; }
  body.sidebar-collapsed .tenant-chip-actions .btn {
    width: 100%;
    padding: 0.4rem 0.25rem;
    font-size: 0;
    line-height: 0;
  }
  body.sidebar-collapsed .tenant-chip-actions .btn::after {
    content: '⇄';
    font-size: 0.95rem;
    line-height: 1;
  }

  .split-login { grid-template-columns: 1fr; }
  .login-hero { min-height: 220px; padding: 2rem; }
  .form-grid { grid-template-columns: 1fr; }
  .parties { grid-template-columns: 1fr; }
  .invoice-header { flex-direction: column; }
  .invoice-meta { text-align: left; }
  .report-actions { margin-left: 0; width: 100%; }
}

/* Training */
.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.training-thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
  overflow: hidden;
}

.training-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-thumb-fallback {
  width: 100%;
  height: 100%;
  min-height: 140px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 2rem;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
}

.training-card-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.training-card-body h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
}

.training-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.training-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.training-card-body .btn {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.training-upload-preview {
  margin-top: 0.55rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  min-height: 120px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
  padding: 0.5rem;
}

.training-upload-preview img,
.training-upload-preview video {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}

.training-video-preview video {
  max-height: 200px;
  object-fit: contain;
  background: #111;
}

.training-watch-frame video {
  width: 100%;
  max-height: 420px;
  background: #111;
  border-radius: 10px;
}

.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.training-thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
  overflow: hidden;
}

.training-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-thumb-fallback {
  width: 100%;
  height: 100%;
  min-height: 140px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.85);
  font-size: 2rem;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
}

.training-card-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.training-card-body h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
}

.training-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.training-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.training-card-body .btn {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.training-upload-preview {
  margin-top: 0.55rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  min-height: 120px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}

.training-upload-preview img,
.training-upload-preview video {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.training-video-preview video {
  max-height: 200px;
  object-fit: contain;
  background: #111;
}

.training-watch-frame video {
  width: 100%;
  max-height: 420px;
  background: #111;
  border-radius: 10px;
}

.training-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.training-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.training-thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
  overflow: hidden;
}

.training-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.training-thumb-fallback {
  width: 100%;
  height: 100%;
  min-height: 140px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.85);
  font-size: 2rem;
  background: linear-gradient(145deg, #1f1638, #3a2a6e);
}

.training-card-body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.training-card-body h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
}

.training-card-body p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.training-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.training-card-body .btn {
  align-self: flex-start;
  margin-top: 0.25rem;
}

.training-upload-preview {
  margin-top: 0.55rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  min-height: 120px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}

.training-upload-preview img,
.training-upload-preview video {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.training-video-preview video {
  max-height: 200px;
  object-fit: contain;
  background: #111;
}

.training-watch-frame video {
  width: 100%;
  max-height: 420px;
  background: #111;
  border-radius: 10px;
}
