:root {
  --ink: #073b59;
  --muted: #5d7180;
  --line: #d6e5ec;
  --panel: #ffffff;
  --soft: #f2f8fb;
  --accent: #00496f;
  --accent-dark: #00344f;
  --brand-navy: #00496f;
  --brand-navy-deep: #003754;
  --brand-red: #c9342d;
  --brand-red-dark: #a92c27;
  --brand-cyan: #43afd6;
  --brand-cyan-soft: #dff4fb;
  --brand-cyan-pale: #eef9fc;
  --brand-grey: #e6e7e8;
  --danger: #c9342d;
  --blue: #1687b7;
  --shadow: 0 18px 50px rgba(0, 73, 111, 0.12);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(67, 175, 214, 0.1), rgba(230, 231, 232, 0.35) 34%, #f6fafc 100%);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.locked {
  display: none;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(67, 175, 214, 0.22), transparent 32%),
    linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-navy-deep) 56%, #06293c 100%);
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  display: grid;
  justify-items: center;
  width: min(440px, 100%);
  gap: 18px;
  padding: 34px;
  background: var(--panel);
  border: 1px solid rgba(67, 175, 214, 0.24);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 31, 48, 0.32);
  text-align: center;
}

.auth-logo {
  width: 96px;
  height: auto;
}

.auth-card p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-status {
  padding: 10px 12px;
  color: var(--brand-navy);
  background: var(--brand-cyan-pale);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-status.ready {
  color: #ffffff;
  background: var(--brand-navy);
}

.auth-actions {
  display: grid;
  width: 100%;
  gap: 10px;
}

.legal-warning {
  margin-top: 4px;
  padding-top: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  border-top: 1px solid var(--line);
  text-align: left;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  color: #eef8fb;
  background: linear-gradient(180deg, var(--brand-navy) 0%, var(--brand-navy-deep) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.brand:hover .brand-logo,
.brand:focus-visible .brand-logo {
  box-shadow: 0 0 0 3px rgba(67, 175, 214, 0.35), 0 10px 24px rgba(3, 38, 58, 0.2);
}

.brand-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  padding: 6px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(3, 38, 58, 0.2);
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: rgba(238, 248, 251, 0.74);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px;
  color: rgba(238, 247, 246, 0.8);
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: #ffffff;
  background: rgba(67, 175, 214, 0.18);
}

.icon,
.button-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  font-weight: 800;
  border-radius: 6px;
}

.nav-item .icon {
  background: rgba(67, 175, 214, 0.2);
}

.panel-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.alert-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 36px;
  max-height: 36px;
  padding: 5px 24px;
  overflow: hidden;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0, 73, 111, 0.04);
}

.alert-bar.has-alerts {
  background: #fff8f7;
  border-bottom-color: rgba(201, 52, 45, 0.24);
}

.alert-bar-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.alert-bar-head strong {
  color: var(--brand-navy);
}

.alert-bar-head span,
.alert-empty {
  color: var(--muted);
  font-size: 12px;
}

.alert-list {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-height: 26px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.alert-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  font-size: 12px;
  white-space: nowrap;
}

.alert-pill span {
  white-space: nowrap;
}

.alert-pill strong {
  color: var(--brand-navy);
}

.alert-pill.warning {
  color: #6d4c00;
  background: #fff7de;
  border-color: #ead08a;
}

.alert-pill.critical {
  color: var(--brand-red-dark);
  background: #fff0ee;
  border-color: rgba(201, 52, 45, 0.3);
}

.topbar,
.section-heading,
.toolbar,
.ticket-title-row,
.detail-actions,
.compose-actions,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 18px;
}

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

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

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

.primary-button,
.ghost-button,
.icon-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
}

.primary-button {
  color: white;
  background: var(--brand-red);
}

.primary-button:hover {
  background: var(--brand-red-dark);
}

