:root {
  --app-teal-900: #174b59;
  --app-teal-800: #215d6d;
  --app-teal-700: #2f7282;
  --app-ink: #17313a;
  --app-muted: #60737a;
  --app-border: #d4e0e3;
  --app-canvas: #f5f8f9;
}

html {
  min-height: 100%;
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--app-ink);
  background: var(--app-canvas);
}

.app-navbar {
  background: linear-gradient(100deg, var(--app-teal-900), var(--app-teal-800));
  box-shadow: 0 2px 12px rgba(20, 62, 74, 0.18);
}

.app-navbar .nav-link {
  color: rgba(255, 255, 255, 0.78);
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
  color: #fff;
}

.demo-banner {
  padding: 0.55rem 1.5rem;
  border-bottom: 1px solid #f3d994;
  color: #664d03;
  background: #fff3cd;
  font-size: 0.9rem;
  text-align: center;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-heading h1 {
  margin: 0;
  color: var(--app-teal-900);
  font-size: clamp(1.45rem, 2vw, 2rem);
  font-weight: 700;
}

.page-heading p {
  margin: 0.3rem 0 0;
  color: var(--app-muted);
}

.card-panel {
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 6px 24px rgba(25, 75, 88, 0.07);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--app-border);
}

.toolbar .search-field {
  flex: 1 1 280px;
}

.toolbar .form-check {
  margin-bottom: 0.55rem;
}

.client-table-wrap {
  overflow-x: auto;
}

.project-table-wrap {
  overflow-x: auto;
}

.resource-table-wrap {
  overflow-x: auto;
}

.invoice-table-wrap {
  overflow-x: auto;
}

.receipt-table-wrap {
  overflow-x: auto;
}

.cost-table-wrap {
  overflow-x: auto;
}

.client-table {
  min-width: 1550px;
  margin: 0;
}

.project-table {
  min-width: 2550px;
  margin: 0;
}

.resource-table {
  min-width: 1850px;
  margin: 0;
}

.invoice-table {
  min-width: 4100px;
  margin: 0;
}

.receipt-table {
  min-width: 2450px;
  margin: 0;
}

.cost-table {
  min-width: 3900px;
  margin: 0;
}

