:root {
  --mci-blaze-orange: #ff6600;
  --mci-orange-dark: #e55a00;
  --mci-dark-navy: #002060;
  --mci-bpoaas-blue: #2f70d9;
  --mci-white: #fff;
  --mci-gray-800: #333;
  --mci-gray-200: #eee;
  --mci-font-family: "Quicksand", Calibri, Arial, sans-serif;
  --mci-orange-pale: #fff0e6;
}

[data-theme="dark"] {
  --color-bg: #00133d;
  --color-panel: rgba(0, 27, 82, 0.96);
  --color-panel-alt: #08255f;
  --color-shell: #000f30;
  --color-text: #fff;
  --color-muted: #c7d3ec;
  --color-border: #214682;
  --color-input: rgba(255, 255, 255, 0.08);
  --color-select-option-bg: #001b52;
  --color-select-option-text: #fff;
  --color-overlay: rgba(0, 9, 28, 0.82);
  --shadow-panel: 0 1rem 2.4rem rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
  --color-bg: #f6f8fb;
  --color-panel: rgba(255, 255, 255, 0.97);
  --color-panel-alt: #f9fafc;
  --color-shell: #002060;
  --color-text: #333;
  --color-muted: #5c6675;
  --color-border: #d9e0ea;
  --color-input: #fff;
  --color-select-option-bg: #fff;
  --color-select-option-text: #333;
  --color-overlay: rgba(9, 23, 54, 0.45);
  --shadow-panel: 0 0.9rem 2.2rem rgba(0, 32, 96, 0.1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--mci-font-family);
  font-size: 14px;
  color: var(--color-text);
  background:
    radial-gradient(circle at top left, rgba(255, 102, 0, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(0, 32, 96, 0.05), rgba(0, 32, 96, 0)),
    var(--color-bg);
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
select option { color: var(--color-select-option-text); background-color: var(--color-select-option-bg); }
textarea { resize: vertical; }

.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;
}

.app-frame {
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(255, 102, 0, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(0, 32, 96, 0.05), rgba(0, 32, 96, 0)),
    var(--color-bg);
}

.app-shell-header {
  min-height: 76px;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-shell);
  color: var(--mci-white);
  border-bottom: 3px solid var(--mci-blaze-orange);
}

.brand-lockup {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  text-decoration: none;
  line-height: 1;
}

