/*
 * NeuroWerk 3.2.1 – terminal layout and contrast correction layer.
 * Loaded after every terminal and embedded module stylesheet.
 */
:root {
  --nw-terminal-topbar-height: 84px;
  --nw-terminal-sidebar-width: 272px;
  --nw-terminal-control-height: 46px;
  --nw-terminal-control-height-small: 40px;
  --nw-terminal-content-width: 1540px;
  --nw-terminal-text-on-accent: #ffffff;
  --nw-terminal-link: #7f172c;
  --nw-terminal-code-bg: #f0e9ec;
  --nw-terminal-overlay: rgba(20, 13, 16, .58);
  --nw-terminal-table-head-text: #61575b;
}

html[data-nw-theme="dark"] {
  --nw-terminal-link: #ff8ca1;
  --nw-terminal-code-bg: #2b2024;
  --nw-terminal-overlay: rgba(0, 0, 0, .72);
  --nw-terminal-table-head-text: #c8bdc1;
}

/* ---------- Global layout resilience ---------- */
.nw-terminal-body,
.nw-terminal-body button,
.nw-terminal-body input,
.nw-terminal-body select,
.nw-terminal-body textarea {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.nw-terminal-body :where(h1,h2,h3,h4,h5,h6,p,li,dt,dd,th,td,label,legend,small,strong,span,a,button) {
  overflow-wrap: anywhere;
}

.nw-terminal-body :where(img,svg,video,canvas,iframe) {
  max-width: 100%;
}

.nw-terminal-body :where(.nw-terminal-main,.nw-terminal-card,.nw-terminal-grid > *,form,fieldset,section,article,aside,div) {
  min-width: 0;
}

.nw-terminal-main {
  width: 100%;
  overflow: visible;
}

.nw-terminal-main > * {
  width: min(100%, var(--nw-terminal-content-width));
  margin-left: auto;
  margin-right: auto;
}

.nw-terminal-main > .nw-terminal-loading,
.nw-terminal-main > script,
.nw-terminal-main > style {
  width: auto;
}

.nw-terminal-main :where(a:not(.nw-terminal-primary):not(.nw-terminal-secondary):not(.nw-terminal-danger):not(.button):not(.button-primary)) {
  color: var(--nw-terminal-link);
}

.nw-terminal-main :where(code,kbd,pre) {
  color: var(--nw-terminal-ink);
  background: var(--nw-terminal-code-bg);
  border-color: var(--nw-terminal-line);
}

.nw-terminal-main pre {
  max-width: 100%;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--nw-terminal-line);
  white-space: pre-wrap;
}

/* ---------- Topbar: larger, stable and non-overlapping ---------- */
.nw-terminal-topbar {
  min-height: var(--nw-terminal-topbar-height);
  height: auto;
  padding: 12px clamp(16px, 2.1vw, 30px);
  gap: 18px;
}

.nw-terminal-topbar-start,
.nw-terminal-topbar-actions,
.nw-terminal-user {
  min-width: 0;
}

.nw-terminal-topbar-start {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 12px;
}

.nw-terminal-brand {
  min-width: 0;
  flex: 0 1 auto;
}

.nw-terminal-brand img {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  padding: 6px;
}

.nw-terminal-brand span {
  min-width: 0;
}

.nw-terminal-brand strong {
  display: block;
  max-width: min(34vw, 460px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1.2;
}

.nw-terminal-brand small,
.nw-terminal-user small {
  line-height: 1.35;
}

.nw-terminal-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  gap: 12px;
}

.nw-terminal-menu-toggle,
.nw-terminal-theme-toggle,
.nw-terminal-user > a {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 14px;
  line-height: 1.15;
  font-size: 13px;
  white-space: nowrap;
}

.nw-terminal-theme-toggle {
  font-size: 13px;
}

.nw-terminal-theme-icon {
  flex: 0 0 18px;
}

.nw-terminal-user {
  gap: 13px;
}

.nw-terminal-user > span {
  min-width: 0;
  max-width: 230px;
}

.nw-terminal-user strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Shell and sidebar ---------- */
.nw-terminal-layout {
  grid-template-columns: var(--nw-terminal-sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--nw-terminal-topbar-height));
}

.nw-terminal-sidebar {
  top: var(--nw-terminal-topbar-height);
  height: calc(100vh - var(--nw-terminal-topbar-height));
  overflow: hidden;
}

.nw-terminal-nav {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 28px;
}

.nw-terminal-nav a {
  min-height: 48px;
  padding: 12px 14px;
  line-height: 1.3;
}

.nw-terminal-nav a span {
  flex: 0 0 25px;
}

.nw-terminal-sidebar-foot {
  gap: 12px;
  padding: 15px 18px;
}

