/* Icon button */
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-m);
  height: var(--control-height-m);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-secondary);
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.icon-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* A header icon that reflects a live on/off state (Clock In/Out, Counter
   Open/Close) starts muted like any inactive control - same as a plain
   .icon-btn - and only shows brand color while aria-pressed="true",
   reverting to muted the moment the state turns off again. The doubled
   class selector beats :hover's specificity so the tint holds even while
   hovering a pressed button. */
.icon-btn.icon-btn--stateful {
  color: var(--text-secondary);
}

.icon-btn.icon-btn--stateful[aria-pressed="true"],
.icon-btn.icon-btn--stateful.is-active {
  color: var(--brand-primary);
}

.icon-btn--sm {
  width: var(--control-height-s);
  height: var(--control-height-s);
}

.icon-btn__badge {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  min-width: var(--icon-size-s);
  height: var(--icon-size-s);
  padding: 0 var(--space-4);
  border-radius: var(--radius-8);
  background: var(--danger);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  text-align: center;
}

/* Header dropdown menus */
.header-menu {
  position: relative;
}

.header-menu__panel {
  position: absolute;
  top: calc(100% + var(--space-8));
  left: 0;
  width: 280px;
  padding: var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-none);
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: var(--space-4);
}

.header-menu__panel--right {
  left: auto;
  right: 0;
}

.header-menu.is-open .header-menu__panel {
  display: flex;
}

.header-menu__title {
  padding: var(--space-8) var(--space-8);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.header-menu__title--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
}

.header-menu__clear {
  padding: 0;
  border: none;
  background: none;
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--brand-primary);
  cursor: pointer;
}

.header-menu__clear:hover {
  text-decoration: underline;
}

.header-menu__clear:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  text-decoration: none;
}

.header-menu__row {
  display: flex;
  align-items: stretch;
  gap: var(--space-4);
}

.header-menu__row .header-menu__item {
  flex: 1;
  min-width: 0;
}

.header-menu__item-action {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--space-32);
  border: none;
  border-radius: var(--radius-8);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}

.header-menu__item-action:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.header-menu__item-action .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.header-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-8);
  border-radius: var(--radius-8);
  color: var(--text-secondary);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
}

.header-menu__item:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.header-menu__item .material-symbols-rounded {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
}

.header-menu__item-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.header-menu__item-title {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.header-menu__item-meta {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

.header-menu__footer {
  display: block;
  margin-top: var(--space-4);
  padding: var(--space-8);
  text-align: center;
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--brand-primary);
  border-top: 1px solid var(--border-default);
}

/* Profile trigger */
.profile-trigger {
  display: flex;
  align-items: center;
  gap: var(--identity-gap);
  height: var(--control-height-m);
  padding: var(--space-4) var(--space-8);
  border: 1px solid transparent;
  border-radius: var(--radius-8);
  background: transparent;
}

.avatar {
  display: grid;
  place-items: center;
  width: var(--identity-icon-size);
  height: var(--identity-icon-size);
  border-radius: var(--radius-8);
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  flex-shrink: 0;
}

.profile-trigger > .avatar {
  transform: translateY(calc(var(--identity-text-offset-y) * -1));
}

.profile-trigger__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: var(--identity-text-gap);
  line-height: var(--leading-tight);
}

.profile-trigger__name {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

.profile-trigger__name--mobile { display: none; }

.profile-trigger__role {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-tight);
  color: var(--text-muted);
}

@media (max-width: 767.98px) {
  .profile-trigger__text {
    display: none;
  }
}

/* Sidebar navigation */
.app-nav {
  padding: var(--space-8);
}

.app-nav__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8);
  border-radius: var(--radius-8);
  color: var(--text-secondary);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
}

.app-nav__link:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.app-nav__icon {
  font-size: var(--icon-size-m);
  color: var(--text-muted);
  flex-shrink: 0;
}

.app-nav__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav__soon {
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-4);
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  flex-shrink: 0;
}

.app-nav__link.is-active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

.app-nav__link.is-active::before {
  content: '';
  position: absolute;
  left: calc(var(--space-8) * -1);
  top: var(--space-8);
  bottom: var(--space-8);
  width: var(--space-4);
  border-radius: var(--radius-4);
  background: var(--brand-primary);
}

.app-nav__link.is-disabled {
  color: var(--text-muted);
  cursor: default;
  pointer-events: none;
}

.app-nav__link.is-disabled .app-nav__icon {
  color: var(--text-muted);
}

/* Left-nav + right-content shell for pages with multiple settings-style
   sections (Settings, Master) - same active/hover language as .app-nav__link. */
.settings-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-24);
  align-items: start;
}

.settings-shell__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: sticky;
  top: var(--space-16);
}

.settings-shell__nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-12);
  border: 0;
  border-radius: var(--radius-8);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  text-align: left;
  cursor: pointer;
}

.settings-shell__nav-item:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.settings-shell__nav-item.is-active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

.settings-shell__nav-item.is-active::before {
  content: '';
  position: absolute;
  left: calc(var(--space-8) * -1);
  top: var(--space-8);
  bottom: var(--space-8);
  width: var(--space-4);
  border-radius: var(--radius-4);
  background: var(--brand-primary);
}

.settings-shell__pane {
  min-width: 0;
}

/* Each pane's wrapper div lost .workspace's flex gap once nested a level
   deeper inside .settings-shell__pane - restore it here so a pane with more
   than one card (e.g. Master's form-card + table-card) still gets spacing
   between them. */
.settings-shell__pane > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

@media (max-width: 767.98px) {
  .settings-shell {
    grid-template-columns: 140px 1fr;
    gap: var(--space-12);
  }

  .settings-shell__nav-item {
    padding: var(--space-8);
    font-size: var(--text-xs);
  }
}

/* Sidebar module groups (parent module + child sub-pages) */
.app-nav__group {
  border-radius: var(--radius-8);
}

.app-nav__group-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8);
  border-radius: var(--radius-8);
  color: var(--text-secondary);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  cursor: pointer;
  list-style: none;
}

.app-nav__group-toggle::-webkit-details-marker {
  display: none;
}

.app-nav__group-toggle:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.app-nav__caret {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-standard);
}

.app-nav__group[open] > .app-nav__group-toggle .app-nav__caret {
  transform: rotate(90deg);
}

.app-nav__children {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-left: var(--space-12);
  border-left: 1px solid var(--border-default);
  margin-left: var(--space-12);
}

.app-nav__children .app-nav__link {
  padding: var(--space-8) var(--space-8);
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
}

.page-header__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.page-header__desc {
  margin-top: var(--identity-text-gap);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.page-header__actions {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: var(--control-height-m);
  padding: 0 var(--space-12);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: var(--text-s);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-relaxed);
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard);
}

.btn .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brand-primary);
  color: var(--text-inverse);
  box-shadow: none;
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--secondary {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--bg-page);
  border-color: var(--border-strong);
}

.btn--destructive {
  background: var(--danger);
  color: var(--text-inverse);
}

.btn--destructive:hover {
  filter: brightness(1.05);
}

/* Loading feedback (design.md Animation System - the sanctioned exception to
   "avoid continuous animation": a spinner is the standard way to represent
   an in-flight request). window.setButtonLoading() in app.js toggles this. */
.spinner {
  display: inline-block;
  width: var(--icon-size-s);
  height: var(--icon-size-s);
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.icon-btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.btn.is-loading .spinner,
.icon-btn.is-loading .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: calc(var(--icon-size-s) / -2) 0 0 calc(var(--icon-size-s) / -2);
  color: var(--text-secondary);
}

.btn--primary.is-loading .spinner, .btn--destructive.is-loading .spinner {
  color: var(--text-inverse);
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.5s;
  }
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
  padding: var(--card-padding);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
}

.filter-bar__group {
  display: flex;
  align-items: flex-end;
  gap: var(--space-12);
  flex-wrap: wrap;
}

.attendance-summary-employee-filter {
  display: grid;
  min-width: 0;
  gap: var(--space-4);
}

.attendance-summary-employee-filter .segmented {
  max-width: 100%;
}

/* A filter-bar pairing a period segmented control with a From/To date
   range (Dashboard, Recharge, and any future page using the same shape)
   has few enough controls to always fit one row instead of wrapping -
   scoped to filter-bars that actually contain .filter-bar__group--dates
   so pages with more/variable filter buttons (People, Drawer, Recharge's
   own network filter, etc.) keep the default wrapping behavior above. */
.filter-bar:has(.filter-bar__group--dates) {
  flex-wrap: nowrap;
}

.filter-bar:has(.filter-bar__group--dates) .segmented {
  flex-wrap: nowrap;
}

.filter-bar:has(.filter-bar__group--dates) .segmented__btn {
  white-space: nowrap;
}

/* From/To are a single date-range control and should never split apart
   from each other. Narrower date inputs so period buttons + From + To
   all fit one row without a scrollbar - 100px clips "DD/MM/YYYY" against
   the icon's padding-right, 120px clears it. */
.filter-bar__group--dates {
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.filter-bar__group--dates .date-picker__input {
  width: 120px;
}

@media (max-width: 767.98px) {
  .filter-bar:has(.filter-bar__group--dates) {
    flex-direction: row;
    align-items: flex-end;
  }
}

/* Every segmented option carries an icon, so all of them share one layout:
   icon and text centred on one line with a small gap. */
.segmented__btn,
.segmented__btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
}

.segmented__btn .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

/* Segmented control */
.segmented {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  /* Same height as inputs; long option lists wrap onto extra rows. */
  min-height: var(--control-height-m);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  flex-wrap: wrap;
  row-gap: var(--space-4);
}

.segmented--equal {
  display: flex;
  width: 100%;
}

.segmented--equal .segmented__btn {
  /* Share the width evenly; wrap only when options genuinely do not fit. */
  flex: 1 1 0;
  min-width: max-content;
  padding: 0 var(--space-4);
  text-align: center;
}

.segmented__btn {
  /* Fills the 36px control: 36 - 2 x 4px padding - 2 x 1px border = 26px. */
  height: calc(var(--control-height-m) - 2 * var(--space-4) - 2px);
  border: 1px solid transparent;
  background: transparent;
  padding: 0 var(--space-12);
  /* Inner corner one step below the group's 8px. */
  border-radius: var(--radius-4);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.segmented__btn:hover {
  color: var(--text-primary);
}

.segmented__btn.is-active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  border: 1px solid var(--border-default);
}

.segmented__btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

fieldset.field {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field > legend.field__label {
  display: inline-flex;
  float: none;
  width: auto;
  padding: 0;
  margin-bottom: var(--space-4);
}

.field--row {
  flex-direction: row;
  align-items: center;
  gap: var(--space-8);
}

.field--row .field__label {
  white-space: nowrap;
}

/* The lead-icon wrapper field-icons.js puts round the input shares the row with the label: it takes the space
   left, never 100% of the row (that pushed the box past the screen edge on phones, e.g. Shop search). */
.field--row > .field-icon-wrap {
  flex: 1;
  width: auto;
  min-width: 0;
}

.field__label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.field__label-icon {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
}

.field__hint {
  display: block;
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.field__control {
  height: var(--control-height-m);
  padding: 0 var(--space-12);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-control);
  background: var(--bg-surface);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}

.field__control--textarea {
  height: auto;
  min-height: calc(var(--control-height-m) * 3 + var(--space-24));
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
  resize: vertical;
}

.field__control:focus {
  outline: none;
  border-color: var(--border-focus);
}

.field__control:hover:not(:disabled):not([readonly]) { border-color: var(--border-strong); }
.field__control:focus-visible {
  border-color: var(--brand-primary);
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.field__control:disabled,
.field__control[readonly] {
  background: var(--bg-page);
  color: var(--text-muted);
  cursor: not-allowed;
}

.field-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.field-prefix__symbol {
  position: absolute;
  left: var(--space-12);
  color: var(--text-muted);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  pointer-events: none;
}

.field-prefix__control {
  width: 100%;
  padding-left: var(--space-32);
}

/* Form card (create/edit workspace used across module pages) */
.form-card {
  padding: var(--card-padding);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  box-shadow: none;
}

.form-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-8);
}

.form-card__header--spaced { margin-top: var(--space-24); }

.form-card__code {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  white-space: nowrap;
}

.form-card__title {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.form-card__error {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--danger);
  background: var(--danger-soft);
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-8);
}

.form-card__error--visible { display: block; }

.form-card__success {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--success);
  background: var(--success-soft);
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-8);
}

.form-card__actions {
  display: flex;
  flex-wrap: wrap; /* 3-4 buttons are wider than a phone: wrap instead of spilling off the left edge */
  gap: var(--space-8);
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-12);
}

.email-compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-16);
  margin-top: var(--space-12);
  align-items: stretch;
}

.email-compose-column {
  display: grid;
  align-content: start;
  gap: var(--space-12);
}

.email-compose-column--right {
  grid-template-rows: auto minmax(0, 1fr);
  align-self: stretch;
  min-height: 0;
}

.email-compose-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
}

.email-compose-message textarea {
  flex: 1 1 auto;
  height: auto;
  min-height: 104px;
  padding: var(--space-8) var(--space-12);
  vertical-align: top;
  line-height: var(--leading-relaxed);
  resize: none;
  overflow-y: auto;
}

.email-compose-message {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.notification-compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-16);
  align-items: stretch;
}

.notification-compose-column {
  display: grid;
  align-content: start;
  gap: var(--space-12);
}

.notification-compose-message {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.notification-compose-message textarea {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  resize: none;
  overflow-y: auto;
}

.whatsapp-compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-16);
  align-items: stretch;
}

.whatsapp-compose-send {
  margin-top: var(--space-12);
}

.whatsapp-compose-column {
  display: grid;
  align-content: start;
  gap: var(--space-12);
}

.whatsapp-compose-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-12);
}

.whatsapp-compose-message {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.whatsapp-compose-message textarea {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  padding: var(--space-8) var(--space-12);
  vertical-align: top;
  line-height: var(--leading-relaxed);
  text-align: left;
  resize: none;
  overflow-y: auto;
}

.form-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

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

/* Project source selection: keep platform, customer and invoice/order together. */
#projectCreateForm {
  display: grid;
  gap: var(--space-16);
}

.project-source-row,
.project-dates-row,
.project-attachments-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.project-source-row > :first-child,
.project-dates-row > :last-child,
.project-attachments-row > :nth-child(2) {
  grid-column: span 2;
}
.project-title-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-source-row fieldset,
.project-title-row fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.project-source-row .project-choice-group,
.project-title-row .project-choice-group,
.project-attachments-row .project-choice-group {
  width: 100%;
}

.project-source-row .combobox {
  min-width: 0;
  width: 100%;
}

.project-source-row .combobox__option {
  flex-wrap: wrap;
  align-items: flex-start;
}

.project-source-row .combobox__option-label,
.project-source-row .combobox__option-meta {
  min-width: 0;
  overflow-wrap: anywhere;
}

.project-source-row .combobox__option-meta {
  flex: 1 1 100%;
}

.project-source-row .segmented__btn,
.project-title-row .segmented__btn {
  min-width: 0;
  white-space: normal;
  line-height: var(--leading-tight);
}

.project-description-field {
  margin: 0;
}

.project-description-field .field__control--textarea {
  height: var(--control-height-m);
  min-height: var(--control-height-m);
}

.project-attachments-row input[type="file"] {
  min-width: 0;
  width: 100%;
}

.project-choice-group {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  min-width: 0;
}

.project-choice-group .segmented__btn {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  text-align: center;
}

.project-employee-group {
  width: 100%;
  justify-content: stretch;
}

.project-choice-group .segmented__btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.project-initial-status {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--control-height-m);
  flex-wrap: wrap;
}

.project-initial-status .field__hint {
  margin: 0;
}

.project-initial-status .segmented {
  width: 100%;
}

.project-initial-status .segmented__btn.is-active:disabled {
  color: var(--brand-primary);
  cursor: default;
}

.project-create-submit {
  min-width: 148px;
}

.project-board-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.project-board-filters .filter-bar__group {
  display: grid;
  align-content: start;
  align-items: stretch;
  gap: var(--space-4);
  min-width: 0;
}

.project-board-filters .segmented {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  gap: var(--space-4);
}

.project-board-filters .segmented__btn {
  flex: 1 1 auto;
  min-width: 0;
}

.project-board-table {
  min-width: 1120px;
}

.project-board-table__source {
  min-width: 190px;
  max-width: 280px;
  white-space: normal !important;
}

.project-board-table__source .data-table__primary,
.project-board-table__source .data-table__secondary {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.project-file-count {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  min-width: 42px;
}

.project-file-count .material-symbols-rounded {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
}

.project-priority {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--space-8);
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.project-priority--high,
.project-priority--urgent {
  background: var(--danger-soft);
  color: var(--danger);
}

.project-priority--low {
  background: var(--success-soft);
  color: var(--success);
}

.project-board-progress {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-width: 104px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.project-board-progress progress {
  display: block;
  width: 72px;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  accent-color: var(--brand-primary);
}

.project-board-progress progress::-webkit-progress-bar {
  background: var(--bg-inset);
  border-radius: var(--radius-pill);
}

.project-board-progress progress::-webkit-progress-value {
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
}

.project-board-progress progress::-moz-progress-bar {
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
}


@media (max-width: 767.98px) {
  .project-board-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-source-row,
  .project-dates-row,
  .project-attachments-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-source-row > :first-child,
  .project-dates-row > :last-child,
  .project-attachments-row > :nth-child(2) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767.98px) {
  .project-board-filters .segmented {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .project-source-row,
  .project-dates-row,
  .project-title-row,
  .project-attachments-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-source-row > :first-child {
    grid-column: auto;
  }
}

.project-progress {
  display: grid;
  gap: var(--space-8);
  margin: var(--space-16) 0;
}

.project-progress__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  color: var(--text-primary);
  font-size: var(--text-s);
}

.project-progress__label b {
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums;
}

.project-progress progress {
  display: block;
  width: 100%;
  height: var(--space-8);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
  accent-color: var(--brand-primary);
}

.project-progress progress::-webkit-progress-bar {
  border-radius: var(--radius-pill);
  background: var(--bg-inset);
}

.project-progress progress::-webkit-progress-value {
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
}

.project-progress progress::-moz-progress-bar {
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
}

.project-progress__hint {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

@media (max-width: 767.98px) {
  .project-source-row,
  .project-dates-row,
  .project-title-row,
  .project-attachments-row { grid-template-columns: minmax(0, 1fr); }
  .project-source-row > :first-child,
  .project-dates-row > :last-child,
  .project-attachments-row > :nth-child(2) { grid-column: auto; }
}

/* Master > Drawer: name gets two-thirds, status one-third. */
.form-grid--drawer {
  grid-template-columns: 2fr 1fr;
}

.form-grid--8 {
  grid-template-columns: repeat(8, 1fr);
}

.form-grid--5 {
  grid-template-columns: repeat(5, 1fr);
}

.form-grid--16 {
  grid-template-columns: repeat(16, 1fr);
}

.form-grid--6 {
  grid-template-columns: repeat(6, 1fr);
}

.form-grid--20 {
  grid-template-columns: repeat(20, 1fr);
}

.form-grid--24 {
  grid-template-columns: repeat(24, 1fr);
}

.field--span-2 {
  grid-column: span 2;
}

.field--span-3 {
  grid-column: span 3;
}

.field--span-4 {
  grid-column: span 4;
}

.letter-message-editor {
  min-height: calc(var(--control-height-m) * 4 + var(--space-24));
}

.letter-message-label {
  display: flex;
  align-items: center;
  min-height: var(--control-height-m);
}

.letter-message-label .field__label-icon {
  flex: 0 0 auto;
  line-height: 1;
}

.field--span-5 {
  grid-column: span 5;
}

.field--span-12 {
  grid-column: span 12;
}

.field--col-4 {
  grid-column: 4;
}

@media (max-width: 767.98px) {
  .form-grid--4,
  .form-grid--5,
  .form-grid--6,
  .form-grid--8,
  .form-grid--16,
  .form-grid--20,
  .form-grid--24 {
    grid-template-columns: repeat(2, 1fr);
  }

  .field--span-3,
  .field--span-4,
  .field--span-5,
  .field--span-12,
  .field--col-4 {
    grid-column: span 2;
  }
}

@media (max-width: 767.98px) {
  .form-grid,
  .form-grid--drawer,
  .form-grid--4,
  .form-grid--2,
  .form-grid--5,
  .form-grid--6,
  .form-grid--8,
  .form-grid--16,
  .form-grid--20,
  .form-grid--24 {
    grid-template-columns: 1fr;
  }

  .email-compose-grid,
  .email-compose-row,
  .notification-compose-grid,
  .whatsapp-compose-grid,
  .whatsapp-compose-row {
    grid-template-columns: 1fr;
  }

  .notification-compose-message textarea {
    min-height: calc(var(--control-height-m) * 3 + var(--space-24));
  }

  .whatsapp-compose-message textarea {
    min-height: calc(var(--control-height-m) * 3 + var(--space-24));
  }

  .field--span-2,
  .field--span-3,
  .field--span-4,
  .field--span-5,
  .field--span-12,
  .field--col-4 {
    grid-column: auto;
  }
}

/* Summary list (key/value rows used in payment panels and view modals) */
.summary-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  overflow: hidden;
}

.summary-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  margin: 0;
  padding: var(--space-12) var(--space-12);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  background: var(--bg-surface);
}

.summary-list__row + .summary-list__row {
  border-top: 1px solid var(--border-default);
}

.summary-list__row dt {
  font-weight: var(--weight-regular);
}

.summary-list__row dd {
  margin: 0;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  text-align: right;
}

.summary-list__row--strong {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  background: var(--bg-page);
}

.summary-list__row--strong dt {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-list__row--strong dd {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  text-align: left;
}

/* Modal */
.barcode-camera-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: var(--space-20);
  background: var(--overlay-scrim);
}

.barcode-camera {
  width: 100%;
  max-width: 560px;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-dialog);
  padding: var(--dialog-padding);
}