.brand-wordmark {
  font-size: clamp(1.35rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-mci { color: var(--mci-blaze-orange); }

.app-title {
  font-size: clamp(1rem, 2vw, 1.5rem);
  font-weight: 600;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.account-actions form { margin: 0; }

.account-summary {
  display: grid;
  gap: 0.2rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.04);
}

.account-caption {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-name-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.account-name {
  font-weight: 700;
  white-space: nowrap;
}

.account-settings-link {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}

.account-settings-link:hover,
.account-settings-link:focus {
  color: var(--mci-white);
}

.account-signout {
  min-height: 2.55rem;
  padding: 0.65rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.7rem;
  color: var(--mci-white);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
}

.account-signout:hover,
.account-signout:focus {
  border-color: var(--mci-blaze-orange);
  background: rgba(255, 102, 0, 0.14);
}

.app-shell-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100dvh - 76px);
}

.app-sidebar {
  padding: 1rem 0.7rem;
  background: var(--color-panel-alt);
  border-right: 1px solid var(--color-border);
}

.app-nav {
  display: grid;
  gap: 0.32rem;
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.76rem 0.85rem;
  border-radius: 0.55rem;
  color: var(--color-muted);
  text-decoration: none;
  font-weight: 700;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-nav a:hover,
.app-nav a:focus,
.app-nav a.active {
  color: var(--mci-white);
  background: var(--color-shell);
  box-shadow: inset 3px 0 0 var(--mci-blaze-orange);
}

.nav-link-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  fill: currentColor;
}

.nav-section-label,
.metric-label {
  color: var(--mci-blaze-orange);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-section-label { margin: 1.25rem 0.85rem 0.35rem; }

.app-content {
  min-width: 0;
  padding: clamp(1rem, 3vw, 2rem);
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.compact-heading { align-items: center; }

.page-heading h1 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.page-heading p {
  margin: 0.35rem 0 0;
  max-width: 680px;
  color: var(--color-muted);
}

.conversation-page-heading h1 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
}

:where(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus,
:where(h1, h2, h3, h4, h5, h6)[tabindex="-1"]:focus-visible {
  outline: none;
  box-shadow: none;
}

.status-copy {
  max-width: 360px;
  color: var(--mci-blaze-orange);
  font-weight: 700;
  text-align: right;
}

.btn {
  min-height: 2.65rem;
  padding: 0.62rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  font-weight: 700;
}

.btn-primary {
  color: #fff;
  background: var(--mci-blaze-orange);
  border-color: var(--mci-blaze-orange);
}

.btn-primary:hover,
.btn-primary:focus {
  color: #fff;
  background: var(--mci-orange-dark);
  border-color: var(--mci-orange-dark);
}

.btn-secondary {
  color: var(--color-text);
  background: transparent;
  border-color: var(--color-border);
}

.btn-secondary:hover,
.btn-secondary:focus {
  border-color: var(--mci-blaze-orange);
  color: var(--mci-blaze-orange);
}

.btn-small {
  min-height: 2.2rem;
  padding: 0.45rem 0.72rem;
  font-size: 0.82rem;
}

.loading-panel,
.empty-state {
  padding: 1rem;
  border: 1px dashed var(--color-border);
  border-radius: 0.55rem;
  color: var(--color-muted);
  text-align: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card,
.panel {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 0.7rem;
  box-shadow: var(--shadow-panel);
}

.metric-card {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
}

.metric-card strong {
  color: var(--mci-blaze-orange);
  font-size: 2.1rem;
  line-height: 1;
}

.metric-card > span:last-child {
  color: var(--color-muted);
  font-size: 0.8rem;
}

.panel { overflow: hidden; }

.panel-heading {
  min-height: 52px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--color-shell);
  color: var(--mci-white);
  border-bottom: 3px solid var(--mci-blaze-orange);
}

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.panel-heading span {
  color: var(--color-muted);
  font-size: 0.78rem;
}

.panel-body { padding: 1rem; }

.conversation-unavailable {
  max-width: 620px;
}

.conversation-unavailable .panel-body {
  display: grid;
  justify-items: start;
  gap: 1rem;
}

.conversation-unavailable p {
  margin: 0;
  color: var(--color-muted);
}

.trend-chart {
  height: 220px;
  padding: 1.5rem 1.3rem 0.8rem;
  display: grid;
  grid-template-columns: repeat(7, minmax(40px, 1fr));
  align-items: end;
  gap: 1rem;
}

.trend-column {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0.4rem;
  text-align: center;
  color: var(--color-muted);
  font-weight: 700;
}

.trend-bars {
  min-height: 1px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 0.22rem;
  border-bottom: 1px solid var(--color-border);
}

.trend-bar {
  width: 15px;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
}

.trend-bar.sent,
.key-sent { background: var(--mci-blaze-orange); }
.trend-bar.received,
.key-received { background: var(--mci-bpoaas-blue); }

.chart-key {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0 1.2rem 1rem;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.chart-key i {
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.3rem;
  border-radius: 50%;
}

.filter-control input,
input,
select,
textarea {
  width: 100%;
  padding: 0.62rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-text);
  background: var(--color-input);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--mci-blaze-orange);
  box-shadow: 0 0 0 0.18rem rgba(255, 102, 0, 0.18);
}

.form-stack {
  display: grid;
  gap: 0.95rem;
}

.form-stack label {
  display: block;
  margin-bottom: 0.28rem;
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.form-stack small {
  display: block;
  margin-top: 0.35rem;
  color: var(--color-muted);
  line-height: 1.45;
}

.segmented-control {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
}

.segmented-control button {
  flex: 1;
  padding: 0.62rem;
  border: 0;
  border-right: 1px solid var(--color-border);
  color: var(--color-muted);
  background: transparent;
  font-weight: 700;
}

.segmented-control button:last-child { border-right: 0; }

.segmented-control button.active {
  color: #fff;
  background: var(--mci-blaze-orange);
}

.segmented-control button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.character-counter {
  color: var(--color-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.conversation-workspace {
  display: grid;
  grid-template-columns: minmax(270px, 0.92fr) minmax(380px, 1.6fr) minmax(290px, 0.95fr);
  gap: 1rem;
  min-height: 680px;
}

.conversation-list,
.message-thread,
.composer {
  min-height: 0;
}

.filter-control {
  padding: 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.filter-control label { display: none; }

.conversation-filter-stack {
  display: grid;
  gap: 0.8rem;
}

.input-with-icon {
  position: relative;
}

.field-icon {
  position: absolute;
  top: 50%;
  left: 0.82rem;
  width: 1rem;
  height: 1rem;
  color: var(--color-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.field-icon svg,
.new-thread svg,
.thread-item-edit svg,
.thread-action svg,
.thread-send-button svg,
.send-button svg,
.pager-button svg,
.thread-reply-icon svg,
.media-viewer-close svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.input-with-icon input { padding-left: 2.45rem; }

.conversation-read-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.conversation-read-filters button {
  min-height: 2.3rem;
  padding: 0.45rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-text);
  background: transparent;
  font-weight: 700;
}

.conversation-read-filters button.active {
  color: #fff;
  background: var(--mci-bpoaas-blue);
  border-color: var(--mci-bpoaas-blue);
}

.count-pill,
.unread-pill {
  min-width: 1.55rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  color: #fff;
  background: var(--mci-bpoaas-blue);
  font-size: 0.72rem;
  line-height: 1.2;
  text-align: center;
  font-weight: 700;
}

.conversation-read-filters button.active .count-pill {
  color: var(--mci-bpoaas-blue);
  background: #fff;
}

.new-thread {
  width: calc(100% - 1.2rem);
  margin: 0.65rem 0.6rem;
  padding: 0.72rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid var(--mci-blaze-orange);
  border-radius: 0.55rem;
  color: var(--mci-blaze-orange);
  background: transparent;
  font-weight: 700;
}

.new-thread svg { width: 1rem; height: 1rem; }

.thread-list {
  display: grid;
  max-height: 520px;
  overflow: auto;
}

.thread-item-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: start;
  padding: 0.95rem;
  border-bottom: 1px solid var(--color-border);
}

.thread-item-shell.unread { background: rgba(47, 112, 217, 0.08); }
[data-theme="dark"] .thread-item-shell.unread { background: rgba(47, 112, 217, 0.15); }

.thread-item-shell.selected {
  background: var(--mci-orange-pale);
  color: #333;
  box-shadow: inset 3px 0 0 var(--mci-blaze-orange);
}

[data-theme="dark"] .thread-item-shell.selected {
  background: #102d60;
  color: #fff;
}

[data-theme="dark"] .thread-item-shell.selected .thread-item-main,
[data-theme="dark"] .thread-item-shell.selected .thread-item-edit,
[data-theme="dark"] .thread-item-shell.selected .thread-item-save,
[data-theme="dark"] .thread-item-shell.selected .thread-item-cancel {
  color: #fff;
}

[data-theme="dark"] .thread-item-shell.selected .thread-item-time,
[data-theme="dark"] .thread-item-shell.selected .thread-item-phone,
[data-theme="dark"] .thread-item-shell.selected .thread-item-subline,
[data-theme="dark"] .thread-item-shell.selected .thread-item-main small {
  color: #d9e4f7;
}

.thread-item-main {
  width: 100%;
  padding: 0;
  display: grid;
  gap: 0.28rem;
  border: 0;
  color: var(--color-text);
  background: transparent;
  text-align: left;
}

.thread-item-header,
.thread-item-identity,
.thread-item-subline,
.conversation-pager,
.conversation-pager-actions,
.thread-heading-actions,
.thread-action,
.thread-reply-actions,
.thread-reply-field,
.message-meta,
.attachment-prep-title-row,
.attachment-prep-actions {
  display: flex;
  align-items: center;
}

.thread-item-header {
  justify-content: space-between;
  gap: 0.75rem;
}

.thread-item-identity {
  gap: 0.45rem;
  min-width: 0;
}

.thread-item-identity strong,
.thread-item-phone,
.thread-item-main small,
.thread-heading-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-item-time,
.thread-item-phone,
.thread-item-main small,
.thread-item-subline,
.conversation-pager,
.message-meta,
.message-date-divider span,
.thread-heading-meta,
.attachment-prep-details {
  color: var(--color-muted);
  font-size: 0.76rem;
}

.thread-item-subline { gap: 0.42rem; }

.thread-item-dot {
  width: 0.22rem;
  height: 0.22rem;
  border-radius: 50%;
  background: currentColor;
}

.thread-item-edit,
.pager-button,
.thread-action {
  border: 1px solid var(--color-border);
  border-radius: 0.55rem;
  color: var(--color-text);
  background: transparent;
  font-weight: 700;
}

.thread-item-edit {
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thread-item-edit:hover,
.thread-item-edit:focus,
.pager-button:hover,
.pager-button:focus,
.thread-action:hover,
.thread-action:focus {
  color: var(--mci-blaze-orange);
  border-color: var(--mci-blaze-orange);
}

.thread-item-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.45rem;
}

.thread-item-editor-actions {
  display: flex;
  gap: 0.45rem;
}

.thread-item-save,
.thread-item-cancel {
  padding: 0.42rem 0.68rem;
  border: 1px solid var(--color-border);
  border-radius: 0.45rem;
  color: var(--color-text);
  background: transparent;
  font-weight: 700;
}

.thread-item-save {
  color: #fff;
  background: var(--mci-blaze-orange);
  border-color: var(--mci-blaze-orange);
}

.thread-item-save:disabled,
.pager-button:disabled,
.thread-send-button:disabled,
.send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.thread-item-cancel:hover,
.thread-item-cancel:focus {
  color: var(--mci-blaze-orange);
  border-color: var(--mci-blaze-orange);
}

.conversation-pager {
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem 0.95rem;
  border-top: 1px solid var(--color-border);
  font-weight: 600;
}

.conversation-pager-actions { gap: 0.45rem; }

.pager-button {
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pager-button svg { width: 1rem; height: 1rem; }

.thread-heading {
  min-height: 72px;
  align-items: flex-start;
}

.thread-heading-copy {
  display: grid;
  gap: 0.16rem;
}

.thread-heading-actions {
  margin-left: auto;
  gap: 0.7rem;
}

.thread-action {
  gap: 0.45rem;
  padding: 0.48rem 0.8rem;
}

.thread-action svg,
.thread-send-button svg,
.send-button svg { width: 0.95rem; height: 0.95rem; }

.thread-panel-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: calc(100% - 72px);
}

.thread-body {
  max-height: 565px;
  overflow: auto;
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.message-date-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--color-muted);
}

.message-date-divider::before,
.message-date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.message-date-divider span {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--color-panel-alt);
  font-weight: 700;
}

.message-row { display: flex; }
.message-row.outbound { justify-content: flex-end; }

.message-bubble {
  max-width: 82%;
  padding: 0.92rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.95rem;
  background: var(--color-panel-alt);
  box-shadow: 0 0.3rem 0.85rem rgba(0, 0, 0, 0.08);
}

.message-bubble.outbound {
  border-color: var(--mci-blaze-orange);
  background: var(--mci-orange-pale);
}

[data-theme="dark"] .message-bubble.outbound {
  background: rgba(255, 102, 0, 0.12);
}

.message-bubble p {
  margin: 0.45rem 0 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.message-meta {
  flex-wrap: wrap;
  gap: 0.55rem;
}

.message-direction {
  color: var(--color-text);
  font-weight: 700;
}

.message-status.pending { color: var(--mci-bpoaas-blue); font-weight: 700; }
.message-status.failed,
.delivery-failure { color: var(--mci-blaze-orange); font-weight: 700; }
.message-status.suppressed { color: var(--mci-blaze-orange); }
.message-status.delivered,
.message-status.inbound { color: var(--color-muted); }

.delivery-failure {
  margin-top: 0.55rem;
  font-size: 0.78rem;
}

.message-media {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.message-attachment {
  padding: 0.38rem 0.62rem;
  border: 1px solid rgba(255, 102, 0, 0.45);
  border-radius: 999px;
  color: var(--mci-blaze-orange);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 700;
}

.message-attachment:hover,
.message-attachment:focus {
  background: rgba(255, 102, 0, 0.1);
}

.thread-reply-bar {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.95rem 1rem 1rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-panel);
}

.thread-reply-bar.disabled { opacity: 0.82; }

.thread-reply-field {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 0.4rem;
}

.thread-reply-icon {
  position: absolute;
  top: 0.9rem;
  left: 0.8rem;
  width: 1rem;
  height: 1rem;
  color: var(--color-muted);
}

.thread-reply-field textarea {
  width: 100%;
  min-height: 3.35rem;
  padding: 0.88rem 3.35rem 0.88rem 2.5rem;
  border-radius: 0.72rem;
  line-height: 1.45;
  resize: none;
}

.message-body-editor {
  position: relative;
}

.emoji-picker {
  position: absolute;
  right: 0.55rem;
  bottom: 0.55rem;
  z-index: 2;
}

.thread-reply-field .emoji-picker {
  bottom: 1.9rem;
}

.emoji-picker-trigger {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  color: var(--color-muted);
  background: var(--color-panel);
  font-size: 1rem;
  line-height: 1;
}

.emoji-picker-trigger:hover,
.emoji-picker-trigger:focus,
.emoji-picker-trigger[aria-expanded="true"] {
  border-color: var(--mci-blaze-orange);
  color: var(--mci-blaze-orange);
  box-shadow: 0 0 0 0.18rem rgba(255, 102, 0, 0.18);
}

.emoji-picker-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.emoji-picker-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.45rem);
  width: min(19rem, calc(100vw - 2rem));
  padding: 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 0.7rem;
  color: var(--color-text);
  background: var(--color-panel-alt);
  box-shadow: var(--shadow-panel);
}

.emoji-picker-group + .emoji-picker-group {
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--color-border);
}

.emoji-picker-group-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.25rem;
}

.emoji-picker-option {
  min-width: 0;
  min-height: 2rem;
  padding: 0.2rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
  background: transparent;
  font-size: 1.05rem;
  line-height: 1;
}

.emoji-picker-option:hover,
.emoji-picker-option:focus {
  border-color: var(--mci-blaze-orange);
  background: rgba(255, 102, 0, 0.12);
  outline: none;
}

.thread-reply-metrics {
  padding-left: 0.2rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.thread-reply-actions {
  flex-shrink: 0;
  gap: 0.75rem;
  align-items: stretch;
}

.thread-send-button,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.thread-send-button {
  min-height: 3.35rem;
  padding: 0.72rem 1.18rem;
  border-radius: 0.72rem;
  gap: 0.55rem;
  white-space: nowrap;
  line-height: 1;
  box-shadow: 0 0.55rem 1.2rem rgba(255, 102, 0, 0.18);
}

.thread-send-button-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thread-send-button-icon svg {
  display: block;
}

.thread-send-button-label {
  display: block;
  line-height: 1;
}

.composer { align-self: start; }

.composer-body { padding: 1rem 1rem 1.15rem; }

.composer textarea { min-height: 9rem; }

.send-button { width: 100%; }

.attachment-prep-card {
  margin-top: 0.8rem;
  padding: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: 0.7rem;
  display: grid;
  gap: 0.75rem;
  background: var(--color-panel-alt);
}

.attachment-state-ready { box-shadow: inset 3px 0 0 var(--mci-bpoaas-blue); }
.attachment-state-advisory { box-shadow: inset 3px 0 0 #ffb347; }
.attachment-state-actionrequired { box-shadow: inset 3px 0 0 var(--mci-blaze-orange); }

.attachment-prep-copy p {
  margin: 0.45rem 0 0;
  color: var(--color-text);
  line-height: 1.5;
}

.attachment-prep-title-row {
  justify-content: space-between;
  gap: 0.7rem;
}

.attachment-prep-title-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-prep-badge {
  padding: 0.18rem 0.52rem;
  border-radius: 999px;
  background: rgba(47, 112, 217, 0.15);
  color: var(--color-text);
  font-size: 0.72rem;
  font-weight: 700;
}

.attachment-prep-actions {
  flex-wrap: wrap;
  gap: 0.55rem;
}

.attachment-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.7rem;
}

.attachment-list span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  background: var(--color-panel-alt);
  font-size: 0.8rem;
}

.attachment-list em {
  font-style: normal;
  color: var(--color-muted);
}

.attachment-list button {
  border: 0;
  color: var(--mci-blaze-orange);
  background: transparent;
  font-weight: 700;
}

.media-viewer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  padding: 1.5rem;
  display: grid;
  place-items: center;
  background: var(--color-overlay);
  backdrop-filter: blur(6px);
}