/* ---------- View heads, cards and grids ---------- */
.nw-terminal-view-head {
  align-items: flex-start;
  flex-wrap: wrap;
  padding: clamp(22px, 2.5vw, 32px);
  gap: 18px 28px;
}

.nw-terminal-view-head > div:first-child {
  flex: 1 1 500px;
  min-width: 0;
}

.nw-terminal-view-head > :last-child:not(div:first-child) {
  flex: 0 1 auto;
}

.nw-terminal-view-head h1 {
  font-size: clamp(27px, 3vw, 42px);
  line-height: 1.08;
}

.nw-terminal-view-head p:last-child {
  max-width: 920px;
}

.nw-terminal-live,
.nw-terminal-count,
.nw-terminal-version,
.nw-terminal-status,
.nw-terminal-pill {
  max-width: 100%;
  line-height: 1.25;
  white-space: normal;
}

.nw-terminal-grid,
.nw-terminal-dashboard-grid,
.nw-terminal-metric-grid,
.nw-terminal-metrics,
.nw-terminal-commerce-metrics,
.nw-terminal-communication-metrics,
.nw-terminal-finance-metrics,
.nw-terminal-work-metrics {
  align-items: stretch;
}

.nw-terminal-grid > *,
.nw-terminal-dashboard-grid > *,
.nw-terminal-metric-grid > *,
.nw-terminal-metrics > * {
  min-width: 0;
}

.nw-terminal-card {
  width: 100%;
  padding: clamp(18px, 2vw, 26px);
  overflow: visible;
}

.nw-terminal-card h2,
.nw-terminal-card h3 {
  line-height: 1.22;
}

.nw-terminal-card-head,
.nw-terminal-record-head {
  flex-wrap: wrap;
}

.nw-terminal-card-head > div,
.nw-terminal-record-head > div {
  flex: 1 1 380px;
  min-width: 0;
}

.nw-terminal-actions,
.nw-terminal-action-row,
.nw-terminal-row-actions,
.nw-terminal-form-actions,
.nw-terminal-account-actions,
.nw-terminal-user-tools,
.nw-terminal-repair-actions,
.nw-terminal-schedule-nav,
.nw-terminal-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nw-terminal-row-actions form,
.nw-terminal-user-tools form,
.nw-terminal-actions form,
.nw-terminal-repair-actions form {
  min-width: 0;
  margin: 0;
}

/* ---------- All controls: readable and touch-safe ---------- */
.nw-terminal-body :where(
  .nw-terminal-primary,
  .nw-terminal-secondary,
  .nw-terminal-danger,
  .nw-terminal-icon-button,
  .nw-terminal-inline-action button,
  .nw-terminal-main button,
  .nw-terminal-main input[type="submit"],
  .nw-terminal-main input[type="button"],
  .nw-terminal-main .button,
  .nw-terminal-main .button-primary,
  .nw-terminal-main .button-secondary,
  .nw-terminal-main .page-title-action
) {
  min-height: var(--nw-terminal-control-height);
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 5px;
  line-height: 1.25;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  cursor: pointer;
}

.nw-terminal-body :where(.nw-terminal-icon-button) {
  min-width: var(--nw-terminal-control-height);
  padding-left: 11px;
  padding-right: 11px;
}

.nw-terminal-body :where(.nw-terminal-primary,.button-primary) {
  border: 1px solid var(--nw-terminal-red);
  background: var(--nw-terminal-red);
  color: var(--nw-terminal-text-on-accent) !important;
}

.nw-terminal-body :where(.nw-terminal-primary,.button-primary):hover {
  border-color: var(--nw-terminal-red-dark);
  background: var(--nw-terminal-red-dark);
  color: #fff !important;
}

.nw-terminal-body :where(.nw-terminal-secondary,.button,.button-secondary,.page-title-action) {
  border: 1px solid var(--nw-terminal-red);
  background: var(--nw-terminal-surface);
  color: var(--nw-terminal-red) !important;
}

.nw-terminal-body :where(.nw-terminal-secondary,.button,.button-secondary,.page-title-action):hover {
  border-color: var(--nw-terminal-red-dark);
  background: var(--nw-terminal-surface-strong);
  color: var(--nw-terminal-red-dark) !important;
}

html[data-nw-theme="dark"] .nw-terminal-body :where(.nw-terminal-secondary,.button,.button-secondary,.page-title-action):hover {
  color: var(--nw-terminal-red-bright) !important;
}

.nw-terminal-body .nw-terminal-danger {
  border-color: color-mix(in srgb, var(--nw-terminal-bad) 55%, var(--nw-terminal-line));
  color: var(--nw-terminal-bad) !important;
}

