body.mar-active {
  --mar-ink: #102033;
  --mar-muted: #66758b;
  --mar-line: #d7e1ee;
  --mar-soft: #f5f8fc;
  --mar-blue: #255da8;
  --mar-teal: #0f7b72;
  --mar-amber: #9a6217;
}

body.mar-active .content-area {
  background: linear-gradient(180deg, #f7f9fc 0%, #f3f6fa 100%);
}

.mar-page {
  display: grid;
  gap: 14px !important;
}

.mar-page .mar-panel {
  border: 1px solid var(--mar-line) !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  box-shadow: 0 16px 36px -30px rgba(16, 32, 51, 0.48) !important;
}

.mar-clean-header {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--mar-line);
  border-radius: 8px;
  box-shadow: 0 14px 32px -28px rgba(16, 32, 51, 0.45);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 18px 20px;
}

.mar-clean-title {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.mar-clean-title a {
  align-items: center;
  background: #eef7f3;
  border: 1px solid #cfe4dd;
  border-radius: 8px;
  color: var(--mar-teal);
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  min-height: 36px;
  padding: 0 11px;
  text-decoration: none;
  white-space: nowrap;
}

body[data-mar-route="/master"] .mar-clean-title a {
  display: none;
}

.mar-clean-title p {
  color: var(--mar-teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.mar-clean-title h1 {
  color: var(--mar-ink);
  font-size: 25px;
  line-height: 1.12;
  margin: 0;
}

.mar-clean-tools {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.mar-clean-stats,
.mar-clean-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mar-clean-stats span {
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  color: var(--mar-muted);
  display: grid;
  font-size: 11px;
  min-width: 82px;
  padding: 7px 10px;
  text-transform: uppercase;
}

.mar-clean-stats b {
  color: var(--mar-ink);
  font-size: 18px;
  line-height: 1.1;
}

.mar-clean-actions button {
  background: var(--mar-blue) !important;
  border: 1px solid #214f91 !important;
  border-radius: 8px !important;
  color: #ffffff !important;
  min-height: 36px !important;
  padding: 8px 12px !important;
}

.mar-clean-actions button[data-mar-action="Clear Filters"],
.mar-clean-actions button[data-mar-action="Refresh"] {
  background: #ffffff !important;
  border-color: var(--mar-line) !important;
  color: var(--mar-ink) !important;
}

.mar-page > .premium-page-header,
.mar-page > .master-toolbar.premium-page-header,
.mar-page > .cmr-hero.premium-page-header {
  position: relative;
  display: grid !important;
  gap: 12px !important;
  min-height: 0 !important;
  padding: 18px 20px !important;
  overflow: hidden;
}

.mar-page > .premium-page-header::before,
.mar-page > .cmr-hero.premium-page-header::before {
  height: 4px !important;
  background: linear-gradient(90deg, var(--mar-blue), var(--mar-teal), #59a66f) !important;
}

.mar-page .module-hero,
.mar-page .master-hero,
.mar-page .cmr-hero {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 14px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.mar-page h2 {
  margin: 0 !important;
  color: var(--mar-ink) !important;
  font-size: 24px !important;
  line-height: 1.1 !important;
  letter-spacing: 0 !important;
}

.mar-page .module-hero p,
.mar-page .master-hero p,
.mar-page .cmr-hero p,
.mar-page > .premium-page-header p.muted,
.mar-page > .master-toolbar p.muted,
.mar-page .premium-page-brief,
.mar-page .module-subtitle,
.mar-page .premium-quiet-description {
  display: none !important;
}

.mar-page .kpi-strip,
.mar-page .cmr-kpi-grid {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}

.mar-page .kpi-pill,
.mar-page .cmr-kpi {
  min-width: 112px !important;
  padding: 9px 12px !important;
  border: 1px solid #c9d8eb !important;
  border-radius: 8px !important;
  background: #f7fbff !important;
  color: #153d73 !important;
  box-shadow: none !important;
}

.mar-page .kpi-pill:nth-child(2n),
.mar-page .cmr-kpi:nth-child(2n) {
  background: #f3fbf8 !important;
  border-color: #bfddd4 !important;
  color: #0f5c53 !important;
}

.mar-page .kpi-pill:nth-child(3n),
.mar-page .cmr-kpi:nth-child(3n) {
  background: #fff9ef !important;
  border-color: #ead7ae !important;
  color: var(--mar-amber) !important;
}

.mar-page .kpi-pill span,
.mar-page .cmr-kpi span {
  color: currentColor !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase !important;
}

.mar-page .kpi-pill strong,
.mar-page .cmr-kpi strong {
  color: currentColor !important;
  font-size: 20px !important;
  line-height: 1.05 !important;
}

.mar-page .compact-actions,
.mar-page .toolbar-row,
.mar-page .cmr-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
}

.mar-page button,
.mar-page .ghost-btn,
.mar-page .action-primary,
.mar-page .action-secondary {
  min-height: 34px !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  letter-spacing: 0 !important;
}

.mar-page .master-hero button,
.mar-page .cmr-hero button {
  display: none !important;
}

.mar-page .action-primary,
.mar-page button:not(.ghost-btn):not(.premium-action-trigger) {
  border-color: #1d4f91 !important;
  background: #214f91 !important;
  color: #ffffff !important;
}

.mar-page .ghost-btn,
.mar-page .action-secondary,
.mar-page button.premium-action-trigger {
  border: 1px solid #cbd8ea !important;
  background: #ffffff !important;
  color: #203a5f !important;
}

.mar-page .premium-filter-console {
  border-color: var(--mar-line) !important;
  background: #ffffff !important;
}

.mar-page input,
.mar-page select,
.mar-page textarea {
  border-color: #cbd8ea !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: var(--mar-ink) !important;
}

.mar-page .mar-control {
  min-height: 38px !important;
}

.mar-page .mar-table {
  border-radius: 8px !important;
  border-color: var(--mar-line) !important;
  background: #ffffff !important;
}

.mar-page .mar-clean-table-wrap {
  overflow: auto !important;
}

.mar-page table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.mar-page thead th {
  height: 36px !important;
  border-bottom: 1px solid #ccd9eb !important;
  background: #f4f7fb !important;
  color: #50627c !important;
  font-size: 10px !important;
  letter-spacing: .08em !important;
}

.mar-page tbody td {
  border-bottom: 1px solid #e5ebf3 !important;
  color: #172944 !important;
  font-size: 13px !important;
  vertical-align: middle !important;
}

.mar-page tbody tr:hover td {
  background: #f8fbff !important;
}

.mar-page .premium-empty-state {
  min-height: 120px !important;
  color: var(--mar-muted) !important;
}

.mar-page .premium-empty-state span {
  display: none !important;
}

.mar-page.module-task-templates {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.mar-page.module-task-templates > .premium-page-header,
.mar-page.module-task-templates > .panel:nth-last-child(1) {
  grid-column: 1 / -1;
}

.mar-page.module-master-overview .master-card-grid,
.mar-page.module-master-overview .overview-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  gap: 12px !important;
}

body[data-mar-route="/master"] .mar-page > .master-hero,
body[data-mar-route="/master/financial-years"] .mar-page > .premium-page-header,
body[data-mar-route="/master/clients"] .mar-page > .cmr-hero {
  display: none !important;
}

body[data-mar-route="/master"] .mar-page > .panel:not(.mar-clean-header):first-of-type {
  display: none !important;
}

body[data-mar-route="/master/access"] .mar-page > .compact-toolbar-panel {
  padding: 12px !important;
}

body[data-mar-route="/master/access"] .compact-toolbar-header,
body[data-mar-route="/master/access"] .compact-toolbar-body .toolbar-right {
  display: none !important;
}

body[data-mar-route="/master/access"] .segmented {
  margin: 0 !important;
}

body[data-mar-route="/master/clients"] .cmr-filter-panel {
  padding: 12px !important;
}

body[data-mar-route="/master/clients"] .cmr-filter-row {
  align-items: center !important;
}

body[data-mar-route="/master/clients"] .cmr-actions {
  display: none !important;
}

body.mar-active .sidebar-subnav a[href="/master"] {
  display: none !important;
}

body[data-mar-route="/master/financial-years"] .premium-empty-state span {
  display: none !important;
}

@media (max-width: 900px) {
  .mar-clean-header {
    align-items: stretch;
    flex-direction: column;
  }

  .mar-clean-tools,
  .mar-clean-actions,
  .mar-clean-stats {
    justify-content: flex-start;
  }

  .mar-page.module-task-templates {
    grid-template-columns: 1fr;
  }

  .mar-page .module-hero,
  .mar-page .master-hero,
  .mar-page .cmr-hero {
    align-items: flex-start !important;
    flex-direction: column !important;
  }

  .mar-page .kpi-strip,
  .mar-page .cmr-kpi-grid {
    justify-content: flex-start !important;
  }
}

@media (max-width: 620px) {
  .mar-clean-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .mar-clean-title h1 {
    font-size: 22px;
  }

  .mar-clean-stats,
  .mar-clean-actions {
    width: 100%;
  }

  .mar-clean-stats span,
  .mar-clean-actions button {
    flex: 1 1 130px;
  }
}