.barcode-camera__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
}

.barcode-camera__video {
  display: block;
  width: 100%;
  max-height: 65vh;
  margin-top: var(--space-12);
  background: var(--text-primary);
  border-radius: var(--radius-8);
}

.barcode-camera__hint {
  margin-bottom: 0;
}

@media (max-width: 767.98px) {
  .barcode-camera-layer { align-items: flex-end; padding: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .barcode-camera { max-width: none; max-height: 94dvh; overflow-y: auto; padding: var(--dialog-padding); border-radius: var(--radius-24) var(--radius-24) 0 0; border-bottom: 0; }
  .barcode-camera__video { max-height: 48dvh; }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-12);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.modal-overlay.is-open {
  opacity: 1;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - var(--space-12) * 2);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-dialog);
  box-shadow: var(--shadow-none);
  display: flex;
  flex-direction: column;
  transform: translateY(var(--space-8)) scale(0.98);
  transition: transform var(--duration-base) var(--ease-standard);
}

.modal-overlay.is-open .modal {
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay,
  .modal {
    transition: none;
  }
}

.modal--wide {
  max-width: 720px;
}

/* Shared document print workspace: fixed modal rails with a scrollable paper canvas. */
.modal--print {
  width: min(1480px, calc(100vw - var(--space-32)));
  height: min(920px, calc(100dvh - var(--space-32)));
  max-width: none;
  max-height: none;
}
.modal--print .modal__header,
.modal--print .modal__footer { flex: 0 0 auto; }
.modal--print .modal__body { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: var(--space-12); }
.modal--print .modal__header-end { margin-left: auto; }
.modal--print .modal__header-custom { display: flex; align-items: center; margin-left: auto; }
.modal--print .print-header-actions { display: flex; align-items: center; gap: var(--space-8); }
.modal--print.is-maximized { position: fixed; inset: var(--space-8); width: auto; height: auto; max-width: none; max-height: none; }
.modal--print .modal__header-end .record-view__reference { color: var(--text-secondary); }
.modal--print .modal__footer { justify-content: flex-end; }
.modal--print .print-workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--space-12); height: 100%; min-height: 0; }
.modal--print .print-settings { display: flex; min-height: 0; flex-direction: column; gap: var(--space-12); overflow-y: auto; padding: var(--space-16); border: 1px solid var(--border-light); border-radius: var(--radius-12); background: var(--bg-surface); }
.modal--print .print-settings__heading { display: flex; align-items: center; gap: var(--space-8); padding-bottom: var(--space-8); border-bottom: 1px solid var(--border-light); color: var(--text-primary); }
.modal--print .print-settings__heading > .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.modal--print .print-settings__heading div { display: grid; gap: var(--space-4); }
.modal--print .print-settings__heading small { color: var(--text-muted); font-size: var(--text-xs); }
.modal--print .print-settings .field { gap: var(--space-4); }
.modal--print .print-settings .field__control { min-height: 36px; }
.modal--print .print-settings__check { display: flex; align-items: center; gap: var(--space-8); color: var(--text-secondary); font-size: var(--text-s); }
.modal--print .print-settings__notes textarea { resize: vertical; }
.modal--print .print-settings__printer { display: grid; gap: var(--space-4); color: var(--text-secondary); font-size: var(--text-xs); }
.modal--print .print-preview { display: flex; min-width: 0; min-height: 0; flex-direction: column; overflow: hidden; border: 1px solid var(--border-light); border-radius: var(--radius-12); background: var(--bg-hover); }
.modal--print .print-preview__toolbar { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: var(--space-12); padding: var(--space-8) var(--space-12); border-bottom: 1px solid var(--border-light); background: var(--bg-surface); }
.modal--print .print-preview__navigation,
.modal--print .print-preview__zoom { display: flex; align-items: center; gap: var(--space-8); }
.modal--print .print-preview__page-number { display: flex; align-items: center; gap: var(--space-8); color: var(--text-secondary); font-size: var(--text-xs); }
.modal--print .print-preview__page-number input { width: 56px; min-height: 32px; text-align: center; }
.modal--print .print-preview__canvas { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--space-20); }
.modal--print .print-preview__document { min-width: 0; padding: 0; background: transparent; overflow: visible; }
.modal--print .print-preview__document .doc-paper { width: max-content; min-width: min(100%, 794px); max-width: 100%; margin-inline: auto; transform: scale(calc(var(--print-scale, 100) / 100)); transform-origin: top center; }
.modal--print .print-preview__document .doc-paper--a4 { width: 794px; }
.modal--print .print-preview__document .doc-paper--a5 { width: 560px; }
.modal--print .print-preview__document .doc-paper--80mm { width: 304px; min-width: 304px; }
.modal--print .print-preview__document .doc-page { min-height: 1050px; border-radius: var(--radius-4); box-shadow: var(--shadow-emphasis); }
.modal--print .print-preview__document .doc-page { transform: scale(var(--print-page-scale, 1)); transform-origin: top center; }
.modal--print .print-preview__document .doc-paper--a5 .doc-page { min-height: 744px; }
.modal--print .print-preview__document .doc-paper--80mm .doc-page { min-height: 600px; }
.modal--print .print-preview__document[data-orientation="landscape"] .doc-paper--a4 { width: 1123px; }
.modal--print .print-preview__document[data-orientation="landscape"] .doc-paper--a5 { width: 794px; }
.modal--print .print-preview__document[data-orientation="landscape"] .doc-page { min-height: 744px; }
.modal--print .print-preview__document .doc-page__body { min-height: 700px; }
.modal--print .print-preview__document .doc-paper--a5 .doc-page__body { min-height: 480px; }
.modal--print .print-preview__document .doc-paper--80mm .doc-page__body { min-height: 480px; }
@media (max-width: 767.98px) {
  .modal--print { width: calc(100vw - var(--space-16)); height: calc(100dvh - var(--space-16)); max-height: none; }
  .modal--print .modal__body { padding: var(--space-8); }
  .modal--print .print-workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .modal--print .print-settings { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: var(--space-8); max-height: 220px; padding: var(--space-8); }
  .modal--print .print-settings__heading { grid-column: 1 / -1; }
  .modal--print .print-settings__notes { grid-column: 1 / -1; }
  .modal--print .print-preview__canvas { padding: var(--space-12); }
  .modal--print .print-preview__zoom { gap: var(--space-4); }
  .modal--print .print-preview__zoom .btn { padding-inline: var(--space-8); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--dialog-padding);
  border-bottom: 1px solid var(--border-default);
}

.modal__header--plain {
  border-bottom: 0;
}

.modal__header--tall {
  align-items: flex-start;
}

.modal__header-start {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal__title {
  font-size: var(--text-l);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.modal__header-end {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.modal__body {
  padding: var(--dialog-padding);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.modal__text {
  margin: 0;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-8);
  padding: var(--dialog-padding);
  border-top: 1px solid var(--border-default);
}

.modal__footer--plain {
  border-top: 0;
}
/* Premium record overview modal system */
.modal--premium {
  max-width: min(920px, calc(100vw - var(--space-24)));
  max-height: min(900px, calc(100dvh - var(--space-24)));
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-16);
  box-shadow: var(--shadow-emphasis);
}
.modal--premium .modal__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px minmax(0,1fr) auto;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-16) var(--space-20);
  background: var(--bg-surface);
}
.modal--premium .modal__header-start { gap: var(--space-4); }
.modal--premium .modal__title { color: var(--text-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.modal--premium .modal__subtitle { margin: 0; color: var(--text-secondary); font-size: var(--text-s); }
.modal__header-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-12);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: var(--icon-size-l);
}
.modal--premium .modal__header-end { gap: var(--space-12); }
.modal--premium .modal__header-end .form-card__code {
  padding: var(--space-8) var(--space-12);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-8);
  background: var(--bg-page-tint);
  color: var(--text-secondary);
  font-size: var(--text-xs);
}
.modal--premium .modal__body {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-20);
  background: var(--bg-page);
}
.modal--premium .modal__footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  flex-wrap: wrap;
  gap: var(--space-8);
  padding: var(--space-12) var(--space-20);
  background: var(--bg-surface);
}
.modal--premium .modal__footer .btn { min-height: 40px; }
.modal--premium .modal__footer .btn--primary { order: 5; }
.modal--premium .modal__action { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8); }
.modal--premium .modal__action .material-symbols-rounded { font-size: var(--icon-size-m); }

.modal--premium .summary-list {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: var(--space-8);
  margin: 0;
}
.modal--premium .summary-list__row {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-12);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
}
.modal--premium .summary-list__row dt {
  color: var(--text-muted);
  font-size: var(--text-xs);
}
.modal--premium .summary-list__row dd {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--text-s);
  font-weight: var(--weight-medium);
  overflow-wrap: anywhere;
}
.modal--premium .summary-list__row dd a { color: var(--brand-primary); text-decoration: underline; overflow-wrap: anywhere; }
.modal--premium .summary-list__row dd b { color: var(--text-primary); font-weight: var(--weight-semibold); }
.modal--premium .summary-list__row dd .status { align-self: flex-start; }
.modal--premium .modal__body > .summary-list + .form-card__title { margin-top: var(--space-8); }
.modal--premium .modal__body > .summary-list:empty { display: none; }
.modal--premium .modal__warning { border-radius: var(--radius-8); }
.modal--premium .form-card__title {
  margin: 0;
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: var(--text-m);
}
.modal--premium .table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
}
.modal--premium .data-table { min-width: 520px; }
.modal--premium .form-grid { gap: var(--space-12); }
.modal--premium .field { min-width: 0; }
.modal--premium .field__label { color: var(--text-secondary); }

@media (max-width: 767.98px) {
  .modal--premium {
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - var(--space-8) * 2);
    border-radius: var(--radius-12);
  }
  .modal--premium .modal__header { grid-template-columns: 36px minmax(0,1fr) auto; gap: var(--space-8); padding: var(--space-12); }
  .modal--premium .modal__body { gap: var(--space-12); padding: var(--space-12); }
  .modal--premium .modal__footer { padding: var(--space-8) var(--space-12); }
  .modal--premium .modal__header-icon { width: 36px; height: 36px; font-size: var(--icon-size-m); }
  .modal--premium .modal__title { font-size: var(--text-l); }
  .modal--premium .modal__header-end { gap: var(--space-4); }
  .modal--premium .modal__header-end .form-card__code { padding: var(--space-4) var(--space-8); }
  .modal--premium .summary-list { grid-template-columns: 1fr 1fr; }
  .modal--premium .summary-list__row { padding: var(--space-8); }
}