.nw-terminal-body :where(
  .nw-terminal-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]),
  .nw-terminal-form select,
  .nw-terminal-form textarea,
  .nw-terminal-main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]),
  .nw-terminal-main select,
  .nw-terminal-main textarea
) {
  min-height: var(--nw-terminal-control-height);
  max-width: 100%;
  padding: 10px 12px;
  line-height: 1.35;
}

.nw-terminal-body textarea {
  min-height: 112px;
  resize: vertical;
}

.nw-terminal-body :where(input,textarea)::placeholder {
  color: color-mix(in srgb, var(--nw-terminal-muted) 82%, transparent);
  opacity: 1;
}

.nw-terminal-body :where(input[type="checkbox"],input[type="radio"]) {
  accent-color: var(--nw-terminal-red);
}

.nw-terminal-body select option {
  background: var(--nw-terminal-input);
  color: var(--nw-terminal-ink);
}

.nw-terminal-form label,
.nw-terminal-filter-grid label {
  color: var(--nw-terminal-ink);
  line-height: 1.35;
}

.nw-terminal-form small,
.nw-terminal-form .description {
  color: var(--nw-terminal-muted);
}

.nw-terminal-form-grid,
.nw-terminal-filter-grid,
.nw-terminal-check-grid,
.nw-terminal-rich-grid {
  min-width: 0;
}

.nw-terminal-form-grid > *,
.nw-terminal-filter-grid > *,
.nw-terminal-check-grid > * {
  min-width: 0;
}

/* ---------- Lists, records and status surfaces ---------- */
.nw-terminal-directory-items > a,
.nw-terminal-work-records > a,
.nw-terminal-work-records > article,
.nw-terminal-communication-list > a,
.nw-terminal-compact-list > a,
.nw-terminal-record-list article,
.nw-terminal-health-list article,
.nw-terminal-system-list article,
.nw-terminal-module-card,
.nw-terminal-milestones article,
.nw-terminal-task,
.nw-terminal-agenda-event {
  min-width: 0;
}

.nw-terminal-directory-items strong,
.nw-terminal-directory-items small {
  white-space: normal;
}

.nw-terminal-task > span:last-child,
.nw-terminal-communication-list em,
.nw-terminal-work-records em,
.nw-terminal-compact-list em {
  min-width: 0;
  overflow-wrap: anywhere;
}

.nw-terminal-status-grid,
.nw-terminal-order-totals {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.nw-terminal-warning,
.nw-terminal-success,
.nw-terminal-note,
.nw-terminal-boundary,
.nw-terminal-callout,
.nw-terminal-help-inline,
.nw-terminal-context-caution,
.nw-terminal-danger-zone,
.nw-terminal-account-panel {
  color: var(--nw-terminal-ink);
}

.nw-terminal-warning,
.nw-terminal-context-caution,
.nw-terminal-callout.is-warning {
  background: var(--nw-terminal-warning-soft);
}

.nw-terminal-success {
  background: var(--nw-terminal-success-soft);
}

.nw-terminal-boundary,
.nw-terminal-danger-zone {
  background: var(--nw-terminal-danger-soft);
}

.nw-terminal-note,
.nw-terminal-help-inline,
.nw-terminal-account-panel {
  background: var(--nw-terminal-surface-alt);
}

/* ---------- Tables: no overlap, clear contrast ---------- */
.nw-terminal-table-wrap,
.nw-terminal-legacy .nw-table-wrap,
.nw-terminal-legacy .widefat,
.nw-terminal-main .nb-admin-table-wrap,
.nw-terminal-main .nwmf-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--nw-terminal-line);
  background: var(--nw-terminal-surface);
}

.nw-terminal-table,
.nw-terminal-table-wrap table,
.nw-terminal-legacy table,
.nw-terminal-main .widefat {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: auto;
  background: var(--nw-terminal-surface);
  color: var(--nw-terminal-ink);
}

.nw-terminal-table th,
.nw-terminal-table td,
.nw-terminal-table-wrap th,
.nw-terminal-table-wrap td,
.nw-terminal-legacy th,
.nw-terminal-legacy td {
  min-width: 90px;
  padding: 12px 13px;
  vertical-align: top;
  border-color: var(--nw-terminal-line-soft) !important;
  color: var(--nw-terminal-ink);
  white-space: normal;
}

.nw-terminal-table th,
.nw-terminal-table-wrap th,
.nw-terminal-legacy th,
.nw-terminal-main .widefat thead th {
  background: var(--nw-terminal-surface-strong) !important;
  color: var(--nw-terminal-table-head-text) !important;
  font-size: 11px;
  line-height: 1.35;
  text-transform: uppercase;
}

.nw-terminal-table tbody tr,
.nw-terminal-legacy table tbody tr {
  background: var(--nw-terminal-surface);
}