.ghost-button {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.ghost-button:hover {
  background: var(--brand-cyan-pale);
}

.icon-button {
  width: 38px;
  background: var(--soft);
  border-color: var(--line);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  gap: 4px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  border-top: 3px solid var(--brand-cyan);
}

.metric:nth-child(2) {
  border-top-color: var(--brand-navy);
}

.metric:nth-child(3) {
  border-top-color: var(--brand-grey);
}

.metric.danger {
  border-top-color: var(--brand-red);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 24px;
}

.metric.danger strong {
  color: var(--danger);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(390px, 0.95fr) minmax(460px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.main-grid.helpdesk-grid {
  grid-template-columns: 1fr;
  gap: 14px;
}

.queue-column,
.ticket-detail,
.page-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.queue-column {
  overflow: hidden;
}

.ticket-command-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.select-all-control,
.ticket-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.select-all-control input,
.ticket-check input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--brand-cyan);
}

.sort-control,
.layout-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.sort-control button,
.sort-control select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.layout-control select {
  min-height: 34px;
  padding: 0 28px 0 8px;
  border-color: var(--brand-cyan);
  box-shadow: 0 0 0 2px rgba(67, 176, 217, 0.15);
}

.command-spacer {
  flex: 1;
}

.ticket-search {
  flex: 0 1 360px;
}

.compact-action {
  min-height: 38px;
}

.ticket-range {
  white-space: nowrap;
  color: var(--muted);
  font-weight: 700;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  min-width: 160px;
  padding: 0 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-wrap input {
  width: 100%;
  min-height: 36px;
  border: 0;
  outline: 0;
  background: transparent;
}

select {
  min-height: 38px;
  padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-list {
  display: grid;
  min-height: 520px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.ticket-card {
  display: grid;
  grid-template-columns: 34px 64px minmax(0, 1fr) minmax(180px, 230px);
  align-items: center;
  gap: 12px;
  min-height: 150px;
  padding: 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  text-align: left;
  cursor: pointer;
}

.ticket-card:hover,
.ticket-card.active {
  background: color-mix(in srgb, var(--brand-cyan-pale) 72%, var(--panel));
}

.ticket-card.active {
  box-shadow: inset 5px 0 0 var(--brand-red);
}

.ticket-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
  font-size: 18px;
}

.ticket-card.active .ticket-avatar {
  background: var(--brand-cyan-soft);
  color: var(--brand-navy);
  border-color: rgba(67, 176, 217, 0.35);
}

.ticket-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.ticket-subject-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.ticket-subject-line strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-subject-line span {
  color: var(--muted);
  font-weight: 700;
}

.ticket-signal {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.ticket-signal.responded {
  color: #005bd3;
  background: #dcedff;
}

.ticket-signal.risk {
  color: #c21d2f;
  background: #ffe1e7;
}

.ticket-side {
  display: grid;
  gap: 12px;
  color: var(--ink);
  font-size: 15px;
}

.ticket-side span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 3px;
  background: #98d36e;
}

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

.priority-dot.priority-critical {
  background: #7a241f;
}

.ticket-status-line::before {
  content: "⌁";
  color: var(--brand-cyan);
  font-weight: 800;
}

.assignment-button {
  justify-self: start;
  max-width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-navy);
  font: inherit;
  cursor: pointer;
}

.assignment-button[data-assign-ticket] {
  font-weight: 800;
}

.assignment-button[data-assign-ticket]:hover {
  color: var(--brand-red);
  text-decoration: underline;
}

.ticket-meta,
.ticket-tags,
.detail-meta,
.timeline-meta,
.admin-action {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-meta,
.detail-meta,
.timeline-meta {
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
}

.tag.priority-high,
.tag.sla-risk {
  color: #7a241f;
  background: #fbe3e1;
}

.tag.priority-critical {
  color: #ffffff;
  background: var(--brand-red);
}

.tag.status-new {
  color: var(--brand-navy);
  background: var(--brand-cyan-soft);
}

.tag.status-assigned {
  color: #ffffff;
  background: var(--brand-navy);
}

.tag.status-on-hold {
  color: var(--brand-navy);
  background: var(--brand-grey);
}

.tag.status-closed {
  color: #426170;
  background: #edf1f3;
}

.ticket-detail {
  min-height: 620px;
  padding: 18px;
}

.compact-detail {
  min-height: 0;
  margin: 14px;
}

.ticket-screen {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ticket-screen .ticket-detail {
  min-height: calc(100vh - 210px);
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.ticket-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-solid);
}

.detail-action-spacer {
  flex: 1;
}

.ticket-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: calc(100vh - 274px);
}

.ticket-message {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 16px;
  padding: 28px 30px 40px 14px;
  overflow: auto;
}

.message-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--panel);
  font-size: 12px;
  font-weight: 800;
}

