:root {
  --ink: #102033;
  --muted: #66768a;
  --line: #d9e4ed;
  --surface: #ffffff;
  --surface-soft: #f6f9fb;
  --page-bg: #eaf1f5;
  --input-bg: #ffffff;
  --brand: #0a1627;
  --brand-2: #2872ff;
  --brand-3: #27d9f2;
  --sidebar-bg: #0a1627;
  --button-soft: #dfeaf0;
  --mini-bg: #edf4f7;
  --login-card-bg: rgba(255, 255, 255, .98);
  --login-pattern: linear-gradient(145deg, rgba(13, 34, 56, .94), rgba(13, 127, 140, .78)), repeating-linear-gradient(135deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 18px);
  --accent: #2fe66c;
  --danger: #c54444;
  --success: #227a55;
  --shadow: 0 18px 55px rgba(16, 32, 51, .12);
  --radius: 8px;
}

:root[data-theme="dark"] {
  --ink: #e7eef6;
  --muted: #9aacbd;
  --line: #2b3e53;
  --surface: #111d2b;
  --surface-soft: #172638;
  --page-bg: #09131f;
  --input-bg: #0c1826;
  --brand: #e7eef6;
  --brand-2: #2f7bff;
  --brand-3: #2ee3f5;
  --sidebar-bg: #071321;
  --button-soft: #203349;
  --mini-bg: #1a2b3e;
  --login-card-bg: #111d2b;
  --login-pattern: linear-gradient(145deg, rgba(5, 14, 24, .96), rgba(4, 55, 81, .86)), repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 18px);
  --shadow: 0 18px 55px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--login-pattern);
}

.login-card {
  width: min(440px, 100%);
  background: var(--login-card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.login-card h1 {
  margin: 28px 0 20px;
  font-size: 28px;
  line-height: 1.1;
}

#loginScreen {
  --ink: #f6faff;
  --muted: #b9c7d8;
  --line: #2c394a;
  --input-bg: #11182a;
  --button-soft: #19273a;
  --brand-2: #66acff;
  --danger: #ff9b9b;
  --login-frame: #070f1e;
  --login-card-bg: #0b1421;
  --login-canvas: radial-gradient(ellipse at 0 0, #092730, transparent 54%), radial-gradient(ellipse at 100% 100%, #152824, transparent 55%), #081223;
  color: var(--ink);
  background: var(--login-canvas);
  padding: clamp(12px, 1.4vw, 24px);
  min-height: 100svh;
}

#loginScreen[data-theme="light"] {
  --ink: #102033;
  --muted: #465a72;
  --line: #cbd8e4;
  --input-bg: #f7fafc;
  --button-soft: #e1ebf3;
  --brand-2: #1657ae;
  --danger: #a92532;
  --login-frame: #edf4f8;
  --login-card-bg: #fff;
  --login-canvas: linear-gradient(140deg, #d9ecef, #e9f1f8 55%, #dcebe3);
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.075fr) minmax(280px, 1fr);
  align-items: center;
  gap: clamp(16px, 2.3vw, 28px);
  width: min(1180px, 100%);
  padding: clamp(14px, 1.85vw, 22px);
  background: var(--login-frame);
  border: 1px solid var(--line);
  border-radius: 28px;
}

.login-art {
  container-type: inline-size;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #20314b;
  border-radius: 21px;
  background: radial-gradient(ellipse at 110% 100%, #0e305c, transparent 72%), linear-gradient(135deg, #050915, #0b1733);
}

.login-wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.4cqw;
  width: 83%;
  color: #fbfdff;
  transform: translateY(2%);
}

.login-wordmark img {
  flex: 0 0 auto;
  width: 39%;
  height: auto;
  filter: drop-shadow(0 8px 18px #031020);
}

.login-wordmark-text {
  min-width: 0;
  line-height: 1;
  white-space: nowrap;
}

.login-wordmark strong {
  font-size: 10.05cqw;
  font-weight: 800;
  letter-spacing: -.045em;
}

.login-wordmark span {
  color: #a2d674;
}

.login-wordmark small {
  display: block;
  margin-top: .3em;
  color: #82ce88;
  font-size: 4.9cqw;
  font-weight: 400;
  letter-spacing: .03em;
}

#loginScreen .login-card {
  container-type: inline-size;
  width: 100%;
  padding: clamp(20px, 2.8vw, 34px);
  border-radius: 22px;
  box-shadow: none;
}

#loginScreen .login-actions {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

#loginScreen .login-actions .icon-button {
  min-height: 32px;
  width: 32px;
  padding: 0;
  color: var(--muted);
}

