:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --line: #dce4ef;
  --line-strong: #c8d3e2;
  --text: #13233a;
  --ink: #13233a;
  --muted: #607089;
  --muted-2: #8a98ad;
  --blue: #0f62d9;
  --blue-soft: #e9f1ff;
  --teal: #13a68b;
  --green: #1fa463;
  --amber: #e99b19;
  --red: #dc3545;
  --orange-soft: #fff1e4;
  --shadow: 0 12px 30px rgba(31, 46, 70, 0.08);
  --shadow-soft: 0 8px 22px rgba(31, 46, 70, 0.06);
  --focus-ring: 0 0 0 3px rgba(15, 98, 217, 0.14);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1724;
  --surface: #151f2f;
  --surface-soft: #1b273a;
  --line: #2d3b52;
  --line-strong: #3b4a63;
  --text: #e7edf6;
  --ink: #e7edf6;
  --muted: #a8b4c6;
  --muted-2: #748299;
  --blue: #70a7ff;
  --blue-soft: #172b4f;
  --teal: #4fd1c5;
  --green: #5fce8d;
  --amber: #f0b94c;
  --red: #ff6b7a;
  --orange-soft: #3a2a1d;
  --shadow: 0 18px 36px rgba(0, 0, 0, 0.36);
  --shadow-soft: 0 12px 26px rgba(0, 0, 0, 0.26);
  --focus-ring: 0 0 0 3px rgba(112, 167, 255, 0.22);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body.sidebar-lock {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
select,
textarea {
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--blue) !important;
  box-shadow: var(--focus-ring);
}

:is(button, a, [tabindex="0"]):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

input[type="file"] {
  width: 100%;
  min-height: 42px;
  padding: 6px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
  font-weight: 720;
}

input[type="file"]::file-selector-button {
  height: 30px;
  margin-right: 10px;
  padding: 0 12px;
  color: var(--blue);
  border: 1px solid #bdd2ee;
  border-radius: 7px;
  background: #f5f8fd;
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.toast-region {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
  pointer-events: auto;
}

.toast.error {
  border-left-color: var(--red);
}

.toast.closing {
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast > span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--green);
  border-radius: 999px;
  background: #eaf8f0;
}

.toast.error > span {
  color: var(--red);
  background: #fff2f4;
}

.toast svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
  line-height: 1.3;
}

.toast button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--muted);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.toast button:hover {
  background: var(--surface-soft);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-shell {
  --sidebar-width: 248px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.18s ease;
}

.app-shell.sidebar-collapsed {
  --sidebar-width: 76px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: none;
  border: 0;
  background: rgba(19, 35, 58, 0.42);
  backdrop-filter: blur(2px);
}

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

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 22px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.auth-tabs button {
  height: 34px;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 760;
  cursor: pointer;
}

.auth-tabs button.active {
  color: var(--blue);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.auth-fields {
  display: grid;
  gap: 14px;
}

.two-factor-fields p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.two-factor-setup {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.two-factor-qr {
  display: grid;
  place-items: center;
  justify-self: start;
  width: 188px;
  height: 188px;
  padding: 12px;
  border: 1px solid #d7e2f2;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.two-factor-qr svg {
  display: block;
  width: 100%;
  height: 100%;
}

.two-factor-qr span {
  color: #526279;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
  text-align: center;
}

.two-factor-setup span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.two-factor-setup code {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 15px;
  font-weight: 820;
  letter-spacing: 0.08em;
}

.two-factor-setup a {
  color: var(--primary);
  font-size: 13px;
  font-weight: 780;
  text-decoration: none;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 730;
}

.login-card input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-brand {
  height: auto;
  padding: 0;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: var(--sidebar-width);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
  transition:
    width 0.18s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 70px;
  padding: 0 18px;
  font-size: 20px;
  font-weight: 760;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--action);
  border-radius: var(--radius);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--action) 25%, transparent);
}

.brand-mark svg,
.icon svg,
.source-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-list {
  display: grid;
  gap: 6px;
  padding: 16px 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.nav-item strong {
  font-size: 12px;
  padding: 2px 6px;
  background: var(--blue-soft);
  border-radius: 999px;
}

.app-shell.sidebar-collapsed .brand {
  justify-content: center;
  padding: 0;
}

.app-shell.sidebar-collapsed .brand span,
.app-shell.sidebar-collapsed .nav-item span:not(.icon),
.app-shell.sidebar-collapsed .nav-item strong,
.app-shell.sidebar-collapsed .theme-toggle-label,
.app-shell.sidebar-collapsed .agent-profile-button > div:last-child {
  display: none;
}

.app-shell.sidebar-collapsed .nav-item {
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
}

.app-shell.sidebar-collapsed .nav-item,
.app-shell.sidebar-collapsed .theme-toggle,
.app-shell.sidebar-collapsed .agent-profile-button,
.app-shell.sidebar-collapsed .logout-button {
  position: relative;
}

.app-shell.sidebar-collapsed .nav-item::after,
.app-shell.sidebar-collapsed .theme-toggle::after,
.app-shell.sidebar-collapsed .agent-profile-button::after,
.app-shell.sidebar-collapsed .logout-button::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  z-index: 40;
  width: max-content;
  max-width: 220px;
  padding: 7px 9px;
  color: #fff;
  border-radius: 7px;
  background: #18253a;
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 740;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-4px);
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
}

.app-shell.sidebar-collapsed .nav-item:hover::after,
.app-shell.sidebar-collapsed .theme-toggle:hover::after,
.app-shell.sidebar-collapsed .agent-profile-button:hover::after,
.app-shell.sidebar-collapsed .logout-button:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.app-shell.sidebar-collapsed .agent-card {
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding-inline: 10px;
}

.app-shell.sidebar-collapsed .agent-profile-button {
  flex: 0 0 auto;
}

.app-shell.sidebar-collapsed .theme-toggle {
  justify-content: center;
  padding: 0;
}

.app-shell.sidebar-collapsed .logout-button {
  width: 38px;
  padding: 0;
}

.app-shell.sidebar-collapsed .logout-label {
  display: none;
}