.message-thread {
  display: grid;
  gap: 22px;
  align-content: start;
}

.ticket-open-header {
  display: grid;
  gap: 12px;
}

.ticket-open-header h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 25px;
  line-height: 1.15;
}

.sender-line {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  color: var(--muted);
}

.sender-line strong {
  color: #005bd3;
}

.sender-line span {
  margin-left: 6px;
}

.detail-avatar {
  width: 38px;
  height: 38px;
  background: #fff3a6;
  color: #9f9340;
}

.email-routing {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--brand-navy);
  font-size: 14px;
}

.open-email-body {
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.75;
}

.detail-compose,
.ticket-activity {
  max-width: 900px;
}

.ticket-properties {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px 18px 22px;
  border-left: 1px solid var(--line);
  background: var(--panel-solid);
}

.property-status {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

.property-title-row h3,
.properties-box h3,
.ticket-activity h3,
.detail-compose h3 {
  margin: 0;
  color: var(--brand-navy);
}

.property-status p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.sla-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 6px;
  border-radius: 5px;
  background: var(--brand-cyan-soft);
  color: var(--brand-navy);
  font-size: 11px;
  font-weight: 800;
}

.properties-box {
  display: grid;
  gap: 14px;
}

.properties-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.properties-box input,
.properties-box select {
  width: 100%;
  min-height: 38px;
}

.admin-wide-action {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
  text-align: left;
}

.helpdesk-filter-panel {
  position: sticky;
  top: 90px;
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.filter-panel-head strong {
  color: var(--brand-navy);
  text-transform: uppercase;
  letter-spacing: 0;
}

.filter-panel-head button {
  border: 0;
  background: transparent;
  color: #005bd3;
  font-weight: 800;
  cursor: pointer;
}

.filter-field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 750;
}

.filter-field.search-wrap {
  display: flex;
  min-height: 58px;
  padding: 0 14px;
  font-weight: 400;
  color: var(--muted);
}

.filter-field select {
  min-height: 56px;
  color: var(--ink);
  font-size: 15px;
}

.detail-header {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 16px;
  margin-top: 16px;
}