/* Record-view refresh: editorial overview shell shared by application summaries. */
.modal--record-view { width: min(1120px, calc(100vw - 40px)); max-height: min(920px, calc(100dvh - 40px)); border: 1px solid var(--border-strong); border-radius: var(--radius-20); background: var(--bg-surface); }
.modal--record-view .modal__header { min-height: 76px; padding: var(--space-16) var(--space-24); border-bottom-color: var(--border-light); }
.modal--record-view .modal__header-icon { width: 44px; height: 44px; border: 1px solid var(--brand-primary-soft); border-radius: var(--radius-12); background: var(--brand-primary-light); }
.modal--record-view .modal__title { font-size: var(--text-xl); letter-spacing: -.025em; }
.modal--record-view .modal__subtitle { margin-top: var(--space-4); }
.modal--record-view .modal__header-end .form-card__code { border-radius: var(--radius-pill); }
.modal--record-view .modal__body { gap: var(--space-20); padding: var(--space-24); background: var(--bg-page); }
.modal--record-view .modal__footer { min-height: 68px; padding: var(--space-12) var(--space-24); }
.modal--record-view .modal__footer .btn { min-height: 40px; padding-inline: var(--space-16); }
.modal--record-view { max-width: min(1160px, calc(100vw - 32px)); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; }
.modal--record-view .modal__header { position: relative; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-16); }
.modal--record-view .modal__header > .modal__header-icon { display: none; }
.modal--record-view .modal__header-start { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); }
.modal--record-view .modal__header-start .modal__title { margin: 0; font-size: var(--text-xl); }
.modal--record-view .modal__header-start .modal__subtitle { margin: 0; }
.record-view__header-type { display: block; margin-bottom: var(--space-4); color: var(--text-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .07em; text-transform: uppercase; }
.modal--record-view .modal__header-end { flex-direction: row-reverse; }
.modal--record-view .modal__header-end { flex-direction: row; }
.record-view__reference { display: inline-flex; align-items: center; padding: var(--space-8) var(--space-12); border: 1px solid var(--border-default); border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.record-view__header-status { display: inline-flex; align-items: center; padding: var(--space-8) var(--space-12); border: 1px solid var(--info-soft); border-radius: var(--radius-pill); background: var(--info-soft); color: var(--info); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.modal--record-view .modal__body { width: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.modal--record-view .modal__footer { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
.record-view { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; gap: var(--space-16); color: var(--text-primary); }
.record-view__metrics { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-12); }
.record-view__metric { display: flex; min-width: 0; align-items: flex-start; gap: var(--space-12); padding: var(--space-16); border: 1px solid var(--border-light); border-radius: var(--radius-12); background: var(--bg-surface); }
.record-view__metric-icon { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: var(--radius-8); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-m); }
.record-view__metric-copy { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); }
.record-view__metric-copy small { color: var(--text-tertiary); font-size: var(--text-xs); }
.record-view__metric-copy b { color: var(--text-primary); font-size: var(--text-l); font-weight: var(--weight-semibold); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.record-view__metric-copy em { color: var(--text-tertiary); font-size: var(--text-xs); font-style: normal; }
.record-view__content, .record-view__aside { display: grid; min-width: 0; gap: var(--space-12); }
.record-view__content { grid-column: 1; }
.record-view__aside { grid-column: 2; }
.record-view--single .record-view__content { grid-column: 1 / -1; }
.record-view--single .record-view__content .record-view__details { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.record-view--single .record-view__aside .record-view__details { grid-template-columns: 1fr; }
.record-view__section { min-width: 0; padding: var(--space-16); border: 1px solid var(--border-light); border-radius: var(--radius-12); background: var(--bg-surface); }
.record-view__section-heading { display: flex; min-width: 0; align-items: center; gap: var(--space-12); margin-bottom: var(--space-12); }
.record-view__section-heading > .material-symbols-rounded { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--brand-primary); font-size: var(--icon-size-m); }
.record-view__section-heading h3 { margin: 0; color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.record-view__section-heading p { margin: var(--space-4) 0 0; color: var(--text-tertiary); font-size: var(--text-xs); }
.record-view__section-count { display: grid; min-width: 28px; height: 28px; margin-left: auto; place-items: center; border-radius: var(--radius-pill); background: var(--bg-inset); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.record-view__details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-20); margin: 0; }
.record-view__detail { display: grid; min-width: 0; grid-template-columns: minmax(90px, .75fr) minmax(0, 1.25fr); align-items: start; gap: var(--space-8); padding: var(--space-12) 0; border-top: 1px solid var(--border-light); }
.record-view__detail dt { color: var(--text-tertiary); font-size: var(--text-xs); }
.record-view__detail dd { min-width: 0; margin: 0; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-medium); line-height: var(--leading-relaxed); overflow-wrap: anywhere; }
.record-view__detail dd a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 2px; }
.record-view__activity { display: grid; gap: var(--space-12); margin: 0; padding: 0; list-style: none; }
.record-view__activity li { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: start; gap: var(--space-8); }
.record-view__activity-icon { display: grid; width: 26px; height: 26px; place-items: center; border-radius: var(--radius-pill); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-s); }
.record-view__activity li > div { min-width: 0; }
.record-view__activity b { display: block; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); }
.record-view__activity p, .record-view__activity time { display: block; margin: var(--space-4) 0 0; color: var(--text-tertiary); font-size: var(--text-xs); overflow-wrap: anywhere; }
.record-view__related { display: grid; gap: var(--space-8); }
.record-view__related-item { display: flex; min-width: 0; align-items: center; gap: var(--space-8); padding: var(--space-8); border: 1px solid var(--border-light); border-radius: var(--radius-8); color: var(--text-primary); text-decoration: none; }
.record-view__related-item > span:first-child { color: var(--brand-primary); }
.record-view__related-item > span:nth-child(2) { display: grid; min-width: 0; flex: 1; gap: var(--space-4); }
.record-view__related-item b { font-size: var(--text-s); overflow-wrap: anywhere; }
.record-view__related-item small { color: var(--text-tertiary); font-size: var(--text-xs); }
.record-view__table-wrap, .record-view__section .table-scroll { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--border-light); border-radius: var(--radius-8); }
.record-view__table { width: 100%; border-collapse: collapse; }
.record-view__table th, .record-view__table td { padding: var(--space-12); border-bottom: 1px solid var(--border-light); color: var(--text-primary); font-size: var(--text-s); text-align: left; }
.record-view__table th { color: var(--text-tertiary); font-weight: var(--weight-semibold); }
.record-view__table .is-numeric, .record-view__table th.is-numeric { text-align: right; }
.record-view__empty { margin: 0; padding: var(--space-12); border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--text-tertiary); font-size: var(--text-s); }
.record-view__progress > div { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-8); }
.record-view__progress > div b { color: var(--brand-primary); font-size: var(--text-xl); }
.record-view__progress > div span, .record-view__progress > p { color: var(--text-secondary); font-size: var(--text-s); }
.record-view__progress progress { width: 100%; height: 8px; accent-color: var(--brand-primary); }
.record-view__progress > p { margin: var(--space-8) 0; }
.record-view__progress ol { display: grid; gap: var(--space-4); margin: var(--space-8) 0 0; padding: 0; list-style: none; }
.record-view__progress li { display: flex; align-items: center; gap: var(--space-8); color: var(--text-tertiary); font-size: var(--text-xs); }
.record-view__progress li > span { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--border-default); border-radius: var(--radius-pill); font-size: var(--text-xs); }
.record-view__progress li.is-done, .record-view__progress li.is-current { color: var(--text-primary); }
.record-view__progress li.is-done > span, .record-view__progress li.is-current > span { border-color: var(--brand-primary); background: var(--brand-primary); color: var(--text-inverse); }
.record-view__action-menu { position: relative; }
.record-view__action-menu > summary { display: inline-flex; min-height: 40px; align-items: center; gap: var(--space-8); padding: 0 var(--space-12); border: 1px solid var(--border-default); border-radius: var(--radius-control); background: var(--bg-surface); color: var(--text-primary); cursor: pointer; list-style: none; }
.record-view__action-menu > summary::-webkit-details-marker { display: none; }
.record-view__action-menu-list { position: absolute; right: 0; bottom: calc(100% + var(--space-8)); z-index: 5; display: grid; min-width: 220px; gap: var(--space-4); padding: var(--space-8); border: 1px solid var(--border-default); border-radius: var(--radius-12); background: var(--bg-surface); }
.record-view__action-menu-list .btn { width: 100%; justify-content: flex-start; }
.record-overview { display: grid; gap: var(--space-16); min-width: 0; color: var(--text-primary); }
.record-overview > h1, .record-overview > h2, .record-overview > h3, .record-overview > h4 { margin: 0; color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.record-overview__identity { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(180px, .6fr); gap: 1px; overflow: hidden; border: 1px solid var(--border-default); border-radius: var(--radius-16); background: var(--border-light); }
.record-overview__identity-item { display: flex; min-width: 0; flex-direction: column; justify-content: center; gap: var(--space-8); min-height: 94px; padding: var(--space-16) var(--space-20); background: var(--bg-surface); }
.record-overview__identity-item--primary { position: relative; padding-left: var(--space-24); }
.record-overview__identity-item--primary::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-primary); content: ""; }
.record-overview__eyebrow { color: var(--text-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .09em; text-transform: uppercase; }
.record-overview__identity-item b { color: var(--text-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.record-overview__identity-item:not(.record-overview__identity-item--primary) b { font-size: var(--text-l); }
.record-overview__section { min-width: 0; padding: var(--space-20); border: 1px solid var(--border-light); border-radius: var(--radius-16); background: var(--bg-surface); }
.record-overview__section h4 { display: flex; align-items: center; gap: var(--space-8); margin: 0 0 var(--space-16); color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.record-overview__section h4 .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.record-overview__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 var(--space-20); margin: 0; }
.record-overview__grid .summary-list__row { display: grid; min-width: 0; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); align-items: start; gap: var(--space-8); padding: var(--space-12) 0; border: 0; border-top: 1px solid var(--border-light); border-radius: 0; background: transparent; }
.record-overview__grid .summary-list__row--wide { grid-column: 1 / -1; }
.record-overview__grid .summary-list__row dt { color: var(--text-tertiary); font-size: var(--text-xs); }
.record-overview__grid .summary-list__row dd { margin: 0; color: var(--text-primary); font-size: var(--text-s); overflow-wrap: anywhere; }
.record-overview__field { display: grid; min-width: 0; grid-template-columns: minmax(96px, .7fr) minmax(0, 1.3fr); align-items: start; gap: var(--space-8); padding: var(--space-12) 0; border-top: 1px solid var(--border-light); }
.record-overview__field--wide { grid-column: 1 / -1; grid-template-columns: minmax(96px, .25fr) minmax(0, 1fr); }
.record-overview__field dt { display: flex; min-width: 0; align-items: center; gap: var(--space-4); color: var(--text-tertiary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
  .record-overview__field dt .material-symbols-rounded { color: var(--text-muted); font-size: var(--icon-size-s); }
.record-overview__field dd { min-width: 0; margin: 0; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-medium); line-height: var(--leading-relaxed); overflow-wrap: anywhere; }
.record-overview__field dd a { color: var(--brand-primary); text-decoration: underline; text-underline-offset: 2px; }
.record-overview__field dd b { font-weight: var(--weight-semibold); }
.record-overview__field dd .status { display: inline-flex; }
.modal--record-view .table-scroll { border-color: var(--border-light); border-radius: var(--radius-12); }
.modal--record-view .modal__warning { border-radius: var(--radius-12); }
.modal--record-view .project-summary__hero, .modal--record-view .order-summary__hero { border-radius: var(--radius-16); }
.modal--premium .modal__header-icon { display: grid; flex: 0 0 44px; align-self: center; }
.modal--premium .modal__header-start { min-width: 0; }
.modal--premium .modal__header-start .modal__title { margin: 0; }
.modal--premium .modal__header-start .modal__subtitle { margin: var(--space-4) 0 0; }
.modal--premium .modal__header > .modal__title { min-width: 0; flex: 1; }
.modal--premium .modal__header > .modal__header-start { flex: 1; }
.modal--premium .modal__header-end .icon-btn { flex: 0 0 var(--control-height-m); }
.modal--premium .modal__footer .btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-8); }
.modal--premium .modal__footer .btn .material-symbols-rounded { flex: 0 0 auto; font-size: var(--icon-size-m); }
.project-summary__panel > header { flex-wrap: nowrap; }
.project-summary__panel > header > .material-symbols-rounded { line-height: 1; }
@media (max-width: 767.98px) {
  .record-overview__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .record-view { grid-template-columns: minmax(0, 1fr); }
  .record-view__metrics, .record-view__content, .record-view__aside { grid-column: 1; }
  .record-view__aside { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 767.98px) {
  .modal--record-view { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: var(--radius-16); }
  .modal--record-view .modal__header { min-height: 0; padding: var(--space-12); }
  .modal--record-view .modal__body { gap: var(--space-12); padding: var(--space-12); }
  .modal--record-view .modal__footer { padding: var(--space-8) var(--space-12); }
  .record-overview { gap: var(--space-12); }
  .record-overview__identity { grid-template-columns: 1fr; }
  .record-overview__identity-item { min-height: 70px; padding: var(--space-12) var(--space-16); }
  .record-overview__identity-item--primary { padding-left: var(--space-20); }
  .record-overview__identity-item b { font-size: var(--text-l); }
  .record-overview__section { padding: var(--space-12); }
  .record-overview__grid { grid-template-columns: 1fr; }
  .record-overview__grid .summary-list__row { grid-template-columns: minmax(96px, .7fr) minmax(0, 1.3fr); }
  .record-overview__field--wide { grid-column: auto; }
  .modal--record-view { max-width: calc(100vw - 16px); }
  .modal--record-view .modal__header { grid-template-columns: minmax(0,1fr) auto; }
  .modal--record-view .modal__header-end { gap: var(--space-4); }
  .modal--record-view .modal__footer { flex-wrap: wrap; }
  .record-view { gap: var(--space-12); }
  .modal--record-view .modal__header-end .record-view__reference { max-width: 84px; overflow: hidden; padding: var(--space-4) var(--space-8); text-overflow: ellipsis; }
  .modal--record-view .modal__header-end .record-view__header-status { padding: var(--space-4) var(--space-8); }
  .record-view__metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8); }
  .record-view__metric { gap: var(--space-8); padding: var(--space-8); }
  .record-view__metric-icon { width: 28px; height: 28px; flex-basis: 28px; font-size: var(--icon-size-s); }
  .record-view__metric-copy b { font-size: var(--text-m); }
  .record-view__section { padding: var(--space-12); }
  .record-view__details, .record-view__aside { grid-template-columns: 1fr; }
  .record-view__detail { grid-template-columns: minmax(88px, .75fr) minmax(0, 1.25fr); }
  .record-view__reference { max-width: 84px; overflow: hidden; padding: var(--space-4) var(--space-8); text-overflow: ellipsis; }
  .record-view__header-status { max-width: 104px; overflow: hidden; text-overflow: ellipsis; }
}


/* Printing a View modal's Print button: window.print() always prints the whole
   page, so while a modal is open, hide everything else and let only the modal
   content flow onto the page (its own action buttons excluded). Gated on
   body.has-modal (toggled by modal.js) rather than :has(.modal-overlay) -
   :has() support inside @media print has been inconsistent, and a
   fixed-position element that isn't correctly repositioned here typically
   prints as a blank page rather than failing loudly. */
@media print {
  body.has-modal .app-shell {
    display: none;
  }

  body.has-modal .modal-overlay {
    position: static;
    background: none;
    padding: 0;
    display: block;
  }

  body.has-modal .modal {
    max-width: none;
    max-height: none;
    border: 0;
    /* Short modal content (a plain summary list, a bulk-export table) would
       otherwise leave the page's gray canvas showing below it instead of a
       full white fill, for every printed modal, not just document-style
       ones. On paper this is A4 (297mm) minus @page's 24mm margin on both
       top and bottom = 249mm, but binary-searching actual print renders
       found this browser's real usable page height for this layout lands
       between 247mm and 248mm, not the theoretical 249mm - at 248mm or
       above, the modal box's own forced height tips a hair past the real
       page boundary and spills a blank second page for every short,
       single-page document (Letter, Invoice, etc.). 246mm stays safely
       under that measured edge; the couple of millimetres of shortfall on
       the white fill isn't visible. */
    min-height: 246mm;
  }

  .modal:not(.modal--print) > .modal__header,
  .modal:not(.modal--print) > .modal__footer {
    display: none;
  }

  /* The modal's own padding would bypass doc-page's fixed
     __header/__footer bands, which anchor to the page box itself. */
  .modal:not(.modal--print) .modal__body:has(.doc-page) {
    padding: 0;
  }

  /* Most pages don't load print.css (that's only pulled in by the handful of
     controllers with a real document to print), so without this the browser
     falls back to its own default print margins, which don't match the
     min-height above and leaves a gray gap at the bottom of the page. */
  @page {
    size: auto;
    margin: 12mm;
  }

  body.has-modal .modal--print { width: auto; height: auto; min-height: 0; max-height: none; overflow: visible; }
  body.has-modal .modal--print .doc-paper { break-after: page; page-break-after: always; }
  body.has-modal .modal--print .doc-paper:last-child { break-after: auto; page-break-after: auto; }
}

/* Toast (transient status notifications, stacked bottom-right) */
.toast-stack {
  position: fixed;
  right: var(--space-12);
  bottom: var(--space-12);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-8);
  width: 100%;
  max-width: 360px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  padding: var(--card-padding);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-none);
  opacity: 0;
  transform: translateY(var(--space-8));
  transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(var(--space-4));
}

.toast__icon {
  flex-shrink: 0;
  font-size: var(--icon-size-m);
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.toast__message {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  margin-top: var(--space-4);
}

.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
}

.toast__close .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.toast--success { border-color: var(--success-soft); background: var(--success-soft); }
.toast--success .toast__icon { color: var(--success); }
.toast--success .toast__title { color: var(--success); }

.toast--error { border-color: var(--danger-soft); background: var(--danger-soft); }
.toast--error .toast__icon { color: var(--danger); }
.toast--error .toast__title { color: var(--danger); }

.toast--warning { border-color: var(--warning-soft); background: var(--warning-soft); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--warning .toast__title { color: var(--warning); }

.toast--info { border-color: var(--info-soft); background: var(--info-soft); }
.toast--info .toast__icon { color: var(--info); }
.toast--info .toast__title { color: var(--info); }

@media (max-width: 767.98px) {
  .toast-stack {
    left: var(--space-12);
    right: var(--space-12);
    max-width: none;
  }

  body:has(.app-mobile-nav) .toast-stack { bottom: calc(var(--header-height) + env(safe-area-inset-bottom, 0px) + var(--space-8)); }
}

/* Combobox (search & dropdown for relational fields) */
.combobox {
  position: relative;
}

.combobox__control {
  position: relative;
  display: flex;
  align-items: center;
}

.combobox__input {
  width: 100%;
  padding-right: calc(var(--space-12) + var(--icon-size-s));
}

.combobox__icon {
  position: absolute;
  right: var(--space-12);
  color: var(--text-muted);
  font-size: var(--icon-size-s);
  pointer-events: none;
}

.combobox__list {
  position: absolute;
  top: calc(100% + var(--space-4));
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-none);
  animation: dropdown-panel-in var(--duration-fast) var(--ease-standard);
}

/* Shared entrance animation for dropdown-style panels (combobox list,
   date-picker/time-picker panels) - these toggle the `hidden` attribute
   rather than a class, so a CSS transition (which needs two committed
   states) can't drive them; a keyframe animation plays automatically the
   moment `hidden` is removed and the element becomes displayable. There is
   no matching exit animation since removing `hidden` again is instant. */
@keyframes dropdown-panel-in {
  from {
    opacity: 0;
    transform: translateY(calc(var(--space-4) * -1));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }

  .combobox__list,
  .date-picker__panel,
  .time-picker__panel {
    animation: none;
  }
}

/* Password / PIN field with inline show-hide toggle */
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field__input {
  width: 100%;
  padding-right: calc(var(--space-8) + var(--icon-size-m) + var(--space-4));
}

.password-field__toggle {
  position: absolute;
  right: var(--space-8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--icon-size-m);
  height: var(--icon-size-m);
  border: 0;
  border-radius: var(--radius-4);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-field__toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.password-field__toggle .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

/* Password / PIN strength meter */
.password-strength {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
}

.password-strength__track {
  flex: 1;
  display: flex;
  gap: var(--space-4);
}

.password-strength__segment {
  height: var(--space-4);
  flex: 1;
  border-radius: var(--radius-4);
  background: var(--border-default);
}

.password-strength__segment.is-filled--weak {
  background: var(--danger);
}

.password-strength__segment.is-filled--medium {
  background: var(--warning);
}

.password-strength__segment.is-filled--strong {
  background: var(--success);
}

.password-strength__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  white-space: nowrap;
}

.password-strength__label--weak {
  color: var(--danger);
}

.password-strength__label--medium {
  color: var(--warning);
}

.password-strength__label--strong {
  color: var(--success);
}

.combobox__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-8) var(--space-8);
  border-radius: var(--radius-8);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  cursor: pointer;
}

.combobox__option.is-active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

.combobox__option-meta {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  flex-shrink: 0;
}

.combobox__option.is-active .combobox__option-meta {
  color: var(--brand-primary);
}

.combobox__empty {
  padding: var(--space-8);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
  text-align: center;
}

/* Time picker */
.time-picker {
  position: relative;
}

.time-picker__control {
  position: relative;
  display: flex;
  align-items: center;
}

.time-picker__input {
  width: 100%;
  padding-right: calc(var(--space-12) + var(--icon-size-s));
  cursor: pointer;
}

.time-picker__icon {
  position: absolute;
  right: var(--space-12);
  color: var(--text-muted);
  font-size: var(--icon-size-s);
  pointer-events: none;
}

.time-picker__panel {
  position: fixed;
  top: calc(100% + var(--space-4));
  left: 0;
  /* Portalled to document.body while open (see time-picker.js) - a sibling
     of .modal-overlay (z-index 100), so this must clear that to render on
     top of an open modal instead of behind it. */
  z-index: 150;
  width: 224px;
  padding: var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-none);
  animation: dropdown-panel-in var(--duration-fast) var(--ease-standard);
}

.time-picker__columns {
  display: flex;
  gap: var(--space-4);
}

.time-picker__col {
  flex: 1;
  max-height: 176px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.time-picker__col--meridiem {
  flex: 0 0 56px;
  max-height: none;
  overflow: visible;
}

.time-picker__option {
  padding: var(--space-8) var(--space-8);
  border-radius: var(--radius-8);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  text-align: center;
  cursor: pointer;
}

.time-picker__option:hover {
  background: var(--bg-hover);
}

.time-picker__option.is-active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

.time-picker__footer {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-default);
}

.time-picker__quick,
.time-picker__done {
  flex: 1;
  height: var(--control-height-s);
  border: 1px solid transparent;
  border-radius: var(--radius-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  cursor: pointer;
}

.time-picker__quick {
  background: var(--bg-page);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.time-picker__quick:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.time-picker__done {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.time-picker__done:hover {
  filter: brightness(1.05);
}

/* Date picker */
.date-picker {
  position: relative;
}

.date-picker__control {
  position: relative;
  display: flex;
  align-items: center;
}

.date-picker__input {
  width: 100%;
  padding-right: calc(var(--space-12) + var(--icon-size-s));
  cursor: pointer;
}

.date-picker__icon {
  position: absolute;
  right: var(--space-12);
  color: var(--text-muted);
  font-size: var(--icon-size-s);
  pointer-events: none;
}

.date-picker__panel {
  position: fixed;
  top: calc(100% + var(--space-4));
  left: 0;
  /* Portalled to document.body while open (see date-picker.js) - a sibling
     of .modal-overlay (z-index 100), so this must clear that to render on
     top of an open modal instead of behind it. */
  z-index: 150;
  width: 264px;
  padding: var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  box-shadow: var(--shadow-none);
  animation: dropdown-panel-in var(--duration-fast) var(--ease-standard);
}

.date-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}

.date-picker__label {
  font-size: var(--text-s);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.date-picker__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height-s);
  height: var(--control-height-s);
  border: 0;
  border-radius: var(--radius-8);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.date-picker__nav:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.date-picker__nav .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.date-picker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.date-picker__weekdays span {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
  text-align: center;
}

.date-picker__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-4);
}

.date-picker__day {
  height: var(--control-height-s);
  border: 0;
  border-radius: var(--radius-8);
  background: transparent;
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  color: var(--text-primary);
  cursor: pointer;
}

.date-picker__day:hover {
  background: var(--bg-hover);
}

.date-picker__day.is-adjacent {
  color: var(--text-muted);
}

.date-picker__day.is-today {
  outline: 1px solid var(--border-strong);
  outline-offset: -1px;
}

.date-picker__day.is-active {
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-weight: var(--weight-semibold);
}

.date-picker__footer {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-default);
}

.date-picker__quick,
.date-picker__done {
  flex: 1;
  height: var(--control-height-s);
  border: 1px solid transparent;
  border-radius: var(--radius-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  cursor: pointer;
}

.date-picker__quick {
  background: var(--bg-page);
  border-color: var(--border-default);
  color: var(--text-secondary);
}

.date-picker__quick:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.date-picker__done {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.date-picker__done:hover {
  filter: brightness(1.05);
}

/* Health check page - a hero banner with the aggregate status, plus a
   grid of small labelled check cards grouped into sections (Application,
   Database, Infrastructure, Automation, Backup & Mail) rather than one
   long vertical table. */
/* Package page's 4 pipeline stages (Build/Download/Upload/Deploy), each
   its own ring card - a fixed identity color per stage (blue/green/red/
   amber), same convention as the Health pillars. */
.package-ring-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-12);
}

.package-ring-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-8);
  padding: var(--card-padding);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
}

.package-ring-card__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.package-ring-card__status {
  font-size: var(--text-s);
  color: var(--text-secondary);
  min-height: 18px;
}

.package-ring-card .btn {
  width: 100%;
  justify-content: center;
}

/* Health Trend chart (2/3) + Health Status Matrix (1/3) side by side. */
.health-overview-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-12);
  align-items: start;
}

.health-matrix-row__meta {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  margin-left: auto;
  flex-shrink: 0;
}