.agent-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.theme-toggle {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 780;
  transition:
    color 0.16s ease,
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.theme-toggle:hover,
.theme-toggle[aria-pressed="true"] {
  color: var(--blue);
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.theme-toggle .icon {
  width: 17px;
  height: 17px;
}

.theme-toggle-dark {
  display: none;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-light {
  display: none;
}

/* Purchase orders */
.orders-view {
  padding: 24px;
}

.orders-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.orders-hero h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

.orders-hero p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.order-eyebrow {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.orders-hero .primary-action svg,
.order-product-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.order-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.order-kpis > div {
  display: grid;
  gap: 5px;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.order-kpis span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.order-kpis b {
  font-size: 24px;
}

.order-kpis .danger b {
  color: var(--red);
}

.order-budget-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(170px, .8fr));
  gap: 0;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.order-budget-panel > div:not(.order-budget-progress) {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 88px;
  padding: 14px 18px;
  border-left: 1px solid var(--line);
}

.order-budget-panel > div:first-child { border-left: 0; }
.order-budget-panel span,
.order-budget-panel small { color: var(--muted); font-size: 11px; font-weight: 700; }
.order-budget-panel b { font-size: 22px; }
.order-budget-panel.risk > div:last-of-type b { color: var(--red); }
.order-budget-progress { grid-column: 1 / -1; height: 4px; background: var(--surface-soft); }
.order-budget-progress i { display: block; height: 100%; background: var(--blue); transition: width 180ms ease; }
.order-budget-panel.risk .order-budget-progress i { background: var(--red); }

.order-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(3, minmax(170px, 0.7fr));
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.order-filters label,
.order-delivery-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.order-filters input,
.order-filters select,
.order-delivery-field input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.orders-layout {
  display: block;
}

.orders-list,
.order-detail-card,
.orders-empty-detail {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.orders-list {
  display: block;
  max-height: none;
}

.order-list-header,
.order-list-row {
  display: grid;
  grid-template-columns: 86px minmax(160px, 1.4fr) 58px 92px 82px minmax(90px, .7fr) 98px 120px 112px 18px;
  align-items: center;
  gap: 6px;
}

.order-list-header {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.order-list-row {
  position: relative;
  width: 100%;
  min-height: 66px;
  padding: 9px 14px;
  color: var(--text);
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  background: var(--surface);
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease;
}

.order-list-header + .order-list-row {
  border-top: 0;
}

.order-list-row:hover,
.order-list-row:focus-visible,
.order-list-row.selected {
  background: var(--surface-soft);
}

.order-list-row:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.order-list-row.sla-overdue {
  border-left-color: var(--red);
}

.order-list-row.sla-risk {
  border-left-color: #e99b24;
}

.order-row-id,
.order-row-product {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.order-row-id b {
  color: var(--blue);
  font-size: 11px;
  letter-spacing: .035em;
}

.order-row-id small,
.order-row-product small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row-product b,
.order-row-site,
.order-row-requester,
.order-row-price {
  overflow: hidden;
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-row-quantity {
  color: var(--text);
  font-size: 12px;
  font-weight: 720;
}

.order-row-open {
  color: var(--muted);
  font-size: 24px;
  font-weight: 400;
  text-align: right;
}

.order-row-mobile-meta {
  display: none;
}

.order-list-item {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 122px;
  padding: 14px 16px;
  color: var(--text);
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  background: var(--surface);
  text-align: left;
}

.order-list-item:first-child {
  border-top: 0;
}

.order-list-item:hover,
.order-list-item.selected {
  background: var(--surface-soft);
}

.order-list-item.selected {
  border-left-color: var(--blue);
}

.order-list-item.sla-overdue {
  border-left-color: var(--red);
}

.order-list-item.sla-risk {
  border-left-color: #e99b24;
}

.order-list-item > div,
.order-list-item footer,
.order-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.order-list-item b {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-list-item p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-id {
  color: var(--blue);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.04em;
}

.order-status,
.order-priority,
.order-list-sla {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 780;
  white-space: nowrap;
}

.order-status {
  color: var(--blue);
  background: var(--blue-soft);
}

.order-status.status-received {
  color: #187348;
  background: #e6f7ee;
}

.order-status.status-rejected,
.order-status.status-cancelled {
  color: #a83342;
  background: #fff0f2;
}

.order-status.status-delivery_pending,
.order-status.status-ordered {
  color: #8a5a10;
  background: #fff4dc;
}

.order-priority.priority-urgent {
  color: #a83342;
  background: #fff0f2;
}

.order-priority.priority-normal {
  color: #81540f;
  background: #fff4dc;
}

.order-priority.priority-low {
  color: var(--muted);
  background: var(--surface-soft);
}

.order-list-sla {
  color: var(--muted);
  background: var(--surface-soft);
}

.order-list-sla.risk {
  color: #9a6209;
  background: #fff4dc;
}

.order-list-sla.overdue {
  color: var(--red);
  background: #fff0f2;
}

:root[data-theme="dark"] .order-status.status-received {
  color: var(--green);
  background: color-mix(in srgb, var(--green) 13%, var(--surface));
}

:root[data-theme="dark"] :is(.order-status.status-rejected, .order-status.status-cancelled, .order-priority.priority-urgent, .order-list-sla.overdue) {
  color: var(--red);
  background: color-mix(in srgb, var(--red) 13%, var(--surface));
}

:root[data-theme="dark"] :is(.order-status.status-delivery_pending, .order-status.status-ordered, .order-priority.priority-normal, .order-list-sla.risk) {
  color: var(--warning-ink);
  background: color-mix(in srgb, var(--amber) 13%, var(--surface));
}

.order-detail-overlay {
  position: fixed;
  z-index: 110;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
}

.order-detail-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.order-detail-dialog {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
  max-height: calc(100dvh - 44px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(15, 23, 42, .28);
}

.order-detail-scroll {
  max-height: calc(100dvh - 44px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.order-detail-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.order-detail-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.order-detail-close:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.order-detail-dialog .order-detail-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.order-detail-dialog .order-detail-head {
  padding-right: 48px;
}

body.order-detail-open {
  overflow: hidden;
}

.order-detail-card {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.order-detail-head {
  align-items: flex-start;
}

.order-detail-head h2 {
  margin: 5px 0 0;
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.order-workflow {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 0;
  overflow-x: auto;
}

.order-workflow > div {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 76px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  text-align: center;
}

.order-workflow > div::before {
  position: absolute;
  z-index: 0;
  top: 13px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: var(--line);
  content: "";
}

.order-workflow > div:first-child::before {
  display: none;
}

.order-workflow i {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  font-style: normal;
}

.order-workflow .done::before,
.order-workflow .current::before {
  background: var(--blue);
}

.order-workflow .done i,
.order-workflow .current i {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.order-workflow .current span {
  color: var(--blue);
}

.order-sla {
  display: grid;
  gap: 8px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.order-sla > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}

.order-sla > div:first-child span,
.order-sla small {
  color: var(--muted);
}

.order-sla-line {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.order-sla-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.order-sla.risk .order-sla-line i {
  background: #e99b24;
}

.order-sla.overdue .order-sla-line i {
  background: var(--red);
}

.order-sla.overdue > div:first-child span {
  color: var(--red);
  font-weight: 760;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.order-detail-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.order-detail-grid b {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.order-detail-grid span {
  overflow: hidden;
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
}

.order-product-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  min-height: 38px;
  padding: 0 13px;
  color: var(--blue);
  border: 1px solid #bed6fb;
  border-radius: 9px;
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.order-justification,
.order-rejection {
  display: grid;
  gap: 6px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.order-justification p,
.order-rejection p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.order-rejection {
  border-color: #f3c3c9;
  background: #fff4f5;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.order-action-stack {
  display: grid;
  gap: 10px;
}

.order-reschedule {
  display: grid;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.order-reschedule-head > div,
.order-reschedule-reason {
  display: grid;
  gap: 4px;
}

.order-reschedule-head b {
  font-size: 13px;
}

.order-reschedule-head span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.order-reschedule-fields {
  display: grid;
  grid-template-columns: minmax(180px, .65fr) minmax(240px, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.order-reschedule-reason {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.order-reschedule-reason textarea {
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  resize: vertical;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  line-height: 1.4;
}

.order-delivery-field {
  min-width: 190px;
}

.order-received-action {
  background: var(--green);
}

.order-history {
  display: grid;
  gap: 12px;
}

.order-history h3 {
  margin: 0;
  font-size: 15px;
}

.order-history-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
}

.order-history-item > i {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-soft);
}

.order-history-item > div {
  display: grid;
  gap: 3px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.order-history-item span {
  color: var(--muted);
  font-size: 11px;
}

.order-history-item p {
  margin: 4px 0 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.orders-empty-detail {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: 240px;
  padding: 60px 20px;
  color: var(--muted);
  text-align: center;
}

.order-modal {
  max-width: 680px;
}

.order-budget-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  background: var(--blue-soft);
}

.order-budget-preview > div { display: grid; gap: 3px; min-width: 0; }
.order-budget-preview span { color: var(--muted); font-size: 10px; font-weight: 760; text-transform: uppercase; }
.order-budget-preview b { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.order-budget-preview p { grid-column: 1 / -1; margin: 0; color: var(--red); font-size: 11px; font-weight: 750; }
.order-budget-preview.over-budget { border-color: rgba(211, 58, 73, .35); background: rgba(211, 58, 73, .08); }

.order-workflow-note {
  padding: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: 12px;
  line-height: 1.45;
}

.order-sla-settings-card {
  grid-column: auto;
}

.order-sla-settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-sla-settings-form .settings-note,
.order-sla-settings-form .primary-action {
  grid-column: 1 / -1;
}

:root[data-theme="dark"] .order-kpis > div,
:root[data-theme="dark"] .order-filters,
:root[data-theme="dark"] .orders-list,
:root[data-theme="dark"] .order-detail-card,
:root[data-theme="dark"] .orders-empty-detail,
:root[data-theme="dark"] .order-list-item,
:root[data-theme="dark"] .order-workflow i,
:root[data-theme="dark"] .order-sla,
:root[data-theme="dark"] .order-detail-grid > div,
:root[data-theme="dark"] .order-justification,
:root[data-theme="dark"] .order-actions {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

:root[data-theme="dark"] .order-reschedule,
:root[data-theme="dark"] .order-reschedule-reason textarea {
  color: var(--text);
  background: var(--surface);
}

:root[data-theme="dark"] .order-list-item:hover,
:root[data-theme="dark"] .order-list-item.selected,
:root[data-theme="dark"] .order-list-row:hover,
:root[data-theme="dark"] .order-list-row:focus-visible,
:root[data-theme="dark"] .order-list-row.selected,
:root[data-theme="dark"] .order-sla,
:root[data-theme="dark"] .order-detail-grid > div,
:root[data-theme="dark"] .order-justification,
:root[data-theme="dark"] .order-filters input,
:root[data-theme="dark"] .order-filters select,
:root[data-theme="dark"] .order-delivery-field input {
  background: var(--surface-soft);
}

:root[data-theme="dark"] .order-rejection {
  border-color: rgba(255, 107, 122, 0.3);
  background: rgba(255, 107, 122, 0.1);
}

@media (max-width: 1350px) and (min-width: 1101px) {
  .order-list-header,
  .order-list-row {
    grid-template-columns: 86px minmax(180px, 1fr) 58px 92px 82px 112px 124px 118px 18px;
  }

  .order-list-header > span:nth-child(6),
  .order-row-requester {
    display: none;
  }
}

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

  .order-list-header,
  .order-list-row {
    grid-template-columns: 88px minmax(180px, 1fr) 64px 92px 86px 102px 120px 116px 26px;
  }

  .order-list-header > span:nth-child(6),
  .order-row-requester {
    display: none;
  }

  .order-detail-grid {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }
}

@media (max-width: 760px) {
  .orders-view {
    padding: 16px 12px;
  }

  .orders-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .order-filters,
  .orders-layout,
  .order-detail-grid,
  .order-sla-settings-form {
    grid-template-columns: 1fr;
  }

  .order-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-budget-panel { grid-template-columns: 1fr 1fr; }
  .order-budget-panel > div:not(.order-budget-progress) { min-height: 76px; padding: 12px; }
  .order-budget-panel .order-budget-main { grid-column: 1 / -1; border-left: 0; border-bottom: 1px solid var(--line); }
  .order-budget-panel > div:nth-child(2) { border-left: 0; }
  .order-budget-preview { grid-template-columns: 1fr; }
  .order-budget-preview p { grid-column: 1; }

  .orders-list {
    max-height: none;
  }

  .order-detail-card {
    padding: 14px;
  }

  .order-detail-overlay {
    padding: 0;
  }

  .order-detail-dialog,
  .order-detail-scroll {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .order-list-header {
    display: none;
  }

  .order-list-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "id status"
      "product product"
      "meta meta"
      "priority sla";
    gap: 7px 12px;
    min-height: 132px;
    padding: 13px 14px;
  }

  .order-row-id { grid-area: id; }
  .order-row-product { grid-area: product; }
  .order-status { grid-area: status; justify-self: end; }
  .order-priority { grid-area: priority; }
  .order-list-sla { grid-area: sla; justify-self: end; }
  .order-row-quantity,
  .order-row-price,
  .order-row-site,
  .order-row-requester,
  .order-row-open { display: none; }
  .order-row-mobile-meta {
    display: block;
    grid-area: meta;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .order-row-product b {
    font-size: 14px;
  }

  .order-detail-head,
  .order-sla > div:first-child {
    align-items: flex-start;
    flex-direction: column;
  }

  .order-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .order-actions > * {
    width: 100%;
  }

  .order-reschedule-fields {
    grid-template-columns: 1fr;
  }

  .order-reschedule-fields > * {
    width: 100%;
  }

  .order-sla-settings-form .settings-note,
  .order-sla-settings-form .primary-action {
    grid-column: auto;
  }
}

.theme-toggle[aria-pressed="true"] .theme-toggle-dark {
  display: inline-flex;
}

.agent-profile-button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  padding: 6px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  text-align: left;
}

.agent-profile-button:hover,
.agent-profile-button.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.agent-profile-button > div:last-child {
  display: grid;
  min-width: 0;
}

.agent-profile-button b,
.agent-profile-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  flex: 0 0 auto;
  color: #526279;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 760;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.logout-button:hover {
  color: var(--red);
  border-color: #f3b8bf;
  background: #fff5f6;
}

:root[data-theme="dark"] .logout-button:hover {
  border-color: rgba(255, 107, 122, 0.38);
  background: rgba(255, 107, 122, 0.12);
}

.logout-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 750;
}

.agent-card b,
.agent-card span {
  display: block;
}

.agent-card b {
  font-size: 13px;
}

.agent-card span,
small {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 42px minmax(240px, 1fr) auto 184px 42px;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

:root[data-theme="dark"] .topbar {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.sidebar-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
}

.app-shell.sidebar-collapsed .sidebar-toggle svg {
  transform: scaleX(-1);
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(31, 46, 70, 0.04);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

kbd {
  color: var(--muted);
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 12px;
}

:root[data-theme="dark"] kbd {
  background: var(--surface-soft);
}

.primary-action,
.secondary-action,
.sync-card,
.filter-button,
.ghost-button,
.link-button,
select {
  height: 38px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 720;
  box-shadow: 0 8px 18px rgba(15, 98, 217, 0.2);
  white-space: nowrap;
}

.primary-action:hover {
  background: #0b56c5;
  border-color: #0b56c5;
  box-shadow: 0 10px 22px rgba(15, 98, 217, 0.24);
}

.primary-action:active {
  transform: translateY(1px);
}

.secondary-action {
  padding: 0 16px;
  color: var(--text);
  font-weight: 720;
}

.secondary-action:hover,
.filter-button:hover,
.ghost-button:hover {
  border-color: #bdd2ee;
  background: #f5f8fd;
}

:root[data-theme="dark"] .secondary-action:hover,
:root[data-theme="dark"] .filter-button:hover,
:root[data-theme="dark"] .ghost-button:hover {
  border-color: #46658e;
  background: var(--surface-soft);
}

.sync-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.sync-card span {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.sync-card b {
  font-size: 12px;
}

.sync-card i {
  width: 14px;
  height: 14px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: inset 0 0 0 4px #e4f7eb;
}

.sync-card.syncing i {
  background: var(--amber);
}

.icon-button,
.ghost-button {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  color: var(--muted);
  position: relative;
}

.ghost-button svg,
.icon-button svg,
.primary-action svg,
.secondary-action svg,
.filter-button svg,
.link-button svg,
.mail-eyebrow svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-tab.pinned-tab {
  gap: 8px;
}

.site-tab.pinned-tab svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-tab.pinned-tab.active svg {
  fill: currentColor;
}

.icon-button {
  height: 38px;
  border: 0;
  background: transparent;
}

.icon-button em {
  position: absolute;
  top: 2px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  color: #fff;
  background: #b42342;
  border-radius: 50%;
  font-size: 10px;
  font-style: normal;
  font-weight: 760;
}

.notification-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.notification-panel {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 30;
  width: min(380px, calc(100vw - 28px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.notification-head b,
.notification-head span {
  display: block;
}

.notification-head b {
  font-size: 14px;
}

.notification-head span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.notification-head .link-button {
  height: 30px;
  padding: 0;
}

.notification-head-actions {
  display: flex;
  gap: 8px;
}

.notification-filters {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.notification-filters button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  font-weight: 760;
}

.notification-filters button.active {
  color: var(--blue);
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.notification-filters span {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: rgba(22, 101, 216, 0.12);
  font-size: 11px;
}

.notification-list {
  display: grid;
  max-height: 430px;
  overflow: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.notification-item:first-child {
  border-top: 0;
}

.notification-item:hover {
  background: var(--blue-soft);
}

:root[data-theme="dark"] .notification-item:hover {
  background: var(--surface-soft);
}

.notification-item > span {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--blue);
}

.notification-item.warning > span {
  background: var(--amber);
}

.notification-item.danger > span {
  background: var(--red);
}

.notification-item.mail > span {
  background: var(--teal);
}

.notification-item:not(.unread) > span {
  background: var(--line-strong);
}

.notification-item b {
  display: block;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.notification-item p {
  margin: 4px 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.notification-item small {
  font-size: 11px;
}

.notification-item.unread b {
  color: var(--blue);
}

.attention-panel {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.attention-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attention-head b,
.attention-head small {
  display: block;
}

.attention-head b {
  font-size: 14px;
}

.attention-head small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.attention-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.attention-head-actions span {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  color: var(--blue);
  border-radius: 999px;
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 780;
}

.attention-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.attention-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  gap: 8px;
  min-height: 58px;
  padding: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: left;
}

.attention-item > button:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px 0 10px 10px;
  border: 0;
  background: transparent;
  text-align: left;
}

.attention-item:hover {
  border-color: #aac8f4;
  background: var(--blue-soft);
}

.attention-dismiss {
  display: grid;
  width: 26px;
  height: 26px;
  margin: 8px 8px 0 0;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.attention-dismiss:hover {
  color: var(--red);
  border-color: #ffd0d6;
  background: #fff1f3;
}

.attention-dismiss svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.attention-item.warning {
  border-left-color: var(--amber);
}

.attention-item.danger {
  border-left-color: var(--red);
}

.attention-item b {
  color: var(--text);
  font-size: 13px;
}

.attention-item span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 680;
}

.content-grid {
  display: grid;
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.content-grid.ticket-focus {
  grid-template-columns: minmax(0, 1fr);
}

.content-grid.no-detail {
  grid-template-columns: minmax(0, 1fr);
}

.content-grid.no-detail .detail-panel {
  display: none;
}

.content-grid.ticket-focus .main-column {
  display: block;
}

.content-grid.ticket-focus .detail-panel {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.main-column {
  min-width: 0;
  padding: 22px 24px 32px;
}

.detail-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 92;
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  overflow: hidden;
  border: 1px solid rgba(154, 178, 214, 0.55);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.98)),
    var(--surface);
  box-shadow:
    0 26px 90px rgba(15, 23, 42, 0.26),
    0 0 0 1px rgba(255, 255, 255, 0.72) inset;
  transform: translate(-50%, -46%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 180ms ease, opacity 180ms ease, box-shadow 180ms ease;
}

.ticket-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: block;
  border: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(96, 145, 216, 0.18), transparent 34%),
    rgba(15, 23, 42, 0.36);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 180ms ease;
}

.content-grid.ticket-focus .ticket-detail-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.queue-panel,
.events-panel {
  background: transparent;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.2;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 18px;
  line-height: 1.35;
}

.site-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
}

.site-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 230px;
  height: 42px;
  padding: 0 12px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.site-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-tab.active {
  color: var(--blue);
  border-color: var(--accent-border);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.site-tab b {
  font-size: 12px;
  color: var(--muted);
  background: #edf2f8;
  padding: 2px 7px;
  border-radius: 999px;
}

.source-tabs {
  display: grid;
  position: relative;
  z-index: 2;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.source-tab {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}

.source-tab .icon {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--blue);
  background: var(--blue-soft);
}

.source-tab[data-source-tab="mail"] .icon {
  color: var(--teal);
  background: rgba(20, 184, 166, 0.12);
}

.source-tab[data-source-tab="bot"] .icon {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.12);
}

.source-tab[data-source-tab="manual"] .icon {
  color: var(--amber);
  background: rgba(245, 158, 11, 0.14);
}

.source-tab span {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 780;
}

.source-tab small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-tab b {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  color: var(--blue);
  border-radius: 999px;
  background: var(--blue-soft);
  font-size: 12px;
}

.source-tab.active {
  border-color: var(--accent-border);
  box-shadow: inset 0 -2px 0 var(--blue), 0 10px 22px rgba(22, 101, 216, 0.08);
}

#sourceFilter {
  display: none;
}

.filters {
  display: grid;
  position: relative;
  z-index: 1;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
}

.reply-required-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 760;
  white-space: nowrap;
}

.reply-required-filter.active {
  color: var(--blue);
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.reply-required-filter b {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
}

select {
  min-width: 118px;
  padding: 0 34px 0 12px;
  color: var(--text);
}

.filters select {
  width: 100%;
  min-width: 0;
}

#assigneeFilter {
  width: 100%;
}

#resetFilters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 12px;
  white-space: nowrap;
}

.reply-required-filter {
  grid-column: span 2;
}

#resetFilters {
  grid-column: span 1;
}

.link-button {
  color: var(--blue);
  background: transparent;
  border: 0;
  padding: 0 8px;
  font-weight: 680;
}

.sort-control {
  grid-column: span 3;
  justify-self: stretch;
  margin-left: 0;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.sort-control select {
  width: 100%;
  min-width: 0;
}

.ticket-table,
.events-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.bulk-actions[hidden] {
  display: none;
}

.bulk-actions b {
  display: block;
}

.bulk-actions span {
  color: var(--muted);
  font-size: 12px;
}

.bulk-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bulk-controls select {
  min-height: 38px;
  min-width: 170px;
  padding: 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 760;
}

.bulk-controls textarea {
  width: min(360px, 100%);
  min-height: 38px;
  padding: 9px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-weight: 650;
  resize: vertical;
}

.bulk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 740;
}

.bulk-check input {
  width: 16px;
  height: 16px;
}

.table-row {
  display: grid;
  grid-template-columns: 30px 58px minmax(170px, 1fr) 132px 88px 118px 92px 86px 112px;
  align-items: center;
  min-height: 58px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  text-align: left;
}

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

.table-row > span {
  min-width: 0;
  overflow: hidden;
  padding: 0 8px;
  text-overflow: ellipsis;
}

.table-head {
  min-height: 36px;
  color: #334259;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
}

.ticket-row {
  width: 100%;
  padding: 0;
  border-top: 1px solid var(--line);
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  background: var(--surface);
  cursor: pointer;
}

.ticket-row:hover,
.ticket-row.selected,
.ticket-row.bulk-selected {
  background: var(--blue-soft);
}

:root[data-theme="dark"] .ticket-row:hover,
:root[data-theme="dark"] .ticket-row.selected,
:root[data-theme="dark"] .ticket-row.bulk-selected {
  background: var(--blue-soft);
}

.row-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  cursor: pointer;
}

.row-select input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.row-select.all {
  margin-left: -2px;
}

.ticket-row.sla-risk {
  box-shadow: inset 3px 0 0 var(--amber);
}

.ticket-row.sla-overdue {
  box-shadow: inset 3px 0 0 var(--red);
}

.ticket-row.sla-paused {
  box-shadow: inset 3px 0 0 var(--blue);
}

.ticket-row.has-unread-reply {
  background: var(--surface-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

:root[data-theme="dark"] .ticket-row.has-unread-reply {
  background: var(--blue-soft);
}

.ticket-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ticket-title-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.new-reply-badge {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 11px;
  font-weight: 780;
}

:root[data-theme="dark"] .new-reply-badge {
  background: var(--blue-soft);
}

.sla-badge {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.sla-badge b {
  width: max-content;
  max-width: 100%;
  padding: 2px 7px;
  color: var(--green);
  border-radius: 999px;
  background: #eaf8f0;
  font-size: 11px;
  font-weight: 780;
}

:root[data-theme="dark"] .sla-badge b {
  background: rgba(95, 206, 141, 0.14);
}

.sla-badge small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.sla-badge.risk b {
  color: var(--warning-ink);
  background: #fff4df;
}

:root[data-theme="dark"] .sla-badge.risk b {
  color: var(--amber);
  background: rgba(240, 185, 76, 0.14);
}

.sla-badge.overdue b {
  color: var(--red);
  background: #fff2f4;
}

:root[data-theme="dark"] .sla-badge.overdue b {
  background: rgba(255, 107, 122, 0.14);
}

.sla-badge.paused b {
  color: var(--blue);
  background: var(--blue-soft);
}

.empty-state,
.empty-detail {
  padding: 22px;
  color: var(--muted);
  font-size: 14px;
}

.compact-empty {
  padding: 12px;
  font-size: 12px;
}

.check {
  width: 13px;
  height: 13px;
  margin-left: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}

.ticket-id {
  color: #31435e;
  font-weight: 720;
}

.ticket-title {
  display: flex;
  align-items: center;
  gap: 9px;
  line-height: 1.25;
  text-align: left;
}

.source-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--blue);
  flex: 0 0 18px;
}

.source-icon svg {
  width: 17px;
  height: 17px;
}

.row-pin {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--amber);
  flex: 0 0 18px;
}

.row-pin svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 740;
  white-space: nowrap;
}

.chip.new,
.chip.work {
  color: var(--blue);
  background: var(--blue-soft);
}

.chip.wait {
  color: var(--warning-ink);
  background: var(--orange-soft);
}

.chip.done,
.chip.active {
  color: var(--green);
  background: #e9f7ef;
}

.priority {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
}

.dot.high {
  background: var(--red);
}

.dot.low {
  background: var(--green);
}

.assignee {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.assignee .avatar {
  width: 24px;
  height: 24px;
  flex-basis: 24px;
  font-size: 10px;
}

.events-panel {
  margin-top: 18px;
}

.settings-view {
  padding: 24px;
}

.reports-view {
  padding: 24px;
}

.mail-view {
  padding: 24px;
}

.dashboard-view {
  padding: 24px;
}

.knowledge-view {
  padding: 24px;
}

.events-view {
  padding: 24px;
}

.profile-view {
  padding: 24px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.profile-hero h1 {
  margin: 4px 0 0;
  font-size: 26px;
}

.profile-hero p {
  margin: 4px 0 0;
  color: var(--muted);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: #fff;
  background: var(--text);
  border-radius: 50%;
  font-size: 20px;
  font-weight: 820;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(360px, 620px);
  gap: 16px;
  align-items: start;
}

.profile-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.profile-meta,
.profile-password-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.profile-meta div {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.profile-meta div:last-child {
  border-bottom: 0;
}

.profile-meta b,
.profile-password-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.profile-meta span {
  color: var(--text);
  font-size: 14px;
}

.profile-password-form label {
  display: grid;
  gap: 6px;
}

.profile-password-form input,
.profile-password-form textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

.profile-password-form textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.45;
}

.signature-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 16px 0;
}

.signature-toolbar select,
.signature-toolbar input[type="color"],
.signature-toolbar button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 720;
}

.signature-toolbar select {
  min-width: 112px;
}

.signature-toolbar input[type="color"] {
  width: 42px;
  padding: 4px;
}

.signature-toolbar button {
  padding: 0 12px;
}

.signature-editor {
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  outline: none;
}

.signature-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.signature-editor:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 24%, transparent);
}

.signature-editor img {
  max-width: 220px;
  height: auto;
  vertical-align: middle;
}

.profile-signature-form p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.two-factor-profile {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.two-factor-status {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.two-factor-status.enabled {
  border-color: rgba(54, 161, 96, 0.35);
  background: rgba(54, 161, 96, 0.08);
}

.two-factor-status.required {
  border-color: rgba(224, 158, 47, 0.45);
  background: rgba(224, 158, 47, 0.1);
}

.two-factor-status b {
  color: var(--text);
}

.two-factor-status p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.profile-password-form.compact {
  padding: 0;
}

.profile-password-form .primary-action {
  justify-self: start;
  min-width: 190px;
}

.settings-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-hero h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.settings-hero p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.settings-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.settings-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: nowrap;
  font-weight: 720;
}

.settings-tabs button:hover,
.settings-tabs button.active {
  color: var(--blue);
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.settings-tabs span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.settings-grid-directories {
  grid-template-columns: minmax(320px, 0.8fr) minmax(420px, 1.2fr);
}

.settings-grid-users {
  grid-template-columns: minmax(360px, 0.45fr) minmax(600px, 1fr);
}

.settings-grid-single {
  grid-template-columns: 1fr;
}

.settings-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.settings-card-head h2 {
  margin: 0;
  font-size: 15px;
}

.settings-card-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.card-head-actions,
.reports-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.pilot-readiness-card .settings-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pilot-readiness-score {
  white-space: nowrap;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 800;
}

.pilot-readiness-score.ok {
  background: rgba(78, 163, 106, 0.12);
  color: var(--green);
}

.pilot-readiness-score.warn {
  background: rgba(225, 159, 54, 0.14);
  color: var(--orange);
}

.pilot-readiness-score.error {
  background: rgba(220, 59, 72, 0.12);
  color: var(--red);
}

.pilot-readiness-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  padding: 14px;
}

.pilot-readiness-item {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.pilot-readiness-item.ok {
  border-left-color: var(--green);
}

.pilot-readiness-item.warn {
  border-left-color: var(--orange);
}

.pilot-readiness-item.error {
  border-left-color: var(--red);
}

.pilot-readiness-item span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 8px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.pilot-readiness-item.ok span {
  color: var(--green);
}

.pilot-readiness-item.warn span {
  color: var(--orange);
}

.pilot-readiness-item.error span {
  color: var(--red);
}

.pilot-readiness-item b {
  display: block;
  color: var(--text);
}

.pilot-readiness-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.pilot-readiness-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.backup-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
  padding: 14px 18px 0;
}

.work-cleanup-card .settings-card-head p {
  max-width: 980px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.work-cleanup-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.work-cleanup-summary div {
  display: grid;
  gap: 5px;
  min-height: 84px;
  padding: 13px;
  border: 1px solid rgba(220, 59, 72, 0.22);
  border-radius: var(--radius);
  background: rgba(220, 59, 72, 0.035);
}

.work-cleanup-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
}

.work-cleanup-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.work-cleanup-form input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 760;
}

.system-status-grid div {
  display: grid;
  gap: 5px;
  min-height: 84px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.backup-status-grid div {
  display: grid;
  gap: 5px;
  min-height: 84px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.system-status-grid span,
.backup-status-grid span,
.work-cleanup-summary span,
.system-error-list b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.system-status-grid b,
.backup-status-grid b,
.work-cleanup-summary b {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.system-status-grid small,
.backup-status-grid small,
.work-cleanup-summary small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.system-error-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.system-error-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.system-error-row span,
.system-error-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-error-row span {
  font-weight: 760;
}

.system-error-row small {
  color: var(--red);
}

.backup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 14px;
  padding: 18px;
}

.maintenance-panel {
  display: grid;
  align-content: space-between;
  gap: 18px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.maintenance-panel b {
  display: block;
  margin-bottom: 5px;
}

.maintenance-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.restore-controls {
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.file-picker {
  display: block;
  min-width: 0;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-picker span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  color: var(--blue);
  border: 1px solid #bdd2ee;
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-weight: 760;
  white-space: nowrap;
}

.restore-controls > small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retention-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  padding: 18px;
}

.retention-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.retention-form input {
  min-height: 44px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-weight: 760;
}

.retention-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.retention-note {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 13px;
}

.system-errors-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
}

.system-error-toolbar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.system-error-toolbar label {
  display: grid;
  gap: 6px;
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.system-error-log-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) minmax(170px, auto);
  gap: 14px;
  align-items: start;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.system-error-log-row:first-child {
  border-top: 0;
}

.system-error-log-row b {
  justify-self: start;
  padding: 4px 9px;
  color: var(--red);
  border-radius: 999px;
  background: #fff1f3;
  font-size: 12px;
}

.system-error-log-row div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.system-error-log-row strong,
.system-error-log-row span,
.system-error-log-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-error-log-row span,
.system-error-log-row small {
  color: var(--muted);
}

.settings-list {
  display: grid;
  align-content: start;
  min-height: 0;
  max-height: 340px;
  overflow: auto;
}

.settings-row {
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.settings-row span:not(.avatar) {
  color: var(--muted);
}

.directory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.agent-edit-row {
  grid-template-columns: 32px minmax(120px, 1fr) 62px auto;
}

.category-edit-row {
  grid-template-columns: minmax(135px, 1fr) 76px auto;
}

.directory-row input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-weight: 680;
}

.directory-row input:focus {
  outline: 0;
  border-color: var(--blue);
  background: var(--surface);
}

.directory-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.mini-action {
  height: 34px;
  min-width: 54px;
  padding: 0 8px;
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 11px;
  font-weight: 760;
}

.mini-action:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

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

.mini-action.danger:hover {
  border-color: rgba(220, 53, 69, 0.32);
  background: #fff2f4;
}

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

.settings-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-soft), var(--surface));
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: #526279;
  font-size: 12px;
  font-weight: 730;
}

.settings-form input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.settings-form select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 720;
}

.settings-note,
.form-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.settings-note {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.assignment-site-rules {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.assignment-site-rules[hidden] {
  display: none;
}

.assignment-site-rules > b {
  color: var(--text);
  font-size: 13px;
}

.assignment-site-rules label {
  grid-template-columns: minmax(130px, 0.55fr) minmax(180px, 1fr);
  align-items: center;
}

.form-hint {
  align-self: end;
  padding: 10px 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.users-card {
  grid-column: 1 / -1;
}

.audit-card {
  grid-column: 1 / -1;
}

.mail-integration-card {
  grid-column: 1 / -1;
}

.mail-check-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mail-check-panel b,
.mail-check-panel span {
  display: block;
}

.mail-check-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.mail-check-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mail-check-result {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.mail-check-result.success {
  border-color: #bfe9cd;
  background: #f2fbf5;
}

.mail-check-result.error {
  border-color: #ffd1d8;
  background: #fff5f6;
}

.mail-check-result.success b {
  color: var(--green);
}

.mail-check-result.error b {
  color: var(--red);
}

.mail-check-result small {
  color: var(--muted);
}

.knowledge-admin-card {
  grid-column: 1 / -1;
}

.users-list {
  max-height: 520px;
}

.audit-list {
  max-height: 430px;
}

.user-row {
  display: grid;
  grid-template-columns: 36px minmax(160px, 1.15fr) minmax(130px, 0.78fr) minmax(120px, 0.75fr) minmax(110px, 0.65fr) minmax(300px, 1.8fr) minmax(112px, 0.7fr) minmax(190px, 1.15fr);
  gap: 12px;
}

.user-row-head {
  min-height: 38px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
}

.user-row-head span {
  color: var(--muted);
}

.user-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-meta span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-role-legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.order-role-legend span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.order-role-legend b {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
}

.order-role-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  gap: 6px;
  min-width: 0;
}

.order-role-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
}

.order-role-picker label:has(input:checked) {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.order-role-picker input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.order-role-picker label:has(input:disabled) {
  cursor: default;
  opacity: 0.68;
}

.admin-order-role {
  grid-column: 1 / -1;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
}

.order-role-hint {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
}

.user-row select,
.password-reset-form input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.user-2fa-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.two-factor-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.two-factor-pill.enabled {
  color: #197242;
  background: #e8f7ee;
}

.two-factor-pill.required {
  color: #a26412;
  background: #fff4df;
}

.password-reset-form {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 86px;
  gap: 6px;
}

.password-reset-form button {
  height: 36px;
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  font-weight: 760;
}

.audit-row {
  display: grid;
  gap: 5px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.audit-row div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.audit-row span,
.audit-row small {
  color: var(--muted);
}

.audit-row p {
  margin: 0;
  color: var(--text);
  font-weight: 680;
}

.audit-row small:empty {
  display: none;
}

.mail-admin-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.mail-admin-summary div {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mail-admin-summary b {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 20px;
}

.mail-admin-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.mail-diagnostics {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-soft) 0%, #fff 100%);
}

.mail-diagnostics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.mail-diagnostics-head b,
.mail-diagnostics-head span {
  display: block;
}

.mail-diagnostics-head b {
  font-size: 15px;
}

.mail-diagnostics-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.mail-diagnostics-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.mail-diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 10px;
}

.mail-diagnostic-tile {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.mail-diagnostic-tile.success {
  border-left-color: var(--green);
}

.mail-diagnostic-tile.error {
  border-left-color: var(--red);
}

.mail-diagnostic-tile span,
.mail-diagnostic-tile small,
.mail-diagnostic-tile em {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-style: normal;
}

.mail-diagnostic-tile b {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.mail-diagnostic-tile em {
  color: #526279;
}

.mail-admin-form {
  display: grid;
  grid-template-columns: 160px minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.mail-admin-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.mail-admin-form input,
.mail-admin-form select {
  width: 100%;
  height: 38px;
  min-width: 0;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.mail-password-note {
  grid-column: 1 / -1;
}

.mail-admin-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.mail-admin-actions .primary-action {
  min-width: 136px;
}

.mail-admin-curl {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.mail-admin-curl b {
  color: var(--muted);
  font-size: 12px;
}

.mail-admin-curl code {
  display: block;
  overflow: auto;
  padding: 12px;
  color: #263752;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f5f7fb;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.knowledge-admin-list {
  max-height: 560px;
}

.knowledge-admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 0.55fr) minmax(160px, 0.65fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
}

.knowledge-admin-row input,
.knowledge-admin-row textarea {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
}

.knowledge-admin-row input {
  height: 36px;
}

.knowledge-admin-row textarea {
  resize: vertical;
  line-height: 1.35;
}

.knowledge-admin-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.knowledge-admin-field.wide {
  grid-column: span 2;
}

.knowledge-admin-field.full {
  grid-column: 1 / -2;
}

.knowledge-admin-row .directory-actions {
  align-self: stretch;
}

.knowledge-admin-form textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.reports-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.reports-hero h1 {
  margin: 0;
  font-size: 24px;
}

.reports-hero p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.report-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto minmax(160px, auto);
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.04);
}

.report-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.report-filters select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.report-filters > span {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.report-kpi {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.report-kpi span,
.report-kpi small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-kpi b {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.report-kpi.blue {
  border-color: var(--accent-border);
}

.report-kpi.red {
  border-color: rgba(220, 53, 69, 0.24);
}

.report-kpi.amber {
  border-color: rgba(224, 161, 54, 0.34);
}

.reports-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.report-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.report-wide {
  grid-column: 1 / -1;
}

.report-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.report-card-head h2 {
  font-size: 15px;
}

.report-card-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.report-table {
  display: grid;
}

.report-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 90px 90px 110px minmax(120px, 0.8fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

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

.report-row > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-row-head {
  min-height: 36px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
}

.report-row-button {
  appearance: none;
  width: 100%;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.report-row-button:hover {
  background: #f4f7ff;
}

:root[data-theme="dark"] .report-row-button:hover {
  background: var(--surface-soft);
}

.return-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-soft) 100%);
}

:root[data-theme="dark"] .return-summary-grid {
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface) 100%);
}

.return-summary-card {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.return-summary-card span,
.return-summary-card small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.return-summary-card b {
  color: var(--text);
  font-size: 26px;
  line-height: 1;
}

.report-bar {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.report-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.report-bar.blue i {
  background: var(--blue);
}

.report-bar.amber i {
  background: var(--amber);
}

.return-report .report-row > span:first-child {
  display: grid;
  gap: 2px;
}

.return-report .report-row > span:first-child small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-report {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.source-metric {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  font-size: 13px;
}

.source-metric > span {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 720;
}

.source-metric small {
  color: var(--muted);
  text-align: right;
}

.source-metric .report-bar {
  grid-column: 1 / -1;
}

.sla-report-list {
  display: grid;
  max-height: 308px;
  overflow: auto;
}

.sla-report-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 10px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 0;
  background: var(--surface);
  text-align: left;
}

.sla-report-item:first-child {
  border-top: 0;
}

.sla-report-item:hover {
  background: #fff8f9;
}

.sla-report-item b {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sla-report-item span {
  color: var(--muted);
  font-size: 12px;
}

.report-danger {
  color: var(--red);
}

.report-warn {
  color: var(--warning-ink);
}

.mail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.mail-hero h1 {
  margin: 6px 0 0;
  font-size: 24px;
}

.mail-hero p {
  max-width: 740px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mail-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.mail-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 780;
}

.mail-eyebrow svg {
  width: 18px;
  height: 18px;
}

.mail-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.mail-kpi {
  display: grid;
  gap: 7px;
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.mail-kpi span,
.mail-kpi small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.mail-kpi b {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.mail-kpi.blue {
  border-color: var(--accent-border);
}

.mail-kpi.green {
  border-color: rgba(31, 164, 99, 0.28);
}

.mail-kpi.amber {
  border-color: rgba(224, 161, 54, 0.34);
}

.mail-kpi.red {
  border-color: rgba(220, 53, 69, 0.24);
}

.dashboard-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-hero h1 {
  margin-top: 6px;
  font-size: 24px;
}

.dashboard-hero p {
  max-width: 720px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dashboard-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.dashboard-actions button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dashboard-actions svg {
  width: 18px;
  height: 18px;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-kpi {
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
  text-align: left;
}

.dashboard-kpi:hover {
  border-color: var(--blue-soft);
  background: var(--surface-soft);
}

.dashboard-kpi span,
.dashboard-kpi small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.dashboard-kpi b {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
}

.dashboard-kpi.blue {
  border-color: var(--accent-border);
}

.dashboard-kpi.green {
  border-color: rgba(31, 164, 99, 0.28);
}

.dashboard-kpi.mail {
  border-color: color-mix(in srgb, var(--blue) 25%, transparent);
}

.dashboard-kpi.danger {
  border-color: rgba(220, 53, 69, 0.24);
}

.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.dashboard-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.dashboard-primary-card {
  grid-column: 1 / -1;
}

.dashboard-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.dashboard-card-head h2 {
  font-size: 16px;
}

.dashboard-card-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 680;
}

.dashboard-card-head b {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
}

.dashboard-list {
  display: grid;
  max-height: 640px;
  overflow: auto;
}

.dashboard-list.compact {
  max-height: 310px;
}

.dashboard-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 68px;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 0;
  background: var(--surface);
  text-align: left;
}

.dashboard-item:first-child {
  border-top: 0;
}

.dashboard-item:hover {
  background: var(--surface-soft);
}

.dashboard-item span {
  width: fit-content;
  max-width: 100%;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-item b {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-item small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-item.danger {
  border-left-color: var(--red);
}

.dashboard-item.warning {
  border-left-color: #e0a136;
}

.dashboard-item.mail {
  border-left-color: var(--blue);
}

.dashboard-item.info {
  border-left-color: #8ea0ba;
}

.dashboard-item.danger span {
  background: #fff0f2;
  color: var(--red);
}

.dashboard-item.warning span {
  background: #fff7e8;
  color: #a66200;
}

.dashboard-item.mail span {
  background: var(--blue-soft);
  color: var(--blue);
}

.dashboard-card > .wide-action {
  width: calc(100% - 32px);
  margin: 14px 16px 16px;
}

.dashboard-ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.dashboard-online-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.dashboard-online-summary span {
  display: grid;
  gap: 3px;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.dashboard-online-summary b {
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.dashboard-online-list {
  max-height: 390px;
}

.dashboard-online-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  border-left: 3px solid #8ea0ba;
  background: var(--surface);
}

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

.dashboard-online-row.active {
  border-left-color: var(--green);
}

.dashboard-online-row.soon {
  border-left-color: #e0a136;
}

.dashboard-online-row > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.dashboard-online-row b,
.dashboard-online-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-online-row b {
  color: var(--text);
  font-size: 13px;
}

.dashboard-online-row small {
  color: var(--muted);
  font-size: 11px;
}

.dashboard-online-time {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-online-row em {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-online-row.active em {
  background: #ebf8f1;
  color: var(--green);
}

.dashboard-online-row.soon em {
  background: #fff7e8;
  color: var(--warning-ink);
}

.mail-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.mail-layout {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(320px, 0.46fr);
  gap: 16px;
  align-items: start;
}

.mail-stack {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.mail-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.mail-card-head h2 {
  margin: 0;
  font-size: 15px;
}

.mail-card-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.mail-card-head span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.mail-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.mail-table {
  display: grid;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-color: #b9c8dc transparent;
  scrollbar-width: thin;
}

.mail-table::-webkit-scrollbar {
  height: 8px;
}

.mail-table::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #b9c8dc;
}

.mail-table::-webkit-scrollbar-track {
  background: transparent;
}

.mail-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(260px, 1.25fr) minmax(260px, 1fr) minmax(118px, 0.45fr);
  align-items: center;
  gap: 14px;
  min-width: 900px;
  min-height: 66px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  cursor: pointer;
}

.mail-row:not(.mail-row-head):hover,
.mail-row.selected {
  background: var(--blue-soft);
}

:root[data-theme="dark"] .mail-row:not(.mail-row-head):hover,
:root[data-theme="dark"] .mail-row.selected {
  background: var(--blue-soft);
}

.mail-row.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}

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

.mail-row > span {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.mail-row > span:last-child,
.mail-date-cell {
  justify-self: end;
  text-align: right;
  white-space: nowrap;
}

.mail-row small,
.muted-text {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.mail-row-head {
  min-height: 38px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
}

.mail-message-cell b {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 780;
}

.mail-status.created {
  color: var(--blue);
  background: var(--blue-soft);
}

.mail-status.comment {
  color: #16854f;
  background: #e9f7ef;
}

.mail-status.duplicate {
  color: var(--red);
  background: #fff2f4;
}

.mail-status.neutral {
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.mail-ticket-link {
  display: block;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  color: var(--blue);
  border: 0;
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.mail-ticket-link:hover {
  text-decoration: underline;
}

.mail-detail {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.mail-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mail-detail-top span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.mail-detail h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.mail-detail-meta {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.mail-detail-meta div {
  display: grid;
  gap: 3px;
}

.mail-detail-meta b,
.mail-body b {
  color: var(--muted);
  font-size: 12px;
}

.mail-detail-meta span {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.mail-network-alert {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fff1f2;
  color: #9f1239;
  font-size: 13px;
}

.mail-network-alert b {
  color: #9f1239;
}

.mail-network-alert span {
  color: #be123c;
  line-height: 1.35;
}

.mail-body {
  display: grid;
  gap: 8px;
}

.mail-body p {
  min-height: 110px;
  max-height: 240px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.mail-detail-action {
  width: 100%;
  min-height: 42px;
}

.knowledge-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.knowledge-hero h1 {
  margin: 6px 0 0;
  font-size: 24px;
}

.knowledge-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.knowledge-hero > span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.knowledge-tools {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(420px, 1.4fr);
  gap: 12px;
  margin-bottom: 16px;
}

.knowledge-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(31, 46, 70, 0.04);
}

.knowledge-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.knowledge-search:focus-within,
:root[data-theme="dark"] .knowledge-search:focus-within {
  border-color: var(--blue);
  box-shadow: var(--focus-ring);
}

:root .knowledge-search input:focus { box-shadow: none; }

.knowledge-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.knowledge-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  white-space: nowrap;
  font-weight: 700;
}

.knowledge-tabs button.active {
  color: var(--blue);
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.knowledge-tabs button:hover:not(.active) {
  background: var(--surface-soft);
}

.knowledge-tabs span {
  padding: 2px 6px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 11px;
}

.knowledge-tabs button.active span {
  background: color-mix(in srgb, var(--blue) 16%, var(--blue-soft));
}

.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.42fr) minmax(520px, 1fr);
  gap: 16px;
  align-items: start;
}

.knowledge-list,
.knowledge-article {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.knowledge-list {
  display: grid;
}

.knowledge-item {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 96px;
  padding: 14px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.knowledge-item:first-child {
  border-top: 0;
}

.knowledge-item:hover:not(.selected) {
  background: var(--surface-soft);
}

.knowledge-item.selected {
  background: var(--blue-soft);
  box-shadow: inset 3px 0 0 var(--blue);
}

.knowledge-item b,
.knowledge-item span,
.knowledge-item small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.knowledge-item b {
  color: var(--text);
  font-size: 14px;
}

.knowledge-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.knowledge-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.knowledge-article {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.knowledge-article-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.knowledge-article-head > span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 760;
}

.knowledge-article h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.knowledge-article > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.knowledge-tags span {
  padding: 4px 8px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.knowledge-article section {
  display: grid;
  gap: 8px;
}

.knowledge-article h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.knowledge-article blockquote,
.knowledge-article pre {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
}

.events-hero-view {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.events-hero-view h1 {
  margin: 6px 0 0;
  font-size: 24px;
}

.events-hero-view p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.events-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.events-hero-actions .primary-action {
  min-height: 42px;
  min-width: 220px;
  padding: 0 16px;
  white-space: nowrap;
}

.event-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.events-view-filters {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(180px, 0.7fr) auto 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.04);
}

.events-view-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.events-view-filters select {
  width: 100%;
  min-width: 0;
}

.events-view-filters > span {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.events-view-layout {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.42fr);
  gap: 16px;
  align-items: start;
}

.events-view-list,
.event-detail,
.event-editor {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 46, 70, 0.05);
}

.events-view-list {
  display: grid;
}

.event-side-stack {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
}

.event-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) 110px 140px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 12px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.event-card:first-child {
  border-top: 0;
}

.event-card:hover,
.event-card.selected {
  background: var(--blue-soft);
}

:root[data-theme="dark"] .event-card:hover,
:root[data-theme="dark"] .event-card.selected {
  background: var(--blue-soft);
}

.event-card.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}

.event-card b,
.event-card span,
.event-card small,
.event-card em {
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card b {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
}

.event-card small {
  white-space: nowrap;
}

.event-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.event-detail {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.event-detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.event-detail h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.event-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.event-detail-meta {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.event-detail-meta div {
  display: grid;
  gap: 3px;
}

.event-detail-meta b,
.event-related h3 {
  color: var(--muted);
  font-size: 12px;
}

.event-detail-meta span {
  color: var(--text);
  font-size: 13px;
}

.event-ticket-action {
  min-height: 42px;
}

.event-detail-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.event-detail-actions .primary-action,
.event-detail-actions .secondary-action {
  width: 100%;
  padding: 0 10px;
  font-size: 13px;
}

.event-related {
  display: grid;
  gap: 8px;
}

.event-related h3 {
  margin: 0;
}

.event-related button {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: left;
}

.event-related button:hover {
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.event-related b,
.event-related span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.event-editor label,
.event-site-field,
.ticket-site-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.event-site-field > span,
.ticket-site-field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.event-editor input,
.event-editor select,
.event-editor textarea {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 680;
}

.event-editor input,
.event-editor select {
  height: 42px;
  padding: 0 12px;
}

.event-site-checks,
.ticket-site-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.event-site-checks label,
.ticket-site-checks label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  flex: 0 1 auto;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
}

.event-site-checks label:has(input:checked),
.ticket-site-checks label:has(input:checked) {
  border-color: var(--accent-border);
  background: var(--blue-soft);
  color: var(--blue);
}

.event-site-checks input,
.ticket-site-checks input {
  position: relative;
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: 0;
  appearance: none;
  border: 1.5px solid #8b98aa;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: none;
}

.event-site-checks input:checked,
.ticket-site-checks input:checked {
  border-color: var(--blue);
  background: var(--blue);
}

.event-site-checks input:checked::after,
.ticket-site-checks input:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg) translate(1px, -1px);
}

.event-editor textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

.event-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) 150px 130px 104px 70px 78px;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

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

.event-head {
  min-height: 34px;
  color: #334259;
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 760;
}

.event-name {
  display: flex;
  align-items: center;
  gap: 9px;
}

.detail-panel {
  padding: 0;
}

.detail-layout {
  display: contents;
}

.content-grid.ticket-focus .detail-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.42fr) minmax(420px, 0.58fr);
  gap: 0;
  align-items: stretch;
  max-height: calc(100dvh - 48px);
  min-height: min(720px, calc(100dvh - 48px));
}

.detail-summary,
.detail-stream {
  min-width: 0;
}

.content-grid.ticket-focus .detail-summary,
.content-grid.ticket-focus .detail-stream {
  min-height: 0;
  background: transparent;
}

.content-grid.ticket-focus .detail-stream {
  position: static;
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: rgba(248, 251, 255, 0.74);
}

.content-grid.ticket-focus .detail-summary {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 24px;
}

.content-grid.ticket-focus #activityPanel {
  min-height: 0;
  overflow: auto;
  padding: 0 22px 22px;
}

.content-grid.ticket-focus .detail-summary::-webkit-scrollbar,
.content-grid.ticket-focus #activityPanel::-webkit-scrollbar {
  width: 8px;
}

.content-grid.ticket-focus .detail-summary::-webkit-scrollbar-thumb,
.content-grid.ticket-focus #activityPanel::-webkit-scrollbar-thumb {
  background: #c9d5e6;
  border-radius: 999px;
}

.content-grid.ticket-focus .detail-summary::-webkit-scrollbar-track,
.content-grid.ticket-focus #activityPanel::-webkit-scrollbar-track {
  background: transparent;
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px -4px 18px 0;
}

.detail-top strong {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 14px;
  line-height: 1;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-actions .ghost-button {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.72) inset;
}

.detail-actions .ghost-button.favorite-ticket.active {
  color: var(--amber);
  background: #fff7e8;
  border-color: #f5c16c;
}

.detail-actions .ghost-button.favorite-ticket.active svg {
  fill: currentColor;
}

.detail-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin: 14px 0 18px;
  padding: 6px 10px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  font-weight: 760;
}

.sla-box {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.sla-line {
  height: 7px;
  margin-top: 10px;
  overflow: hidden;
  background: #e8edf4;
  border-radius: 999px;
}

.sla-line div {
  width: 74%;
  height: 100%;
  background: var(--green);
}

.sla-box.risk .sla-line div {
  background: var(--amber);
}

.sla-box.overdue .sla-line div {
  background: var(--red);
}

.sla-box.paused .sla-line div {
  background: var(--blue);
}

.sla-box.risk span {
  color: #9b5b00;
}

.sla-box.overdue span {
  color: var(--red);
}

.sla-box.paused span {
  color: var(--blue);
}

.sla-box small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.lxp-panel {
  display: grid;
  gap: 10px;
  margin: 10px 0 16px;
  padding: 13px;
  border: 1px solid var(--accent-border);
  border-radius: 11px;
  background: var(--blue-soft);
}

.lxp-panel > div:first-child { display: grid; gap: 3px; }
.lxp-panel b { color: var(--blue); font-size: 12px; }
.lxp-panel span { font-size: 13px; font-weight: 760; }
.lxp-panel p,
.lxp-panel small { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.lxp-panel.forwarded { border-color: rgba(38, 161, 104, .35); background: rgba(38, 161, 104, .09); }
.lxp-panel.forwarded b { color: var(--green); }
.lxp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lxp-actions button { min-height: 36px; padding-inline: 11px; font-size: 11px; }

.meta-list {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.meta-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  font-size: 13px;
}

.meta-item b,
.sla-box b {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #526279;
}

.meta-item span,
.sla-box span {
  color: var(--text);
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: auto 0 0;
  padding-top: 18px;
}

.panel-actions.admin-actions.has-assign {
  grid-template-columns: 1fr 1fr;
}

.panel-actions .primary-action,
.panel-actions .secondary-action {
  width: 100%;
  min-height: 42px;
}

.panel-actions.support-actions .primary-action,
.panel-actions.support-actions .secondary-action,
.panel-actions:not(.has-assign) .primary-action,
.panel-actions:not(.has-assign) .secondary-action,
.panel-actions .wide-action {
  grid-column: 1 / -1;
}

.danger-outline {
  color: var(--red);
  border-color: rgba(220, 53, 69, 0.28);
  background: #fff8f9;
}

.danger-outline:hover {
  background: #fff2f4;
}

.danger-action {
  background: var(--red);
}

.ticket-edit-form {
  display: grid;
  gap: 13px;
}

.ticket-edit-modal,
.ticket-close-modal {
  width: min(760px, calc(100vw - 32px));
}

.ticket-edit-form .section-heading {
  margin-bottom: 2px;
}

.ticket-edit-form .section-heading > div {
  display: grid;
  gap: 4px;
}

.edit-ticket-id {
  color: var(--muted);
  font-size: 13px;
}

.ticket-edit-form label {
  display: grid;
  gap: 6px;
  color: #526279;
  font-size: 13px;
  font-weight: 700;
}

.ticket-status-edit-form {
  max-width: 460px;
}

.form-note {
  margin: 0;
  padding: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: 13px;
  line-height: 1.45;
}

.ticket-edit-form input,
.ticket-edit-form textarea,
.ticket-edit-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  font-size: 14px;
  font-weight: 660;
}

:root[data-theme="dark"] .ticket-edit-form input,
:root[data-theme="dark"] .ticket-edit-form textarea,
:root[data-theme="dark"] .ticket-edit-form select {
  background: var(--surface);
}

.ticket-edit-form input,
.ticket-edit-form select {
  height: 42px;
  padding: 0 12px;
}

.ticket-edit-form textarea {
  min-height: 110px;
  resize: vertical;
  padding: 10px 12px;
}

.timeline-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.timeline-tabs button {
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
}

.timeline-tabs button.active {
  color: var(--blue);
  border-color: var(--blue);
  font-weight: 740;
}

.timeline {
  display: grid;
  gap: 12px;
  padding-top: 16px;
}

.timeline-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
}

.timeline-filters button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.timeline-filters button.active {
  border-color: var(--blue-soft);
  background: var(--blue-soft);
  color: var(--blue);
}

.timeline-filters span {
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: inherit;
  font-size: 11px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 42px 28px minmax(0, 1fr);
  gap: 10px;
  font-size: 13px;
}

.timeline-time {
  color: var(--muted);
  font-size: 12px;
  padding-top: 6px;
}

.timeline-marker {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
}

.timeline-marker svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.timeline-item.mail .timeline-marker {
  background: var(--blue-soft);
  color: var(--blue);
}

.timeline-item.change .timeline-marker {
  background: #fff7e8;
  color: #b56d12;
}

.timeline-item.comment .timeline-marker {
  background: #edf8f1;
  color: #3f8f5d;
}

.timeline-item.system .timeline-marker {
  background: #f4f6fb;
  color: var(--muted);
}

.timeline-body {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  line-height: 1.45;
}

.timeline-body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.timeline-body-head b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-body p {
  margin-top: 4px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.timeline-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.timeline-badge.mail {
  background: var(--blue-soft);
  color: var(--blue);
}

.timeline-badge.change {
  background: #fff7e8;
  color: var(--warning-ink);
}

.timeline-badge.comment {
  background: #edf8f1;
  color: var(--green);
}

.timeline-badge.system {
  background: #f4f6fb;
  color: var(--muted);
}

.comment-list {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  min-width: 0;
}

.comment-item {
  min-width: 0;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: 13px;
}

.comment-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto);
  align-items: start;
  gap: 10px;
  margin-bottom: 8px;
  min-width: 0;
}

.comment-head b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-head span {
  min-width: 0;
  max-width: 210px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-mail-state {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0 0 8px;
  padding: 6px 9px;
  border-radius: 6px;
  overflow: hidden;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-mail-state.created {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #bfdbff;
}

.comment-mail-state.comment {
  color: #16854f;
  background: #e9f7ef;
  border-color: #c7ecd7;
}

.comment-mail-state.duplicate {
  color: var(--red);
  background: #fff2f4;
  border-color: #ffd1d8;
}

.comment-item p {
  line-height: 1.45;
  white-space: pre-wrap;
}

.attachment-section {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.attachment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.attachment-head span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  place-items: center;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 800;
}

.attachment-list {
  display: grid;
  gap: 8px;
}

.attachment-list.compact {
  margin-top: 10px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.attachment-item:hover {
  border-color: var(--accent-border);
  background: var(--blue-soft);
}

.attachment-type-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 34px;
  border: 1px solid #dbe8ff;
  border-radius: 10px;
  color: var(--blue);
  background: #f7fbff;
}

.attachment-type-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attachment-info {
  display: grid;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.attachment-info b,
.attachment-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-info small {
  color: var(--muted);
  font-size: 12px;
}

.attachment-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.attachment-actions a {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  text-decoration: none;
  transition: 0.15s ease;
}

.attachment-actions a:hover {
  color: var(--blue);
  border-color: var(--accent-border);
  background: #fff;
}

:root[data-theme="dark"] .attachment-actions a:hover {
  border-color: #46658e;
  background: var(--surface-soft);
}

.attachment-actions svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reply-form {
  display: grid;
  gap: 10px;
  padding-top: 14px;
}

.reply-form button:disabled,
.comment-mail-retry:disabled {
  opacity: .62;
  cursor: wait;
}

.reply-file-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.reply-pending-delivery {
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
  border-radius: 8px;
  color: var(--warning-ink, #89530e);
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  font-size: 12px;
  line-height: 1.45;
}

.reply-pending-delivery[hidden],
.reply-actions button[hidden] {
  display: none;
}

.comment-mail-state b,
.comment-mail-state > span {
  display: block;
}

.comment-mail-state > span {
  margin-top: 2px;
  font-weight: 560;
  white-space: normal;
  overflow-wrap: anywhere;
}

.comment-mail-retry {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  margin-top: 6px;
  padding: 4px 9px;
  border: 1px solid var(--accent-border);
  border-radius: 7px;
  color: var(--blue);
  background: var(--surface);
  font: inherit;
  font-weight: 740;
  cursor: pointer;
}

.comment-mail-retry:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.comment-mail-state.uncertain {
  color: var(--warning-ink, #89530e);
  border-color: color-mix(in srgb, var(--amber) 46%, var(--line));
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
}

.reply-delivery-note {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  background: var(--blue-soft);
}

.reply-delivery-note b { color: var(--blue); font-size: 12px; }
.reply-delivery-note span { color: var(--muted); font-size: 11px; line-height: 1.4; }

.reply-template-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.reply-template-panel b,
.reply-template-panel span,
.reply-template-panel small {
  display: block;
}

.reply-template-panel > div:first-child span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.reply-template-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.reply-template-picker select {
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 760;
}

.reply-form textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.45;
}

.file-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.reply-actions label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.comment-mail-state {
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.comment-mail-state > b {
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}

.comment-mail-state > span {
  line-height: 1.4;
}

.reply-form,
.reply-form > *,
.reply-form textarea,
.reply-template-picker,
.reply-actions {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 400px) {
  .reply-template-picker {
    grid-template-columns: minmax(0, 1fr);
  }

  .reply-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
  }

  .reply-actions > button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .reply-form input[type="file"] {
    width: 100%;
    min-width: 0;
  }
}

.check-option {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 740;
  line-height: 1.35;
}

.check-option input {
  appearance: auto;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--blue);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(19, 35, 58, 0.34);
}

.modal {
  width: min(680px, 100%);
  max-height: min(860px, calc(100vh - 36px));
  overflow: auto;
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal label:not(.check-option) {
  display: grid;
  gap: 7px;
  color: #526279;
  font-size: 13px;
  font-weight: 700;
}

.modal input:not([type="checkbox"]):not([type="radio"]),
.modal textarea,
.modal select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #fff;
  font-size: 14px;
  font-weight: 660;
}

.modal input:not([type="checkbox"]):not([type="radio"]),
.modal select {
  height: 42px;
  padding: 0 12px;
}

.modal textarea {
  min-height: 108px;
  resize: vertical;
  padding: 10px 12px;
}

.ticket-sla-preview {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  background: var(--blue-soft);
}

.ticket-sla-preview span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 8px;
  color: var(--blue);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 780;
}

.ticket-sla-preview b {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.ticket-sla-preview small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1480px) {
  .mail-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .mail-detail {
    position: static;
  }

  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .mail-hero,
  .events-hero-view,
  .settings-hero,
  .profile-hero,
  .reports-hero {
    flex-wrap: wrap;
  }

  .mail-hero-actions,
  .events-hero-actions,
  .dashboard-actions {
    flex-wrap: wrap;
  }
}

@media (min-width: 761px) and (max-width: 1480px) {
  .user-row-head {
    display: none;
  }

  .user-row:not(.user-row-head) {
    grid-template-columns: 36px minmax(180px, 1.4fr) repeat(3, minmax(120px, 1fr));
    align-items: center;
  }

  .user-row:not(.user-row-head) .order-role-picker {
    grid-column: 2 / -1;
  }

  .user-row:not(.user-row-head) .user-2fa-cell {
    grid-column: 2 / 3;
  }

  .user-row:not(.user-row-head) .password-reset-form {
    grid-column: 3 / -1;
  }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .sidebar {
    width: 76px;
  }

  .brand span,
  .nav-item span:not(.icon),
  .nav-item strong,
  .agent-card div,
  .logout-label {
    display: none;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .nav-item {
    grid-template-columns: 1fr;
    place-items: center;
    padding: 0;
  }

  .agent-card {
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding-inline: 10px;
  }

  .logout-button {
    width: 38px;
    padding: 0;
  }

  .topbar {
    grid-template-columns: 42px minmax(220px, 1fr) auto 42px;
  }

  .sync-card {
    display: none;
  }

  .notification-panel {
    right: -6px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .content-grid.ticket-focus .detail-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .content-grid.ticket-focus .detail-stream {
    position: static;
    height: auto;
    max-height: min(520px, calc(100dvh - 240px));
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .detail-panel {
    width: min(720px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    border: 1px solid var(--line);
    border-radius: 16px;
  }

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

  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .dashboard-ops-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-primary-card {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    width: min(292px, calc(100vw - 54px));
    height: 100dvh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow);
    transform: translateX(-105%);
  }

  .app-shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  .workspace {
    grid-column: 1;
  }

  .brand {
    justify-content: flex-start;
    padding: 0 14px;
  }

  .brand span {
    display: inline;
  }

  .nav-list {
    display: grid;
    overflow: visible;
    padding: 16px 10px;
  }

  .nav-item {
    grid-template-columns: 22px 1fr auto;
    min-width: 0;
    padding: 0 14px;
  }

  .nav-item span:not(.icon) {
    display: inline;
  }

  .nav-item strong {
    display: inline-block;
  }

  .agent-card {
    display: flex;
  }

  .agent-card div {
    display: grid;
  }

  .logout-label {
    display: inline;
  }

  .topbar {
    position: sticky;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    padding: 12px;
    width: 100vw;
    max-width: 100vw;
  }

  .sidebar-toggle {
    display: grid;
  }

  .search,
  .sync-card {
    display: none;
  }

  .notification-wrap {
    justify-self: end;
  }

  .app-shell.sidebar-collapsed .brand {
    justify-content: flex-start;
    padding: 0 14px;
  }

  .app-shell.sidebar-collapsed .brand span,
  .app-shell.sidebar-collapsed .nav-item span:not(.icon),
  .app-shell.sidebar-collapsed .nav-item strong,
  .app-shell.sidebar-collapsed .agent-profile-button > div:last-child,
  .app-shell.sidebar-collapsed .logout-label {
    display: inline;
  }

  .app-shell.sidebar-collapsed .nav-item,
  .app-shell.sidebar-collapsed .agent-profile-button,
  .app-shell.sidebar-collapsed .logout-button {
    width: auto;
  }

  .app-shell.sidebar-collapsed .logout-button {
    padding: 0 11px;
  }

  .app-shell.sidebar-collapsed .nav-item {
    grid-template-columns: 22px 1fr auto;
    place-items: initial;
    padding: 0 14px;
  }

  .app-shell.sidebar-collapsed .agent-card {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 14px;
  }

  .app-shell.sidebar-collapsed .nav-item::after,
  .app-shell.sidebar-collapsed .agent-profile-button::after,
  .app-shell.sidebar-collapsed .logout-button::after {
    display: none;
  }

  .topbar .primary-action {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    justify-self: stretch;
    min-height: 42px;
    color: #fff;
    font-size: 0;
    font-weight: 760;
  }

  .topbar .primary-action .icon {
    display: none;
  }

  .topbar .primary-action::after {
    content: "Создать заявку";
    color: #fff;
    font-size: 16px;
  }

  .main-column {
    padding: 16px 12px;
  }

  .source-tabs {
    grid-template-columns: 1fr 1fr;
  }

  .source-tab {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    min-height: 44px;
    padding: 7px 10px;
  }

  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .site-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-tab {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .section-heading,
  .mail-card-head,
  .dashboard-card-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .reply-required-filter,
  #resetFilters,
  .filters select,
  .sort-control,
  .sort-control select {
    width: 100%;
  }

  .sort-control {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    margin-left: 0;
    justify-self: stretch;
  }

  .reply-required-filter,
  #resetFilters {
    grid-column: 1 / -1;
  }

  .settings-view {
    padding: 16px 12px;
  }

  .reports-view {
    padding: 16px 12px;
  }

  .mail-view {
    padding: 16px 12px;
  }

  .dashboard-view {
    padding: 16px 12px;
  }

  .knowledge-view {
    padding: 16px 12px;
  }

  .events-view {
    padding: 16px 12px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .report-kpis,
  .mail-kpis,
  .dashboard-kpis,
  .reports-grid {
    grid-template-columns: 1fr;
  }

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

  .dashboard-ops-grid,
  .dashboard-online-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-online-row {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .dashboard-online-row em {
    grid-column: 2;
    width: fit-content;
  }

  .knowledge-tools,
  .knowledge-layout,
  .events-view-filters,
  .events-view-layout,
  .profile-layout,
  .event-kpis,
  .pilot-readiness-grid,
  .system-status-grid,
  .backup-status-grid,
  .work-cleanup-summary,
  .work-cleanup-form,
  .maintenance-grid,
  .restore-controls,
  .mail-diagnostics-grid,
  .system-error-log-row {
    grid-template-columns: 1fr;
  }

  .mail-diagnostics-head {
    align-items: stretch;
    flex-direction: column;
  }

  .mail-diagnostics-actions {
    justify-content: flex-start;
  }

  .mail-detail,
  .event-side-stack {
    position: static;
  }

  .events-hero-view,
  .dashboard-hero,
  .dashboard-actions,
  .events-hero-actions,
  .event-detail-actions {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .report-filters {
    grid-template-columns: 1fr;
  }

  .report-filters > span {
    justify-self: start;
    white-space: normal;
  }

  .report-wide {
    grid-column: auto;
  }

  .report-row {
    grid-template-columns: minmax(130px, 1fr) 56px 56px 70px minmax(82px, 0.7fr);
    gap: 7px;
    padding: 0 10px;
    font-size: 12px;
  }

  .users-card,
  .audit-card,
  .mail-integration-card,
  .knowledge-admin-card {
    grid-column: auto;
  }

  .user-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .order-role-legend {
    grid-template-columns: 1fr;
  }

  .order-role-picker {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .mail-admin-summary,
  .mail-admin-form {
    grid-template-columns: 1fr;
  }

  .mail-admin-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .knowledge-admin-row {
    grid-template-columns: 1fr;
  }

  .user-row select {
    grid-column: 1 / -1;
  }

  .user-2fa-cell,
  .password-reset-form {
    grid-column: 1 / -1;
  }

  .directory-row,
  .agent-edit-row,
  .category-edit-row {
    grid-template-columns: 1fr;
  }

  .directory-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .password-reset-form {
    grid-column: 1 / -1;
  }

  .ticket-table,
  .events-table,
  .mail-table {
    overflow-x: auto;
  }

  .table-row {
    min-width: 1100px;
  }

  .event-row {
    min-width: 760px;
  }

  .event-card {
    grid-template-columns: 1fr;
  }

  .mail-row {
    min-width: 820px;
  }

  .form-grid,
  .panel-actions,
  .ticket-sla-preview {
    grid-template-columns: 1fr;
  }

  .ticket-sla-preview small {
    white-space: normal;
  }
}

/* Keep the compact theme button visually unambiguous in every sidebar state. */
.theme-toggle[aria-pressed="false"] .theme-toggle-dark {
    display: none;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-light {
    display: none;
}

/* Dark theme sweep for composite surfaces that intentionally keep light accents in the default theme. */
:root[data-theme="dark"] .attention-panel,
:root[data-theme="dark"] .bulk-actions,
:root[data-theme="dark"] .mail-diagnostics,
:root[data-theme="dark"] .mail-check-panel,
:root[data-theme="dark"] .maintenance-panel,
:root[data-theme="dark"] .profile-card,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .knowledge-list,
:root[data-theme="dark"] .knowledge-article,
:root[data-theme="dark"] .knowledge-search,
:root[data-theme="dark"] .knowledge-admin-card,
:root[data-theme="dark"] .events-view-filters,
:root[data-theme="dark"] .events-view-list,
:root[data-theme="dark"] .event-detail,
:root[data-theme="dark"] .event-editor,
:root[data-theme="dark"] .pilot-readiness-item,
:root[data-theme="dark"] .mail-admin-summary div,
:root[data-theme="dark"] .backup-status-grid div,
:root[data-theme="dark"] .system-status-grid div,
:root[data-theme="dark"] .work-cleanup-summary div,
:root[data-theme="dark"] .return-summary-card,
:root[data-theme="dark"] .dashboard-kpi,
:root[data-theme="dark"] .reply-template-panel,
:root[data-theme="dark"] .attachment-section,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .ticket-edit-modal,
:root[data-theme="dark"] .ticket-close-modal {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

:root[data-theme="dark"] .bulk-actions {
  background: var(--blue-soft);
  border-color: var(--accent-border);
}

:root[data-theme="dark"] .bulk-actions span,
:root[data-theme="dark"] .bulk-actions b {
  color: var(--text);
}

:root[data-theme="dark"] .bulk-actions span {
  color: var(--muted);
}

:root[data-theme="dark"] .bulk-controls select,
:root[data-theme="dark"] .bulk-controls textarea,
:root[data-theme="dark"] .modal input:not([type="checkbox"]):not([type="radio"]),
:root[data-theme="dark"] .modal textarea,
:root[data-theme="dark"] .modal select,
:root[data-theme="dark"] .profile-password-form input,
:root[data-theme="dark"] .profile-password-form textarea,
:root[data-theme="dark"] .signature-toolbar select,
:root[data-theme="dark"] .signature-toolbar input[type="color"],
:root[data-theme="dark"] .signature-toolbar button,
:root[data-theme="dark"] .signature-editor,
:root[data-theme="dark"] .mail-admin-form input,
:root[data-theme="dark"] .mail-admin-form select,
:root[data-theme="dark"] .mail-admin-curl code,
:root[data-theme="dark"] .knowledge-admin-row input,
:root[data-theme="dark"] .knowledge-admin-row textarea,
:root[data-theme="dark"] .knowledge-admin-form textarea,
:root[data-theme="dark"] .settings-form input,
:root[data-theme="dark"] .settings-form textarea,
:root[data-theme="dark"] .settings-form select,
:root[data-theme="dark"] .user-row select,
:root[data-theme="dark"] .password-reset-form input,
:root[data-theme="dark"] .event-editor input,
:root[data-theme="dark"] .event-editor textarea,
:root[data-theme="dark"] .event-editor select,
:root[data-theme="dark"] .restore-controls input,
:root[data-theme="dark"] .work-cleanup-form input,
:root[data-theme="dark"] .file-picker {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
}

:root[data-theme="dark"] .bulk-controls select:focus,
:root[data-theme="dark"] .bulk-controls textarea:focus,
:root[data-theme="dark"] .modal input:not([type="checkbox"]):not([type="radio"]):focus,
:root[data-theme="dark"] .modal textarea:focus,
:root[data-theme="dark"] .modal select:focus {
  border-color: var(--blue);
  box-shadow: var(--focus-ring);
}

:root[data-theme="dark"] .attention-item:hover,
:root[data-theme="dark"] .dashboard-kpi:hover,
:root[data-theme="dark"] .dashboard-item:hover,
:root[data-theme="dark"] .sla-report-item:hover,
:root[data-theme="dark"] .event-related button:hover,
:root[data-theme="dark"] .report-row-button:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .event-related button,
:root[data-theme="dark"] .password-reset-form button,
:root[data-theme="dark"] .report-row-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

:root[data-theme="dark"] .settings-card-head,
:root[data-theme="dark"] .table-head,
:root[data-theme="dark"] .mail-row-head {
  background: var(--surface-soft);
  border-color: var(--line);
}

:root[data-theme="dark"] .settings-tabs button:not(.active) {
  color: var(--muted);
  background: transparent;
}

:root[data-theme="dark"] .settings-tabs button:hover:not(.active) {
  color: var(--text);
  background: var(--surface-soft);
}

:root[data-theme="dark"] .settings-tabs button.active {
  color: var(--blue);
  border-color: transparent;
  background: var(--blue-soft);
}

:root[data-theme="dark"] .attention-dismiss:hover,
:root[data-theme="dark"] .mini-action.danger:hover,
:root[data-theme="dark"] .danger-outline,
:root[data-theme="dark"] .danger-outline:hover,
:root[data-theme="dark"] .mail-network-alert {
  background: rgba(255, 107, 122, 0.12);
  border-color: rgba(255, 107, 122, 0.34);
}

:root[data-theme="dark"] .mail-network-alert,
:root[data-theme="dark"] .mail-network-alert b {
  color: #ff9aa6;
}

:root[data-theme="dark"] .file-picker span,
:root[data-theme="dark"] .attachment-type-icon,
:root[data-theme="dark"] .ticket-sla-preview span {
  background: var(--blue-soft);
  border-color: var(--accent-border);
  color: var(--blue);
}

:root[data-theme="dark"] .mail-diagnostics,
:root[data-theme="dark"] .return-summary-grid {
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface) 100%);
}

:root[data-theme="dark"] .event-site-checks,
:root[data-theme="dark"] .ticket-site-checks {
  background: var(--surface-soft);
  border-color: var(--line);
}

:root[data-theme="dark"] .event-site-checks label,
:root[data-theme="dark"] .ticket-site-checks label {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .event-site-checks label:has(input:checked),
:root[data-theme="dark"] .ticket-site-checks label:has(input:checked) {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border-color: color-mix(in srgb, var(--blue) 42%, transparent);
  color: var(--blue);
}

:root[data-theme="dark"] .event-site-checks input,
:root[data-theme="dark"] .ticket-site-checks input,
:root[data-theme="dark"] .row-select input,
:root[data-theme="dark"] .bulk-check input {
  background: var(--surface);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .detail-actions .ghost-button.favorite-ticket.active,
:root[data-theme="dark"] .timeline-item.change .timeline-marker,
:root[data-theme="dark"] .timeline-badge.change,
:root[data-theme="dark"] .dashboard-item.warning span {
  background: rgba(240, 185, 76, 0.14);
  color: #ffd37a;
  border-color: rgba(240, 185, 76, 0.34);
}

:root[data-theme="dark"] .timeline-item.mail .timeline-marker,
:root[data-theme="dark"] .timeline-badge.mail,
:root[data-theme="dark"] .dashboard-item.mail span,
:root[data-theme="dark"] .mail-status.created,
:root[data-theme="dark"] .comment-mail-state.created {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 30%, transparent);
}

:root[data-theme="dark"] .timeline-item.comment .timeline-marker,
:root[data-theme="dark"] .timeline-badge.comment,
:root[data-theme="dark"] .mail-status.comment,
:root[data-theme="dark"] .comment-mail-state.comment {
  background: rgba(95, 206, 141, 0.14);
  color: var(--green);
  border-color: rgba(95, 206, 141, 0.28);
}

:root[data-theme="dark"] .timeline-item.system .timeline-marker,
:root[data-theme="dark"] .timeline-badge.system {
  background: var(--surface-soft);
  color: var(--muted);
}

:root[data-theme="dark"] .mail-status.duplicate,
:root[data-theme="dark"] .comment-mail-state.duplicate,
:root[data-theme="dark"] .system-error-log-row b,
:root[data-theme="dark"] .dashboard-item.danger span {
  background: rgba(255, 107, 122, 0.14);
  color: var(--red);
  border-color: rgba(255, 107, 122, 0.28);
}

:root[data-theme="dark"] .dashboard-online-summary,
:root[data-theme="dark"] .dashboard-online-row {
  border-color: var(--line);
}

:root[data-theme="dark"] .dashboard-online-row.active em {
  background: rgba(95, 206, 141, 0.14);
  color: var(--green);
}

:root[data-theme="dark"] .dashboard-online-row.soon em {
  background: rgba(240, 185, 76, 0.14);
  color: #ffd37a;
}

:root[data-theme="dark"] .attachment-item:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] ::placeholder {
  color: var(--muted-2);
}

:root[data-theme="dark"] input[type="file"]::file-selector-button,
:root[data-theme="dark"] .reply-required-filter.active,
:root[data-theme="dark"] .timeline-filters button.active,
:root[data-theme="dark"] .chip.new,
:root[data-theme="dark"] .chip.work {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border-color: color-mix(in srgb, var(--blue) 34%, transparent);
  color: var(--blue);
}

:root[data-theme="dark"] input[type="file"] {
  color: var(--muted);
  background: var(--surface-soft);
  border-color: var(--line);
}

:root[data-theme="dark"] input[type="file"]::file-selector-button:hover {
  background: color-mix(in srgb, var(--blue) 22%, transparent);
  border-color: color-mix(in srgb, var(--blue) 52%, transparent);
}

:root[data-theme="dark"] .toast > span,
:root[data-theme="dark"] .chip.done,
:root[data-theme="dark"] .chip.active,
:root[data-theme="dark"] .mail-check-result.success {
  background: rgba(95, 206, 141, 0.14);
  border-color: rgba(95, 206, 141, 0.28);
  color: var(--green);
}

:root[data-theme="dark"] .toast.error > span,
:root[data-theme="dark"] .mail-check-result.error {
  background: rgba(255, 107, 122, 0.14);
  border-color: rgba(255, 107, 122, 0.3);
  color: var(--red);
}

:root[data-theme="dark"] .chip.wait {
  background: rgba(240, 185, 76, 0.14);
  color: #ffd37a;
}

:root[data-theme="dark"] .mail-check-result.success,
:root[data-theme="dark"] .mail-check-result.error {
  border-style: solid;
}

:root[data-theme="dark"] .table-head {
  color: var(--muted);
}

:root[data-theme="dark"] .ticket-id,
:root[data-theme="dark"] .row-select,
:root[data-theme="dark"] .table-row .ticket-id,
:root[data-theme="dark"] .mail-row > span:last-child,
:root[data-theme="dark"] .event-row > span,
:root[data-theme="dark"] .dashboard-kpi b,
:root[data-theme="dark"] .backup-status-grid b,
:root[data-theme="dark"] .system-status-grid b {
  color: var(--text);
}

:root[data-theme="dark"] .ticket-title-text,
:root[data-theme="dark"] .table-row > span,
:root[data-theme="dark"] .mail-row b,
:root[data-theme="dark"] .event-card b,
:root[data-theme="dark"] .event-detail h2,
:root[data-theme="dark"] .event-detail-meta span,
:root[data-theme="dark"] .knowledge-item b,
:root[data-theme="dark"] .knowledge-article h2,
:root[data-theme="dark"] .mail-diagnostic-tile b,
:root[data-theme="dark"] .audit-row p {
  color: var(--text);
}

:root[data-theme="dark"] .mail-diagnostic-tile em,
:root[data-theme="dark"] .knowledge-item span,
:root[data-theme="dark"] .knowledge-article > p,
:root[data-theme="dark"] .event-description,
:root[data-theme="dark"] .event-card em,
:root[data-theme="dark"] .event-detail-meta b,
:root[data-theme="dark"] .event-related h3,
:root[data-theme="dark"] .audit-row span,
:root[data-theme="dark"] .audit-row small,
:root[data-theme="dark"] .mail-admin-summary span {
  color: var(--muted);
}

:root[data-theme="dark"] .ticket-row.selected .ticket-id,
:root[data-theme="dark"] .ticket-row.bulk-selected .ticket-id,
:root[data-theme="dark"] .ticket-row:hover .ticket-id,
:root[data-theme="dark"] .ticket-row.selected .ticket-title-text,
:root[data-theme="dark"] .ticket-row.bulk-selected .ticket-title-text,
:root[data-theme="dark"] .ticket-row:hover .ticket-title-text {
  color: #ffffff;
}

:root[data-theme="dark"] .site-tab b,
:root[data-theme="dark"] .source-tab b,
:root[data-theme="dark"] .nav-item strong,
:root[data-theme="dark"] .attention-head-actions span,
:root[data-theme="dark"] .attachment-head span,
:root[data-theme="dark"] .notification-count,
:root[data-theme="dark"] .settings-tabs span,
:root[data-theme="dark"] .knowledge-tabs span {
  color: var(--blue);
  background: var(--blue-soft);
}

:root[data-theme="dark"] .settings-tabs button.active span {
  background: color-mix(in srgb, var(--blue) 16%, var(--blue-soft));
}

:root[data-theme="dark"] .sla-badge small,
:root[data-theme="dark"] .sla-box small,
:root[data-theme="dark"] .table-row small,
:root[data-theme="dark"] .muted-text,
:root[data-theme="dark"] .detail-muted,
:root[data-theme="dark"] .mail-row small,
:root[data-theme="dark"] .ticket-row .assignee-name,
:root[data-theme="dark"] .ticket-row .created-at {
  color: #b9c5d8;
}

:root[data-theme="dark"] .sla-badge b,
:root[data-theme="dark"] .new-reply-badge,
:root[data-theme="dark"] .detail-status,
:root[data-theme="dark"] .chip {
  text-shadow: none;
}

:root[data-theme="dark"] .sla-box {
  background: rgba(22, 34, 52, 0.76);
  border-color: var(--line);
  box-shadow: none;
}

:root[data-theme="dark"] .detail-panel {
  border-color: rgba(129, 161, 207, 0.34);
  background:
    linear-gradient(180deg, rgba(21, 32, 49, 0.98), rgba(15, 24, 38, 0.98)),
    var(--surface);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(139, 176, 232, 0.06) inset;
}

:root[data-theme="dark"] .ticket-detail-backdrop {
  background:
    radial-gradient(circle at 50% 36%, rgba(82, 132, 204, 0.2), transparent 34%),
    rgba(3, 7, 14, 0.62);
}

:root[data-theme="dark"] .content-grid.ticket-focus .detail-stream {
  background: rgba(12, 20, 33, 0.58);
  border-color: var(--line);
}

:root[data-theme="dark"] .detail-top strong,
:root[data-theme="dark"] .detail-actions .ghost-button {
  background: rgba(22, 34, 52, 0.84);
  border-color: var(--line);
}

:root[data-theme="dark"] .content-grid.ticket-focus .detail-summary::-webkit-scrollbar-thumb,
:root[data-theme="dark"] .content-grid.ticket-focus #activityPanel::-webkit-scrollbar-thumb {
  background: #40506a;
}

:root[data-theme="dark"] .sla-box b {
  color: var(--muted);
}

:root[data-theme="dark"] .sla-box span {
  color: var(--text);
}

:root[data-theme="dark"] .sla-box.risk span {
  color: #ffd37a;
}

:root[data-theme="dark"] .sla-box.overdue span {
  color: var(--red);
}

:root[data-theme="dark"] .sla-box.paused span {
  color: var(--blue);
}

:root[data-theme="dark"] .sla-line {
  background: #dbe4f3;
}

:root[data-theme="dark"] .modal-backdrop {
  background: rgba(5, 10, 18, 0.58);
}

:root[data-theme="dark"] .modal label:not(.check-option),
:root[data-theme="dark"] .ticket-edit-form label,
:root[data-theme="dark"] .profile-password-form label,
:root[data-theme="dark"] .settings-form label,
:root[data-theme="dark"] .mail-admin-form label,
:root[data-theme="dark"] .knowledge-admin-field,
:root[data-theme="dark"] .event-editor label,
:root[data-theme="dark"] .file-field {
  color: var(--muted);
}

:root[data-theme="dark"] .ticket-edit-form input,
:root[data-theme="dark"] .ticket-edit-form textarea,
:root[data-theme="dark"] .ticket-edit-form select,
:root[data-theme="dark"] .reply-template-picker select,
:root[data-theme="dark"] .reply-form textarea {
  color: var(--text);
  background: var(--surface-soft);
  border-color: var(--line);
}

:root[data-theme="dark"] .ticket-sla-preview {
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  border-color: color-mix(in srgb, var(--blue) 42%, transparent);
}

:root[data-theme="dark"] .ticket-sla-preview span {
  background: color-mix(in srgb, var(--blue) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 34%, transparent);
  color: var(--blue);
}

:root[data-theme="dark"] .ticket-sla-preview b,
:root[data-theme="dark"] .ticket-sla-preview small {
  color: var(--text);
}

:root[data-theme="dark"] .file-picker span {
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  border-color: color-mix(in srgb, var(--blue) 38%, transparent);
  color: var(--blue);
}

:root[data-theme="dark"] .restore-controls > small {
  color: var(--muted);
}

:root[data-theme="dark"] .ghost-button,
:root[data-theme="dark"] .secondary-action {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

:root[data-theme="dark"] .ghost-button:hover,
:root[data-theme="dark"] .secondary-action:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .ticket-row:hover,
:root[data-theme="dark"] .ticket-row.selected,
:root[data-theme="dark"] .ticket-row.bulk-selected {
  background: var(--blue-soft);
}

:root[data-theme="dark"] .ticket-row.selected .table-row > span,
:root[data-theme="dark"] .ticket-row.bulk-selected .table-row > span,
:root[data-theme="dark"] .ticket-row:hover .table-row > span {
  color: var(--text);
}

.event-site-checks label,
.ticket-site-checks label,
.modal .event-site-checks label,
.modal .ticket-site-checks label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  justify-content: flex-start;
  width: max-content;
  max-width: 100%;
  gap: 8px;
  min-height: 34px;
  padding: 0 11px;
  line-height: 1;
}

.event-site-checks input,
.ticket-site-checks input,
.modal .event-site-checks input[type="checkbox"],
.modal .ticket-site-checks input[type="checkbox"] {
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  height: 18px;
  min-height: 18px;
  max-height: 18px;
  margin: 0;
  padding: 0;
  appearance: none;
}

.event-site-checks label span,
.ticket-site-checks label span {
  min-width: 0;
  overflow: hidden;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Colored status blocks get a quiet glow; neutral cards keep their plain surface. */
.mail-kpi,
.dashboard-kpi,
.report-kpi,
.attention-item,
.dashboard-item,
.mail-check-result,
.mail-diagnostic-tile {
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.mail-kpi.blue,
.dashboard-kpi.blue,
.report-kpi.blue,
.dashboard-item.mail,
.attention-item {
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--blue) 8%, transparent),
    0 0 18px color-mix(in srgb, var(--blue) 12%, transparent),
    0 12px 30px color-mix(in srgb, var(--blue) 9%, transparent);
}

.mail-kpi.green,
.dashboard-kpi.green,
.mail-check-result.success,
.mail-diagnostic-tile.success {
  box-shadow:
    0 0 0 1px rgba(31, 164, 99, 0.1),
    0 0 18px rgba(31, 164, 99, 0.15),
    0 12px 30px rgba(31, 164, 99, 0.1);
}

.mail-kpi.amber,
.dashboard-kpi.mail,
.report-kpi.amber,
.attention-item.warning,
.dashboard-item.warning {
  box-shadow:
    0 0 0 1px rgba(224, 161, 54, 0.1),
    0 0 18px rgba(224, 161, 54, 0.16),
    0 12px 30px rgba(224, 161, 54, 0.1);
}

.mail-kpi.red,
.dashboard-kpi.danger,
.report-kpi.red,
.attention-item.danger,
.dashboard-item.danger,
.mail-check-result.error,
.mail-diagnostic-tile.error {
  box-shadow:
    0 0 0 1px rgba(220, 53, 69, 0.1),
    0 0 18px rgba(220, 53, 69, 0.15),
    0 12px 30px rgba(220, 53, 69, 0.1);
}

:root[data-theme="dark"] .mail-kpi.blue,
:root[data-theme="dark"] .dashboard-kpi.blue,
:root[data-theme="dark"] .report-kpi.blue,
:root[data-theme="dark"] .dashboard-item.mail,
:root[data-theme="dark"] .attention-item {
  border-color: color-mix(in srgb, var(--blue) 55%, transparent);
  background:
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--blue) 16%, transparent), transparent 42%),
    linear-gradient(135deg, color-mix(in srgb, var(--blue) 8%, transparent), transparent 60%),
    var(--surface);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--blue) 20%, transparent),
    0 0 34px color-mix(in srgb, var(--blue) 20%, transparent),
    inset 0 0 26px color-mix(in srgb, var(--blue) 5%, transparent),
    0 16px 38px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .mail-kpi.green,
:root[data-theme="dark"] .dashboard-kpi.green,
:root[data-theme="dark"] .mail-check-result.success,
:root[data-theme="dark"] .mail-diagnostic-tile.success {
  border-color: rgba(95, 206, 141, 0.42);
  background:
    radial-gradient(circle at 18% 0%, rgba(95, 206, 141, 0.15), transparent 42%),
    linear-gradient(135deg, rgba(95, 206, 141, 0.07), transparent 60%),
    var(--surface);
  box-shadow:
    0 0 0 1px rgba(95, 206, 141, 0.16),
    0 0 34px rgba(95, 206, 141, 0.18),
    inset 0 0 26px rgba(95, 206, 141, 0.05),
    0 16px 38px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .mail-kpi.amber,
:root[data-theme="dark"] .dashboard-kpi.mail,
:root[data-theme="dark"] .report-kpi.amber,
:root[data-theme="dark"] .attention-item.warning,
:root[data-theme="dark"] .dashboard-item.warning {
  border-color: rgba(240, 185, 76, 0.42);
  background:
    radial-gradient(circle at 18% 0%, rgba(240, 185, 76, 0.16), transparent 42%),
    linear-gradient(135deg, rgba(240, 185, 76, 0.075), transparent 60%),
    var(--surface);
  box-shadow:
    0 0 0 1px rgba(240, 185, 76, 0.17),
    0 0 34px rgba(240, 185, 76, 0.2),
    inset 0 0 26px rgba(240, 185, 76, 0.05),
    0 16px 38px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .mail-kpi.red,
:root[data-theme="dark"] .dashboard-kpi.danger,
:root[data-theme="dark"] .report-kpi.red,
:root[data-theme="dark"] .attention-item.danger,
:root[data-theme="dark"] .dashboard-item.danger,
:root[data-theme="dark"] .mail-check-result.error,
:root[data-theme="dark"] .mail-diagnostic-tile.error {
  border-color: rgba(255, 107, 122, 0.42);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 107, 122, 0.15), transparent 42%),
    linear-gradient(135deg, rgba(255, 107, 122, 0.07), transparent 60%),
    var(--surface);
  box-shadow:
    0 0 0 1px rgba(255, 107, 122, 0.17),
    0 0 34px rgba(255, 107, 122, 0.19),
    inset 0 0 26px rgba(255, 107, 122, 0.05),
    0 16px 38px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] .two-factor-setup {
  border-color: rgba(126, 166, 255, 0.55);
  background: rgba(126, 166, 255, 0.1);
}

:root[data-theme="dark"] .two-factor-qr {
  border-color: #4b5f7d;
  background: #fff;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.34);
}

:root[data-theme="dark"] .two-factor-setup code,
:root[data-theme="dark"] .two-factor-status b {
  color: var(--text);
}

:root[data-theme="dark"] .two-factor-status.enabled {
  border-color: rgba(95, 206, 141, 0.42);
  background: rgba(95, 206, 141, 0.09);
}

:root[data-theme="dark"] .two-factor-status.required {
  border-color: rgba(240, 185, 76, 0.42);
  background: rgba(240, 185, 76, 0.1);
}

:root[data-theme="dark"] .two-factor-pill {
  color: #b7c2d5;
  background: var(--surface-soft);
}

:root[data-theme="dark"] .two-factor-pill.enabled {
  color: #78e0a1;
  background: rgba(95, 206, 141, 0.14);
}

:root[data-theme="dark"] .two-factor-pill.required {
  color: #ffd47a;
  background: rgba(240, 185, 76, 0.15);
}

:root[data-theme="dark"] .mail-table {
  scrollbar-color: #40506a transparent;
}

:root[data-theme="dark"] .mail-table::-webkit-scrollbar-thumb {
  background: #40506a;
}

/* Compact operational views and a stable collapsed sidebar footer. */
.reports-view,
.dashboard-view {
  padding: 20px;
}

.reports-hero,
.dashboard-hero {
  margin-bottom: 12px;
}

.reports-hero h1,
.dashboard-hero h1 {
  font-size: 22px;
}

.report-filters {
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.report-filters label {
  gap: 4px;
}

.report-filters select {
  height: 36px;
}

.report-kpis,
.dashboard-kpis {
  gap: 10px;
  margin-bottom: 12px;
}

.report-kpi,
.dashboard-kpi {
  align-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 12px 14px;
}

.report-kpi b,
.dashboard-kpi b {
  font-size: 26px;
}

.reports-grid,
.dashboard-layout,
.dashboard-ops-grid {
  gap: 12px;
}

.report-card-head,
.dashboard-card-head {
  min-height: 46px;
  padding: 8px 14px;
}

.report-card-head h2,
.dashboard-card-head h2 {
  font-size: 14px;
}

.report-row {
  min-height: 40px;
  padding-inline: 14px;
}

.report-row-head {
  min-height: 34px;
}

.return-summary-grid,
.source-report {
  gap: 8px;
  padding: 10px 14px;
}

.return-summary-card {
  min-height: 72px;
  padding: 10px 12px;
}

.return-summary-card b {
  font-size: 23px;
}

.sla-report-item {
  min-height: 52px;
  padding: 8px 14px;
}

.dashboard-primary-card .dashboard-list {
  max-height: 232px;
}

.dashboard-list.compact {
  max-height: 238px;
}

.dashboard-item {
  gap: 3px;
  min-height: 58px;
  padding: 9px 14px;
}

.dashboard-item span {
  padding: 2px 7px;
}

.dashboard-card > .wide-action {
  width: calc(100% - 28px);
  margin: 10px 14px 14px;
}

.dashboard-ops-grid {
  margin-top: 12px;
}

.dashboard-online-summary span {
  padding: 8px 12px;
}

.dashboard-online-row {
  min-height: 56px;
  padding: 8px 12px;
}

:root[data-theme="dark"] .dashboard-item.danger,
:root[data-theme="dark"] .dashboard-item.warning,
:root[data-theme="dark"] .dashboard-item.mail,
:root[data-theme="dark"] .dashboard-item.info {
  box-shadow:
    0 0 0 1px color-mix(in srgb, currentColor 12%, transparent),
    0 0 14px color-mix(in srgb, currentColor 9%, transparent),
    inset 0 0 18px color-mix(in srgb, currentColor 3%, transparent);
}

.app-shell.sidebar-collapsed .agent-card {
  display: grid;
  grid-template-columns: 40px;
  justify-content: center;
  justify-items: center;
  gap: 8px;
  padding: 10px 8px 12px;
}

.app-shell.sidebar-collapsed .theme-toggle {
  grid-column: auto;
  width: 40px;
  height: 40px;
  padding: 0;
}

.app-shell.sidebar-collapsed .agent-profile-button {
  width: 40px;
  height: 40px;
  flex: none;
  justify-content: center;
  padding: 3px;
}

.app-shell.sidebar-collapsed .agent-profile-button .avatar {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.app-shell.sidebar-collapsed .logout-button {
  width: 40px;
  height: 40px;
  padding: 0;
}

@media (min-width: 761px) and (max-width: 1180px) {
  .agent-card {
    grid-template-columns: 40px;
    justify-content: center;
    justify-items: center;
    gap: 8px;
    padding: 10px 8px 12px;
  }

  .theme-toggle-label,
  .agent-profile-button > div:last-child {
    display: none;
  }

  .theme-toggle {
    grid-column: auto;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
  }

  .agent-profile-button {
    width: 40px;
    height: 40px;
    flex: none;
    justify-content: center;
    padding: 3px;
  }

  .agent-profile-button .avatar {
    display: grid;
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .logout-button {
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 760px) {
  .agent-card,
  .app-shell.sidebar-collapsed .agent-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    justify-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }

  .theme-toggle,
  .app-shell.sidebar-collapsed .theme-toggle {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
    height: 36px;
    padding: 0 10px;
  }

  .theme-toggle-label,
  .app-shell.sidebar-collapsed .theme-toggle-label {
    display: inline;
  }

  .agent-profile-button,
  .app-shell.sidebar-collapsed .agent-profile-button {
    width: auto;
    height: auto;
    justify-content: flex-start;
    padding: 6px;
  }

  .agent-profile-button > div:last-child,
  .app-shell.sidebar-collapsed .agent-profile-button > div:last-child {
    display: grid;
  }

  .logout-button,
  .app-shell.sidebar-collapsed .logout-button {
    width: auto;
    height: 34px;
    padding: 0 11px;
  }

  .logout-label,
  .app-shell.sidebar-collapsed .logout-label {
    display: inline;
  }
}

.theme-toggle[aria-pressed="false"] .theme-toggle-dark {
  display: none;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-light {
  display: none;
}

/* UI refresh: final overrides after all legacy component styles. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --line: #e1e6ec;
  --line-strong: #cbd3dd;
  --text: #182230;
  --ink: #182230;
  --muted: #647184;
  --muted-2: #98a2b3;
  --blue: #2f64d6;
  --blue-soft: #edf3ff;
  --shadow: 0 18px 48px rgba(20, 34, 53, 0.12);
  --shadow-soft: 0 4px 14px rgba(20, 34, 53, 0.05);
  --radius: 10px;
}

:root[data-theme="dark"] {
  --bg: #101722;
  --surface: #171f2b;
  --surface-soft: #1d2735;
  --line: #2b3747;
  --line-strong: #3a485b;
  --text: #edf2f8;
  --ink: #edf2f8;
  --muted: #a5b0c0;
  --muted-2: #738096;
  --blue: #79a7ff;
  --blue-soft: #1d3154;
}

.app-shell { --sidebar-width: 224px; }
.app-shell.sidebar-collapsed { --sidebar-width: 68px; }
.brand { height: 64px; }
.nav-list { display: block; flex: 1 1 auto; overflow-y: auto; padding: 12px 10px 18px; }
.nav-section-label {
  display: block;
  padding: 12px 10px 6px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.nav-item { min-height: 40px; margin: 2px 0; padding-inline: 11px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.nav-item:hover { color: var(--text); background: var(--surface-soft); }
.nav-item.active { color: var(--blue); background: var(--blue-soft); }
.app-shell.sidebar-collapsed .nav-section-label { height: 12px; padding: 0; overflow: hidden; color: transparent; }

.topbar {
  grid-template-columns: 38px minmax(260px, 760px) minmax(20px, 1fr) auto 38px;
  min-height: 64px;
  gap: 10px;
  padding: 10px 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.topbar .search { grid-column: 2; height: 40px; background: var(--surface-soft); box-shadow: none; }
.topbar > .primary-action { grid-column: 4; box-shadow: none; }
.topbar .sync-card { display: none; }
.topbar .notification-wrap { grid-column: 5; }

.main-column,
.settings-view,
.reports-view,
.mail-view,
.dashboard-view,
.knowledge-view,
.events-view,
.orders-view,
.profile-view { padding: 26px 28px 38px; }
.queue-heading { margin-bottom: 14px; }
.queue-heading h1,
.dashboard-hero h1,
.settings-hero h1,
.orders-hero h1 { font-size: 24px; letter-spacing: -.02em; }
.queue-heading p { margin-top: 4px; color: var(--muted); font-size: 13px; }

.site-tabs { display: flex; flex-wrap: nowrap; gap: 4px; padding-bottom: 10px; overflow-x: auto; }
.site-tab {
  flex: 0 0 auto;
  width: auto;
  max-width: 260px;
  height: 32px;
  padding-inline: 9px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.site-tab.active { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 24%, var(--line)); background: var(--surface); box-shadow: none; }

.source-tabs {
  display: inline-flex;
  grid-template-columns: none;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 12px;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.source-tab {
  display: inline-flex;
  grid-template-columns: none;
  flex: 0 0 auto;
  min-height: 34px;
  gap: 7px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.source-tab .icon { width: 20px; height: 20px; border-radius: 6px; background: transparent !important; }
.source-tab .icon svg { width: 15px; height: 15px; }
.source-tab span { display: block; font-weight: 700; }
.source-tab small { display: none; }
.source-tab b { min-width: 20px; height: 20px; padding-inline: 5px; color: var(--muted); background: color-mix(in srgb, var(--muted) 9%, transparent); font-size: 10px; }
.source-tab.active { color: var(--blue); border-color: var(--line); background: var(--surface); box-shadow: 0 1px 3px rgba(20, 34, 53, .06); }

.filters {
  grid-template-columns: auto auto minmax(190px, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.filters > select,
.filters > #resetFilters { display: none; }
.filter-button { min-width: 112px; height: 34px; border-color: transparent; background: var(--surface-soft); font-size: 12px; }
.filter-button b { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: 999px; color: #fff; background: var(--blue); font-size: 10px; }
.reply-required-filter { grid-column: auto; min-height: 34px; border-color: transparent; background: transparent; color: var(--muted); font-size: 12px; }
.sort-control { grid-column: auto; grid-template-columns: auto minmax(150px, 190px); justify-self: end; }
.sort-control select { height: 34px; font-size: 12px; }
.filters.expanded { grid-template-columns: repeat(6, minmax(112px, 1fr)); padding: 10px; }
.filters.expanded > select:not(#sourceFilter) { display: block; height: 36px; font-size: 12px; }
.filters.expanded > #resetFilters { display: inline-flex; grid-column: auto; height: 36px; }
.filters.expanded .reply-required-filter { grid-column: span 2; border-color: var(--line); background: var(--surface-soft); }
.filters.expanded .sort-control { grid-column: span 3; }

.attention-panel { grid-template-columns: 190px minmax(0, 1fr); gap: 12px; margin: 0 0 12px; padding: 10px 12px; box-shadow: none; }
.attention-head-actions .link-button { display: none; }
.attention-list { display: flex; grid-template-columns: none; flex-wrap: nowrap; gap: 6px; overflow-x: auto; }
.attention-item { flex: 0 0 220px; min-height: 50px; border-left-width: 3px; border-radius: 8px; }
.attention-item > button:first-child { padding: 8px 0 8px 10px; }
.attention-item b { font-size: 12px; }
.attention-item span { font-size: 11px; }

.ticket-table,
.events-table { border-radius: 12px; }
.table-head { min-height: 38px; color: var(--muted); font-size: 11px; }
.table-row { min-height: 52px; }
.ticket-title-text { font-weight: 690; }

.dashboard-kpis,
.order-kpis { gap: 0; overflow: hidden; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.dashboard-kpi,
.order-kpis > div { min-height: 82px; padding: 12px 14px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: var(--surface); box-shadow: none; }
.dashboard-kpi:first-child,
.order-kpis > div:first-child { border-left: 0; }
.dashboard-kpi b,
.order-kpis b { font-size: 25px; }
.dashboard-card,
.settings-card,
.orders-list,
.order-detail-card,
.orders-empty-detail,
.profile-card { border-radius: 12px; box-shadow: none; }
.dashboard-card-head,
.settings-card-head { min-height: 50px; padding: 10px 14px; background: var(--surface); }

.settings-tabs { gap: 22px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.settings-tabs button { min-height: 40px; padding: 0 1px 10px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); font-size: 13px; }
.settings-tabs button:hover,
.settings-tabs button.active { color: var(--blue); border-color: var(--blue); background: transparent; }

.order-filters { gap: 8px; padding: 8px; border-radius: 11px; }
.order-filters input,
.order-filters select { height: 36px; border-color: transparent; font-size: 12px; }
.orders-list { max-height: none; }
.order-list-item { min-height: 104px; padding: 12px 14px; }

.detail-panel { width: min(1220px, calc(100vw - 40px)); max-height: calc(100dvh - 40px); border-color: var(--line); border-radius: 14px; background: var(--surface); }
.content-grid.ticket-focus .detail-layout { grid-template-columns: minmax(390px, .42fr) minmax(520px, .58fr); min-height: min(700px, calc(100dvh - 40px)); max-height: calc(100dvh - 40px); }
.content-grid.ticket-focus .detail-summary { padding: 22px 24px; }
.content-grid.ticket-focus .detail-stream { background: var(--surface-soft); }
.content-grid.ticket-focus #activityPanel { padding: 0 24px 24px; }
.detail-top { margin: 0 0 16px; }
.detail-top strong { min-height: 28px; padding: 4px 9px; border: 0; border-radius: 6px; font-size: 12px; }
.detail-actions .ghost-button { width: 34px; height: 34px; border-color: transparent; border-radius: 8px; background: transparent; box-shadow: none; }
.detail-title-block { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.detail-title-block h3 { max-width: 34ch; font-size: 21px; letter-spacing: -.02em; }
.detail-status { flex: 0 0 auto; margin: 0; padding: 5px 9px; border-color: transparent; border-radius: 7px; font-size: 11px; }
.sla-box { margin: 16px 0 8px; padding: 12px; border-radius: 10px; }
.meta-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; margin: 8px 0 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.meta-item { grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.meta-item:nth-last-child(-n + 2) { border-bottom: 0; }
.meta-item b,
.sla-box b { margin-bottom: 2px; color: var(--muted); font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.meta-item span { font-size: 12px; }
.timeline-tabs { min-height: 56px; gap: 22px; padding: 0 24px; background: var(--surface); }
.timeline-tabs button { height: 56px; font-size: 13px; }
.timeline-filters { gap: 2px; padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.timeline-filters button { min-height: 30px; padding-inline: 8px; border-color: transparent; border-radius: 7px; background: transparent; font-size: 11px; }
.timeline-filters button.active { border-color: transparent; background: var(--blue-soft); }
.timeline { gap: 0; padding-top: 4px; }
.timeline-item { grid-template-columns: 54px 20px minmax(0, 1fr); gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline-marker { width: 20px; height: 20px; margin-top: 2px; border-radius: 6px; }
.timeline-marker svg { width: 12px; height: 12px; }
.timeline-body { padding: 0; border: 0; background: transparent; }
.timeline-time { padding-top: 3px; font-size: 11px; }
.timeline-body-head b,
.timeline-body p { font-size: 12px; }
.timeline-body p { color: var(--muted); }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { width: 68px; }
  .topbar { grid-template-columns: 38px minmax(220px, 1fr) auto 38px; }
  .topbar > .primary-action { grid-column: 3; }
  .topbar .notification-wrap { grid-column: 4; }
  .filters.expanded { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .content-grid.ticket-focus .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .attention-panel { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: min(280px, calc(100vw - 48px)); }
  .nav-section-label,
  .app-shell.sidebar-collapsed .nav-section-label { height: auto; padding: 12px 10px 6px; color: var(--muted-2); }
  .topbar { grid-template-columns: 38px minmax(0, 1fr) 38px; min-height: 58px; padding: 8px 12px; }
  .topbar > .primary-action { grid-column: 2; }
  .topbar .notification-wrap { grid-column: 3; }
  .main-column,
  .settings-view,
  .reports-view,
  .mail-view,
  .dashboard-view,
  .knowledge-view,
  .events-view,
  .orders-view,
  .profile-view { padding: 18px 12px 28px; }
  .source-tabs { display: flex; width: 100%; }
  .filters { grid-template-columns: 1fr auto; }
  .filters .sort-control { grid-column: 1 / -1; width: 100%; }
  .filters.expanded { grid-template-columns: 1fr; }
  .filters.expanded > *,
  .filters.expanded .reply-required-filter,
  .filters.expanded .sort-control { grid-column: 1; }
  .detail-panel { inset: 0; width: 100vw; max-height: 100dvh; overflow-y: auto; border: 0; border-radius: 0; transform: translateY(12px); }
  .content-grid.ticket-focus .detail-panel { transform: none; }
  .content-grid.ticket-focus .detail-layout { display: block; max-height: none; min-height: 100dvh; }
  .content-grid.ticket-focus .detail-summary,
  .content-grid.ticket-focus #activityPanel { overflow: visible; padding-inline: 16px; }
  .content-grid.ticket-focus .detail-stream { max-height: none; overflow: visible; }
  .detail-title-block { display: grid; }
  .meta-list { grid-template-columns: 1fr; }

  .dashboard-kpis,
  .order-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-kpi:nth-child(odd),
  .order-kpis > div:nth-child(odd) {
    border-left: 0;
  }

  .dashboard-kpi:nth-child(n + 3),
  .order-kpis > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .ticket-table {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .ticket-table > .table-head {
    display: none;
  }

  #ticketRows {
    display: grid;
    gap: 8px;
  }

  .table-row.ticket-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    grid-template-areas:
      "check id status"
      "check title title"
      ". sla sla"
      ". site assignee"
      ". created priority";
    gap: 7px 9px;
    min-width: 0;
    min-height: 0;
    padding: 11px 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-left: 3px solid var(--line-strong);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: none;
  }

  .table-row.ticket-row.sla-risk { border-left-color: var(--amber); }
  .table-row.ticket-row.sla-overdue { border-left-color: var(--red); }
  .table-row.ticket-row.sla-paused { border-left-color: var(--blue); }
  .table-row.ticket-row.has-unread-reply { border-left-color: var(--blue); }

  .table-row.ticket-row > span {
    padding: 0;
    overflow: visible;
  }

  .table-row.ticket-row > span:nth-child(1) { grid-area: check; }
  .table-row.ticket-row > span:nth-child(2) { grid-area: id; align-self: center; }
  .table-row.ticket-row > span:nth-child(3) { grid-area: title; }
  .table-row.ticket-row > span:nth-child(4) { grid-area: status; justify-self: end; }
  .table-row.ticket-row > span:nth-child(5) { grid-area: priority; justify-self: end; }
  .table-row.ticket-row > span:nth-child(6) { grid-area: sla; }
  .table-row.ticket-row > span:nth-child(7) { grid-area: site; color: var(--muted); font-size: 12px; }
  .table-row.ticket-row > span:nth-child(8) { grid-area: created; color: var(--muted); font-size: 11px; }
  .table-row.ticket-row > span:nth-child(9) { grid-area: assignee; justify-self: end; }

  .table-row.ticket-row .row-select {
    margin-top: 1px;
  }

  .table-row.ticket-row .ticket-id {
    color: var(--blue);
    font-size: 11px;
  }

  .table-row.ticket-row .ticket-title {
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.35;
  }

  .table-row.ticket-row .ticket-title-text {
    overflow: visible;
    white-space: normal;
  }

  .table-row.ticket-row .sla-badge {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }

  .table-row.ticket-row .sla-badge small {
    white-space: normal;
  }

  .table-row.ticket-row .assignee .avatar {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .order-modal {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-x: hidden;
  }

  .order-modal .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .order-modal .modal-actions > * {
    width: 100%;
  }

  .order-workflow {
    gap: 6px;
    padding-bottom: 8px;
    scrollbar-width: thin;
  }

  .order-workflow > div {
    min-width: 92px;
  }
}

/* UI density pass: comfortable primary navigation, compact reports and settings. */
@media (min-width: 761px) {
  .app-shell {
    --sidebar-width: 252px;
  }

  .app-shell.sidebar-collapsed {
    --sidebar-width: 76px;
  }

  .brand {
    height: 68px;
    padding-inline: 18px;
    font-size: 21px;
  }

  .nav-list {
    padding: 10px 12px 20px;
  }

  .nav-section-label {
    padding: 13px 11px 7px;
    font-size: 11px;
  }

  .nav-item {
    min-height: 44px;
    padding-inline: 12px;
    gap: 12px;
    font-size: 14px;
  }
}

.reports-view,
.settings-view {
  padding: 20px 22px 32px;
}

.reports-hero,
.settings-hero {
  align-items: center;
  margin-bottom: 10px;
}

.reports-hero h1,
.settings-hero h1 {
  font-size: 22px;
}

.reports-hero p,
.settings-hero p {
  margin-top: 3px;
}

.report-filters {
  gap: 7px;
  margin-bottom: 10px;
  padding: 8px 10px;
  box-shadow: none;
}

.report-filters label {
  gap: 3px;
  font-size: 11px;
}

.report-filters select {
  height: 34px;
  font-size: 12px;
}

.report-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.report-kpi,
.report-kpi.blue,
.report-kpi.red,
.report-kpi.amber {
  align-content: center;
  gap: 3px;
  min-height: 72px;
  padding: 9px 12px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.report-kpi:first-child {
  border-left: 0;
}

.report-kpi b {
  font-size: 23px;
}

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

.report-sites {
  grid-column: span 8;
}

.report-side-stack {
  grid-column: span 4;
  display: grid;
  gap: 10px;
  align-content: start;
}

.report-assignees,
.report-categories {
  grid-column: span 6;
}

.report-returns {
  grid-column: 1 / -1;
}

.report-card-head {
  min-height: 40px;
  padding: 7px 12px;
  background: var(--surface);
}

.report-card-head h2 {
  margin: 0;
  font-size: 14px;
}

.report-row {
  grid-template-columns: minmax(130px, 1fr) 64px 64px 84px minmax(90px, .8fr);
  gap: 8px;
  min-height: 36px;
  padding-inline: 12px;
  font-size: 12px;
}

.report-row-head {
  min-height: 30px;
  font-size: 11px;
}

.source-report {
  gap: 0;
  padding: 6px 10px;
}

.source-metric {
  grid-template-columns: minmax(104px, .7fr) minmax(60px, 1fr) 24px 34px;
  gap: 6px;
  min-height: 34px;
  border-top: 1px solid var(--line);
}

.source-metric:first-child {
  border-top: 0;
}

.source-metric > span {
  grid-column: 1;
  grid-row: 1;
  font-size: 12px;
}

.source-metric > b {
  grid-column: 3;
  grid-row: 1;
  text-align: right;
}

.source-metric .report-bar {
  grid-column: 2;
  grid-row: 1;
}

.source-metric small {
  grid-column: 4;
  grid-row: 1;
  font-size: 11px;
}

.sla-report-list {
  max-height: 112px;
}

.sla-report-item {
  gap: 2px;
  min-height: 40px;
  padding: 5px 10px;
}

.return-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 8px 12px;
}

.return-summary-card {
  min-height: 62px;
  padding: 8px 10px;
}

.return-summary-card b {
  font-size: 21px;
}

.settings-layout {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

.settings-tabs {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 6px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.settings-tabs button {
  justify-content: space-between;
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  font-size: 12px;
}

.settings-tabs button:hover,
.settings-tabs button.active {
  border-color: transparent;
  background: var(--blue-soft);
}

.settings-tabs span {
  min-width: 20px;
  height: 20px;
  padding-inline: 5px;
  font-size: 10px;
}

.settings-grid {
  gap: 10px;
}

.settings-grid-directories {
  grid-template-columns: minmax(220px, .75fr) minmax(300px, 1fr) minmax(300px, 1fr);
}

.settings-grid-users {
  grid-template-columns: minmax(360px, .55fr) minmax(0, 1fr);
}

.settings-grid-maintenance {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-grid-maintenance .pilot-readiness-card,
.settings-grid-maintenance .system-status-card,
.settings-grid-maintenance .backup-card,
.settings-grid-maintenance .system-errors-card {
  grid-column: 1 / -1;
}

.settings-card-head {
  min-height: 42px;
  padding: 7px 12px;
}

.settings-list {
  max-height: 280px;
}

.settings-row {
  min-height: 44px;
  padding: 6px 10px;
}

.directory-row input,
.settings-form input,
.settings-form select {
  height: 34px;
}

.settings-form {
  gap: 8px;
  padding: 10px;
}

.settings-note {
  padding: 8px 10px;
}

.agents-card .agent-edit-row {
  grid-template-columns: 32px minmax(96px, 1fr) 48px auto;
  gap: 8px;
}

.agents-card .mini-action {
  min-width: 48px;
  padding-inline: 6px;
}

.pilot-readiness-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 10px;
}

.pilot-readiness-item {
  gap: 4px;
  min-height: 76px;
  padding: 9px 10px;
}

.pilot-readiness-item span {
  margin-bottom: 4px;
  padding: 2px 6px;
  font-size: 10px;
}

.pilot-readiness-item b {
  font-size: 14px;
}

.pilot-readiness-item small,
.pilot-readiness-item p {
  font-size: 11px;
  line-height: 1.3;
}

@media (min-width: 981px) and (max-width: 1180px) {
  .app-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .sidebar {
    width: var(--sidebar-width);
  }

  .app-shell:not(.sidebar-collapsed) .agent-card {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: stretch;
    justify-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }

  .app-shell:not(.sidebar-collapsed) .brand {
    justify-content: flex-start;
    padding-inline: 18px;
  }

  .app-shell:not(.sidebar-collapsed) .brand span,
  .app-shell:not(.sidebar-collapsed) .nav-item span:not(.icon),
  .app-shell:not(.sidebar-collapsed) .nav-item strong,
  .app-shell:not(.sidebar-collapsed) .logout-label {
    display: inline;
  }

  .app-shell:not(.sidebar-collapsed) .nav-item {
    grid-template-columns: 22px 1fr auto;
    place-items: initial;
    align-items: center;
    padding-inline: 12px;
  }

  .app-shell:not(.sidebar-collapsed) .theme-toggle-label,
  .app-shell:not(.sidebar-collapsed) .agent-profile-button > div:last-child {
    display: grid;
  }

  .app-shell:not(.sidebar-collapsed) .theme-toggle {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
    height: 36px;
    padding-inline: 10px;
  }

  .app-shell:not(.sidebar-collapsed) .agent-profile-button {
    width: auto;
    height: auto;
    justify-content: flex-start;
    padding: 6px;
  }

  .app-shell:not(.sidebar-collapsed) .logout-button {
    width: auto;
    height: 34px;
    padding-inline: 11px;
  }
}

@media (max-width: 1350px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    position: static;
    display: flex;
    gap: 3px;
    padding: 4px;
    overflow-x: auto;
  }

  .settings-tabs button {
    flex: 0 0 auto;
  }

  .settings-grid-directories {
    grid-template-columns: minmax(260px, .8fr) minmax(360px, 1.2fr);
  }

  .settings-grid-directories .order-sla-settings-card {
    grid-column: 1 / -1;
  }
}

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

  .report-filters > #reportResetFilters {
    grid-column: 1;
    justify-self: start;
  }

  .report-filters > span {
    grid-column: 2 / -1;
    justify-self: end;
  }

  .report-sites,
  .report-assignees,
  .report-categories,
  .report-returns {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .report-side-stack {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .pilot-readiness-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .settings-grid-users,
  .settings-grid-directories,
  .settings-grid-maintenance {
    grid-template-columns: 1fr;
  }

  .settings-grid-maintenance > *,
  .settings-grid-directories .order-sla-settings-card {
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  .brand {
    height: 68px;
    font-size: 21px;
  }

  .nav-section-label {
    font-size: 11px;
  }

  .nav-item {
    min-height: 44px;
    padding-inline: 12px;
    font-size: 14px;
  }

  .reports-view,
  .settings-view {
    padding: 16px 12px 26px;
  }

  .reports-hero,
  .settings-hero {
    align-items: flex-start;
  }

  .report-filters {
    grid-template-columns: 1fr;
  }

  .report-filters > #reportResetFilters,
  .report-filters > span {
    grid-column: 1;
    justify-self: start;
  }

  .report-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-kpi,
  .report-kpi.blue,
  .report-kpi.red,
  .report-kpi.amber {
    min-height: 68px;
    border-top: 1px solid var(--line);
  }

  .report-kpi:nth-child(odd) {
    border-left: 0;
  }

  .report-kpi:nth-child(-n + 2) {
    border-top: 0;
  }

  .report-kpi:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .reports-grid {
    grid-template-columns: 1fr;
  }

  .report-sites,
  .report-side-stack,
  .report-sources,
  .report-sla,
  .report-assignees,
  .report-categories,
  .report-returns {
    grid-column: 1;
  }

  .report-side-stack,
  .pilot-readiness-grid {
    grid-template-columns: 1fr;
  }

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

  .report-row {
    min-width: 530px;
  }

  .return-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-tabs {
    margin-inline: -1px;
  }
}

/* Readable user access cards and an explicit password reset workflow. */
.user-card-list {
  grid-template-columns: repeat(auto-fit, minmax(600px, 1fr));
  gap: 10px;
  max-height: 680px;
  padding: 10px;
  background: var(--surface-soft);
}

.user-card-list .user-access-card {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.user-card-list .user-access-card > * {
  grid-column: 1 !important;
}

.user-card-identity {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
}

.user-card-identity .avatar {
  width: 40px;
  height: 40px;
  flex-basis: 40px;
}

.user-access-card .user-meta {
  gap: 1px;
}

.user-access-card .user-meta b {
  font-size: 15px;
}

.user-access-card .user-meta span,
.user-access-card .user-meta small {
  overflow: visible;
  color: var(--muted);
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.user-access-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(135px, 1fr));
  gap: 8px;
}

.user-access-field {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
}

.user-access-field > span:first-child,
.user-card-section-title > b,
.password-reset-title > b {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.user-access-card select {
  grid-column: auto;
  height: 38px;
  padding-inline: 10px;
  font-size: 13px;
}

.user-2fa-field .user-2fa-cell {
  grid-column: auto !important;
  min-height: 38px;
  flex-wrap: wrap;
}

.user-2fa-field .two-factor-pill {
  min-height: 30px;
}

.user-orders-section,
.password-reset-form {
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.user-card-section-title,
.password-reset-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.user-card-section-title > span,
.password-reset-title > small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  text-align: right;
}

.user-access-card .order-role-picker {
  grid-column: auto !important;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 7px;
}

.user-access-card .order-role-picker label {
  align-items: flex-start;
  gap: 8px;
  min-height: 60px;
  padding: 9px 10px;
}

.user-access-card .order-role-picker label > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-access-card .order-role-picker label b {
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
}

.user-access-card .order-role-picker label small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.user-access-card .admin-order-role {
  margin-top: 1px;
}

.user-access-card .password-reset-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.password-reset-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 7px;
}

.user-access-card .password-reset-form input,
.user-access-card .password-reset-form button {
  height: 38px;
}

.user-access-card .password-reset-form input {
  padding-inline: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .03em;
}

.user-access-card .password-reset-form button {
  min-width: 118px;
  padding-inline: 12px;
  white-space: nowrap;
}

.user-access-card .generate-password-button {
  color: var(--blue);
  background: var(--surface);
}

.user-access-card .reset-password-button {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

:root[data-theme="dark"] .user-card-list {
  background: color-mix(in srgb, var(--surface-soft) 78%, var(--bg));
}

:root[data-theme="dark"] .user-access-card .reset-password-button {
  color: #101722;
  border-color: var(--blue);
  background: var(--blue);
}

@media (max-width: 900px) {
  .user-card-list {
    grid-template-columns: 1fr;
  }

  .user-access-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .user-card-list {
    gap: 8px;
    max-height: none;
    padding: 8px;
    overflow: visible;
  }

  .user-card-list .user-access-card {
    gap: 11px;
    padding: 12px;
  }

  .user-access-grid,
  .user-access-card .order-role-picker,
  .password-reset-controls {
    grid-template-columns: 1fr;
  }

  .user-card-section-title,
  .password-reset-title {
    display: grid;
  }

  .user-card-section-title > span,
  .password-reset-title > small {
    text-align: left;
  }

  .user-access-card .password-reset-form button {
    width: 100%;
  }
}

/* Profile workspace: compact navigation and one focused section at a time. */
.profile-hero {
  min-height: 76px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.profile-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 17px;
}

.profile-hero-copy {
  min-width: 0;
}

.profile-hero-copy .mail-eyebrow {
  color: var(--blue);
  font-size: 11px;
}

.profile-hero-copy h1 {
  margin-top: 3px;
  font-size: 24px;
  letter-spacing: -.02em;
}

.profile-hero-copy p {
  font-size: 13px;
}

.profile-hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.profile-hero-badges span,
.profile-card-heading > span,
.profile-card-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.2;
}

.profile-settings-layout {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.profile-settings-content {
  min-width: 0;
}

.profile-tabs {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.profile-tabs button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 54px;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.settings-tabs button:hover:not(.active),
.profile-tabs button:hover:not(.active) {
  color: var(--text);
  background: var(--surface-soft);
}

.profile-tabs button.active {
  color: var(--blue);
  background: var(--blue-soft);
}

.profile-tab-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: color-mix(in srgb, currentColor 8%, transparent);
}

.profile-tab-icon svg {
  width: 15px;
  height: 15px;
}

.profile-tab-copy {
  display: grid;
  align-content: center;
  min-width: 0;
}

.profile-tab-copy b {
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tab-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-tabs button em {
  grid-column: 2;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 9px;
  font-style: normal;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-content-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 46px;
  gap: 12px;
  padding: 2px 2px 10px;
}

.profile-content-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  letter-spacing: -.01em;
}

.profile-content-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.profile-card-heading {
  min-height: 54px;
  gap: 12px;
  background: var(--surface);
}

.profile-card-heading > div {
  min-width: 0;
}

.profile-card-heading h2 {
  font-size: 14px;
}

.profile-card-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
}

.profile-card-status.success {
  color: #237a4b;
  border-color: color-mix(in srgb, #36a160 28%, var(--line));
  background: color-mix(in srgb, #36a160 10%, var(--surface));
}

.profile-card-status.warning {
  color: #9a6515;
  border-color: color-mix(in srgb, #e09e2f 34%, var(--line));
  background: color-mix(in srgb, #e09e2f 11%, var(--surface));
}

.profile-account-card {
  width: 100%;
}

.profile-account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.profile-account-grid > div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 15px 16px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.profile-account-grid > div:nth-child(odd) {
  border-left: 0;
}

.profile-account-grid span,
.profile-access-row > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.profile-account-grid strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 690;
}

.profile-access-block {
  display: grid;
  gap: 0;
  padding: 14px 16px 16px;
}

.profile-access-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 12px;
}

.profile-access-heading > div {
  display: grid;
  gap: 2px;
}

.profile-access-heading b {
  color: var(--text);
  font-size: 13px;
}

.profile-access-heading small {
  color: var(--muted);
  font-size: 10px;
}

.profile-access-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--blue);
  border-radius: 8px;
  background: var(--blue-soft);
}

.profile-access-icon svg {
  width: 16px;
  height: 16px;
}

:is(.profile-tab-icon, .profile-access-icon) svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-theme="dark"] .signature-editor:focus {
  border-color: var(--blue);
  box-shadow: var(--focus-ring);
}

.profile-access-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 45px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.profile-access-row > strong {
  color: var(--text);
  font-size: 13px;
}

.profile-role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-role-list b {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--line));
  border-radius: 7px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 10px;
  line-height: 1.25;
}

.profile-security-grid {
  display: grid;
  grid-template-columns: minmax(300px, .88fr) minmax(420px, 1.12fr);
  gap: 12px;
  align-items: start;
}

.profile-security-card {
  min-width: 0;
}

.profile-security-card .two-factor-profile,
.profile-security-card .profile-password-form {
  padding: 14px;
}

.profile-security-card .two-factor-status {
  padding: 12px;
  border-radius: 9px;
}

.profile-security-card .profile-password-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-security-card .profile-password-form > label:first-child,
.profile-security-card .profile-password-form > .settings-note,
.profile-security-card .profile-password-form > .primary-action {
  grid-column: 1 / -1;
}

.profile-security-card .profile-password-form input {
  min-height: 38px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.profile-security-card .profile-password-form .primary-action {
  min-width: 168px;
  min-height: 38px;
}

.profile-signature-card {
  width: 100%;
}

.profile-signature-card .profile-signature-form {
  grid-template-columns: 1fr;
  padding: 0 14px 14px;
}

.profile-signature-card .signature-toolbar {
  padding: 14px 0 0;
}

.profile-signature-card .signature-editor {
  min-height: 220px;
  background: var(--surface-soft);
}

:root[data-theme="dark"] .profile-card-status.success {
  color: #7be0a3;
}

:root[data-theme="dark"] .profile-card-status.warning {
  color: #f0bf6b;
}

@media (max-width: 1180px) {
  .profile-settings-layout {
    grid-template-columns: 1fr;
  }

  .profile-tabs {
    position: static;
    display: flex;
    gap: 3px;
    padding: 4px;
    overflow-x: auto;
  }

  .profile-tabs button {
    flex: 0 0 184px;
  }

  .profile-security-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .profile-hero {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 0;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 14px;
  }

  .profile-avatar {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .profile-hero-copy h1 {
    font-size: 21px;
  }

  .profile-hero-copy p {
    line-height: 1.35;
  }

  .profile-hero-badges {
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-left: 0;
  }

  .profile-tabs button {
    flex-basis: 164px;
    min-height: 50px;
  }

  .profile-tabs button em {
    display: none;
  }

  .profile-content-heading {
    min-height: 0;
    padding: 4px 2px 10px;
  }

  .profile-content-heading h2 {
    font-size: 17px;
  }

  .profile-card-heading {
    align-items: flex-start;
    min-height: 0;
    padding: 11px 12px;
  }

  .profile-account-grid,
  .profile-security-card .profile-password-form {
    grid-template-columns: 1fr;
  }

  .profile-account-grid > div {
    padding: 12px;
    border-left: 0;
  }

  .profile-access-block {
    padding: 12px;
  }

  .profile-access-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .profile-security-card .profile-password-form > * {
    grid-column: 1 !important;
  }

  .profile-security-card .profile-password-form .primary-action,
  .profile-signature-card .profile-password-form .primary-action {
    width: 100%;
  }

  .profile-signature-card .signature-toolbar {
    gap: 6px;
  }

  .profile-signature-card .signature-toolbar select:first-child {
    flex: 1 1 150px;
  }

  .profile-signature-card .signature-editor {
    min-height: 180px;
  }
}

/* Ticket detail must have a definite scroll container. A max-height alone lets
   the grid grow to its content height while the outer panel clips the action
   buttons below the viewport. */
@media (min-width: 1181px) {
  .content-grid.ticket-focus .detail-panel {
    height: calc(100dvh - 40px);
  }

  .content-grid.ticket-focus .detail-layout {
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow: hidden;
  }

  .content-grid.ticket-focus .detail-summary,
  .content-grid.ticket-focus .detail-stream {
    height: 100%;
    max-height: 100%;
  }

  .content-grid.ticket-focus .detail-summary {
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
}

@media (min-width: 761px) and (max-width: 1180px) {
  .content-grid.ticket-focus .detail-panel {
    height: calc(100dvh - 28px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .content-grid.ticket-focus .detail-layout {
    display: block;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .content-grid.ticket-focus .detail-summary {
    overflow: visible;
  }
}

/* IThub workspace: quiet surfaces, a clear channel switch, and optional secondary controls. */
.dashboard-workspace {
  display: grid;
  grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr);
  grid-template-areas: "activity online";
  align-items: start;
  gap: 16px;
}
.dashboard-activity { grid-area: activity; min-width: 0; }
.dashboard-activity .dashboard-layout { grid-template-columns: minmax(0, 1fr); }
.dashboard-activity .dashboard-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-activity .dashboard-kpi { min-width: 0; }
.dashboard-online-card { grid-area: online; }
.dashboard-online-card .dashboard-card-head { min-height: 62px; padding: 12px 16px; }
.dashboard-online-card .dashboard-card-head h2 { font-size: 18px; }
.dashboard-online-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.dashboard-online-controls select {
  width: min(100%, 290px);
  min-height: 36px;
  padding: 4px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
}
.dashboard-online-card .dashboard-online-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dashboard-online-card .dashboard-online-list { max-height: none; margin: 0; padding: 0; list-style: none; }
.dashboard-online-card .dashboard-online-row { min-height: 60px; padding: 10px 14px; }
.dashboard-online-card .dashboard-online-row :is(b, small) {
  overflow: visible;
  overflow-wrap: anywhere;
  white-space: normal;
}
.dashboard-online-card .dashboard-online-time { font-variant-numeric: tabular-nums; }
@media (max-width: 1080px) {
  .dashboard-workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "online" "activity"; }
}
@media (max-width: 480px) {
  .dashboard-workspace { gap: 12px; }
  .dashboard-activity .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-online-card .dashboard-online-summary span { padding-inline: 8px; }
  .dashboard-online-card .dashboard-online-row { padding-inline: 9px; }
}
.notification-sound-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 12px;
  padding: 5px 14px;
  border-bottom: 1px solid var(--line);
}
.notification-sound-controls .link-button { min-height: 32px; font-size: 12px; }
.notification-sound-controls .link-button:disabled { opacity: .55; cursor: default; }
:root {
  --bg: #f2f2f4;
  --surface: #fff;
  --surface-soft: #f6f5f8;
  --line: #e3e1e7;
  --line-strong: #d2ceda;
  --text: #171619;
  --ink: #171619;
  --muted: #5d5866;
  --muted-2: #6f6878;
  --blue: #791cc3;
  --blue-soft: #f4eafb;
  --accent-border: color-mix(in srgb, var(--blue) 40%, var(--line));
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent);
  --green: #126d43;
  --red: #b42342;
  --warning-ink: #89530e;
  --action: #8927d5;
}
:root[data-theme="dark"] {
  --bg: #131313;
  --surface: #1b1b1d;
  --surface-soft: #232225;
  --line: #343136;
  --line-strong: #4b464f;
  --text: #f4f1f6;
  --ink: #f4f1f6;
  --muted: #bdb6c4;
  --muted-2: #a9a2ae;
  --blue: #ce99fa;
  --blue-soft: #30223d;
  --action: #8835d0;
  --green: #5fce8d;
  --red: #ff6b7a;
  --warning-ink: #ffd37a;
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--blue) 24%, transparent);
}
.primary-action { color: #fff; background: var(--action); border-color: var(--action); box-shadow: none; }
.primary-action:hover { background: #7720bd; border-color: #7720bd; box-shadow: none; }
.queue-heading h1 { font-size: clamp(27px, 3vw, 36px); font-weight: 760; }
#sourceTabs {
  display: flex; width: 100%; gap: 10px; margin: 0; padding: 0 12px;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0;
  background: var(--surface);
}
#sourceTabs .source-tab {
  gap: 5px; min-height: 45px; padding-inline: 9px; border: 0;
  border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--muted); font-size: 14px; box-shadow: none;
}
#sourceTabs .source-tab .icon { display: none; }
#sourceTabs .source-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
#sourceTabs .source-tab.active b { color: var(--blue); background: var(--blue-soft); }
#ticketFilters { display: flex; flex-wrap: wrap; border-radius: 0 0 10px 10px; margin-bottom: 10px; }
#ticketFilters:not(.expanded) :is(.site-tabs, .sort-control, .reply-required-filter) { display: none; }
#ticketFilters .site-tabs { flex: 1 0 100%; padding: 3px 0 0; }
#ticketFilters .sort-control { margin-left: auto; }
#ticketFilters .filter-button { min-width: 0; }
#ticketFilters .search { display: flex; flex: 1 1 130px; min-width: 0; max-width: 430px; height: 36px; box-shadow: none; }
#ticketFilters .search input { display: block; min-width: 0; }
.attention-disclosure { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.attention-disclosure summary,
.report-breakdown summary,
.queue-events summary { cursor: pointer; padding: 10px 12px; width: fit-content; max-width: 100%; }
.queue-events summary { color: var(--muted); font-size: 13px; }
.queue-event-actions { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.attention-disclosure summary b { margin-left: 5px; color: var(--blue); }
.attention-disclosure .attention-panel { grid-template-columns: minmax(0, 1fr); }
.report-breakdown { margin-top: 10px; }
.report-breakdown summary { color: var(--blue); font-weight: 650; }
.report-channels { overflow: hidden; }
.report-channels table { width: 100%; border-collapse: collapse; background: var(--surface); text-align: left; }
.report-channels :is(th, td) { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.report-channels thead { background: var(--surface-soft); color: var(--muted); }
.report-channels tbody tr:last-child > * { border-bottom: 0; }
:root[data-theme="dark"] .detail-panel { background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow); }
:root[data-theme="dark"] .ticket-detail-backdrop { background: #09070bb0; }
:root[data-theme="dark"] .content-grid.ticket-focus .detail-stream { background: var(--bg); }
:root[data-theme="dark"] .sla-box { background: var(--surface-soft); }
@media (max-width: 760px) {
  #sourceTabs { gap: 4px; padding-inline: 8px; }
  #sourceTabs .source-tab { padding-inline: 8px; }
  #ticketFilters.expanded > select { flex: 1 1 110px; min-width: 0; }
  #ticketFilters.expanded .sort-control { margin-left: 0; }
  .report-channels :is(th, td) { padding: 8px 5px; font-size: 11px; }
  .reports-actions { flex-wrap: wrap; }
}

/* Compact, scoped layout for the existing reports, orders and admin views.
   This changes presentation only: no report, filter, setting or action is hidden. */
.reports-view .reports-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.reports-view .reports-grid > .report-card,
.reports-view .report-side-stack {
  grid-column: 1;
  grid-row: auto;
  min-width: 0;
}

.reports-view .report-side-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.reports-view .report-card,
.settings-view .settings-card {
  box-shadow: none;
}

.reports-view .report-card-head,
.settings-view .settings-card-head {
  background: var(--surface);
}

.reports-view .report-table {
  overflow-x: auto;
}

.reports-view .report-row {
  min-width: 560px;
}

/* Keep the budget, spend and remaining amount visible at once. */
.orders-view .order-budget-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}

.orders-view .order-budget-panel > div:not(.order-budget-progress) {
  min-height: 60px;
  padding: 8px 14px;
  gap: 2px;
  border-bottom: 0;
}

.orders-view .order-budget-panel b {
  font-size: 17px;
  overflow-wrap: anywhere;
}

.orders-view .order-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.orders-view .order-kpis > div {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.orders-view .order-kpis > div:first-child { border-left: 0; }
.orders-view .order-kpis b { font-size: 18px; }
.orders-view .order-filters { margin-bottom: 10px; }

/* Wide configuration forms get room to breathe without cutting off labels. */
@media (min-width: 981px) {
  .settings-view .settings-grid-directories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .settings-view .settings-grid-directories .order-sla-settings-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .orders-view .order-budget-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orders-view .order-budget-panel .order-budget-main { grid-column: 1 / -1; }
  .orders-view .order-budget-panel > div:not(.order-budget-progress) {
    min-height: 0;
    padding: 8px 12px;
  }
  .orders-view .order-budget-panel .order-budget-main { border-bottom: 1px solid var(--line); }
  .orders-view .order-budget-panel > div:nth-child(2) { border-left: 0; }
  .orders-view .order-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orders-view .order-kpis > div:nth-child(3) { border-left: 0; }
  .orders-view .order-kpis > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
