﻿:root {
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #eef4f1;
  --ink: #18201d;
  --muted: #65716d;
  --muted-2: #88948f;
  --line: #dce5e0;
  --line-strong: #c4d1ca;
  --brand: #0f766e;
  --brand-2: #0d9488;
  --brand-deep: #0b3f3b;
  --brand-soft: #dff5ef;
  --blue: #285f9d;
  --blue-soft: #e2edf9;
  --amber: #b36b00;
  --amber-soft: #fff0d2;
  --red: #ba3f45;
  --red-soft: #fae4e6;
  --green: #19734d;
  --green-soft: #e3f3e9;
  --violet: #5d4da8;
  --violet-soft: #ebe8fb;
  --shadow: 0 18px 44px rgba(21, 36, 31, 0.09);
  --shadow-soft: 0 8px 22px rgba(21, 36, 31, 0.07);
  --radius: 8px;
  --sidebar: #111917;
  --sidebar-2: #1a2724;
  --sidebar-line: rgba(229, 244, 238, 0.1);
}

[hidden] {
  display: none !important;
}

html[data-contrast="high"] {
  --bg: #ecefed;
  --surface: #ffffff;
  --surface-2: #f5f6f5;
  --ink: #101312;
  --muted: #3f4743;
  --line: #b9c3bc;
  --brand: #005f54;
  --brand-soft: #d7eee8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(40, 95, 157, 0.08), transparent 34%),
    repeating-linear-gradient(0deg, rgba(24, 32, 29, 0.025) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, rgba(24, 32, 29, 0.02) 0 1px, transparent 1px 32px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(20, 55, 49, 0.7), transparent 34%),
    var(--sidebar);
  color: #f8faf8;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 16px 0 38px rgba(14, 23, 20, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  min-height: 46px;
}

.brand:hover {
  background: rgba(255, 255, 255, 0.05);
}

.brand > span:last-child {
  display: grid;
  gap: 2px;
}

.brand b {
  font-size: 18px;
  line-height: 1;
}

.brand small {
  color: #a9b9b3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #d8f4e5, #c4e7ff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 10px 24px rgba(13, 148, 136, 0.25);
}

.brand-mark span {
  display: block;
  align-self: end;
  border-radius: 6px 6px 2px 2px;
  background: var(--brand);
}

.brand-mark span:nth-child(1) {
  height: 13px;
}

.brand-mark span:nth-child(2) {
  height: 21px;
}

.brand-mark span:nth-child(3) {
  height: 16px;
  background: #315f9f;
}

.primary-nav {
  margin-top: 28px;
  display: grid;
  gap: 12px;
}

.portal-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.portal-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #aebdb7;
  font-size: 11px;
  font-weight: 900;
}

.portal-switch button.active {
  background: #d8f4e5;
  color: var(--brand-deep);
  box-shadow: 0 8px 18px rgba(9, 50, 45, 0.24);
}

.nav-group {
  display: grid;
  gap: 5px;
}

body[data-portal-mode="user"] .agent-nav,
body[data-portal-mode="user"] .workspace-section-title,
body[data-portal-mode="agent"] .user-nav,
body[data-portal-mode="agent"] .user-section-title {
  display: none !important;
}

.agent-workspace-shortcut {
  display: none !important;
}

body[data-auth-role="agent"] .agent-workspace-shortcut,
body[data-auth-role="admin"] .agent-workspace-shortcut {
  display: flex !important;
}

.shortcut-stack .agent-workspace-shortcut {
  justify-content: center;
}

.employee-portal-link {
  margin-top: 8px;
  border-top-color: rgba(255, 255, 255, 0.08);
}

.nav-link {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: #b9c7c2;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover,
.nav-link.active {
  background: linear-gradient(135deg, rgba(223, 245, 239, 0.12), rgba(226, 237, 249, 0.08));
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.11);
  transform: translateX(2px);
}

.nav-ico {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #d8f4e5;
  font-size: 11px;
  font-weight: 900;
}

.nav-link.active .nav-ico {
  background: #d8f4e5;
  color: var(--brand);
}

.sidebar-panel {
  margin-top: auto;
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.055);
  backdrop-filter: blur(14px);
}

.sidebar-panel strong {
  display: block;
  font-size: 13px;
}

.sidebar-panel p {
  margin: 4px 0 0;
  color: #b8c2be;
  font-size: 11px;
}

.pulse {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 999px;
  background: #72d09d;
  box-shadow: 0 0 0 6px rgba(114, 208, 157, 0.14);
}

main {
  min-width: 0;
  width: min(100%, 1760px);
  margin: 0 auto;
  padding: 0 clamp(20px, 3.4vw, 54px) 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(238, 242, 241, 0.98), rgba(238, 242, 241, 0.78) 78%, transparent);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 34px;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 760;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(196, 209, 202, 0.8);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.global-search {
  width: 340px;
  position: relative;
}

.global-search > label {
  position: absolute;
  left: 12px;
  top: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.global-search input {
  height: 52px;
  padding: 20px 12px 7px;
  border-color: transparent;
  background: var(--surface-2);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fcfdfc;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 118px;
  resize: vertical;
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.72);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

.primary-action,
.text-button,
.icon-button {
  min-height: 40px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 900;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-action {
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.primary-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.26);
}

.primary-action span,
.text-button span {
  font-weight: 900;
}

.text-button,
.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.text-button:hover,
.icon-button:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.text-button {
  padding: 0 13px;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-enter 0.18s ease-out;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.portal-grid,
.workspace-row,
.ticket-layout,
.asset-layout,
.licenses-layout,
.contracts-layout,
.automation-layout,
.communication-layout,
.admin-layout,
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 20px;
}

.agent-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(0, 1.28fr);
  gap: 20px;
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail {
  border: 1px solid rgba(196, 209, 202, 0.78);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail {
  padding: 22px;
}

.section-title,
.queue-toolbar,
.detail-top,
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-title h2,
.page-heading h2 {
  margin: 3px 0 0;
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: 0;
  font-weight: 760;
}

.compact-badge,
.status-badge,
.priority-badge,
.sla-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.service-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.service-card {
  position: relative;
  min-height: 142px;
  padding: 17px;
  display: grid;
  align-content: start;
  gap: 11px;
  overflow: hidden;
  border: 1px solid rgba(196, 209, 202, 0.9);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7faf8);
  color: inherit;
  text-align: left;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.service-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--blue), var(--violet));
  opacity: 0;
  transition: opacity 0.16s ease;
}

.service-card:hover {
  border-color: var(--brand);
  box-shadow: 0 16px 34px rgba(21, 36, 31, 0.12);
  transform: translateY(-2px);
}

.service-card:hover::after {
  opacity: 1;
}

.service-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-soft), var(--blue-soft));
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.service-card strong {
  display: block;
  font-size: 15px;
}

.service-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.quick-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.score-card {
  position: relative;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff, #f4faf7);
}

.score-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
}

.score-card.warn::before {
  background: var(--amber);
}

.score-card span,
.score-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.score-card span {
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.score-card strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--brand);
  font-size: 34px;
  line-height: 1;
}

.score-card.warn strong {
  color: var(--amber);
}

.shortcut-stack {
  display: grid;
  gap: 8px;
}