.message-panel,
.side-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.email-body,
.compose-box,
.timeline-item,
.admin-box {
  padding: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.email-body {
  white-space: pre-wrap;
  line-height: 1.5;
}

.compose-box textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compose-actions {
  justify-content: flex-start;
  margin-top: 8px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  gap: 6px;
}

.admin-box {
  display: grid;
  gap: 10px;
}

.admin-action {
  justify-content: space-between;
  padding: 9px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-action button {
  min-height: 30px;
  padding: 0 10px;
  color: white;
  background: var(--brand-navy);
  border: 0;
  border-radius: 7px;
}

.admin-action button:hover {
  background: var(--brand-red);
}

.page-panel {
  padding: 18px;
}

.rule-grid,
.integration-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.rule-item,
.integration {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.rule-item span,
.integration span {
  color: var(--muted);
}

.client-table {
  min-width: 1080px;
}

.domain-table.contacts-table td {
  vertical-align: top;
  line-height: 1.4;
}

.domain-table.contacts-table td:first-child {
  display: table-cell;
  gap: 0;
}

.domain-table.contacts-table td:nth-child(6) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.updates-table {
  min-width: 1080px;
}

.domain-table.updates-table td {
  vertical-align: top;
  line-height: 1.4;
}

.domain-table.updates-table td:first-child {
  display: table-cell;
  gap: 0;
}

.domain-table.updates-table td:nth-child(5) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.update-status-tag.update-status-requested {
  background: rgba(0, 73, 111, 0.1);
  color: var(--brand-navy);
}

.update-status-tag.update-status-in-progress {
  background: rgba(22, 163, 74, 0.12);
  color: #16703c;
}

.update-status-tag.update-status-completed {
  background: rgba(0, 158, 202, 0.14);
  color: #006d90;
}

.update-status-tag.update-status-closed {
  background: rgba(100, 116, 139, 0.16);
  color: #475569;
}

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

.opportunity-metric {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand-cyan);
  border-radius: 8px;
  background: var(--soft);
}

.opportunity-metric:nth-child(2) {
  border-top-color: var(--brand-navy);
}

.opportunity-metric:nth-child(3) {
  border-top-color: var(--brand-red);
}

.opportunity-metric:nth-child(4) {
  border-top-color: #16a34a;
}

.opportunity-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.opportunity-metric strong {
  display: block;
  margin-top: 8px;
  color: var(--brand-navy);
  font-size: 24px;
}

.opportunity-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
  gap: 14px;
  margin-top: 14px;
}

.opportunity-chart-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chart-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.chart-card-heading span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.pipeline-chart {
  display: grid;
  gap: 12px;
}

.pipeline-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.pipeline-label {
  display: grid;
  gap: 2px;
}

.pipeline-label strong {
  color: var(--brand-navy);
}

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

.pipeline-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 73, 111, 0.08);
}

.pipeline-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-cyan);
}

.pipeline-fill-lead {
  background: #64748b;
}

.pipeline-fill-qualified {
  background: var(--brand-cyan);
}

.pipeline-fill-proposal {
  background: var(--brand-navy);
}

.pipeline-fill-negotiation {
  background: var(--brand-red);
}

.pipeline-fill-won {
  background: #16a34a;
}

.pipeline-fill-lost {
  background: #94a3b8;
}

.forecast-chart {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.forecast-donut {
  position: relative;
  display: grid;
  width: 168px;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--forecast-gradient);
}

.forecast-donut::after {
  position: absolute;
  inset: 28px;
  content: "";
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.forecast-donut strong,
.forecast-donut span {
  position: relative;
  z-index: 1;
  display: block;
  text-align: center;
}

.forecast-donut strong {
  color: var(--brand-navy);
  font-size: 18px;
}

.forecast-donut span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.forecast-legend {
  display: grid;
  gap: 10px;
}

.forecast-legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.forecast-legend-item span {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

.forecast-legend-item strong {
  color: var(--text);
}

.forecast-legend-item em {
  color: var(--brand-navy);
  font-style: normal;
  font-weight: 800;
}

.opportunities-table {
  min-width: 1120px;
}

.domain-table.opportunities-table td {
  vertical-align: top;
  line-height: 1.4;
}

.domain-table.opportunities-table td:first-child {
  display: table-cell;
  gap: 0;
}

.domain-table.opportunities-table td:first-child span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.opportunity-stage-tag.opportunity-stage-lead {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

.opportunity-stage-tag.opportunity-stage-qualified {
  background: rgba(0, 158, 202, 0.14);
  color: #006d90;
}

.opportunity-stage-tag.opportunity-stage-proposal {
  background: rgba(0, 73, 111, 0.12);
  color: var(--brand-navy);
}

.opportunity-stage-tag.opportunity-stage-negotiation {
  background: rgba(201, 52, 45, 0.12);
  color: var(--brand-red-dark);
}

.opportunity-stage-tag.opportunity-stage-won {
  background: rgba(22, 163, 74, 0.12);
  color: #16703c;
}

.opportunity-stage-tag.opportunity-stage-lost {
  background: rgba(100, 116, 139, 0.18);
  color: #475569;
}

.opportunity-probability {
  display: grid;
  grid-template-columns: minmax(74px, 1fr) 42px;
  gap: 8px;
  align-items: center;
}

.opportunity-probability > span {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 73, 111, 0.1);
}

.opportunity-probability > span span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand-cyan);
}