.health-matrix-row__time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Health page hero: three pillar cards (Application/Database/System),
   each a real ring of that pillar's own checks-passing % - never one
   combined score split three ways. */
.health-pillar-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-12);
}

.health-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--card-padding);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
}

.health-pillar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-8);
}

.health-pillar__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.health-pillar__header .status {
  flex-shrink: 0;
}

.health-pillar__ring {
  margin: var(--space-16) 0 var(--space-8);
}

.health-pillar__caption {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.health-pillar__summary {
  margin-top: var(--space-4);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.health-pillar__footer {
  width: 100%;
  margin-top: var(--space-16);
  padding-top: var(--space-12);
  border-top: 1px solid var(--border-light);
  text-align: left;
}

.health-pillar__footer-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.health-pillar__footer-value {
  margin-top: var(--space-4);
  font-size: var(--text-s);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Small leading dot on a .status pill (used in the health-pillar header)
   - inherits its color from the pill's own text color, no new token. */
.status-dot {
  width: var(--space-8);
  height: var(--space-8);
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Health page detail: three label/value diagnostic panels (Application/
   Database/System), one per pillar above - a dense "spec sheet" list
   rather than another row of icon chips and tags. */
.diagnostic-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-12);
  align-items: start;
}

.diagnostic-panel {
  padding: var(--card-padding);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
}

.diagnostic-panel__title {
  padding-bottom: var(--space-8);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-default);
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

.diagnostic-list__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-8);
  padding: var(--space-8) 0;
  border-bottom: 1px solid var(--border-light);
}

.diagnostic-list__row:last-child {
  border-bottom: 0;
}

.diagnostic-list__row dt {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.diagnostic-list__row dd {
  margin: 0;
  min-width: 0;
  font-size: var(--text-s);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Tone set by health.php: class="is-' . $tone . '" */
.diagnostic-list__row dd.is-success { color: var(--success); }
.diagnostic-list__row dd.is-warning { color: var(--warning); }
.diagnostic-list__row dd.is-danger { color: var(--danger); }

/* KPI cards - one shared design for the whole project via View::kpiCard().
   Same surface as every other card (border, card radius, card padding). The
   soft colored icon tile sits beside the uppercase label and bold tabular
   value. The tile color follows the card's row position
   (info, success, danger, warning). */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-12);
}

.kpi-card {
  position: relative;
  padding: var(--card-padding);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  gap: var(--identity-gap);
  min-width: 0;
}

.kpi-card__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--identity-icon-size);
  height: var(--identity-icon-size);
  border-radius: var(--radius-control);
  background: var(--info-soft);
  color: var(--info);
  transform: translateY(calc(var(--identity-text-offset-y) * -1));
}

.kpi-card__icon .material-symbols-rounded {
  font-size: var(--icon-size-m);
}

.kpi-card--success .kpi-card__icon { background: var(--success-soft); color: var(--success); }
.kpi-card--danger .kpi-card__icon { background: var(--danger-soft); color: var(--danger); }
.kpi-card--warning .kpi-card__icon { background: var(--warning-soft); color: var(--warning); }

.kpi-card__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  align-content: center;
  column-gap: var(--space-8);
  row-gap: var(--identity-text-gap);
  min-width: 0;
}

.kpi-card__label {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card__value {
  grid-column: 1 / -1;
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Borderless status list - one shared design for any page's "list of
   items with a severity/category icon and a trailing status tag"
   (dashboard's Needs Attention/Recent Activity/Reminders, Counter's
   drawer balances, and any future page needing the same shape). Every
   row's icon chip is colored by severity/category; the trailing tag
   carries the row's status. */
.attention-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.attention-row {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-8) var(--space-12);
  border-top: 1px solid var(--border-light);
}

.attention-row:first-child {
  border-top: 0;
}

/* A standalone attention row placed directly inside a card is not a list
   item and should not inherit the list separator line. */
.attention-row--standalone {
  border-top: 0;
}

.attention-row__icon {
  display: grid;
  place-items: center;
  width: var(--icon-size-l);
  height: var(--icon-size-l);
  border-radius: var(--radius-4);
  flex-shrink: 0;
}

.attention-row__icon .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.attention-row--info .attention-row__icon {
  background: var(--info-soft);
  color: var(--info);
}

.attention-row--success .attention-row__icon {
  background: var(--success-soft);
  color: var(--success);
}

.attention-row--warning .attention-row__icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.attention-row--danger .attention-row__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.attention-row__desc {
  font-size: var(--text-s);
  font-weight: var(--weight-semibold);
  flex-shrink: 0;
}

.attention-row__reason {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Trailing group of small .status pills (e.g. one per checked extension
   or storage path) in place of a single .tag, for attention-rows that
   report on several sub-items at once. */

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  flex-shrink: 0;
}

.tag--success {
  background: var(--success-soft);
  color: var(--success);
}

.tag--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.tag--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.tag--info {
  background: var(--info-soft);
  color: var(--info);
}

.tag--neutral {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-weight: var(--weight-regular);
  font-variant-numeric: tabular-nums;
}

/* "+N more" after a list cell's first item (window.itemSummaryHtml); hover lists every item. */
.item-more {
  margin-left: var(--space-4);
  padding: 0 var(--space-4);
  white-space: nowrap;
  cursor: help;
}

/* Radial progress ring (e.g. storage/usage percentage) - pure CSS, set --value: 0-100 inline */
.radial-progress {
  --value: 0;
  position: relative;
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: 50%;
  background: conic-gradient(var(--brand-primary) calc(var(--value) * 1%), var(--bg-hover) 0);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.radial-progress::before {
  content: '';
  position: absolute;
  inset: var(--space-8);
  border-radius: 50%;
  background: var(--bg-surface);
}

.radial-progress__value {
  position: relative;
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.radial-progress--success {
  background: conic-gradient(var(--success) calc(var(--value) * 1%), var(--bg-hover) 0);
}

.radial-progress--warning {
  background: conic-gradient(var(--warning) calc(var(--value) * 1%), var(--bg-hover) 0);
}

.radial-progress--danger {
  background: conic-gradient(var(--danger) calc(var(--value) * 1%), var(--bg-hover) 0);
}

.radial-progress--lg {
  width: 120px;
  height: 120px;
  min-width: 120px;
}

.radial-progress--lg::before {
  inset: var(--space-12);
}

.radial-progress--lg .radial-progress__value {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

/* Linear progress bar (Package build/upload feedback) - stays visible at 0%
   at rest so the card never looks empty, then fills toward 100% while its
   operation runs. */

.package-action {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  padding-top: var(--space-8);
}

.package-action__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-12);
}

.chart-card--wide {
  grid-column: span 2;
}

.chart-card {
  padding: var(--card-padding);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.chart-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-8);
}

.chart-card__title {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.chart-card__subtitle {
  margin-top: var(--identity-text-gap);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

.chart-card__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--identity-gap);
}

.chart-card__identity-icon {
  display: grid;
  width: var(--identity-icon-size);
  height: var(--identity-icon-size);
  flex: 0 0 var(--identity-icon-size);
  place-items: center;
  border-radius: var(--radius-8);
  background: var(--info-soft);
  color: var(--info);
  font-size: var(--icon-size-l);
  transform: translateY(calc(var(--identity-text-offset-y) * -1));
}

.chart-card__identity-copy { min-width: 0; }
.chart-card__identity-copy .chart-card__subtitle { margin-top: var(--identity-text-gap); }

.chart-card__body {
  min-height: 220px;
  position: relative;
}

.chart-axis-label {
  font-size: var(--text-xs);
  fill: var(--text-muted);
  font-family: var(--font-primary);
}

.chart-gridline {
  stroke: var(--border-default);
  stroke-width: 1;
}

.chart-card__body--center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.chart-card__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-12);
}

.chart-legend__item {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.chart-legend__swatch {
  width: var(--space-12);
  height: var(--space-8);
  border-radius: var(--radius-4);
  flex-shrink: 0;
}

.chart-legend__value {
  color: var(--text-muted);
}

.chart-legend__item--toggle {
  cursor: pointer;
  align-items: center;
}

.chart-legend__item--toggle input[type="checkbox"] {
  width: var(--icon-size-s);
  height: var(--icon-size-s);
  margin: 0;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* Table card */
.table-card {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  background: var(--bg-surface);
  overflow: hidden;
  box-shadow: none;
}

/* Server-paged tables (paged-table.js) while the next page loads: the current rows stay, dimmed and not clickable. */
.table-card.is-loading tbody {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.table-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
  padding: var(--card-padding);
  border-bottom: 1px solid var(--border-default);
}

.table-card__title {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.card-subtitle {
  margin-top: var(--identity-text-gap);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-tertiary);
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
}

.data-table th,
.data-table td {
  padding: var(--space-8) var(--space-12);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-default);
}

/* A row's height is just the max of its cells' natural content height, so
   a table whose Action column holds compact row buttons (28px) renders
   taller rows than one with plain text or a .status pill only. Every cell
   gets the action row's own height as its floor (compact control + the
   cell's 8px top/bottom padding + 1px bottom border, border-box), so every
   .data-table row is the same height app-wide, action buttons or not. */
.data-table td {
  height: calc(var(--control-height-s) + var(--space-8) * 2 + 1px);
}

/* A long free-text column (e.g. a notification message) truncates with an
   ellipsis instead of forcing the whole table wider - full text is still
   available via the row's View action. */
.table-cell--truncate {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table th {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  background: var(--bg-page-tint);
  text-align: center;
}

.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-standard);
}

.data-table tbody tr:hover {
  background: var(--bg-page-tint);
}

.data-table__primary,
.data-table__secondary {
  display: block;
}

.data-table__primary {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

.data-table .data-table__primary.data-table__amount--danger {
  color: var(--danger);
}

.data-table__secondary {
  margin-top: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

.data-table td.transaction-outstanding--unpaid .data-table__primary,
.data-table td.transaction-outstanding--unpaid .data-table__secondary {
  color: var(--danger);
}

.data-table .data-table__secondary.transaction-outstanding--unpaid {
  color: var(--danger);
}

.data-table .is-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table th.is-numeric {
  text-align: center;
}

/* A Status pill or a row's action buttons read better centered under
   .data-table th's own centered header text than left-aligned - matched
   by content (every such cell already wraps its contents in .status or
   .row-actions app-wide) rather than a column-index/class the markup
   would otherwise need adding to individually on every table. */
.data-table td:has(.status),
.data-table td:has(.row-actions) {
  text-align: center;
}

.data-table .is-negative {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}

.data-table .transaction-outstanding--unpaid {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}

.data-table .transaction-amount--outflow {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}

.row-actions {
  display: inline-flex;
  gap: var(--space-4);
}

.bulk-select-cell {
  width: var(--control-height-m);
  white-space: nowrap;
}

.bulk-checkbox {
  width: var(--icon-size-s);
  height: var(--icon-size-s);
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.data-table tbody tr.is-selected {
  background: var(--bg-hover);
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
  padding: var(--space-12) var(--card-padding);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-page);
}

.bulk-toolbar__count {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.bulk-toolbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  flex-wrap: wrap;
}

.bulk-toolbar__actions [disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.table-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  flex-wrap: wrap;
  padding: var(--card-padding);
  border-top: 1px solid var(--border-default);
}

.table-card__page-size {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  flex-wrap: wrap;
}

.table-card__page-size-select {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

.table-card__page-size-select select {
  height: var(--control-height-s);
  padding: 0 var(--space-8);
  font-size: var(--text-xs);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.table-card__page-size-select .field-icon-wrap {
  width: auto;
}

.table-card__page-size-select select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.table-card__count {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

.table-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-12);
  text-align: center;
}

.table-empty .material-symbols-rounded {
  font-size: var(--icon-size-xl);
  color: var(--text-muted);
}

.table-empty__title {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

.table-empty__desc {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

/* Error state (400/401/403/404/500/503/offline) - rendered inside the
   signed-out frame's card (auth.css), so it has no padding or width of its
   own. The icon badge matches .auth-card__icon; its tone comes from
   ErrorModel (info 404, warning 400/401/503/offline, danger 403/500). */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  text-align: center;
}

.error-state__icon {
  display: grid;
  place-items: center;
  width: var(--icon-size-2xl);
  height: var(--icon-size-2xl);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--danger-soft);
  color: var(--danger);
}

.error-state__icon .material-symbols-rounded {
  font-size: var(--icon-size-l);
}

.error-state--info .error-state__icon { background: var(--info-soft); color: var(--info); }
.error-state--warning .error-state__icon { background: var(--warning-soft); color: var(--warning); }

.error-state__code {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-relaxed);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.error-state__title {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

.error-state__desc {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

/* Offline page: live connection state (public/js/error.js). */
.error-state__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-8);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
}

.error-state__status--success { background: var(--success-soft); color: var(--success); }
.error-state__status--danger { background: var(--danger-soft); color: var(--danger); }

.error-state__actions {
  display: flex;
  gap: var(--space-8);
  width: 100%;
  margin-top: var(--space-8);
}

.error-state__actions .btn {
  flex: 1;
  justify-content: center;
}

@media (max-width: 767.98px) {
  .error-state__actions {
    flex-direction: column-reverse;
  }
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.pagination__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-height-s);
  height: var(--control-height-s);
  padding: 0 var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.pagination__btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.pagination__btn.is-active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.pagination__btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-height-s);
  height: var(--control-height-s);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Status badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  white-space: nowrap;
}

.status--active,
.status--enabled,
.status--completed,
.status--done,
.status--paid,
.status--settled,
.status--deposited,
.status--withdrawn,
.status--transferred,
.status--approved,
.status--accepted,
.status--posted,
.status--matched,
.status--in-stock,
.status--trusted,
.status--built,
.status--build,
.status--applied,
.status--closed,
.status--success,
.status--healthy,
.status--operational,
.status--uploaded,
.status--upload,
.status--balanced,
.status--full-day {
  background: var(--success-soft);
  color: var(--success);
}

.status--completed,
.status--ready,
.status--collected {
  background: var(--success-soft);
  color: var(--success);
}

.status--progress,
.status--confirmed,
.status--production {
  background: var(--info-soft);
  color: var(--info);
}

.status--over-paid {
  background: var(--warning-soft);
  color: var(--warning);
}

.status--credit {
  background: var(--danger-soft);
  color: var(--danger);
}

.status--inactive,
.status--disabled,
.status--cancelled,
.status--dismissed,
.status--expired,
.status--removed,
.status--deleted {
  background: var(--danger-soft);
  color: var(--danger);
}

.status--pending,
.status--draft,
.status--due,
.status--unpaid,
.status--unrefunded,
.status--partially-paid,
.status--partial-paid,
.status--partially-refunded,
.status--partial-refund,
.status--partially-returned,
.status--discrepancy,
.status--low-stock,
.status--degraded,
.status--scheduled,
.status--staged,
.status--deploy,
.status--in-progress,
.status--overage,
.status--due-tomorrow,
.status--due-today,
.status--maintenance {
  background: var(--warning-soft);
  color: var(--warning);
}

.status--error,
.status--reversed,
.status--refunded,
.status--refund,
.status--over-refund,
.status--returned,
.status--overdue,
.status--rejected,
.status--out-of-stock,
.status--revoked,
.status--failed,
.status--down,
.status--critical,
.status--shortage,
.status--remains-overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

.status--info,
.status--upcoming,
.status--open,
.status--clocked-in,
.status--processed,
.status--unread,
.status--sent,
.status--downloaded,
.status--download,
.status--commission,
.status--upcoming-due {
  background: var(--info-soft);
  color: var(--info);
}

/* Priority badges (Workflow module) */
.priority {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-8);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  white-space: nowrap;
}

.priority--high {
  background: var(--danger-soft);
  color: var(--danger);
}

.priority--medium {
  background: var(--warning-soft);
  color: var(--warning);
}

.priority--low {
  background: var(--info-soft);
  color: var(--info);
}