.nw-terminal-table tbody tr:nth-child(even),
.nw-terminal-legacy table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--nw-terminal-surface-alt) 66%, var(--nw-terminal-surface));
}

.nw-terminal-table tbody tr:hover,
.nw-terminal-legacy table tbody tr:hover {
  background: var(--nw-terminal-surface-strong);
}

/* ---------- Calendar and complex editors ---------- */
.nw-terminal-month-grid,
.nw-terminal-month-weekdays,
.nw-terminal-availability-grid,
.nw-terminal-connection-grid,
.nw-terminal-booking-editor,
.nw-terminal-order-layout,
.nw-terminal-finance-grid,
.nw-terminal-finance-editor,
.nw-terminal-commerce-dashboard {
  min-width: 0;
}

.nw-terminal-month-day,
.nw-terminal-agenda-day,
.nw-terminal-connection-grid > article,
.nw-terminal-availability-day {
  background: var(--nw-terminal-surface);
  color: var(--nw-terminal-ink);
  border-color: var(--nw-terminal-line);
}

.nw-terminal-month-day.is-other {
  background: var(--nw-terminal-surface-alt);
  color: var(--nw-terminal-muted);
}

.nw-terminal-month-event {
  background: var(--nw-terminal-surface-strong);
  color: var(--nw-terminal-ink);
}

.nw-terminal-invoice-items,
.nw-terminal-gallery-list,
.nw-terminal-variant-list,
.nw-terminal-product-form {
  max-width: 100%;
  overflow: visible;
}

.nw-terminal-invoice-item {
  min-width: 0;
}

/* ---------- Embedded/legacy module layout reset ---------- */
.nw-terminal-legacy,
.nw-terminal-legacy .wrap,
.nw-terminal-main .nw-admin,
.nw-terminal-main .nb-booking-admin,
.nw-terminal-main .nw-document-studio,
.nw-terminal-main .nw-storefront,
.nw-terminal-main .nw-customer-account,
.nw-terminal-main .nw-office,
.nw-terminal-main .nw-portal,
.nw-terminal-main .nw-customer-portal {
  width: 100%;
  max-width: none;
  min-width: 0;
  margin-left: 0;
  margin-right: 0;
  color: var(--nw-terminal-ink);
}

.nw-terminal-legacy .wrap {
  margin-top: 0;
  padding: 0;
}

.nw-terminal-legacy :where(.wp-heading-inline,h1.wp-heading-inline) {
  margin: 0 0 14px;
  color: var(--nw-terminal-ink);
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.15;
}

.nw-terminal-legacy .page-title-action {
  display: inline-flex;
  margin: 0 0 14px 8px;
  vertical-align: middle;
}

.nw-terminal-legacy :where(.nav-tab-wrapper,.wp-tab-bar,.subsubsub) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  margin: 0 0 18px;
  padding: 6px;
  overflow: visible;
  border: 1px solid var(--nw-terminal-line);
  background: var(--nw-terminal-surface-alt);
}

.nw-terminal-legacy :where(.nav-tab,.wp-tab-bar a,.subsubsub a) {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 9px 13px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--nw-terminal-muted) !important;
  font-weight: 800;
  text-decoration: none;
}

.nw-terminal-legacy :where(.nav-tab-active,.nav-tab:hover,.wp-tab-bar a:hover,.subsubsub a.current,.subsubsub a:hover) {
  border-color: var(--nw-terminal-line);
  background: var(--nw-terminal-surface);
  color: var(--nw-terminal-red) !important;
}

.nw-terminal-legacy :where(.card,.postbox,.notice,.updated,.error,.nw-card,.nw-form-section,.nw-help-panel,.nw-commerce-variant,.nw-center-item,.nw-center-count,.nw-ops-metrics > a,.nw-ops-metrics > div) {
  max-width: 100%;
  background: var(--nw-terminal-surface) !important;
  border-color: var(--nw-terminal-line) !important;
  color: var(--nw-terminal-ink) !important;
  box-shadow: var(--nw-terminal-shadow-soft) !important;
}

.nw-terminal-legacy :where(.postbox-header,.hndle,.handlediv,.inside) {
  color: var(--nw-terminal-ink);
  border-color: var(--nw-terminal-line) !important;
}

.nw-terminal-legacy :where(.notice,.updated,.error) {
  padding: 13px 15px;
}

.nw-terminal-legacy :where(.description,.help,.hint,small,p) {
  color: var(--nw-terminal-muted);
}

.nw-terminal-legacy :where(label,legend,h1,h2,h3,h4,strong,th,dt) {
  color: var(--nw-terminal-ink);
}

