@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/montserrat-latin-variable.woff2") format("woff2");
}

:root {
  --red: #c41e3a;
  --red-strong: #a51830;
  --ink: #231f20;
  --grey-50: #f7f7f8;
  --grey-200: #e6e6e6;

  --bg: var(--grey-50);
  --surface: #ffffff;
  --text: var(--ink);
  --text-muted: #6b6768;
  --border: var(--grey-200);
  --accent: var(--red);
  --accent-text: #ffffff;
  --focus: var(--red);
  --shadow: 0 1px 2px rgba(35, 31, 32, 0.06), 0 2px 8px rgba(35, 31, 32, 0.04);
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn: #8f5400;
  --warn-bg: #fff6e8;
  --good: #2e7d4f;
  --chart-last: #6b6768;
  --age-current: #5b6770;
  --age-30: #d9a441;
  --age-45: #e07b39;
  --age-60: #c41e3a;
  --age-90: #7a1224;

  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 10px;
}

:root[data-theme="dark"] {
  --bg: #161314;
  --surface: #231f20;
  --text: #f7f7f8;
  --text-muted: #a9a5a6;
  --border: #3a3536;
  --accent: #e0455f;
  --accent-text: #ffffff;
  --focus: #e0455f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --danger: #ff8a80;
  --danger-bg: #3a1514;
  --warn: #f5a623;
  --warn-bg: #3a2e14;
  --good: #6fcf97;
  --chart-last: #cfcbcc;
  --age-current: #8a98a3;
  --age-30: #e6b755;
  --age-45: #ea8f55;
  --age-60: #e0455f;
  --age-90: #a8334a;
  color-scheme: dark;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 4px solid var(--red);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand__logo {
  display: block;
  width: auto;
  height: 34px;
}

.brand__logo--dark {
  display: none;
}

:root[data-theme="dark"] .brand__logo--light {
  display: none;
}

:root[data-theme="dark"] .brand__logo--dark {
  display: block;
}

.brand__sub {
  padding-left: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
  white-space: nowrap;
  border-left: 1px solid var(--border);
}

@media (max-width: 700px) {
  .brand__sub {
    display: none;
  }

  .brand__logo {
    height: 28px;
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.theme-toggle__icon {
  display: block;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

:root[data-theme="light"] .theme-toggle__icon--sun,
:root[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

.tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  overflow-x: auto;
}

.tabs__list {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tabs__link {
  display: block;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

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

.tabs__link.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
}

.page__title {
  margin: 0 0 20px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.empty {
  padding: 56px 24px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.empty__text {
  margin: 0;
  color: var(--text-muted);
}

.footer {
  padding: 16px 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}
.topbar__inner .brand {
  margin-right: auto;
}

/* Sign-in page and sign-out control */
.signout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.signout__who {
  color: var(--text-muted);
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signout__button {
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.signout__button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* No-access page (shares the card look of the old sign-in page) */
.login {
  max-width: 26rem;
}

.login__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-top: 1rem;
}

.login__muted {
  color: var(--text-muted);
  margin: 0;
}

/* Sign-in page: a centred card on the page background */
.signin-bar {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px 0;
  border-top: 4px solid var(--red);
}

.main--signin {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.signin {
  width: 100%;
  max-width: 26rem;
}

.signin__card {
  padding: 2.25rem 2rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--red);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(35, 31, 32, 0.1), 0 2px 6px rgba(35, 31, 32, 0.06);
}

:root[data-theme="dark"] .signin__card {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.signin__logo {
  display: block;
  width: auto;
  height: 40px;
  margin: 0 auto 1.5rem;
}

.signin__logo--dark {
  display: none;
}

:root[data-theme="dark"] .signin__logo--light {
  display: none;
}

:root[data-theme="dark"] .signin__logo--dark {
  display: block;
}

.signin__title {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
}

.signin__subtitle {
  margin: 0.25rem 0 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.signin__error {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
}

.signin__button {
  display: block;
  width: 100%;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.signin__button:hover {
  background: var(--red-strong);
  border-color: var(--red-strong);
  box-shadow: 0 4px 12px rgba(196, 30, 58, 0.3);
}

.signin__button:focus-visible,
.signin__input:focus-visible,
.signin__more summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.signin__muted {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.signin__more {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.signin__more summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.signin__form {
  margin-top: 1rem;
}

.signin__label {
  display: block;
  margin: 0 0 0.375rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.signin__input {
  display: block;
  width: 100%;
  margin: 0 0 1rem;
  padding: 0.75rem 0.875rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.signin__input:focus {
  border-color: var(--accent);
}

@media (max-width: 480px) {
  .signin__card {
    padding: 1.75rem 1.25rem 1.5rem;
    border-radius: 14px;
  }
}

/* Admin: users and access */
.muted {
  color: var(--text-muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.crumbs {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.crumbs a {
  color: var(--text-muted);
}

.admin-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-links__card {
  display: block;
  height: 100%;
  padding: 18px 20px;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-links__card:hover {
  border-color: var(--accent);
}

.admin-links__title {
  display: block;
  font-weight: 700;
}

.admin-links__text {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.panel {
  margin-bottom: 20px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel--flush {
  padding: 0;
  overflow-x: auto;
}

.panel__title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.panel__hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.notice,
.form-error {
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #2e7d4f;
  border-radius: var(--radius);
}

.form-error {
  border-left-color: var(--accent);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}

.field--grow {
  flex: 1;
}

.field--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-bottom: 8px;
}

.field__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field__hint {
  max-width: 260px;
  font-size: 12px;
  color: var(--text-muted);
}

.field__static {
  padding: 8px 0;
  font-weight: 600;
}

.field__input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
}

.button {
  display: inline-block;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 7px 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button--ghost {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}

.button--ghost:hover {
  border-color: var(--accent);
}

.button--small {
  padding: 3px 10px;
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tr.is-inactive td {
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.badge--admin {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.badge--off {
  color: var(--text-muted);
}

.chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 1px 8px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.chip__src {
  font-weight: 700;
  color: var(--text-muted);
}

.sections__group {
  margin: 0;
  padding: 10px 14px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sections__group legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
}

.toggle__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle__track {
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}

.toggle__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}

.toggle__input:checked + .toggle__track {
  background: var(--accent);
}

.toggle__input:checked + .toggle__track::after {
  transform: translateX(14px);
}

.toggle__input:focus-visible + .toggle__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.toggle--bare {
  display: inline-flex;
  padding: 0;
}

.notice--warn {
  background: var(--warn-bg);
  border-left-color: var(--warn);
}

/* Admin: groups (permission matrix) */
.perm-matrix th,
.perm-matrix td {
  vertical-align: middle;
}

.perm-matrix__group {
  min-width: 112px;
  text-align: center;
}

.perm-matrix__name {
  display: block;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.perm-matrix__group .cell-sub {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.perm-matrix__category th {
  padding-top: 14px;
  padding-bottom: 6px;
  color: var(--accent);
  background: var(--bg);
}

.perm-matrix .perm-matrix__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.perm-matrix__label .cell-sub {
  display: block;
  font-weight: 400;
}

.perm-matrix__cell {
  text-align: center;
}

.perm-matrix__select {
  padding: 4px 8px;
  font-size: 13px;
}

/* Admin: a user's permissions (inherit / override) */
.perms__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 6px;
}

.perms__head .panel__title {
  margin: 0;
}

.perms__groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(470px, 100%), 1fr));
  gap: 16px;
}

.perm {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto 124px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.perm:last-child {
  border-bottom: 0;
}

.perm__label {
  font-size: 14px;
}

.seg {
  display: inline-flex;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.seg__opt {
  position: relative;
  cursor: pointer;
}

.seg__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.seg__text {
  display: block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
}

.seg__opt:first-child .seg__text {
  border-left: 0;
}

.seg__input:checked + .seg__text {
  color: var(--accent-text);
  background: var(--accent);
}

.seg__input[value="inherit"]:checked + .seg__text {
  color: var(--text);
  background: var(--border);
}

.seg__input:focus-visible + .seg__text {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.perm__effective {
  justify-self: end;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.perm__effective.is-on {
  color: var(--accent);
  border-color: var(--accent);
}

.perm__effective.is-off {
  color: var(--text-muted);
}

.perm__effective.is-on.is-override {
  color: var(--accent-text);
  background: var(--accent);
}

.perm__effective.is-off.is-override {
  color: var(--surface);
  background: var(--text-muted);
  border-color: var(--text-muted);
}

.alias-list {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.alias-list__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.alias-list__item form {
  margin-left: auto;
}

.cell-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.badge--stale {
  color: var(--accent);
  border-color: var(--accent);
}

.badge--running {
  color: #2e7d4f;
  border-color: #2e7d4f;
}

.result--failed {
  color: var(--accent);
}

.freshness {
  margin: -12px 0 20px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Dashboard: open orders */
.empty--compact {
  padding: 32px 24px;
}

.orders__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.orders__title {
  margin: 0 8px 4px 0;
  font-size: 16px;
  font-weight: 700;
}

.field--compact {
  min-width: 0;
}

.field--compact .field__input {
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 6px;
}

.orders__summary {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.orders__count--overdue {
  color: var(--danger);
  font-weight: 700;
}

.orders__count--soon {
  color: var(--warn);
  font-weight: 700;
}

.orders__panel {
  margin-bottom: 8px;
}

.table--tight {
  font-size: 13px;
  line-height: 1.35;
}

.table--tight th,
.table--tight td {
  padding: 5px 10px;
}

.table--tight th {
  font-size: 11px;
  background: var(--bg);
}

.orders__row.is-overdue td {
  background: var(--danger-bg);
}

.orders__row.is-soon td {
  background: var(--warn-bg);
}

.orders__row.is-overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}

.orders__row.is-soon td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}

.orders__job {
  display: inline-block;
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.orders__due {
  white-space: nowrap;
}

.orders__due--overdue {
  color: var(--danger);
  font-weight: 700;
}

.orders__due--soon {
  color: var(--warn);
  font-weight: 700;
}

.orders__when {
  font-size: 12px;
  font-weight: 600;
}

.orders__sched-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.orders__sched-when {
  font-weight: 600;
}

.sched-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.sched-warning svg {
  flex: none;
}

.orders__legend {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.source-badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}

.source-badge--dm {
  color: var(--accent);
  border-color: var(--accent);
}

.firm-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
  background: var(--red);
  border-radius: 4px;
}

.orders__actions {
  white-space: nowrap;
  text-align: right;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.icon-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.55;
}

a.icon-button {
  text-decoration: none;
}

a.icon-button:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.icon-button--inline {
  width: 22px;
  height: 22px;
  margin-left: 6px;
  vertical-align: middle;
}

.orders__print-form {
  display: inline-block;
  margin: 0;
}

.icon-button-wrap {
  display: inline-flex;
  cursor: not-allowed;
}

.icon-button-wrap > .icon-button:disabled {
  pointer-events: none;
}

/* Dashboard: open quotes */
.quotes {
  margin: 0 0 24px;
}

.quotes-table th.quotes__amount-head,
.quotes-table td.quotes__amount {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.quotes__age {
  white-space: nowrap;
}

.quotes__age-text--warn {
  color: var(--warn);
  font-weight: 700;
}

.quotes__age-text--danger {
  color: var(--danger);
  font-weight: 700;
}

.quotes__pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 12px 0;
}

.quotes__expired {
  color: var(--danger);
}

.quotes-table td.orders__actions {
  white-space: nowrap;
}

.quotes__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.quotes__button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
}

.quotes__button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.quotes__summary-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.quotes__inline-form {
  display: inline-flex;
  margin: 0;
}

.quotes__slot:empty {
  display: none;
}

.quotes__lost-form {
  display: grid;
  gap: 6px;
  width: min(100%, 26rem);
  margin-left: auto;
  white-space: normal;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
}

.quotes__lost-actions {
  display: flex;
  gap: 6px;
}

.quotes__row--lost > td {
  background: color-mix(in srgb, var(--danger) 6%, transparent);
}

.quotes__row--lost [data-field="customer"],
.quotes__row--lost [data-field="amount"] {
  opacity: 0.75;
}

.quotes__notice:empty {
  display: none;
}

.quotes__notice {
  margin: 0 0 12px;
}

.quotes__dm-lost {
  white-space: normal;
  max-width: 11rem;
  text-align: right;
}

.quotes__lost-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Dashboard: quick-launch pills */
.launch {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.launch__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.launch__tile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 5px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.launch__tile:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.launch__logo {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.launch__logo img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.launch__text {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.launch__sub {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The RFQ widget reuses the round icon badge. */
.launch__icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-radius: 12px;
}

/* Quick RFQ widget (dashboard): one compact card, heading and form on a single row */
.rfqbox {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 14px;
  margin: 0 0 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.rfqbox--tab {
  margin-top: 8px;
}

.rfqbox__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.rfqbox__head .launch__icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.rfqbox__heading {
  min-width: 0;
}

.rfqbox__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
}

.rfqbox__sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-muted);
}

.rfqbox__form {
  flex: 1 1 420px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "input actions"
    "status status";
  align-items: start;
  gap: 4px 10px;
}

.rfqbox__input {
  grid-area: input;
  display: block;
  width: 100%;
  height: 3.9em;
  box-sizing: border-box;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: none;
  overflow-y: auto;
  transition: height 0.15s ease;
}

.rfqbox__form:focus-within .rfqbox__input {
  height: calc(5 * 1.4em + 18px);
}

.rfqbox__input::placeholder {
  color: var(--text-muted);
}

.rfqbox__input:focus {
  border-color: var(--focus);
  outline: 2px solid color-mix(in srgb, var(--focus) 25%, transparent);
  outline-offset: 0;
}

.rfqbox__actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.rfqbox__submit,
.rfqbox__full {
  padding: 7px 14px;
  font-size: 14px;
}

.rfqbox__status {
  grid-area: status;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rfqbox__form:focus-within .rfqbox__status,
.rfqbox__status--warn {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

@media (max-width: 700px) {
  .rfqbox__form {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "input"
      "actions"
      "status";
  }
}

/* Imposer tab */
.imposer__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 12px;
}

.imposer__head .page__title {
  margin: 0;
}

.imposer__status {
  font-size: 12px;
  color: var(--text-muted);
}

.imposer__office {
  margin-left: auto;
  font-size: 13px;
  color: var(--text-muted);
}

.imposer__frame-wrap {
  position: relative;
}

.imposer__error {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  max-width: 520px;
  border-left: 4px solid var(--accent);
}

.imposer__error[hidden] {
  display: none;
}

.imposer__unavailable {
  max-width: 520px;
  border-left: 4px solid var(--accent);
}

/* Dashboard: due-date form and preview (shadow mode) */
.orders__due-slot:empty {
  display: none;
}

.orders__due-slot {
  padding: 0;
}

.due-panel {
  margin: 6px 10px 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  white-space: normal;
}

.due-panel--preview {
  border-color: var(--warn);
  background: var(--warn-bg);
}

.due-banner {
  display: inline-block;
  margin: 0 0 6px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: 9999px;
}

.due-panel__title {
  margin: 0 0 2px;
  font-weight: 700;
}

.due-panel__current {
  margin: 0 0 8px;
  color: var(--text-muted);
}

.due-panel__note {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.due-panel__error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.due-form__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 14px;
}

.due-form__reason {
  min-width: 200px;
}

.due-form__confirm {
  margin-top: 8px;
  padding-bottom: 0;
}

.due-form__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.due-form__submit {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.due-preview {
  margin-top: 4px;
  background: var(--surface);
}

.due-preview tr.is-changed td:last-child {
  font-weight: 700;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch__track {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 16px;
  background: var(--border);
  border-radius: 99px;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 99px;
  transition: left 0.12s;
}

.switch input:checked + .switch__track {
  background: var(--accent);
}

.switch input:checked + .switch__track::after {
  left: 14px;
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch__label {
  font-size: 13px;
}

.due-form [hidden] {
  display: none;
}

.due-form__actions .button:not(.due-form__submit),
.due-panel--preview .due-form__actions .button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

/* Admin: due date changes */
.changes__filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.changes__pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.result-badge {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.result-badge--updated,
.result-badge--ready {
  color: #2e7d4f;
  border-color: #2e7d4f;
}

.result-badge--flagged,
.result-badge--stopped {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: var(--warn);
}

.result-badge--failed,
.result-badge--unreadable {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger);
}

.result-badge--reverted {
  color: var(--text);
  border-color: var(--text-muted);
}

.changes__nowrap {
  white-space: nowrap;
}

td[data-field="when"].changes__nowrap {
  white-space: normal;
  min-width: 6.5rem;
}

[data-field="actions"] .button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

[data-field="actions"] form {
  margin: 0 0 0.35rem;
}

.cell-sub--warn {
  color: var(--warn);
}

.drift-list {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* Embedded tools (Imposer, RFQ; a Scheduler tab later): the tool reads as part of the page. The iframe has
   no border, card or background of its own and no scroll bar; static/js/embed.js sets its height from the
   tool's resize messages, so the portal page does all the scrolling. */
.embed-frame {
  display: block;
  width: 100%;
  min-height: 600px;
  border: 0;
  background: transparent;
}

.embed-frame[data-embed-sized] {
  min-height: 0;
}

.embedbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px 16px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

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

.embedbar__button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.embedbar .imposer__status {
  margin-right: auto;
}

.rfqpage__warning,
.rfqbox__status--warn {
  color: #9a5b00;
  font-weight: 600;
}

:root[data-theme="dark"] .rfqpage__warning,
:root[data-theme="dark"] .rfqbox__status--warn {
  color: #f0b45a;
}

.rfqpage__warning {
  margin: 0 0 12px;
  font-size: 13px;
}

/* Admin: due-date writes (kill switch) */
.write-state {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: var(--surface);
}

.write-state--off {
  border-left-color: #2e7d4f;
}

.write-state--on {
  border-color: var(--danger);
  border-left-color: var(--danger);
  background: var(--danger-bg);
}

.write-state__label {
  font-size: 18px;
  font-weight: 700;
}

.write-state__text {
  font-size: 13px;
  color: var(--text-muted);
}

.badge--on {
  color: var(--danger);
  border-color: var(--danger);
}

.dry-run-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.dry-run-report__steps {
  margin: 4px 0 12px;
  padding-left: 20px;
}

.dry-run-report__selector {
  word-break: break-all;
  font-size: 12px;
}

.write-switch-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

/* Admin alert banners and Admin > System */
.admin-alerts p:last-child {
  margin-bottom: 20px;
}

.system-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.system-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0 0 12px;
}

.system-facts dt {
  font-weight: 600;
}

.system-facts dd {
  margin: 0;
}

[data-table="limits"] caption {
  text-align: left;
  padding: 12px 14px 4px;
}

/* Dashboard: sales stats strip and panel. Pure server-rendered HTML and SVG; colours come from the theme tokens. */
.stats {
  margin: 0 0 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 8px 14px;
}

.stats__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.stats__scope {
  font-size: 13px;
  color: var(--text-muted);
}

.stats__picker {
  margin: 0;
}

.stats__picker .field {
  min-width: 0;
}

.stats__strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1;
}

.stats__strip-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.stats__strip-label,
.stats__tile-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.stats__strip-value {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats__asof {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
}

.stats__toggle {
  margin: 0 0 0 auto;
}

.stats__delta {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--text-muted);
}

.stats__delta--up {
  color: var(--good);
}

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

.stats__detail {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--border);
}

.stats__scope-line {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.stats__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stats__tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
}

.stats__tile-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stats__note {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.stats__empty {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.stats__block {
  margin-top: 18px;
}

.stats__heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.stats__total {
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chart {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
}

.chart text {
  font-family: var(--font);
}

.chart__grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart__axis {
  font-size: 10px;
  fill: var(--text-muted);
}

.chart__bar {
  fill: var(--accent);
}

.chart__bar--partial {
  opacity: 0.7;
}

.chart__line {
  fill: none;
  stroke: var(--chart-last);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart__dot {
  fill: var(--surface);
  stroke: var(--chart-last);
  stroke-width: 2;
}

.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.chart__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  border-radius: 2px;
}

.chart__swatch--this {
  background: var(--accent);
}

.chart__swatch--last {
  height: 3px;
  vertical-align: 3px;
  background: var(--chart-last);
}

.stats__numbers {
  margin-top: 6px;
  font-size: 12px;
}

.stats__numbers summary {
  cursor: pointer;
  color: var(--text-muted);
}

.stats__numbers table {
  max-width: 360px;
  margin-top: 6px;
}

.stats__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin: 0;
}

.stats__fact {
  display: flex;
  flex-direction: column;
}

.stats__fact dt {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.stats__fact dd {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stats__ratio,
.stats__stack {
  display: block;
  width: 100%;
  max-width: 720px;
  margin-top: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.stats__ratio {
  height: 8px;
}

.stats__stack {
  height: 18px;
}

.stats__ratio-lost {
  fill: var(--border);
}

.stats__ratio-won {
  fill: var(--accent);
}

.stats__seg--current,
.stats__swatch--current {
  fill: var(--age-current);
  background: var(--age-current);
}

.stats__seg--30,
.stats__swatch--30 {
  fill: var(--age-30);
  background: var(--age-30);
}

.stats__seg--45,
.stats__swatch--45 {
  fill: var(--age-45);
  background: var(--age-45);
}

.stats__seg--60,
.stats__swatch--60 {
  fill: var(--age-60);
  background: var(--age-60);
}

.stats__seg--90,
.stats__swatch--90 {
  fill: var(--age-90);
  background: var(--age-90);
}

.stats__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.stats__swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
}

.stats__queues {
  display: grid;
  gap: 6px;
  max-width: 720px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stats__queue {
  display: grid;
  grid-template-columns: 130px 1fr 190px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.stats__queue-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.stats__queue-bar {
  display: block;
  width: 100%;
  height: 10px;
  border-radius: 3px;
  overflow: hidden;
}

.stats__queue-track {
  fill: var(--border);
}

.stats__queue-fill {
  fill: var(--accent);
}

.stats__queue-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats__problems {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
}

@media (max-width: 700px) {
  .stats__queue {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .stats__queue-value {
    text-align: left;
  }

  .stats__toggle {
    margin-left: 0;
  }
}