.media-viewer-dialog {
  width: min(100%, 900px);
  max-height: calc(100dvh - 3rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.media-viewer-header,
.media-viewer-footer {
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.media-viewer-header {
  background: var(--color-shell);
  color: var(--mci-white);
  border-bottom: 2px solid var(--mci-blaze-orange);
}

.media-viewer-header strong,
.media-viewer-header span {
  display: block;
}

.media-viewer-header span {
  color: var(--color-muted);
  font-size: 0.76rem;
}

.media-viewer-close {
  width: 2.3rem;
  height: 2.3rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: var(--mci-white);
  background: transparent;
}

.media-viewer-body {
  padding: 1rem;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(0, 0, 0, 0.12);
}

.media-viewer-body img {
  max-width: 100%;
  max-height: calc(100dvh - 13rem);
  border-radius: 0.7rem;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.25);
}

.media-viewer-footer {
  border-top: 1px solid var(--color-border);
  justify-content: flex-end;
}

.split-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.table-panel { margin-top: 1rem; }
.table-responsive { overflow-x: auto; }

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

th,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  text-align: left;
}

th {
  color: var(--color-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td { font-size: 0.86rem; }

.empty-cell {
  color: var(--color-muted);
  text-align: center;
}

.import-result {
  display: grid;
  gap: 0.25rem;
  padding: 0.7rem;
  border-left: 3px solid var(--mci-blaze-orange);
  background: var(--color-panel-alt);
  font-size: 0.8rem;
}

.template-list { display: grid; }

.template-list article {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.template-list strong,
.template-list span { display: block; }

.template-list span {
  margin-top: 0.15rem;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.template-list p {
  margin: 0.55rem 0 0;
  white-space: pre-wrap;
}

.filter-panel { margin-bottom: 1rem; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  align-items: end;
  gap: 0.8rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.filter-actions .btn { flex: 1; }

.settings-panel { max-width: 620px; }

.public-main {
  min-height: 100dvh;
  padding: 1.5rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, rgba(0, 32, 96, 0.97), rgba(0, 15, 48, 0.98)), var(--mci-dark-navy);
}

.login-page { width: min(100%, 460px); }
.public-brand { justify-content: center; margin-bottom: 1rem; color: #fff; }

.login-card {
  padding: 1.8rem;
  border: 1px solid #214682;
  border-radius: 0.7rem;
  color: #fff;
  background: #000f30;
  box-shadow: 0 0.65rem 1.75rem rgba(0, 0, 0, 0.28);
}

.login-card h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
}

.login-card h1::after {
  content: "";
  display: block;
  width: 100%;
  height: 2px;
  margin: 0.8rem 0;
  background: #2f70d9;
}

.login-intro,
.login-footer,
.managed-account-card p { color: #c7d3ec; }

.login-card .form-control {
  height: 2.85rem;
  min-height: 2.85rem;
  line-height: 1.4;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.32);
}

.remember-row {
  display: inline-flex !important;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  margin: 0.1rem 0 0.25rem;
  color: #fff !important;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  user-select: none;
}

.remember-checkbox {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--mci-blaze-orange);
}

.remember-row span {
  display: inline-block;
}

.login-submit { width: 100%; min-height: 3.25rem; }
.login-footer { text-align: center; font-size: 0.8rem; }

#blazor-error-ui {
  display: none;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 99;
  padding: 0.75rem 1rem;
  color: #000;
  background: #fff3cd;
}

#blazor-error-ui .dismiss {
  float: right;
  cursor: pointer;
}

@media (max-width: 1180px) {
  .conversation-workspace {
    grid-template-columns: minmax(240px, 0.92fr) minmax(0, 1.3fr);
  }

  .composer {
    grid-column: 1 / -1;
  }

  .composer .form-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .composer .form-stack > div:nth-child(6),
  .composer .form-stack > div:nth-child(7),
  .composer .send-button {
    grid-column: 1 / -1;
  }

  .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell-header {
    min-height: 64px;
    padding: 0.85rem 1rem;
    align-items: flex-start;
    flex-direction: column;
  }

  .account-actions {
    width: 100%;
    justify-content: space-between;
  }

  .account-summary {
    flex: 1;
  }

  .app-shell-body { display: block; }

  .app-sidebar {
    padding: 0.45rem 0.6rem;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
    overflow-x: auto;
  }

  .app-nav {
    display: flex;
    width: max-content;
  }

  .app-nav a {
    padding: 0.56rem 0.7rem;
    font-size: 0.8rem;
  }

  .nav-section-label { display: none; }

  .app-content { padding: 1rem; }

  .page-heading,
  .compact-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.65rem;
  }

  .status-copy { text-align: left; }

  .metric-grid,
  .split-layout { grid-template-columns: 1fr; }

  .conversation-workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .conversation-list { max-height: 420px; }
  .thread-list { max-height: 240px; }
  .thread-panel-body { height: auto; }
  .thread-body { max-height: 420px; }

  .thread-reply-bar,
  .thread-reply-actions,
  .conversation-pager,
  .media-viewer-header,
  .media-viewer-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .conversation-pager-actions { justify-content: flex-end; }
  .message-bubble { max-width: 100%; }

  .composer .form-stack { grid-template-columns: 1fr; }
  .composer .form-stack > * { grid-column: auto !important; }

  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; }
  .trend-chart { gap: 0.4rem; padding-inline: 0.6rem; }
}