.nw-terminal-legacy :where(.wp-list-table,.form-table,.striped) {
  background: var(--nw-terminal-surface) !important;
  color: var(--nw-terminal-ink) !important;
}

/* Keep embedded sticky toolbars below the NeuroWerk topbar or make them local. */
.nw-terminal-main :where(.nw-studio-toolbar,.nw-office-nav,.nw-admin .nw-sticky,.nb-booking-admin .nb-sticky) {
  top: calc(var(--nw-terminal-topbar-height) + 8px);
}

.nw-terminal-main :where(.nw-studio-palette,.nw-studio-properties) {
  top: calc(var(--nw-terminal-topbar-height) + 96px);
  max-height: calc(100vh - var(--nw-terminal-topbar-height) - 116px);
}

/* ---------- Embedded modules: token bridge in both themes ---------- */
.nw-terminal-main .nw-admin,
.nw-terminal-main .nb-booking-admin,
.nw-terminal-main .nw-document-studio,
.nw-terminal-main .nw-storefront,
.nw-terminal-main .nw-customer-account,
.nw-terminal-main .nw-office,
.nw-terminal-main .nw-portal,
.nw-terminal-main .nw-customer-portal {
  --nw-red: var(--nw-terminal-red);
  --nw-red-dark: var(--nw-terminal-red-dark);
  --nw-red-soft: var(--nw-terminal-danger-soft);
  --nw-ink: var(--nw-terminal-ink);
  --nw-muted: var(--nw-terminal-muted);
  --nw-line: var(--nw-terminal-line);
  --nw-bg: var(--nw-terminal-bg);
  --nw-card: var(--nw-terminal-surface);
  --nw-ok: var(--nw-terminal-good);
  --nw-warn: var(--nw-terminal-warn);
  --nw-danger: var(--nw-terminal-bad);
  --nw-border: var(--nw-terminal-line);
  --nw-accent: var(--nw-terminal-red);
  --nw-text: var(--nw-terminal-ink);
  --nw-shell: var(--nw-terminal-bg);
  --nw-panel: var(--nw-terminal-surface);
  --nw-panel-alt: var(--nw-terminal-surface-alt);
  --nw-graphite: var(--nw-terminal-ink);
  --nw-silver: var(--nw-terminal-muted);
  --nw-color-accent: var(--nw-terminal-red);
  --nw-color-accent-strong: var(--nw-terminal-red-dark);
  --nw-color-surface: var(--nw-terminal-surface);
  --nw-color-canvas: var(--nw-terminal-bg);
  --nw-color-text: var(--nw-terminal-ink);
  --nw-color-muted: var(--nw-terminal-muted);
  --nw-color-border: var(--nw-terminal-line);
  --nw-color-success: var(--nw-terminal-good);
  --nw-color-warning: var(--nw-terminal-warn);
  --nw-color-error: var(--nw-terminal-bad);
  --nw-panel-soft: var(--nw-terminal-surface-alt);
  --nw-panel-accent: var(--nw-terminal-danger-soft);
  --nw-comfort-canvas: var(--nw-terminal-bg);
  --nw-comfort-panel: var(--nw-terminal-surface);
  --nw-comfort-panel-soft: var(--nw-terminal-surface-alt);
  --nw-comfort-line: var(--nw-terminal-line);
  --nw-comfort-line-strong: var(--nw-terminal-input-border);
  --nw-comfort-ink: var(--nw-terminal-ink);
  --nw-comfort-muted: var(--nw-terminal-muted);
  --nw-surface: var(--nw-terminal-surface);
  --nw-surface-soft: var(--nw-terminal-surface-alt);
  --nw-surface-tint: var(--nw-terminal-danger-soft);
  --nw-form-surface: var(--nw-terminal-surface-alt);
  --nw-form-surface-strong: var(--nw-terminal-surface-strong);
  --nw-form-border: var(--nw-terminal-line);
  --nw-form-border-strong: var(--nw-terminal-input-border);
  --nw-form-text: var(--nw-terminal-ink);
  --nw-form-muted: var(--nw-terminal-muted);
  --nw-sf-red: var(--nw-terminal-red);
  --nw-sf-red-dark: var(--nw-terminal-red-dark);
  --nw-sf-ink: var(--nw-terminal-ink);
  --nw-sf-muted: var(--nw-terminal-muted);
  --nw-sf-line: var(--nw-terminal-line);
  --nw-sf-soft: var(--nw-terminal-surface-alt);
  --nw-sf-cream: var(--nw-terminal-surface-alt);
  --nw-sf-white: var(--nw-terminal-surface);
  --studio-line: var(--nw-terminal-line);
  --studio-muted: var(--nw-terminal-muted);
  --studio-accent: var(--nw-terminal-red);
}