/* Subsection (boxed group nested inside a form-card, e.g. Permission Matrix, Bundle Components) */
.subsection {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-card);
  background: var(--bg-page);
  padding: var(--card-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.subsection__title {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}

/* Variant picker (attribute + value multi-select used by Product/Service/Bundle) */
.variant-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.variant-picker__values {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

.variant-picker__group {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.variant-picker__actions {
  display: flex;
  justify-content: flex-start;
  margin-top: var(--space-12);
}

.variant-picker__grid {
  margin-top: var(--space-12);
}

/* Generated combination grid (inline-editable table cells) */
.data-table__input {
  width: 100%;
  min-width: 80px;
  height: var(--control-height-s);
  padding: 0 var(--space-8);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-4);
  background: var(--bg-surface);
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.data-table__input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.data-table__input:disabled {
  background: var(--bg-page);
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 767.98px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card--wide { grid-column: auto; }
  .kpi-row,
  .health-pillar-row,
  .diagnostic-row,
  .package-ring-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .health-overview-row { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
  .kpi-row,
  .health-pillar-row,
  .diagnostic-row,
  .package-ring-row {
    grid-template-columns: 1fr;
  }

  .kpi-card__label {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .page-header {
    flex-direction: column;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  /* Health diagnostics contain long technical names; stack each label above
     its value so the phone never squeezes or clips the text. */
  .diagnostic-panel { padding: var(--card-padding); border-radius: var(--radius-16); }
  .diagnostic-list__row { align-items: flex-start; flex-direction: column; gap: var(--space-4); padding: var(--space-8) 0; }
  .diagnostic-list__row dt { white-space: normal; overflow-wrap: anywhere; }
  .diagnostic-list__row dd { width: 100%; text-align: left; }
  .health-matrix-row__meta { flex-wrap: wrap; justify-content: flex-start; margin-left: 0; }
}

/* ---------- Title icons (one design system) ----------
   Page, form, table and chart titles carry data-icon="<material symbol>" and
   an optional data-tone. The icon is drawn as a pseudo-element so scripts that
   read or rewrite a title's textContent never see or remove it.
   Palette is limited to blue (info), green (success), red (danger), amber (warning). */
.page-header__title[data-icon],
.form-card__title[data-icon],
.table-card__title[data-icon],
.chart-card__title[data-icon],
.site-section__title[data-icon] {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}

.page-header__title[data-icon]::before,
.form-card__title[data-icon]::before,
.table-card__title[data-icon]::before,
.chart-card__title[data-icon]::before,
.site-section__title[data-icon]::before {
  content: attr(data-icon);
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 20;
  font-size: var(--icon-size-m);
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: var(--icon-size-2xl);
  height: var(--icon-size-2xl);
  border-radius: var(--radius-8);
  background: var(--info-soft);
  color: var(--info);
  user-select: none;
}

.page-header__title[data-icon]::before {
  width: var(--icon-size-2xl);
  height: var(--icon-size-2xl);
  border-radius: var(--radius-12);
  font-size: var(--icon-size-l);
}

[data-icon][data-tone="success"]::before { background: var(--success-soft); color: var(--success); }
[data-icon][data-tone="danger"]::before  { background: var(--danger-soft);  color: var(--danger); }
[data-icon][data-tone="warning"]::before { background: var(--warning-soft); color: var(--warning); }

/* Shared icon + title + subtitle header. The icon occupies its own leading
   column and centers against the complete text stack. */
.page-header__text:has(> .page-header__title[data-icon]),
.form-card__header > div:has(> .form-card__title[data-icon]),
.table-card__header > div:has(> .table-card__title[data-icon]),
.chart-card__header > div:has(> .chart-card__title[data-icon]),
.site-section__head > div:has(> .site-section__title[data-icon]) {
  display: grid;
  grid-template-columns: var(--identity-icon-size) minmax(0, 1fr);
  column-gap: var(--identity-gap);
  align-content: center;
  position: relative;
}

.page-header__text > .page-header__title[data-icon],
.form-card__header > div > .form-card__title[data-icon],
.table-card__header > div > .table-card__title[data-icon],
.chart-card__header > div > .chart-card__title[data-icon],
.site-section__head > div > .site-section__title[data-icon] {
  position: static;
  grid-column: 2;
  display: block;
  padding-left: 0;
}

.page-header__text > .page-header__title[data-icon]::before,
.form-card__header > div > .form-card__title[data-icon]::before,
.table-card__header > div > .table-card__title[data-icon]::before,
.chart-card__header > div > .chart-card__title[data-icon]::before,
.site-section__head > div > .site-section__title[data-icon]::before {
  position: absolute;
  top: calc(50% - var(--identity-text-offset-y));
  left: 0;
  transform: translateY(-50%);
}

.page-header__text > .page-header__desc,
.form-card__header > div > .card-subtitle,
.table-card__header > div > .card-subtitle,
.chart-card__header > div > .chart-card__subtitle,
.site-section__head > div > .site-section__desc {
  grid-column: 2;
  margin-left: 0;
}


/* ---------- Icon tones (applied by public/js/icon-tone.js) ----------
   One color per icon meaning, everywhere. `body` raises specificity above the
   component defaults that grey icons out (sidebar, header menus, footer, empty states). */
body .material-symbols-rounded.icon--info    { color: var(--info); }
body .material-symbols-rounded.icon--success { color: var(--success); }
body .material-symbols-rounded.icon--danger  { color: var(--danger); }
body .material-symbols-rounded.icon--warning { color: var(--warning); }

/* Icon + text pair used for small inline labels (header menus, footers). */
.with-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
}

.with-icon > .material-symbols-rounded {
  font-size: var(--icon-size-s);
}

.header-menu__footer.with-icon,
.header-menu__item[role="status"] .with-icon {
  display: flex;
  justify-content: center;
}

/* ---------- Field lead icons (added by public/js/field-icons.js) ----------
   Each input box shows its label's icon on the left, in the label icon's color. */
.field-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.field-icon-wrap > .field__control {
  width: 100%;
}

.has-lead-icon > .field__lead-icon {
  position: absolute;
  left: var(--space-12);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--icon-size-s);
  pointer-events: none;
  z-index: 1;
}

.has-lead-icon--textarea > .field__lead-icon {
  top: var(--space-12);
  transform: none;
}

.has-lead-icon .field__control {
  padding-left: calc(var(--space-12) + var(--icon-size-s) + var(--space-8));
}

/* Money boxes: icon, then "Rs.", then the amount. */
.field-prefix.has-lead-icon .field-prefix__symbol {
  left: calc(var(--space-12) + var(--icon-size-s) + var(--space-8));
}

.field-prefix.has-lead-icon .field-prefix__control {
  padding-left: calc(var(--space-12) + var(--icon-size-s) + var(--space-8) + var(--space-28));
}

/* Table content lines up with the card's side padding. */
.data-table th:first-child,
.data-table td:first-child {
  padding-left: var(--card-padding);
}

.data-table th:last-child,
.data-table td:last-child {
  padding-right: var(--card-padding);
}

/* Date and time boxes show their icon once, on the left (field lead icon);
   the decorative right-side calendar/clock is hidden and its space released. */
.date-picker__icon,
.time-picker__icon {
  display: none;
}

.date-picker__input,
.time-picker__input {
  padding-right: var(--space-12);
}

/* ---------- Profile menu (header) ---------- */
button.profile-trigger {
  font: inherit;
  cursor: pointer;
}

.profile-trigger:hover,
.profile-menu.is-open .profile-trigger {
  background: var(--bg-page);
  border-color: var(--border-default);
}

.profile-trigger__caret {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-standard);
}

.profile-menu.is-open .profile-trigger__caret {
  transform: rotate(180deg);
}

.profile-menu__panel {
  width: 300px;
  font-weight: var(--weight-regular);
}

/* Chip card: who is signed in. */
.profile-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12);
  margin-bottom: var(--space-8);
  padding: var(--space-12);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-page);
}

.avatar--lg {
  width: var(--icon-size-2xl);
  height: var(--icon-size-2xl);
  font-size: var(--text-l);
  flex-shrink: 0;
}

.profile-chip__text {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.profile-chip__name {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip__email {
  font-size: var(--text-s);
  font-weight: var(--weight-regular);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip__tags {
  /* Own row under avatar and name. */
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

/* Menu items rendered as <button> look the same as the link items. */
button.header-menu__item {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-menu__signout {
  margin-top: var(--space-4);
  border-top: 1px solid var(--border-default) !important;
  border-radius: 0 0 var(--radius-8) var(--radius-8);
}

/* Page permissions (data-can-* on <body>, from the role's grants): controls
   for actions the role may not take are not shown. The server refuses them too. */
body[data-can-edit="0"] .row-actions [data-action="edit"],
body[data-can-delete="0"] .row-actions [data-action="delete"],
body[data-can-delete="0"] [data-bulk-delete],
body[data-can-print="0"] .row-actions [data-action="print"],
body[data-can-download="0"] [data-bulk-excel],
body[data-can-approve="0"] .row-actions [data-action="approve"],
body[data-can-reject="0"] .row-actions [data-action="reject"],
body[data-can-create="0"][data-can-edit="0"] .form-card[id$="FormCard"] {
  display: none !important;
}

/* ---------- Rich text editor (public/js/rich-editor.js) ----------
   Toolbar of small icon buttons over an editable area styled like .field__control. */
.rich-editor { display: flex; flex-direction: column; border: 1px solid var(--border-default); border-radius: var(--radius-8); background: var(--bg-surface); overflow: hidden; }
.rich-editor:focus-within { border-color: var(--border-focus); }
.rich-editor.is-loading { opacity: 0.6; pointer-events: none; }
.rich-editor__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-8); border-bottom: 1px solid var(--border-default); background: var(--bg-subtle); position: sticky; top: 0; z-index: 1; }
.rich-editor__sep { width: 1px; height: var(--icon-size-m); background: var(--border-default); margin: 0 var(--space-4); }
.rich-editor__area { min-height: 280px; max-height: 70vh; overflow-y: auto; padding: var(--space-16); font-weight: var(--weight-regular); line-height: var(--leading-relaxed); color: var(--text-primary); outline: none; }
.rich-editor__area:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.rich-editor__area > * + * { margin-top: var(--space-12); }
.rich-editor__area h2 { font-size: var(--text-xl); }
.rich-editor__area h3 { font-size: var(--text-l); }
.rich-editor__area ul, .rich-editor__area ol { padding-left: var(--space-24); list-style: revert; }
.rich-editor__area blockquote { border-left: 3px solid var(--brand-primary); padding-left: var(--space-12); color: var(--text-secondary); }
.rich-editor__area img { max-width: 100%; border-radius: var(--radius-8); }
.rich-editor__area a { text-decoration: underline; }
/* ---------- Photo field (public/js/media-field.js): one cover photo or an ordered gallery ---------- */
/* The picker is a normal field box (.field__control) that opens the file dialog; chosen photos list under it. */
.media-field { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; }
.media-field__picker { display: flex; align-items: center; gap: var(--space-8); width: 100%; text-align: left; color: var(--text-muted); cursor: pointer; }
.media-field__picker .material-symbols-rounded { font-size: var(--icon-size-m); color: var(--text-secondary); }
.media-field__picker:hover:not(:disabled), .media-field__picker:focus-visible { border-color: var(--border-focus); outline: none; }
.media-field__picker:disabled { background: var(--bg-page); cursor: not-allowed; }
.media-field.is-disabled { pointer-events: none; }
.media-field.is-disabled .media-field__picker { background: var(--bg-page); }
.media-field.is-loading { opacity: 0.6; pointer-events: none; }

/* Email composer and mailbox */
.email-page { display: flex; flex-direction: column; gap: var(--space-16); }
.email-page__mailbox { min-width: 0; }
.email-page__filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: start; gap: var(--space-16); }
.email-page__filters .filter-bar__group { width: 100%; min-width: 0; }
.email-page__filters .segmented { display: flex; width: 100%; max-width: 100%; flex-wrap: wrap; }
.email-page__filters .segmented__btn { flex: 1 1 0; min-width: max-content; white-space: nowrap; }
.email-page__subject { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) {
  .email-page__filters { grid-template-columns: 1fr; }
}

/* ---------- Schedule page heading ---------- */
.schedule-page__today { display: flex; align-items: center; gap: var(--space-12); padding: var(--space-12) var(--space-16); border: 1px solid var(--border-default); border-radius: var(--radius-card); background: var(--bg-surface); }
.schedule-page__today > .material-symbols-rounded { display: grid; width: 36px; height: 36px; place-items: center; border-radius: var(--radius-8); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-l); }
.schedule-page__today > span:last-child { display: flex; flex-direction: column; gap: var(--space-4); }
.schedule-page__today small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-page__today b { color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); }
/* ---------- Schedule: agenda-led production command view ---------- */
.schedule-page--planner { gap: var(--space-16); }
.schedule-kpis { margin-bottom: 0; }
.schedule-command { overflow: hidden; border: 1px solid var(--border-default); border-radius: var(--radius-card); background: var(--bg-surface); }
.schedule-command__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-16); padding: var(--space-24); border-bottom: 1px solid var(--border-light); }
.schedule-command__title { min-width: 0; }
.schedule-command__eyebrow,.schedule-agenda__eyebrow { display: block; margin-bottom: var(--space-8); color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .08em; }
.schedule-command__title h2 { margin: 0; color: var(--text-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.schedule-command__title p { margin: var(--space-4) 0 0; color: var(--text-secondary); font-size: var(--text-s); }
.schedule-command__nav { display: flex; align-items: center; gap: var(--space-8); }
.schedule-command__nav .icon-btn { width: 36px; height: 36px; }
.schedule-command__filters { display: grid; grid-template-columns: minmax(240px, 1.6fr) minmax(180px, 1fr) minmax(180px, 1fr); gap: var(--space-12); padding: var(--space-16) var(--space-24); background: var(--bg-page-tint); border-bottom: 1px solid var(--border-light); }
.schedule-date-rail { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-8); padding: var(--space-16) var(--space-24); border-bottom: 1px solid var(--border-light); }
.schedule-date { display: flex; min-width: 0; min-height: 76px; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); padding: var(--space-8); border: 1px solid transparent; border-radius: var(--radius-12); background: var(--bg-page-tint); color: var(--text-secondary); cursor: pointer; transition: background-color .15s ease,border-color .15s ease,color .15s ease; }
.schedule-date:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.schedule-date > span { font-size: var(--text-xs); font-weight: var(--weight-medium); text-transform: uppercase; }
.schedule-date > b { display: grid; width: 32px; height: 32px; place-items: center; border-radius: var(--radius-8); color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.schedule-date > small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-date.is-today > span { color: var(--brand-primary); }
.schedule-date.is-selected { border-color: var(--brand-primary); background: var(--brand-primary-light); color: var(--brand-primary); }
.schedule-date.is-selected > b { background: var(--brand-primary); color: var(--text-inverse); }
.schedule-date.is-selected > small { color: var(--brand-primary); }
.schedule-command__body { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .85fr); align-items: start; gap: var(--space-16); padding: var(--space-20) var(--space-24) var(--space-24); background: var(--bg-page-tint); }
.schedule-agenda { min-width: 0; }
.schedule-agenda__header,.schedule-sidecard__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); }
.schedule-agenda__header { margin-bottom: var(--space-12); }
.schedule-agenda__header h3,.schedule-sidecard__header h3 { margin: 0; color: var(--text-primary); font-size: var(--text-l); font-weight: var(--weight-semibold); }
.schedule-agenda__header p { margin: var(--space-4) 0 0; color: var(--text-secondary); font-size: var(--text-s); }
.schedule-agenda__header .schedule-agenda__eyebrow,.schedule-sidecard__header .schedule-agenda__eyebrow { margin-bottom: var(--space-4); }
.schedule-agenda__count { flex: 0 0 auto; padding: var(--space-4) var(--space-8); border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--bg-surface); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.schedule-agenda__list { display: flex; flex-direction: column; gap: var(--space-8); }
.schedule-task { display: grid; grid-template-columns: 76px minmax(180px, 1fr) minmax(140px, .7fr) minmax(130px, .6fr); align-items: center; gap: var(--space-16); width: 100%; padding: var(--space-16); border: 1px solid var(--border-default); border-left: 3px solid var(--brand-primary); border-radius: var(--radius-12); background: var(--bg-surface); color: var(--text-primary); text-align: left; cursor: pointer; transition: border-color .15s ease,background-color .15s ease; }
.schedule-task:hover,.schedule-task:focus-visible { border-color: var(--brand-primary); outline: 2px solid var(--border-focus); outline-offset: 2px; background: var(--brand-primary-light); }
.schedule-task.is-overdue { border-left-color: var(--danger); }
.schedule-task.is-canceled { border-left-color: var(--text-muted); }
.schedule-task__date { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding-right: var(--space-12); border-right: 1px solid var(--border-light); color: var(--text-secondary); text-align: center; }
.schedule-task__date .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.schedule-task.is-overdue .schedule-task__date,.schedule-task.is-overdue .schedule-task__date .material-symbols-rounded { color: var(--danger); }
.schedule-task__date small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-task__date b { font-size: var(--text-s); font-weight: var(--weight-semibold); white-space: nowrap; }
.schedule-task__main { display: flex; min-width: 0; flex-direction: column; gap: var(--space-12); }
.schedule-task__identity { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); }
.schedule-task__identity small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-task__identity b { overflow: hidden; color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); text-overflow: ellipsis; white-space: nowrap; }
.schedule-task__identity > span { overflow: hidden; color: var(--text-secondary); font-size: var(--text-s); text-overflow: ellipsis; white-space: nowrap; }
.schedule-task__owner { display: flex; min-width: 0; align-items: center; gap: var(--space-8); padding-top: var(--space-8); border-top: 1px solid var(--border-light); }
.schedule-task__avatar { display: grid; flex: 0 0 28px; width: 28px; height: 28px; place-items: center; border-radius: var(--radius-pill); background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--icon-size-s); }
.schedule-task__owner > span:last-child { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); }
.schedule-task__owner small,.schedule-task__next small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-task__owner b { overflow: hidden; color: var(--text-primary); font-size: var(--text-xs); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.schedule-task__progress { min-width: 0; }
.schedule-task__progress-head { display: flex; justify-content: space-between; gap: var(--space-8); color: var(--text-secondary); font-size: var(--text-xs); }
.schedule-task__progress-head b { color: var(--brand-primary); font-weight: var(--weight-semibold); }
.schedule-task__track { position: relative; display: flex; align-items: center; justify-content: space-between; height: 16px; margin: var(--space-4) var(--space-4) 0; }
.schedule-task__track::before,.schedule-task__track > i { position: absolute; top: 7px; left: 0; height: var(--space-4); border-radius: var(--radius-pill); content: ''; }
.schedule-task__track::before { right: 0; background: var(--border-default); }
.schedule-task__track > i { z-index: 1; background: var(--brand-primary); }
.schedule-task__track > span { z-index: 2; width: 8px; height: 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); background: var(--bg-surface); }
.schedule-task__track > span.is-done,.schedule-task__track > span.is-current { border-color: var(--brand-primary); background: var(--brand-primary); }
.schedule-task__track > span.is-current { width: 12px; height: 12px; outline: 3px solid var(--brand-primary-light); }
.schedule-task__progress.is-rejected .schedule-task__progress-head b { color: var(--danger); }
.schedule-task__progress.is-rejected .schedule-task__track > i { background: var(--danger); }
.schedule-task__progress.is-canceled .schedule-task__progress-head b { color: var(--text-secondary); }
.schedule-task__next { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-4) var(--space-8); padding-left: var(--space-12); border-left: 1px solid var(--border-light); }
.schedule-task__next small { grid-column: 1 / -1; }
.schedule-task__next b { color: var(--brand-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); }
.schedule-task__next .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.schedule-sideboard { display: flex; flex-direction: column; gap: var(--space-12); }
.schedule-sidecard { min-width: 0; padding: var(--space-16); border: 1px solid var(--border-default); border-radius: var(--radius-12); background: var(--bg-surface); }
.schedule-sidecard__header { margin-bottom: var(--space-12); }
.schedule-sidecard__header > .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-l); }
.schedule-workflow-summary { display: flex; flex-direction: column; gap: var(--space-4); }
.schedule-workflow-row { display: grid; grid-template-columns: minmax(90px,1fr) 24px minmax(60px,.8fr) 32px; align-items: center; gap: var(--space-8); width: 100%; padding: var(--space-8) var(--space-4); border: 0; border-radius: var(--radius-8); background: transparent; color: var(--text-secondary); text-align: left; cursor: pointer; }
.schedule-workflow-row:hover { background: var(--bg-page-tint); }
.schedule-workflow-row__name { display: flex; align-items: center; gap: var(--space-8); font-size: var(--text-s); }
.schedule-workflow-row__name i { flex: 0 0 8px; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--brand-primary); }
.schedule-workflow-row__name i.is-rejected { background: var(--danger); }
.schedule-workflow-row__name i.is-canceled { background: var(--text-muted); }
.schedule-workflow-row > b { color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); text-align: right; }
.schedule-workflow-row__bar { overflow: hidden; height: var(--space-4); border-radius: var(--radius-pill); background: var(--bg-inset); }
.schedule-workflow-row__bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand-primary); }
.schedule-workflow-row small { color: var(--text-muted); font-size: var(--text-xs); text-align: right; }
.schedule-upcoming { display: flex; flex-direction: column; }
.schedule-upcoming__item { display: grid; grid-template-columns: 40px minmax(0,1fr) 20px; align-items: center; gap: var(--space-8); width: 100%; padding: var(--space-8) 0; border: 0; border-top: 1px solid var(--border-light); background: transparent; color: var(--text-primary); text-align: left; cursor: pointer; }
.schedule-upcoming__item:first-child { border-top: 0; }
.schedule-upcoming__item:hover .schedule-upcoming__details b { color: var(--brand-primary); }
.schedule-upcoming__date { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 40px; border-radius: var(--radius-8); background: var(--brand-primary-light); color: var(--brand-primary); }
.schedule-upcoming__date b { font-size: var(--text-m); font-weight: var(--weight-semibold); }
.schedule-upcoming__date small { font-size: var(--text-xs); }
.schedule-upcoming__details { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); }
.schedule-upcoming__details b,.schedule-upcoming__details small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-upcoming__details b { font-size: var(--text-s); font-weight: var(--weight-medium); }
.schedule-upcoming__details small { color: var(--text-muted); font-size: var(--text-xs); }
.schedule-upcoming__item > .material-symbols-rounded { color: var(--text-muted); font-size: var(--icon-size-m); }
.schedule-sidecard__empty { margin: 0; padding: var(--space-8) 0; color: var(--text-muted); font-size: var(--text-s); }
.schedule-agenda__empty { display: flex; min-height: 220px; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-8); padding: var(--space-24); border: 1px dashed var(--border-strong); border-radius: var(--radius-12); background: var(--bg-surface); text-align: center; }
.schedule-agenda__empty > .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-2xl); }
.schedule-agenda__empty b { color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.schedule-agenda__empty p { margin: 0; color: var(--text-muted); font-size: var(--text-s); }
.schedule-page--planner .schedule-unscheduled { display: flex; flex-direction: column; gap: var(--space-16); }
.schedule-page--planner .schedule-unscheduled > .form-card__header { margin-bottom: 0; }
.schedule-page--planner .schedule-queue { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; gap: var(--space-16); }
.schedule-queue-card { display: flex; min-width: 0; min-height: 0; flex-direction: column; gap: var(--space-8); padding: var(--space-12); border: 1px solid var(--border-default); border-radius: var(--radius-12); background: var(--bg-surface); color: var(--text-primary); text-align: left; cursor: pointer; transition: border-color .16s ease; }
.schedule-queue-card:hover,.schedule-queue-card:focus-visible { border-color: var(--brand-primary); outline: 2px solid var(--border-focus); outline-offset: 2px; }
.schedule-queue-card__top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
.schedule-queue-card__code { color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .03em; }
.schedule-queue-card__status { padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-medium); white-space: nowrap; }
.schedule-queue-card__title { display: -webkit-box; overflow: hidden; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); line-height: 1.35; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.schedule-queue-card__details { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: var(--space-8); }
.schedule-queue-card__customer,.schedule-queue-card__owner { display: flex; min-width: 0; align-items: center; gap: var(--space-4); overflow: hidden; color: var(--text-secondary); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.schedule-queue-card__customer .material-symbols-rounded { color: var(--text-muted); font-size: var(--icon-size-m); }
.schedule-queue-card__owner .material-symbols-rounded { color: var(--text-muted); font-size: var(--icon-size-s); }
.schedule-queue-card__action { display: flex; min-width: 0; align-items: center; gap: var(--space-4); padding-top: var(--space-8); border-top: 1px solid var(--border-light); color: var(--brand-primary); }
.schedule-queue-card__action .material-symbols-rounded { font-size: var(--icon-size-s); }
.schedule-queue-card__action b { font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.schedule-queue-card__source { overflow: hidden; margin-left: auto; color: var(--text-muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767.98px) {
  .schedule-page--planner .schedule-queue { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.schedule-unscheduled__pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12); padding-top: var(--space-12); border-top: 1px solid var(--border-light); color: var(--text-secondary); font-size: var(--text-s); }
.schedule-unscheduled__pagination[hidden] { display: none; }
.schedule-unscheduled__pagination > div { display: flex; gap: var(--space-8); }
.schedule-unscheduled__pagination .btn { min-height: 36px; }
@media (max-width: 767.98px) {
  .schedule-command__body { grid-template-columns: 1fr; padding: var(--space-16); }
  .schedule-task { grid-template-columns: 64px minmax(0,1fr); }
  .schedule-task__next { grid-column: 1 / -1; }
  .schedule-command__header { align-items: flex-start; flex-direction: column; padding: var(--space-16); }
  .schedule-command__nav { align-self: flex-end; }
  .schedule-command__filters { grid-template-columns: 1fr; padding: var(--space-12) var(--space-16); }
  .schedule-date-rail { gap: var(--space-4); padding: var(--space-12) var(--space-16); }
  .schedule-date { min-height: 68px; padding: var(--space-4); }
  .schedule-date > small { font-size: var(--text-xs); }
  .schedule-command__body { grid-template-columns: 1fr; padding: var(--space-16); }
  .schedule-sideboard { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
}
@media (max-width: 767.98px) {
  .schedule-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .schedule-page__header { align-items: flex-start; }
  .schedule-page__header .page-header__text { min-width: 0; }
  .schedule-page__today { align-self: flex-start; gap: var(--space-4); padding: var(--space-8); }
  .schedule-page__today > .material-symbols-rounded { width: 28px; height: 28px; font-size: var(--icon-size-m); }
  .schedule-page__today > span:last-child { gap: 0; }
  .schedule-page__today small { font-size: var(--text-xs); }
  .schedule-page__today b { font-size: var(--text-xs); }
  .schedule-command__header { padding: var(--space-12); }
  .schedule-command__nav { align-self: stretch; justify-content: space-between; width: 100%; }
  .schedule-command__nav .btn { flex: 1; }
  .schedule-date-rail { display: flex; overflow-x: auto; gap: var(--space-8); padding-inline: var(--space-12); scroll-snap-type: x mandatory; }
  .schedule-date { flex: 0 0 76px; scroll-snap-align: start; }
  .schedule-task { grid-template-columns: 56px minmax(0,1fr); gap: var(--space-12); padding: var(--space-12); }
  .schedule-task__date { grid-row: span 2; }
  .schedule-task__main { grid-column: 2; }
  .schedule-task__progress { grid-column: 2; }
  .schedule-task__next { grid-column: 2; }
  .schedule-sideboard { grid-template-columns: 1fr; }
  .schedule-page--planner .schedule-queue { grid-template-columns: 1fr; }
}
/* Collection workflow and OTP verification */
.collection-page { display: flex; flex-direction: column; gap: var(--space-16); }
.collection-queue__filters { align-items: center; }
.filter-bar__group--labeled { flex-direction: column; align-items: flex-start; gap: var(--space-4); }
.filter-bar__group--labeled > .field__label { margin: 0; }
.collection-queue__table th.collection-queue__action-heading,
.collection-queue__table td.collection-queue__action-cell { text-align: center !important; }
.collection-queue__table td.collection-queue__action-cell .icon-btn { margin-inline: auto; }
.collection-queue__hint { display: block; margin-top: var(--space-4); color: var(--warning); }
.collection-otp { display: flex; flex-direction: column; gap: var(--space-16); padding: var(--space-4) 0; }
.collection-otp__step { display: flex; align-items: center; gap: var(--space-8); color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .06em; }
.collection-otp__step .material-symbols-rounded { font-size: var(--icon-size-m); }
.collection-otp h3 { margin: 0; color: var(--text-primary); font-size: var(--text-l); font-weight: var(--weight-semibold); }
.collection-otp > p { margin: calc(-1 * var(--space-8)) 0 0; color: var(--text-secondary); font-size: var(--text-s); line-height: 1.5; overflow-wrap: anywhere; }
.collection-otp > p b { color: var(--text-primary); font-weight: var(--weight-medium); }
.collection-otp__input { height: 56px; text-align: center; font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: .35em; }
.collection-otp__hint { display: flex; align-items: center; gap: var(--space-8); color: var(--text-muted); font-size: var(--text-xs); }
.collection-otp__hint .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.collection-page .table-card { min-width: 0; }
.request-page { display: flex; flex-direction: column; gap: var(--space-16); }
.request-inbox__filters { justify-content: space-between; }
.request-inbox__filters .segmented { max-width: 100%; }
.request-inbox__filters .segmented__btn { white-space: nowrap; }
.contact-page { display: flex; flex-direction: column; gap: var(--space-16); }
.contact-page__messages { min-width: 0; }
.contact-page__messages .table-card__header > .field { flex: 0 1 300px; min-width: min(100%, 240px); }
.contact-page__messages .data-table { min-width: 1040px; }
.contact-page__messages .contact-page__email { max-width: 220px; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.contact-page__filters { justify-content: flex-start; }
@media (max-width: 767.98px) {
  .request-inbox__filters { align-items: stretch; }
  .request-inbox__filters .filter-bar__group,
  .request-inbox__filters .segmented { width: 100%; }
  .request-inbox__filters .segmented__btn { flex: 1 1 0; padding-inline: var(--space-8); }
  .contact-page__messages .table-card__header > .field { flex: 1 1 100%; min-width: 0; }
  .contact-page__filters .segmented { width: 100%; flex-wrap: wrap; }
  .contact-page__filters .segmented__btn { flex: 1 1 auto; }
}
/* Read-only project summary opened from the Schedule planner. */
.project-summary { display: flex; flex-direction: column; gap: var(--space-16); }
.project-summary__hero { display: flex; min-width: 0; align-items: center; gap: var(--space-12); padding: var(--space-16); border: 1px solid var(--border-light); border-radius: var(--radius-12); background: var(--bg-page-tint); }
.project-summary__hero-icon { display: grid; flex: 0 0 44px; width: 44px; height: 44px; place-items: center; border-radius: var(--radius-12); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-l); }
.project-summary__hero-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: var(--space-4); }
.project-summary__hero-copy small { color: var(--text-muted); font-size: var(--text-xs); }
.project-summary__hero-copy h3 { overflow: hidden; margin: 0; color: var(--text-primary); font-size: var(--text-l); font-weight: var(--weight-semibold); text-overflow: ellipsis; }
.project-summary__hero-copy > span { color: var(--text-secondary); font-size: var(--text-s); }
.project-summary__badge { padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; }
.project-summary__facts { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--space-8); }
.project-summary__facts > div { display: flex; min-width: 0; flex-direction: column; gap: var(--space-4); padding: var(--space-12); border: 1px solid var(--border-light); border-radius: var(--radius-8); background: var(--bg-surface); }
.project-summary__facts small { color: var(--text-muted); font-size: var(--text-xs); }
.project-summary__facts b { overflow: hidden; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.project-summary__section { display: flex; flex-direction: column; gap: var(--space-8); }
.project-summary__section h4 { display: flex; align-items: center; gap: var(--space-8); margin: 0; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); }
.project-summary__section h4 .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.project-summary__items { display: flex; flex-direction: column; border-top: 1px solid var(--border-light); }
.project-summary__item { display: flex; min-width: 0; align-items: center; gap: var(--space-8); padding: var(--space-8) var(--space-4); border-bottom: 1px solid var(--border-light); }
.project-summary__item > .material-symbols-rounded { color: var(--text-muted); font-size: var(--icon-size-m); }
.project-summary__item > span:nth-child(2) { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: var(--space-4); }
.project-summary__item b { overflow: hidden; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-medium); text-overflow: ellipsis; white-space: nowrap; }
.project-summary__item small,.project-summary__item strong { color: var(--text-muted); font-size: var(--text-xs); }
.project-summary__item strong { color: var(--text-primary); font-weight: var(--weight-semibold); }
.project-summary__empty,.project-summary__description,.project-summary__workflow p { margin: 0; color: var(--text-secondary); font-size: var(--text-s); line-height: 1.5; }
.project-summary__description { padding: var(--space-12); border-radius: var(--radius-8); background: var(--bg-page-tint); white-space: pre-wrap; }
.project-summary__workflow > div { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); }
.project-summary__workflow > div > span { color: var(--brand-primary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.project-summary__workflow progress { width: 100%; height: 8px; accent-color: var(--brand-primary); }
.project-summary__workflow p { color: var(--text-muted); font-size: var(--text-xs); }
@media (max-width: 767.98px) {
  .project-summary__facts { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .project-summary__hero { align-items: flex-start; flex-wrap: wrap; }
  .project-summary__badge { margin-left: calc(var(--space-32) + var(--space-24)); }
}
/* Library page: small square photo previews in the Photo List. */
.library-thumb { display: block; width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-8); border: 1px solid var(--border-default); background: var(--bg-subtle); }
.media-field__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-8); }
.media-field__item { position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-8); overflow: hidden; border: 1px solid var(--border-default); background: var(--bg-subtle); }
.media-field__item img { width: 100%; height: 100%; object-fit: cover; }
.media-field__actions { position: absolute; right: var(--space-4); bottom: var(--space-4); display: flex; gap: var(--space-4); }
.media-field__actions .icon-btn { background: var(--bg-surface); }
.media-field__badge { position: absolute; left: var(--space-4); top: var(--space-4); padding: 0 var(--space-8); border-radius: var(--radius-pill); background: var(--brand-primary); color: var(--text-inverse); font-size: var(--text-xs); }