.shortcut-stack a,
.shortcut-stack button {
  height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.shortcut-stack a:hover,
.shortcut-stack button:hover {
  border-color: var(--brand);
  background: #ffffff;
  transform: translateX(2px);
}

.workspace-row {
  margin-top: 18px;
}

.wide-card {
  min-width: 0;
}

.article-strip,
.focus-list,
.suggestion-stack,
.license-stack,
.schedule-list,
.settings-stack {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.article-strip {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.article-card,
.focus-item,
.suggestion,
.license-card,
.license-row,
.license-user-card,
.license-contract-card,
.license-action-card,
.template-card,
.notification-log-card,
.smtp-card,
.schedule-card,
.setting-card,
.config-card,
.rule-card,
.asset-row,
.ticket-row {
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.article-card {
  min-height: 132px;
  padding: 14px;
  display: grid;
  gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.article-card:hover,
.suggestion:hover,
.focus-item:hover,
.ticket-row:hover {
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.article-card strong {
  font-size: 13px;
}

.article-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
}

.focus-item,
.suggestion,
.license-card,
.license-row,
.license-user-card,
.license-contract-card,
.license-action-card,
.template-card,
.notification-log-card,
.smtp-card,
.schedule-card,
.setting-card,
.config-card {
  padding: 12px;
}

.focus-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  color: inherit;
  text-align: left;
}

.focus-item strong,
.suggestion strong,
.schedule-card strong,
.setting-card strong,
.config-card strong {
  display: block;
  font-size: 12px;
}

.focus-item span,
.suggestion span,
.schedule-card span,
.setting-card span,
.config-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.ticket-form {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.ticket-form-status {
  display: flex;
  justify-content: flex-end;
}

.ticket-form label > span,
.field-block > span {
  display: block;
  margin-bottom: 7px;
  color: #48534d;
  font-size: 11px;
  font-weight: 900;
}

.ticket-form label > span b,
.field-block > span b {
  color: #b42318;
}

.span-2,
.dynamic-fields {
  grid-column: 1 / -1;
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dynamic-request-type {
  grid-column: auto;
  grid-template-columns: minmax(0, 1fr);
}

.field-block.full {
  grid-column: 1 / -1;
}

.field-block b {
  color: var(--red);
}

.field-helper {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.ticket-request-type-readonly {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.employee-ticket-modal {
  width: min(640px, calc(100vw - 32px));
}

.employee-ticket-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}

.employee-ticket-summary div,
.employee-ticket-description,
.employee-ticket-updates li {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.employee-ticket-summary div {
  padding: 10px;
}

.employee-ticket-summary dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.employee-ticket-summary dd {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 800;
}

.employee-ticket-description {
  padding: 12px;
  margin-bottom: 18px;
}

.employee-ticket-description h3,
.employee-ticket-modal section h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.employee-ticket-description p {
  margin: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.ticket-rich-email-description {
  color: var(--muted);
  line-height: 1.45;
  max-block-size: 14rem;
  overflow: auto;
  overflow-wrap: anywhere;
}

.ticket-rich-email-description > :first-child {
  margin-top: 0;
}

.ticket-rich-email-description > :last-child {
  margin-bottom: 0;
}

.ticket-rich-email-description p,
.ticket-rich-email-description ul,
.ticket-rich-email-description ol,
.ticket-rich-email-description blockquote,
.ticket-rich-email-description pre,
.ticket-rich-email-description table {
  margin: 0 0 10px;
}

.ticket-rich-email-description ul,
.ticket-rich-email-description ol {
  padding-left: 20px;
}

.ticket-rich-email-description blockquote {
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

.ticket-rich-email-description pre {
  overflow: auto;
  white-space: pre-wrap;
}

.ticket-rich-email-description table {
  max-width: 100%;
  border-collapse: collapse;
}

.ticket-rich-email-description td,
.ticket-rich-email-description th {
  padding: 3px 6px;
  border: 1px solid var(--line);
  text-align: left;
}

.ticket-rich-email-description img {
  display: block;
  max-width: 100%;
  height: auto;
}

.ticket-rich-email-description a {
  color: var(--brand);
  text-decoration: underline;
}

.ticket-original-email-action {
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ticket-original-email-action:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.original-email-modal {
  width: min(960px, calc(100vw - 48px));
}

.original-email-content {
  padding: 0;
  overflow: hidden;
  background: #fff;
}

.original-email-preview-frame {
  display: block;
  width: 100%;
  height: min(70vh, 720px);
  min-height: 360px;
  border: 0;
  background: #fff;
}

.original-email-attachments {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.original-email-attachments h3 {
  margin: 0;
  font-size: 14px;
}

.original-email-attachment-list {
  display: grid;
  gap: 6px;
}

.employee-ticket-updates {
  display: grid;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.employee-ticket-updates li {
  padding: 10px 12px;
}

.employee-ticket-updates strong,
.employee-ticket-updates span {
  display: block;
}

.employee-ticket-updates span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.policy-box {
  margin-top: 16px;
  padding: 14px;
  display: grid;
  gap: 5px;
  border-left: 3px solid var(--brand);
  background: linear-gradient(135deg, var(--brand-soft), rgba(226, 237, 249, 0.65));
  border-radius: var(--radius);
}

.policy-box strong,
.policy-box span {
  font-size: 12px;
}

.queue-panel {
  min-height: 650px;
  align-self: start;
}

.queue-toolbar {
  align-items: center;
  margin-bottom: 14px;
}

.queue-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.queue-refresh-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}

.queue-refresh-icon {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

.queue-refresh-button.is-loading .queue-refresh-icon {
  opacity: 0.58;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(238, 244, 241, 0.9);
}

.segmented button {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.segmented button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 8px rgba(32, 36, 34, 0.08);
}

.queue-toolbar select {
  width: 160px;
  height: 38px;
}

.ticket-list {
  display: grid;
  gap: 8px;
}

.ticket-row {
  width: 100%;
  padding: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  color: inherit;
  text-align: left;
}

.ticket-row.active {
  border-color: var(--brand);
  background: linear-gradient(135deg, #f0fbf7, #f5f9ff);
  box-shadow: inset 3px 0 0 var(--brand);
}

.ticket-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.ticket-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.status-badge.new,
.ticket-status.tone-new {
  background: var(--red-soft);
  color: var(--red);
}

.status-badge.open,
.ticket-status.tone-open {
  background: var(--blue-soft);
  color: var(--blue);
}

.status-badge.waiting,
.ticket-status.tone-waiting {
  background: var(--violet-soft);
  color: var(--violet);
}

.status-badge.pending,
.ticket-status.tone-pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.resolved,
.status-badge.completed,
.ticket-status.tone-resolved,
.ticket-status.tone-completed {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.closed,
.ticket-status.tone-closed {
  background: var(--surface-3);
  color: var(--muted);
}

.muted-note {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.priority-badge.high,
.priority-badge.urgent {
  background: var(--red-soft);
  color: var(--red);
}

.priority-badge.medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.sla-badge.risk {
  background: var(--red-soft);
  color: var(--red);
}

.ticket-detail {
  min-height: 650px;
  align-self: start;
}

.empty-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state.compact {
  min-height: 92px;
  padding: 16px;
  font-size: 12px;
}

.detail-top h2 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.16;
}

.detail-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.detail-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.detail-stat {
  padding: 12px;
  border: 1px solid rgba(196, 209, 202, 0.82);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  min-width: 0;
}

.detail-stat span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.detail-columns {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.activity-card,
.side-card {
  padding: 14px;
  border: 1px solid rgba(196, 209, 202, 0.82);
  border-radius: var(--radius);
  background: rgba(247, 249, 248, 0.82);
}

.activity-card h3,
.side-card h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.timeline {
  display: grid;
  gap: 1px;
}

.timeline-item {
  position: relative;
  padding: 7px 0 7px 18px;
  border-left: 1px solid var(--line-strong);
  margin-left: 4px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid var(--surface-2);
}

.timeline-item strong,
.task-row strong {
  display: block;
  font-size: 12px;
}

.timeline-item span,
.task-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.task-list {
  display: grid;
  gap: 7px;
}

.task-row {
  padding: 9px;
  border-radius: var(--radius);
  background: var(--surface);
}

.task-row.done strong {
  color: var(--green);
}

.reply-box {
  margin-top: 14px;
}

.reply-box textarea {
  min-height: 88px;
}

.reply-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.knowledge-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
}

.kb-filters,
.kb-results {
  padding: 18px;
  border: 1px solid rgba(196, 209, 202, 0.78);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.kb-filters {
  display: grid;
  align-content: start;
  gap: 8px;
}

.kb-filters button {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-align: left;
}

.kb-filters button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.kb-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kb-results .article-card {
  min-height: 170px;
}

.article-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.article-actions button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 900;
}

.asset-metrics,
.asset-table,
.license-metrics,
.license-table,
.contract-table,
.notification-stack,
.license-contract-grid,
.license-action-list,
.notification-log,
.template-list,
.agreement-grid,
.exposure-stack,
.dependency-map,
.lifecycle-list,
.rule-list,
.config-grid,
.dashboard-grid {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.asset-metrics,
.license-metrics {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.metric-card,
.exposure-card {
  padding: 13px;
  border: 1px solid rgba(196, 209, 202, 0.8);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(247, 249, 248, 0.84));
}

.metric-card span,
.exposure-card span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong,
.exposure-card strong {
  display: block;
  margin-top: 6px;
  color: var(--brand);
  font-size: 22px;
  line-height: 1;
}

.metric-card small,
.exposure-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.asset-row {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 0.9fr 0.9fr 0.8fr minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
}

.asset-row.header {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.asset-row strong,
.asset-row span,
.license-row strong,
.license-row span,
.contract-row strong,
.contract-row span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
}

.inline-link {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-weight: 900;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}

.inline-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.profile-modal {
  width: min(1080px, calc(100vw - 28px));
}

.profile-body {
  display: grid;
  gap: 16px;
}

.profile-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.profile-summary-grid article,
.profile-row {
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
}

.profile-summary-grid article {
  padding: 12px;
}

.profile-summary-grid span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-summary-grid strong {
  display: block;
  margin-top: 6px;
  color: var(--brand);
  font-size: 22px;
}

.profile-summary-grid .access-summary-card strong {
  margin-top: 7px;
}

.profile-summary-grid small,
.profile-row small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.profile-actions-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 2px;
}

.profile-section {
  display: grid;
  gap: 10px;
}

.profile-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.profile-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.profile-section-head small {
  color: var(--muted);
  font-weight: 750;
}

.profile-list {
  display: grid;
  gap: 8px;
}

.profile-row {
  width: 100%;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  color: inherit;
  text-align: left;
}

.profile-row.as-button:hover,
.profile-row:hover {
  border-color: rgba(37, 99, 235, 0.34);
  box-shadow: var(--shadow-soft);
}

.profile-row strong,
.profile-row span,
.profile-row small {
  display: block;
}

.profile-record-link {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-record-link:hover strong {
  color: var(--brand);
}

.profile-record-link:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
  border-radius: 4px;
}

.profile-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.asset-row span,
.license-row span,
.contract-row span {
  display: grid;
  gap: 3px;
  color: var(--muted);
}

.asset-row strong small,
.asset-row span small,
.license-row strong small,
.license-row span small,
.contract-row strong small,
.contract-row span small,
.license-card small {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-row .contract-service-summary small {
  white-space: normal;
  overflow: visible;
}

.status-badge.risk {
  background: var(--red-soft);
  color: var(--red);
}

.status-badge.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.contract-row {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 0.75fr 0.75fr 0.62fr 78px;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.contract-row.header {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.license-row {
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(150px, 0.95fr) minmax(0, 1.1fr) 0.8fr 0.72fr minmax(168px, 0.8fr);
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.license-row.header {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.license-row.active {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: inset 3px 0 0 var(--brand);
}

.usage-meter {
  width: 100%;
  height: 7px;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece8;
}

.usage-meter em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--blue));
}

.notification-card,
.dependency-node,
.lifecycle-card,
.agreement-card,
.license-user-card,
.license-contract-card,
.license-action-card,
.template-card,
.notification-log-card,
.smtp-card {
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.notification-card {
  width: 100%;
  padding: 12px;
  display: grid;
  gap: 6px;
  color: inherit;
  text-align: left;
}

.notification-card:hover,
.contract-row:hover,
.license-row:hover,
.dependency-node:hover,
.lifecycle-card:hover,
.agreement-card:hover,
.license-action-card:hover,
.template-card:hover {
  border-color: rgba(15, 118, 110, 0.48);
  box-shadow: var(--shadow-soft);
}

.notification-card strong,
.dependency-node strong,
.lifecycle-card strong,
.agreement-card strong,
.license-user-card strong,
.license-contract-card strong,
.license-action-card strong,
.template-card strong,
.notification-log-card strong,
.smtp-card strong {
  display: block;
  font-size: 12px;
}

.notification-card span,
.notification-card small,
.dependency-node span,
.dependency-node small,
.lifecycle-card span,
.lifecycle-card small,
.agreement-card p,
.agreement-card small,
.agreement-card dd,
.license-user-card span,
.license-user-card small,
.license-contract-card span,
.license-contract-card dd,
.license-action-card span,
.license-action-card small,
.template-card span,
.template-card small,
.notification-log-card span,
.notification-log-card small,
.smtp-card span,
.smtp-card small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.dependency-map {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dependency-node,
.lifecycle-card {
  padding: 12px;
}

.dependency-node span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
}

.lifecycle-card {
  display: grid;
  gap: 5px;
}

.agreement-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.license-contract-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.license-user-panel,
.license-user-list,
.license-action-list,
.template-list,
.notification-log {
  display: grid;
  gap: 10px;
}

.selected-license-summary,
.smtp-card {
  padding: 12px;
  display: grid;
  gap: 5px;
}

.selected-license-summary {
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: var(--radius);
  background: var(--brand-soft);
}

.license-user-card,
.license-contract-card,
.license-action-card,
.template-card,
.notification-log-card {
  padding: 12px;
  display: grid;
  gap: 6px;
}

.license-action-card,
.license-card {
  width: 100%;
  color: inherit;
  text-align: left;
}

.license-contract-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.license-contract-card dt {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.license-contract-card dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.template-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.smtp-card.ready {
  border-color: rgba(16, 124, 65, 0.28);
  background: var(--green-soft);
}

.smtp-card.pending {
  border-color: rgba(220, 127, 44, 0.28);
  background: var(--amber-soft);
}

.agreement-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.agreement-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.agreement-card p {
  margin: 0;
}

.agreement-card dl {
  margin: 0;
  display: grid;
  gap: 8px;
}

.agreement-card dt {
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.agreement-card dd {
  margin: 3px 0 0;
}

.license-card {
  padding: 12px;
  display: grid;
  gap: 9px;
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.license-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.license-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ece8;
}

.license-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--blue));
}

.rule-card {
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.rule-card strong {
  display: block;
  font-size: 13px;
}

.rule-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.switch {
  width: 46px;
  height: 26px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: #cbd6ce;
}

.switch span {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: white;
  transition: transform 0.18s ease;
}

.switch.active {
  background: var(--brand);
}

.switch.active span {
  transform: translateX(20px);
}

.rule-output {
  margin-top: 14px;
  padding: 12px;
  min-height: 68px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 18px;
}

.dash-card {
  padding: 18px;
  border: 1px solid rgba(196, 209, 202, 0.78);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.dash-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dash-card strong {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 30px;
  line-height: 1;
}

.dash-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.dash-card.report-good strong {
  color: var(--green);
}

.report-library-card {
  margin-bottom: 18px;
}

.report-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.report-card {
  min-height: 188px;
  padding: 14px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid rgba(196, 209, 202, 0.84);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
}

.report-process {
  display: inline-block;
  max-width: 100%;
  color: var(--brand);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-card strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.report-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.report-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.report-card .primary-action {
  width: 100%;
  justify-content: center;
}

.trend-chart {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.trend-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 12px;
}

.trend-row strong,
.trend-row span {
  font-size: 12px;
}

.bar-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eee9;
}

.bar-track b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--blue));
}

.config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #15211d;
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    padding: 14px 4vw;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    overflow: hidden;
  }

  .primary-nav {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .portal-switch {
    min-width: 224px;
  }

  .nav-group {
    display: flex;
    gap: 6px;
  }

  .nav-link {
    width: auto;
    white-space: nowrap;
  }

  .sidebar-panel {
    display: none;
  }

  .portal-grid,
  .workspace-row,
  .ticket-layout,
  .asset-layout,
  .licenses-layout,
  .contracts-layout,
  .automation-layout,
  .communication-layout,
  .admin-layout,
  .settings-layout,
  .agent-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding-top: 0;
  }

  .topbar {
    top: 74px;
  }

  .detail-columns {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* User management workspace */
.users-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.user-mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.user-mode-switch button {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-weight: 750;
}

.user-mode-switch button.active {
  border-color: rgba(56, 189, 248, 0.42);
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.user-mode-switch span {
  color: var(--muted);
  font-size: 12px;
}

.user-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 9px;
  margin-bottom: 10px;
}

.user-table {
  display: grid;
  gap: 8px;
}

.user-row {
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 38px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  overflow: visible;
}

.user-row-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(128px, 0.7fr) minmax(150px, 0.8fr) minmax(108px, 0.6fr) minmax(150px, 0.8fr);
  gap: 10px;
  align-items: center;
}

.user-row-profile-trigger {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.user-quick-look-control {
  display: grid;
  place-items: center;
}

.user-quick-look-heading {
  text-align: center;
}

.user-quick-look-control input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
}

.user-quick-look-control input:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.6);
  outline-offset: 3px;
}

.user-row.header {
  min-height: 34px;
  padding-block: 6px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.user-row.active {
  border-color: rgba(15, 108, 189, 0.34);
  background: var(--brand-soft);
  box-shadow: inset 3px 0 0 var(--brand);
}

.user-row strong,
.user-row span {
  min-width: 0;
}

.user-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.user-detail-panel {
  position: sticky;
  top: 16px;
}

.userDetail,
.user-link-section {
  display: grid;
  gap: 9px;
}

.selected-user-summary,
.user-access-card,
.user-link-card {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.88);
}

.selected-user-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.user-profile-link-card {
  width: 100%;
  color: inherit;
  text-align: left;
}

.user-profile-link-card:hover {
  border-color: rgba(15, 108, 189, 0.32);
  background: var(--brand-soft);
}

.user-row:has(.user-row-profile-trigger:hover) {
  border-color: rgba(15, 108, 189, 0.28);
  background: rgba(232, 243, 255, 0.5);
}

.user-row-profile-trigger:focus-visible,
.user-profile-link-card:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.6);
  outline-offset: 3px;
  border-radius: 5px;
}

.selected-user-summary strong,
.user-access-card strong,
.user-link-card strong {
  display: block;
  font-size: 13px;
}

.selected-user-summary span,
.selected-user-summary small,
.user-access-card span,
.user-access-card small,
.user-link-card span,
.user-link-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.access-type-control {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.access-type-control span {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.access-type-control select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.access-type-control.compact {
  margin: 7px 0 0;
}

.user-link-actions {
  justify-content: start;
}

.user-link-section h3 {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.user-link-card {
  width: 100%;
  text-align: left;
  color: var(--ink);
}

.user-link-card:hover {
  border-color: rgba(15, 108, 189, 0.28);
  background: rgba(232, 243, 255, 0.72);
}

html[data-theme="dark"] .user-mode-switch button,
html[data-theme="dark"] .user-row,
html[data-theme="dark"] .selected-user-summary,
html[data-theme="dark"] .user-access-card,
html[data-theme="dark"] .user-link-card {
  background: rgba(17, 24, 39, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .user-mode-switch button.active,
html[data-theme="dark"] .user-row.active {
  background: rgba(56, 189, 248, 0.14);
}

@media (max-width: 1160px) {
  .users-layout {
    grid-template-columns: 1fr;
  }

  .user-detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .user-row.header {
    display: none;
  }
}

/* Ticket references stay readable in the composer while their safe link target is retained for submission. */
.ticket-composer-editor {
  display: block;
  width: 100%;
  min-height: 112px;
  overflow: auto;
  resize: vertical;
  padding: 12px 12px 38px;
  border: 1px solid #cfd7e3;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  cursor: text;
  font: inherit;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ticket-composer-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}

.ticket-composer-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
  outline: none;
}

.ticket-composer-editor [data-ticket-composer-link] {
  color: var(--brand-deep);
  font-weight: 750;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.reply-box .ticket-composer-editor {
  min-height: 112px;
}

.quick-ticket-update .ticket-composer-editor {
  min-height: 76px;
}

.agent-grid.ticket-detail-expanded .reply-box .ticket-composer-editor {
  min-height: 150px;
}

html[data-theme="dark"] .ticket-composer-editor {
  border-color: var(--line-strong);
  background: rgba(15, 23, 42, 0.84);
  color: var(--ink);
}

@media (max-width: 760px) {
  main {
    padding: 0 16px 44px;
  }

  .topbar {
    top: 126px;
    min-height: 150px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-top: 8px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .top-actions,
  .global-search {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 40px;
    padding: 8px;
  }

  .top-actions .primary-action {
    grid-column: 1 / -1;
  }

  .service-grid,
  .article-strip,
  .ticket-form,
  .dynamic-fields,
  .kb-results,
  .config-grid,
  .asset-metrics,
  .license-metrics,
  .dashboard-grid,
  .detail-grid,
  .detail-columns,
  .dependency-map,
  .license-contract-grid,
  .agreement-grid {
    grid-template-columns: 1fr;
  }

  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .asset-row,
  .license-row,
  .contract-row {
    grid-template-columns: 1fr 1fr;
  }

  .asset-row.header,
  .license-row.header,
  .contract-row.header {
    display: none;
  }

  .trend-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .sidebar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .primary-nav {
    width: 100%;
  }

  .portal-switch {
    width: 100%;
    min-width: 0;
  }

  .nav-group {
    width: 100%;
    overflow-x: auto;
  }

  .brand {
    width: 100%;
  }

  .nav-link {
    height: 38px;
    padding: 0 10px;
  }

  .service-panel,
  .quick-panel,
  .work-card,
  .queue-panel,
  .ticket-detail,
  .kb-filters,
  .kb-results {
    padding: 16px;
  }

  .section-title,
  .detail-top,
  .queue-toolbar,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .queue-toolbar select {
    width: 100%;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .segmented button {
    padding: 0 6px;
  }

  .detail-actions,
  .form-actions {
    justify-content: stretch;
  }

  .detail-actions > *,
  .form-actions > * {
    flex: 1 1 0;
  }

  .reply-actions > * {
    flex: 1 1 140px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
}

@media (min-width: 1440px) {
  .service-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .article-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .agent-grid {
    grid-template-columns: minmax(420px, 0.68fr) minmax(0, 1.32fr);
  }
}

@media (max-width: 520px) {
  main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar {
    min-height: 164px;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .detail-grid,
  .asset-row,
  .license-row,
  .contract-row {
    grid-template-columns: 1fr;
  }

  .asset-row,
  .license-row,
  .contract-row {
    gap: 6px;
  }

  .asset-row .text-button,
  .license-row .text-button,
  .contract-row .text-button {
    width: 100%;
  }

  .compact-badge,
  .status-badge,
  .priority-badge,
  .sla-badge {
    white-space: normal;
    text-align: center;
  }
}

/* Windows-inspired visual refresh */
:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef4fb;
  --ink: #1f2328;
  --muted: #5f6876;
  --muted-2: #8a94a3;
  --line: #e1e6ef;
  --line-strong: #cbd4e1;
  --brand: #2563eb;
  --brand-2: #0f6cbd;
  --brand-deep: #123a7a;
  --brand-soft: #eaf2ff;
  --blue: #0f6cbd;
  --blue-soft: #e7f1ff;
  --amber: #9a6700;
  --amber-soft: #fff4ce;
  --red: #c42b1c;
  --red-soft: #fde7e9;
  --green: #107c41;
  --green-soft: #e7f6ed;
  --violet: #5b5fc7;
  --violet-soft: #efeffd;
  --shadow: 0 18px 42px rgba(31, 35, 40, 0.08);
  --shadow-soft: 0 8px 20px rgba(31, 35, 40, 0.06);
  --radius: 8px;
  --sidebar: rgba(255, 255, 255, 0.76);
  --sidebar-2: rgba(246, 249, 253, 0.86);
  --sidebar-line: rgba(31, 35, 40, 0.09);
}

html[data-contrast="high"] {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --ink: #111827;
  --muted: #374151;
  --line: #9ca3af;
  --brand: #004e8c;
  --brand-soft: #e5f1fb;
}

body {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(238, 244, 252, 0.86) 45%, rgba(244, 246, 251, 0.94) 100%),
    linear-gradient(90deg, rgba(37, 99, 235, 0.08), rgba(16, 124, 65, 0.04) 48%, rgba(91, 95, 199, 0.05)),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.app-shell {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  padding: 16px 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 249, 253, 0.78)),
    var(--sidebar);
  color: var(--ink);
  border-right: 1px solid var(--sidebar-line);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.7) inset;
  backdrop-filter: blur(24px) saturate(145%);
}

.brand {
  min-height: 48px;
  padding: 8px;
  color: var(--ink);
}

.brand:hover {
  background: rgba(37, 99, 235, 0.06);
}

.brand b {
  font-size: 17px;
  font-weight: 650;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  padding: 4px;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 35, 40, 0.1), inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.brand-mark::after,
.brand-mark span {
  height: auto !important;
  align-self: stretch;
  border-radius: 3px;
  background: #2563eb;
}

.brand-mark::after {
  content: "";
  display: block;
  background: #7c3aed;
}

.brand-mark span:nth-child(1) {
  background: #0f6cbd;
}

.brand-mark span:nth-child(2) {
  background: #107c41;
}

.brand-mark span:nth-child(3) {
  background: #d83b01;
}

.primary-nav {
  margin-top: 22px;
}

.portal-switch {
  gap: 2px;
  padding: 3px;
  border-color: rgba(31, 35, 40, 0.08);
  background: rgba(237, 241, 247, 0.86);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.88) inset;
}

.portal-switch button {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.portal-switch button.active {
  background: #ffffff;
  color: var(--brand-deep);
  box-shadow: 0 5px 14px rgba(31, 35, 40, 0.08), 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.nav-link {
  height: 38px;
  padding: 0 10px;
  color: #3f4754;
  font-size: 13px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(37, 99, 235, 0.08);
  color: #0f172a;
  border-color: rgba(37, 99, 235, 0.1);
  transform: none;
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.nav-ico {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(15, 108, 189, 0.08);
  color: var(--brand);
  font-size: 14px;
  font-weight: 400;
  flex: 0 0 auto;
}

.nav-link.active .nav-ico {
  background: var(--brand);
  color: #ffffff;
}

.nav-ico::before,
.service-icon::before {
  font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets", "Segoe UI Symbol", sans-serif;
  line-height: 1;
}

.ico-home::before {
  content: "\E80F";
}

.ico-add::before {
  content: "\E710";
}

.ico-book::before {
  content: "\E82D";
}

.ico-queue::before {
  content: "\E8FD";
}

.ico-users::before {
  content: "\E716";
}

.ico-device::before {
  content: "\E772";
}

/* Stock keeps consumable quantities, ready equipment, invoice evidence, and allocation spend in one compact workspace. */
.stock-workspace-card {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.stock-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.stock-tabs button {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stock-tabs button:hover,
.stock-tabs button:focus-visible {
  border-color: var(--brand);
  color: var(--brand);
}

.stock-tabs button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.stock-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.stock-metric {
  min-height: 86px;
  padding: 10px;
}

.stock-metric.risk {
  border-color: #f0c987;
  background: #fffbeb;
}

.stock-content {
  min-width: 0;
}

.stock-content > .list-controls {
  margin: 0 0 8px;
}

.stock-table {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stock-table-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(90px, 0.8fr) minmax(102px, 0.8fr) minmax(120px, 0.95fr) minmax(120px, 1fr) minmax(138px, auto);
  align-items: center;
  gap: 10px;
  min-width: 840px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.stock-table-row:first-child {
  border-top: 0;
}

.stock-table-header {
  min-height: 34px;
  padding-top: 7px;
  padding-bottom: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.stock-table-row > span,
.stock-item-link {
  min-width: 0;
}

.stock-table-row strong,
.stock-table-row small {
  display: block;
}

.stock-table-row strong {
  color: var(--ink);
  font-size: 12px;
}

.stock-table-row small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-item-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.stock-item-link:hover strong,
.stock-item-link:focus-visible strong {
  color: var(--brand);
  text-decoration: underline;
}

.stock-quantity {
  display: inline-flex;
  min-width: 30px;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
}

.stock-quantity.low {
  background: var(--amber-soft);
  color: var(--amber);
}

.stock-quantity.empty {
  background: var(--red-soft);
  color: var(--red);
}

.stock-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.compact-action {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
}

.compact-action:hover,
.compact-action:focus-visible {
  border-color: var(--brand);
  color: var(--brand);
}

.compact-action.is-unavailable {
  border-style: dashed;
  color: var(--muted);
}

.stock-row-menu summary {
  width: 30px;
  min-width: 30px;
  height: 30px;
}

.stock-spend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stock-spend-section {
  min-width: 0;
}

.stock-spend-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.stock-spend-table .stock-table-row {
  grid-template-columns: minmax(160px, 1.5fr) minmax(92px, 0.8fr) minmax(92px, 0.8fr) minmax(86px, 0.72fr);
  min-width: 540px;
}

.stock-spend-table.has-assets .stock-table-row {
  grid-template-columns: minmax(150px, 1.4fr) minmax(82px, 0.8fr) minmax(82px, 0.8fr) minmax(82px, 0.8fr) minmax(80px, 0.65fr);
  min-width: 620px;
}

.invoice-detail-modal {
  width: min(820px, calc(100vw - 32px));
}

.invoice-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.invoice-summary div {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.invoice-summary dt {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.invoice-summary dd {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.invoice-activity {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.invoice-activity-section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.invoice-activity-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
}

.invoice-activity-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.invoice-activity-heading h3 {
  margin: 0;
}

.invoice-activity-heading .text-button {
  flex: 0 0 auto;
}

.invoice-activity-section p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.invoice-activity-row {
  display: grid;
  gap: 3px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.invoice-activity-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.invoice-activity-row span {
  color: var(--muted);
  font-size: 10px;
}

.invoice-file-row {
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
}

.invoice-file-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.invoice-file-remove {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 14px;
}

@media (max-width: 1220px) {
  .stock-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stock-spend-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .stock-workspace-card .section-title {
    align-items: flex-start;
  }

  .stock-workspace-card .section-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stock-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-summary,
  .invoice-activity {
    grid-template-columns: minmax(0, 1fr);
  }

  .stock-receipt-context,
  .stock-receipt-line {
    grid-template-columns: minmax(0, 1fr);
  }

  .stock-receipt-remove,
  .stock-receipt-spacer {
    justify-self: end;
  }
}

@media (max-width: 520px) {
  .stock-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .stock-workspace-card .section-actions .primary-action,
  .stock-workspace-card .section-actions .text-button {
    flex: 1 1 auto;
  }
}

.ico-stock::before {
  content: "\E719";
}

.ico-license::before {
  content: "\E8D4";
}

.ico-document::before {
  content: "\E8A5";
}

.ico-flow::before {
  content: "\E895";
}

.ico-chart::before {
  content: "\E9D2";
}

.ico-settings::before {
  content: "\E713";
}

.sidebar-panel {
  padding: 12px;
  border-color: rgba(31, 35, 40, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.sidebar-panel p {
  color: var(--muted);
}

.pulse {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(16, 124, 65, 0.14);
}

main {
  width: min(100%, 1680px);
  padding: 0 clamp(18px, 2.8vw, 42px) 54px;
}

.topbar {
  min-height: 92px;
  padding: 12px 0;
  background: linear-gradient(180deg, rgba(243, 246, 251, 0.96), rgba(243, 246, 251, 0.82) 74%, rgba(243, 246, 251, 0));
  backdrop-filter: blur(22px) saturate(140%);
}

.topbar h1 {
  margin-top: 2px;
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 650;
}

.eyebrow {
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
}

.top-actions {
  min-height: 58px;
  padding: 7px;
  border-color: rgba(31, 35, 40, 0.08);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(31, 35, 40, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(22px) saturate(140%);
}

.global-search {
  width: min(36vw, 420px);
}

.global-search span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.global-search input {
  height: 44px;
  padding: 16px 13px 5px;
  border: 1px solid transparent;
  background: rgba(246, 248, 252, 0.95);
}

.contrast-button span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(90deg, #1f2328 0 50%, #ffffff 50% 100%);
  box-shadow: 0 0 0 1px rgba(31, 35, 40, 0.2);
}

input,
select,
textarea {
  border-color: #cfd7e3;
  background: #ffffff;
}

input,
select {
  height: 42px;
}

textarea {
  min-height: 112px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.primary-action,
.text-button,
.icon-button {
  min-height: 38px;
  font-size: 12px;
  font-weight: 650;
}

.primary-action {
  border: 1px solid rgba(15, 108, 189, 0.25);
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.primary-action:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.24);
}

.text-button,
.icon-button {
  border-color: rgba(31, 35, 40, 0.12);
  background: rgba(255, 255, 255, 0.86);
  color: #273243;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.text-button:hover,
.icon-button:hover {
  border-color: rgba(37, 99, 235, 0.38);
  background: #ffffff;
  transform: translateY(-1px);
}

.portal-grid,
.workspace-row,
.ticket-layout,
.asset-layout,
.licenses-layout,
.contracts-layout,
.automation-layout,
.communication-layout,
.admin-layout,
.settings-layout,
.agent-grid {
  gap: 16px;
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.kb-filters,
.kb-results {
  border: 1px solid rgba(31, 35, 40, 0.09);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(135%);
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail {
  padding: 20px;
}

.section-title h2,
.page-heading h2 {
  font-size: 21px;
  font-weight: 650;
}

.compact-badge,
.status-badge,
.priority-badge,
.sla-badge {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.service-grid {
  gap: 12px;
}

.service-card {
  min-height: 136px;
  padding: 16px;
  gap: 10px;
  border-color: rgba(31, 35, 40, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 252, 255, 0.9)),
    var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.service-card::after {
  top: 0;
  right: auto;
  bottom: 0;
  width: 3px;
  height: auto;
  background: var(--brand);
  opacity: 0;
}

.service-card:hover {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: 0 14px 28px rgba(31, 35, 40, 0.1);
  transform: translateY(-1px);
}

.service-card:nth-child(2n)::after {
  background: #107c41;
}

.service-card:nth-child(3n)::after {
  background: #d83b01;
}

.service-card:nth-child(4n)::after {
  background: #5b5fc7;
}

.service-icon {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.1);
  font-size: 17px;
}

.service-icon-general::before {
  content: "\E897";
}

.service-icon-incident::before {
  content: "\E7BA";
}

.service-icon-new-starter::before {
  content: "\E77B";
}

.service-icon-leaver::before {
  content: "\E8AC";
}

.service-icon-hardware::before {
  content: "\E772";
}

.service-icon-business-central::before {
  content: "\E8A5";
}

.service-icon-security::before {
  content: "\E72E";
}

.service-icon-access::before {
  content: "\E8D7";
}

.service-icon-software::before {
  content: "\ECAA";
}

.service-icon-network::before {
  content: "\E968";
}

.service-icon-printing::before {
  content: "\E749";
}

.service-card strong {
  font-size: 14px;
  font-weight: 650;
}

.service-card small {
  color: var(--muted);
  font-size: 12px;
}

.score-card {
  border-color: rgba(31, 35, 40, 0.09);
  background: #ffffff;
}

.score-card::before {
  width: 3px;
  background: var(--brand);
}

.score-card strong {
  color: var(--brand);
  font-size: 32px;
  font-weight: 650;
}

.score-card span {
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.shortcut-stack a,
.shortcut-stack button {
  border-color: rgba(31, 35, 40, 0.09);
  background: #ffffff;
  font-weight: 650;
}

.shortcut-stack a:hover,
.shortcut-stack button:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--brand-soft);
  transform: none;
}

.article-card,
.focus-item,
.suggestion,
.license-card,
.schedule-card,
.setting-card,
.config-card,
.rule-card,
.asset-row,
.ticket-row,
.contract-row,
.notification-card,
.dependency-node,
.lifecycle-card,
.agreement-card,
.metric-card,
.exposure-card,
.detail-stat,
.activity-card,
.side-card {
  border-color: rgba(31, 35, 40, 0.09);
  background: rgba(255, 255, 255, 0.9);
}

.article-card:hover,
.suggestion:hover,
.focus-item:hover,
.ticket-row:hover,
.notification-card:hover,
.contract-row:hover,
.license-row:hover,
.dependency-node:hover,
.lifecycle-card:hover,
.agreement-card:hover,
.license-action-card:hover,
.template-card:hover {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.article-card strong,
.focus-item strong,
.suggestion strong,
.schedule-card strong,
.setting-card strong,
.config-card strong,
.rule-card strong,
.notification-card strong,
.dependency-node strong,
.lifecycle-card strong,
.agreement-card strong,
.license-user-card strong,
.license-contract-card strong,
.license-action-card strong,
.template-card strong,
.notification-log-card strong,
.smtp-card strong {
  font-weight: 650;
}

.ticket-form label > span,
.field-block > span {
  color: #344054;
  font-weight: 650;
}

.policy-box {
  border-left-color: var(--brand);
  background: linear-gradient(135deg, var(--brand-soft), rgba(255, 255, 255, 0.86));
}

.segmented {
  border-color: rgba(31, 35, 40, 0.09);
  background: rgba(237, 241, 247, 0.86);
}

.segmented button {
  font-weight: 650;
  min-width: 0;
  white-space: nowrap;
}

.segmented button.active {
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
}

.ticket-row.active {
  border-color: rgba(37, 99, 235, 0.42);
  background: linear-gradient(90deg, rgba(234, 242, 255, 0.95), rgba(255, 255, 255, 0.95));
  box-shadow: inset 3px 0 0 var(--brand);
}

.timeline-item::before {
  background: var(--brand);
  border-color: #ffffff;
}

.kb-filters button {
  border-color: rgba(31, 35, 40, 0.09);
  background: #ffffff;
  font-weight: 650;
}

.kb-filters button.active {
  border-color: rgba(37, 99, 235, 0.32);
  background: var(--brand-soft);
  color: var(--brand);
}

.metric-card,
.exposure-card {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.metric-card strong,
.exposure-card strong,
.dash-card strong {
  color: var(--brand);
  font-weight: 650;
}

.asset-row.header,
.license-row.header,
.contract-row.header {
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.dependency-node span {
  background: var(--brand-soft);
  color: var(--brand);
}

.license-meter,
.usage-meter {
  background: #edf2f7;
}

.license-meter span,
.usage-meter em,
.bar-track b {
  background: linear-gradient(90deg, var(--brand), #0f6cbd);
}

.dash-card {
  border-color: rgba(31, 35, 40, 0.09);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.dash-card span {
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.toast {
  border-color: rgba(31, 35, 40, 0.14);
  background: rgba(32, 36, 43, 0.94);
  box-shadow: 0 18px 40px rgba(31, 35, 40, 0.24);
  font-weight: 650;
  backdrop-filter: blur(18px);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 12px 4vw;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-line);
  }

  .nav-link.active {
    box-shadow: inset 0 -3px 0 var(--brand);
  }

  .topbar {
    top: 72px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 0 14px 44px;
  }

  .primary-nav {
    display: grid;
    overflow: visible;
  }

  .nav-group {
    display: grid;
    overflow: visible;
  }

  .user-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .agent-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-link {
    justify-content: center;
    gap: 7px;
    padding: 0 6px;
    font-size: 12px;
  }

  .topbar {
    top: 128px;
    min-height: 142px;
  }

  .top-actions {
    min-height: 0;
  }

  .global-search {
    width: 100%;
  }

  .service-panel,
  .quick-panel,
  .work-card,
  .queue-panel,
  .ticket-detail,
  .kb-filters,
  .kb-results {
    padding: 14px;
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 156px;
  }

  .brand b {
    font-size: 16px;
  }

  .service-card {
    min-height: 124px;
  }

  .nav-link {
    gap: 5px;
    font-size: 11px;
  }

  .nav-ico {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }
}

@media (max-width: 760px) {
  .top-actions {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
  }

  .top-actions .global-search {
    grid-column: 1 / -1;
  }

  .top-actions .primary-action {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
  }

  .top-actions .icon-button {
    grid-column: 2;
    grid-row: 2;
    width: 42px;
    min-width: 42px;
    height: 38px;
  }
}

.focus-item {
  align-items: center;
  min-width: 0;
}

.focus-copy {
  display: grid !important;
  gap: 4px;
  min-width: 0;
  margin-top: 0 !important;
}

.focus-copy strong {
  min-width: 0;
  line-height: 1.28;
}

.focus-copy .focus-meta {
  margin-top: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.focus-item > .sla-badge {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 28px;
  margin-top: 0;
  padding: 0 10px;
  border-radius: 999px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .focus-item {
    gap: 10px;
  }

  .focus-item > .sla-badge {
    min-width: 58px;
    min-height: 26px;
    padding: 0 8px;
    font-size: 9px;
    white-space: nowrap;
  }
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.modal-root:empty {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: block;
  background: rgba(15, 23, 42, 0.34);
  backdrop-filter: blur(10px);
}

.modal-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-layer:not(:last-child) {
  pointer-events: none;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  border: 1px solid rgba(31, 35, 40, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(31, 35, 40, 0.28);
}

.modal-root > .modal-layer > .modal-panel {
  position: relative;
  z-index: 1;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(31, 35, 40, 0.08);
}

.modal-head > div {
  min-width: 0;
}

.modal-head h2 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.16;
  overflow-wrap: anywhere;
}

.modal-head .icon-button {
  flex: 0 0 42px;
  width: 42px;
}

.modal-body {
  padding: 16px;
}

.modal-actions {
  justify-content: flex-end;
  position: sticky;
  z-index: 2;
  bottom: 0;
  border-top: 1px solid rgba(31, 35, 40, 0.08);
  border-bottom: 0;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 16px rgba(15, 23, 42, 0.05);
}

.modal-head > .modal-workspace-toggle,
.modal-head > [data-modal-close].icon-button {
  flex: 0 0 32px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
}

html[data-theme="dark"] .modal-actions {
  background: rgba(17, 24, 39, 0.98);
  box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.16);
}

.modal-actions .primary-action,
.modal-actions .text-button {
  flex: 0 1 auto;
  min-width: 0;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.modal-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.toggle-field {
  display: flex !important;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.8);
}

.toggle-field input {
  appearance: none;
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  border: 1px solid rgba(100, 116, 139, 0.42);
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-field input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.22);
  transition: transform 160ms ease;
}

.toggle-field input:checked {
  border-color: var(--brand);
  background: var(--brand);
}

.toggle-field input:checked::before {
  transform: translateX(18px);
}

.toggle-field input:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.32);
  outline-offset: 2px;
}

.toggle-field > span {
  display: grid;
  gap: 2px;
}

.toggle-field strong {
  color: var(--ink);
  font-size: 13px;
}

.toggle-field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.confirmation-checkbox {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--ink);
  cursor: pointer;
}

.confirmation-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.confirmation-checkbox span {
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.confirmation-checkbox input:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.32);
  outline-offset: 2px;
}

.modal-form label.full,
.modal-form .full {
  grid-column: 1 / -1;
}

.opening-balance-modal {
  width: min(1120px, 100%);
}

.opening-balance-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.opening-balance-count {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.opening-balance-table-wrap {
  max-height: min(48vh, 460px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.opening-balance-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
}

.opening-balance-table th,
.opening-balance-table td {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.opening-balance-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.opening-balance-table td:first-child {
  min-width: 230px;
}

.opening-balance-table strong,
.opening-balance-table small {
  display: block;
}

.opening-balance-table small {
  margin-top: 2px;
  color: var(--muted);
}

.opening-balance-table :is(input[type="text"], input[type="number"]) {
  width: 100%;
  min-width: 88px;
  height: var(--field-compact-height);
  min-height: var(--field-compact-height);
}

@media (max-width: 760px) {
  .opening-balance-meta {
    grid-template-columns: 1fr;
  }
}

.modal-form textarea {
  min-height: 96px;
}

.modal-form.user-details-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 8px 12px;
}

.modal-form.user-details-form label {
  gap: 4px;
}

.modal-form.user-details-form .choice-dropdown-field {
  align-self: start;
}

.modal-form.user-details-form .choice-dropdown-field legend {
  margin-bottom: 4px;
}

.modal-form.user-details-form :is(input, select, .choice-dropdown summary) {
  min-height: var(--control-height);
  height: var(--control-height);
}

.modal-form.user-details-form .toggle-field {
  min-height: var(--control-height);
  padding: 6px 9px;
  gap: 8px;
}

.modal-form.user-details-form textarea {
  min-height: 76px;
}

@media (max-width: 960px) {
  .modal-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

/* Canonical portal form system: shared field geometry, state treatment, and validation. */
:root {
  --field-height: 38px;
  --field-compact-height: 32px;
  --field-radius: 6px;
  --field-padding-inline: 10px;
  --field-label-size: 11px;
  --field-label-line-height: 1.25;
  --field-text-size: 13px;
  --field-helper-size: 11px;
  --field-row-gap: 12px;
  --field-label-gap: 4px;
  --field-border: var(--line-strong);
  --field-hover-border: color-mix(in srgb, var(--brand) 30%, var(--line-strong));
  --field-active-border: color-mix(in srgb, var(--brand) 56%, var(--line-strong));
  --field-active-surface: color-mix(in srgb, var(--brand-soft) 42%, var(--surface));
  --field-disabled-surface: var(--surface-2);
  --field-error: #b42318;
  --field-error-surface: #fff6f5;
}

:where(.form-field, .field-block, .choice-dropdown-field) {
  min-width: 0;
}

:where(.form-field, .field-block) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--field-label-gap);
  color: var(--muted);
  font-size: var(--field-label-size);
  font-weight: 700;
  line-height: var(--field-label-line-height);
}

.modal-form > label:not(.toggle-field):not(.confirmation-checkbox),
.modal-form > .article-rich-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--field-label-gap);
  min-width: 0;
  color: var(--muted);
  font-size: var(--field-label-size);
  font-weight: 700;
  line-height: var(--field-label-line-height);
}

:where(.form-field, .field-block) > .field-label,
.modal-form > label > span:not(.sr-only),
.choice-dropdown-field > legend .field-label,
.article-rich-crop-controls > label > span {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: var(--field-label-size);
  font-weight: 700;
  line-height: var(--field-label-line-height);
}

.field-required {
  color: var(--red);
  font-weight: 800;
}

:where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  box-sizing: border-box;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--field-text-size);
  font-weight: 600;
  line-height: 1.35;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

:where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select) {
  min-height: var(--field-height);
  height: var(--field-height);
  padding: 0 var(--field-padding-inline);
}

textarea {
  min-height: 96px;
  padding: 9px var(--field-padding-inline);
}

input[type="file"] {
  padding-block: 6px;
}

:where(input, textarea)::placeholder {
  color: var(--muted-2);
  font-weight: 500;
  opacity: 1;
}

:where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):not(:disabled):not([readonly]):hover {
  border-color: var(--field-hover-border);
}

:where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus,
.choice-dropdown > summary:focus,
.choice-dropdown > summary:focus-visible {
  border-color: var(--field-active-border);
  background: var(--field-active-surface);
  box-shadow: inset 0 0 0 1px var(--field-active-border) !important;
  outline: none;
}

:where(input, select, textarea):disabled {
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--field-disabled-surface);
  color: var(--muted);
  opacity: 1;
}

:where(input:not([type="checkbox"]):not([type="radio"]), textarea)[readonly] {
  cursor: default;
  border-color: var(--line);
  background: var(--field-disabled-surface);
  color: var(--muted);
}

:where(input[type="checkbox"], input[type="radio"]) {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

input[type="range"] {
  width: 100%;
  min-height: 28px;
  margin: 0;
  accent-color: var(--brand);
}

:where(input[type="checkbox"], input[type="radio"]):focus-visible {
  outline: 2px solid var(--field-active-border) !important;
  outline-offset: 2px !important;
}

.field-helper {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: var(--field-helper-size);
  font-weight: 500;
  line-height: 1.35;
}

.field-error {
  display: block;
  margin: 0;
  color: var(--field-error);
  font-size: var(--field-helper-size);
  font-weight: 700;
  line-height: 1.35;
}

.field-error::before {
  content: "!";
  display: inline-grid;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  place-items: center;
  border-radius: 50%;
  background: var(--field-error);
  color: #ffffff;
  font-size: 9px;
  line-height: 1;
}

.field-error[hidden] {
  display: none;
}

html[data-theme="dark"] .field-error {
  color: #fca5a5;
}

html[data-theme="dark"] :where(input, select, textarea)[aria-invalid="true"],
html[data-theme="dark"] .has-field-error .choice-dropdown > summary {
  border-color: #f87171 !important;
  background: rgba(127, 29, 29, 0.28) !important;
}

:where(input, select, textarea)[aria-invalid="true"],
.has-field-error .choice-dropdown > summary {
  border-color: var(--field-error) !important;
  background: var(--field-error-surface) !important;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--field-error) 18%, transparent) !important;
}

.has-field-error :where(input[type="checkbox"], input[type="radio"]) {
  outline: 1px solid var(--field-error);
  outline-offset: 2px;
}

.has-field-error .choice-dropdown > summary[aria-invalid="true"] {
  color: var(--field-error);
}

.ticket-form,
.dynamic-fields,
.modal-form {
  gap: var(--field-row-gap);
}

.ticket-form > .form-field,
.ticket-form > .field-block,
.modal-form > .form-field,
.modal-form > .field-block {
  align-self: start;
}

/* Compact list/table controls deliberately use the same border and text treatment at a denser rhythm. */
.list-control.form-field {
  gap: 4px;
}

.list-control.form-field > .field-label {
  margin: 0;
}

.choice-dropdown-field {
  display: grid;
  gap: var(--field-label-gap);
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-dropdown-field > legend {
  width: 100%;
  margin: 0;
  padding: 0;
}

.brand-choice-field {
  display: grid;
  gap: var(--field-label-gap);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.brand-choice-field > legend {
  width: 100%;
  margin: 0;
  padding: 0;
}

.brand-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.brand-choice-list label {
  display: flex;
  align-items: center;
  min-height: var(--field-height);
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--field-text-size);
  font-weight: 600;
  cursor: pointer;
}

.brand-choice-list label:hover {
  border-color: var(--field-hover-border);
}

.brand-choice-list label:has(input:checked) {
  border-color: var(--field-active-border);
  background: var(--field-active-surface);
  box-shadow: inset 0 0 0 1px var(--field-active-border);
  color: var(--brand-deep);
}

.brand-choice-list input {
  inline-size: 16px;
  block-size: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.brand-choice-list input:focus-visible {
  outline: 2px solid var(--field-active-border);
  outline-offset: 2px;
}

.brand-choice-field .field-helper {
  min-width: 0;
  overflow-wrap: anywhere;
}

.searchable-combobox-field {
  min-width: 0;
}

.searchable-combobox {
  position: relative;
  min-width: 0;
}

.searchable-combobox-input {
  width: 100%;
  padding-right: calc(var(--field-padding-inline) + 28px) !important;
}

.searchable-combobox-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: inline-grid;
  width: calc(var(--field-height) - 2px);
  height: calc(var(--field-height) - 2px);
  place-items: center;
  border: 0;
  border-radius: calc(var(--field-radius) - 1px);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.searchable-combobox-toggle:hover,
.searchable-combobox-toggle:focus-visible {
  background: var(--surface-3);
  color: var(--brand);
  outline: none;
}

.searchable-combobox-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.searchable-combobox-list {
  position: absolute;
  z-index: 180;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: min(var(--popup-available-height, 264px), 264px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

[data-viewport-popup-host].popup-viewport-positioned > [data-viewport-popup] {
  position: fixed;
  z-index: 700;
  top: var(--popup-fixed-top);
  right: auto;
  bottom: auto;
  left: var(--popup-fixed-left);
  width: var(--popup-fixed-width);
}

.modal-panel .searchable-combobox:focus-within {
  z-index: 3;
}

.directory-user-field .searchable-combobox-list {
  right: auto;
  width: min(360px, calc(100vw - 24px));
}

.searchable-combobox-list[hidden] {
  display: none;
}

.searchable-combobox-list button {
  display: block;
  width: 100%;
  min-height: var(--field-compact-height);
  padding: 6px 8px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.searchable-combobox-list button:hover,
.searchable-combobox-list button:focus-visible,
.searchable-combobox-list button[aria-selected="true"] {
  background: var(--field-active-surface);
  color: var(--brand);
  outline: none;
}

.searchable-combobox-empty {
  margin: 0;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 560px) {
  .brand-choice-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

.choice-dropdown > summary {
  min-height: var(--field-height);
  padding-inline: var(--field-padding-inline);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--field-text-size);
  font-weight: 600;
}

.choice-dropdown[open] > summary {
  border-color: var(--field-active-border);
  background: var(--field-active-surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--field-active-border);
}

.choice-dropdown-list {
  gap: 6px;
  padding: 8px;
  border-color: var(--field-border);
  border-radius: var(--field-radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.choice-dropdown-search {
  min-height: var(--field-compact-height);
  height: var(--field-compact-height);
  padding-inline: 9px;
  border-radius: 5px;
  font-size: 12px;
}

.choice-dropdown-list label {
  min-height: var(--field-compact-height);
  gap: 8px;
  padding: 6px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
}

.choice-dropdown-list label:has(input:checked) {
  background: var(--field-active-surface);
  color: var(--brand);
}

.choice-dropdown-list label:hover {
  background: var(--surface-3);
}

.inline-ticket-field :where(input:not([type="hidden"]), select) {
  min-height: var(--field-compact-height);
  height: var(--field-compact-height);
  padding-inline: 8px;
  font-size: 12px;
}

.inline-ticket-field > .field-label {
  font-size: 10px;
}

.invoice-entry-line :where(input:not([type="hidden"]), select) {
  min-height: var(--field-compact-height);
  height: var(--field-compact-height);
  padding-inline: 8px;
  font-size: 12px;
}

.article-rich-crop-controls > label {
  display: grid;
  gap: var(--field-label-gap);
  min-width: 0;
}

.article-rich-crop-controls :where(select, input:not([type="range"])) {
  min-height: var(--field-compact-height);
  height: var(--field-compact-height);
  font-size: 12px;
}

.global-search input {
  height: 40px;
}

.session-impersonate-select {
  min-height: 28px;
  height: 28px;
}

html[data-theme="dark"] :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea),
html[data-theme="dark"] .choice-dropdown > summary,
html[data-theme="dark"] .choice-dropdown-list {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(18, 24, 38, 0.98);
  color: var(--ink);
}

html[data-theme="dark"] :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea):focus,
html[data-theme="dark"] .choice-dropdown[open] > summary {
  background: rgba(30, 58, 96, 0.48);
}

html[data-theme="dark"] :where(input, textarea)::placeholder {
  color: #94a3b8;
}

@media (max-width: 760px) {
  :root {
    --field-height: 42px;
  }

  .modal-form.user-details-form,
  .ticket-form,
  .dynamic-fields {
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .modal-form.user-details-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

.modal-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mailbox-config-modal,
.structured-config-modal {
  width: min(980px, 100%);
}

.structured-config-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(223, 245, 239, 0.72), rgba(226, 237, 249, 0.56));
}

.structured-config-head strong,
.structured-config-head span {
  display: block;
}

.structured-config-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mailbox-config-list,
.structured-config-list {
  display: grid;
  gap: 10px;
}

.mailbox-config-row,
.structured-config-row {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mailbox-config-row {
  grid-template-columns: 92px minmax(190px, 1.2fr) minmax(150px, 0.9fr) 132px 36px;
}

.structured-config-row {
  grid-template-columns: repeat(var(--structured-columns, 2), minmax(130px, 1fr)) 36px;
}

.mailbox-config-row label,
.structured-config-row label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.mailbox-primary-choice {
  min-height: 42px;
  padding: 9px 10px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px !important;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink) !important;
}

.mailbox-primary-choice input {
  width: auto;
  margin: 0;
}

.mailbox-primary-choice:has(input:checked) {
  border-color: rgba(15, 118, 110, 0.42);
  background: var(--brand-soft);
  color: var(--brand-deep) !important;
}

.mailbox-remove,
.structured-remove {
  width: 36px;
  height: 36px;
  align-self: end;
}

@media (max-width: 760px) {
  .section-actions {
    justify-content: stretch;
  }

  .section-actions > * {
    flex: 1 1 150px;
  }

  .modal-root {
    align-items: end;
    padding: 10px;
  }

  .modal-panel {
    max-height: 92vh;
  }

  .modal-form {
    grid-template-columns: 1fr;
  }

  .structured-config-head,
  .mailbox-config-row,
  .structured-config-row {
    grid-template-columns: 1fr;
  }

  .structured-config-head {
    align-items: stretch;
  }

  .mailbox-primary-choice {
    justify-content: flex-start;
  }

  .modal-head,
  .modal-body,
  .modal-actions {
    padding: 14px;
  }
}

.asset-row {
  grid-template-columns: minmax(0, 1.05fr) 0.85fr 0.85fr 0.72fr minmax(0, 0.95fr) 132px;
}

.license-row {
  grid-template-columns: minmax(0, 1.18fr) minmax(140px, 0.9fr) minmax(0, 1fr) 0.72fr 0.64fr 180px;
}

.contract-row {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr) 0.7fr 0.72fr 0.62fr 132px;
}

.row-actions {
  position: relative;
  z-index: 2;
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  overflow: visible;
}

.row-actions .text-button {
  min-height: 32px;
  padding: 0 10px;
}

.rule-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.schedule-card {
  align-items: start;
}

.schedule-card .text-button {
  justify-self: start;
  min-height: 32px;
  margin-top: 4px;
}

.article-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.article-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(31, 35, 40, 0.1);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
}

.submitted-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 16px;
}

.submitted-fields div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}

.submitted-fields span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.submitted-fields strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 650;
}

.article-reader-summary {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.article-reader-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.article-reader-steps li {
  line-height: 1.5;
}

.list-controls {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(0, 1.55fr);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.list-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.list-summary strong {
  color: var(--brand);
  font-size: 18px;
  line-height: 1;
}

.list-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.list-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
  align-items: end;
}

.list-control {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.list-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.list-control select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  font-size: 12px;
}

.list-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.list-pager span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.list-pager .text-button {
  min-height: 34px;
}

.text-button:disabled {
  cursor: default;
  opacity: 0.48;
  transform: none;
}

.settings-console,
.settings-side {
  min-width: 0;
}

.settings-tabs {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 8px;
  background: rgba(237, 241, 247, 0.86);
}

.settings-tabs button {
  min-height: 36px;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.settings-tabs button.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
}

.settings-panel {
  margin-top: 16px;
  display: grid;
  gap: 14px;
}

.settings-panel-head,
.settings-action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.settings-panel-head h3 {
  margin: 2px 0 0;
  font-size: 18px;
  font-weight: 650;
}

.settings-grid,
.settings-list,
.settings-health,
.settings-quick-actions,
.settings-audit {
  display: grid;
  gap: 10px;
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.settings-item {
  padding: 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
}

.settings-item.muted {
  opacity: 0.68;
}

.settings-item strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.settings-item span,
.settings-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.settings-side .text-button {
  width: 100%;
  justify-content: flex-start;
}

.text-button.danger {
  border-color: rgba(196, 43, 28, 0.24);
  color: var(--red);
  background: var(--red-soft);
}

.session-panel {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--sidebar-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #f7fbff;
}

.session-panel strong,
.session-panel p {
  display: block;
  margin: 0;
}

.session-panel p {
  margin-top: 4px;
  color: rgba(236, 244, 255, 0.72);
  font-size: 11px;
}

.session-panel .text-button {
  min-height: 34px;
  justify-content: center;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.12);
  color: #f7fbff;
}

.auth-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.92), rgba(248, 250, 252, 0.88));
  box-shadow: var(--shadow-soft);
}

.auth-banner.show {
  display: flex;
}

.auth-banner span {
  color: var(--muted);
  font-size: 12px;
}

.login-shell {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(760px, 100%);
  display: grid;
  gap: 18px;
}

.login-hero h2 {
  margin: 4px 0 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
}

.login-hero p {
  max-width: 620px;
  color: var(--muted);
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.password-login-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
}

.password-login-form label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.password-login-form input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

.password-login-form .primary-action {
  min-height: 42px;
}

.staged-login-form {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.staged-login-form label.full {
  grid-column: auto;
}

.login-state-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.login-state-card strong {
  color: var(--ink);
  font-size: 15px;
}

.login-state-card span {
  color: var(--muted);
  line-height: 1.45;
}

.compact-actions {
  margin-top: 4px;
}

.password-login-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -8px;
}

body[data-auth-role="guest"] .app-shell {
  grid-template-columns: 1fr;
}

body[data-auth-role="guest"] .sidebar,
body[data-auth-role="guest"] .topbar,
body[data-auth-role="guest"] #authBanner {
  display: none !important;
}

body[data-auth-role="guest"] main {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px);
}

body[data-auth-role="guest"] .view:not(#view-login) {
  display: none !important;
}

body[data-auth-role="guest"] #view-login.active {
  display: block;
}

body[data-auth-role="guest"] .login-shell {
  min-height: calc(100vh - clamp(36px, 8vw, 96px));
}

/* Page polish pass: modernise page surfaces without changing the menu. */
main {
  padding: 0 clamp(16px, 2.4vw, 34px) 34px;
}

.topbar {
  margin-inline: calc(clamp(16px, 2.4vw, 34px) * -1);
  padding-inline: clamp(16px, 2.4vw, 34px);
}

.view.active {
  max-width: 1680px;
}

.page-heading {
  margin-bottom: 14px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}

.section-title,
.page-heading,
.settings-panel-head {
  min-width: 0;
}

.section-title h2,
.page-heading h2,
.settings-panel-head h3 {
  color: var(--ink);
  font-weight: 720;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.section-actions .primary-action,
.section-actions .text-button,
.section-actions .row-menu summary {
  min-height: 34px;
}

.contract-health-heading {
  align-items: start;
}

.contract-health-tabs {
  flex-shrink: 0;
}

.contract-health-tabs button {
  min-width: 0;
}

.report-scope-control {
  min-height: 34px;
  display: grid;
  grid-template-columns: auto minmax(126px, 1fr);
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.report-scope-control span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.report-scope-control select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
}

.report-scope-control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.portal-grid,
.workspace-row,
.ticket-layout,
.asset-layout,
.licenses-layout,
.contracts-layout,
.automation-layout,
.communication-layout,
.admin-layout,
.settings-layout,
.users-layout {
  gap: 14px;
}

.asset-layout,
.licenses-layout,
.contracts-layout,
.automation-layout,
.communication-layout,
.settings-layout,
.users-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 330px);
}

.workspace-row {
  margin-top: 14px;
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.activity-card,
.side-card,
.kb-filters,
.kb-results {
  border-radius: 7px;
  border-color: rgba(15, 23, 42, 0.085);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 8px 22px rgba(15, 23, 42, 0.045);
}

.service-panel,
.quick-panel,
.work-card,
.kb-filters,
.kb-results {
  padding: clamp(14px, 1.5vw, 18px);
}

.quick-panel,
.settings-side,
.user-detail-panel {
  align-self: start;
}

.metric-card,
.score-card,
.setting-card,
.config-card,
.article-card,
.focus-item,
.suggestion,
.license-card,
.license-user-card,
.license-contract-card,
.license-action-card,
.template-card,
.notification-log-card,
.smtp-card,
.schedule-card,
.rule-card,
.notification-card,
.agreement-card,
.exposure-card,
.selected-user-summary,
.user-access-card,
.user-link-card,
.requester-card,
.mini-feed div,
.requester-history button {
  border-radius: 6px;
  border-color: rgba(15, 23, 42, 0.08);
  background: #ffffff;
  box-shadow: none;
}

.metric-card,
.exposure-card,
.score-card {
  padding: 10px 11px;
}

.metric-card strong,
.exposure-card strong,
.score-card strong {
  margin-top: 5px;
  font-size: 20px;
  font-weight: 720;
}

.metric-card span,
.exposure-card span,
.score-card span {
  letter-spacing: 0.04em;
}

.metric-card small,
.exposure-card small,
.score-card small {
  margin-top: 5px;
  line-height: 1.3;
}

.asset-metrics,
.license-metrics,
.settings-grid,
.dashboard-grid {
  gap: 8px;
}

.asset-metrics,
.license-metrics {
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
}

.list-controls {
  grid-template-columns: minmax(112px, 0.26fr) minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 7px;
  background: rgba(248, 250, 252, 0.82);
  box-shadow: none;
}

.list-summary strong {
  font-size: 16px;
}

.list-filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 7px;
}

.list-control span {
  font-size: 9.5px;
}

.list-control select {
  height: 34px;
  border-radius: 6px;
}

.asset-table,
.license-table,
.contract-table,
.user-table,
.settings-list,
.rule-list,
.schedule-list,
.template-list,
.notification-log,
.license-stack,
.notification-stack,
.license-action-list,
.exposure-stack,
.lifecycle-list,
.dependency-map {
  gap: 8px;
}

.asset-row,
.license-row,
.contract-row,
.user-row {
  min-height: 58px;
  padding: 10px 11px;
  border-color: rgba(15, 23, 42, 0.075);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
}

.asset-row:hover,
.license-row:hover,
.contract-row:hover,
.user-row:hover {
  border-color: rgba(15, 108, 189, 0.22);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.055);
}

.asset-row.header,
.license-row.header,
.contract-row.header,
.user-row.header {
  min-height: 30px;
  padding: 0 11px 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.asset-row strong,
.asset-row span,
.license-row strong,
.license-row span,
.contract-row strong,
.contract-row span,
.user-row strong,
.user-row span {
  line-height: 1.25;
}

.asset-row small,
.license-row small,
.contract-row small,
.user-row small {
  margin-top: 4px;
  line-height: 1.3;
}

.row-actions .row-menu summary,
.page-menu summary,
.action-menu summary {
  min-width: 38px;
  min-height: 34px;
}

.article-card,
.rule-card,
.schedule-card,
.notification-card,
.agreement-card,
.license-action-card,
.setting-card,
.settings-item,
.license-contract-card {
  padding: 11px 12px;
}

.article-card {
  min-height: auto;
}

.article-card p,
.agreement-card p,
.rule-card p {
  line-height: 1.4;
}

.service-grid,
.article-strip {
  gap: 10px;
}

.service-card {
  min-height: 118px;
  padding: 13px;
  gap: 9px;
}

.service-icon {
  width: 30px;
  height: 30px;
}

.focus-item {
  align-items: center;
}

.focus-item .sla-badge {
  flex: 0 0 auto;
}

.knowledge-layout {
  gap: 14px;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
}

.kb-filters {
  gap: 6px;
}

.stock-receipt-modal {
  width: min(920px, calc(100vw - 32px));
}

.stock-receipt-context {
  grid-template-columns: minmax(240px, 1.4fr) minmax(190px, 0.8fr);
}

.stock-receipt-context label.full {
  grid-column: 1 / -1;
}

.stock-receipt-items {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.stock-receipt-items-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.stock-receipt-items-head h3,
.stock-receipt-items-head p {
  margin: 0;
}

.stock-receipt-items-head h3 {
  font-size: 14px;
}

.stock-receipt-items-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stock-receipt-line {
  display: grid;
  grid-template-columns: minmax(210px, 1.6fr) minmax(90px, 0.55fr) minmax(120px, 0.7fr) minmax(150px, 1fr) 34px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.stock-receipt-line + .stock-receipt-line {
  margin-top: 8px;
}

.stock-receipt-line label {
  min-width: 0;
}

.stock-receipt-remove,
.stock-receipt-spacer {
  width: 34px;
  height: 34px;
}

.invoice-entry-modal {
  width: min(1260px, calc(100vw - 32px));
  overflow-x: hidden;
}

/* The item table owns horizontal scrolling; never duplicate it on the dialog. */
.invoice-entry-modal:has(.searchable-combobox-list:not([hidden])) {
  overflow-x: hidden;
  overflow-y: auto;
}

.invoice-entry-modal .modal-note {
  margin-bottom: 10px;
}

.invoice-entry-modal .modal-form textarea {
  min-height: 76px;
}

.invoice-entry-items-section {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.invoice-entry-toggle {
  min-height: 34px;
  margin-bottom: 8px;
}

.invoice-entry-items-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
}

.invoice-entry-received-at {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.invoice-entry-received-at input {
  width: 190px;
  min-width: 0;
  height: 32px;
}

.invoice-entry-items-toolbar .text-button {
  min-height: 32px;
  padding-inline: 9px;
  white-space: nowrap;
}

.invoice-entry-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.invoice-entry-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

.invoice-entry-col-item { width: 22%; }
.invoice-entry-col-sku { width: 10%; }
.invoice-entry-col-category { width: 12%; }
.invoice-entry-col-unit { width: 8%; }
.invoice-entry-col-default-location { width: 13%; }
.invoice-entry-col-quantity { width: 6%; }
.invoice-entry-col-cost { width: 9%; }
.invoice-entry-col-location { width: 13%; }
.invoice-entry-col-reorder { width: 7%; }
.invoice-entry-col-actions { width: 42px; }

.invoice-entry-table th,
.invoice-entry-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.invoice-entry-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.invoice-entry-table tbody tr:last-child td {
  border-bottom: 0;
}

.invoice-entry-line td,
.invoice-entry-line-item,
.invoice-item-picker,
.invoice-new-item-picker {
  min-width: 0;
}

.invoice-entry-line input,
.invoice-entry-line select {
  width: 100%;
  min-width: 0;
  height: 32px;
}

.invoice-entry-line-actions {
  width: 42px;
  text-align: center !important;
}

.invoice-item-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoice-item-picker input {
  flex: 1 1 auto;
}

.invoice-item-picker .searchable-combobox {
  flex: 1 1 180px;
}

.invoice-item-picker .text-button {
  min-height: 32px;
  padding-inline: 8px;
  white-space: nowrap;
}

.invoice-new-item-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.invoice-new-item-picker input {
  flex: 1 1 auto;
}

.invoice-entry-line-remove,
.invoice-entry-line-spacer {
  width: 32px;
  height: 32px;
}

.invoice-entry-static {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kb-filters button {
  height: 34px;
  border-radius: 6px;
  font-size: 11px;
}

.kb-results {
  gap: 10px;
}

.settings-tabs {
  display: block;
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.settings-search {
  display: grid;
  width: 100%;
  margin-bottom: 10px;
}

.settings-search input {
  width: 100%;
}

.settings-tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.settings-tab-list button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.settings-tab-list button.active {
  border-color: rgba(15, 108, 189, 0.26);
  background: var(--brand-soft);
  color: var(--brand);
}

.settings-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.settings-map-card {
  min-height: 96px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 6px;
  background: #ffffff;
  color: inherit;
  text-align: left;
}

.settings-map-card:hover {
  border-color: rgba(15, 108, 189, 0.28);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.055);
}

.settings-map-card strong,
.settings-map-card span,
.settings-map-card small {
  display: block;
}

.settings-map-card strong {
  font-size: 13px;
}

.settings-map-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.settings-map-card small {
  margin-top: 8px;
  color: var(--brand);
  font-size: 10px;
  font-weight: 720;
}

.settings-item {
  min-height: 56px;
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: none;
}

.settings-panel {
  gap: 12px;
}

.selected-user-summary,
.user-access-card {
  padding: 10px 12px;
}

.user-link-actions {
  justify-content: flex-start;
}

.user-link-section h3 {
  margin-bottom: 8px;
}

.login-shell {
  align-items: center;
}

.login-card {
  width: min(720px, 100%);
  gap: 14px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

.login-hero h2 {
  max-width: 620px;
  font-size: clamp(32px, 5.2vw, 54px);
  line-height: 0.98;
}

.login-hero p {
  max-width: 560px;
  margin-bottom: 0;
}

.password-login-form,
.login-state-card {
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}

.password-login-form {
  gap: 9px;
  padding: 12px;
}

.password-login-form[data-login-step="password"] {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.34fr);
}

.password-login-form[data-login-step="password"] .primary-action {
  grid-column: 1 / -1;
  width: 100%;
}

.password-login-form input {
  height: 40px;
  border-radius: 6px;
}

.password-login-form .primary-action {
  min-height: 40px;
}

.login-actions,
.password-login-links {
  gap: 8px;
}

html[data-theme="dark"] .service-panel,
html[data-theme="dark"] .quick-panel,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .queue-panel,
html[data-theme="dark"] .ticket-detail,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .kb-filters,
html[data-theme="dark"] .kb-results,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .score-card,
html[data-theme="dark"] .setting-card,
html[data-theme="dark"] .config-card,
html[data-theme="dark"] .article-card,
html[data-theme="dark"] .focus-item,
html[data-theme="dark"] .suggestion,
html[data-theme="dark"] .license-card,
html[data-theme="dark"] .license-user-card,
html[data-theme="dark"] .license-contract-card,
html[data-theme="dark"] .license-action-card,
html[data-theme="dark"] .template-card,
html[data-theme="dark"] .notification-log-card,
html[data-theme="dark"] .smtp-card,
html[data-theme="dark"] .schedule-card,
html[data-theme="dark"] .rule-card,
html[data-theme="dark"] .notification-card,
html[data-theme="dark"] .agreement-card,
html[data-theme="dark"] .exposure-card,
html[data-theme="dark"] .report-card,
html[data-theme="dark"] .selected-user-summary,
html[data-theme="dark"] .user-access-card,
html[data-theme="dark"] .user-link-card,
html[data-theme="dark"] .settings-map-card,
html[data-theme="dark"] .password-login-form,
html[data-theme="dark"] .login-state-card {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(17, 24, 39, 0.9);
  box-shadow: none;
}

html[data-theme="dark"] .asset-row,
html[data-theme="dark"] .license-row,
html[data-theme="dark"] .contract-row,
html[data-theme="dark"] .user-row,
html[data-theme="dark"] .settings-item {
  border-color: rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.56);
}

@media (max-width: 1180px) {
  .asset-layout,
  .licenses-layout,
  .contracts-layout,
  .automation-layout,
  .communication-layout,
  .settings-layout,
  .users-layout,
  .portal-grid,
  .workspace-row,
  .ticket-layout {
    grid-template-columns: 1fr;
  }

  .quick-panel,
  .settings-side,
  .user-detail-panel {
    order: 2;
  }
}

@media (max-width: 760px) {
  main {
    padding-inline: 12px;
  }

  .topbar {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .kb-filters {
    display: flex;
    flex-wrap: wrap;
  }

  .kb-filters button {
    flex: 1 1 130px;
  }

  .kb-results {
    grid-template-columns: 1fr;
  }

  .list-controls {
    grid-template-columns: 1fr;
  }

  .settings-tab-list {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

.settings-tab-list button {
  flex: 0 0 auto;
  }

  .login-card {
    padding: 18px;
  }

  .password-login-form[data-login-step="password"] {
    grid-template-columns: 1fr;
  }

  .login-hero h2 {
    font-size: clamp(30px, 12vw, 44px);
  }
}

/* Directory/list containment: keep action menus inside the page at tablet widths. */
.wide-card,
.user-table,
.asset-table,
.license-table,
.contract-table {
  min-width: 0;
}

.user-row {
  grid-template-columns: 56px minmax(0, 1fr) 38px;
  gap: 8px;
}

.user-row-main {
  grid-template-columns: minmax(150px, 1.18fr) minmax(86px, 0.56fr) minmax(118px, 0.78fr) minmax(100px, 0.6fr) minmax(132px, 0.88fr);
  gap: 8px;
}

.user-row-main > strong,
.user-row-main > span {
  overflow-wrap: anywhere;
}

.user-row .row-actions {
  min-width: 38px;
  justify-content: end;
}

.user-row.header > span:last-child {
  overflow: hidden;
  text-align: right;
  text-indent: -999px;
}

@media (max-width: 980px) {
  .user-row-main {
    grid-template-columns: minmax(150px, 1.2fr) minmax(92px, 0.6fr) minmax(126px, 0.8fr) minmax(100px, 0.62fr) minmax(0, 1fr);
  }

  .user-metrics {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  }
}

@media (max-width: 720px) {
  .user-row {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .user-row.header {
    display: none;
  }

  .user-row-main {
    grid-template-columns: 1fr;
  }

  .user-quick-look-control {
    align-self: start;
    margin-top: 2px;
  }

  .user-row .row-actions {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
  }
}

/* Final tight-spot pass from visual audit. */
.ticket-view-button strong {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ticket-view-button {
  align-items: start;
}

.agent-grid {
  grid-template-columns: minmax(390px, 0.72fr) minmax(0, 1.28fr);
}

.ticket-workspace-list {
  grid-template-columns: 1fr;
}

.ticket-view-rail {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-right: 0;
  padding-bottom: 8px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.ticket-view-rail .rail-head {
  grid-column: 1 / -1;
}

.kb-results .list-controls {
  grid-column: 1 / -1;
}

.knowledge-list-controls {
  grid-template-columns: minmax(112px, 0.24fr) minmax(0, 1fr);
}

.license-contract-card dl {
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.license-contract-card dl div,
.license-contract-card dt,
.license-contract-card dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .agent-grid {
    grid-template-columns: 1fr;
  }

  .knowledge-list-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .password-login-form {
    grid-template-columns: 1fr;
  }

  .password-login-form .primary-action {
    width: 100%;
  }
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.agent-workspace-title h2 {
  margin: 2px 0 0;
  font-size: 21px;
}

.ticket-workspace-list {
  display: grid;
  grid-template-columns: minmax(170px, 0.34fr) minmax(0, 0.66fr);
  gap: 12px;
  align-items: start;
}

.ticket-view-rail,
.ticket-results {
  min-width: 0;
  display: grid;
  gap: 9px;
}

.rail-head,
.queue-summary,
.conversation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rail-head strong {
  font-size: 12px;
}

.rail-head .text-button {
  min-height: 30px;
  padding: 0 8px;
}

.ticket-view-button {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-left: 3px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: inherit;
  text-align: left;
}

.ticket-view-button strong,
.ticket-view-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-view-button strong {
  font-size: 12px;
}

.ticket-view-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.ticket-view-button b {
  min-width: 28px;
  min-height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
}

.ticket-view-button.active {
  border-color: rgba(37, 99, 235, 0.28);
  border-left-color: var(--brand);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 35, 40, 0.08);
}

.ticket-view-button.color-red {
  border-left-color: var(--red);
}

.ticket-view-button.color-amber {
  border-left-color: var(--amber);
}

.ticket-view-button.color-green {
  border-left-color: var(--green);
}

.queue-summary {
  padding: 11px 12px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.84);
}

.queue-summary h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

.queue-summary span {
  max-width: 220px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.ticket-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.ticket-tabs button {
  min-width: 154px;
  max-width: 220px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(31, 35, 40, 0.1);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.88);
  color: inherit;
  text-align: left;
}

.ticket-tabs button.active {
  border-color: rgba(37, 99, 235, 0.34);
  background: #ffffff;
  box-shadow: inset 0 -2px 0 var(--brand);
}

.ticket-tabs span,
.ticket-tabs strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-tabs span {
  color: var(--brand);
  font-size: 10px;
  font-weight: 750;
}

.ticket-tabs strong {
  grid-column: 1 / -1;
  font-size: 11px;
}

.ticket-tabs i {
  grid-row: 1;
  grid-column: 2;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-style: normal;
}

.ticket-tabs [data-ticket-tab-close] {
  display: inline-grid;
  place-items: center;
  justify-self: center;
  align-self: center;
  line-height: 1;
  cursor: pointer;
}

.ticket-tabs [data-ticket-tab-close] svg {
  width: 10px;
  height: 10px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.ticket-workspace-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.36fr);
  gap: 14px;
}

.ticket-conversation,
.ticket-properties {
  min-width: 0;
}

.conversation-head h3,
.property-section h3 {
  margin: 0;
  font-size: 14px;
}

.conversation-head span {
  color: var(--muted);
  font-size: 11px;
}

.composer-mode {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  width: min(340px, 100%);
  margin-bottom: 8px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(237, 241, 247, 0.86);
}

.composer-mode button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.composer-mode button.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 4px 10px rgba(31, 35, 40, 0.08);
}

.timeline-item.internal {
  margin: 2px 0 2px 4px;
  padding: 7px 10px 7px 18px;
  border-left-color: rgba(217, 119, 6, 0.72);
  border-radius: 0 8px 8px 0;
  background: rgba(255, 247, 237, 0.72);
}

.timeline-item.internal strong {
  color: #92400e;
}

.timeline-item.continuation {
  padding-top: 4px;
  padding-bottom: 5px;
}

.timeline-item.continuation::before {
  top: 8px;
  width: 6px;
  height: 6px;
  left: -3px;
}

.timeline-item.internal.continuation {
  margin-top: 2px;
  margin-bottom: 2px;
  border-radius: 0 8px 8px 0;
  background: rgba(255, 247, 237, 0.72);
}

.property-section {
  display: grid;
  gap: 9px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.property-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.property-section + .property-section {
  padding-top: 14px;
}

.requester-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.requester-facts span {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.requester-facts b {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
}

.timeline-item-head time {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.timeline-meta {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  margin-top: 0;
}

.timeline-author {
  color: var(--muted-2);
  font-size: 10px;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.timeline-item.continuation .timeline-message {
  margin-top: 1px;
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 7px;
}

.composer-tools span {
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.timeline-message {
  display: grid;
  gap: 5px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.timeline-message p {
  margin: 0;
}

.timeline-signature {
  width: fit-content;
  max-width: 100%;
  margin-top: 1px;
}

.timeline-signature summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 18px;
  padding: 0 6px 3px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
  list-style: none;
}

.timeline-signature summary::-webkit-details-marker {
  display: none;
}

.timeline-signature summary:hover,
.timeline-signature summary:focus-visible {
  border-color: var(--brand);
  color: var(--brand);
  outline: none;
}

.timeline-signature[open] summary {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.timeline-signature-content {
  max-width: min(520px, 100%);
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 4px 4px 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
}

.timeline-message a {
  color: var(--brand);
  font-weight: 700;
}

.ticket-code-snippet {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.ticket-code-snippet summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 0 9px;
  color: var(--ink);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
  list-style: none;
}

.ticket-code-snippet summary::-webkit-details-marker {
  display: none;
}

.ticket-code-snippet summary::after {
  content: "Expand";
  color: var(--brand);
  font-size: 9px;
  font-weight: 700;
}

.ticket-code-snippet[open] summary {
  border-bottom: 1px solid var(--line);
}

.ticket-code-snippet[open] summary::after {
  content: "Collapse";
}

.ticket-code-block {
  position: relative;
  max-width: 100%;
  margin: 0;
  padding: 9px;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 11px/1.45 Consolas, "Courier New", monospace;
  white-space: pre;
}

.ticket-code-block::before {
  content: none;
}

.ticket-code-block .code-token.comment { color: #64748b; font-style: italic; }
.ticket-code-block .code-token.string { color: #a16207; }
.ticket-code-block .code-token.number { color: #7c3aed; }
.ticket-code-block .code-token.keyword { color: #1d4ed8; font-weight: 700; }
.ticket-code-block .code-token.tag { color: #b45309; }

html[data-theme="dark"] .ticket-code-block .code-token.comment { color: #94a3b8; }
html[data-theme="dark"] .ticket-code-block .code-token.string { color: #fbbf24; }
html[data-theme="dark"] .ticket-code-block .code-token.number { color: #c4b5fd; }
html[data-theme="dark"] .ticket-code-block .code-token.keyword { color: #7dd3fc; }
html[data-theme="dark"] .ticket-code-block .code-token.tag { color: #fdba74; }

.inline-ticket-fields {
  display: grid;
  gap: 8px;
}

.inline-ticket-field {
  display: grid;
  grid-template-columns: minmax(72px, 0.38fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.inline-ticket-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.inline-ticket-field select,
.inline-ticket-field input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 0 9px;
}

.inline-ticket-field select:focus,
.inline-ticket-field input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
  border-color: rgba(37, 99, 235, 0.62);
}

.ticket-tag-field {
  align-items: start;
}

.ticket-tag-field > span {
  padding-top: 8px;
}

.ticket-tag-editor {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-muted);
}

.ticket-tag-editor > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 32px;
  padding: 0 8px;
  cursor: pointer;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  list-style: none;
}

.ticket-tag-editor > summary::-webkit-details-marker {
  display: none;
}

.ticket-tag-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-tag-summary.is-empty {
  color: var(--muted);
  font-weight: 600;
}

.ticket-tag-editor > summary i {
  width: 5px;
  height: 5px;
  margin-left: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
}

.ticket-tag-editor[open] {
  border-color: var(--active-border);
  background: var(--active-surface);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.ticket-tag-editor[open] > summary {
  color: var(--brand);
}

.ticket-tag-editor[open] > summary i {
  transform: rotate(225deg) translateY(-1px);
}

.ticket-tag-editor-panel {
  position: absolute;
  z-index: 28;
  top: calc(100% + 6px);
  left: 0;
  display: grid;
  gap: 6px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(280px, var(--popup-available-height, 280px));
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.ticket-tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ticket-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--active-border);
  border-radius: 5px;
  background: var(--active-surface);
  color: var(--brand);
  font: inherit;
  font-size: 10px;
  font-weight: 750;
  line-height: 1;
}

.ticket-tag-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-tag-chip i {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 500;
}

.ticket-tag-chip:hover,
.ticket-tag-chip:focus-visible {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--active-surface) 78%, var(--brand) 6%);
}

.ticket-tag-entry {
  position: relative;
  display: block;
  min-width: 0;
}

.ticket-tag-editor-panel .ticket-tag-entry input {
  height: 30px;
  border-color: var(--line);
  background: var(--surface);
  font-size: 11px;
}

.ticket-tag-entry input {
  width: 100%;
  min-width: 0;
}

.ticket-tag-suggestions {
  position: absolute;
  z-index: 26;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  display: grid;
  max-height: min(176px, var(--popup-available-height, 176px));
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.ticket-tag-suggestions[hidden] {
  display: none;
}

.ticket-tag-suggestions button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.ticket-tag-suggestions button:last-child {
  border-bottom: 0;
}

.ticket-tag-suggestions button:hover,
.ticket-tag-suggestions button:focus-visible {
  background: var(--active-surface);
  color: var(--brand);
}

.ticket-tag-suggestions strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.ticket-tag-suggestions small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.tag-management-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.tag-management-toolbar label {
  display: grid;
  gap: 4px;
  width: min(320px, 100%);
}

.tag-management-toolbar label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tag-management-toolbar input {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.tag-management-count {
  padding-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.tag-management-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.tag-management-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 100px 48px;
  gap: var(--space-2);
  align-items: center;
  min-height: 42px;
  padding: 6px 9px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.tag-management-row:first-child {
  border-top: 0;
}

.tag-management-row > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-management-row > .row-actions {
  justify-self: end;
}

.tag-management-head {
  min-height: 32px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.tag-management-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
}

.tag-management-status.is-active {
  background: #e6f7ec;
  color: #22763d;
}

.tag-management-status.is-merged {
  background: var(--surface-2);
  color: var(--muted);
}

@media (max-width: 620px) {
  .tag-management-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-2);
  }

  .tag-management-count {
    padding-bottom: 0;
  }

  .tag-management-row {
    grid-template-columns: minmax(0, 1fr) 50px 72px 40px;
    gap: 5px;
    padding-inline: 7px;
  }
}

.automatic-ticket-status:not(.ticket-status) {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.requester-card,
.property-list,
.mini-feed {
  display: grid;
  gap: 8px;
}

.requester-card {
  padding: 12px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.84);
}

.requester-profile-link {
  color: inherit;
  text-decoration: none;
}

.requester-profile-link:hover {
  border-color: rgba(15, 108, 189, 0.34);
  background: var(--brand-soft);
}

.requester-profile-link:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.6);
  outline-offset: 3px;
}

.requester-card strong,
.requester-card span,
.requester-card small,
.muted-line {
  display: block;
}

.requester-card span,
.requester-card small,
.muted-line {
  color: var(--muted);
  font-size: 11px;
}

.requester-card .requester-profile-link-label {
  margin-top: 5px;
  color: var(--brand);
  font-weight: 800;
}

.requester-history {
  display: grid;
  gap: 7px;
}

.requester-history button,
.mini-feed div,
.property-list div {
  padding: 9px;
  border: 1px solid rgba(31, 35, 40, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: inherit;
  text-align: left;
}

.requester-history button strong,
.requester-history button span,
.mini-feed strong,
.mini-feed span,
.mini-feed small,
.property-list span,
.property-list strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.property-list span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.property-list strong {
  margin-top: 3px;
  font-size: 12px;
}

.mini-feed span,
.mini-feed small,
.requester-history button span {
  color: var(--muted);
  font-size: 11px;
}

.settings-panel-head.sub-head {
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 760px) {
  .asset-row,
  .license-row,
  .contract-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .text-button {
    flex: 1 1 120px;
  }

  .rule-card {
    grid-template-columns: 1fr;
  }

  .rule-actions {
    justify-content: space-between;
  }

  .submitted-fields {
    grid-template-columns: 1fr;
  }

  .list-controls {
    grid-template-columns: 1fr;
  }

  .list-pager {
    justify-content: stretch;
  }

  .list-pager .text-button {
    flex: 1 1 96px;
  }

  .settings-item {
    grid-template-columns: 1fr;
  }

  .settings-action-row > *,
  .settings-panel-head > .text-button,
  .settings-panel-head > .primary-action {
    flex: 1 1 160px;
  }

  .auth-banner.show,
  .login-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-workspace-list,
  .ticket-workspace-grid {
    grid-template-columns: 1fr;
  }

  .inline-ticket-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .queue-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .queue-summary span {
    max-width: none;
    text-align: left;
  }

  .ticket-view-rail {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .rail-head {
    grid-column: 1 / -1;
  }
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  width: 74px;
  min-height: 38px;
  padding: 3px;
  border: 1px solid rgba(31, 35, 40, 0.1);
  border-radius: 8px;
  background: rgba(237, 241, 247, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.theme-switch button {
  display: grid;
  min-height: 30px;
  padding: 0;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.theme-switch-icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.theme-switch button.active {
  background: #ffffff;
  color: var(--brand-deep);
  box-shadow: 0 5px 14px rgba(31, 35, 40, 0.08);
}

.section-actions .text-button,
.section-actions .primary-action {
  white-space: nowrap;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #151f31;
  --surface-3: #1e293b;
  --ink: #e6edf7;
  --muted: #a1aec0;
  --muted-2: #748195;
  --line: rgba(148, 163, 184, 0.2);
  --line-strong: rgba(148, 163, 184, 0.32);
  --brand: #60a5fa;
  --brand-2: #38bdf8;
  --brand-deep: #dbeafe;
  --brand-soft: rgba(96, 165, 250, 0.16);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.16);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.16);
  --red: #fb7185;
  --red-soft: rgba(251, 113, 133, 0.16);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.16);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.16);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.24);
  --sidebar: rgba(11, 18, 32, 0.92);
  --sidebar-2: rgba(17, 24, 39, 0.9);
  --sidebar-line: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] body {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.98), rgba(17, 24, 39, 0.94) 48%, rgba(30, 41, 59, 0.92)),
    linear-gradient(90deg, rgba(96, 165, 250, 0.1), rgba(52, 211, 153, 0.04), rgba(167, 139, 250, 0.08)),
    var(--bg);
  color: var(--ink);
}

html[data-theme="dark"] .sidebar {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(17, 24, 39, 0.88)),
    var(--sidebar);
  color: var(--ink);
  border-right-color: var(--sidebar-line);
  box-shadow: 1px 0 0 rgba(255, 255, 255, 0.03) inset;
}

html[data-theme="dark"] .brand,
html[data-theme="dark"] .nav-link,
html[data-theme="dark"] .text-button,
html[data-theme="dark"] .icon-button,
html[data-theme="dark"] .article-actions button {
  color: var(--ink);
}

html[data-theme="dark"] .brand small,
html[data-theme="dark"] .nav-link,
html[data-theme="dark"] .service-card small,
html[data-theme="dark"] .ticket-form label > span,
html[data-theme="dark"] .field-block > span,
html[data-theme="dark"] .modal-form label,
html[data-theme="dark"] .modal-note {
  color: var(--muted);
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .portal-switch button.active,
html[data-theme="dark"] .theme-switch button.active,
html[data-theme="dark"] .settings-tabs button.active {
  background: rgba(30, 41, 59, 0.96);
  color: var(--brand-deep);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24), inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .portal-switch,
html[data-theme="dark"] .theme-switch,
html[data-theme="dark"] .segmented,
html[data-theme="dark"] .settings-tabs {
  border-color: var(--line);
  background: rgba(15, 23, 42, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active {
  background: rgba(96, 165, 250, 0.12);
  color: var(--ink);
  border-color: rgba(96, 165, 250, 0.2);
}

html[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, rgba(11, 18, 32, 0.96), rgba(11, 18, 32, 0.78) 74%, rgba(11, 18, 32, 0));
}

html[data-theme="dark"] .top-actions,
html[data-theme="dark"] .auth-banner,
html[data-theme="dark"] .service-panel,
html[data-theme="dark"] .quick-panel,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .queue-panel,
html[data-theme="dark"] .ticket-detail,
html[data-theme="dark"] .kb-filters,
html[data-theme="dark"] .kb-results,
html[data-theme="dark"] .sidebar-panel,
html[data-theme="dark"] .modal-panel {
  border-color: var(--line);
  background: rgba(17, 24, 39, 0.86);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .service-card,
html[data-theme="dark"] .score-card,
html[data-theme="dark"] .shortcut-stack a,
html[data-theme="dark"] .shortcut-stack button,
html[data-theme="dark"] .article-card,
html[data-theme="dark"] .focus-item,
html[data-theme="dark"] .suggestion,
html[data-theme="dark"] .license-card,
html[data-theme="dark"] .license-row,
html[data-theme="dark"] .license-user-card,
html[data-theme="dark"] .license-contract-card,
html[data-theme="dark"] .license-action-card,
html[data-theme="dark"] .template-card,
html[data-theme="dark"] .notification-log-card,
html[data-theme="dark"] .smtp-card,
html[data-theme="dark"] .schedule-card,
html[data-theme="dark"] .setting-card,
html[data-theme="dark"] .config-card,
html[data-theme="dark"] .rule-card,
html[data-theme="dark"] .ticket-view-button,
html[data-theme="dark"] .ticket-tabs button,
html[data-theme="dark"] .queue-summary,
html[data-theme="dark"] .requester-card,
html[data-theme="dark"] .requester-history button,
html[data-theme="dark"] .mini-feed div,
html[data-theme="dark"] .property-list div,
html[data-theme="dark"] .asset-row,
html[data-theme="dark"] .ticket-row,
html[data-theme="dark"] .contract-row,
html[data-theme="dark"] .notification-card,
html[data-theme="dark"] .dependency-node,
html[data-theme="dark"] .lifecycle-card,
html[data-theme="dark"] .agreement-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .exposure-card,
html[data-theme="dark"] .detail-stat,
html[data-theme="dark"] .submitted-fields div,
html[data-theme="dark"] .list-controls,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .settings-item,
html[data-theme="dark"] .article-actions button {
  border-color: var(--line);
  background: rgba(21, 31, 49, 0.88);
  color: var(--ink);
}

html[data-theme="dark"] .ticket-row.active {
  border-color: rgba(96, 165, 250, 0.46);
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.24), rgba(21, 31, 49, 0.92));
}

html[data-theme="dark"] .ticket-view-button.active,
html[data-theme="dark"] .ticket-tabs button.active,
html[data-theme="dark"] .composer-mode button.active {
  background: rgba(96, 165, 250, 0.14);
  color: var(--brand-deep);
}

html[data-theme="dark"] .composer-mode {
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--line);
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .global-search input {
  border-color: var(--line-strong);
  background: rgba(15, 23, 42, 0.84);
  color: var(--ink);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #748195;
}

html[data-theme="dark"] .text-button,
html[data-theme="dark"] .icon-button {
  border-color: var(--line);
  background: rgba(30, 41, 59, 0.86);
}

html[data-theme="dark"] .text-button:hover,
html[data-theme="dark"] .icon-button:hover,
html[data-theme="dark"] .shortcut-stack a:hover,
html[data-theme="dark"] .shortcut-stack button:hover,
html[data-theme="dark"] .kb-filters button:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(37, 99, 235, 0.18);
}

html[data-theme="dark"] .policy-box,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .exposure-card {
  background: linear-gradient(180deg, rgba(21, 31, 49, 0.92), rgba(15, 23, 42, 0.92));
}

html[data-theme="dark"] .asset-row.header,
html[data-theme="dark"] .license-row.header,
html[data-theme="dark"] .contract-row.header {
  background: transparent;
}

html[data-theme="dark"] .timeline-item::before {
  border-color: #0f172a;
}

html[data-theme="dark"] .timeline-item.internal {
  border-left-color: rgba(251, 191, 36, 0.72);
  background: rgba(120, 53, 15, 0.26);
}

html[data-theme="dark"] .timeline-item.internal strong {
  color: #fde68a;
}

@media (max-width: 760px) {
  .theme-switch {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }
}

@media (max-width: 520px) {
  .section-actions .text-button,
  .section-actions .primary-action {
    white-space: normal;
  }
}

/* Compact operations layout: flatter Windows-style panes, fewer bubbles. */
:root {
  --radius: 6px;
  --shadow: 0 12px 28px rgba(31, 35, 40, 0.08);
  --shadow-soft: 0 4px 14px rgba(31, 35, 40, 0.06);
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.kb-filters,
.kb-results,
.settings-tabs,
.settings-item,
.setting-card,
.service-card,
.ticket-row,
.asset-row,
.license-row,
.contract-row,
.article-card,
.focus-item,
.suggestion,
.modal-panel {
  border-radius: 6px;
  box-shadow: none;
}

.compact-badge,
.status-badge,
.priority-badge,
.sla-badge,
.ticket-view-button b {
  border-radius: 4px;
}

.primary-action,
.text-button,
.icon-button,
.nav-link,
.settings-tabs button,
.theme-switch button,
.segmented button {
  border-radius: 4px;
}

.queue-panel,
.ticket-detail {
  padding: 14px;
}

.ticket-workspace-list {
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 10px;
}

.ticket-view-button {
  padding: 8px 9px;
  border-left-width: 2px;
  background: transparent;
}

.ticket-view-button small,
.queue-summary span {
  display: none;
}

.ticket-view-button.active {
  background: rgba(37, 99, 235, 0.06);
  box-shadow: none;
}

.queue-summary {
  padding: 8px 0 10px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.queue-summary h3 {
  font-size: 15px;
}

.ticket-results .list-controls {
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 8px;
}

.ticket-results .list-filter-grid {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-row {
  padding: 10px 8px;
  border-width: 0 0 1px;
  background: transparent;
}

.ticket-row:hover {
  background: rgba(37, 99, 235, 0.05);
  transform: none;
}

.ticket-row.active {
  border-color: var(--line);
  background: rgba(37, 99, 235, 0.08);
  box-shadow: inset 2px 0 0 var(--brand);
}

.ticket-row-side {
  display: grid;
  justify-items: end;
  gap: 3px;
  min-width: 94px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.ticket-row-side b {
  color: var(--ink);
  font-size: 11px;
}

.ticket-row-side small {
  margin: 0;
  white-space: nowrap;
}

.ticket-tabs {
  margin-bottom: 10px;
}

.ticket-tabs button {
  min-width: 136px;
  padding: 8px;
  border-radius: 5px;
  box-shadow: none;
}

.detail-top {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-top h2 {
  font-size: 21px;
}

.detail-subtitle {
  max-width: 850px;
  font-size: 13px;
  line-height: 1.45;
}

.detail-actions {
  align-items: flex-start;
  gap: 8px;
}

.action-menu {
  position: relative;
}

.ticket-expand-toggle {
  min-width: 38px;
  min-height: 38px;
}

.action-menu summary {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.86);
  color: #273243;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 210px;
  display: grid;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 16px 32px rgba(31, 35, 40, 0.16);
}

.action-menu-list button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
}

.action-menu-list button:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.detail-grid {
  margin-top: 12px;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

.detail-stat {
  padding: 8px 0;
  border-width: 0 0 1px;
  border-radius: 0;
  background: transparent;
}

.ticket-workspace-grid {
  grid-template-columns: minmax(0, 1fr) minmax(250px, 320px);
  gap: 12px;
}

.activity-card,
.side-card,
.submitted-fields div,
.requester-card,
.requester-history button,
.mini-feed div,
.property-list div {
  border-radius: 5px;
  box-shadow: none;
}

.activity-card,
.side-card {
  padding: 14px;
}

.timeline-item {
  padding-left: 14px;
}

.reply-box textarea {
  min-height: 112px;
}

.property-section {
  gap: 8px;
}

html[data-theme="dark"] .ticket-row,
html[data-theme="dark"] .ticket-view-button,
html[data-theme="dark"] .queue-summary,
html[data-theme="dark"] .detail-stat {
  background: transparent;
}

html[data-theme="dark"] .ticket-row:hover,
html[data-theme="dark"] .ticket-row.active,
html[data-theme="dark"] .ticket-view-button.active {
  background: rgba(96, 165, 250, 0.11);
}

html[data-theme="dark"] .action-menu summary {
  border-color: var(--line);
  background: rgba(30, 41, 59, 0.86);
  color: var(--ink);
}

html[data-theme="dark"] .action-menu-list {
  background: var(--surface-2);
}

@media (max-width: 1100px) {
  .ticket-workspace-list,
  .ticket-workspace-grid {
    grid-template-columns: 1fr;
  }

  .ticket-view-rail {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .rail-head {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .top-actions {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 0.32fr);
  }

  .ticket-row {
    grid-template-columns: 1fr;
  }

  .ticket-row-side {
    justify-items: start;
    text-align: left;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .action-menu-list {
    right: auto;
    left: 0;
  }
}

.nav-section-title {
  display: block;
  margin: 8px 2px 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.primary-nav {
  overflow: hidden;
}

body[data-portal-mode="user"] .primary-nav .agent-nav,
body[data-portal-mode="user"] .workspace-section-title,
body[data-portal-mode="agent"] .primary-nav .user-nav,
body[data-portal-mode="agent"] .user-section-title {
  display: none !important;
}

body[data-auth-role="user"] .primary-nav .agent-nav,
body[data-auth-role="user"] .workspace-section-title {
  display: none !important;
}

body[data-auth-role="agent"] .admin-only-nav {
  display: none !important;
}

.agent-nav [hidden],
.workspace-section-title[hidden] {
  display: none !important;
}

.agent-access-head {
  align-items: flex-start;
}

.agent-access-head p:not(.eyebrow) {
  max-width: 680px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.agent-access-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}

.agent-access-profile-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agent-access-profile-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.agent-access-profile-card-head > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.agent-access-profile-card-head strong {
  color: var(--ink);
  font-size: 14px;
}

.agent-access-profile-card-head small,
.agent-access-profile-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.agent-access-profile-card p {
  min-height: 34px;
  margin: 10px 0;
}

.agent-access-section-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.agent-access-assignment-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.compact-section-title {
  margin-bottom: 8px;
}

.compact-section-title h4 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.compact-section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.agent-access-assignment-list {
  display: grid;
  gap: 6px;
  max-height: 460px;
  overflow: auto;
}

.agent-access-assignment-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(180px, 240px) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.agent-access-assignment-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.agent-access-assignment-row strong,
.agent-access-assignment-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-access-assignment-row strong {
  color: var(--ink);
  font-size: 13px;
}

.agent-access-assignment-row small {
  color: var(--muted);
  font-size: 11px;
}

.agent-access-assignment-row label {
  min-width: 0;
}

.agent-access-assignment-row select {
  width: 100%;
  min-height: 34px;
}

html[data-theme="dark"] .agent-access-profile-card,
html[data-theme="dark"] .agent-access-assignment-row {
  background: var(--surface-2);
}

@media (max-width: 700px) {
  .agent-access-head {
    display: grid;
    gap: 10px;
  }

  .agent-access-head .primary-action {
    width: 100%;
  }

  .agent-access-assignment-row {
    grid-template-columns: 1fr;
  }

  .agent-access-assignment-row .compact-action {
    width: 100%;
  }
}

.ticket-essentials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.ticket-essentials span {
  display: inline-flex;
  gap: 6px;
  min-width: 0;
}

.ticket-essentials strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-menu {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
  z-index: 1;
}

.asset-row,
.license-row,
.contract-row,
.user-row,
.settings-item,
.settings-action-row {
  position: relative;
  overflow: visible;
}

.asset-row:has(.row-menu[open]),
.license-row:has(.row-menu[open]),
.contract-row:has(.row-menu[open]),
.user-row:has(.row-menu[open]),
.settings-item:has(.row-menu[open]),
.settings-action-row:has(.row-menu[open]) {
  z-index: 70;
}

.row-menu[open] {
  z-index: 120;
}

.row-menu summary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid rgba(31, 35, 40, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}

.row-menu[open] summary {
  border-color: rgba(37, 99, 235, 0.42);
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.row-menu summary::-webkit-details-marker {
  display: none;
}

.row-menu summary span {
  line-height: 1;
}

.row-menu summary em {
  font-style: normal;
}

.row-menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 500;
  min-width: 190px;
  display: grid;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 14px 28px rgba(31, 35, 40, 0.16);
}

.action-menu-list,
.row-menu-list,
.choice-dropdown-list {
  max-inline-size: calc(100vw - 16px);
  max-height: min(var(--menu-available-height, 320px), calc(100dvh - 16px));
  overflow-y: auto;
}

.menu-opens-upward > .action-menu-list,
.menu-opens-upward > .row-menu-list,
.menu-opens-upward > .choice-dropdown-list {
  top: auto;
  bottom: calc(100% + 6px);
}

.menu-align-start > .action-menu-list,
.menu-align-start > .row-menu-list,
.menu-align-start > .choice-dropdown-list {
  right: auto;
  left: 0;
  inset-inline: auto;
}

.menu-align-end > .action-menu-list,
.menu-align-end > .row-menu-list,
.menu-align-end > .choice-dropdown-list {
  right: 0;
  left: auto;
  inset-inline: auto;
}

/* Keep menu actions above scrollable table panels instead of expanding their container. */
details.menu-viewport-positioned > .action-menu-list,
details.menu-viewport-positioned > .row-menu-list,
details.menu-viewport-positioned > .choice-dropdown-list {
  position: fixed;
  top: var(--menu-fixed-top);
  right: auto;
  bottom: auto;
  left: var(--menu-fixed-left);
  inset-inline: auto;
  width: var(--menu-fixed-width);
}

.timeline-item .timeline-entry-title {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  margin-top: 0;
  gap: 5px;
}

.timeline-note-edit-button {
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
}

.timeline-note-edit-button .ticket-edit-icon {
  width: 10px;
  height: 10px;
}

.timeline-note-editor {
  display: grid;
  gap: 7px;
}

.timeline-note-editor textarea {
  min-height: 76px;
  resize: vertical;
}

.timeline-note-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-menu-list button {
  min-height: 32px;
  padding: 0 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
}

.row-menu-list button:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.action-menu-list button:disabled,
.row-menu-list button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.action-menu-list button:disabled:hover,
.row-menu-list button:disabled:hover {
  background: transparent;
  color: var(--muted);
}

.action-menu:not([open]) .action-menu-list,
.row-menu:not([open]) .row-menu-list {
  display: none;
}

.action-menu[open] .action-menu-list,
.row-menu[open] .row-menu-list {
  display: grid;
}

.settings-action-row .row-menu {
  justify-self: start;
}

html[data-theme="dark"] .row-menu summary {
  border-color: var(--line);
  background: rgba(30, 41, 59, 0.86);
  color: var(--ink);
}

html[data-theme="dark"] .row-menu-list {
  background: var(--surface-2);
}

@media (max-width: 760px) {
  .nav-section-title {
    width: 100%;
  }

  .row-menu,
  .row-menu summary {
    width: 100%;
  }

  .row-menu-list {
    right: auto;
    left: 0;
    min-width: min(220px, 86vw);
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: relative;
    top: auto;
    z-index: 1;
  }

  .topbar {
    top: 0;
  }
}

@media (max-width: 760px) {
  .sidebar {
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 10px;
    overflow: visible;
  }

  .brand {
    width: 100%;
    min-width: 0;
  }

  .primary-nav {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-group {
    flex: 0 0 auto;
    display: flex !important;
    gap: 6px;
    overflow: visible;
  }

  .nav-link {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    height: 36px;
    white-space: nowrap;
  }
}

/* Full settings console */
.settings-tabs {
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 2fr);
  align-items: stretch;
  gap: 8px;
  padding: 8px;
}

.settings-search {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.settings-search span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.settings-search input {
  min-height: 36px;
  width: 100%;
  border-radius: 4px;
}

.settings-tab-list {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(98px, 1fr));
  gap: 6px;
}

.settings-tab-list button {
  min-width: 0;
  padding: 0 8px;
  overflow-wrap: anywhere;
}

.settings-map {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.settings-map-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.settings-map-card:hover {
  border-color: rgba(37, 99, 235, 0.28);
  background: rgba(37, 99, 235, 0.06);
}

.settings-map-card strong,
.settings-section strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.settings-map-card span,
.settings-map-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.settings-section {
  display: grid;
  gap: 10px;
  padding-top: 2px;
}

.settings-smtp {
  margin: 0;
}

.settings-grid .setting-card {
  min-width: 0;
}

.setting-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.setting-card-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-card-with-action > div {
  min-width: 0;
}

.modal-panel {
  width: min(900px, 100%);
}

.new-ticket-modal {
  width: min(960px, 100%);
}

.new-ticket-modal .ticket-form {
  margin-top: var(--space-3);
}

.new-ticket-modal .ticket-form-status {
  justify-content: flex-start;
}

.modal-form textarea {
  resize: vertical;
}

html[data-theme="dark"] .settings-map-card {
  border-color: var(--line);
  background: rgba(21, 31, 49, 0.88);
  color: var(--ink);
}

html[data-theme="dark"] .settings-map-card span,
html[data-theme="dark"] .settings-map-card small,
html[data-theme="dark"] .setting-card small,
html[data-theme="dark"] .settings-search span {
  color: var(--muted);
}

@media (max-width: 980px) {
  .settings-tabs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .settings-map,
  .settings-grid,
  .settings-tab-list {
    grid-template-columns: 1fr;
  }

  .settings-map-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    overflow-x: auto;
  }

  .brand {
    width: auto;
    min-width: 132px;
  }

  .primary-nav {
    width: auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
  }

  .nav-section-title,
  .sidebar-panel,
  .session-panel {
    display: none;
  }

  .nav-group {
    width: auto;
    display: flex !important;
    gap: 6px;
    overflow: visible;
  }

  .nav-link {
    width: auto;
    min-width: max-content;
  }

  .topbar {
    top: 0;
  }
}

/* Action compaction pass: make content and operational fields the priority. */
.section-actions {
  align-items: center;
  flex-wrap: nowrap;
}

.section-actions .primary-action {
  flex: 0 0 auto;
}

.section-actions .page-menu,
.settings-action-row .row-menu,
.reply-actions .row-menu,
.article-actions .row-menu {
  flex: 0 0 auto;
}

.action-menu summary em,
.row-menu summary em {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.action-menu summary,
.row-menu summary {
  min-width: 38px;
  justify-content: center;
}

.page-menu .row-menu-list {
  min-width: 210px;
}

.reply-actions {
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 6px;
}

.reply-actions > .reply-utility-actions,
.reply-actions > .reply-submit-group {
  flex: 0 1 auto;
}

.reply-utility-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.reply-submit-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.reply-submit-group .primary-action {
  min-width: 0;
  padding-inline: 14px;
  justify-content: center;
}

.reply-submit-group .submit-menu summary {
  min-width: 38px;
  justify-content: center;
}

.reply-submit-group .row-menu-list {
  min-width: 190px;
}

.requester-card .requester-facts span {
  display: grid;
  gap: 2px;
}

.requester-card .requester-facts b {
  display: block;
}

.article-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.rule-actions,
.template-card .row-actions {
  flex-wrap: nowrap;
}

.schedule-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.schedule-card > span {
  grid-column: 1 / 2;
}

.asset-row {
  grid-template-columns: minmax(0, 1.32fr) minmax(0, 0.98fr) minmax(0, 1.06fr) minmax(0, 0.88fr) minmax(0, 1.12fr) 44px;
}

.license-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(135px, 0.98fr) minmax(0, 1.18fr) minmax(0, 0.9fr) minmax(0, 0.72fr) 44px;
}

.contract-row {
  grid-template-columns: minmax(0, 1.48fr) minmax(0, 1.18fr) minmax(0, 0.84fr) minmax(0, 0.86fr) minmax(0, 0.7fr) 44px;
}

.asset-row .row-actions,
.license-row .row-actions,
.contract-row .row-actions {
  flex-wrap: nowrap;
  justify-content: center;
}

.asset-row.header span:last-child,
.license-row.header span:last-child,
.contract-row.header span:last-child {
  text-align: center;
}

.asset-row strong small,
.asset-row span small,
.license-row strong small,
.license-row span small,
.contract-row strong small,
.contract-row span small {
  white-space: normal;
}

.settings-action-row {
  justify-content: flex-start;
}

.settings-action-row .row-menu summary,
.section-actions .row-menu summary,
.reply-actions .row-menu summary,
.article-actions .row-menu summary {
  width: 38px;
  padding-inline: 0;
}

@media (min-width: 1100px) {
  .asset-layout,
  .licenses-layout,
  .contracts-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  }

  .automation-layout,
  .communication-layout {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 300px);
  }
}

@media (max-width: 760px) {
  .section-actions {
    justify-content: flex-end;
  }

  .section-actions > * {
    flex: 0 0 auto;
  }

  .section-actions .primary-action {
    min-width: 132px;
  }

  .row-menu,
  .row-menu summary {
    width: auto;
  }

  .article-actions {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .asset-row,
  .license-row,
  .contract-row,
  .schedule-card {
    grid-template-columns: 1fr auto;
  }

  .asset-row.header,
  .license-row.header,
  .contract-row.header {
    display: none;
  }

  .asset-row .row-actions,
  .license-row .row-actions,
  .contract-row .row-actions,
  .schedule-card .row-menu {
    justify-self: end;
  }

  .section-actions .page-menu .row-menu-list,
  .asset-row .row-actions .row-menu-list,
  .license-row .row-actions .row-menu-list,
  .contract-row .row-actions .row-menu-list,
  .schedule-card .row-menu-list {
    right: 0;
    left: auto;
  }
}

@media (max-width: 520px) {
  .asset-row,
  .license-row,
  .contract-row,
  .schedule-card {
    grid-template-columns: 1fr;
  }

  .asset-row .row-actions,
  .license-row .row-actions,
  .contract-row .row-actions,
  .schedule-card .row-menu {
    justify-self: start;
  }

  .asset-row .row-actions .row-menu-list,
  .license-row .row-actions .row-menu-list,
  .contract-row .row-actions .row-menu-list,
  .schedule-card .row-menu-list {
    right: auto;
    left: 0;
  }
}

/* Ticket workspace density pass: keep the focus on ticket content. */
.agent-grid {
  grid-template-columns: minmax(320px, 0.58fr) minmax(0, 1.42fr);
  gap: 12px;
}

.queue-panel,
.ticket-detail {
  min-width: 0;
  padding: 12px;
}

.queue-toolbar {
  min-width: 0;
  margin-bottom: 10px;
  gap: 10px;
}

.agent-grid > *,
.agent-workspace-title,
.ticket-list,
.ticket-workspace-list,
.ticket-results {
  min-width: 0;
}

.queue-toolbar select {
  width: 142px;
  height: 34px;
  font-size: 12px;
}

.ticket-workspace-list {
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 8px;
}

.rail-head {
  gap: 6px;
}

.rail-head .text-button {
  min-height: 28px;
}

.ticket-view-button {
  min-height: 34px;
  padding: 7px 8px;
  gap: 7px;
}

.ticket-view-button b {
  min-width: 24px;
  min-height: 21px;
  font-size: 10px;
}

.queue-summary {
  min-height: 34px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}

.queue-summary h3 {
  margin-top: 1px;
  font-size: 14px;
}

.queue-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid rgba(31, 35, 40, 0.09);
  border-radius: 4px;
  background: rgba(237, 241, 247, 0.8);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.ticket-results .tickets-list-controls {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0 0 6px;
  border: 0;
  background: transparent;
}

.ticket-results .tickets-list-controls .list-summary {
  display: none;
}

.ticket-results .tickets-list-controls .list-filter-grid {
  display: flex;
  justify-content: flex-end;
}

.ticket-results .tickets-list-controls .list-control {
  display: inline-grid;
  grid-template-columns: auto 78px;
  align-items: center;
  gap: 6px;
}

.ticket-results .tickets-list-controls .list-control span {
  font-size: 10px;
}

.ticket-results .tickets-list-controls .list-control select {
  height: 30px;
  padding: 0 8px;
  font-size: 11px;
}

.ticket-row {
  padding: 8px;
  gap: 8px;
}

.ticket-row strong {
  font-size: 12px;
}

.ticket-row small {
  margin-top: 3px;
}

.ticket-row-side {
  min-width: 76px;
}

.ticket-tabs {
  gap: 6px;
  margin-bottom: 8px;
}

.ticket-tabs button {
  min-width: 126px;
  max-width: 190px;
  min-height: 34px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px;
  padding: 6px 7px;
}

.ticket-tabs span {
  grid-column: 1;
}

.ticket-tabs strong {
  grid-row: 1;
  grid-column: 2;
}

.ticket-tabs i {
  grid-row: 1;
  grid-column: 3;
  width: 18px;
  height: 18px;
}

.detail-top {
  gap: 10px;
  padding-bottom: 10px;
}

.detail-top h2 {
  font-size: 20px;
}

.detail-subtitle {
  margin-top: 6px;
  font-size: 13px;
}

.detail-actions .primary-action,
.detail-actions .action-menu summary {
  min-height: 34px;
}

.ticket-essentials {
  gap: 6px 14px;
  margin-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.submitted-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.submitted-fields div {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(248, 250, 252, 0.78);
}

.submitted-fields span {
  flex: 0 0 auto;
  font-size: 10px;
}

.submitted-fields strong {
  font-size: 12px;
}

.ticket-workspace-grid {
  margin-top: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 280px);
  gap: 12px;
}

.activity-card,
.side-card {
  padding: 12px;
}

.ticket-conversation {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.ticket-conversation .conversation-head {
  flex: 0 0 auto;
}

.ticket-conversation .timeline {
  max-height: clamp(104px, calc(100dvh - 390px), 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 10px 2px 0;
  border-bottom: 1px solid var(--line);
  scrollbar-gutter: stable;
}

.ticket-conversation .timeline.is-empty {
  padding-right: 0;
  border-bottom: 0;
}

.ticket-conversation .timeline.is-empty .empty-state {
  inline-size: 100%;
  box-sizing: border-box;
}

.ticket-conversation .timeline::-webkit-scrollbar {
  width: 9px;
}

.ticket-conversation .timeline::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.32);
  background-clip: content-box;
}

.ticket-conversation .timeline::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.45);
  background-clip: content-box;
}

.ticket-conversation .reply-box {
  flex: 0 0 auto;
}

.requester-card {
  display: grid;
  gap: 3px;
  padding: 9px;
}

.property-section {
  gap: 7px;
  padding-bottom: 10px;
}

.property-section + .property-section {
  padding-top: 10px;
}

.property-list {
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(31, 35, 40, 0.08);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.62);
}

.property-list div {
  display: grid;
  grid-template-columns: minmax(64px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 0;
  border-bottom: 1px solid rgba(31, 35, 40, 0.07);
  border-radius: 0;
  background: transparent;
}

.property-list div:last-child {
  border-bottom: 0;
}

.property-list span {
  font-size: 10px;
  text-transform: none;
}

.property-list strong {
  margin-top: 0;
  font-size: 12px;
}

html[data-theme="dark"] .queue-count,
html[data-theme="dark"] .submitted-fields div,
html[data-theme="dark"] .property-list {
  border-color: var(--line);
  background: rgba(30, 41, 59, 0.62);
}

html[data-theme="dark"] .inline-ticket-field select,
html[data-theme="dark"] .inline-ticket-field input,
html[data-theme="dark"] .toggle-field {
  border-color: var(--line);
  background: rgba(15, 23, 42, 0.82);
  color: var(--ink);
}

html[data-theme="dark"] .toggle-field input {
  background: rgba(71, 85, 105, 0.9);
}

html[data-theme="dark"] .toggle-field input:checked {
  background: var(--brand);
}

html[data-theme="dark"] .property-list div {
  border-bottom-color: var(--line);
  background: transparent;
}

@media (max-width: 1200px) {
  .agent-grid {
    grid-template-columns: minmax(300px, 0.64fr) minmax(0, 1.36fr);
  }

  .ticket-workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-conversation .timeline {
    max-height: clamp(104px, calc(100dvh - 370px), 360px);
  }
}

@media (max-width: 760px) {
  .agent-grid,
  .ticket-workspace-list {
    grid-template-columns: 1fr;
  }

  .ticket-view-rail {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .ticket-results .tickets-list-controls .list-filter-grid {
    justify-content: stretch;
  }

  .ticket-results .tickets-list-controls .list-control {
    width: 100%;
    grid-template-columns: auto minmax(82px, 0.32fr);
  }

  .submitted-fields div {
    width: 100%;
  }

  .ticket-conversation .timeline {
    max-height: clamp(96px, calc(100dvh - 350px), 260px);
  }
}

/* Visual audit pass: calmer panels, clearer ticket rows, reliable action menus. */
body {
  background:
    linear-gradient(180deg, #f6f8fb 0%, #eef3f8 58%, #edf4f1 100%),
    var(--bg);
}

.topbar {
  border-bottom: 1px solid rgba(31, 35, 40, 0.08);
  background: rgba(248, 250, 252, 0.88);
  box-shadow: 0 10px 24px rgba(31, 35, 40, 0.04);
}

.queue-panel,
.ticket-detail,
.work-card,
.activity-card,
.side-card {
  border-color: rgba(31, 35, 40, 0.1);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 10px 24px rgba(31, 35, 40, 0.05);
}

.agent-grid {
  gap: 14px;
}

.queue-panel,
.ticket-detail {
  border-radius: 7px;
}

.ticket-workspace-list {
  gap: 10px;
}

.ticket-view-rail {
  padding-right: 10px;
  border-right: 1px solid var(--line);
}

.ticket-view-button {
  min-height: 38px;
  border-color: transparent;
  background: transparent;
}

.ticket-view-button:hover {
  border-color: rgba(37, 99, 235, 0.18);
  background: rgba(37, 99, 235, 0.05);
}

.ticket-view-button.active {
  border-color: rgba(37, 99, 235, 0.22);
  border-left-color: var(--brand);
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.09), rgba(37, 99, 235, 0.03));
}

.ticket-results {
  gap: 8px;
}

.ticket-row {
  min-height: 76px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.7);
}

.ticket-row:hover {
  border-color: rgba(37, 99, 235, 0.18);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(31, 35, 40, 0.06);
}

.ticket-row.active {
  border-color: rgba(37, 99, 235, 0.28);
  background: #eef5ff;
  box-shadow: inset 3px 0 0 var(--brand), 0 8px 18px rgba(37, 99, 235, 0.08);
}

.ticket-row-main {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.ticket-row-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.ticket-row-head strong {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.ticket-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 0;
  color: var(--muted);
  line-height: 1.25;
}

.ticket-row-meta span {
  min-width: 0;
}

.ticket-row-meta span + span::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 8px 2px 0;
  border-radius: 50%;
  background: var(--muted-2);
}

.ticket-row-side {
  min-width: 88px;
  gap: 7px;
}

.ticket-status,
.ticket-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.ticket-status {
  background: var(--blue-soft);
  color: var(--blue);
}

.ticket-priority {
  border: 1px solid rgba(31, 35, 40, 0.08);
  background: rgba(248, 250, 252, 0.95);
  color: var(--muted);
}

.ticket-priority.tone-high,
.ticket-priority.tone-urgent {
  background: var(--red-soft);
  color: var(--red);
}

.ticket-priority.tone-medium {
  background: var(--amber-soft);
  color: var(--amber);
}

.ticket-priority.tone-low {
  background: var(--green-soft);
  color: var(--green);
}

.ticket-tabs {
  gap: 8px;
  margin-bottom: 12px;
  padding: 2px 2px 6px;
}

.ticket-tabs button {
  min-width: 176px;
  max-width: 260px;
  min-height: 44px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 6px;
  padding: 8px 9px;
  border-color: rgba(31, 35, 40, 0.1);
  border-radius: 7px;
  background: #ffffff;
}

.ticket-tabs button.active {
  border-color: rgba(37, 99, 235, 0.38);
  background: #eef5ff;
  box-shadow: inset 0 -3px 0 var(--brand), 0 7px 16px rgba(37, 99, 235, 0.08);
}

.ticket-tabs span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 4px;
  background: rgba(37, 99, 235, 0.09);
}

.ticket-tabs strong {
  font-size: 12px;
  line-height: 1.2;
}

.ticket-tabs i {
  border-radius: 4px;
}

.ticket-tabs i:hover {
  background: rgba(31, 35, 40, 0.08);
  color: var(--ink);
}

.ticket-tabs button[draggable="true"] {
  cursor: grab;
}

.ticket-tabs button[draggable="true"]:active {
  cursor: grabbing;
}

.ticket-tabs button.dragging {
  opacity: 0.45;
}

.ticket-tabs button.drag-over-before {
  box-shadow: inset 3px 0 0 var(--brand);
}

.ticket-tabs button.drag-over-after {
  box-shadow: inset -3px 0 0 var(--brand);
}

.action-menu summary,
.row-menu summary {
  min-width: 42px;
  min-height: 36px;
  border-color: rgba(31, 35, 40, 0.14);
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}

.action-menu summary:hover,
.row-menu summary:hover,
.action-menu[open] summary,
.row-menu[open] summary {
  border-color: rgba(37, 99, 235, 0.4);
  background: #eef5ff;
  color: var(--brand);
}

.action-menu-list,
.row-menu-list {
  z-index: 2000;
  border-color: rgba(31, 35, 40, 0.12);
  background: #ffffff;
  box-shadow: 0 18px 38px rgba(31, 35, 40, 0.18);
}

.action-menu-list button,
.row-menu-list button {
  min-height: 35px;
  font-weight: 650;
}

.action-menu[open],
.row-menu[open],
.detail-actions,
.row-actions,
.section-actions {
  position: relative;
  z-index: 2100;
}

.asset-row .row-actions,
.license-row .row-actions,
.contract-row .row-actions,
.user-row .row-actions {
  overflow: visible !important;
}

.asset-row .row-actions .row-menu-list,
.license-row .row-actions .row-menu-list,
.contract-row .row-actions .row-menu-list,
.user-row .row-actions .row-menu-list {
  pointer-events: auto;
}

.user-row-profile-trigger,
.license-row [data-license-select],
.asset-row [data-asset-open],
.contract-row [data-contract-open] {
  cursor: pointer;
}

.user-row-profile-trigger:hover,
.license-row [data-license-select]:hover,
.asset-row [data-asset-open]:hover,
.contract-row [data-contract-open]:hover {
  color: var(--brand);
}

@media (max-width: 760px) {
  .agent-grid.ticket-detail-expanded .ticket-workspace-grid {
    grid-template-columns: 1fr;
  }

  .agent-grid.ticket-detail-expanded .inline-ticket-fields {
    grid-template-columns: 1fr;
  }

  .ticket-view-rail {
    padding-right: 0;
    padding-bottom: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ticket-row {
    grid-template-columns: 1fr;
  }

  .ticket-row-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    text-align: left;
  }

  .ticket-tabs button {
    min-width: 210px;
  }
}

html[data-theme="dark"] body {
  background:
    linear-gradient(180deg, #0f172a 0%, #111827 58%, #0f1f1d 100%),
    var(--bg);
}

html[data-theme="dark"] .queue-panel,
html[data-theme="dark"] .ticket-detail,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .ticket-tabs button,
html[data-theme="dark"] .action-menu-list,
html[data-theme="dark"] .row-menu-list {
  background: rgba(17, 24, 39, 0.94);
}

html[data-theme="dark"] .ticket-row {
  background: rgba(15, 23, 42, 0.72);
}

html[data-theme="dark"] .ticket-row.active,
html[data-theme="dark"] .ticket-tabs button.active,
html[data-theme="dark"] .action-menu summary:hover,
html[data-theme="dark"] .row-menu summary:hover,
html[data-theme="dark"] .action-menu[open] summary,
html[data-theme="dark"] .row-menu[open] summary {
  background: rgba(37, 99, 235, 0.18);
}

@media (max-width: 1320px) {
  .ticket-workspace-list {
    grid-template-columns: 1fr;
  }

  .ticket-view-rail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    padding-right: 0;
    padding-bottom: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .ticket-view-rail .rail-head {
    grid-column: 1 / -1;
  }

  .ticket-view-button {
    min-height: 36px;
  }

  .ticket-row {
    min-height: 82px;
  }
}

@media (min-width: 1321px) {
  .ticket-workspace-list {
    grid-template-columns: 132px minmax(0, 1fr);
  }
}

/* Final visual QA pass: make tablet widths intentional instead of half-desktop. */
@media (max-width: 980px) {
  .sidebar {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .brand {
    flex: 0 0 auto;
  }

  .primary-nav {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
  }

  .nav-section-title {
    display: none;
  }

  .session-panel,
  .sidebar-panel {
    display: none;
  }

  .primary-nav .nav-group {
    display: flex !important;
    flex: 0 0 auto;
    width: auto;
    gap: 6px;
  }

  body[data-portal-mode="user"] .primary-nav .agent-nav,
  body[data-portal-mode="user"] .workspace-section-title,
  body[data-portal-mode="agent"] .primary-nav .user-nav,
  body[data-portal-mode="agent"] .user-section-title,
  body[data-auth-role="user"] .primary-nav .agent-nav,
  body[data-auth-role="user"] .workspace-section-title {
    display: none !important;
  }

  .nav-link {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    white-space: nowrap;
  }

  .agent-grid {
    grid-template-columns: 1fr;
  }

  .ticket-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .ticket-tabs button {
    min-width: 154px;
  }
}

.primary-nav::-webkit-scrollbar,
.ticket-tabs::-webkit-scrollbar {
  height: 6px;
}

.primary-nav::-webkit-scrollbar-track,
.ticket-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.primary-nav::-webkit-scrollbar-thumb,
.ticket-tabs::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(31, 35, 40, 0.22);
}

.primary-nav::-webkit-scrollbar-thumb:hover,
.ticket-tabs::-webkit-scrollbar-thumb:hover {
  background: rgba(31, 35, 40, 0.34);
}

/* Menu stacking QA: only the active row should sit above neighbouring row actions. */
.row-actions {
  z-index: auto;
}

.asset-row:has(.row-menu[open]),
.license-row:has(.row-menu[open]),
.contract-row:has(.row-menu[open]),
.user-row:has(.row-menu[open]),
.settings-item:has(.row-menu[open]),
.settings-action-row:has(.row-menu[open]) {
  z-index: 2300;
}

.asset-row:has(.row-menu[open]) .row-actions,
.license-row:has(.row-menu[open]) .row-actions,
.contract-row:has(.row-menu[open]) .row-actions,
.user-row:has(.row-menu[open]) .row-actions,
.settings-item:has(.row-menu[open]) .row-actions,
.settings-action-row:has(.row-menu[open]) .row-actions {
  z-index: 2301;
}

.row-menu[open],
.action-menu[open] {
  z-index: 2302;
}

.row-menu[open] .row-menu-list,
.action-menu[open] .action-menu-list {
  z-index: 2303;
}

/* License allocation workspace */
.selected-license-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.selected-license-actions .primary-action,
.selected-license-actions .text-button {
  min-height: 34px;
}

.license-user-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.license-user-card .row-actions {
  justify-content: end;
}

.license-preview-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.license-preview-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.license-preview-heading > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.license-preview-heading strong,
.license-preview-heading span,
.license-preview-details dd {
  overflow-wrap: anywhere;
}

.license-preview-heading span,
.license-preview-details dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.license-preview-metrics,
.license-preview-details {
  margin: 0;
  display: grid;
  gap: 8px;
}

.license-preview-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.license-preview-metrics div {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-2);
}

.license-preview-metrics dt,
.license-preview-details dt {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
}

.license-preview-metrics dd,
.license-preview-details dd {
  margin: 3px 0 0;
  font-weight: 800;
}

.license-preview-details {
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.license-preview-details div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.license-preview-details dd {
  text-align: right;
  font-size: 0.84rem;
}

.license-preview-open {
  width: 100%;
  min-height: 34px;
  justify-content: center;
}

.license-contract-card dl {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.license-contract-card small {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 980px) {
  .license-contract-card dl {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .license-user-card {
    grid-template-columns: 1fr;
  }

  .selected-license-actions,
  .license-user-card .row-actions {
    justify-content: start;
  }

  .license-preview-heading {
    align-items: start;
  }

  .license-contract-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Focused settings controls */
.settings-option-list {
  gap: 8px;
}

.settings-item.direct-option {
  min-height: 58px;
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.settings-item.direct-option:hover,
.settings-item.direct-option:focus-visible {
  border-color: rgba(15, 108, 189, 0.34);
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  outline: none;
}

.settings-item.direct-option strong {
  font-size: 12px;
}

.settings-item.direct-option span,
.settings-item.direct-option small {
  font-size: 10.5px;
}

.compact-action {
  min-height: 32px;
  padding: 0 10px;
  white-space: nowrap;
}

.choice-dropdown-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-dropdown-field legend {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.choice-dropdown {
  position: relative;
  min-width: 0;
}

.choice-dropdown summary {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--field-height);
  height: var(--field-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 var(--field-padding-inline);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--field-text-size);
  font-weight: 600;
  line-height: 1.35;
  list-style: none;
  cursor: pointer;
}

.choice-dropdown summary::-webkit-details-marker {
  display: none;
}

.choice-dropdown summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  flex: 0 0 auto;
}

.choice-dropdown[open] summary {
  border-color: var(--active-border);
  background: var(--active-surface);
  box-shadow: none;
}

.choice-dropdown-list {
  position: absolute;
  z-index: 90;
  inset-inline: 0;
  top: calc(100% + 6px);
  display: grid;
  gap: 4px;
  box-sizing: border-box;
  min-width: 0;
  max-height: 240px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
}

/* A windowed form keeps its open multi-select above the form, without widening the dialog. */
.modal-panel details.choice-dropdown.menu-viewport-positioned > .choice-dropdown-list {
  z-index: 720;
}

.choice-dropdown-list label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.choice-dropdown-list label:hover {
  background: var(--surface-3);
}

.choice-dropdown-list label input {
  width: 16px;
  height: 16px;
}

.choice-dropdown-search {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.choice-dropdown-options {
  display: grid;
  gap: 4px;
}

.ticket-form-metadata {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.ticket-form-metadata .choice-dropdown-field.full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .ticket-form-metadata {
    grid-template-columns: minmax(0, 1fr);
  }
}

.choice-dropdown-empty {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

html[data-theme="dark"] .settings-item.direct-option {
  background: rgba(18, 24, 38, 0.92);
}

html[data-theme="dark"] .choice-dropdown summary,
html[data-theme="dark"] .choice-dropdown-list {
  background: rgba(18, 24, 38, 0.98);
  border-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .choice-dropdown-list label:hover {
  background: rgba(56, 189, 248, 0.1);
}

/* RandaDesk brand pass */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #edf5ff;
  --ink: #172033;
  --muted: #5d6676;
  --muted-2: #8993a4;
  --line: #dfe6f0;
  --line-strong: #c7d1df;
  --brand: #0f6cbd;
  --brand-2: #38bdf8;
  --brand-deep: #101827;
  --brand-soft: #e8f3ff;
  --violet: #6d5dfc;
  --violet-soft: #efedff;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.06);
  --radius: 7px;
  --sidebar: #111827;
  --sidebar-2: #172033;
  --sidebar-line: rgba(226, 232, 240, 0.12);
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(242, 247, 253, 0.94) 48%, rgba(238, 244, 251, 0.98) 100%),
    linear-gradient(105deg, rgba(56, 189, 248, 0.08), transparent 34%, rgba(109, 93, 252, 0.06) 100%),
    var(--bg);
}

.app-shell {
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  padding: 16px 12px;
  background:
    linear-gradient(180deg, rgba(31, 41, 65, 0.92), rgba(17, 24, 39, 0.98)),
    var(--sidebar);
  color: #eef5ff;
  border-right: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.12);
}

.brand {
  min-height: 48px;
  padding: 7px;
  border: 1px solid transparent;
}

.brand:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.16);
}

.brand b {
  color: #ffffff;
  font-size: 18px;
  font-weight: 750;
}

.brand small {
  color: #9fb2c9;
  font-size: 11px;
  font-weight: 650;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: block;
  padding: 0;
  overflow: hidden;
  border-radius: 10px;
  background: transparent;
  box-shadow: 0 10px 22px rgba(56, 189, 248, 0.18);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark::after,
.brand-mark span {
  display: none !important;
}

.nav-section-title {
  color: #7f93ad;
}

.nav-link {
  min-height: 38px;
  color: #cbd7e8;
  border-radius: 6px;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(15, 108, 189, 0.36), rgba(56, 189, 248, 0.12));
  color: #ffffff;
  box-shadow: inset 3px 0 0 #38bdf8;
}

.nav-link.active .nav-ico {
  background: #38bdf8;
  color: #082f49;
}

.sidebar-panel,
.session-panel {
  background: rgba(15, 23, 42, 0.52);
  border-color: rgba(148, 163, 184, 0.18);
  color: #e8f1ff;
}

.sidebar-panel p,
.session-panel span,
.session-panel small {
  color: #a8b6ca;
}

.topbar {
  background: rgba(250, 252, 255, 0.88);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.045);
}

.top-actions {
  min-width: 0;
  max-width: 100%;
}

.global-search {
  min-width: min(340px, 100%);
  max-width: 100%;
}

.topbar h1 {
  color: #111827;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--brand);
  font-weight: 760;
}

.primary-action {
  background: linear-gradient(135deg, #0f6cbd, #2563eb 58%, #6d5dfc);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.primary-action:hover {
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.23);
}

.text-button,
.icon-button,
.row-menu summary,
.action-menu summary {
  border-radius: 6px;
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.activity-card,
.side-card,
.settings-panel,
.modal-panel {
  border-color: rgba(15, 23, 42, 0.09);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.88) inset, 0 12px 30px rgba(15, 23, 42, 0.055);
}

.service-card {
  border-radius: 7px;
  border-color: rgba(15, 23, 42, 0.08);
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.service-card::after {
  background: linear-gradient(90deg, #0f6cbd, #38bdf8, #6d5dfc);
}

.service-card:hover {
  border-color: rgba(15, 108, 189, 0.28);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.metric-card,
.score-card,
.setting-card {
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

html[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #172033;
  --surface-3: #1d2a44;
  --ink: #e8eef8;
  --muted: #a7b3c5;
  --line: rgba(148, 163, 184, 0.2);
  --brand: #38bdf8;
  --brand-2: #60a5fa;
  --brand-deep: #dbeafe;
  --brand-soft: rgba(56, 189, 248, 0.15);
}

html[data-theme="dark"] .topbar,
html[data-theme="dark"] .service-panel,
html[data-theme="dark"] .quick-panel,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .queue-panel,
html[data-theme="dark"] .ticket-detail,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .modal-panel {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .service-card strong,
html[data-theme="dark"] .score-card strong,
html[data-theme="dark"] .metric-card strong,
html[data-theme="dark"] .setting-card strong {
  color: #f8fafc;
}

html[data-theme="dark"] .service-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .score-card,
html[data-theme="dark"] .setting-card {
  background: rgba(17, 24, 39, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

@media (max-width: 1220px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .top-actions {
    justify-content: stretch;
  }

  .global-search {
    flex: 1 1 280px;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    background: rgba(17, 24, 39, 0.96);
  }

  .brand {
    min-width: 154px;
  }

  .sidebar,
  .primary-nav,
  .ticket-tabs {
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar,
  .primary-nav::-webkit-scrollbar,
  .ticket-tabs::-webkit-scrollbar {
    display: none;
  }
}

/* Compact agent queue pass. Keep ticket content primary and reduce control noise. */
.queue-panel {
  padding: 10px;
}

.queue-toolbar {
  margin-bottom: 8px;
}

.queue-toolbar select {
  width: 136px;
  height: 34px;
  border-radius: 7px;
}

.ticket-workspace-list {
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 10px;
}

.ticket-view-rail {
  gap: 5px;
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.ticket-view-rail .rail-head {
  padding: 0 2px 4px;
}

.ticket-view-rail .rail-head strong {
  font-size: 11px;
}

.ticket-view-rail .rail-head .text-button {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 6px;
}

.ticket-view-button {
  min-height: 32px;
  padding: 6px 7px;
  gap: 6px;
  border-radius: 7px;
  border-left-width: 2px;
  background: transparent;
}

.ticket-view-button strong {
  font-size: 11px;
  line-height: 1.15;
}

.ticket-view-button small {
  display: none;
}

.ticket-view-button b {
  min-width: 22px;
  min-height: 20px;
  border-radius: 5px;
  font-size: 10px;
}

.ticket-view-button.active {
  box-shadow: inset 2px 0 0 var(--brand);
}

.ticket-results {
  gap: 5px;
}

.queue-summary {
  min-height: 42px;
  padding: 0 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.queue-summary h3 {
  margin: 1px 0 0;
  font-size: 15px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-summary-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.queue-new-ticket-action {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 11px;
}

.queue-summary-actions .list-control {
  display: grid;
  grid-template-columns: auto 74px;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.queue-summary-actions .list-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.queue-summary-actions .list-control select {
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 11px;
}

.queue-count {
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.ticket-row {
  min-height: 62px;
  grid-template-columns: minmax(0, 1fr) minmax(74px, auto);
  align-items: start;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
}

.ticket-row:hover {
  border-color: rgba(15, 118, 110, 0.18);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: none;
}

.ticket-row.active {
  border-color: rgba(37, 99, 235, 0.34);
  background: rgba(239, 246, 255, 0.78);
  box-shadow: inset 3px 0 0 var(--brand);
}

.ticket-row-main {
  gap: 5px;
}

.ticket-row .ticket-subject {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 12px;
  line-height: 1.2;
  white-space: normal;
  text-overflow: clip;
}

.ticket-row-meta {
  gap: 3px 6px;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.25;
}

.ticket-row-meta span + span::before {
  width: 2px;
  height: 2px;
  margin: 0 6px 2px 0;
}

.ticket-row-side {
  min-width: 74px;
  display: grid;
  gap: 5px;
  justify-items: end;
}

.ticket-pill-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.ticket-status,
.ticket-priority {
  min-height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  font-size: 9.5px;
  line-height: 1;
}

.ticket-sla-text {
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.empty-read-pane {
  min-height: 420px;
  border-radius: 7px;
  background: transparent;
}

@media (min-width: 1321px) {
  .ticket-workspace-list {
    grid-template-columns: 116px minmax(0, 1fr);
  }
}

@media (max-width: 1320px) {
  .ticket-workspace-list {
    grid-template-columns: 1fr;
  }

  .ticket-view-rail {
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
    padding-right: 0;
    padding-bottom: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .queue-summary {
    align-items: start;
  }

  .queue-summary-actions {
    align-items: end;
    flex-direction: column;
    gap: 5px;
  }

  .queue-summary-actions .list-control {
    grid-template-columns: auto 68px;
  }

  .ticket-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-row-side {
    justify-items: start;
  }

  .ticket-sla-text {
    text-align: left;
  }
}

body[data-auth-role="guest"] .app-shell {
  grid-template-columns: 1fr !important;
}

body[data-auth-role="guest"] .sidebar,
body[data-auth-role="guest"] .topbar,
body[data-auth-role="guest"] #authBanner {
  display: none !important;
}

body[data-auth-role="guest"] main {
  width: 100% !important;
  max-width: none !important;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 48px) !important;
}

body[data-auth-role="guest"] .view:not(#view-login) {
  display: none !important;
}

body[data-auth-role="guest"] #view-login.active {
  display: block !important;
}

body[data-auth-role="guest"] .login-shell {
  min-height: calc(100vh - clamp(36px, 8vw, 96px));
}
/* Final cascade lock: these rules must stay after the compact queue block. */
.settings-tabs {
  display: block;
}

.settings-search {
  display: grid;
  width: 100%;
  margin-bottom: 10px;
}

.settings-search input {
  width: 100%;
}

.settings-tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.agent-grid {
  grid-template-columns: minmax(390px, 0.72fr) minmax(0, 1.28fr);
}

.ticket-workspace-list {
  grid-template-columns: 1fr !important;
}

.ticket-view-rail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  padding-right: 0;
  padding-bottom: 8px;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.ticket-view-rail .rail-head {
  grid-column: 1 / -1;
}

.ticket-view-button {
  min-width: 0;
}

.ticket-view-button strong {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ticket-results {
  width: 100%;
}

.kb-results .list-controls {
  grid-column: 1 / -1;
}

.license-contract-card dl {
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.license-contract-card dl div,
.license-contract-card dt,
.license-contract-card dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.password-login-form[data-login-step="password"] {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.34fr);
}

.password-login-form[data-login-step="password"] .primary-action {
  grid-column: 1 / -1;
  width: 100%;
}

@media (max-width: 1180px) {
  .agent-grid {
    grid-template-columns: 1fr;
  }

  .knowledge-list-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .settings-tab-list {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .settings-tab-list button {
    flex: 0 0 auto;
  }

  .password-login-form[data-login-step="password"] {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1220px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    overflow-x: clip;
  }

  .top-actions {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .top-actions .global-search {
    flex: 1 1 280px;
    min-width: min(280px, 100%);
  }

  .theme-switch {
    flex: 0 0 auto;
  }
}

/* Security hardening pass: focused, responsive login surface. */
body[data-auth-role="guest"] {
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(236, 242, 249, 0.92)),
    var(--bg);
}

body[data-auth-role="guest"] .login-shell {
  align-items: center;
}

body[data-auth-role="guest"] .login-card {
  width: min(920px, 100%);
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.10);
}

body[data-auth-role="guest"] .login-hero {
  display: grid;
  gap: 8px;
}

body[data-auth-role="guest"] .login-hero .eyebrow {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  font-weight: 780;
}

body[data-auth-role="guest"] .login-hero h2 {
  max-width: 780px;
  margin: 0;
  color: #111827;
  font-size: clamp(34px, 6vw, 60px);
  line-height: 1.02;
  letter-spacing: 0;
}

body[data-auth-role="guest"] .login-subtitle {
  max-width: 660px;
  margin: 4px 0 0;
  color: #64748b;
  font-size: 15px;
  line-height: 1.55;
}

body[data-auth-role="guest"] .password-login-form,
body[data-auth-role="guest"] .login-state-card {
  border-color: rgba(37, 99, 235, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

body[data-auth-role="guest"] .password-login-form {
  grid-template-columns: minmax(260px, 1fr) auto;
  padding: 14px;
}

body[data-auth-role="guest"] .password-login-form[data-login-step="password"] {
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 0.48fr);
}

body[data-auth-role="guest"] .email-code-login-form {
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 0.32fr) auto;
}

body[data-auth-role="guest"] .password-login-form label {
  color: #475569;
  font-size: 12px;
}

body[data-auth-role="guest"] .password-login-form input {
  height: 46px;
  border-color: rgba(100, 116, 139, 0.34);
  border-radius: 8px;
  font-size: 15px;
}

body[data-auth-role="guest"] .password-login-form input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: none;
}

body[data-auth-role="guest"] .login-code-input {
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
}

.empty-read-pane-return {
  margin-top: var(--space-2);
}

body[data-auth-role="guest"] .password-login-form .primary-action,
body[data-auth-role="guest"] .login-state-card .primary-action {
  min-height: 46px;
  border-radius: 8px;
}

body[data-auth-role="guest"] .login-state-card {
  gap: 12px;
  padding: 20px;
}

body[data-auth-role="guest"] .login-state-card strong {
  font-size: clamp(17px, 2vw, 22px);
}

body[data-auth-role="guest"] .login-state-card span {
  max-width: 680px;
  color: #64748b;
  font-size: 15px;
}

body[data-auth-role="guest"] .password-login-links,
body[data-auth-role="guest"] .login-actions {
  gap: 10px;
}

body[data-auth-role="guest"] .login-method-note,
body[data-auth-role="guest"] .login-footnote {
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}

body[data-auth-role="guest"] .login-method-note {
  margin-top: -2px;
}

body[data-auth-role="guest"] .text-button {
  min-height: 42px;
  border-radius: 8px;
}

@media (max-width: 720px) {
  body[data-auth-role="guest"] main {
    padding: 16px !important;
  }

  body[data-auth-role="guest"] .login-card {
    padding: 20px;
    border-radius: 12px;
  }

  body[data-auth-role="guest"] .password-login-form,
  body[data-auth-role="guest"] .password-login-form[data-login-step="password"],
  body[data-auth-role="guest"] .email-code-login-form {
    grid-template-columns: 1fr;
  }

  body[data-auth-role="guest"] .password-login-form .primary-action {
    width: 100%;
  }
}

.text-button.danger-action,
.row-menu-list button.danger-action {
  color: var(--red);
}

.action-menu-list button.danger-action {
  color: var(--red);
}

.action-menu-list button.danger-action:hover {
  background: var(--red-soft);
  color: var(--red);
}

.deleted-ticket-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.deleted-ticket-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

.deleted-ticket-table th,
.deleted-ticket-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.3;
  text-align: left;
  vertical-align: middle;
}

.deleted-ticket-table th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.deleted-ticket-table tr:last-child td {
  border-bottom: 0;
}

.deleted-ticket-table th:nth-child(1),
.deleted-ticket-table td:nth-child(1) { width: 72px; }

.deleted-ticket-table th:nth-child(3),
.deleted-ticket-table td:nth-child(3),
.deleted-ticket-table th:nth-child(4),
.deleted-ticket-table td:nth-child(4) { width: 82px; }

.deleted-ticket-table th:nth-child(5),
.deleted-ticket-table td:nth-child(5) { width: 138px; }

.deleted-ticket-table th:nth-child(6),
.deleted-ticket-table td:nth-child(6) { width: 214px; }

.deleted-ticket-reference {
  color: var(--brand) !important;
  font-weight: 800;
  white-space: nowrap;
}

.deleted-ticket-subject {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deleted-ticket-time-left {
  color: var(--red) !important;
  font-weight: 700;
}

.deleted-ticket-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

.text-button.danger-action {
  border-color: rgba(196, 43, 28, 0.24);
  background: var(--red-soft);
}

.row-menu-list button.danger-action:hover {
  background: var(--red-soft);
  color: var(--red);
}

/* Queue UX compression: keep the daily triage path dense, readable, and action-led. */
.agent-grid {
  grid-template-columns: minmax(410px, 520px) minmax(0, 1fr);
  gap: 14px;
}

.agent-grid.ticket-detail-expanded {
  grid-template-columns: minmax(0, 1fr);
}

.agent-grid.ticket-detail-expanded .queue-panel {
  display: none;
}

@keyframes ticket-viewport-expand {
  from {
    opacity: 0.82;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ticket-viewport-collapse {
  from {
    opacity: 0.84;
    transform: translateX(8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ticket-queue-reveal {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.agent-grid.ticket-view-expanding .ticket-detail {
  animation: ticket-viewport-expand 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.agent-grid.ticket-view-collapsing .ticket-detail {
  animation: ticket-viewport-collapse 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.agent-grid.ticket-view-collapsing .queue-panel {
  animation: ticket-queue-reveal 180ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.agent-grid.ticket-detail-expanded .ticket-detail {
  min-height: calc(100vh - 112px);
}

.agent-grid.ticket-detail-expanded .ticket-workspace-grid {
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 16px;
}

.agent-grid.ticket-detail-expanded .ticket-conversation .timeline {
  max-height: clamp(104px, calc(100dvh - 440px), 430px);
}

.agent-grid.ticket-detail-expanded .reply-box textarea {
  min-height: 150px;
}

.agent-grid.ticket-detail-expanded .inline-ticket-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.queue-panel {
  padding: 12px;
}

.queue-list-controls {
  --queue-control-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line);
}

.queue-list-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 4px;
  min-width: 0;
}

.queue-page-size-control {
  min-width: 0;
}

.queue-page-size-control .list-control {
  margin: 0;
}

.global-search-results {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(440px, var(--popup-available-height, 440px), calc(100dvh - 16px));
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.global-search-result {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.global-search-result:hover,
.global-search-result.active {
  background: var(--brand-soft);
}

.global-search-result:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.global-search-result-type {
  overflow: hidden;
  color: var(--brand);
  font-size: 10px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-search-result-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.global-search-result-copy strong,
.global-search-result-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-search-result-copy strong {
  font-size: 12px;
}

.global-search-result-copy small,
.global-search-empty {
  color: var(--muted);
  font-size: 11px;
}

.global-search-empty {
  margin: 0;
  padding: 12px 10px;
  line-height: 1.4;
}

.queue-page-size-control .list-control {
  display: grid;
  grid-template-columns: auto 64px;
  align-items: center;
  gap: 4px;
  height: var(--queue-control-height);
}

.queue-page-size-control .list-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.queue-page-size-control .list-control select {
  width: 58px;
  height: var(--queue-control-height);
  min-height: var(--queue-control-height);
  max-height: var(--queue-control-height);
  box-sizing: border-box;
  padding: 0 6px;
}

.queue-list-actions .queue-refresh-button,
.queue-list-actions .queue-deleted-tickets-button {
  flex: 0 0 var(--queue-control-height);
  width: var(--queue-control-height);
  min-width: var(--queue-control-height);
  height: var(--queue-control-height);
  min-height: var(--queue-control-height);
  max-height: var(--queue-control-height);
  box-sizing: border-box;
}

.queue-deleted-tickets-button {
  padding: 0;
}

.queue-deleted-tickets-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ticket-workspace-list {
  grid-template-columns: 1fr !important;
  gap: 9px;
}

.ticket-view-rail {
  display: flex !important;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 4px;
  padding: 0;
  border-right: 0;
  border-bottom: 0;
}

.ticket-view-button {
  flex: 1 1 calc(33.333% - 3px);
  min-width: 0;
  min-height: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 7px;
  border-left-width: 2px;
  background: transparent;
}

.ticket-view-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.15;
}

.ticket-view-button small {
  display: none;
}

.ticket-view-button b {
  min-width: 20px;
  min-height: 18px;
  border-radius: 5px;
  font-size: 10px;
}

@media (max-width: 680px) {
  .ticket-view-button {
    flex-basis: calc(50% - 2px);
  }
}

.ticket-view-button.active {
  background: rgba(37, 99, 235, 0.06);
  box-shadow: inset 2px 0 0 var(--brand);
}

.ticket-results {
  gap: 8px;
}

.queue-summary {
  min-height: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 0 0 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.queue-summary h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
}

.queue-summary span {
  display: none;
  max-width: 300px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
}

.queue-summary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.queue-new-ticket-action {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 11px;
}

.queue-count {
  height: var(--queue-control-height, 28px);
  min-height: var(--queue-control-height, 28px);
  max-height: var(--queue-control-height, 28px);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.queue-summary-actions .list-control {
  display: grid;
  grid-template-columns: auto 58px;
  align-items: center;
  gap: 5px;
  margin: 0;
}

.queue-summary-actions .list-control span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.queue-summary-actions .list-control select {
  height: 30px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 11px;
}

.queue-empty-state {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.72);
  text-align: center;
}

.queue-empty-state strong,
.empty-read-pane strong {
  color: var(--ink);
  font-size: 14px;
}

.queue-empty-state span,
.empty-read-pane span {
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.queue-empty-state div {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.empty-read-pane {
  min-height: 420px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.54);
  text-align: center;
}

html[data-theme="dark"] .ticket-view-button.active,
html[data-theme="dark"] .queue-empty-state,
html[data-theme="dark"] .empty-read-pane {
  background: rgba(96, 165, 250, 0.08);
}

@media (max-width: 1180px) {
  .agent-grid {
    grid-template-columns: 1fr;
  }

  .empty-read-pane {
    min-height: 180px;
  }
}

@media (max-width: 460px) {
  .queue-list-controls {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .queue-list-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(82px, auto) auto 36px;
  }

  .ticket-view-button {
    flex-basis: calc(50% - 4px);
  }

  .queue-empty-state {
    min-height: 132px;
    padding: 16px;
  }

  .queue-empty-state span {
    max-width: 100%;
  }
}

/* Production UX layout pass: shared spacing, clearer hierarchy, and responsive task surfaces. */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --shell-sidebar: 244px;
  --content-max: 1500px;
  --control-height: 38px;
  --panel-border: rgba(15, 23, 42, 0.1);
  --panel-bg: rgba(255, 255, 255, 0.97);
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

body {
  background: #f4f7fb;
}

html,
body {
  overflow-x: hidden;
}

.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 1000;
  transform: translateY(-160%);
  padding: var(--space-2) var(--space-3);
  border-radius: 7px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.skip-link:focus {
  transform: translateY(0);
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  outline-offset: 0;
  box-shadow: none;
}

main:focus {
  outline: 3px solid #2563eb;
  outline-offset: -3px;
}

.app-shell {
  grid-template-columns: var(--shell-sidebar) minmax(0, 1fr);
}

main {
  width: 100%;
  margin: 0;
  padding: 0 var(--space-6) var(--space-8);
}

.sidebar {
  padding: var(--space-4) var(--space-3);
  box-shadow: none;
}

.primary-nav {
  margin-top: var(--space-4);
  gap: var(--space-2);
}

.nav-group {
  gap: var(--space-1);
}

.nav-section-title {
  margin-top: var(--space-2);
  font-size: 10px;
}

.nav-link {
  min-height: 36px;
  height: auto;
  padding: 0 var(--space-2);
  border-radius: 7px;
}

.topbar {
  margin-inline: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  background: rgba(244, 247, 251, 0.92);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: none;
}

.topbar h1 {
  margin-top: var(--space-1);
  font-size: clamp(24px, 2.2vw, 30px);
}

.top-actions {
  gap: var(--space-2);
  padding: var(--space-2);
  border-color: var(--panel-border);
  background: #ffffff;
  box-shadow: none;
}

.global-search {
  width: clamp(220px, 28vw, 320px);
  min-width: 0;
}

.global-search input {
  height: 40px;
  padding: 17px var(--space-3) 6px;
}

input,
select {
  height: var(--control-height);
}

textarea {
  min-height: 96px;
}

.primary-action,
.text-button,
.icon-button,
.row-menu summary,
.action-menu summary {
  min-height: var(--control-height);
}

.primary-action:hover,
.text-button:hover,
.icon-button:hover,
.shortcut-stack a:hover,
.shortcut-stack button:hover,
.article-card:hover,
.suggestion:hover,
.focus-item:hover,
.ticket-row:hover {
  transform: none;
}

.portal-grid,
.workspace-row,
.ticket-layout,
.asset-layout,
.licenses-layout,
.contracts-layout,
.automation-layout,
.communication-layout,
.admin-layout,
.settings-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  gap: var(--space-4);
}

.agent-grid {
  grid-template-columns: minmax(390px, 500px) minmax(0, 1fr);
  gap: var(--space-4);
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.kb-filters,
.kb-results,
.activity-card,
.side-card,
.settings-panel,
.modal-panel {
  border-color: var(--panel-border);
  background: var(--panel-bg);
  box-shadow: none;
  backdrop-filter: none;
}

.service-panel,
.quick-panel,
.work-card,
.queue-panel,
.ticket-detail,
.kb-filters,
.kb-results {
  padding: var(--space-4);
}

.workspace-row {
  margin-top: var(--space-4);
}

.section-title,
.queue-toolbar,
.detail-top,
.page-heading,
.settings-panel-head {
  gap: var(--space-3);
}

.section-title h2,
.page-heading h2 {
  margin-top: var(--space-1);
  font-size: clamp(18px, 1.8vw, 22px);
}

.section-actions {
  gap: var(--space-2);
}

.service-grid,
.article-strip,
.focus-list,
.suggestion-stack,
.license-stack,
.schedule-list,
.settings-stack,
.asset-metrics,
.asset-table,
.license-metrics,
.license-table,
.contract-table,
.notification-stack,
.license-contract-grid,
.license-action-list,
.notification-log,
.template-list,
.agreement-grid,
.exposure-stack,
.dependency-map,
.lifecycle-list,
.rule-list,
.config-grid,
.dashboard-grid {
  margin-top: var(--space-3);
  gap: var(--space-2);
}

.service-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.service-card {
  min-height: 112px;
  padding: var(--space-3);
  gap: var(--space-2);
}

.article-card {
  min-height: 108px;
  padding: var(--space-3);
}

.score-card,
.metric-card,
.exposure-card,
.setting-card,
.config-card {
  padding: var(--space-3);
}

.score-card strong {
  margin: var(--space-2) 0 var(--space-1);
  font-size: 28px;
}

.ticket-form,
.dynamic-fields,
.modal-form {
  gap: var(--space-3);
}

.ticket-form {
  margin-top: var(--space-3);
}

.form-actions,
.reply-actions,
.detail-actions,
.compact-actions,
.login-actions,
.password-login-links {
  gap: var(--space-2);
}

.empty-state {
  min-height: 180px;
  padding: var(--space-5);
}

.empty-state.compact {
  min-height: 72px;
}

.queue-panel,
.ticket-detail {
  min-height: 0;
}

.empty-read-pane {
  min-height: 260px;
}

.detail-grid,
.settings-grid {
  gap: var(--space-2);
}

.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.settings-map,
.settings-list {
  gap: var(--space-2);
}

.settings-map-card,
.settings-item,
.direct-option {
  min-width: 0;
}

.asset-table,
.license-table,
.contract-table,
.user-table {
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.asset-row,
.license-row,
.contract-row,
.user-row {
  min-width: 760px;
}

.asset-row.header,
.license-row.header,
.contract-row.header,
.user-row.header {
  min-height: 30px;
}

.login-shell {
  min-height: min(720px, calc(100vh - 48px));
  align-items: center;
}

body[data-auth-role="guest"] main {
  display: grid;
  align-items: center;
  min-height: 100vh;
  padding: var(--space-6) !important;
  overflow-x: hidden;
}

body[data-auth-role="guest"] .login-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

body[data-auth-role="guest"] .login-card {
  box-sizing: border-box;
  width: 100%;
  max-width: min(720px, calc(100vw - 48px));
  min-width: 0;
  padding: var(--space-6);
  border-radius: 10px;
  box-shadow: 0 14px 42px rgba(15, 23, 42, 0.08);
}

body[data-auth-role="guest"] .login-hero {
  gap: var(--space-2);
}

body[data-auth-role="guest"] .login-hero h2 {
  max-width: 620px;
  min-width: 0;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.06;
  overflow-wrap: anywhere;
}

body[data-auth-role="guest"] .login-subtitle {
  max-width: 580px;
  font-size: 14px;
}

body[data-auth-role="guest"] .password-login-form,
body[data-auth-role="guest"] .login-state-card {
  box-shadow: none;
}

body[data-auth-role="guest"] .password-login-form {
  grid-template-columns: minmax(240px, 1fr) auto;
  max-width: 100%;
  min-width: 0;
  padding: var(--space-3);
}

body[data-auth-role="guest"] .password-login-form[data-login-step="password"] {
  grid-template-columns: minmax(210px, 0.95fr) minmax(190px, 1fr) auto;
}

body[data-auth-role="guest"] .email-code-login-form {
  grid-template-columns: minmax(210px, 1fr) minmax(130px, 0.45fr) auto;
}

body[data-auth-role="guest"] .password-login-form input,
body[data-auth-role="guest"] .password-login-form .primary-action,
body[data-auth-role="guest"] .login-state-card .primary-action {
  min-height: 42px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1180px) {
  .portal-grid,
  .workspace-row,
  .ticket-layout,
  .asset-layout,
  .licenses-layout,
  .contracts-layout,
  .automation-layout,
  .communication-layout,
  .admin-layout,
  .settings-layout,
  .agent-grid,
  .knowledge-layout,
  .detail-columns {
    grid-template-columns: 1fr;
  }

  .user-detail-panel {
    position: static;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    max-height: none;
  }

  .primary-nav {
    margin-top: var(--space-3);
  }

  .nav-group {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-1);
  }

  .nav-link {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sidebar-panel,
  .session-panel {
    display: none;
  }

  main {
    width: 100%;
  }
}

@media (max-width: 760px) {
  main {
    padding: 0 var(--space-3) var(--space-6);
  }

  .topbar {
    position: static;
    min-height: auto;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: var(--space-3) 0;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    width: 100%;
  }

  .global-search {
    width: 100%;
  }

  .top-actions .primary-action {
    grid-column: 1 / -1;
  }

  .section-title,
  .detail-top,
  .queue-toolbar,
  .page-heading,
  .settings-panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-actions {
    justify-content: flex-start;
  }

  .queue-toolbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .ticket-form,
  .dynamic-fields,
  .modal-form,
  .article-strip,
  .kb-results,
  .config-grid,
  .asset-metrics,
  .license-metrics,
  .dashboard-grid,
  .detail-grid,
  .dependency-map,
  .license-contract-grid,
  .agreement-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .asset-row,
  .license-row,
  .contract-row,
  .user-row {
    min-width: 0;
  }

  .detail-actions > *,
  .form-actions > * {
    flex: 1 1 160px;
  }

  body[data-auth-role="guest"] main {
    padding: var(--space-4) !important;
  }

  body[data-auth-role="guest"] .login-card {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    padding: var(--space-4);
  }

  body[data-auth-role="guest"] .login-hero h2,
  body[data-auth-role="guest"] .login-subtitle {
    overflow-wrap: anywhere;
  }

  body[data-auth-role="guest"] .password-login-form,
  body[data-auth-role="guest"] .password-login-form[data-login-step="password"],
  body[data-auth-role="guest"] .email-code-login-form {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  body[data-auth-role="guest"] .password-login-form .primary-action {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .top-actions {
    grid-template-columns: 1fr;
  }

  .theme-switch {
    width: 100%;
  }

  .service-panel,
  .quick-panel,
  .work-card,
  .queue-panel,
  .ticket-detail,
  .kb-filters,
  .kb-results {
    padding: var(--space-3);
  }

  .section-actions > *,
  .detail-actions > *,
  .form-actions > *,
  .reply-actions > * {
    width: 100%;
  }

  .reply-submit-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .reply-actions {
    flex-wrap: wrap;
  }

  .reply-utility-actions {
    width: 100%;
  }

  .reply-submit-group .primary-action {
    min-width: 0;
  }
}

html[data-theme="dark"] body {
  background: #0b1120;
}

html[data-theme="dark"] .topbar {
  background: rgba(11, 17, 32, 0.9);
  border-bottom-color: rgba(148, 163, 184, 0.14);
}

html[data-theme="dark"] .top-actions,
html[data-theme="dark"] .service-panel,
html[data-theme="dark"] .quick-panel,
html[data-theme="dark"] .work-card,
html[data-theme="dark"] .queue-panel,
html[data-theme="dark"] .ticket-detail,
html[data-theme="dark"] .kb-filters,
html[data-theme="dark"] .kb-results,
html[data-theme="dark"] .activity-card,
html[data-theme="dark"] .side-card,
html[data-theme="dark"] .settings-panel,
html[data-theme="dark"] .modal-panel {
  background: rgba(17, 24, 39, 0.96);
  border-color: rgba(148, 163, 184, 0.18);
}

/* Ticket detail deduplication: each panel owns distinct information. */
.ticket-detail .detail-top {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.ticket-detail .detail-subtitle {
  max-width: 760px;
}

.ticket-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.ticket-title-line {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

.ticket-title-line h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ticket-title-edit-button {
  flex: 0 0 32px;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  height: 32px;
  margin-top: -3px;
}

.ticket-permalink-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ticket-title-editor {
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-2);
}

.ticket-title-editor label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.ticket-title-editor input {
  width: 100%;
  height: 38px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
}

.ticket-title-edit-actions {
  display: flex;
  gap: var(--space-2);
}

.ticket-title-edit-actions .text-button,
.ticket-title-edit-actions .primary-action {
  min-height: 38px;
  padding-inline: var(--space-3);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .ticket-title-editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-title-edit-actions {
    justify-content: flex-start;
  }
}

.ticket-essentials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.ticket-essentials span {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.ticket-essentials b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.ticket-essentials strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-request-fields {
  margin-top: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
}

.detail-request-fields div,
.property-list div {
  background: transparent;
}

.ticket-sidebar-summary .property-list div {
  grid-template-columns: minmax(72px, 0.36fr) minmax(0, 1fr);
}

.email-preview-modal {
  max-width: 720px;
}

.report-preview-modal {
  width: min(1440px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.report-preview-body {
  min-height: 0;
  padding: 0 !important;
  overflow: hidden;
}

.report-preview-frame {
  display: block;
  width: 100%;
  height: min(76vh, 920px);
  min-height: 420px;
  border: 0;
  background: #f4f7fb;
}

.email-preview-meta {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.email-preview-meta div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line);
}

.email-preview-meta span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.email-preview-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.email-preview-body {
  min-height: 280px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #111827;
  font-family: Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.email-preview-html {
  min-height: 280px;
  max-height: min(58vh, 560px);
  overflow: auto;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #111827;
}

.email-preview-html img {
  max-width: 324px;
  height: auto;
}

.email-preview-html .email-preview-inline-image {
  margin: 12px 0;
}

.email-preview-html .email-preview-inline-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.property-list {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.property-list div {
  display: grid;
  grid-template-columns: minmax(78px, 0.42fr) minmax(0, 1fr);
  gap: var(--space-2);
  padding: 9px var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.property-list div:last-child {
  border-bottom: 0;
}

.property-list span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.property-list strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.requester-card {
  display: grid;
  gap: 3px;
  padding: var(--space-3);
}

.task-row {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.task-row:hover {
  border-color: rgba(37, 99, 235, 0.3);
  background: var(--surface-2);
}

.task-row strong {
  font-size: 12px;
}

.task-row span {
  color: var(--muted);
  font-size: 11px;
}

html[data-theme="dark"] .ticket-essentials span,
html[data-theme="dark"] .task-row {
  background: rgba(17, 24, 39, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

/* Ticket log switch: separate human communication from operational audit noise. */
.ticket-conversation .conversation-head {
  align-items: center;
  gap: var(--space-3);
}

.ticket-conversation .conversation-head > div:first-child {
  min-width: 0;
}

.ticket-conversation .conversation-head h3 {
  margin-bottom: 2px;
}

.ticket-log-switch {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
}

.ticket-log-switch button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ticket-log-switch button.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.ticket-log-switch b {
  min-width: 18px;
  min-height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
}

.timeline-item.operational::before {
  background: var(--muted-2);
}

@media (max-width: 760px) {
  .ticket-conversation .conversation-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-log-switch {
    width: 100%;
  }

  .ticket-log-switch button {
    flex: 1 1 0;
    justify-content: center;
  }
}

html[data-theme="dark"] .ticket-log-switch {
  background: rgba(17, 24, 39, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .ticket-log-switch button.active {
  background: rgba(56, 189, 248, 0.14);
}

html[data-theme="dark"] .user-row:has(.user-row-profile-trigger:hover),
html[data-theme="dark"] .user-profile-link-card:hover,
html[data-theme="dark"] .requester-profile-link:hover {
  border-color: rgba(56, 189, 248, 0.34);
  background: rgba(56, 189, 248, 0.12);
}

/* Compact, scrollable ticket tabs keep the detail workspace clear. */
.ticket-tabs {
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 8px;
  padding: 2px 0 5px;
  overscroll-behavior-inline: contain;
  scroll-padding-inline: 2px;
  scroll-snap-type: inline proximity;
}

.ticket-tabs button {
  flex: 0 0 148px;
  min-width: 148px;
  max-width: 148px;
  min-height: 34px;
  gap: 4px;
  padding: 5px 6px;
  scroll-snap-align: start;
}

.ticket-tabs span {
  min-height: 18px;
  padding: 0 4px;
  font-size: 9px;
}

.ticket-tabs strong {
  font-size: 11px;
}

.ticket-tabs i {
  width: 16px;
  height: 16px;
}

@media (max-width: 760px) {
  .ticket-tabs button {
    flex-basis: 136px;
    min-width: 136px;
    max-width: 136px;
  }
}

/* Keep every ticket-header action on the same compact control grid. */
.detail-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}

.detail-actions .ticket-viewer-presence,
.detail-actions .ticket-permalink-button,
.detail-actions .ticket-expand-toggle,
.detail-actions .ticket-context-edit-button,
.detail-actions .action-menu,
.detail-actions .action-menu > summary {
  flex: 0 0 var(--control-height);
  width: var(--control-height);
  min-width: var(--control-height);
}

.detail-actions .ticket-viewer-presence,
.detail-actions .ticket-permalink-button,
.detail-actions .ticket-expand-toggle,
.detail-actions .ticket-context-edit-button,
.detail-actions .action-menu > summary {
  height: var(--control-height);
  min-height: var(--control-height);
  display: grid;
  place-items: center;
  justify-content: center;
  padding: 0;
}

.ticket-viewport-icon {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

.rail-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rail-actions .icon-button.compact {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 18px;
}

.queue-list-actions .ticket-queue-edit-button {
  flex: 0 0 auto;
  height: var(--queue-control-height);
  min-height: var(--queue-control-height);
  max-height: var(--queue-control-height);
  padding: 0 10px;
  border-radius: 6px;
}

.ticket-view-modal {
  width: min(760px, calc(100vw - 32px));
}

.ticket-queue-manager-modal {
  width: min(760px, calc(100vw - 32px));
}

.ticket-manager-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.ticket-manager-toolbar .primary-action {
  min-height: 34px;
}

.ticket-manager-list {
  display: grid;
  gap: 8px;
}

.ticket-manager-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ticket-manager-content {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.queue-reorder-handle,
.queue-move-button {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
}

.queue-reorder-handle {
  cursor: grab;
  color: var(--muted);
}

.queue-reorder-handle:active {
  cursor: grabbing;
}

.ticket-manager-item.is-dragging {
  opacity: 0.5;
}

.ticket-manager-item .inline-actions {
  align-items: center;
}

.ticket-manager-item span,
.ticket-manager-item small {
  color: var(--muted);
}

.ticket-manager-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-manager-item small {
  font-size: 12px;
}

.ticket-view-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ticket-view-form > label,
.ticket-view-form > label span {
  display: grid;
  gap: 6px;
}

.ticket-view-form .full {
  grid-column: 1 / -1;
}

.ticket-filter-builder {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.ticket-filter-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.ticket-filter-builder-head div {
  display: grid;
  gap: 3px;
}

.ticket-filter-builder-head span,
.ticket-filter-empty {
  color: var(--muted);
  font-size: 12px;
}

.ticket-filter-rows {
  display: grid;
  gap: 8px;
}

.ticket-filter-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.9fr) minmax(105px, 0.7fr) minmax(160px, 1.2fr) 32px;
  align-items: center;
  gap: 8px;
}

.ticket-filter-row .searchable-combobox {
  min-width: 0;
}

.ticket-filter-row .icon-button.compact {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.ticket-column-builder {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.ticket-column-builder .ticket-filter-builder-head {
  margin-bottom: 0;
}

.ticket-column-rows {
  display: grid;
  gap: 6px;
}

.ticket-column-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: var(--surface);
}

.ticket-column-row.is-dragging {
  opacity: 0.55;
  border-color: var(--brand);
}

.ticket-column-drag {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  cursor: grab;
}

.ticket-column-drag:active {
  cursor: grabbing;
}

.ticket-column-row-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ticket-column-row-copy small {
  color: var(--muted);
  font-size: 12px;
}

.ticket-column-row-actions,
.ticket-column-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ticket-column-row-actions .icon-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.ticket-column-required {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ticket-column-add-row {
  justify-content: flex-end;
}

.ticket-column-add-row label {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: min(100%, 360px);
}

.ticket-column-add-row label span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 620px) {
  .ticket-view-form {
    grid-template-columns: 1fr;
  }

  .ticket-view-form .full {
    grid-column: auto;
  }

  .ticket-filter-row {
    grid-template-columns: 1fr 1fr 32px;
  }

  .ticket-filter-row input {
    grid-column: 1 / 3;
  }

  .ticket-filter-row .searchable-combobox {
    grid-column: 1 / 3;
  }

  .ticket-column-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .ticket-column-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .ticket-column-add-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-column-add-row label {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .ticket-manager-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-manager-item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .ticket-manager-item .inline-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

.ticket-viewer-presence {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 var(--control-height);
  width: var(--control-height);
  height: var(--control-height);
  border: 1px solid color-mix(in srgb, var(--green) 48%, var(--line-strong));
  border-radius: var(--radius);
  color: var(--green);
  background: var(--green-soft);
  cursor: help;
  outline: none;
}

.ticket-viewer-presence:focus-visible {
  box-shadow: 0 0 0 3px rgba(45, 116, 207, 0.24);
}

.ticket-viewer-presence svg {
  width: 16px;
  height: 16px;
}

.ticket-viewer-tooltip {
  position: absolute;
  z-index: 12;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  width: max-content;
  max-width: 260px;
  padding: 7px 9px;
  border-radius: 4px;
  color: #fff;
  background: #1f2937;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
}

.ticket-viewer-presence:hover .ticket-viewer-tooltip,
.ticket-viewer-presence:focus-visible .ticket-viewer-tooltip {
  display: block;
}

@media (max-width: 760px) {
  .detail-actions .action-menu-list {
    right: 0;
    left: auto;
  }
}

/* Dense, scannable agent queue with semantic sortable columns. */
.queue-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.queue-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  color: var(--ink);
  font-size: 11px;
}

.queue-table col.queue-select-column {
  width: 36px;
}

.queue-table col.queue-content-column {
  width: max-content;
}

.queue-table col.queue-id-column {
  width: 1%;
}

.queue-table col.queue-subject-column {
  width: 100%;
}

.queue-table th {
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  text-align: left;
}

.queue-table th.queue-select-column,
.queue-table td.queue-select-column {
  width: 36px;
  padding: 0 8px;
  text-align: center;
}

.queue-select-column input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

.queue-bulk-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--queue-control-height, 28px);
  padding: 2px 4px 2px 8px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: 6px;
  background: rgba(239, 246, 255, 0.88);
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.queue-bulk-actions .text-button {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 10px;
}

.bulk-ticket-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-theme="dark"] .queue-bulk-actions {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(30, 64, 175, 0.2);
}

@media (max-width: 760px) {
  .queue-bulk-actions {
    order: -1;
  }

  .bulk-ticket-form {
    grid-template-columns: 1fr;
  }
}

.queue-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 10px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.queue-sort-button:hover,
.queue-sort-button.active {
  color: var(--brand);
  background: rgba(37, 99, 235, 0.06);
}

.queue-sort-button span {
  font-size: 12px;
  line-height: 1;
}

.queue-table td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-table tbody tr:last-child td {
  border-bottom: 0;
}

.queue-table-row {
  background: transparent;
  transition: background-color 120ms ease;
}

.queue-table-row:hover {
  background: rgba(37, 99, 235, 0.04);
}

.queue-table-row.active {
  background: rgba(239, 246, 255, 0.9);
  box-shadow: inset 3px 0 0 var(--brand);
}

.queue-table-row.subticket {
  box-shadow: inset 2px 0 0 rgba(37, 99, 235, 0.34);
}

.queue-table-row.subticket.active {
  box-shadow: inset 3px 0 0 var(--brand);
}

.queue-subticket-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: 18px;
  padding: 0 2px;
  border: 0;
  border-radius: 3px;
  color: #111827;
  background: transparent;
  font: inherit;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.queue-subticket-toggle:hover,
.queue-subticket-toggle:focus-visible,
.queue-subticket-toggle.expanded {
  color: var(--brand);
  background: transparent;
}

.queue-subticket-branch {
  width: 11px;
  height: 11px;
  stroke-width: 2;
}

html[data-theme="dark"] .queue-subticket-toggle {
  color: var(--ink);
}

.queue-subticket-marker {
  position: absolute;
  top: 50%;
  left: 0;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  transform: translateY(-50%);
}

.queue-ticket-reference,
.queue-ticket-date,
.queue-ticket-sla {
  color: var(--muted);
  font-size: 10px;
}

.queue-ticket-reference-content {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-left: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.queue-table-row.subticket .queue-ticket-reference-content {
  padding-left: 14px;
}

.queue-ticket-reference {
  position: relative;
  padding-left: 8px !important;
}

.queue-ticket-reference-id {
  flex: 0 0 auto;
}

.queue-ticket-request button {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-weight: 800;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-ticket-request button:hover {
  color: var(--brand);
  text-decoration: underline;
}

.queue-table-row[data-ticket-select] {
  cursor: pointer;
}

.queue-table-row[data-ticket-select]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.queue-ticket-title {
  display: grid;
  grid-template-columns: var(--action-button-compact-height) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
}

.queue-ticket-title > span {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-table td.queue-ticket-request {
  position: relative;
  overflow: visible;
}

.queue-table-row.project-deadline-due-soon .queue-ticket-request {
  box-shadow: inset 3px 0 0 #d97706;
}

.queue-table-row.project-deadline-breached .queue-ticket-request {
  box-shadow: inset 3px 0 0 #dc2626;
}

.queue-deadline-tooltip-layer {
  position: fixed;
  z-index: 60;
  display: flex;
  align-items: center;
  width: max-content;
  max-width: calc(100vw - 16px);
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-left-width: 2px;
  border-radius: 5px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  font-size: 11px;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 80ms ease, transform 80ms ease;
  white-space: nowrap;
}

.queue-deadline-tooltip-layer.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.truncated-text-tooltip {
  position: fixed;
  z-index: 65;
  max-width: min(360px, calc(100vw - 16px));
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.35;
  opacity: 0;
  overflow-wrap: anywhere;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 100ms ease, transform 100ms ease;
}

.truncated-text-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

html[data-theme="dark"] .truncated-text-tooltip {
  border-color: rgba(148, 163, 184, 0.28);
  background: #172033;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34);
  color: #e5edf8;
}

.queue-deadline-tooltip-layer > span:first-child {
  font-weight: 700;
}

.queue-deadline-tooltip-layer strong {
  font-size: inherit;
  line-height: inherit;
}

.queue-deadline-tooltip-layer > span:last-child {
  color: inherit;
  font-size: inherit;
  font-weight: 700;
}

.queue-deadline-tooltip-layer > span:last-child::before {
  content: "-";
  margin-right: 4px;
}

.queue-deadline-tooltip-layer[data-state="due-soon"] {
  border-color: #f3cc6a;
  border-left-color: #d97706;
  color: #9a6700;
  background: #fff7e2;
}

.queue-deadline-tooltip-layer[data-state="breached"] {
  border-color: #f3b8b4;
  border-left-color: #dc2626;
  color: #b42318;
  background: #fff3f1;
}

.queue-ticket-open {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  box-shadow: none;
}

.queue-ticket-open:hover,
.queue-ticket-open:focus-visible {
  border-color: var(--active-border);
  background: var(--active-surface);
  color: var(--brand);
  transform: none;
  text-decoration: none;
}

.queue-ticket-open > span {
  display: block;
  font-weight: 800;
  line-height: 1;
  transform: translateX(0.5px);
}

.quick-ticket-update {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
}

.quick-ticket-update-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.quick-ticket-update textarea {
  min-height: 76px;
  resize: vertical;
}

.quick-ticket-update-actions {
  justify-content: flex-end;
}

.ticket-notify-assignee {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ticket-notify-assignee input {
  inline-size: 15px;
  block-size: 15px;
  margin: 0;
  accent-color: var(--brand);
}

.single-submit-menu {
  flex: 0 0 auto;
}

.single-submit-menu > summary {
  min-width: 0 !important;
  min-height: 32px;
  padding: 0 10px !important;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  gap: 8px;
}

.reply-actions .single-submit-menu > summary {
  width: auto;
  min-width: 84px !important;
}

.single-submit-menu > summary:hover,
.single-submit-menu[open] > summary {
  border-color: var(--brand-strong);
  background: var(--brand-strong);
}

.single-submit-menu > .row-menu-list {
  right: 0;
  left: auto;
  min-width: 144px;
}

@media (max-width: 640px) {
  .quick-ticket-update-actions {
    align-items: stretch;
    flex-direction: column;
  }

}

.queue-ticket-sla {
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

.queue-ticket-sla.on-track {
  color: var(--green);
}

.queue-ticket-sla.breached {
  color: var(--red);
}

.ticket-subticket-list button {
  width: 100%;
  padding: 9px;
  border: 1px solid rgba(31, 35, 40, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: inherit;
  font: inherit;
  text-align: left;
}

.ticket-subticket-list button:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--brand-soft);
}

.ticket-subticket-list button:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.62);
  outline-offset: 2px;
}

html[data-theme="dark"] .ticket-subticket-list button {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(17, 24, 39, 0.9);
}

.queue-table .ticket-status,
.queue-table .ticket-priority {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 9.5px;
  white-space: nowrap;
}

html[data-theme="dark"] .queue-table-wrap {
  background: rgba(15, 23, 42, 0.72);
}

html[data-theme="dark"] .queue-table th {
  background: rgba(17, 24, 39, 0.9);
}

html[data-theme="dark"] .queue-table-row:hover,
html[data-theme="dark"] .queue-table-row.active {
  background: rgba(96, 165, 250, 0.11);
}

@media (max-width: 760px) {
  .queue-table-wrap {
    border-radius: 6px;
  }

  .queue-table {
    min-width: 720px;
  }
}

/* Agent workspace density: preserve space for queue scanning and conversation work. */
.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sidebar-brand-row .brand {
  min-width: 0;
}

button.sidebar-collapse-button {
  display: inline-grid;
  flex: 0 0 10px;
  width: 10px;
  min-width: 10px;
  min-height: 10px;
  height: 10px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 0 !important;
  border-radius: 0;
  background: transparent !important;
  color: #a8b6ca;
  box-shadow: none !important;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  outline: 0;
  place-items: center;
}

button.sidebar-collapse-button:hover,
button.sidebar-collapse-button:focus-visible {
  border: 0 !important;
  background: transparent !important;
  color: #38bdf8;
  box-shadow: none !important;
  transform: none;
}

button.sidebar-collapse-button:hover .sidebar-collapse-symbol,
button.sidebar-collapse-button:focus-visible .sidebar-collapse-symbol {
  filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.7));
}

.sidebar-collapse-symbol {
  display: grid;
  width: 10px;
  height: 10px;
  place-items: center;
  line-height: 1;
}

.sidebar-collapse-symbol::before {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(135deg);
}

.sidebar-collapse-button[data-collapsed="true"] .sidebar-collapse-symbol::before {
  transform: rotate(-45deg);
}

@media (min-width: 981px) {
  body.sidebar-collapsed {
    --shell-sidebar: 70px;
  }

  body.sidebar-collapsed .sidebar {
    align-items: center;
    padding-inline: var(--space-1);
  }

  body.sidebar-collapsed .sidebar-brand-row {
    display: grid;
    grid-template-columns: 36px 10px;
    width: 100%;
    align-items: center;
    justify-content: center;
    column-gap: 6px;
  }

  body.sidebar-collapsed .sidebar-brand-row .brand {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    gap: 0;
  }

  body.sidebar-collapsed .sidebar-collapse-button {
    flex: 0 0 10px;
    width: 10px;
    min-width: 10px;
    min-height: 10px;
    height: 10px;
  }

  body.sidebar-collapsed .sidebar-brand-row .brand > span:last-child,
  body.sidebar-collapsed .nav-section-title,
  body.sidebar-collapsed .sidebar-panel,
  body.sidebar-collapsed .session-panel {
    display: none;
  }

  body.sidebar-collapsed .primary-nav {
    display: grid;
    width: 100%;
    align-items: center;
    justify-items: center;
  }

  body.sidebar-collapsed .nav-group {
    display: grid;
    width: 100%;
    align-items: center;
    justify-items: center;
  }

  body.sidebar-collapsed .nav-link,
  body.sidebar-collapsed .agent-workspace-shortcut,
  body.sidebar-collapsed .employee-portal-link {
    position: relative;
    display: grid !important;
    place-items: center;
    align-content: center;
    justify-content: center;
    justify-self: center;
    align-self: center;
    box-sizing: border-box;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    gap: 0;
    color: transparent;
    font-size: 0;
  }

  /* Collapsing the sidebar must not override role or access-profile visibility. */
  body.sidebar-collapsed .nav-link[hidden],
  body.sidebar-collapsed .agent-workspace-shortcut[hidden],
  body.sidebar-collapsed .employee-portal-link[hidden] {
    display: none !important;
  }

  body.sidebar-collapsed .nav-link:hover,
  body.sidebar-collapsed .nav-link.active {
    transform: none;
  }

  body.sidebar-collapsed .nav-link .nav-ico {
    display: grid;
    place-items: center;
    align-self: center;
    justify-self: center;
    margin: 0;
  }

  body.sidebar-collapsed .nav-link .nav-ico::before {
    display: block;
    line-height: 1;
    transform: translateY(1px);
  }

  body.sidebar-collapsed .nav-link:hover::after,
  body.sidebar-collapsed .nav-link:focus-visible::after {
    position: absolute;
    z-index: 80;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 8px;
    border-radius: 4px;
    color: #ffffff;
    background: #1f2937;
    content: attr(data-sidebar-label);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
  }
}

@media (min-width: 1181px) {
  .agent-grid {
    grid-template-columns: minmax(470px, 600px) minmax(0, 1fr);
    align-items: start;
  }

  .queue-panel {
    align-self: start;
  }

  .ticket-view-rail,
  .ticket-results {
    min-height: 0;
    max-height: calc(100vh - 210px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .ticket-results {
    padding-right: 2px;
  }

  .queue-table th {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

.ticket-workspace-grid {
  grid-template-columns: minmax(0, 1fr) minmax(210px, 244px);
  gap: var(--space-3);
}

@media (min-width: 1181px) {
  .agent-grid:not(.ticket-detail-expanded) {
    grid-template-columns: minmax(680px, 1.28fr) minmax(340px, 0.72fr);
  }
}

.ticket-detail-content.is-compact .ticket-workspace-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.ticket-detail-content.is-compact .ticket-conversation,
.ticket-detail-content.is-compact .ticket-properties {
  padding: var(--space-3);
}

.ticket-detail-content.is-compact .ticket-conversation .timeline {
  max-height: clamp(96px, calc(100dvh - 390px), 198px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ticket-detail-content.is-compact .ticket-properties {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-properties {
  display: grid;
  align-content: start;
  gap: var(--space-2);
  container-type: inline-size;
}

.ticket-properties .property-section {
  padding: 0;
  border: 0;
}

.ticket-context-panel {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.ticket-context-panel-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  min-width: 0;
}

.ticket-context-requester {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}

a.ticket-context-requester:hover .ticket-context-person strong {
  color: var(--brand);
}

a.ticket-context-requester:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.6);
  outline-offset: 3px;
  border-radius: 4px;
}

.ticket-context-person {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ticket-context-person strong {
  font-size: 14px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.ticket-context-person span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-context-requester-facts,
.ticket-context-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
}

.ticket-context-requester-facts div,
.ticket-context-summary-grid div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ticket-context-requester-facts .ticket-context-manager-fact {
  grid-column: 1 / -1;
}

.ticket-context-requester-facts dt,
.ticket-context-summary-grid dt {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-context-requester-facts dd,
.ticket-context-summary-grid dd {
  margin: 0;
  overflow: hidden;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-project-deadline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  border-radius: 5px;
  background: var(--surface-muted);
}

.ticket-project-deadline > div {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.ticket-project-deadline span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-project-deadline strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-project-deadline > b {
  padding: 3px 5px;
  border-radius: 3px;
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
}

.ticket-project-deadline.project-deadline-on-track {
  border-left-color: #16a34a;
}

.ticket-project-deadline.project-deadline-on-track > b {
  color: #166534;
  background: rgba(34, 197, 94, 0.12);
}

.ticket-project-deadline.project-deadline-due-soon {
  border-color: rgba(217, 119, 6, 0.28);
  border-left-color: #d97706;
  background: rgba(245, 158, 11, 0.1);
}

.ticket-project-deadline.project-deadline-due-soon > b {
  color: #9a6700;
  background: rgba(245, 158, 11, 0.16);
}

.ticket-project-deadline.project-deadline-breached {
  border-color: rgba(220, 38, 38, 0.28);
  border-left-color: #dc2626;
  background: rgba(239, 68, 68, 0.1);
}

.ticket-project-deadline.project-deadline-breached > b {
  color: #b42318;
  background: rgba(239, 68, 68, 0.15);
}

.ticket-project-deadline.project-deadline-complete > b {
  color: var(--muted);
  background: rgba(100, 116, 139, 0.12);
}

.ticket-detail-content.is-expanded .ticket-context-requester {
  grid-template-columns: minmax(0, 1fr) minmax(136px, 0.8fr);
  align-items: start;
  gap: 8px 14px;
}

.ticket-detail-content.is-expanded .ticket-context-requester-facts,
.ticket-detail-content.is-expanded .ticket-context-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ticket-context-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: start;
  gap: var(--space-3);
}

.ticket-context-top-grid > * {
  min-width: 0;
}

.ticket-context-top-grid .ticket-quick-fields {
  position: relative;
  z-index: 2;
  padding-top: 0 !important;
  border-top: 0 !important;
}

.ticket-context-top-grid .ticket-context-panel {
  gap: 7px;
  padding-left: var(--space-3);
  border-left: 1px solid var(--line);
}

.ticket-context-top-grid .ticket-context-requester {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.ticket-context-top-grid .ticket-context-requester-facts,
.ticket-context-top-grid .ticket-context-summary-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 5px 8px;
}

.ticket-quick-fields {
  padding-top: var(--space-2) !important;
  border-top: 1px solid var(--line) !important;
}

.ticket-quick-fields-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.ticket-quick-fields-head > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-quick-fields .ticket-context-inline-fields,
.ticket-context-details .inline-ticket-fields {
  gap: var(--space-2);
}

.ticket-quick-fields .ticket-context-inline-fields {
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
}

.ticket-quick-fields .ticket-field-stack-secondary {
  margin-top: var(--space-3);
}

.ticket-quick-fields .inline-ticket-field {
  grid-template-columns: minmax(68px, 0.52fr) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.ticket-quick-fields .inline-ticket-field span {
  font-size: 9px;
}

.ticket-quick-fields .inline-ticket-field select,
.ticket-quick-fields .inline-ticket-field input {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.ticket-context-inline-fields {
  display: grid;
  gap: 5px;
}

.ticket-context-inline-fields .inline-ticket-field {
  grid-template-columns: minmax(60px, 0.42fr) minmax(0, 1fr);
  align-items: center;
  gap: 6px;
}

.ticket-context-inline-fields .inline-ticket-field span {
  font-size: 9px;
}

.ticket-context-inline-fields .inline-ticket-field select,
.ticket-context-inline-fields .inline-ticket-field input {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 11px;
}

.ticket-context-top-fields {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.ticket-context-asset-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: end;
  gap: 6px;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.ticket-context-asset-control .ticket-context-top-fields {
  padding-bottom: 0;
  border-bottom: 0;
}

.anydesk-launch-button {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-decoration: none;
  box-shadow: none;
}

.anydesk-launch-button:hover,
.anydesk-launch-button:focus-visible {
  border-color: var(--active-border);
  background: var(--active-surface);
  color: var(--brand);
}

.ticket-context-bottom-fields {
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
}

.ticket-context-details {
  border-top: 1px solid var(--line);
  padding-top: var(--space-2);
}

.ticket-context-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 30px;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  list-style: none;
}

.ticket-context-details summary::-webkit-details-marker {
  display: none;
}

.ticket-context-details summary::before {
  content: "+";
  color: var(--brand);
  font-size: 16px;
  font-weight: 500;
}

.ticket-context-details[open] summary::before {
  content: "-";
}

.ticket-context-details summary span {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.ticket-context-details > :not(summary) {
  margin-top: var(--space-2);
}

.ticket-related-ticket-list {
  display: grid;
  gap: 5px;
}

.ticket-related-ticket {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 7px;
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
}

.ticket-related-ticket:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--brand-soft);
}

.ticket-related-ticket:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.62);
  outline-offset: 2px;
}

.ticket-related-ticket-reference {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.ticket-related-ticket strong,
.ticket-related-ticket small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-related-ticket strong {
  font-size: 11px;
}

.ticket-related-ticket small {
  color: var(--muted);
  font-size: 10px;
}

.ticket-parent-reference {
  display: grid;
  gap: 4px;
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
}

.ticket-parent-reference > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-parent-reference button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
}

.ticket-parent-reference button:hover {
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--brand-soft);
}

.ticket-parent-reference button:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.62);
  outline-offset: 2px;
}

.ticket-parent-reference strong {
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.ticket-parent-reference button span {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-context-details .inline-ticket-fields,
.ticket-sidebar-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.ticket-context-details .inline-ticket-field {
  grid-template-columns: minmax(52px, 0.45fr) minmax(0, 1fr);
  gap: 5px;
  min-width: 0;
  padding: 6px 7px;
  border-bottom: 1px solid var(--line);
}

.ticket-context-details .inline-ticket-field:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.ticket-context-details .inline-ticket-field select,
.ticket-context-details .inline-ticket-field input {
  min-height: 28px;
  padding: 0 6px;
  font-size: 11px;
}

.ticket-sidebar-summary div {
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 6px 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ticket-sidebar-summary div:nth-child(even) {
  border-right: 0;
}

.ticket-sidebar-summary div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.ticket-attachments-collapsible .ticket-attachment-collapsible-body {
  display: grid;
  gap: 6px;
}

.ticket-attachments-collapsible .ticket-attachment-head-actions {
  justify-content: flex-end;
}

@container (max-width: 420px) {
  .ticket-context-top-grid,
  .ticket-detail-content.is-expanded .ticket-context-requester,
  .ticket-detail-content.is-expanded .ticket-context-requester-facts,
  .ticket-detail-content.is-expanded .ticket-context-summary-grid,
  .ticket-quick-fields .ticket-context-inline-fields,
  .ticket-context-details .inline-ticket-fields,
  .ticket-sidebar-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-context-top-grid .ticket-context-panel {
    padding-left: 0;
    border-left: 0;
    padding-top: var(--space-2);
    border-top: 1px solid var(--line);
  }

  .ticket-context-details .inline-ticket-field,
  .ticket-sidebar-summary div {
    border-right: 0;
  }

  .ticket-context-details .inline-ticket-field:nth-last-child(2),
  .ticket-sidebar-summary div:nth-last-child(2) {
    border-bottom: 1px solid var(--line);
  }
}

.ticket-view-button {
  --view-accent: var(--muted);
  --view-surface: var(--surface-2);
  border-left-color: var(--view-accent);
  background: var(--view-surface);
}

.ticket-view-button.color-blue {
  --view-accent: var(--blue);
  --view-surface: var(--blue-soft);
}

.ticket-view-button.color-green {
  --view-accent: var(--green);
  --view-surface: var(--green-soft);
}

.ticket-view-button.color-amber {
  --view-accent: var(--amber);
  --view-surface: var(--amber-soft);
}

.ticket-view-button.color-red {
  --view-accent: var(--red);
  --view-surface: var(--red-soft);
}

.ticket-view-button.color-violet {
  --view-accent: var(--violet);
  --view-surface: var(--violet-soft);
}

.ticket-view-button.color-neutral {
  --view-accent: var(--muted);
  --view-surface: var(--surface-2);
}

.ticket-view-button b {
  border: 1px solid color-mix(in srgb, var(--view-accent) 24%, transparent);
  background: var(--surface);
  color: var(--view-accent);
}

.ticket-view-button.active {
  border-color: var(--view-accent);
  border-left-color: var(--view-accent);
  background: var(--view-surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--view-accent) 18%, transparent);
}

.ticket-view-rail {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  padding: 0;
  border: 0;
}

.ticket-view-button {
  flex: 0 1 auto;
  width: fit-content;
  max-width: 100%;
  grid-template-columns: minmax(0, max-content) auto;
  gap: 4px;
  padding: 4px 7px;
}

.ticket-view-button strong {
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .ticket-workspace-grid {
    grid-template-columns: 1fr;
  }

  .agent-grid.ticket-detail-expanded .ticket-workspace-grid {
    grid-template-columns: 1fr;
  }

  .ticket-properties {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .sidebar-brand-row {
    width: 100%;
  }

  .sidebar-collapse-button {
    display: none;
  }

  .ticket-properties {
    grid-template-columns: 1fr;
  }
}

/* Keep the selected ticket flush with the available agent workspace on wide screens. */
#view-agent.active,
#view-agent .agent-grid,
#view-agent .ticket-detail,
#view-agent .ticket-detail-content {
  width: 100%;
  max-width: none;
}

#view-agent .agent-grid {
  min-width: 0;
}

@media (min-width: 1181px) {
  #view-agent .agent-grid:not(.ticket-detail-expanded) {
    grid-template-columns: minmax(440px, 0.99fr) minmax(0, 1.51fr);
  }

  #view-agent .agent-grid.ticket-detail-expanded {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Reports prioritise the service desk decisions, then keep detailed packs easy to reach. */
#view-analytics .dashboard-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: var(--space-3) 0;
}

#view-analytics .dash-card {
  min-width: 0;
  padding: var(--space-3);
}

#view-analytics .dash-card strong {
  margin-top: var(--space-1);
  font-size: 26px;
}

#view-analytics .dash-card small {
  margin-top: 4px;
}

#view-analytics .dash-card.report-attention strong {
  color: var(--amber);
}

.report-library-card {
  margin-bottom: var(--space-3);
}

.report-group-tabs {
  display: flex;
  gap: 4px;
  margin-top: var(--space-3);
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.report-group-tab {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.report-group-tab:hover {
  background: var(--blue-soft);
  color: var(--brand);
}

.report-group-tab.active {
  border-color: color-mix(in srgb, var(--brand) 34%, var(--line));
  background: var(--blue-soft);
  color: var(--brand);
}

.report-group-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--brand) 28%, transparent);
  outline-offset: 2px;
}

#view-analytics .report-catalog {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--space-2);
  margin-top: var(--space-2);
}

#view-analytics .report-card {
  min-height: 142px;
  padding: var(--space-3);
  gap: var(--space-2);
}

#view-analytics .report-card strong {
  margin-top: 0;
}

#view-analytics .report-card p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#view-analytics .report-card small {
  margin-top: var(--space-2);
}

#view-analytics .report-card .primary-action {
  min-height: 34px;
}

@media (max-width: 980px) {
  #view-analytics .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  #view-analytics .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Wide-screen queue review keeps the full ticket register visible beside a concise preview. */
@media (min-width: 1300px) {
  #view-agent .agent-grid:not(.ticket-detail-expanded) {
    grid-template-columns: minmax(580px, 1.28fr) minmax(324px, 0.72fr);
  }

  #view-agent .ticket-detail-content.is-compact .ticket-workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #view-agent .ticket-detail-content.is-compact .ticket-properties {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  #view-agent .ticket-detail-content.is-compact .ticket-conversation .timeline {
    max-height: clamp(96px, calc(100dvh - 390px), 198px);
  }
}

@media (min-width: 1600px) {
  #view-agent .agent-grid:not(.ticket-detail-expanded) {
    grid-template-columns: minmax(900px, 1.66fr) minmax(360px, 0.54fr);
  }
}

@media (min-width: 1300px) {
  .queue-table {
    min-width: 100%;
    font-size: 10.5px;
  }

  .queue-table td {
    padding: 5px 6px;
  }

  .queue-sort-button {
    min-height: 30px;
    padding: 0 6px;
    font-size: 10px;
  }

  .queue-table .ticket-status,
  .queue-table .ticket-priority {
    min-height: 18px;
    padding: 0 5px;
    font-size: 9px;
  }
}

/* Dialogs remain visually separate without obscuring the work behind them. */
.modal-root {
  background: transparent;
  backdrop-filter: none;
}

.modal-root > .modal-layer > .modal-panel {
  transform: translate3d(var(--modal-offset-x, 0), var(--modal-offset-y, 0), 0);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.modal-root > .modal-layer > .modal-panel.modal-attention {
  animation: modal-attention 460ms ease-out;
}

@keyframes modal-attention {
  0%, 100% { box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14); }
  45% { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.34), 0 12px 30px rgba(15, 23, 42, 0.18); }
}

.modal-panel[data-modal-draggable="true"] .modal-head {
  cursor: grab;
  touch-action: none;
}

.modal-panel[data-modal-dragging="true"] {
  user-select: none;
}

.modal-panel[data-modal-dragging="true"] .modal-head {
  cursor: grabbing;
}

html[data-theme="dark"] .modal-root > .modal-layer > .modal-panel {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.modal-workspace-toggle {
  margin-left: auto;
}

.modal-workspace-toggle svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-layer.modal-workspace-expanded {
  place-items: stretch;
  padding: 0;
}

.modal-panel.modal-workspace-expanded {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  border-radius: 0;
  transform: none !important;
}

.modal-panel.modal-workspace-expanded[data-modal-draggable="true"] .modal-head {
  cursor: default;
}

@media (min-width: 981px) {
  .modal-root:has(.modal-panel.modal-workspace-expanded) {
    left: var(--shell-sidebar);
  }
}

@media (max-width: 760px) {
  .modal-panel[data-modal-draggable="true"] .modal-head {
    cursor: default;
    touch-action: auto;
  }
}

/* Ticket attachments stay compact in the detail column while keeping each file actionable. */
.ticket-attachments {
  display: grid;
  gap: 8px;
}

.ticket-context-panel .ticket-attachments {
  padding-top: var(--space-2);
  border-top: 1px solid var(--line);
}

.ticket-attachments-head {
  min-height: 28px;
  align-items: center;
}

.ticket-attachments h3 {
  margin: 0;
  font-size: 12px;
}

.ticket-attachments h3 span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.ticket-attachment-head-actions,
.ticket-attachment-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ticket-attachment-list {
  display: grid;
  gap: 5px;
  max-height: 144px;
  overflow: auto;
  overscroll-behavior: contain;
}

.ticket-attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  min-height: 38px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.ticket-attachment-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.ticket-attachment-copy strong,
.ticket-attachment-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-attachment-copy strong {
  font-size: 12px;
}

.ticket-attachment-copy small,
.attachment-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

/* Ticket header and file actions share the same compact, quiet control frame. */
.ticket-icon-action,
.ticket-detail .detail-actions .action-menu > summary {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  flex: 0 0 var(--action-button-compact-height);
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: none;
  color: var(--ink);
  line-height: 1;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ticket-icon-action:hover,
.ticket-detail .detail-actions .action-menu > summary:hover {
  border-color: rgba(37, 99, 235, 0.38);
  background: var(--brand-soft);
  transform: none;
}

.ticket-icon-action:focus-visible,
.ticket-detail .detail-actions .action-menu > summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: none;
}

.ticket-icon-action .attachment-action-icon {
  width: 15px;
  height: 15px;
}

.attachment-preview-modal {
  width: min(980px, calc(100vw - 40px));
}

.attachment-preview-body {
  display: grid;
  place-items: center;
  min-height: 280px;
  max-height: min(68vh, 760px);
  padding: 0;
  overflow: auto;
  background: var(--surface-2);
}

.ticket-attachment-action .attachment-action-icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.attachment-preview-loading,
.attachment-preview-fallback {
  max-width: 480px;
  margin: 24px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.attachment-preview-actions {
  justify-content: flex-end;
}

.attachment-preview-image,
.attachment-preview-frame,
.attachment-preview-media {
  display: block;
  width: 100%;
  min-height: 280px;
  border: 0;
}

.attachment-preview-image {
  max-height: min(68vh, 760px);
  object-fit: contain;
  background: var(--surface);
}

.attachment-preview-media {
  align-self: center;
  min-height: 0;
  max-height: min(68vh, 760px);
  padding: 16px;
}

.attachment-preview-text {
  min-width: 0;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: var(--ink);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 520px) {
  .ticket-attachments-head,
  .ticket-attachment-row {
    align-items: flex-start;
  }

  .ticket-attachments-head {
    display: grid;
    gap: 6px;
  }

  .ticket-attachment-head-actions {
    flex-wrap: wrap;
  }

  .attachment-preview-modal {
    width: calc(100vw - 24px);
  }
}

/* Pending attachments stay visible under the composer until the update is submitted. */
.ticket-composer-input-wrap {
  position: relative;
}

.ticket-composer-input-wrap textarea {
  display: block;
  width: 100%;
  padding-bottom: 38px;
}

.request-description-input-wrap textarea {
  min-height: 132px;
}

.ticket-description-field.is-file-dragging .request-description-input-wrap {
  outline: 2px dashed var(--brand);
  outline-offset: 4px;
}

.ticket-raiser-field {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 0;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.ticket-raiser-field > span {
  margin-bottom: 7px;
}

.ticket-composer-input-wrap [data-composer-attachment-host] {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.composer-attachment-picker {
  display: grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
}

.composer-attachment-picker:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.composer-attachment-picker:focus-within {
  outline: 3px solid rgba(37, 99, 235, 0.72);
  outline-offset: 2px;
}

.composer-attachment-picker svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.composer-attachment-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.composer-attachment-tray {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.composer-attachment-tray-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.composer-attachment-tray-items {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.composer-attachment-chip {
  display: inline-grid;
  grid-template-columns: 24px minmax(0, 150px) 18px;
  align-items: center;
  gap: 5px;
  min-width: 0;
  height: 26px;
  padding: 0 4px 0 2px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}

.composer-attachment-chip.uploaded {
  opacity: 0.65;
}

.composer-attachment-chip > span:nth-child(2) {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment-chip > button:last-child {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.composer-attachment-chip > button:last-child:hover {
  background: var(--red-soft);
  color: var(--red);
}

.composer-attachment-thumb,
.composer-attachment-file-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 3px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12px;
}

.composer-attachment-thumb {
  padding: 0;
  cursor: zoom-in;
}

.composer-attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reply-box.is-file-dragging,
.quick-ticket-update.is-file-dragging {
  outline: 2px dashed var(--brand);
  outline-offset: 4px;
}

.timeline-attachment-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  max-width: 440px;
  min-height: 30px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.timeline-attachment-type {
  display: grid;
  min-width: 28px;
  height: 22px;
  place-items: center;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 9px;
  font-weight: 700;
}

.timeline-attachment-type.image {
  background: var(--violet-soft);
  color: var(--violet);
}

.timeline-attachment-card > div:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.timeline-attachment-card strong,
.timeline-attachment-card small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-attachment-card strong {
  font-size: 11px;
}

.timeline-attachment-card small {
  color: var(--muted);
  font-size: 10px;
}

.timeline-attachment-actions {
  display: inline-flex;
  gap: 4px;
}

.timeline-attachment-actions .ticket-attachment-action {
  flex: 0 0 var(--action-button-compact-height);
}

.timeline-inline-image {
  width: min(100%, var(--inline-image-width, 480px));
  margin: 8px 0 0;
}

.timeline-inline-image img,
.timeline-inline-image-loading,
.timeline-inline-image-unavailable {
  display: block;
  width: 100%;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
}

.timeline-inline-image img {
  height: auto;
  min-height: 0;
}

.timeline-inline-image-loading,
.timeline-inline-image-unavailable {
  display: grid;
  place-items: center;
  padding: var(--space-3);
  color: var(--muted);
  font-size: 11px;
}

.timeline-inline-image figcaption {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.ticket-composer-inline-image {
  --composer-inline-image-width: 420px;
  position: relative;
  display: block;
  width: min(100%, var(--composer-inline-image-width));
  max-width: 100%;
  margin: 10px 0;
  line-height: 0;
  outline: none;
}

.ticket-composer-inline-image > img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-2);
  user-select: none;
}

.ticket-composer-inline-image:hover > img,
.ticket-composer-inline-image:focus-within > img,
.ticket-composer-inline-image.is-resizing > img {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 28%, transparent);
}

.ticket-composer-inline-image-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.ticket-composer-inline-image:hover .ticket-composer-inline-image-actions,
.ticket-composer-inline-image:focus-within .ticket-composer-inline-image-actions {
  opacity: 1;
}

.ticket-composer-inline-image-actions button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--ink);
  cursor: pointer;
}

.ticket-composer-inline-image-actions button:hover,
.ticket-composer-inline-image-actions button:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-deep);
  outline: none;
}

.ticket-composer-inline-image-actions button:last-child:hover,
.ticket-composer-inline-image-actions button:last-child:focus-visible {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.ticket-composer-inline-image-actions svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ticket-composer-inline-image-resize {
  position: absolute;
  z-index: 1;
  width: 10px;
  height: 10px;
  border: 1px solid var(--brand-deep);
  border-radius: 2px;
  background: var(--surface);
  opacity: 0;
}

.ticket-composer-inline-image:hover .ticket-composer-inline-image-resize,
.ticket-composer-inline-image:focus-within .ticket-composer-inline-image-resize,
.ticket-composer-inline-image.is-resizing .ticket-composer-inline-image-resize {
  opacity: 1;
}

.ticket-composer-inline-image-resize.nw { top: -4px; left: -4px; cursor: nwse-resize; }
.ticket-composer-inline-image-resize.ne { top: -4px; right: -4px; cursor: nesw-resize; }
.ticket-composer-inline-image-resize.sw { bottom: -4px; left: -4px; cursor: nesw-resize; }
.ticket-composer-inline-image-resize.se { right: -4px; bottom: -4px; cursor: nwse-resize; }

.ticket-inline-image-modal {
  width: min(720px, calc(100vw - 32px));
}

.ticket-inline-image-cropper {
  display: grid;
  gap: 10px;
}

.ticket-inline-image-crop-stage {
  position: relative;
  width: 100%;
  height: min(54vh, 460px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.ticket-inline-image-crop-stage > img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.ticket-inline-image-crop-selection {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.45);
  cursor: move;
  outline: none;
}

.ticket-inline-image-crop-selection:focus-visible {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent), 0 0 0 9999px rgba(15, 23, 42, 0.45);
}

.ticket-inline-image-crop-selection span {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 3px;
  background: var(--brand);
}

.ticket-inline-image-crop-selection span[data-inline-image-crop-handle="nw"] { top: -7px; left: -7px; cursor: nwse-resize; }
.ticket-inline-image-crop-selection span[data-inline-image-crop-handle="ne"] { top: -7px; right: -7px; cursor: nesw-resize; }
.ticket-inline-image-crop-selection span[data-inline-image-crop-handle="sw"] { bottom: -7px; left: -7px; cursor: nesw-resize; }
.ticket-inline-image-crop-selection span[data-inline-image-crop-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.ticket-inline-image-crop-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 520px) {
  .timeline-attachment-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .timeline-attachment-actions {
    grid-column: 1 / -1;
  }

  .ticket-inline-image-crop-stage {
    height: min(46vh, 360px);
  }
}

.article-editor-modal {
  width: min(980px, calc(100vw - 32px));
  max-width: none;
}

.article-rich-field {
  display: grid;
  gap: 6px;
}

.article-rich-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.article-rich-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.article-rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.article-rich-toolbar button,
.article-rich-image-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
}

.article-rich-toolbar button:hover,
.article-rich-image-button:hover {
  border-color: var(--line);
  background: var(--surface);
  color: var(--brand);
}

.article-rich-toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: var(--line);
}

.article-rich-image-button input {
  display: none;
}

.article-rich-editable {
  min-height: 280px;
  padding: 14px;
  color: var(--ink);
  line-height: 1.55;
  outline: none;
}

.article-rich-editable:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.55);
}

.article-rich-editable > :first-child,
.article-reader-content > :first-child {
  margin-top: 0;
}

.article-rich-editable > :last-child,
.article-reader-content > :last-child {
  margin-bottom: 0;
}

.article-rich-editable h2,
.article-reader-content h2 {
  margin: 18px 0 8px;
  font-size: 18px;
}

.article-rich-editable h3,
.article-reader-content h3 {
  margin: 15px 0 7px;
  font-size: 15px;
}

.article-rich-editable ul,
.article-rich-editable ol,
.article-reader-content ul,
.article-reader-content ol {
  padding-left: 22px;
}

.article-rich-editable figure,
.article-reader-content figure {
  margin: 14px 0;
}

.article-rich-editable figure[data-article-selected-image="true"] {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

.article-rich-editable figure img,
.article-reader-content figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.article-rich-editable .article-image-size-small,
.article-reader-content .article-image-size-small {
  max-width: 360px;
}

.article-rich-editable .article-image-size-medium,
.article-reader-content .article-image-size-medium {
  max-width: 640px;
}

.article-rich-editable .article-image-size-large,
.article-reader-content .article-image-size-large {
  max-width: 100%;
}

.article-rich-cropper {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.article-rich-cropper-head,
.article-rich-crop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.article-rich-cropper-head button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
}

.article-rich-crop-preview {
  position: relative;
  justify-self: center;
  width: min(100%, 520px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e8eef7;
}

.article-rich-crop-preview img {
  position: absolute;
  max-width: none;
}

.article-rich-crop-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.article-rich-crop-controls label {
  display: grid;
  gap: 4px;
}

.article-rich-crop-controls label.full {
  grid-column: 1 / -1;
}

.article-rich-crop-controls span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.article-reader-content {
  color: var(--ink);
  line-height: 1.55;
}

.article-reader-content a {
  color: var(--brand);
  font-weight: 750;
}

@media (max-width: 640px) {
  .article-editor-modal {
    width: calc(100vw - 16px);
  }

  .article-rich-editable {
    min-height: 220px;
  }

  .article-rich-crop-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Expanded ticket context keeps the update controls and requester context in one scan-friendly editor. */
.ticket-detail-content.is-expanded .ticket-workspace-grid {
  grid-template-columns: minmax(0, 1fr) minmax(620px, 0.82fr);
}

.ticket-detail-content.is-expanded .ticket-properties {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
}

.ticket-detail-content.is-expanded .ticket-context-top-grid {
  grid-template-columns: minmax(300px, 1.5fr) minmax(220px, 0.9fr);
  gap: 20px;
}

.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-quick-fields,
.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-panel {
  min-width: 0;
}

.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-panel {
  gap: 10px;
  padding-left: 20px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .ticket-context-inline-fields {
  gap: 9px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .ticket-project-deadline {
  margin-bottom: 10px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field {
  grid-template-columns: 80px minmax(0, 1fr);
  gap: 8px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: none;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field select,
.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field input {
  width: 100%;
  max-width: 200px;
  min-height: 38px;
  padding: 6px 10px;
  font-size: 12px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .ticket-field-stack-secondary {
  margin-top: 26px;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.ticket-detail-content.is-expanded .ticket-context-person strong {
  font-size: 17px;
}

.ticket-detail-content.is-expanded .ticket-context-person span {
  font-size: 12px;
}

.ticket-detail-content.is-expanded .ticket-context-requester-facts,
.ticket-detail-content.is-expanded .ticket-context-summary-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.ticket-detail-content.is-expanded .ticket-context-requester-facts dt,
.ticket-detail-content.is-expanded .ticket-context-summary-grid dt {
  font-size: 10px;
}

.ticket-detail-content.is-expanded .ticket-context-requester-facts dd,
.ticket-detail-content.is-expanded .ticket-context-summary-grid dd {
  font-size: 12px;
  white-space: normal;
}

.ticket-detail-content.is-expanded .ticket-context-top-fields,
.ticket-detail-content.is-expanded .ticket-context-bottom-fields {
  gap: 8px;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field {
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field span {
  font-size: 10px;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field select,
.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field input {
  width: 100%;
  max-width: 150px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 12px;
}

/* Keep the compact details rail stable so conversation review uses the remaining workspace. */
.ticket-detail-content.is-expanded .ticket-workspace-grid {
  grid-template-columns: minmax(280px, 1fr) 376px;
}

.ticket-detail-content.is-expanded .ticket-context-top-grid {
  grid-template-columns: repeat(2, minmax(0, 170px));
  gap: 12px;
  justify-content: start;
}

.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-panel {
  padding-left: 14px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field select {
  max-width: none;
}

.ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field input {
  max-width: none;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field {
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field select {
  max-width: none;
}

.ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field input {
  max-width: none;
}

.ticket-detail-content.is-expanded .ticket-context-requester-facts {
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
}

.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-requester {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.ticket-detail-content.is-expanded .ticket-context-summary-grid {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-requester-facts {
  grid-template-columns: minmax(0, 1fr);
}

.ticket-detail-content.is-expanded .ticket-properties > .ticket-attachments {
  width: 100%;
  max-width: 340px;
  justify-self: start;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.ticket-detail-content.is-expanded .ticket-properties > .ticket-attachments .ticket-attachment-list {
  max-height: 180px;
}

/* Shared action hierarchy keeps dense operational screens calm and predictable. */
:root {
  --action-height: 34px;
  --switch-height: 30px;
  --control-radius: 5px;
  --active-surface: color-mix(in srgb, var(--brand) 8%, var(--surface));
  --active-border: color-mix(in srgb, var(--brand) 32%, var(--line));
}

.primary-action,
.text-button,
.icon-button,
.row-menu summary,
.action-menu summary {
  min-height: var(--action-height);
  border-radius: var(--control-radius);
  box-shadow: none;
}

.primary-action {
  padding: 0 11px;
  background: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--brand-2);
  box-shadow: none;
}

.text-button {
  padding: 0 10px;
  font-weight: 750;
}

.icon-button {
  width: var(--action-height);
  min-width: var(--action-height);
}

/* Queue row actions use the same compact action frame without changing row density. */
.queue-table .queue-ticket-open {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
}

.ticket-expand-toggle {
  min-width: var(--action-height);
  min-height: var(--action-height);
}

.row-menu:not(.single-submit-menu) summary,
.action-menu summary {
  min-height: var(--action-height);
  padding-inline: 10px;
  border-color: var(--line-strong);
  background: var(--surface);
  font-weight: 750;
}

.row-menu[open]:not(.single-submit-menu) summary,
.action-menu[open] summary,
.choice-dropdown[open] summary {
  border-color: var(--active-border);
  background: var(--active-surface);
  color: var(--brand);
  box-shadow: none;
}

.segmented,
.composer-mode,
.ticket-log-switch,
.settings-tabs {
  gap: 3px;
  padding: 3px;
  border-radius: 6px;
  background: var(--surface-2);
  box-shadow: none;
}

.segmented button,
.composer-mode button,
.ticket-log-switch button,
.settings-tabs button,
.theme-switch button,
.contract-health-tabs button {
  min-height: var(--switch-height);
  padding-inline: 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 750;
}

.segmented button.active,
.composer-mode button.active,
.ticket-log-switch button.active,
.settings-tabs button.active,
.theme-switch button.active,
.contract-health-tabs button.active {
  background: var(--active-surface);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--active-border);
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  grid-template-columns: none;
  margin-top: 12px;
}

.settings-tabs button {
  flex: 0 1 auto;
  min-width: 0;
}

.user-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}

.user-mode-switch button {
  flex: 1 1 180px;
  min-height: var(--action-height);
  padding: 6px 9px;
  border-radius: var(--control-radius);
  background: var(--surface);
  font-size: 12px;
}

.user-mode-switch button.active {
  border-color: var(--active-border);
  background: var(--active-surface);
  color: var(--brand);
  box-shadow: inset 2px 0 0 var(--brand);
}

.ticket-view-button {
  min-height: var(--switch-height);
  padding: 4px 7px;
  border-left-width: 2px;
  border-radius: var(--control-radius);
  box-shadow: none;
}

.ticket-view-button.active {
  border-color: color-mix(in srgb, var(--view-accent) 36%, var(--line));
  border-left-color: var(--view-accent);
  background: var(--view-surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--view-accent) 16%, transparent);
}

.ticket-view-button b {
  min-width: 20px;
  min-height: 18px;
  font-size: 10px;
}

.kb-filters button,
.report-group-tab {
  min-height: var(--switch-height);
  padding: 0 9px;
  border-radius: var(--control-radius);
  font-size: 11px;
}

.kb-filters button.active,
.report-group-tab.active,
.queue-sort-button.active {
  border-color: var(--active-border);
  background: var(--active-surface);
  color: var(--brand);
  box-shadow: none;
}

.queue-sort-button {
  min-height: 28px;
  padding-inline: 6px;
}

html[data-theme="dark"] .primary-action {
  background: var(--brand);
}

html[data-theme="dark"] .row-menu summary,
html[data-theme="dark"] .action-menu summary {
  background: var(--surface-2);
}

.portal-switch {
  gap: 3px;
  padding: 3px;
  border-radius: 6px;
}

.portal-switch button {
  min-height: var(--switch-height);
  border-radius: 4px;
  font-size: 11px;
}

.portal-switch button.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* Context disclosures remain aligned to their label inside the fixed detail rail. */
.ticket-context-details summary {
  display: grid;
  grid-template-columns: 14px minmax(0, max-content) auto;
  justify-content: start;
  gap: 6px;
}

.ticket-context-details summary::before {
  grid-column: 1;
}

.ticket-context-details summary .ticket-context-summary-label {
  min-width: 0;
  grid-column: 2;
  margin-left: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.ticket-context-summary-count {
  min-width: 18px;
  min-height: 18px;
  display: inline-grid;
  grid-column: 3;
  place-items: center;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

/* Operational registers scroll inside their panel, leaving filtering and paging in view. */
.asset-table,
.license-table,
.contract-table,
.user-table {
  overflow: visible;
}

.record-list-viewport {
  max-block-size: clamp(300px, calc(100dvh - 380px), 640px);
  display: grid;
  gap: var(--space-2);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: var(--space-1);
}

.record-list-viewport:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.72);
  outline-offset: 3px;
}

.record-list-viewport > .asset-row.header,
.record-list-viewport > .license-row.header,
.record-list-viewport > .contract-row.header,
.record-list-viewport > .user-row.header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel-bg);
}

.record-action-heading {
  min-width: 0;
  overflow: visible !important;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-align: center !important;
  text-indent: 0 !important;
}

.record-list-viewport:has(.row-menu[open]) {
  overflow: visible;
}

@media (max-width: 760px) {
  .record-list-viewport {
    max-block-size: clamp(250px, calc(100dvh - 300px), 520px);
  }
}

@media (max-width: 1100px) {
  .ticket-detail-content.is-expanded .ticket-workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticket-detail-content.is-expanded .ticket-properties {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 520px) {
  .ticket-detail-content.is-expanded .ticket-context-top-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .ticket-detail-content.is-expanded .ticket-context-top-grid .ticket-context-panel {
    padding-left: 0;
    padding-top: var(--space-3);
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field,
  .ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field select,
  .ticket-detail-content.is-expanded .ticket-quick-fields .inline-ticket-field input,
  .ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field select,
  .ticket-detail-content.is-expanded .ticket-context-inline-fields .inline-ticket-field input {
    max-width: none;
  }

  .stock-workspace-card .section-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) 38px;
    width: 100%;
    gap: 6px;
  }

  .stock-workspace-card .section-actions > * {
    min-width: 0;
    width: auto;
    flex: none;
  }

  .stock-workspace-card .section-actions .text-button,
  .stock-workspace-card .section-actions .primary-action {
    min-width: 0;
    padding: 0 8px;
    white-space: nowrap;
  }

  .stock-workspace-card .section-actions .icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 36px;
  }
}

/* Keep focus visible inside the control instead of drawing a halo around it. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
main:focus,
.record-list-viewport:focus-visible,
.article-rich-editable:focus-visible {
  outline: none !important;
  outline-offset: 0 !important;
  box-shadow: none !important;
}

:where(button:not(.primary-action), summary):hover,
:where(button:not(.primary-action), summary):focus,
:where(button:not(.primary-action), summary):focus-visible,
:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
  border-color: var(--active-border);
  background: var(--active-surface);
  box-shadow: inset 0 0 0 1px var(--active-border) !important;
}

.primary-action:focus,
.primary-action:focus-visible {
  border-color: color-mix(in srgb, var(--brand-2) 74%, #ffffff);
  background: var(--brand-2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34) !important;
}

:where(a, [tabindex]):focus-visible {
  outline: 1px solid var(--active-border) !important;
  outline-offset: 1px !important;
  background: var(--active-surface);
}

:where(input[type="checkbox"], input[type="radio"]):focus-visible {
  outline: 1px solid var(--active-border) !important;
  outline-offset: 1px !important;
}

.article-rich-editable:focus-visible {
  border-color: var(--active-border);
  background: var(--active-surface);
  box-shadow: inset 0 0 0 1px var(--active-border) !important;
}

.text-button.edit-action,
.ticket-queue-edit-button {
  min-height: 28px;
  height: 28px;
  padding-inline: 8px;
  font-size: 11px;
}

/* Sidebar account controls stay compact without losing their labels or keyboard targets. */
.session-panel {
  gap: 8px;
  padding: 10px;
}

.session-identity {
  min-width: 0;
}

.session-panel .session-identity strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-panel .session-identity p {
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-actions {
  display: grid;
  gap: 5px;
  align-items: center;
}

.session-actions[data-account-actions="admin"] {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.session-actions[data-account-actions="standard"],
.session-actions[data-account-actions="impersonating"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.session-impersonate-select {
  min-width: 0;
  height: 28px;
  padding: 0 22px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--control-radius);
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font: inherit;
  font-size: 10px;
  font-weight: 750;
}

.session-impersonate-select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

/* Native option lists do not inherit the sidebar surface, so keep account names readable. */
.session-impersonate-select option,
.session-impersonate-select optgroup {
  background: var(--surface);
  color: var(--ink);
}

.session-panel .session-actions .text-button {
  min-height: 28px;
  height: 28px;
  padding: 0 8px;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  font-size: 10px;
  font-weight: 750;
}

.session-panel .session-actions .text-button:hover,
.session-panel .session-actions .text-button:focus-visible,
.session-impersonate-select:hover,
.session-impersonate-select:focus-visible {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.session-panel .session-actions .sign-out-action {
  background: transparent;
}

@media (max-width: 1180px) {
  .session-actions[data-account-actions="admin"] {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .session-actions[data-account-actions="admin"] .sign-out-action {
    grid-column: 1 / -1;
  }
}

/* Keep floating controls inside the usable viewport before constraining their content. */
[data-viewport-popup-host] {
  --popup-gap: 6px;
}

.ticket-tag-entry {
  --popup-gap: 4px;
}

.popup-opens-upward > [data-viewport-popup] {
  top: auto !important;
  bottom: calc(100% + var(--popup-gap));
}

.popup-align-start > [data-viewport-popup] {
  right: auto !important;
  left: 0 !important;
  inset-inline: auto;
}

.popup-align-end > [data-viewport-popup] {
  right: 0 !important;
  left: auto !important;
  inset-inline: auto;
}

/* Separate requester identity from the ticket's editable and operational details. */
.ticket-context-panel-top {
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--blue) 18%, var(--line));
  border-radius: 7px;
  background: color-mix(in srgb, var(--blue-soft) 46%, var(--surface));
}

.ticket-context-panel-top .ticket-context-requester {
  gap: 6px;
  padding-bottom: 0;
  border-bottom: 0;
}

html[data-theme="dark"] .ticket-context-panel-top {
  border-color: rgba(96, 165, 250, 0.26);
  background: rgba(30, 58, 96, 0.42);
}

/* Keep reusable information cards on dark surfaces instead of inheriting light-mode white fills. */
html[data-theme="dark"] .profile-summary-grid article,
html[data-theme="dark"] .profile-row,
html[data-theme="dark"] .detail-stat,
html[data-theme="dark"] .employee-ticket-summary div,
html[data-theme="dark"] .employee-ticket-description,
html[data-theme="dark"] .employee-ticket-updates li,
html[data-theme="dark"] .contract-row:not(.header),
html[data-theme="dark"] .license-row:not(.header),
html[data-theme="dark"] .notification-card,
html[data-theme="dark"] .dependency-node,
html[data-theme="dark"] .lifecycle-card,
html[data-theme="dark"] .agreement-card,
html[data-theme="dark"] .license-user-card,
html[data-theme="dark"] .license-contract-card,
html[data-theme="dark"] .license-action-card,
html[data-theme="dark"] .template-card,
html[data-theme="dark"] .notification-log-card,
html[data-theme="dark"] .smtp-card {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: none;
}

/* Keep the directory summary and filters compact enough for a single desktop row. */
@media (min-width: 1200px) {
  .user-metrics {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  .users-list-controls {
    grid-template-columns: minmax(160px, 0.22fr) minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }

  .users-list-controls .list-filter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
  }

  .users-list-controls .list-control select {
    padding-inline: 8px;
  }
}

/* Keep the icon-only theme control aligned with the compact mobile header. */
@media (max-width: 760px) {
  .top-actions {
    grid-template-columns: minmax(0, 1fr) 74px;
  }

  .top-actions .global-search {
    grid-column: 1 / -1;
  }

  .top-actions .primary-action {
    grid-column: 1;
    grid-row: 2;
  }

  .top-actions .theme-switch {
    grid-column: 2;
    grid-row: 2;
    width: 74px;
    min-width: 74px;
  }

  /* Form fields keep a comfortable touch target without expanding dense tables and inline ticket controls. */
  :where(.ticket-form, .modal-form) :where(.form-field, .field-block):not(.list-control):not(.inline-ticket-field):not(.access-type-control) > :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select) {
    min-height: var(--field-height);
    height: var(--field-height);
  }

  :where(.ticket-form, .modal-form) .choice-dropdown > summary {
    min-height: var(--field-height);
  }

  .article-rich-crop-controls .form-field > :where(select, input:not([type="range"])) {
    min-height: var(--field-compact-height);
    height: var(--field-compact-height);
  }
}

/* Ticket actions stay out of the title's reading width. */
.ticket-detail .detail-top {
  display: grid;
  grid-template-areas:
    "heading actions"
    "description description";
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-2);
  row-gap: var(--space-2);
  align-items: start;
}

.ticket-detail .ticket-heading {
  grid-area: heading;
  width: 100%;
}

.ticket-detail .detail-subtitle {
  max-width: none;
}

.ticket-detail .ticket-description-full {
  grid-area: description;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.ticket-detail .detail-actions {
  --ticket-header-action-size: var(--action-button-compact-height);

  grid-area: actions;
  justify-self: end;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  margin-bottom: 0;
}

.ticket-detail .detail-actions .ticket-viewer-presence,
.ticket-detail .detail-actions .ticket-permalink-button,
.ticket-detail .detail-actions .ticket-expand-toggle,
.ticket-detail .detail-actions .ticket-context-edit-button,
.ticket-detail .detail-actions .ticket-subticket-action,
.ticket-detail .detail-actions .ticket-side-conversation-action,
.ticket-detail .detail-actions .ticket-delete-action,
.ticket-detail .detail-actions .action-menu,
.ticket-detail .detail-actions .action-menu > summary {
  flex: 0 0 var(--ticket-header-action-size);
  width: var(--ticket-header-action-size);
  min-width: var(--ticket-header-action-size);
  height: var(--ticket-header-action-size);
  min-height: var(--ticket-header-action-size);
  padding: 0;
}

.ticket-detail .detail-actions :is(.ticket-viewer-presence, .ticket-permalink-button, .ticket-expand-toggle, .ticket-context-edit-button, .ticket-subticket-action, .ticket-side-conversation-action, .ticket-delete-action, .action-menu > summary) {
  display: grid;
  place-items: center;
}

.ticket-detail .detail-actions :is(.ticket-permalink-button svg, .ticket-edit-icon, .ticket-viewport-icon, .ticket-viewer-presence svg, .ticket-subticket-action .queue-subticket-branch, .ticket-side-conversation-action svg, .ticket-delete-action svg) {
  width: 16px;
  height: 16px;
}

.ticket-detail .detail-actions .action-menu > summary > span {
  font-size: 16px;
  line-height: 1;
}

.ticket-title-edit-button .ticket-edit-icon {
  width: 16px;
  height: 16px;
}

.ticket-detail .detail-actions .ticket-delete-action {
  color: var(--danger);
}

.ticket-detail .detail-actions .ticket-delete-action:hover,
.ticket-detail .detail-actions .ticket-delete-action:focus-visible {
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line-strong));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger);
}

/* Full-width headers show direct actions; the same actions collapse into More on narrow screens. */
.ticket-detail .detail-actions .ticket-compact-actions {
  display: none;
}

/* Keep the title edit control on the same baseline as the header action row. */
.ticket-detail .ticket-title-edit-button {
  flex: 0 0 var(--ticket-header-action-size);
  width: var(--ticket-header-action-size);
  min-width: var(--ticket-header-action-size);
  height: var(--ticket-header-action-size);
  min-height: var(--ticket-header-action-size);
  margin-top: 2px;
  padding: 0;
}

@media (max-width: 760px) {
  .ticket-detail .detail-top {
    grid-template-areas:
      "heading"
      "actions"
      "description";
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--space-2);
  }

  .ticket-detail .detail-actions {
    justify-self: stretch;
    justify-content: flex-start;
    margin-top: 0;
  }

  .ticket-detail .detail-actions .ticket-side-conversation-action,
  .ticket-detail .detail-actions .ticket-delete-action {
    display: none;
  }

  .ticket-detail .detail-actions .ticket-compact-actions {
    display: block;
  }
}

/* Intake fields follow the same compact, scan-first grid as the rest of the portal. */
.ticket-form.ticket-intake-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ticket-form.ticket-intake-form .span-full {
  grid-column: 1 / -1;
}

.ticket-form.ticket-intake-form > .ticket-raiser-host,
.ticket-form.ticket-intake-form > .ticket-form-metadata-host,
.ticket-form.ticket-intake-form .ticket-form-metadata {
  display: contents;
}

.ticket-form.ticket-intake-form .ticket-raiser-field {
  gap: var(--field-label-gap);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.ticket-form.ticket-intake-form .ticket-raiser-field > span {
  margin-bottom: 0;
}

.ticket-form.ticket-intake-form .form-field > .field-label,
.ticket-form.ticket-intake-form .field-block > .field-label {
  margin-bottom: 0;
}

.ticket-form.ticket-intake-form .dynamic-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 960px) {
  .ticket-form.ticket-intake-form,
  .ticket-form.ticket-intake-form .dynamic-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .ticket-form.ticket-intake-form,
  .ticket-form.ticket-intake-form .dynamic-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Canonical action sizing: pages use one calm control scale, while dense lists opt into compact controls. */
:root {
  --action-button-height: 34px;
  --action-button-compact-height: 30px;
}

.primary-action,
.text-button,
.icon-button,
.row-menu > summary,
.action-menu > summary {
  min-height: var(--action-button-height);
  height: var(--action-button-height);
  box-sizing: border-box;
}

.primary-action,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-inline: 10px;
  line-height: 1;
  white-space: nowrap;
}

.icon-button,
.row-menu:not(.single-submit-menu) > summary,
.action-menu > summary {
  width: var(--action-button-height);
  min-width: var(--action-button-height);
  padding-inline: 0;
}

.profile-actions-strip,
.selected-license-actions,
.inline-actions,
.section-actions,
.modal-actions,
.detail-actions,
.form-actions {
  align-items: center;
}

.profile-actions-strip,
.selected-license-actions {
  gap: 6px;
}

/* Full-word actions in cards and dialogs share the same height, including Edit. */
.text-button.edit-action:not(.ticket-queue-edit-button),
.profile-actions-strip .text-button,
.selected-license-actions .text-button,
.modal-actions :where(.primary-action, .text-button),
.section-actions > :where(.primary-action, .text-button) {
  min-height: var(--action-button-height);
  height: var(--action-button-height);
}

/* Lists, queue controls, and icon affordances remain deliberately denser. */
:where(.row-actions, .ticket-column-row-actions) :where(.text-button, .icon-button, .row-menu > summary, .action-menu > summary),
.text-button.compact,
.compact-action,
.icon-button.compact {
  min-height: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
}

:where(.row-actions, .ticket-column-row-actions) :where(.icon-button, .row-menu > summary, .action-menu > summary),
.icon-button.compact {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
}

/* Dense queue tools and ticket header affordances share the compact icon scale. */
.queue-list-controls .text-button,
.queue-list-controls .icon-button,
.queue-list-controls .row-menu > summary,
.queue-list-controls .action-menu > summary,
.queue-list-controls .ticket-queue-edit-button,
.queue-list-actions .queue-refresh-button,
.queue-list-actions .queue-deleted-tickets-button,
.queue-page-size-control .list-control,
.queue-page-size-control .list-control select {
  min-height: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
}

.queue-list-actions .queue-refresh-button,
.queue-list-actions .queue-deleted-tickets-button {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
}

.queue-list-actions .queue-refresh-button,
.queue-list-actions .queue-deleted-tickets-button {
  flex: 0 0 var(--action-button-compact-height);
}

/* Keep room for three-digit page sizes without turning the selector into an icon box. */
.queue-page-size-control .list-control select {
  width: 64px;
  min-width: 64px;
  padding-inline: 7px;
}

.detail-actions .ticket-viewer-presence,
.detail-actions .ticket-permalink-button,
.detail-actions .ticket-expand-toggle,
.detail-actions .ticket-context-edit-button,
.detail-actions .ticket-subticket-action,
.detail-actions .action-menu,
.detail-actions .action-menu > summary,
.modal-head .icon-button,
.ticket-title-edit-button,
.anydesk-launch-button,
.ticket-filter-row .icon-button.compact {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
}

.detail-actions .ticket-viewer-presence,
.detail-actions .ticket-permalink-button,
.detail-actions .ticket-expand-toggle,
.detail-actions .ticket-context-edit-button,
.detail-actions .ticket-subticket-action,
.detail-actions .action-menu {
  flex: 0 0 var(--action-button-compact-height);
}

.ticket-queue-edit-button {
  padding-inline: 10px;
  font-size: 12px;
}

.row-actions .text-button,
.row-actions .icon-button,
.row-actions .row-menu > summary,
.ticket-column-row-actions .text-button,
.ticket-column-row-actions .icon-button,
.ticket-column-row-actions .row-menu > summary {
  min-height: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
}

/* Icon-only controls use one compact frame throughout the portal. Text and numeric controls stay content-sized. */
.icon-button,
.row-menu:not(.single-submit-menu) > summary,
.action-menu > summary {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
}

/* These earlier component rules have stronger selectors, so align their frames explicitly. */
body .rail-actions .icon-button.compact,
body .ticket-filter-row .icon-button.compact,
body .ticket-column-drag,
body .ticket-column-row-actions .icon-button,
body .stock-workspace-card .section-actions .icon-button {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
}

@media (max-width: 760px) {
  .icon-button {
    width: var(--action-button-compact-height);
  }
}

/* Final portal icon contract: one quiet frame, regardless of legacy component selectors. */
.icon-button,
.anydesk-launch-button,
.row-menu:not(.single-submit-menu) > summary,
.action-menu > summary {
  box-sizing: border-box;
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  background: var(--surface);
  box-shadow: none;
  color: var(--ink);
  line-height: 1;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.icon-button:hover,
.icon-button:focus,
.icon-button:focus-visible,
.anydesk-launch-button:hover,
.anydesk-launch-button:focus-visible,
.row-menu:not(.single-submit-menu) > summary:hover,
.row-menu:not(.single-submit-menu) > summary:focus-visible,
.action-menu > summary:hover,
.action-menu > summary:focus-visible {
  border-color: var(--active-border);
  background: var(--active-surface);
  box-shadow: none !important;
  color: var(--brand);
  outline: none !important;
  transform: none;
}

/* Stronger historic component selectors still inherit the shared frame above. */
body .rail-actions .icon-button.compact,
body .ticket-filter-row .icon-button.compact,
body .ticket-column-drag,
body .ticket-column-row-actions .icon-button,
body .stock-workspace-card .section-actions .icon-button,
.mailbox-remove,
.structured-remove,
.stock-receipt-remove,
.queue-reorder-handle,
.queue-move-button,
.ticket-title-edit-button,
.queue-ticket-open {
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
  padding: 0;
}

/* Modal headers stay legible while long records scroll beneath them. */
.modal-panel > .modal-head {
  position: sticky;
  z-index: 4;
  top: 0;
  isolation: isolate;
  background: var(--surface);
}

/* Only controls deliberately marked as dense use the smaller icon frame. */
:root {
  --action-button-micro-icon-size: 20px;
  --action-button-micro-icon-glyph-size: 10px;
}

.icon-button.compact,
.ticket-title-edit-button,
.timeline-note-edit-button,
.ticket-attachment-action,
.queue-ticket-open {
  flex: 0 0 var(--action-button-micro-icon-size);
  width: var(--action-button-micro-icon-size);
  min-width: var(--action-button-micro-icon-size);
  height: var(--action-button-micro-icon-size);
  min-height: var(--action-button-micro-icon-size);
  padding: 0;
  font-size: 11px;
}

.icon-button.compact :is(svg, .ticket-edit-icon, .attachment-action-icon),
.ticket-title-edit-button :is(svg, .ticket-edit-icon, .attachment-action-icon),
.timeline-note-edit-button :is(svg, .ticket-edit-icon, .attachment-action-icon),
.ticket-attachment-action :is(svg, .ticket-edit-icon, .attachment-action-icon),
.queue-ticket-open :is(svg, .ticket-edit-icon, .attachment-action-icon) {
  width: var(--action-button-micro-icon-glyph-size);
  height: var(--action-button-micro-icon-glyph-size);
}

/* These are intentionally larger page-level controls, not dense utility icons. */
.top-actions .icon-button,
.stock-workspace-card .section-actions .icon-button {
  flex-basis: var(--action-button-compact-height);
  width: var(--action-button-compact-height);
  min-width: var(--action-button-compact-height);
  height: var(--action-button-compact-height);
  min-height: var(--action-button-compact-height);
}

/* Queue refresh and bin actions are primary toolbar controls, so match Rows and Edit. */
.queue-list-controls .queue-list-actions > :is(.queue-refresh-button, .queue-deleted-tickets-button) {
  flex: 0 0 var(--action-button-height);
  width: var(--action-button-height);
  min-width: var(--action-button-height);
  height: var(--action-button-height);
  min-height: var(--action-button-height);
}

html[data-theme="dark"] .modal-panel > .modal-head {
  background: var(--surface);
}