.login-kicker {
  margin: 0;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

#loginScreen .login-card h1 {
  margin: 3px 0 28px;
  font-size: clamp(2.5rem, 22cqw, 4.25rem);
  letter-spacing: -.052em;
  line-height: 1.05;
}

#loginScreen .stack-form { gap: 20px; }
#loginScreen label { color: var(--ink); }
#loginScreen .form-error { color: var(--danger); }

#loginScreen .primary-button {
  min-height: 52px;
  margin-top: 4px;
  border-radius: 9px;
  background: linear-gradient(110deg, #14b8a6, #82cc16);
  color: #061715;
  box-shadow: 0 12px 32px #11a99429;
}

#loginScreen .link-button {
  display: block;
  margin: 21px auto 0;
  min-height: 36px;
  color: var(--brand-2);
}

@media (max-width: 760px) {
  .login-layout {
    max-width: 460px;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    border-radius: 22px;
  }

  .login-art { aspect-ratio: 16 / 8; border-radius: 15px; }
  .login-wordmark { width: 78%; transform: none; }
  .login-wordmark img { width: 35%; }
  #loginScreen .login-card { border-radius: 16px; }
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

:root[data-theme="dark"] .form-error {
  color: #ff9b9b;
}

.brand-lockup,
.navigation-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup strong,
.navigation-brand strong {
  display: block;
  color: var(--brand);
  font-size: 18px;
}

.brand-lockup span,
.navigation-brand span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: block;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 12px 30px rgba(39, 217, 242, .18);
}

.stack-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  background: var(--input-bg);
  outline: 0;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(13, 127, 140, .14);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.mini-button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  color: #061321;
  background: linear-gradient(135deg, #18c95b, #39ef7b);
}

.secondary-button {
  color: var(--brand);
  background: var(--button-soft);
}

.ghost-button {
  color: var(--brand);
  background: transparent;
  border: 1px solid var(--line);
}

.danger-button {
  color: white;
  background: var(--danger);
}

.mini-button {
  min-height: 32px;
  padding: 6px 10px;
  color: var(--brand);
  background: var(--mini-bg);
}

.danger-mini {
  color: white;
  background: var(--danger);
}

.success-mini {
  color: #061321;
  background: var(--success);
}

.icon-button {
  display: inline-flex;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  pointer-events: none;
}

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

button:disabled {
  cursor: wait;
  opacity: .65;
}