.client-table thead th,
.project-table thead th,
.resource-table thead th,
.invoice-table thead th,
.receipt-table thead th {
  padding: 0.75rem;
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: var(--app-teal-800);
  font-size: 0.82rem;
  font-weight: 650;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.cost-table thead th {
  padding: 0.75rem;
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: var(--app-teal-800);
  font-size: 0.82rem;
  font-weight: 650;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.client-table tbody td,
.project-table tbody td,
.resource-table tbody td,
.invoice-table tbody td,
.receipt-table tbody td {
  padding: 0.7rem 0.75rem;
  border-color: var(--app-border);
  font-size: 0.86rem;
  vertical-align: middle;
}

.cost-table tbody td {
  padding: 0.7rem 0.75rem;
  border-color: var(--app-border);
  font-size: 0.86rem;
  vertical-align: middle;
}

.client-table tbody tr:nth-child(even) td,
.project-table tbody tr:nth-child(even) td,
.resource-table tbody tr:nth-child(even) td {
  background: #f4f8f9;
}

.client-table tbody tr.archived-row td,
.project-table tbody tr.archived-row td,
.resource-table tbody tr.archived-row td {
  color: #78868a;
  background: #f1f2f2;
}

.client-code {
  color: #164fbe;
  font-weight: 650;
  text-decoration: none;
}

.client-code:hover {
  text-decoration: underline;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
}

.status-active {
  color: #17613a;
  background: #dff4e8;
}

.status-archived {
  color: #6c4a10;
  background: #f6eaca;
}

.empty-state {
  padding: 3rem 1rem;
  color: var(--app-muted);
  text-align: center;
}

.form-card {
  max-width: 1050px;
  padding: clamp(1rem, 3vw, 2rem);
}

.project-form-card {
  max-width: 1220px;
}

.resource-form-card {
  max-width: 1180px;
}

.invoice-form-card {
  max-width: 1320px;
}

.invoice-plan-form-card {
  max-width: 980px;
}

.receipt-form-card {
  max-width: 1180px;
}

.cost-form-card {
  max-width: 1320px;
}

.cost-autofill-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.cost-autofill-panel > div {
  padding: 0.8rem;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  background: #f7fafb;
}

.cost-autofill-panel span,
.cost-autofill-panel small {
  display: block;
  color: var(--app-muted);
}

.cost-autofill-panel strong {
  display: block;
  margin: 0.15rem 0;
}

.cost-payment-unpaid {
  color: #842029;
  background: #f8d7da;
}

.cost-payment-partially-paid {
  color: #664d03;
  background: #fff3cd;
}

.cost-payment-paid {
  color: #0f5132;
  background: #d1e7dd;
}

@media (max-width: 900px) {
  .cost-autofill-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.form-section-title {
  margin: 1.25rem 0 0.8rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--app-border);
  color: var(--app-teal-800);
  font-size: 1rem;
  font-weight: 700;
}

.form-label {
  color: #294750;
  font-weight: 600;
}

.validation-summary-errors {
  padding: 0.8rem 1rem;
  border: 1px solid #f1aeb5;
  border-radius: 0.5rem;
  color: #842029;
  background: #f8d7da;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.2rem;
}

.validation-summary-valid {
  display: none;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus {
  border-color: var(--app-teal-700);
  box-shadow: 0 0 0 0.2rem rgba(47, 114, 130, 0.2);
}

.btn-primary {
  border-color: var(--app-teal-800);
  background: var(--app-teal-800);
}

.btn-primary:hover {
  border-color: var(--app-teal-900);
  background: var(--app-teal-900);
}

.field-note {
  margin-top: 0.3rem;
  color: var(--app-muted);
  font-size: 0.8rem;
}

.action-cell {
  white-space: nowrap;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.negative-value {
  color: #a02929;
}

.calculated-field {
  color: #234b57;
  background: #edf4f5;
  font-weight: 650;
}

.client-autofill-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 0.6rem;
  background: var(--app-border);
}

.client-autofill-panel > div {
  min-width: 0;
  padding: 0.75rem;
  background: #f7fafb;
}

.client-autofill-panel span {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--app-muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.client-autofill-panel strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 650;
}

.project-status {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

.project-status-active {
  color: #17613a;
  background: #dff4e8;
}

.project-status-completed {
  color: #18527a;
  background: #deeffa;
}

.project-status-on-hold,
.project-status-lead {
  color: #74510a;
  background: #fff0c9;
}

.project-status-cancelled {
  color: #8a2b2b;
  background: #f9dddd;
}

.calculation-note {
  margin-top: 0.8rem;
  color: var(--app-muted);
  font-size: 0.82rem;
}

.invoice-type-toggle {
  margin: 0;
  padding: 0;
  border: 0;
}

.invoice-type-toggle legend {
  margin-bottom: 0.65rem;
  color: var(--app-teal-800);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.invoice-type-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.invoice-type-option {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border: 2px solid var(--app-border);
  border-radius: 0.7rem;
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.invoice-type-option:has(input:checked).invoice-type-tax {
  border-color: #4aa675;
  background: #edf9f2;
}

.invoice-type-option:has(input:checked).invoice-type-proforma {
  border-color: #4a8fc1;
  background: #edf6fc;
}

.invoice-type-option input {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
}

.invoice-type-option strong,
.invoice-type-option small {
  display: block;
}

.invoice-type-option strong {
  color: var(--app-ink);
}

.invoice-type-option small {
  margin-top: 0.15rem;
  color: var(--app-muted);
}

.invoice-autofill-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  background: var(--app-border);
}

.invoice-autofill-panel > div {
  min-width: 0;
  padding: 0.75rem;
  background: #f7fafb;
}

.invoice-autofill-panel span,
.invoice-calculation-grid span,
.invoice-balance-preview span,
.invoice-summary-card span,
.invoice-plan-stats span,
.invoice-plan-footer span {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--app-muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.invoice-autofill-panel strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.invoice-calculation-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}

.invoice-calculation-grid > div {
  padding: 0.8rem;
  border: 1px solid var(--app-border);
  border-radius: 0.6rem;
  background: #f7fafb;
}

.invoice-calculation-grid strong {
  display: block;
  color: #234b57;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.invoice-calculation-grid .calculation-primary {
  border-color: #9fc4cc;
  background: #eaf4f6;
}

.invoice-balance-preview {
  display: flex;
  gap: 0.65rem 1rem;
  align-items: center;
  margin-top: 1.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid #b8d1d6;
  border-radius: 0.65rem;
  background: #eef6f7;
}

.invoice-balance-preview span {
  margin: 0;
}

.invoice-balance-preview strong {
  color: var(--app-teal-900);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.invoice-balance-preview small {
  margin-left: auto;
  color: var(--app-muted);
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.receipt-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.receipt-toolbar > div:not(.search-field):not(.form-check) {
  min-width: 175px;
}

.receipt-autofill-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-top: 1rem;
  overflow: hidden;
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  background: var(--app-border);
}

.receipt-autofill-panel > div {
  min-width: 0;
  padding: 0.8rem;
  background: #f7fafb;
}

.receipt-autofill-panel span {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--app-muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.receipt-autofill-panel strong,
.receipt-autofill-panel small {
  display: block;
  overflow-wrap: anywhere;
}

.receipt-autofill-panel strong {
  color: #234b57;
  font-size: 0.92rem;
}

.receipt-autofill-panel small {
  margin-top: 0.1rem;
  color: var(--app-muted);
}

.receipt-table tbody tr:nth-child(even) td {
  background: #f4f8f9;
}

.receipt-table tbody tr.receipt-row-cancelled td {
  color: #7c8588;
  background: #f0f1f2;
}

.invoice-summary-card {
  padding: 1rem;
  border: 1px solid var(--app-border);
  border-radius: 0.7rem;
  background: #fff;
  box-shadow: 0 4px 16px rgba(25, 75, 88, 0.05);
}

.invoice-summary-card strong {
  display: block;
  margin: 0.1rem 0;
  color: var(--app-teal-900);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.invoice-summary-card small {
  color: var(--app-muted);
}

.invoice-summary-warning {
  border-color: #e9cb8d;
  background: #fffaf0;
}

.invoice-toolbar > div:not(.search-field):not(.form-check) {
  min-width: 190px;
}

.invoice-table tbody tr.invoice-row-tax td {
  background: #f0faf4;
}

.invoice-table tbody tr.invoice-row-tax:nth-child(even) td {
  background: #e8f6ee;
}

.invoice-table tbody tr.invoice-row-proforma td {
  background: #f0f7fc;
}

.invoice-table tbody tr.invoice-row-proforma:nth-child(even) td {
  background: #e7f2fa;
}

.invoice-table tbody tr.invoice-row-cancelled td {
  color: #7c8588;
  background: #f0f1f2;
}

.invoice-type-badge,
.invoice-status,
.invoice-plan-frequency {
  display: inline-block;
  padding: 0.22rem 0.52rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.invoice-type-badge-tax {
  color: #17613a;
  background: #d9f2e4;
}

.invoice-type-badge-proforma {
  color: #185b88;
  background: #dceefa;
}

.invoice-number {
  color: #164fbe;
  font-weight: 700;
  text-decoration: none;
}

.invoice-number:hover {
  text-decoration: underline;
}

.invoice-status-paid {
  color: #17613a;
  background: #d9f2e4;
}

.invoice-status-overdue,
.invoice-status-cancelled {
  color: #8a2b2b;
  background: #f9dddd;
}

.invoice-status-partially-paid,
.invoice-status-outstanding {
  color: #74510a;
  background: #fff0c9;
}

.invoice-status-proforma {
  color: #185b88;
  background: #dceefa;
}

.invoice-status-converted {
  color: #52407a;
  background: #e9e1f8;
}

.invoice-plan-section {
  margin-top: 1.35rem;
}

.invoice-plan-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  margin-bottom: 0.8rem;
}

.invoice-plan-heading h2 {
  margin: 0;
  color: var(--app-teal-900);
  font-size: 1.25rem;
}

.invoice-plan-heading p {
  margin: 0.2rem 0 0;
  color: var(--app-muted);
}

.invoice-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.invoice-plan-card {
  padding: 1rem;
  border: 1px solid #bfd9ea;
  border-radius: 0.75rem;
  background: #f5faff;
  box-shadow: 0 5px 18px rgba(38, 101, 143, 0.07);
}

.invoice-plan-card-header,
.invoice-plan-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.invoice-plan-card-header > div > span {
  color: #497184;
  font-size: 0.76rem;
  font-weight: 700;
}

.invoice-plan-card-header h3 {
  margin: 0.15rem 0 0;
  color: #164f70;
  font-size: 1.05rem;
}

.invoice-plan-card-header p {
  margin: 0.1rem 0 0;
  color: var(--app-muted);
  font-size: 0.84rem;
}

.invoice-plan-frequency {
  color: #185b88;
  background: #dceefa;
}

.invoice-plan-progress {
  height: 0.55rem;
  margin: 0.9rem 0;
  background: #dfeaf1;
}

.invoice-plan-progress .progress-bar {
  background: #4288b5;
}

.invoice-plan-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.invoice-plan-stats > div {
  min-width: 0;
  padding: 0.65rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.8);
}

.invoice-plan-stats strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.invoice-plan-footer {
  align-items: center;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid #d4e4ee;
}

.invoice-plan-footer strong {
  display: block;
  color: #174b59;
}

.conversion-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 1rem;
  max-width: 1050px;
}

.conversion-summary,
.conversion-form {
  padding: 1.25rem;
}

.conversion-summary h2 {
  margin: 0.7rem 0 1rem;
  color: var(--app-teal-900);
  font-size: 1.25rem;
}

.conversion-summary dl,
.conversion-summary dd {
  margin: 0;
}

.conversion-summary dl > div {
  padding: 0.65rem 0;
  border-top: 1px solid var(--app-border);
}

.conversion-summary dt {
  color: var(--app-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.conversion-summary dd {
  margin-top: 0.15rem;
  font-weight: 650;
}

.yes-no-badge {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  text-align: center;
}

.yes-badge {
  color: #17613a;
  background: #dff4e8;
}

.no-badge {
  color: #5d6467;
  background: #e9edef;
}

.tds-layout {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.tds-form-card {
  padding: 1.25rem;
}

.tds-form-card h2 {
  margin: 0 0 1rem;
  color: var(--app-teal-900);
  font-size: 1.2rem;
  font-weight: 700;
}

.master-table thead th {
  padding: 0.75rem;
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  background: var(--app-teal-800);
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}

.master-table tbody td {
  padding: 0.75rem;
  border-color: var(--app-border);
  vertical-align: middle;
}

.master-table tbody tr:nth-child(even) td {
  background: #f4f8f9;
}

.report-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 380px));
  gap: 1rem;
}

.report-link-card {
  display: block;
  padding: 1.35rem;
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  color: inherit;
  background: #fff;
  box-shadow: 0 8px 24px rgba(25, 74, 86, 0.08);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.report-link-card:hover {
  color: inherit;
  box-shadow: 0 12px 30px rgba(25, 74, 86, 0.14);
  transform: translateY(-2px);
}

.report-link-card h2 {
  margin: 0.35rem 0 0.5rem;
  color: var(--app-teal-900);
  font-size: 1.3rem;
}

.report-link-card p { color: var(--app-muted); }
.report-link-card strong,
.report-card-kicker { color: var(--app-teal-700); }
.report-card-kicker { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }

.report-heading { align-items: end; }
.report-breadcrumb { margin-bottom: 0.35rem; color: var(--app-muted); font-size: 0.85rem; }
.report-breadcrumb span { padding: 0 0.45rem; }
.report-year-filter { min-width: 260px; }

.report-definition-note {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--app-teal-600);
  border-radius: 0.25rem;
  background: #f7fbfc;
}

.report-table-panel { padding: 0; overflow: hidden; }
.report-table-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
}
.report-table-heading h2 { margin: 0; color: var(--app-teal-900); font-size: 1.2rem; }
.report-table-heading p { margin: 0.2rem 0 0; color: var(--app-muted); font-size: 0.82rem; }
.report-table-heading > span { color: var(--app-muted); font-weight: 650; }
.tax-report-table {
  width: 100%;
  margin-bottom: 0;
  table-layout: fixed;
}

.tds-tracker-table col.tax-month-column { width: 18%; }
.tds-tracker-table col.tax-money-column { width: 27.333%; }
.gst-summary-table col.tax-month-column { width: 13%; }
.tax-review-table { min-width: 1000px; }
.tax-review-table th.number-cell { text-align: right !important; }
.gst-summary-table col.tax-money-column { width: 14.5%; }
.receivables-ageing-table col.ageing-bucket-column { width: 34%; }
.receivables-ageing-table col.ageing-money-column { width: 38%; }
.receivables-ageing-table col.ageing-count-column { width: 28%; }

.receivables-ageing-table tfoot .ageing-overdue-total th {
  border-top: 1px solid var(--app-border);
  color: #8a5a00;
  background: #fff8e8;
}

.tax-report-table thead th {
  line-height: 1.2;
  white-space: normal;
}

.tax-report-table thead th:not(:first-child),
.tax-report-table tbody td:not(:first-child),
.tax-report-table tfoot th:not(:first-child) {
  text-align: center !important;
}

.tax-report-table thead th + th {
  border-left: 1px solid rgba(255, 255, 255, 0.22);
}

.tax-report-table tbody td + td,
.tax-report-table tfoot th + th {
  border-left: 1px solid var(--app-border);
}

.tax-report-table tbody td,
.tax-report-table tfoot th {
  font-variant-numeric: tabular-nums;
}

.tax-report-table tfoot th {
  padding: 0.85rem 0.75rem;
  border-top: 2px solid var(--app-teal-700);
  color: var(--app-teal-900);
  background: #edf5f6;
}

.report-wide-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.report-data-table {
  width: 100%;
  margin: 0;
  table-layout: fixed;
}

.report-data-table thead th,
.report-data-table tbody td,
.report-data-table tfoot th {
  box-sizing: border-box;
  vertical-align: middle;
}

.report-data-table thead th.number-cell,
.report-data-table tfoot th.number-cell {
  text-align: right;
}

.pnl-table {
  min-width: 1760px;
}

.pnl-table col.pnl-project-id { width: 90px; }
.pnl-table col.pnl-project-name { width: 155px; }
.pnl-table col.pnl-client { width: 145px; }
.pnl-table col.pnl-type { width: 120px; }
.pnl-table col.pnl-status { width: 95px; }
.pnl-table col.pnl-money { width: 135px; }
.pnl-table col.pnl-record { width: 90px; }

.pnl-table thead th {
  line-height: 1.2;
  white-space: normal;
}

.pnl-table tbody td,
.pnl-table tfoot th {
  font-variant-numeric: tabular-nums;
}

.pnl-table tfoot th,
.client-summary-table tfoot th {
  padding: 0.85rem 0.75rem;
  border-top: 2px solid var(--app-teal-700);
  color: var(--app-teal-900);
  background: #edf5f6;
  white-space: nowrap;
}

.client-summary-table {
  min-width: 1500px;
}

.client-summary-table col.client-summary-id { width: 90px; }
.client-summary-table col.client-summary-name { width: 170px; }
.client-summary-table col.client-summary-projects { width: 80px; }
.client-summary-table col.client-summary-money { width: 135px; }
.client-summary-table col.client-summary-record { width: 90px; }

.client-summary-table thead th {
  line-height: 1.2;
  white-space: normal;
}

.client-summary-table tbody td,
.client-summary-table tfoot th {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .tds-layout {
    grid-template-columns: 1fr;
  }

  .tds-form-card {
    max-width: none;
  }

  .client-autofill-panel {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-summary-grid,
  .invoice-plan-grid,
  .receipt-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-autofill-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receipt-autofill-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-calculation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .conversion-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .client-autofill-panel {
    grid-template-columns: 1fr;
  }

  .invoice-type-options,
  .invoice-summary-grid,
  .invoice-plan-grid,
  .invoice-autofill-panel,
  .invoice-calculation-grid,
  .invoice-plan-stats,
  .receipt-summary-grid,
  .receipt-autofill-panel {
    grid-template-columns: 1fr;
  }

  .invoice-balance-preview {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-balance-preview small {
    margin-left: 0;
  }
}

/* Central Finance workspace */
.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  width: 260px;
  overflow-y: auto;
  color: #fff;
  background: linear-gradient(180deg,var(--app-teal-900) 0%,#123f4b 100%);
  box-shadow: 5px 0 24px rgba(14,52,62,.16);
}
.app-sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; min-height: 78px; padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.12); }
.app-sidebar-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; color: #fff; text-decoration: none; }
.app-sidebar-brand:hover { color: #fff; }
.app-sidebar-brand-mark { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: .65rem; color: var(--app-teal-900); background: #fff; font-size: 1.3rem; font-weight: 800; }
.app-sidebar-brand strong,.app-sidebar-brand small { display: block; }
.app-sidebar-brand strong { font-size: 1.06rem; line-height: 1.15; }
.app-sidebar-brand small { margin-top: .13rem; color: rgba(255,255,255,.72); font-size: .72rem; letter-spacing: .02em; }
.app-sidebar-toggler { display: none; padding: .25rem .4rem; border-color: rgba(255,255,255,.32); }
.app-sidebar-toggler .navbar-toggler-icon { filter: brightness(0) invert(1); }
.app-sidebar-navigation { display: block !important; padding: .75rem .7rem 1.5rem; }
.app-sidebar-group { padding: .45rem 0 .65rem; }
.app-sidebar-label { display: block; padding: .25rem .75rem .38rem; color: rgba(255,255,255,.48); font-size: .69rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.app-sidebar-link { position: relative; display: flex; align-items: center; min-height: 40px; margin: .08rem 0; padding: .58rem .75rem .58rem 1rem; border-radius: .48rem; color: rgba(255,255,255,.82); font-size: .91rem; line-height: 1.2; text-decoration: none; transition: background-color .15s ease,color .15s ease; }
.app-sidebar-link:hover { color: #fff; background: rgba(255,255,255,.09); }
.app-sidebar-link.active { color: #fff; background: rgba(255,255,255,.16); font-weight: 700; }
.app-sidebar-link.active::before { position: absolute; inset: .55rem auto .55rem 0; width: 3px; border-radius: 3px; background: #7fd6df; content: ""; }
.app-main { min-width: 0; min-height: 100vh; margin-left: 260px; }
.app-main-content { width: 100%; padding: 1.5rem; }
.app-main > .demo-banner { margin: 0; }
.finance-heading-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.finance-filter-panel { margin-bottom: 1rem; padding: 1rem; }
.finance-filter-grid { display: grid; grid-template-columns: repeat(6,minmax(130px,1fr)); gap: .75rem; align-items: end; }
.finance-filter-actions { display: flex; gap: .5rem; }
.finance-kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .85rem; margin-bottom: .85rem; }
.finance-kpi { min-height: 126px; padding: 1rem 1.1rem; border: 1px solid var(--app-border); border-radius: .75rem; background: #fff; box-shadow: 0 6px 20px rgba(25,75,88,.06); }
.finance-kpi span,.finance-tax-card span { display: block; color: var(--app-muted); font-size: .76rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
.finance-kpi strong,.finance-tax-card strong { display: block; margin: .35rem 0 .2rem; color: var(--app-teal-900); font-size: clamp(1.25rem,2vw,1.65rem); font-variant-numeric: tabular-nums; }
.finance-kpi small,.finance-tax-card p { color: var(--app-muted); }
.finance-positive { color: #147354 !important; }
.finance-negative { color: #b64040 !important; }
.finance-tax-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .85rem; margin-bottom: .85rem; }
.finance-tax-card { padding: 1rem; }
.finance-tax-card dl { margin: .65rem 0 0; }
.finance-tax-card dl div { display: flex; justify-content: space-between; gap: .75rem; padding: .25rem 0; border-top: 1px solid #edf2f3; }
.finance-tax-card dt { color: var(--app-muted); font-weight: 500; }
.finance-tax-card dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.finance-chart-grid,.finance-detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .85rem; margin-bottom: .85rem; }
.finance-chart-card,.finance-list-card { min-width: 0; overflow: hidden; }
.finance-chart-card { padding: 0 1rem 1rem; }
.finance-chart-card canvas { display: block; width: 100%; }
.finance-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; }
.finance-chart-card .finance-section-heading { padding-left: 0; padding-right: 0; }
.finance-section-heading h2 { margin: 0; color: var(--app-teal-900); font-size: 1.08rem; }
.finance-section-heading p { margin: .15rem 0 0; color: var(--app-muted); font-size: .82rem; }
.finance-section-heading a { white-space: nowrap; }
.finance-compact-table { margin: 0; }
.finance-compact-table thead th { padding: .65rem .8rem; color: #fff; background: var(--app-teal-800); font-size: .78rem; white-space: nowrap; }
.finance-compact-table td { padding: .7rem .8rem; border-color: var(--app-border); vertical-align: middle; }
.finance-compact-table tbody tr:nth-child(even) td { background: #f6f9fa; }
.finance-compact-table small { display: block; color: var(--app-muted); font-size: .74rem; }
.finance-due { display: inline-block; padding: .18rem .42rem; border-radius: .3rem; background: #edf5f6; white-space: nowrap; }
.finance-due.overdue { color: #9d2e2e; background: #fdecec; }
.finance-due.due_today,.finance-due.due_7_days { color: #875500; background: #fff3d6; }
.finance-account-table { min-width: 1200px; }
.finance-upcoming-table { min-width: 1150px; }
.finance-payment-table { min-width: 1500px; }
.finance-ledger-table { min-width: 1750px; }
.finance-ledger-table small { display: block; margin-top: .15rem; color: var(--app-muted); white-space: nowrap; }
.finance-ledger-filter { display: grid; grid-template-columns: 145px 145px minmax(230px,1fr) minmax(280px,1.5fr) auto auto; gap: .75rem; align-items: end; }
.finance-ledger-check { align-self: center; margin-top: 1.6rem; white-space: nowrap; }
.finance-reconcile-form { display: grid; grid-template-columns: 145px 190px auto; gap: .35rem; align-items: center; min-width: 450px; }
.finance-entry-card { padding: 1.1rem; }
.finance-entry-card h2 { color: var(--app-teal-900); font-size: 1.15rem; }
.finance-entry-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 1200px) {
  .finance-filter-grid { grid-template-columns: repeat(3,minmax(150px,1fr)); }
  .finance-kpi-grid,.finance-tax-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .finance-ledger-filter { grid-template-columns: repeat(3,minmax(180px,1fr)); }
}
@media (max-width: 760px) {
  .finance-filter-grid,.finance-kpi-grid,.finance-tax-grid,.finance-chart-grid,.finance-detail-grid { grid-template-columns: 1fr; }
  .finance-heading { flex-direction: column; }
  .finance-entry-grid { grid-template-columns: 1fr; }
  .finance-ledger-filter { grid-template-columns: 1fr; }
  .finance-ledger-check { margin-top: 0; }
}

@media (max-width: 991.98px) {
  .app-sidebar { position: sticky; inset: 0 0 auto; width: 100%; max-height: 100vh; overflow-y: auto; }
  .app-sidebar-brand-row { min-height: 64px; padding: .7rem 1rem; }
  .app-sidebar-brand-mark { flex-basis: 34px; width: 34px; height: 34px; }
  .app-sidebar-toggler { display: block; }
  .app-sidebar-navigation { display: none !important; max-height: calc(100vh - 64px); padding: .35rem .7rem 1rem; overflow-y: auto; }
  .app-sidebar-navigation.show { display: block !important; }
  .app-sidebar-group { padding: .25rem 0 .35rem; }
  .app-main { margin-left: 0; }
  .app-main-content { padding: 1rem; }
}

#itemsForm .invoice-autofill-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.payout-project-table { min-width: 1050px; }
.payout-project-table thead th { white-space: normal; max-width: 140px; vertical-align: bottom; }
.payout-project-table th:first-child, .payout-project-table td:first-child { min-width: 210px; }
.payout-project-table small { display: block; color: var(--app-muted); }
@media (max-width: 600px) {
  #itemsForm .invoice-autofill-panel { grid-template-columns: 1fr; }
}