/* ---------- Dark mode: comprehensive contrast correction ---------- */
html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-card,
  .nw-terminal-view-head,
  .nw-terminal-context-guide,
  .nw-terminal-help-topic,
  .nw-terminal-directory-list,
  .nw-terminal-directory-search,
  .nw-terminal-subnav,
  .nw-terminal-toolbar,
  .nw-terminal-table,
  .nw-terminal-task,
  .nw-terminal-day-card,
  .nw-terminal-status-grid span,
  .nw-terminal-order-totals span,
  .nw-terminal-agenda-day,
  .nw-terminal-month-day,
  .nw-terminal-record-list article,
  .nw-terminal-connection-grid > article,
  .nw-terminal-availability-day,
  .nw-terminal-module-card,
  .nw-terminal-health-list article,
  .nw-terminal-system-list article,
  .nw-terminal-milestones article,
  .nw-terminal-conversation-message,
  .nw-terminal-message-body,
  .nw-terminal-account-panel,
  .nw-terminal-permissions,
  .nw-terminal-danger-zone,
  .nw-terminal-help-inline,
  .nw-terminal-empty,
  .nw-terminal-empty-small
) {
  background: var(--nw-terminal-surface) !important;
  color: var(--nw-terminal-ink) !important;
  border-color: var(--nw-terminal-line) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-directory-search,
  .nw-terminal-context-guide[open] summary,
  .nw-terminal-process-flow span,
  .nw-terminal-role-list span,
  .nw-terminal-help-group > header span,
  .nw-terminal-status-grid span,
  .nw-terminal-order-totals span,
  .nw-terminal-agenda-day > header,
  .nw-terminal-month-weekdays span,
  .nw-terminal-month-event,
  .nw-terminal-month-day.is-other,
  .nw-terminal-callout,
  .nw-terminal-note,
  .nw-terminal-help-inline,
  .nw-terminal-empty-small,
  .nw-terminal-table tbody tr:nth-child(even)
) {
  background: var(--nw-terminal-surface-alt) !important;
  color: var(--nw-terminal-ink) !important;
  border-color: var(--nw-terminal-line) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  h1,h2,h3,h4,h5,h6,label,legend,strong,dt,dd,th,td,summary
) {
  color: var(--nw-terminal-ink);
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  p,small,.description,.nw-terminal-muted,.nw-terminal-data dt,.nw-terminal-data-list dt
) {
  color: var(--nw-terminal-muted);
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-notice.is-success,.nw-terminal-success,.nw-terminal-up-to-date
) {
  background: var(--nw-terminal-success-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-notice.is-warning,.nw-terminal-warning,.nw-terminal-context-caution,.nw-terminal-callout.is-warning,.nw-terminal-auth-message
) {
  background: var(--nw-terminal-warning-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-notice.is-error,.nw-terminal-boundary,.nw-terminal-danger-zone
) {
  background: var(--nw-terminal-danger-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-pill.is-paid,.nw-terminal-pill.is-refunded,.nw-terminal-status.is-active
) {
  background: var(--nw-terminal-success-soft) !important;
  color: var(--nw-terminal-good) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-pill.is-unpaid,.nw-terminal-pill.is-pending,.nw-terminal-pill.is-partial,.nw-terminal-pill.is-partially_refunded,.nw-terminal-status.is-vacation,.nw-terminal-status.is-lead
) {
  background: var(--nw-terminal-warning-soft) !important;
  color: var(--nw-terminal-warn) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :where(
  .nw-terminal-pill.is-failed,.nw-terminal-pill.is-cancelled,.nw-terminal-pill.is-expired,.nw-terminal-status.is-blocked,.nw-terminal-status.is-archived,.nw-terminal-status.is-inactive
) {
  background: var(--nw-terminal-danger-soft) !important;
  color: var(--nw-terminal-bad) !important;
}

/* Generic hard-coded light surfaces inside embedded modules. */
html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  .card,.postbox,.inside,.notice,.updated,.error,
  .nw-card,.nw-form-section,.nw-help-panel,.nw-table-wrap,.nw-commerce-variant,
  .nw-ops-metrics > a,.nw-ops-metrics > div,.nw-center-item,.nw-center-count,
  .nw-office-card,.nw-office-metrics > div,.nw-office-footer,
  .nw-portal-card,.nw-portal-metrics > div,.nw-portal-login,
  .nw-customer-portal-grid section,.nw-account-card,.nw-account-tabs,.nw-account-stats article,.nw-account-hero,
  .nb-card,.nb-admin-card,.nb-panel,.nb-admin-tab-panel > section,
  .nw-studio-toolbar,.nw-studio-palette,.nw-studio-properties,
  .nw-component-list button,.nw-field-browser button,
  .nw-storefront-card,.nw-storefront-cart,.nw-storefront-checkout,.nw-storefront-status
) {
  background: var(--nw-terminal-surface) !important;
  border-color: var(--nw-terminal-line) !important;
  color: var(--nw-terminal-ink) !important;
  box-shadow: var(--nw-terminal-shadow-soft) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  h1,h2,h3,h4,h5,h6,label,legend,strong,th,td,dt,dd,.title,.name
) {
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  p,small,.description,.hint,.help,.muted,.nw-muted,.nb-muted
) {
  color: var(--nw-terminal-muted) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),textarea,select
) {
  background: var(--nw-terminal-input) !important;
  border-color: var(--nw-terminal-input-border) !important;
  color: var(--nw-terminal-ink) !important;
  -webkit-text-fill-color: var(--nw-terminal-ink);
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  .notice-success,.updated,.is-success,.nw-message-success,.nw-account-message-success
) {
  background: var(--nw-terminal-success-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  .notice-warning,.is-warning,.nw-message-warning,.nw-account-message-warning
) {
  background: var(--nw-terminal-warning-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-admin,
  .nb-booking-admin,
  .nw-document-studio,
  .nw-office,
  .nw-portal,
  .nw-customer-account,
  .nw-customer-portal,
  .nw-storefront
) :is(
  .notice-error,.error,.is-error,.nw-message-error,.nw-account-message-error
) {
  background: var(--nw-terminal-danger-soft) !important;
  color: var(--nw-terminal-ink) !important;
}

/* Intentionally white print/document previews remain white and readable. */
html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-invoice-paper,.nw-document-paper,.nw-print-paper,.nw-preview-paper
) {
  background: #ffffff !important;
  color: #20262d !important;
  border-color: #cfd5dc !important;
}

html[data-nw-theme="dark"] .nw-terminal-main :is(
  .nw-invoice-paper,.nw-document-paper,.nw-print-paper,.nw-preview-paper
) :is(h1,h2,h3,h4,p,span,strong,small,td,th) {
  color: inherit !important;
}

/* ---------- Authentication polish ---------- */
.nw-terminal-auth-panel {
  overflow-y: auto;
}

.nw-terminal-auth-panel > * {
  min-width: 0;
}

.nw-terminal-auth-tabs button,
.nw-terminal-auth .nw-terminal-primary,
.nw-terminal-auth .nw-terminal-secondary,
.nw-terminal-auth .nw-terminal-password button {
  min-height: 48px;
  font-size: 14px;
}

.nw-terminal-auth .nw-terminal-password button {
  min-width: 104px;
}

html[data-nw-theme="dark"] .nw-terminal-auth-panel,
html[data-nw-theme="dark"] .nw-terminal-auth-tabs button.is-active {
  color: var(--nw-terminal-ink);
}

html[data-nw-theme="dark"] .nw-terminal-auth-panel :where(h1,h2,h3,label,strong) {
  color: var(--nw-terminal-ink);
}

html[data-nw-theme="dark"] .nw-terminal-auth-panel :where(p,small) {
  color: var(--nw-terminal-muted);
}

/* ---------- Responsive breakpoints ---------- */
@media (max-width: 1260px) {
  :root {
    --nw-terminal-sidebar-width: 248px;
  }

  .nw-terminal-grid-main,
  .nw-terminal-commerce-dashboard,
  .nw-terminal-order-layout,
  .nw-terminal-finance-grid,
  .nw-terminal-finance-editor {
    grid-template-columns: 1fr;
  }

  .nw-terminal-day-card,
  .nw-terminal-directory-list,
  .nw-terminal-sticky {
    position: static;
    max-height: none;
  }
}

@media (max-width: 980px) {
  :root {
    --nw-terminal-topbar-height: 76px;
  }

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

  .nw-terminal-sidebar {
    top: 0;
    height: 100dvh;
  }

  .nw-terminal-topbar {
    min-height: var(--nw-terminal-topbar-height);
  }

  .nw-terminal-brand strong {
    max-width: 36vw;
  }

  .nw-terminal-main :where(.nw-studio-toolbar,.nw-office-nav,.nw-admin .nw-sticky,.nb-booking-admin .nb-sticky),
  .nw-terminal-main :where(.nw-studio-palette,.nw-studio-properties) {
    position: static;
    top: auto;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .nw-terminal-grid,
  .nw-terminal-grid-2,
  .nw-terminal-dashboard-grid,
  .nw-terminal-metric-grid,
  .nw-terminal-help-grid,
  .nw-terminal-module-grid,
  .nw-terminal-connection-grid,
  .nw-terminal-form-grid,
  .nw-terminal-check-grid,
  .nw-terminal-rich-grid {
    grid-template-columns: 1fr;
  }

  .nw-terminal-form-grid .is-wide {
    grid-column: auto;
  }

  .nw-terminal-view-head,
  .nw-terminal-card-head,
  .nw-terminal-record-head,
  .nw-terminal-account-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .nw-terminal-view-head > *,
  .nw-terminal-card-head > *,
  .nw-terminal-record-head > * {
    width: 100%;
  }

  .nw-terminal-actions,
  .nw-terminal-action-row,
  .nw-terminal-row-actions,
  .nw-terminal-form-actions,
  .nw-terminal-account-actions,
  .nw-terminal-user-tools,
  .nw-terminal-repair-actions {
    align-items: stretch;
  }

  .nw-terminal-actions > *,
  .nw-terminal-action-row > *,
  .nw-terminal-row-actions > *,
  .nw-terminal-form-actions > *,
  .nw-terminal-account-actions > *,
  .nw-terminal-user-tools > *,
  .nw-terminal-repair-actions > * {
    flex: 1 1 180px;
  }
}

@media (max-width: 680px) {
  :root {
    --nw-terminal-topbar-height: 70px;
    --nw-terminal-control-height: 48px;
  }

  .nw-terminal-topbar {
    padding: 10px 11px;
    gap: 8px;
  }

  .nw-terminal-brand img {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }

  .nw-terminal-brand strong {
    max-width: 120px;
    font-size: 14px;
  }

  .nw-terminal-brand small,
  .nw-terminal-user > span {
    display: none;
  }

  .nw-terminal-menu-toggle,
  .nw-terminal-theme-toggle,
  .nw-terminal-user > a {
    min-height: 46px;
    padding: 9px 11px;
  }

  .nw-terminal-theme-label,
  .nw-terminal-menu-toggle:not(:focus) {
    font-size: 0;
  }

  .nw-terminal-menu-toggle span {
    font-size: 20px;
  }

  .nw-terminal-main {
    padding: 12px;
  }

  .nw-terminal-view-head,
  .nw-terminal-card {
    padding: 18px;
  }

  .nw-terminal-row-actions,
  .nw-terminal-actions,
  .nw-terminal-form-actions,
  .nw-terminal-user-tools,
  .nw-terminal-account-actions,
  .nw-terminal-repair-actions,
  .nw-terminal-filter {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .nw-terminal-row-actions form,
  .nw-terminal-actions form,
  .nw-terminal-user-tools form,
  .nw-terminal-account-actions form,
  .nw-terminal-repair-actions form,
  .nw-terminal-row-actions button,
  .nw-terminal-actions button,
  .nw-terminal-actions a,
  .nw-terminal-form-actions button,
  .nw-terminal-user-tools button,
  .nw-terminal-user-tools select,
  .nw-terminal-account-actions button,
  .nw-terminal-repair-actions button,
  .nw-terminal-filter select,
  .nw-terminal-filter input {
    width: 100%;
  }

  .nw-terminal-table,
  .nw-terminal-table-wrap table,
  .nw-terminal-legacy table,
  .nw-terminal-main .widefat {
    min-width: 640px;
  }

  .nw-terminal-auth .nw-terminal-password {
    grid-template-columns: 1fr;
  }

  .nw-terminal-auth .nw-terminal-password button {
    width: 100%;
    border-left: 1px solid var(--nw-terminal-input-border);
    border-radius: 5px;
  }
}

@media (max-width: 430px) {
  .nw-terminal-brand span {
    display: none;
  }

  .nw-terminal-topbar-actions {
    gap: 6px;
  }

  .nw-terminal-user > a,
  .nw-terminal-theme-toggle,
  .nw-terminal-menu-toggle {
    min-width: 42px;
    padding-left: 9px;
    padding-right: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nw-terminal-card:hover,
  .nw-terminal-body :where(button,a) {
    transform: none !important;
  }
}

@media print {
  .nw-terminal-topbar,
  .nw-terminal-sidebar,
  .nw-terminal-context-guide,
  .nw-terminal-loading {
    display: none !important;
  }

  .nw-terminal-layout {
    display: block;
  }

  .nw-terminal-main {
    padding: 0;
  }
}

/* 3.2.1 final visual verification corrections */
.nw-terminal-legacy :where(.button,.button-primary,.button-secondary,.page-title-action),
.nw-terminal-main .nw-admin :where(button,.button,input[type="submit"],input[type="button"]) {
  min-height: var(--nw-terminal-control-height) !important;
  padding: 10px 16px !important;
  line-height: 1.25 !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  white-space: normal !important;
}

@media (max-width: 820px) {
  .nw-terminal-view-head > div:first-child,
  .nw-terminal-card-head > div,
  .nw-terminal-record-head > div {
    flex: 0 1 auto;
  }
}