.offline-sync-status { position: fixed; right: var(--space-16); bottom: var(--space-16); z-index: 1200; padding: var(--space-8) var(--space-12); border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--bg-surface); color: var(--text-secondary); box-shadow: var(--shadow-none); font-size: var(--text-xs); }
.offline-sync-status--syncing { color: var(--brand-primary); }
.offline-sync-status--pending { color: var(--warning); }
.offline-sync-status--synced { color: var(--success); }

@media (max-width: 767.98px) {
  .app-shell:not(.site-shell) .offline-sync-status {
    right: var(--space-12);
    bottom: calc(72px + env(safe-area-inset-bottom, 0px) + var(--space-8));
    max-width: calc(100vw - var(--space-24));
  }
}

/* ---------- Page loading bar (public/js/page-progress.js) ----------
   Thin brand line pinned to the top of the viewport while the next page
   loads: eases towards 90% (it never knows the real progress), then fills
   and fades once the new page arrives. Above the header, modals and toasts. */
.page-progress { position: fixed; top: 0; left: 0; right: 0; z-index: 1300; height: 2px; pointer-events: none; opacity: 0; transition: opacity var(--duration-base) var(--ease-standard); }
.page-progress__bar { display: block; height: 100%; background: var(--brand-primary); transform: scaleX(0); transform-origin: left center; }
.page-progress.is-active { opacity: 1; }
.page-progress.is-active .page-progress__bar { transform: scaleX(0.9); transition: transform 10s cubic-bezier(0.08, 0.7, 0.2, 1); }
.page-progress.is-done .page-progress__bar { transform: scaleX(1); transition: transform var(--duration-base) var(--ease-standard); }
.page-progress.is-done { opacity: 0; transition-delay: var(--duration-base); }
@media (prefers-reduced-motion: reduce) {
  .page-progress.is-active .page-progress__bar { transform: scaleX(1); transition: none; }
}

/* Modal text variants (built by page scripts through window.viewModal):
   message bodies keep their line breaks, log entries wrap long lines, and
   numbered instructions get list markers - no inline styles. */
.modal__text--pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.modal__pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--font-primary); font-size: var(--text-s); line-height: var(--leading-relaxed); color: var(--text-primary); }
.modal__list { display: flex; flex-direction: column; gap: var(--space-4); padding-left: var(--space-20); list-style: decimal; line-height: var(--leading-relaxed); }

/* ---------- Native controls, one look on every browser/OS ----------
   <select>: the system arrow is replaced by the same chevron used across the
   app (the SVG can't read tokens; its stroke is --text-muted #94A3B8).
   Number boxes: no browser spin buttons - quantities have their own steppers.
   File inputs: the picker button is drawn as a secondary .btn. */
select.field__control,
.table-card__page-size-select select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: calc(var(--space-12) + var(--icon-size-s) + var(--space-4));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-12) center;
  background-size: var(--icon-size-s) var(--icon-size-s);
  cursor: pointer;
}

.table-card__page-size-select select {
  padding-right: calc(var(--space-8) + var(--icon-size-s));
  background-position: right var(--space-4) center;
}

input[type="number"].field__control,
input[type="number"].data-table__input {
  -moz-appearance: auto;
  appearance: auto;
}

input[type="number"].field__control::-webkit-outer-spin-button,
input[type="number"].field__control::-webkit-inner-spin-button,
input[type="number"].data-table__input::-webkit-outer-spin-button,
input[type="number"].data-table__input::-webkit-inner-spin-button {
  -webkit-appearance: auto;
  opacity: 1;
  margin: 0;
}

input[type="file"].field__control {
  height: auto;
  min-height: var(--control-height-m);
  padding: var(--space-4);
  color: var(--text-secondary);
  cursor: pointer;
}

input[type="file"].field__control::file-selector-button {
  height: var(--control-height-s);
  margin-right: var(--space-12);
  padding: 0 var(--space-12);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: var(--text-s);
  cursor: pointer;
}

input[type="file"].field__control::file-selector-button:hover {
  background: var(--bg-page);
  border-color: var(--border-strong);
}

/* Project standard: Mobile View at 767px and below; Desktop View at 768px and above. */

/* Period buttons + From/To stay on one line only while there is room. */
@media (max-width: 767.98px) {
  .filter-bar:has(.filter-bar__group--dates) {
    flex-wrap: wrap;
  }
}

/* Long page lists wrap instead of pushing the footer wider than the card. */
.pagination {
  flex-wrap: wrap;
}

/* Settings / Master: the section list becomes a scrolling row above the
   content instead of a 140px column beside it. */
@media (max-width: 767.98px) {
  .settings-shell {
    grid-template-columns: 1fr;
    gap: var(--space-12);
  }

  .settings-shell__nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--space-4);
  }

  .settings-shell__nav-item {
    flex-shrink: 0;
    white-space: nowrap;
    padding: var(--space-8) var(--space-12);
    font-size: var(--text-s);
  }

  .settings-shell__nav-item.is-active::before {
    display: none;
  }
}

@media (max-width: 767.98px) {
  /* Filter bars stack: segmented periods full width, then From | To. */
  .filter-bar:has(.filter-bar__group--dates) {
    flex-direction: column;
    align-items: stretch;
  }

  .app-workspace .workspace:not(.dashboard-page) .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }

  .app-workspace .workspace:not(.dashboard-page) .kpi-row .kpi-card__label { font-size: var(--text-xs); }

  .filter-bar__group {
    width: 100%;
  }

  .filter-bar__group > .field,
  .filter-bar__group--dates > * {
    flex: 1 1 0;
    min-width: 0;
  }

  .filter-bar__group--dates .date-picker__input {
    width: 100%;
  }

  .filter-bar .segmented,
  .filter-bar:has(.filter-bar__group--dates) .segmented {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-bar .segmented__btn {
    flex: 1 1 auto;
  }

  /* Page actions become full-width, evenly split buttons. */
  .page-header__actions {
    width: 100%;
  }

  .page-header__actions > .btn {
    flex: 1 1 auto;
  }

  /* Keep dialog padding consistent across screen sizes. */
  .modal-overlay {
    padding: var(--space-8);
  }

  .modal {
    max-height: calc(100dvh - var(--space-8) * 2);
  }

  .modal__header,
  .modal__body,
  .modal__footer {
    padding: var(--dialog-padding);
  }

  .modal__footer {
    flex-wrap: wrap;
  }

  .modal__footer > .btn {
    flex: 1 1 auto;
  }

  /* 16px text in form fields stops iPhone Safari zooming the page on focus. */
  .field__control,
  .data-table__input {
    font-size: var(--text-l);
  }

  .table-card__footer {
    justify-content: center;
  }
}

/* Touch screens: compact row buttons and page numbers get a 36px target. */
@media (pointer: coarse) {
  .icon-btn--sm {
    width: var(--control-height-m);
    height: var(--control-height-m);
  }

  .pagination__btn,
  .pagination__ellipsis {
    min-width: var(--control-height-m);
    height: var(--control-height-m);
  }
}