@media (max-width: 460px) {
  .brand-wordmark { font-size: 1.18rem; }
  .app-title { font-size: 0.98rem; }

  .account-name-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.2rem;
  }

  .filter-grid { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .login-card { padding: 1.25rem; }
  .media-viewer-backdrop { padding: 0.75rem; }
}

/* Follow-up shell, settings, and conversation polish */
.account-actions {
  align-items: stretch;
  gap: 0.85rem;
}

.account-actions form {
  display: flex;
  margin: 0;
}

.account-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.28rem;
  min-height: 3.3rem;
  padding: 0.55rem 0.9rem;
  box-sizing: border-box;
}

.account-name-row {
  line-height: 1.1;
}

.account-settings-link {
  color: var(--mci-blaze-orange);
}

.account-settings-link:hover,
.account-settings-link:focus {
  color: #ff8a3d;
}

.account-signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.3rem;
  padding: 0.65rem 1.05rem;
  box-sizing: border-box;
}

.thread-body {
  scroll-behavior: smooth;
}

.thread-reply-bar {
  margin: 0 1rem 1rem;
  padding: 0.95rem 1rem 1.15rem;
  border: 1px solid var(--color-border);
  border-radius: 0.9rem;
}

.settings-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}

.settings-panel {
  max-width: none;
}