.opportunity-probability strong {
  color: var(--brand-navy);
  font-size: 12px;
}

.client-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.client-search {
  max-width: 360px;
}

#clientSearchClearButton {
  min-width: 72px;
}

.search-clear-button {
  min-width: 72px;
  min-height: 40px;
  padding: 0 12px;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-navy);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.link-button:hover {
  color: var(--brand-red);
  text-decoration: underline;
}

.client-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.client-parent-label {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.client-actions-cell {
  width: 48px;
  text-align: right;
}

.client-actions-cell .icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
}

.client-status-tag.client-status-active {
  color: #0d5f3d;
  background: #dff6ec;
}

.client-status-tag.client-status-prospect {
  color: var(--brand-navy);
  background: var(--brand-cyan-soft);
}

.client-status-tag.client-status-lost {
  color: #7a241f;
  background: #fbe3e1;
}

.client-editor-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  margin-top: 18px;
}

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

.contact-form {
  margin-top: 18px;
}

.client-identity-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(96px, 0.55fr);
  gap: 10px;
}

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

.client-form input,
.client-form select,
.client-form textarea {
  width: 100%;
  padding: 10px;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.form-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-section h3 {
  color: var(--brand-navy);
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
}

.documents-section {
  align-content: stretch;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 320px;
  height: var(--documents-section-height, 360px);
  overflow: hidden;
}

.client-sites-section {
  align-content: start;
}

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

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

.documents-heading h3,
.sites-heading h3 {
  margin: 0;
}

.documents-heading .compact-button,
.sites-heading .compact-button {
  width: auto;
  min-height: 32px;
  padding: 0 12px;
}

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

.site-empty {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-solid);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.site-item {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(170px, 0.75fr);
  gap: 12px;
  align-items: stretch;
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.site-details {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.site-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.site-title-row strong {
  color: var(--brand-navy);
  font-size: 14px;
  line-height: 1.25;
}

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

.site-field {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.site-address {
  padding-bottom: 2px;
}

.site-notes {
  padding: 6px 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.site-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  text-transform: uppercase;
}

.site-field strong {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.site-edit-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 16px;
  color: var(--brand-navy);
  background: var(--soft);
  border-color: var(--line);
}

.site-map-panel {
  position: relative;
  min-height: 154px;
}

.site-map-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: flex;
  gap: 6px;
}

.site-map-zoom-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
  background: var(--panel-solid);
  border-color: var(--line);
  box-shadow: 0 6px 16px rgba(0, 73, 111, 0.12);
}

.site-map-frame {
  width: 100%;
  height: 100%;
  min-height: 154px;
  border: 0;
  border-radius: 8px;
  background: var(--soft);
}

.document-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.document-empty {
  padding: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-solid);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.document-description-link {
  color: var(--brand-navy);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.document-description-link:hover {
  color: var(--brand-red);
  text-decoration: underline;
}

.document-file-name {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.document-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.document-rename-button,
.document-remove-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
  background: var(--soft);
  border-color: var(--line);
}

.document-rename-button {
  color: var(--brand-navy);
}

.document-remove-button {
  color: var(--danger);
}

.services-grid {
  display: grid;
  grid-template-columns: 130px repeat(2, minmax(130px, 0.65fr)) minmax(220px, 1.2fr);
  gap: 14px;
  align-items: end;
}

.services-grid strong {
  align-self: center;
  color: var(--brand-navy);
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.client-side-panel {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 10px;
  align-self: start;
}

.client-map-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.client-map-card strong {
  color: var(--brand-navy);
}

.map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.map-controls {
  display: flex;
  gap: 6px;
}

.map-zoom-button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.client-map-card iframe {
  width: 100%;
  height: 184px;
  border: 0;
  border-radius: 8px;
  background: var(--soft);
}

.setup-list div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.setup-list strong {
  display: inline-grid;
  min-width: 28px;
  height: 28px;
  place-items: center;
  color: #ffffff;
  background: var(--brand-navy);
  border-radius: 8px;
}

.connected {
  border-left: 4px solid var(--brand-cyan);
}

.pending {
  border-left: 4px solid var(--brand-red);
}

.hidden {
  display: none !important;
}

.dialog-message {
  color: var(--muted);
  line-height: 1.45;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 52, 79, 0.56);
}

.dialog-content {
  display: grid;
  gap: 14px;
}

.dialog-content label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dialog-content input,
.dialog-content textarea {
  width: 100%;
  padding: 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  color: white;
  background: var(--brand-navy);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    padding: 12px;
  }

  .nav-list {
    display: flex;
    overflow: auto;
  }

  .main-grid,
  .content-grid,
  .client-editor-body,
  .client-form,
  .contact-grid,
  .services-grid {
    grid-template-columns: 1fr;
  }

  .client-side-panel {
    position: static;
  }

  .site-item {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .ticket-list {
    max-height: 360px;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 14px;
  }

  .topbar,
  .toolbar,
  .ticket-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .rule-grid,
  .integration-grid {
    grid-template-columns: 1fr 1fr;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .client-identity-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .metrics,
  .rule-grid,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .brand span,
  .nav-item span:last-child {
    display: none;
  }
}

/* Visual refresh */
:root {
  --page-bg:
    radial-gradient(circle at 12% 8%, rgba(67, 175, 214, 0.18), transparent 28%),
    linear-gradient(180deg, #f7fbfd 0%, #eef6fa 42%, #f8fafb 100%);
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --soft: #eef8fc;
  --surface-raised: #ffffff;
  --line: rgba(0, 73, 111, 0.14);
  --muted: #607888;
  --shadow: 0 18px 54px rgba(0, 73, 111, 0.14);
  --shadow-soft: 0 10px 28px rgba(0, 73, 111, 0.1);
}

:root[data-theme="dark"] {
  --ink: #e9f6fb;
  --muted: #98b6c5;
  --line: rgba(129, 207, 236, 0.18);
  --panel: rgba(7, 32, 47, 0.88);
  --panel-solid: #092b40;
  --soft: rgba(67, 175, 214, 0.1);
  --surface-raised: #0d354d;
  --brand-cyan-pale: rgba(67, 175, 214, 0.16);
  --brand-cyan-soft: rgba(67, 175, 214, 0.24);
  --brand-grey: #263e4c;
  --page-bg:
    radial-gradient(circle at 14% 4%, rgba(67, 175, 214, 0.26), transparent 30%),
    linear-gradient(180deg, #041b29 0%, #071f2f 44%, #061722 100%);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.26);
}

body {
  color: var(--ink);
  font-family: Aptos, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  background: var(--page-bg);
  letter-spacing: 0;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.auth-gate {
  background:
    radial-gradient(circle at 12% 10%, rgba(67, 175, 214, 0.28), transparent 34%),
    radial-gradient(circle at 84% 82%, rgba(201, 52, 45, 0.18), transparent 28%),
    linear-gradient(135deg, var(--brand-navy) 0%, #052f48 52%, #061722 100%);
}

.auth-card,
.queue-column,
.ticket-detail,
.page-panel,
.metric {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(440px, 100%);
  padding: 34px;
  gap: 18px;
}

.auth-logo {
  width: 96px;
}

h1 {
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
  font-weight: 760;
}

h3 {
  font-size: 16px;
  font-weight: 760;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 12px 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(67, 175, 214, 0.22), transparent 32%),
    linear-gradient(90deg, var(--brand-navy) 0%, #032f49 58%, #031e2f 100%);
  box-shadow: 0 12px 34px rgba(0, 52, 79, 0.2);
}

.brand {
  gap: 14px;
  padding: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  box-shadow: 0 12px 30px rgba(0, 18, 28, 0.24);
}

.brand strong {
  max-width: none;
  font-size: 16px;
  line-height: 1.15;
  white-space: nowrap;
}

.nav-list {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.nav-item {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}

.nav-item.active {
  background: rgba(67, 175, 214, 0.22);
  border-color: rgba(67, 175, 214, 0.32);
  box-shadow: inset 0 -3px 0 var(--brand-red);
}

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

.bar-icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  color: #ffffff;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(238, 248, 251, 0.24);
  border-radius: 8px;
  box-shadow: none;
}

.bar-icon-button:hover,
.bar-icon-button:focus-visible {
  background: rgba(67, 175, 214, 0.28);
  border-color: rgba(238, 248, 251, 0.44);
  transform: translateY(-1px);
}

.bar-icon-button[aria-pressed="true"] {
  color: #042235;
  background: var(--brand-cyan);
  border-color: rgba(238, 248, 251, 0.5);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon,
.button-icon {
  border-radius: 8px;
}

.workspace {
  padding: 24px 30px 30px;
}

.alert-bar {
  padding: 5px 30px;
  background: var(--panel-solid);
}

:root[data-theme="dark"] .alert-bar.has-alerts {
  background: rgba(201, 52, 45, 0.14);
  border-bottom-color: rgba(201, 52, 45, 0.34);
}

:root[data-theme="dark"] .alert-pill.warning {
  color: #ffe8ad;
  background: rgba(234, 184, 72, 0.14);
  border-color: rgba(234, 184, 72, 0.32);
}

:root[data-theme="dark"] .alert-pill.critical {
  color: #ffd6d2;
  background: rgba(201, 52, 45, 0.2);
  border-color: rgba(201, 52, 45, 0.38);
}

.topbar {
  align-items: flex-start;
  padding: 4px 2px 2px;
  margin-bottom: 22px;
}

.topbar p {
  font-size: 15px;
}

.topbar-actions {
  align-items: center;
}

.primary-button,
.ghost-button,
.icon-button,
.theme-switch,
.admin-action button,
.demo-access button {
  min-height: 40px;
  border-radius: 8px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  box-shadow: 0 10px 24px rgba(201, 52, 45, 0.24);
}

.primary-button:hover,
.ghost-button:hover,
.theme-switch:hover,
.admin-action button:hover,
.demo-access button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.theme-switch,
select,
.search-wrap {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  font-weight: 750;
}

.theme-switch.compact {
  min-width: 132px;
}

.theme-track {
  position: relative;
  width: 40px;
  height: 22px;
  padding: 3px;
  background: var(--brand-grey);
  border-radius: 999px;
}

.theme-knob {
  display: block;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 31, 48, 0.24);
  transition: transform 160ms ease, background 160ms ease;
}

.theme-switch[aria-pressed="true"] .theme-track {
  background: var(--brand-cyan);
}

.theme-switch[aria-pressed="true"] .theme-knob {
  transform: translateX(18px);
  background: var(--brand-navy);
}

.metrics {
  gap: 12px;
  margin-bottom: 16px;
}

.connectivity-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.compact-metric {
  min-height: 78px;
}

.section-subtitle {
  margin-top: 4px;
  color: var(--muted);
}

.connectivity-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  margin-top: 18px;
}

.connector-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.domain-table-wrap {
  margin-top: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.domain-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.service-table {
  min-width: 980px;
}

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

.domain-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--soft);
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-header span {
  display: inline-flex;
  width: 12px;
  color: var(--brand-cyan);
  font-size: 13px;
  line-height: 1;
}

.sort-header.active {
  color: var(--brand-navy);
}

[data-theme="dark"] .sort-header.active {
  color: var(--text);
}

.domain-table td:first-child {
  display: grid;
  gap: 4px;
}

.domain-table td:first-child span {
  color: var(--muted);
  font-size: 12px;
}

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

.metric {
  position: relative;
  overflow: hidden;
  min-height: 78px;
  padding: 12px 16px 12px 18px;
  border-top: 0;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--brand-cyan);
}

.metric:nth-child(2)::before {
  background: var(--brand-navy);
}

.metric:nth-child(3)::before {
  background: var(--brand-grey);
}

.metric.danger::before {
  background: var(--brand-red);
}

.metric strong {
  font-size: 26px;
  font-weight: 800;
}

.main-grid:not(.helpdesk-grid) {
  grid-template-columns: minmax(430px, 0.95fr) minmax(520px, 1.05fr);
  gap: 20px;
}

.toolbar {
  padding: 14px;
}

.main-grid:not(.helpdesk-grid) .ticket-list {
  max-height: calc(100vh - 160px);
}

.ticket-card {
  transition: background 140ms ease, box-shadow 140ms ease;
}

.ticket-card.active {
  box-shadow: inset 5px 0 0 var(--brand-red);
}

.main-grid:not(.helpdesk-grid) .ticket-card strong {
  font-size: 15px;
}

.ticket-detail {
  padding: 22px;
}

.detail-header {
  gap: 16px;
}

.content-grid {
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

.email-body,
.compose-box,
.timeline-item,
.admin-box,
.rule-item,
.integration,
.admin-action {
  background: var(--soft);
  border-color: var(--line);
  border-radius: 8px;
}

.email-body,
.timeline-item {
  line-height: 1.6;
}

.tag {
  border: 1px solid rgba(0, 73, 111, 0.08);
}

:root[data-theme="dark"] .tag {
  border-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .tag.status-assigned,
:root[data-theme="dark"] .setup-list strong {
  background: var(--brand-cyan);
  color: #042235;
}

:root[data-theme="dark"] .tag.status-closed {
  color: #b8cbd5;
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .tag.priority-high,
:root[data-theme="dark"] .tag.sla-risk {
  color: #ffd6d2;
  background: rgba(201, 52, 45, 0.22);
}

.tag.service-broadband {
  color: var(--brand-navy);
  background: var(--brand-cyan-pale);
}

.tag.service-leased {
  color: #ffffff;
  background: var(--brand-navy);
}

.dialog-content input,
.dialog-content textarea,
.compose-box textarea {
  background: var(--panel-solid);
  color: var(--ink);
  border-color: var(--line);
}

.toast {
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    box-shadow: 0 12px 30px rgba(0, 52, 79, 0.18);
    min-width: 0;
  }

  .brand strong {
    max-width: none;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .ticket-workspace {
    grid-template-columns: 1fr;
  }

  .ticket-properties {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .ticket-message {
    grid-template-columns: 36px minmax(0, 1fr);
    padding-right: 18px;
  }

  .opportunity-metrics {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .opportunity-dashboard,
  .forecast-chart {
    grid-template-columns: 1fr;
  }

  .forecast-donut {
    margin: 0 auto;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .workspace,
  .alert-bar,
  .main-grid,
  .queue-column,
  .ticket-detail,
  .page-panel,
  .topbar,
  .topbar-actions {
    max-width: 100%;
    overflow-x: hidden;
  }

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

  .nav-list {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }

  .sidebar-actions {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .brand strong {
    font-size: 16px;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .alert-bar {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    height: 36px;
    max-height: 36px;
    padding: 5px 16px;
  }

  .alert-bar-head {
    justify-content: flex-start;
  }

  .connectivity-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .connector-status {
    margin-left: 0;
    white-space: normal;
  }

  .connectivity-metrics {
    grid-template-columns: 1fr;
  }

  .opportunity-metrics {
    grid-template-columns: 1fr;
  }

  .pipeline-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .theme-switch.compact {
    width: 100%;
  }
}