/* Premium record summaries: shared application detail-view system. */
.modal--premium { width: min(1040px, calc(100vw - 32px)); max-height: min(900px, calc(100dvh - 32px)); border: 1px solid var(--border-default); border-radius: var(--radius-dialog); }
.modal--premium .modal__header { border-bottom: 1px solid var(--border-light); background: var(--bg-surface); }
.modal--premium .modal__body { min-width: 0; overflow-x: hidden; background: var(--bg-page); }
.modal--premium .modal__footer { border-top: 1px solid var(--border-light); background: var(--bg-surface); }
.modal--premium .summary-list.record-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8); margin: 0; }
.modal--premium .record-summary-field { min-width: 0; padding: var(--space-12); border: 1px solid var(--border-light); border-radius: var(--radius-card); background: var(--bg-surface); }
.modal--premium .record-summary-field.summary-list__row--wide { grid-column: 1 / -1; }
.modal--premium .record-summary-field dt { display: flex; align-items: center; gap: var(--space-8); color: var(--text-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .035em; text-transform: uppercase; }
.modal--premium .record-summary-field .summary-list__label-icon { display: grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border-radius: var(--radius-8); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-s); }
.modal--premium .record-summary-field dd { min-width: 0; margin: var(--space-8) 0 0 calc(var(--space-32) + var(--space-4)); color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-medium); line-height: var(--leading-relaxed); overflow-wrap: anywhere; }
.modal--premium .record-summary-field dd a { color: var(--brand-primary); }
.modal--premium .record-summary-field dd b { font-weight: var(--weight-semibold); }
.modal--premium .record-summary-field.summary-list__row--wide dd { margin-left: calc(var(--space-32) + var(--space-4)); }
.project-summary, .order-summary { display: flex; min-width: 0; flex-direction: column; gap: var(--space-16); color: var(--text-primary); }
.project-summary__hero, .order-summary__hero { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: var(--space-16); padding: var(--space-20); border: 1px solid var(--border-default); border-radius: var(--radius-card); background: var(--bg-surface); }
.project-summary__hero-title, .order-summary__identity { display: flex; min-width: 0; align-items: center; gap: var(--space-16); }
.project-summary__hero-icon, .order-summary__hero-icon { display: grid; width: 52px; height: 52px; flex: 0 0 52px; place-items: center; border-radius: var(--radius-12); background: var(--brand-primary-light); color: var(--brand-primary); font-size: var(--icon-size-xl); }
.project-summary__eyebrow, .order-summary__eyebrow { display: block; color: var(--text-tertiary); font-size: var(--text-xs); font-weight: var(--weight-semibold); letter-spacing: .08em; text-transform: uppercase; }
.project-summary__hero h2, .order-summary__identity h2 { margin: var(--space-4) 0; color: var(--text-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: var(--leading-tight); overflow-wrap: anywhere; }
.project-summary__hero p, .order-summary__identity p { margin: 0; color: var(--text-secondary); font-size: var(--text-m); overflow-wrap: anywhere; }
.project-summary__badge, .order-summary__status { display: inline-flex; align-items: center; justify-content: center; width: fit-content; padding: var(--space-8) var(--space-12); border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--bg-subtle); color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-semibold); white-space: nowrap; }
.project-summary__layout, .order-summary__layout { display: grid; min-width: 0; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .85fr); align-items: start; gap: var(--space-16); }
.project-summary__main, .project-summary__rail, .order-summary__main, .order-summary__rail { display: flex; min-width: 0; flex-direction: column; gap: var(--space-12); }
.project-summary__panel, .order-summary__panel { min-width: 0; padding: var(--space-16); border: 1px solid var(--border-light); border-radius: var(--radius-card); background: var(--bg-surface); }
.project-summary__panel > header, .order-summary__panel-heading { display: flex; min-width: 0; align-items: center; gap: var(--space-12); margin: 0 0 var(--space-12); }
.project-summary__panel > header > .material-symbols-rounded, .order-summary__panel-heading > .material-symbols-rounded { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--brand-primary); font-size: var(--icon-size-m); }
.project-summary__panel > header h3, .order-summary__panel-heading h3 { margin: 0; color: var(--text-primary); font-size: var(--text-m); font-weight: var(--weight-semibold); }
.project-summary__panel > header p, .order-summary__panel-heading p { margin: var(--space-4) 0 0; color: var(--text-tertiary); font-size: var(--text-s); }
.project-summary__count { display: grid; min-width: 28px; height: 28px; margin-left: auto; place-items: center; border-radius: var(--radius-pill); background: var(--bg-inset); color: var(--text-secondary); font-size: var(--text-s); font-weight: var(--weight-semibold); }
.project-summary__table-wrap { width: 100%; overflow-x: auto; }
.project-summary__table { width: 100%; border-collapse: collapse; }
.project-summary__table th, .project-summary__table td { padding: var(--space-12) var(--space-8); border-bottom: 1px solid var(--border-light); text-align: left; font-size: var(--text-s); }
.project-summary__table th { color: var(--text-tertiary); font-weight: var(--weight-semibold); }
.project-summary__table th.is-numeric, .project-summary__table td.is-numeric { text-align: right; }
.project-summary__item-name { display: flex; align-items: center; gap: var(--space-8); }
.project-summary__item-name > .material-symbols-rounded { color: var(--brand-primary); font-size: var(--icon-size-m); }
.project-summary__item-name b, .project-summary__item-name small, .project-summary__file b, .project-summary__file small { display: block; }
.project-summary__item-name small, .project-summary__file small { margin-top: var(--space-4); color: var(--text-tertiary); font-size: var(--text-xs); }
.project-summary__empty, .order-summary__empty { margin: 0; padding: var(--space-12); border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--text-tertiary); font-size: var(--text-s); }
.project-summary__description, .order-summary__notes { margin: 0; padding: var(--space-12); border-radius: var(--radius-8); background: var(--bg-subtle); color: var(--text-secondary); font-size: var(--text-m); line-height: var(--leading-relaxed); overflow-wrap: anywhere; }
.project-summary__details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-12); margin: 0; }
.project-summary__details > div { min-width: 0; padding: var(--space-8); border-radius: var(--radius-8); background: var(--bg-subtle); }
.project-summary__details dt { color: var(--text-tertiary); font-size: var(--text-xs); }
.project-summary__details dd { margin: var(--space-4) 0 0; color: var(--text-primary); font-size: var(--text-s); font-weight: var(--weight-medium); overflow-wrap: anywhere; }
.project-summary__priority { display: inline-flex; border-radius: var(--radius-pill); padding: var(--space-4) var(--space-8); background: var(--bg-inset); }
.project-summary__progress-value { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-8); margin: var(--space-4) 0 var(--space-8); }
.project-summary__progress-value b { color: var(--brand-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.project-summary__progress-value span { color: var(--text-secondary); font-size: var(--text-s); font-weight: var(--weight-medium); }
.project-summary__progress-panel progress { display: block; width: 100%; height: 8px; accent-color: var(--brand-primary); }
.project-summary__steps { display: grid; gap: 0; margin: var(--space-12) 0 0; padding: 0; list-style: none; }
.project-summary__steps li { position: relative; display: flex; min-height: 32px; align-items: center; gap: var(--space-8); color: var(--text-tertiary); font-size: var(--text-s); }
.project-summary__steps li:not(:last-child)::before { position: absolute; top: 24px; left: 11px; width: 1px; height: 16px; background: var(--border-default); content: ""; }
.project-summary__steps li > span { z-index: 1; display: grid; width: 22px; height: 22px; flex: 0 0 22px; place-items: center; border: 1px solid var(--border-default); border-radius: var(--radius-pill); background: var(--bg-surface); font-size: var(--text-xs); }
.project-summary__steps li.is-done, .project-summary__steps li.is-current { color: var(--text-primary); }
.project-summary__steps li.is-done > span, .project-summary__steps li.is-current > span { border-color: var(--brand-primary); background: var(--brand-primary); color: var(--text-inverse); }
.project-summary__steps li.is-current { font-weight: var(--weight-semibold); }
.project-summary__steps--collection li.is-done > span, .project-summary__steps--collection li.is-current > span { border-color: var(--success); background: var(--success); }
.project-summary__files { display: grid; gap: var(--space-8); }
.project-summary__file, .order-summary__slip { display: flex; min-width: 0; align-items: center; gap: var(--space-8); padding: var(--space-12); border: 1px solid var(--border-light); border-radius: var(--radius-8); color: var(--text-primary); text-decoration: none; }
.project-summary__file > .material-symbols-rounded, .order-summary__slip > .material-symbols-rounded { flex: 0 0 auto; color: var(--brand-primary); }
.project-summary__file > span:nth-child(2), .order-summary__slip > span:nth-child(2) { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.project-summary__file .status { margin-left: auto; }
.project-summary__file-open { font-size: var(--icon-size-s); }
.order-summary__total { display: grid; justify-items: end; gap: var(--space-4); }
.order-summary__total > span:first-child { color: var(--text-tertiary); font-size: var(--text-xs); }
.order-summary__total > b { color: var(--text-primary); font-size: var(--text-xl); font-weight: var(--weight-semibold); }
.order-summary__status { padding: var(--space-4) var(--space-8); }
.order-summary .summary-list.record-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.order-summary__panel .table-scroll { max-width: 100%; overflow-x: auto; }
.order-summary__panel .data-table { min-width: 580px; }
.order-summary__panel > .table-scroll { margin: 0; }
.order-summary__slip { margin-top: var(--space-12); }
.order-summary__slip small { display: block; margin-top: var(--space-4); color: var(--text-tertiary); font-size: var(--text-xs); }
.order-summary__review .form-grid { grid-template-columns: 1fr; }
.record-timeline { display: grid; gap: var(--space-12); margin: 0; padding: 0; list-style: none; }
.record-timeline li { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--space-8); }
.record-timeline__marker { z-index: 1; color: var(--brand-primary); font-size: var(--icon-size-m); }
.record-timeline li:not(:last-child)::after { position: absolute; top: 20px; bottom: -12px; left: 10px; width: 1px; background: var(--border-default); content: ""; }
.record-timeline time { display: block; margin-bottom: var(--space-4); color: var(--text-tertiary); font-size: var(--text-xs); }
.record-timeline b { color: var(--text-primary); font-size: var(--text-s); }
.record-timeline p { margin: var(--space-4) 0 0; color: var(--text-secondary); font-size: var(--text-s); overflow-wrap: anywhere; }
@media (max-width: 767.98px) {
  .project-summary__layout, .order-summary__layout { grid-template-columns: minmax(0, 1fr); }
  .project-summary__rail, .order-summary__rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (max-width: 767.98px) {
  .modal--premium { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .project-summary, .order-summary { gap: var(--space-12); }
  .project-summary__hero, .order-summary__hero { align-items: flex-start; padding: var(--space-12); }
  .project-summary__hero-title, .order-summary__identity { align-items: flex-start; gap: var(--space-8); }
  .project-summary__hero-icon, .order-summary__hero-icon { width: 36px; height: 36px; flex-basis: 36px; font-size: var(--icon-size-m); }
  .project-summary__hero h2, .order-summary__identity h2 { font-size: var(--text-l); }
  .project-summary__hero p, .order-summary__identity p { font-size: var(--text-s); }
  .project-summary__badge { padding: var(--space-4) var(--space-8); }
  .order-summary__total { flex: 0 0 auto; }
  .order-summary__total > b { font-size: var(--text-l); }
  .project-summary__panel, .order-summary__panel { padding: var(--space-12); }
  .project-summary__rail, .order-summary__rail { display: flex; }
  .project-summary__details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal--premium .summary-list.record-summary-grid, .order-summary .summary-list.record-summary-grid { grid-template-columns: 1fr; }
}

/* Shared mobile application surfaces and touch targets. Page-specific
   components can still override these rules where their workflow needs it. */
@media (max-width: 767.98px) {
  .app-workspace { background: var(--bg-page); }

  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-12);
    padding: var(--space-12);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-12);
    background: var(--bg-surface);
    box-shadow: var(--shadow-none);
  }

  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) > .filter-bar__group,
  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) .filter-bar__group--dates { width: 100%; min-width: 0; }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) .filter-bar__group--dates {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .field {
    min-width: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) .segmented {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--radius-12);
    background: var(--bg-inset);
  }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) .segmented__btn {
    min-width: 0;
    min-height: 48px;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--radius-8);
    font-size: var(--text-xs);
    line-height: 1.1;
  }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar:has(.filter-bar__group--dates) .segmented__btn .material-symbols-rounded { font-size: var(--icon-size-s); }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .field__label { font-size: var(--text-s); font-weight: var(--weight-medium); }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker,
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker__control,
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker__input { width: 100%; min-width: 0; }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker__input {
    min-height: 48px;
    padding-left: calc(var(--space-12) + var(--icon-size-s) + var(--space-8));
    padding-right: var(--space-28);
    border-radius: var(--radius-8);
    font-size: var(--text-s);
  }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker__control > .field__lead-icon { display: inline-flex; }
  .app-workspace .workspace:not(.dashboard-page) .filter-bar__group--dates .date-picker__icon { display: none; }

  .app-workspace .workspace:not(.dashboard-page) .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-12);
  }

  .app-workspace .workspace {
    gap: var(--space-16);
    padding: var(--space-16);
  }

  .app-workspace .workspace .page-header__title { font-size: var(--text-xl); letter-spacing: -.03em; }
  .app-workspace .workspace .page-header__desc { font-size: var(--text-s); }
  .app-workspace .workspace-section { gap: var(--space-12); }

  .app-workspace .workspace .filter-bar,
  .app-workspace .workspace .table-card,
  .app-workspace .workspace .chart-card,
  .app-workspace .workspace .form-card,
  .app-workspace .workspace .detail-card,
  .app-workspace .workspace .summary-card {
    border-radius: var(--radius-12);
  }

  .app-workspace .workspace .field__control,
  .app-workspace .workspace select.field__control,
  .app-workspace .workspace .btn:not(.btn--icon),
  .app-workspace .workspace button.btn:not(.btn--icon) {
    min-height: 48px;
  }

  .app-workspace .workspace:has(#accountTable) #accountFormCard .segmented__btn,
  .app-workspace .workspace:has(#cashbookTable) #cashbookFormCard .segmented__btn,
  .app-workspace .workspace:has(#transferTable) #transferFormCard .segmented__btn {
    min-height: 48px;
  }

  .app-workspace .workspace:has(#cashbookTable) #cashbookReason {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .app-workspace .workspace:has(#cashbookTable) #cashbookReason .segmented__btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (max-width: 767.98px) {
  /* Phone screens use a native-app rhythm: compact screen title, full-width
     actions, edge-to-edge workspace, and sheets that rise from the bottom. */
  .app-workspace .workspace {
    padding: var(--space-16) var(--space-16) calc(var(--space-24) + env(safe-area-inset-bottom, 0px));
    gap: var(--space-16);
  }

  .app-workspace .workspace > .page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
    padding: var(--space-4);
  }

  .app-workspace .workspace > .page-header .page-header__title { font-size: var(--text-xl); }
  .app-workspace .workspace > .page-header .page-header__desc { margin-top: var(--identity-text-gap); }
  .app-workspace .workspace > .page-header .page-header__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-8); }
  .app-workspace .workspace > .page-header .page-header__actions > .btn { width: 100%; min-width: 0; padding-inline: var(--space-8); }
  .app-workspace .workspace > .page-header .page-header__actions > .btn:only-child { grid-column: 1 / -1; }

  .app-workspace .workspace .form-card,
  .app-workspace .workspace .table-card,
  .app-workspace .workspace .filter-bar,
  .app-workspace .workspace .chart-card,
  .app-workspace .workspace .detail-card,
  .app-workspace .workspace .summary-card {
    border-radius: var(--radius-12);
  }

  .app-workspace .workspace .form-card { padding: var(--card-padding); }
  .app-workspace .workspace .table-card__header { padding: var(--card-padding); }
  .app-workspace .workspace .table-card__footer { padding: var(--space-12) var(--space-16); }
  .app-workspace .workspace .form-card[data-settings-form] { gap: var(--space-12); }
  .app-workspace .workspace .form-card[data-settings-form] > .form-card__header:not(:first-child) {
    margin-top: var(--space-4);
    padding-top: var(--space-12);
    border-top: 1px solid var(--border-light);
  }
  .app-workspace .workspace .form-card[data-settings-form] .segmented--equal .segmented__btn { min-height: 44px; }
  .settings-shell__nav-item { min-height: 44px; border-radius: var(--radius-12); }
  .settings-shell__nav-item.is-active { background: var(--brand-primary-light); }
  .app-workspace .workspace .form-card__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-workspace .workspace .form-card__actions > .btn { width: 100%; min-width: 0; }
  .app-workspace .workspace .form-card__actions > .btn:only-child,
  .app-workspace .workspace .form-card__actions > .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .app-workspace .workspace .field__control,
  .app-workspace .workspace .data-table__input { min-height: 48px; }

  /* Native-feeling bottom sheets keep modal actions reachable above the
     phone home indicator and let long forms scroll independently. */
  .modal-overlay:not(:has(.modal--print)) {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal-overlay:not(:has(.modal--print)) .modal {
    width: 100%;
    max-width: none;
    max-height: min(92dvh, 900px);
    border-radius: var(--radius-24) var(--radius-24) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(24px);
  }

  .modal-overlay.is-open:not(:has(.modal--print)) .modal { transform: translateY(0); }
  .modal-overlay:not(:has(.modal--print)) .modal__header { position: sticky; top: 0; z-index: 1; background: var(--bg-surface); }
  .modal-overlay:not(:has(.modal--print)) .modal__footer { position: sticky; bottom: 0; z-index: 1; background: var(--bg-surface); }

  /* Narrow, multi-action bars wrap cleanly instead of preserving a desktop row. */
  .app-workspace .workspace .toolbar,
  .app-workspace .workspace .action-bar,
  .app-workspace .workspace .button-group { max-width: 100%; flex-wrap: wrap; }
  .app-workspace .workspace :is(.toolbar, .action-bar, .button-group) > .btn { min-width: 0; }

  .app-workspace .workspace .page-header__desc { max-width: 60ch; }
  .app-workspace .workspace .form-grid { gap: var(--space-12); }
  .app-workspace .workspace .filter-bar { padding: var(--space-12); }

  .app-workspace .workspace > .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }

  .app-workspace .workspace > .kpi-row .kpi-card {
    min-height: 108px;
    align-items: center;
    flex-direction: row;
    gap: var(--space-8);
    padding: var(--card-padding);
    border-radius: var(--radius-12);
  }

  .app-workspace .workspace > .kpi-row .kpi-card__icon {
    width: var(--icon-size-2xl);
    height: var(--icon-size-2xl);
    border-radius: var(--radius-8);
  }

  .app-workspace .workspace > .kpi-row .kpi-card__icon .material-symbols-rounded { font-size: var(--icon-size-m); }
  .app-workspace .workspace > .kpi-row .kpi-card__label { font-size: var(--text-xs); }
  .app-workspace .workspace > .kpi-row .kpi-card__value { font-size: var(--text-xl); }

  /* Keep the desktop-style icon beside the label and value on mobile. Labels
     can wrap to two lines while numeric values retain enough width to scan. */
  .app-workspace .workspace .kpi-row .kpi-card {
    min-height: 0;
    align-items: center;
    flex-direction: row;
    gap: var(--space-8);
    padding: var(--card-padding);
    border-radius: var(--radius-12);
  }

  .app-workspace .workspace .kpi-row .kpi-card__icon {
    width: var(--icon-size-l);
    height: var(--icon-size-l);
    border-radius: var(--radius-8);
  }

  .app-workspace .workspace .kpi-row .kpi-card__body {
    flex: 1 1 auto;
    width: auto;
  }
  .app-workspace .workspace .kpi-row .kpi-card__label {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .app-workspace .workspace .kpi-row .kpi-card__value {
    font-size: var(--text-xl);
    overflow: visible;
    text-overflow: clip;
  }

  .app-workspace .workspace:has(#peopleFormCard) #peopleFormCard .form-card__header {
    align-items: flex-start;
  }

  .app-workspace .workspace:has(#peopleFormCard) .table-card__header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-workspace .workspace:has(#peopleFormCard) .table-card__header > .field { width: 100%; }

  .app-workspace .workspace:has(#peopleTable) .filter-bar__group { width: 100%; min-width: 0; }
  .app-workspace .workspace:has(#peopleTable) .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-workspace .workspace:has(#peopleTable) .segmented__btn { flex: 0 0 auto; min-height: 48px; white-space: nowrap; }

  .app-workspace .workspace:has(#peopleTable) .table-scroll { overflow: visible; border: 0; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable thead { display: none; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody { display: grid; gap: var(--space-8); }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody tr:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-12);
    overflow: hidden;
    padding: var(--space-4) var(--space-12);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-16);
    background: var(--bg-surface);
    box-shadow: 0 3px 12px rgb(25 44 79 / 4%);
  }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td {
    display: flex;
    min-width: 0;
    min-height: 50px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8) 0;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
  }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td::before {
    color: var(--text-muted);
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td:first-child,
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td:last-child { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td:first-child { min-height: 58px; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable tbody td:last-child { border-bottom: 0; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable .data-table__primary { white-space: normal; }
  .app-workspace .workspace:has(#peopleTable) #peopleTable .row-actions { justify-content: flex-start; }

  .app-workspace .workspace:has(#reportFilesTable) .form-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-workspace .workspace:has(#reportFilesTable) .form-grid--4 .field--span-2 { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#reportFilesTable) .form-grid--4 [data-target="report-period"] { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-workspace .workspace:has(#reportFilesTable) .form-grid--4 [data-target="report-period"] .segmented__btn { flex: 0 0 auto; min-height: 48px; white-space: nowrap; }
  .app-workspace .workspace:has(#reportFilesTable) .form-card__actions > .btn { flex: 1 1 100%; }
  .app-workspace .workspace:has(#reportFilesTable) .form-grid--4 > .field--span-2 { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#reportFilesTable) .table-card__header {
    align-items: stretch;
    flex-direction: column;
  }
  .app-workspace .workspace:has(#reportFilesTable) .table-card__header > .field { width: 100%; }
  .app-workspace .workspace:has(#reportFilesTable) .table-scroll { overflow: visible; border: 0; }
  .app-workspace .workspace #reportFilesTable { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
  .app-workspace .workspace #reportFilesTable thead { display: none; }
  .app-workspace .workspace #reportFilesTable tbody { display: grid; gap: var(--space-8); }
  .app-workspace .workspace #reportFilesTable tbody tr:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-12);
    overflow: hidden;
    padding: var(--space-4) var(--space-12);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-16);
    background: var(--bg-surface);
    box-shadow: 0 3px 12px rgb(25 44 79 / 4%);
  }
  .app-workspace .workspace #reportFilesTable tbody td {
    display: flex;
    min-width: 0;
    min-height: 46px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8) 0;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
  }
  .app-workspace .workspace #reportFilesTable tbody td::before {
    color: var(--text-muted);
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(1),
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(3),
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(4),
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(5),
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(9) { grid-column: 1 / -1; }
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(1) { min-height: 54px; }
  .app-workspace .workspace #reportFilesTable tbody td:nth-child(9) { border-bottom: 0; }
  .app-workspace .workspace #reportFilesTable .row-actions { justify-content: flex-start; }

  .app-workspace .workspace:has(#attendanceTable) #attendanceFormCard .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-workspace .workspace:has(#attendanceTable) #attendanceFormCard .form-grid > .field:nth-child(2) {
    grid-column: 1 / -1;
  }
  .app-workspace .workspace:has(#attendanceTable) #attendanceFormCard .form-card__actions > .btn { flex: 1 1 100%; }

  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .table-card__header {
    align-items: stretch;
    flex-direction: column;
  }
  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .table-card__header > .field { width: 100%; }
  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .filter-bar__group { width: 100%; min-width: 0; }
  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .filter-bar .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .filter-bar .segmented__btn { flex: 0 0 auto; min-height: 48px; white-space: nowrap; }
  .app-workspace .workspace:has(:is(#attendanceTable, #workflowTable)) .table-scroll { overflow: visible; border: 0; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) thead { display: none; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody { display: grid; gap: var(--space-8); }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody tr:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-12);
    overflow: hidden;
    padding: var(--space-4) var(--space-12);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-16);
    background: var(--bg-surface);
    box-shadow: 0 3px 12px rgb(25 44 79 / 4%);
  }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td {
    display: flex;
    min-width: 0;
    min-height: 48px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8) 0;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
  }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td::before {
    color: var(--text-muted);
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td:first-child,
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td:last-child { grid-column: 1 / -1; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td:first-child { min-height: 56px; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) tbody td:last-child { border-bottom: 0; }
  .app-workspace .workspace #attendanceTable tbody td:nth-child(3),
  .app-workspace .workspace #workflowTable tbody td:nth-child(4) { grid-column: 1 / -1; }
  .app-workspace .workspace :is(#attendanceTable, #workflowTable) .row-actions { justify-content: flex-start; }

  .app-workspace .workspace:has(#employeeTable) #employeeFormCard .form-grid--4,
  .app-workspace .workspace:has(#appointmentTable) #appointmentFormCard .form-grid--4,
  .app-workspace .workspace:has(#accountTable) #accountFormCard .form-grid--4,
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard .form-grid--4,
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard .form-grid--4,
  .app-workspace .workspace:has(#agreementTable) #agreementFormCard .form-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-workspace .workspace:has(#employeeTable) #employeeFormCard .form-grid--4 > .field:first-child,
  .app-workspace .workspace:has(#employeeTable) #employeeFormCard .form-grid--4 > .field--span-2,
  .app-workspace .workspace:has(#employeeTable) #employeeFormCard .form-grid--4 > .field--span-3,
  .app-workspace .workspace:has(#appointmentTable) #appointmentFormCard .form-grid--4 > .field:first-child,
  .app-workspace .workspace:has(#appointmentTable) #appointmentFormCard .form-grid--4 > .field--span-2 { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#accountTable) #accountFormCard [data-target="account-type"] {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .app-workspace .workspace:has(#accountTable) #accountFormCard [data-target="account-type"] .segmented__btn {
    flex: 0 0 auto;
  }
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard .form-grid--4 > .field:first-child,
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard .form-grid--3 > .field--span-2,
  .app-workspace .workspace:has(#agreementTable) #agreementFormCard .form-grid--4 > .field:first-child,
  .app-workspace .workspace:has(#agreementTable) #agreementFormCard .form-grid--4 > .field--span-2,
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard .form-grid--4 > .field:first-child,
  .app-workspace .workspace:has(#userTable) #userFormCard .form-grid > .field--span-3 { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard [data-target="leave-type"],
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard [data-target="leave-status"],
  .app-workspace .workspace:has(#agreementTable) #agreementFormCard [data-target="agreement-status"],
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard [data-target="payroll-payment-status"] {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard [data-target="leave-type"] .segmented__btn,
  .app-workspace .workspace:has(#leaveTable) #leaveFormCard [data-target="leave-status"] .segmented__btn,
  .app-workspace .workspace:has(#agreementTable) #agreementFormCard [data-target="agreement-status"] .segmented__btn,
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard [data-target="payroll-payment-status"] .segmented__btn { flex: 0 0 auto; min-height: 40px; }
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard .form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-workspace .workspace:has(#payrollTable) #payrollFormCard #payrollPaidFields[hidden] { display: none; }

  .app-workspace .workspace:has(#projectTable) #createProjectSection .project-source-row,
  .app-workspace .workspace:has(#projectTable) #createProjectSection .project-dates-row,
  .app-workspace .workspace:has(#projectTable) #createProjectSection .project-title-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .app-workspace .workspace:has(#projectTable) #createProjectSection .project-source-row > .field:first-child { grid-column: 1 / -1; }
  .app-workspace .workspace:has(#projectTable) #createProjectSection .button-group { gap: var(--space-8); }
  .app-workspace .workspace:has(#projectTable) #createProjectSection .button-group > .btn { min-height: 40px; padding-inline: var(--space-8); }
  .app-workspace .workspace:has(#projectTable) #createProjectSection .project-create-submit { width: 100%; }

  .app-workspace .workspace:has(#employeeTable) .table-card__header,
  .app-workspace .workspace:has(#appointmentTable) .table-card__header,
  .app-workspace .workspace:has(#accountTable) .table-card__header,
  .app-workspace .workspace:has(#projectTable) .table-card__header,
  .app-workspace .workspace:has(#leaveTable) .table-card__header,
  .app-workspace .workspace:has(#payrollTable) .table-card__header,
  .app-workspace .workspace:has(#agreementTable) .table-card__header,
  .app-workspace .workspace:has(#userTable) .table-card__header,
  .app-workspace .workspace:has(#notificationTable) .table-card__header,
  .app-workspace .workspace:has(#auditTable) .table-card__header {
    align-items: stretch;
    flex-direction: column;
  }
  .app-workspace .workspace:has(#employeeTable) .table-card__header > .field,
  .app-workspace .workspace:has(#appointmentTable) .table-card__header > .field,
  .app-workspace .workspace:has(#accountTable) .table-card__header > .field,
  .app-workspace .workspace:has(#projectTable) .table-card__header > .field,
  .app-workspace .workspace:has(#leaveTable) .table-card__header > .field,
  .app-workspace .workspace:has(#payrollTable) .table-card__header > .field,
  .app-workspace .workspace:has(#agreementTable) .table-card__header > .field,
  .app-workspace .workspace:has(#userTable) .table-card__header > .field,
  .app-workspace .workspace:has(#notificationTable) .table-card__header > .field,
  .app-workspace .workspace:has(#auditTable) .table-card__header > .field { width: 100%; }
  .app-workspace .workspace:has(:is(#appointmentTable, #projectTable, #leaveTable, #agreementTable, #payrollTable, #notificationTable)) .filter-bar__group { width: 100%; min-width: 0; }
  .app-workspace .workspace:has(:is(#appointmentTable, #projectTable, #leaveTable, #agreementTable, #payrollTable, #notificationTable)) .filter-bar .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-workspace .workspace:has(:is(#appointmentTable, #projectTable, #leaveTable, #agreementTable, #payrollTable, #notificationTable)) .filter-bar .segmented__btn { flex: 0 0 auto; min-height: 48px; white-space: nowrap; }

  .app-workspace .workspace .table-card:has(table[data-mobile-cards]) .table-card__header {
    align-items: stretch;
    flex-direction: column;
  }
  .app-workspace .workspace .table-card:has(table[data-mobile-cards]) .table-card__header > .field { width: 100%; }
  .app-workspace .workspace .table-card:has(table[data-mobile-cards]) .filter-bar__group { width: 100%; min-width: 0; }
  .app-workspace .workspace .table-card:has(table[data-mobile-cards]) .filter-bar .segmented { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-workspace .workspace .table-card:has(table[data-mobile-cards]) .filter-bar .segmented__btn { flex: 0 0 auto; min-height: 48px; white-space: nowrap; }
  .app-workspace .workspace .table-scroll:has(table[data-mobile-cards]) { overflow: visible; border: 0; }
  .app-workspace .workspace table[data-mobile-cards] { width: 100%; min-width: 0; border-collapse: separate; border-spacing: 0; }
  .app-workspace .workspace table[data-mobile-cards] thead { display: none; }
  .app-workspace .workspace table[data-mobile-cards] tbody { display: grid; gap: var(--space-8); }
  .app-workspace .workspace table[data-mobile-cards] tbody tr:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-12);
    overflow: hidden;
    padding: var(--space-4) var(--space-12);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-card);
    background: var(--bg-surface);
    box-shadow: var(--shadow-none);
  }
  .app-workspace .workspace table[data-mobile-cards] tbody td {
    display: flex;
    min-width: 0;
    height: auto;
    min-height: 48px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-8) 0;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    white-space: normal;
  }
  .app-workspace .workspace table[data-mobile-cards] tbody td::before {
    color: var(--text-muted);
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .app-workspace .workspace table[data-mobile-cards] tbody td:first-child:not(.bulk-select-cell),
  .app-workspace .workspace table[data-mobile-cards] tbody td:last-child { grid-column: 1 / -1; }
  .app-workspace .workspace table[data-mobile-cards] tbody tr:has(> .bulk-select-cell) td:nth-child(2) { grid-column: 1 / -1; }
  .app-workspace .workspace table[data-mobile-cards] tbody td.bulk-select-cell {
    min-height: 40px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding: var(--space-4) 0;
  }
  .app-workspace .workspace table[data-mobile-cards] tbody td.bulk-select-cell::before { content: none; }
  .app-workspace .workspace table[data-mobile-cards] tbody td:last-child { border-bottom: 0; }
  .app-workspace .workspace table[data-mobile-cards] .data-table__primary,
  .app-workspace .workspace table[data-mobile-cards] .data-table__secondary { white-space: normal; overflow-wrap: anywhere; }
  .app-workspace .workspace table[data-mobile-cards] .is-numeric { text-align: left; }
  .app-workspace .workspace table[data-mobile-cards] .row-actions { justify-content: flex-start; }
  .app-workspace .workspace #reorderTable .reorder-level,
  .app-workspace .workspace #barcodeCatalogTable .barcode-copies { min-height: 48px; }

  /* Complex ledgers and transaction lists get field groupings chosen for
     phone scanning: record identity and long descriptions use the full row. */
  .app-workspace .workspace :is(#settlementOutstandingTable, #settlementHistoryTable, #exchangeTable, #rechargeTable, #transactionTable,
    #providentTable, #invoiceTable, #returnTable, #statementTable, #orderTable, #receiptTable, #whatsappTable, #deviceTable,
    #dbTableTable, #requestTable, #sessionTable, #ledgerTable, #libraryTable, #emailTable, #reminderTable, #quotationTable) tbody td {
    overflow-wrap: anywhere;
  }

  .app-workspace .workspace :is(#settlementOutstandingTable, #settlementHistoryTable, #exchangeTable, #rechargeTable, #transactionTable,
    #providentTable, #invoiceTable, #returnTable, #statementTable, #orderTable, #receiptTable, #whatsappTable, #deviceTable,
    #dbTableTable, #requestTable, #sessionTable, #ledgerTable, #libraryTable, #emailTable, #reminderTable, #quotationTable) tbody td:last-child,
  .app-workspace .workspace #settlementOutstandingTable tbody td:nth-child(2),
  .app-workspace .workspace #settlementOutstandingTable tbody td:nth-child(3),
  .app-workspace .workspace #settlementOutstandingTable tbody td:nth-child(4),
  .app-workspace .workspace #settlementHistoryTable tbody td:nth-child(3),
  .app-workspace .workspace #settlementHistoryTable tbody td:nth-child(4),
  .app-workspace .workspace #settlementHistoryTable tbody td:nth-child(5),
  .app-workspace .workspace #exchangeTable tbody td:nth-child(2),
  .app-workspace .workspace #exchangeTable tbody td:nth-child(4),
  .app-workspace .workspace #rechargeTable tbody td[data-label="Transaction"],
  .app-workspace .workspace #rechargeTable tbody td[data-label="People"],
  .app-workspace .workspace #rechargeTable tbody td[data-label="Description"],
  .app-workspace .workspace #drawerTable tbody td[data-label="Employee & Accounts"],
  .app-workspace .workspace #transactionTable tbody td[data-label="Transaction"],
  .app-workspace .workspace #transactionTable tbody td[data-label="People"],
  .app-workspace .workspace #transactionTable tbody td[data-label="Description"],
  .app-workspace .workspace #providentTable tbody td:nth-child(2),
  .app-workspace .workspace #providentTable tbody td:nth-child(7),
  .app-workspace .workspace #providentTable tbody td:nth-child(8),
  .app-workspace .workspace #providentTable tbody td:nth-child(10),
  .app-workspace .workspace #invoiceTable tbody td:nth-child(3),
  .app-workspace .workspace #invoiceTable tbody td:nth-child(4),
  .app-workspace .workspace #invoiceTable tbody td:nth-child(5),
  .app-workspace .workspace #returnTable tbody td:nth-child(2),
  .app-workspace .workspace #returnTable tbody td:nth-child(3),
  .app-workspace .workspace #returnTable tbody td:nth-child(4),
  .app-workspace .workspace #returnTable tbody td:nth-child(9),
  .app-workspace .workspace #statementTable tbody td:nth-child(4),
  .app-workspace .workspace #statementTable tbody td:nth-child(5),
  .app-workspace .workspace #orderTable tbody td:nth-child(3),
  .app-workspace .workspace #orderTable tbody td:nth-child(7),
  .app-workspace .workspace #orderTable tbody td:nth-child(8),
  .app-workspace .workspace #receiptTable tbody td:nth-child(3),
  .app-workspace .workspace #receiptTable tbody td:nth-child(4),
  .app-workspace .workspace #receiptTable tbody td:nth-child(5),
  .app-workspace .workspace #whatsappTable tbody td:nth-child(4),
  .app-workspace .workspace #whatsappTable tbody td:nth-child(5),
  .app-workspace .workspace #whatsappTable tbody td:nth-child(7),
  .app-workspace .workspace #deviceTable tbody td:nth-child(2),
  .app-workspace .workspace #deviceTable tbody td:nth-child(3),
  .app-workspace .workspace #deviceTable tbody td:nth-child(6),
  .app-workspace .workspace #dbTableTable tbody td:nth-child(1),
  .app-workspace .workspace #requestTable tbody td:nth-child(1),
  .app-workspace .workspace #requestTable tbody td:nth-child(2),
  .app-workspace .workspace #requestTable tbody td:nth-child(3),
  .app-workspace .workspace #sessionTable tbody td:nth-child(2),
  .app-workspace .workspace #sessionTable tbody td:nth-child(3),
  .app-workspace .workspace #sessionTable tbody td:nth-child(6),
  .app-workspace .workspace #accountTable tbody td[data-label="Account Name"],
  .app-workspace .workspace #cashbookTable tbody td[data-label="Description"],
  .app-workspace .workspace #transferTable tbody td[data-label="From / To"],
  .app-workspace .workspace #barcodeCatalogTable tbody td:is([data-label="Barcode"], [data-label="Item"], [data-label="Variant"]),
  .app-workspace .workspace #productTable tbody td:is([data-label="Product"], [data-label="Variant"], [data-label="Barcode"]),
  .app-workspace .workspace #bundleTable tbody td:is([data-label="Bundle"], [data-label="Components"], [data-label="Barcode"]),
  .app-workspace .workspace #serviceTable tbody td:is([data-label="Service"], [data-label="Variant"], [data-label="Barcode"]),
  .app-workspace .workspace #reorderTable tbody td:is([data-label="Product"], [data-label="Variant"]),
  .app-workspace .workspace #inventoryStockTable tbody td[data-label="Product"],
  .app-workspace .workspace #inventoryStockTable tbody td[data-label="Actions"],
  .app-workspace .workspace #movementTable tbody td:is([data-label="Item"], [data-label="Variant"]),
  .app-workspace .workspace #topupPackageTable tbody td:is([data-label="Network"], [data-label="Package"]),
  .app-workspace .workspace #ledgerTable tbody td[data-label="People"],
  .app-workspace .workspace #ledgerTable tbody td[data-label="Description"],
  .app-workspace .workspace #libraryTable tbody td:nth-child(2),
  .app-workspace .workspace #libraryTable tbody td:nth-child(7),
  .app-workspace .workspace #emailTable tbody td:nth-child(4),
  .app-workspace .workspace #emailTable tbody td:nth-child(5),
  .app-workspace .workspace #emailTable tbody td:nth-child(6),
  .app-workspace .workspace #reminderTable tbody td:nth-child(3),
  .app-workspace .workspace #reminderTable tbody td:nth-child(4),
  .app-workspace .workspace #quotationTable tbody td:nth-child(3),
  .app-workspace .workspace #quotationTable tbody td:nth-child(4) { grid-column: 1 / -1; }

  .app-workspace .workspace #bundleComponentBody > tr > td:nth-child(2) { grid-column: 1 / -1; }

  .app-workspace .workspace:has(#rechargeTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented,
  .app-workspace .workspace:has(#transactionTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .app-workspace .workspace:has(#rechargeTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented__btn,
  .app-workspace .workspace:has(#transactionTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented__btn {
    flex: 0 0 auto;
    min-height: 48px;
    white-space: nowrap;
  }

  .app-workspace .workspace:has(#cashbookTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented,
  .app-workspace .workspace:has(#transferTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .app-workspace .workspace:has(#cashbookTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented__btn,
  .app-workspace .workspace:has(#transferTable) > .filter-bar:not(:has(.filter-bar__group--dates)) .segmented__btn {
    flex: 0 0 auto;
    min-height: 48px;
    white-space: nowrap;
  }

}