.settings-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.settings-note {
  color: var(--color-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.settings-status {
  min-height: 1.25rem;
}

@media (max-width: 720px) {
  .thread-reply-bar {
    margin: 0 0.75rem 0.75rem;
  }
}

/* Conversation spacing and login card focus stability */
.thread-panel-body {
  padding-bottom: 1rem;
  box-sizing: border-box;
}



.login-card,
.login-card:focus,
.login-card:focus-within {
  border-color: #214682;
  outline: none;
  box-shadow: 0 0.65rem 1.75rem rgba(0, 0, 0, 0.28);
}



/* Contact-list import and verification */
.import-mapping {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.55rem;
  background: var(--color-panel-alt);
}
.import-mapping .btn { grid-column: 1 / -1; justify-self: start; }
.import-panel { display: flex; flex-direction: column; min-height: 100%; }
.import-panel .panel-body { display: flex; flex: 1; flex-direction: column; }
.import-panel .import-preview { flex: 1; min-height: 13rem; max-height: none; border: 1px solid var(--color-border); border-radius: 0.45rem; }
.preview-status { display: inline-flex; min-width: 4.7rem; justify-content: center; padding: 0.2rem 0.4rem; border-radius: 999px; color: var(--mci-white); font-size: 0.74rem; font-weight: 700; }
.preview-status.is-valid { background: #157347; }
.preview-status.is-invalid { background: var(--mci-blaze-orange); }
.list-actions { display: flex; gap: 0.4rem; justify-content: flex-end; white-space: nowrap; }
.list-actions .btn { min-height: 2.1rem; padding: 0.4rem 0.65rem; }
.list-detail > td { padding: 0.65rem; background: var(--color-panel-alt); }
.delete-confirmation { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.65rem; color: var(--color-text); font-weight: 600; }
@media (max-width: 620px) { .import-mapping { grid-template-columns: 1fr; } .list-actions { justify-content: flex-start; } .import-panel .import-preview { min-height: 11rem; } }