.link-button {
  width: fit-content;
  min-height: auto;
  margin-top: 12px;
  border: 0;
  padding: 0;
  color: var(--brand-2);
  background: transparent;
  font-weight: 800;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-navigation {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 24px;
  color: white;
  background: var(--sidebar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.app-navigation .brand-mark {
  box-shadow: 0 12px 30px rgba(40, 114, 255, .2);
}

.navigation-brand strong {
  color: white;
}

.navigation-brand span {
  color: rgba(255, 255, 255, .68);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-button {
  width: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  padding: 10px;
  color: rgba(255, 255, 255, .82);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.nav-button:hover,
.nav-button.active {
  color: white;
  background: linear-gradient(90deg, rgba(40, 114, 255, .28), rgba(39, 217, 242, .12));
}
.nav-button > svg { width: 16px; height: 16px; margin-left: 8px; }
.client-nav-menu { position: fixed; inset: auto; margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow-y: auto; }
.client-nav-menu .nav-button { width: 100%; color: var(--ink); }
.client-nav-menu .nav-button:hover, .client-nav-menu .nav-button.active { color: var(--ink); background: var(--button-soft); }
.dashboard-project { padding: 16px 0; border-bottom: 1px solid var(--line); }
.dashboard-project:last-child { border-bottom: 0; }
.dashboard-project-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.dashboard-project progress { display: block; width: 100%; height: 12px; margin: 12px 0 8px; accent-color: var(--brand-2); }
.dashboard-operation-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dashboard-operation-row:last-child { border-bottom: 0; }
.dashboard-operation-row progress { flex-basis: 100%; height: 10px; width: 100%; accent-color: var(--brand-2); }
.dashboard-kpi-link { text-align: left; white-space: normal; color: var(--ink); }

.navigation-brand, #logoutButton { flex-shrink: 0; }

.app-navigation .ghost-button {
  color: white;
  border-color: rgba(255, 255, 255, .25);
}

.workspace {
  min-width: 0;
  width: 100%;
  padding: 22px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.role-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brand);
  background: var(--button-soft);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.success {
  color: #155c3d;
  background: #dff3ea;
}

.status-pill.warning {
  color: #7b520f;
  background: #fff2d2;
}

.status-pill.danger {
  color: #8a2929;
  background: #f8dddd;
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius);
  padding: 12px 14px;
  color: white;
  background: #0f88a0;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.view-root {
  display: grid;
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card,
.panel,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(16, 32, 51, .06);
}

.kpi-card {
  padding: 18px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 32px;
  line-height: 1;
}

.panel {
  padding: 18px;
}

.panel h3,
.table-panel h3 {
  margin: 0 0 14px;
  color: var(--brand);
  font-size: 17px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.record-editor {
  width: min(1120px, 100%);
  min-width: 0;
  margin-inline: auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  container-type: inline-size;
}

.report-filter-form {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.report-export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.report-export-button svg {
  width: 18px;
  height: 18px;
}

.report-summary strong {
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.report-preview {
  min-width: 0;
}

.report-preview .table-heading {
  flex-wrap: wrap;
}

.report-preview table {
  min-width: 850px;
}

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

.report-nowrap {
  white-space: nowrap;
}

.report-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-block: 14px;
}

.editor-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.editor-heading h3 {
  margin: 0;
  font-size: 20px;
}

.wide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .full,
.stack-form .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

.table-panel {
  overflow: hidden;
}

.table-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px;
}

.table-heading h3 {
  margin-bottom: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

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

.subtle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.row-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.record-actions-cell {
  width: 68px;
  white-space: nowrap;
}

.record-actions-trigger[aria-expanded="true"] {
  color: var(--brand-2);
  background: var(--button-soft);
}

.record-action-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(248px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.record-action-menu .record-action-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

.record-action-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  pointer-events: none;
}

.record-action-item:hover:not(:disabled),
.record-action-item:focus-visible {
  background: var(--surface-soft);
}

.record-action-menu .danger-mini {
  color: var(--danger);
}

:root[data-theme="dark"] .record-action-menu .danger-mini {
  color: #ff9b9b;
}

.record-action-menu [data-delete]:not(:first-child) {
  margin-top: 5px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 4px 4px;
}

.record-action-menu button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.empty-state {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.quote-builder {
  display: grid;
  gap: 12px;
}

.quote-item-row {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr) 90px 140px auto;
  gap: 10px;
  align-items: end;
}

.quote-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.quote-chip {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.quote-editable-item {
  grid-template-columns: minmax(180px, 1fr) 100px 140px minmax(100px, auto) 40px;
  align-items: end;
}

.quote-editable-item > strong {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.product-thumbnail {
  display: block;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.product-name,
.quote-item-description {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.quote-item-description label {
  flex: 1;
}

.quote-selection-photo .product-thumbnail {
  width: 96px;
  height: 96px;
}

.product-image-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.product-image-preview {
  display: grid;
  place-items: center;
  flex: 0 0 128px;
  width: 128px;
  height: 128px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  overflow: hidden;
  background: var(--surface-soft);
}

.product-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.product-image-preview > svg {
  width: 32px;
  height: 32px;
}

.product-image-controls {
  display: flex;
  flex: 1 1 200px;
  align-items: end;
  min-width: 0;
  gap: 10px;
}

.product-image-controls label {
  flex: 1;
}

@container (max-width: 780px) {
  .quote-item-row,
  .quote-editable-item {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-item-row > label:nth-child(-n+2),
  .quote-editable-item > :first-child {
    grid-column: 1 / -1;
  }

  .quote-editable-item > strong {
    justify-content: flex-start;
  }

  .quote-editable-item > button {
    justify-self: end;
  }
}

.totals-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-weight: 900;
}

.split-list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.list-item strong {
  color: var(--brand);
}

.permission-note {
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  background: var(--surface-soft);
  border-radius: 0 7px 7px 0;
}

.success-note {
  border-left-color: var(--success);
  background: var(--surface-soft);
}

.config-panel {
  padding: 12px;
}

.config-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.active-tab {
  color: white;
  background: var(--brand-2);
}

.acl-cell {
  min-width: 140px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.inline-checks {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.smtp-profile {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-soft);
}

.smtp-profile h4 {
  margin: 0;
  color: var(--brand);
  font-size: 15px;
}

.smtp-profile code {
  color: var(--brand);
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 14, 24, .62);
}

.modal-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.compact-heading {
  padding: 0;
  margin-bottom: 14px;
}

.quote-email-dialog {
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  color: var(--ink);
}

.quote-email-dialog::backdrop {
  background: rgba(5, 14, 24, .7);
}

#quoteEmailSubject {
  overflow-wrap: anywhere;
  margin: 0 0 18px;
}

@media (max-width: 1180px) {
  .report-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-grid,
  .wide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .workspace {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .report-filters,
  .kpi-grid,
  .quote-item-row {
    grid-template-columns: 1fr;
  }

  .quote-chip {
    grid-template-columns: 1fr;
  }

  .record-editor {
    padding: 16px;
  }
}
.ticket-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.ticket-update {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.ticket-update:last-child { border-bottom: 0; }
.ticket-update-internal { border-left: 3px solid var(--muted); padding-left: 14px; }
.ticket-update-heading { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between; }
.ticket-detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.ticket-back-button { justify-self: start; }
.ticket-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sla-summary { display: grid; gap: 6px; margin-top: 8px; }
.sla-summary > .status-pill { justify-self: start; }
.sla-overdue { border-left: 3px solid #e15b64; padding-left: 10px; }
.sla-calendar { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.ticket-description-preview { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.ticket-bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ticket-bulk-toolbar > .subtle { flex-basis: 100%; }
.bulk-action-label { min-width: 210px; }
.ticket-select-cell { width: 46px; min-width: 46px; text-align: center; }
.ticket-select-cell input, .checkbox-line input { width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 0; accent-color: var(--brand-2); cursor: pointer; }
tr.ticket-selected > td { background: color-mix(in srgb, var(--brand-2) 10%, var(--surface)); }
.ticket-group-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.ticket-group-heading .icon-button { width: 28px; height: 28px; min-height: 28px; }
.ticket-group-child > td:nth-child(2) { padding-left: 36px; border-left: 3px solid var(--brand-2); }
.ticket-group-label { margin-bottom: 6px; color: var(--brand-2); }
.ticket-bulk-dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; color: var(--ink); }
.ticket-bulk-dialog::backdrop { background: rgba(5, 14, 24, .7); }
.ticket-bulk-dialog .checkbox-line { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; overflow-wrap: anywhere; }
.ticket-bulk-dialog .checkbox-line input { flex: 0 0 18px; }
.bulk-selection-summary { padding: 12px; margin-bottom: 18px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.bulk-selection-summary ul { max-height: 180px; overflow-y: auto; padding-left: 20px; }
.bulk-selection-summary li { padding: 4px 0; overflow-wrap: anywhere; }
#bulkPaymentFields { display: grid; gap: 12px; }
#bulkPaymentFields.hidden { display: none; }
@media (max-width: 600px) { .bulk-action-label { flex: 1 1 100%; } .ticket-bulk-dialog .form-actions { flex-wrap: wrap; } }
.ticket-list-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.ticket-list-table { min-width: 0; max-width: 100%; }
.ticket-list-table table { min-width: 1000px; }
.ticket-work-views { display: flex; flex-wrap: wrap; gap: 10px; }
.ticket-work-views button { display: inline-flex; align-items: center; gap: 12px; }
.ticket-work-views button > span { min-width: 24px; padding: 3px 7px; border-radius: 20px; background: var(--surface); font-size: 12px; }
.ticket-work-views .active-work-view { outline: 2px solid var(--brand-2); outline-offset: -2px; }
.ticket-queue-label { margin-top: 4px; color: var(--brand-2); font-size: 12px; font-weight: 700; }
.queue-routing-intro { padding: 4px 2px; }
.queue-routing-list { min-width: 0; }
.queue-routing-list table { min-width: 850px; }
.queue-routing-list td:nth-child(3) { min-width: 260px; max-width: 480px; overflow-wrap: anywhere; }
[data-rule-conditions] { display: grid; gap: 16px; }
.queue-rule-condition { display: grid; grid-template-columns: 1fr 1fr minmax(180px, 1.5fr) auto; gap: 12px; align-items: end; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.queue-rule-condition legend { padding: 0 8px; font-size: 13px; color: var(--muted); }
.queue-rule-condition label { min-width: 0; }
.rule-add-condition { display: inline-flex; align-items: center; gap: 8px; width: fit-content; }
.rule-add-condition svg { width: 18px; height: 18px; }
.routing-simulation-result { padding: 14px; border-left: 3px solid var(--brand-2); background: var(--surface-soft); overflow-wrap: anywhere; }

.rmm-workspace { min-width: 0; }
.rmm-heading, .rmm-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rmm-heading { justify-content: space-between; }
.rmm-heading h2, .rmm-heading h3, .rmm-heading p { margin: 0; }
.rmm-heading p { margin-top: 6px; }
.rmm-heading a { text-decoration: none; }
.rmm-client { max-width: 420px; margin-bottom: 22px; }
.rmm-table { overflow-x: auto; margin: 12px 0 24px; }
.rmm-table table { min-width: 520px; }
.rmm-enrollment { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; align-items: end; padding: 16px; margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.rmm-enrollment p { grid-column: 1 / -1; margin: 0; }
.rmm-grants { margin: 16px 0 24px; padding: 12px 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.rmm-grants summary { cursor: pointer; font-weight: 700; }
.rmm-check { display: flex; align-items: center; gap: 8px; }
.rmm-check input { width: auto; min-height: auto; }
.rmm-viewer { margin-top: 24px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.rmm-screen { display: block; width: auto; height: auto; max-width: 100%; max-height: 72vh; margin: 16px auto 0; background: #08121e; border-radius: 6px; user-select: none; }
.rmm-screen[hidden] { display: none; }
.rmm-screen:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 4px; }
@media (max-width: 760px) { .queue-rule-condition { grid-template-columns: 1fr; } .queue-rule-condition > button { justify-self: end; } }
.notification-bell { position: relative; }
.notification-badge { position: absolute; top: -6px; right: -5px; border-radius: 12px; min-width: 20px; padding: 2px 4px; background: #c54444; color: white; font-size: 10px; line-height: 16px; }
.ticket-notification-center { position: fixed; inset: auto; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); color: var(--ink); overflow-y: auto; }
.ticket-notification-item { padding: 14px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.ticket-notification-item p, .ticket-notification-popup p { margin: 8px 0 12px; overflow-wrap: anywhere; }
.notification-read { opacity: .65; }
.ticket-notification-popups { position: fixed; bottom: 18px; right: 18px; width: min(380px, calc(100vw - 32px)); display: grid; gap: 12px; z-index: 45; pointer-events: none; }
.ticket-notification-popup { position: relative; padding: 18px; border: 1px solid var(--line); border-left: 4px solid var(--brand-2); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); pointer-events: auto; }
.ticket-notification-popup > strong { display: block; padding-right: 28px; }
.notification-sla { border-left-color: #d99027; }
.notification-dismiss { position: absolute; right: 8px; top: 8px; width: 28px; min-width: 28px; height: 28px; min-height: 28px; }
.ticket-column-filter-trigger { display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: inherit; font: inherit; text-transform: uppercase; }
.ticket-column-filter-trigger svg { width: 14px; height: 14px; flex-shrink: 0; }
.ticket-column-filter-trigger:hover, .ticket-column-filter-trigger.filter-active { color: var(--brand-2); }
.filter-active-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 50%; background: var(--brand-2); color: white; font-size: 11px; }
.ticket-column-filter { position: fixed; inset: auto; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); overflow-y: auto; font-size: 14px; font-weight: 400; text-transform: none; text-align: left; }
.ticket-column-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ticket-column-filter .form-actions { justify-content: space-between; }
.ticket-column-filter .icon-button { width: 28px; min-width: 28px; height: 28px; min-height: 28px; }
.ticket-column-filter .icon-button svg { width: 16px; height: 16px; }
.ticket-list-table .table-heading { gap: 12px; flex-wrap: wrap; }
.ticket-title-button { display: inline; width: auto; min-height: 0; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--ink); white-space: normal; text-align: left; font-size: inherit; line-height: inherit; }
.ticket-title-button:hover { color: var(--brand-2); text-decoration: underline; }
tr[data-ticket-row] { cursor: pointer; }
tr[data-ticket-row]:not(.ticket-selected):hover > td { background: var(--surface-soft); }
.ticket-detail-heading { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.ticket-detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; align-items: start; gap: 20px; }
.ticket-detail-main, .ticket-detail-controls { display: grid; min-width: 0; gap: 20px; }
.ticket-detail-layout h3, .ticket-detail-layout p { overflow-wrap: anywhere; }
.ticket-description-full { padding: 16px; margin: 18px 0; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; max-height: 380px; overflow-y: auto; }
@media (max-width: 1050px) {
  .app-navigation { flex-wrap: wrap; gap: 8px 18px; }
  .app-navigation #logoutButton { margin-left: auto; }
  .nav-list { order: 3; flex-basis: 100%; }
}
@media (max-width: 1050px) {
  .ticket-detail-layout { grid-template-columns: minmax(0, 1fr) 310px; }
}
@media (max-width: 760px) {
  .app-navigation { padding: 10px 16px; }
  .navigation-brand .brand-mark { width: 36px; height: 36px; }
  .nav-button { min-height: 38px; padding: 8px 10px; }
  .ticket-detail-layout { grid-template-columns: minmax(0, 1fr); }
  .ticket-detail-main { display: contents; }
  .ticket-detail-main > .panel:first-child { grid-row: 1; }
  .ticket-detail-controls { grid-row: 2; width: 100%; }
  .topbar { flex-direction: row; align-items: center; }
  .topbar h2 { font-size: 24px; }
  .topbar-actions { flex-shrink: 0; gap: 6px; }
  .topbar-actions button { padding: 8px 10px; }
}
