:root {
  color-scheme: light;
  --bg: oklch(96.5% 0.012 245);
  --surface: oklch(100% 0 0);
  --surface-subtle: oklch(94% 0.018 245);
  --ink: oklch(21% 0.035 250);
  --ink-soft: oklch(42% 0.032 250);
  --muted: oklch(53% 0.028 250);
  --border: oklch(87% 0.02 245);
  --primary: oklch(45% 0.088 175);
  --primary-strong: oklch(34% 0.075 175);
  --rust: oklch(52% 0.135 46);
  --gold: oklch(72% 0.115 82);
  --danger: oklch(45% 0.16 27);
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.09);
  --shadow-tight: 0 8px 22px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, oklch(99% 0.004 245), var(--bg) 280px),
    var(--bg);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  text-wrap: pretty;
}

.tgdevs-footer {
  position: fixed;
  z-index: 1000;
  right: 12px;
  bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.tgdevs-footer a {
  color: var(--ink-soft);
  font-weight: 700;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 38%),
    linear-gradient(135deg, oklch(24% 0.04 248), oklch(17% 0.034 250));
  color: white;
  padding: 22px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 28px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a,
.nav button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.84);
  cursor: pointer;
  display: block;
  padding: 11px 12px;
  text-align: left;
}

.nav a:hover,
.nav button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.main {
  padding: 26px 30px 40px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.topbar-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 700;
}

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.12;
}

h1 {
  font-size: 30px;
  margin: 0 0 18px;
}

h2 {
  font-size: 20px;
  margin: 28px 0 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
}

.metric {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  margin-top: 10px;
}

.metric-strip {
  border-top: 3px solid var(--primary);
}

.metric-strip:nth-child(2) {
  border-top-color: var(--rust);
}

.metric-strip:nth-child(3) {
  border-top-color: var(--gold);
}

.metric-strip:nth-child(4) {
  border-top-color: var(--ink-soft);
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.dashboard-header h1 {
  margin-bottom: 6px;
}

.dashboard-metric {
  position: relative;
  overflow: hidden;
}

.dashboard-card-line {
  height: 5px;
  width: 72px;
  border-radius: 999px;
  margin-top: 16px;
}

.dashboard-insight p {
  min-height: 42px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dashboard-leaders {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}

.dashboard-leaders p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-weight: 800;
}

.live-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 0 4px oklch(84% 0.08 175 / 0.28);
}

.live-dot.active {
  animation: pulse-live 900ms ease-in-out infinite;
}

.live-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.live-chart-card {
  display: grid;
  gap: 14px;
  min-height: 190px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.live-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.live-chart-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.95fr) minmax(120px, 2fr) 42px;
  gap: 10px;
  align-items: center;
}

.bar-label {
  color: var(--ink-soft);
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-subtle);
}

.bar-fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  transition: width 280ms ease;
}

.bar-value {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

@keyframes pulse-live {
  0% {
    transform: scale(1);
    opacity: 0.75;
  }

  50% {
    transform: scale(1.22);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.75;
  }
}

.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

.table th {
  background: var(--surface-subtle);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: oklch(98% 0.009 175);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: oklch(98% 0.012 175);
  color: var(--primary-strong);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  margin: 0 4px 4px 0;
}

.pill.success {
  border-color: oklch(76% 0.12 155);
  background: oklch(96% 0.03 155);
  color: oklch(42% 0.13 155);
}

.button {
  border: 0;
  border-radius: 7px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 40px;
  padding: 10px 14px;
  font-weight: 700;
}

.button.secondary {
  background: var(--ink-soft);
}

.button.danger {
  background: var(--danger);
}

.button.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.button:hover {
  background: var(--primary-strong);
}

.form {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.field {
  display: grid;
  gap: 6px;
}

.field input,
.field select,
.inline-form input,
.inline-form select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
}

.field input:focus,
.field select:focus,
.inline-form input:focus,
.inline-form select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px oklch(84% 0.08 175 / 0.38);
  outline: 0;
}

.page-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-title-row h1 {
  margin-bottom: 6px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.account-section {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.account-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-end;
}

.account-section-head h2 {
  margin: 0 0 4px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-end;
}

.section-head h2 {
  margin: 0 0 4px;
}

.integration-action-card {
  align-content: start;
}

.integrations-table td {
  vertical-align: top;
}

.integration-whatsapp-cell,
.integration-whatsapp-cell form,
.inline-connect-form {
  display: grid;
  gap: 8px;
}

.integration-whatsapp-cell form {
  grid-template-columns: repeat(2, max-content);
}

.inline-connect-form {
  grid-template-columns: minmax(160px, 220px) max-content;
  align-items: center;
}

.inline-connect-form input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
}

.integration-qr-cell {
  display: grid;
  gap: 8px;
}

.user-edit-details {
  position: relative;
}

.user-edit-details summary {
  list-style: none;
}

.user-edit-details summary::-webkit-details-marker {
  display: none;
}

.inline-edit-card {
  position: absolute;
  right: 0;
  z-index: 5;
  width: min(360px, calc(100vw - 48px));
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow-tight);
}

.compact-toggle {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-tight);
  color: inherit;
  cursor: pointer;
  padding: 16px 18px;
  text-align: left;
}

.compact-toggle:hover {
  border-color: oklch(76% 0.06 175);
}

.compact-summary {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chevron {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.contact-cell {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 210px;
}

.contact-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--avatar-ring, var(--border));
  box-shadow: 0 0 0 2px white;
  background: var(--surface-subtle);
}

.contact-avatar.large {
  width: 72px;
  height: 72px;
}

.contact-avatar.fallback {
  display: grid;
  place-items: center;
  color: var(--primary-strong);
  font-weight: 800;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus {
  outline: 3px solid oklch(84% 0.08 175 / 0.58);
  outline-offset: -3px;
}

.contact-detail-dialog {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  margin: 0;
}

.contact-detail-body {
  height: 100%;
  max-height: none;
  overflow: auto;
  padding: 0;
}

.contact-detail-title {
  display: flex;
  gap: 14px;
  align-items: center;
}

.fullscreen-close {
  min-height: 46px;
  padding-inline: 18px;
}

.contact-detail-body > .modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 22px 30px;
}

.contact-detail-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.35fr) repeat(3, minmax(240px, 0.85fr));
  gap: 18px;
  padding: 24px 30px 0;
}

.detail-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: oklch(99% 0.004 245);
  padding: 16px;
}

.detail-panel.full {
  grid-column: 1 / -1;
  margin: 0 30px 30px;
}

.detail-panel h3 {
  margin: 0;
  font-size: 16px;
}

.tag-checklist {
  display: grid;
  gap: 10px;
}

.contact-edit-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.contact-edit-form .span-2 {
  grid-column: 1 / -1;
}

.tag-checkbox {
  display: flex;
  gap: 8px;
  align-items: center;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attachment-row {
  display: grid;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  padding: 10px;
}

.conversation-page {
  height: calc(100vh - 146px);
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.conversation-sidebar {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--border);
  background: oklch(98% 0.006 245);
}

.conversation-sidebar-head {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 18px;
}

.conversation-sidebar-head h1 {
  margin-bottom: 5px;
}

.conversation-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.conversation-tabs button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.conversation-tabs button.active {
  border-color: var(--primary);
  background: oklch(94% 0.025 175);
  color: var(--primary-strong);
}

.conversation-search {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.conversation-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  padding: 10px 12px;
}

.conversation-search-box {
  position: relative;
  display: block;
}

.conversation-search-box button {
  position: absolute;
  top: 50%;
  right: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px 8px;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 800;
}

.conversation-search-box input:not(:placeholder-shown) {
  padding-right: 68px;
}

.conversation-list {
  min-height: 0;
  overflow: auto;
}

.conversation-account-group {
  display: grid;
}

.conversation-account-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: oklch(94% 0.014 245);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 9px 14px;
  font-size: 12px;
  text-align: left;
}

.conversation-account-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 13px;
}

.conversation-account-head span {
  white-space: nowrap;
}

.conversation-account-head:hover {
  background: oklch(92% 0.018 245);
}

.conversation-group-toggle {
  color: var(--primary-strong);
  font-weight: 800;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 13px 14px;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: white;
}

.conversation-item.active {
  box-shadow: inset 4px 0 0 var(--primary);
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  border: 2px solid var(--avatar-ring, var(--border));
  border-radius: 50%;
  box-shadow: 0 0 0 2px white;
  background: var(--surface-subtle);
  object-fit: cover;
}

.conversation-avatar.large {
  width: 56px;
  height: 56px;
}

.conversation-avatar.fallback {
  display: grid;
  place-items: center;
  color: var(--primary-strong);
  font-weight: 800;
}

.conversation-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-item-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.conversation-item-title span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 12px;
}

.conversation-item-preview {
  min-width: 0;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.conversation-item-preview-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.conversation-unread {
  min-width: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 900;
}

.conversation-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
}

.channel-badge.whatsapp {
  background: oklch(94% 0.035 155);
  color: oklch(34% 0.09 155);
}

.channel-badge.email {
  background: oklch(94% 0.03 250);
  color: oklch(36% 0.08 250);
}

.channel-badge.owner {
  background: var(--surface-subtle);
  color: var(--ink-soft);
}

.conversation-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(180deg, oklch(99% 0.004 245), oklch(96% 0.012 245)),
    var(--bg);
}

.conversation-panel-head {
  display: flex;
  gap: 13px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 15px 18px;
}

.conversation-head-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-head-main h2 {
  margin: 0;
}

.conversation-head-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.conversation-channel-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 6px;
}

.conversation-channel-tabs.three {
  grid-template-columns: repeat(3, minmax(88px, 1fr));
}

.conversation-channel-tabs button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 800;
}

.conversation-channel-tabs button.active {
  border-color: var(--primary);
  background: oklch(94% 0.025 175);
  color: var(--primary-strong);
}

.conversation-channel-tabs button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.message-shell {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.message-timeline {
  grid-row: 2;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px;
}

.message-day-separator {
  align-self: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: oklch(99% 0.004 245 / 0.88);
  color: var(--ink-soft);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.account-delete-action {
  min-width: 190px;
  display: grid;
  gap: 6px;
}

.account-delete-action .muted {
  max-width: 240px;
  color: var(--danger);
  font-size: 11px;
}

.message-floating-date {
  position: sticky;
  top: 8px;
  z-index: 4;
  align-self: center;
  min-height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: oklch(99% 0.004 245 / 0.94);
  color: var(--ink-soft);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(6px);
}

.email-title-list {
  display: grid;
  gap: 8px;
}

.email-title-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  gap: 5px 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 12px 14px;
  box-shadow: var(--shadow-tight);
}

.email-title-row.incoming {
  border-left: 4px solid oklch(58% 0.13 160);
}

.email-title-row.outgoing {
  border-left: 4px solid oklch(58% 0.12 245);
}

.email-title-row.selected,
.message-bubble.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px oklch(86% 0.06 175);
}

.email-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-title-row span {
  color: var(--muted);
  font-size: 12px;
}

.email-title-row > span:last-of-type {
  grid-column: 3 / -1;
}

.email-direction-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
}

.email-direction-badge.incoming {
  background: oklch(94% 0.035 155);
  color: oklch(34% 0.09 155);
}

.email-direction-badge.outgoing {
  background: oklch(94% 0.03 250);
  color: oklch(36% 0.08 250);
}

.email-title-row button,
.email-title-row form button,
.message-menu button,
.message-menu form button {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 10px;
  text-align: left;
}

.message-select-inline,
.message-actions label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.message-selection-bar {
  grid-row: 1;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: oklch(98% 0.01 245 / 0.96);
  padding: 9px 14px;
  backdrop-filter: blur(8px);
}

.message-selection-bar strong {
  font-size: 13px;
}

.message-selection-bar form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.message-history-bar {
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  background: oklch(99% 0.006 245 / 0.96);
  padding: 9px 14px;
}

.message-history-bar label {
  display: grid;
  gap: 4px;
  min-width: min(260px, 100%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.message-history-bar input {
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 9px;
}

.message-forward-modal {
  width: min(440px, calc(100vw - 28px));
}

.message-forward-modal select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 9px;
}

.message-flags,
.reply-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
  font-size: 0.78rem;
}

.message-flags span,
.reply-preview {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: oklch(98% 0.01 245);
  color: var(--muted);
  padding: 5px 8px;
}

.reply-preview {
  justify-content: space-between;
  margin-bottom: 8px;
}

.reply-preview strong {
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.reply-preview button,
.message-reaction-form button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.message-reaction-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px 8px;
}

.message-bubble {
  width: min(680px, 78%);
  display: grid;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 12px 13px;
  box-shadow: var(--shadow-tight);
}

.message-actions {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  border-bottom: 1px solid oklch(91% 0.01 245);
  padding-bottom: 4px;
}

.message-bubble .message-actions {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message-bubble:hover .message-actions,
.message-bubble:focus-within .message-actions,
.message-bubble.selected .message-actions {
  opacity: 1;
}

.message-menu-wrap {
  position: relative;
  display: inline-flex;
}

.message-menu-trigger {
  min-width: 28px;
  min-height: 24px;
  border: 0;
  border-radius: 999px;
  background: oklch(97% 0.006 245);
  color: var(--muted);
  cursor: pointer;
  font-weight: 950;
}

.message-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 156px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow-soft);
  padding: 5px;
}

.message-menu button:hover,
.message-menu form button:hover {
  background: oklch(96% 0.01 245);
}

.message-select-compact {
  width: 22px;
  overflow: hidden;
}

.message-bubble.outgoing {
  align-self: flex-end;
  background: oklch(94% 0.026 175);
}

.message-bubble.incoming {
  align-self: flex-start;
}

.message-bubble-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-bubble p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-subject {
  color: var(--ink);
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.message-attachments {
  display: grid;
  gap: 8px;
}

.message-attachment-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink-soft);
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.message-attachment-actions {
  display: flex;
  gap: 8px;
}

.message-attachment-actions a {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  color: var(--primary-strong);
  font-weight: 800;
  text-decoration: none;
}

.delivery-failed strong {
  color: var(--danger);
}

.delivery-read strong,
.delivery-played strong {
  color: oklch(47% 0.14 240);
}

.media-preview {
  width: min(100%, 640px);
  max-height: 520px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  object-fit: contain;
}

.media-preview.compact {
  max-height: 260px;
}

.audio-preview {
  width: 100%;
  min-width: 240px;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 180px;
  max-width: 320px;
  height: 42px;
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary) 9%, transparent);
}

.voice-waveform span {
  width: 3px;
  min-height: 3px;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0.8;
}

.message-scroll-action {
  position: absolute;
  right: 24px;
  bottom: 18px;
  z-index: 2;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-strong);
  cursor: pointer;
  padding: 8px 12px;
  box-shadow: var(--shadow-tight);
  font-size: 13px;
  font-weight: 800;
}

.message-scroll-action:hover {
  border-color: var(--primary);
  background: oklch(96% 0.018 175);
}

.conversation-compose-placeholder {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 14px 18px;
  font-size: 13px;
}

.conversation-compose {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
}

.compose-target {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compose-target select,
.conversation-compose textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 9px 10px;
}

.conversation-compose textarea {
  grid-column: 3;
  grid-row: 2;
  min-height: 42px;
  max-height: 160px;
  resize: vertical;
}

.conversation-compose > .button[type="submit"] {
  grid-column: 4;
  grid-row: 2;
}

.compose-tool-wrap {
  grid-row: 2;
  position: relative;
  display: inline-grid;
  place-items: end center;
}

.compose-icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 21px;
  font-weight: 800;
}

.compose-icon-button:hover {
  background: oklch(94% 0.012 245);
  color: var(--ink);
}

.compose-attachments {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(2, minmax(142px, 1fr));
  gap: 7px;
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow-soft);
  padding: 8px;
}

.compose-attachments label,
.compose-attachment-option {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  min-height: 50px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
  gap: 8px;
  padding: 7px 9px;
}

.compose-attachments label:hover,
.compose-attachment-option:hover {
  border-color: var(--primary);
  background: oklch(96% 0.018 175);
}

.compose-attachment-option.recording {
  border-color: oklch(58% 0.2 28);
  background: oklch(97% 0.025 28);
}

.compose-attachments input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.compose-attachments strong,
.compose-attachments small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-attachments strong {
  font-size: 12px;
  font-weight: 900;
}

.compose-attachments small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.compose-attachment-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: oklch(94% 0.03 175);
  color: var(--primary);
  font-size: 10px;
  font-weight: 950;
}

.compose-attachment-summary {
  grid-column: 1 / -1;
  grid-row: 3;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  border: 1px solid oklch(86% 0.035 175);
  border-radius: 8px;
  background: oklch(97% 0.015 175);
  color: var(--ink);
  padding: 9px 11px;
}

.compose-attachment-summary .button {
  justify-self: end;
}

.compose-error {
  grid-column: 1 / -1;
  grid-row: 4;
  margin: 0;
  color: oklch(50% 0.17 28);
  font-size: 12px;
  font-weight: 800;
}

.compose-upload-status {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: oklch(97% 0.012 245);
  color: var(--ink);
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 800;
}

.compose-upload-status progress {
  width: 100%;
  height: 8px;
  accent-color: var(--primary);
}

.compose-upload-status.done {
  border-color: oklch(82% 0.08 155);
  background: oklch(97% 0.02 155);
}

.compose-upload-status.error {
  border-color: oklch(78% 0.08 28);
  background: oklch(97% 0.025 28);
  color: oklch(43% 0.16 28);
}

.compose-emoji-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(6, 34px);
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow-soft);
  padding: 9px;
}

.compose-emoji-panel button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: oklch(97% 0.006 245);
  cursor: pointer;
  font-size: 17px;
}

.compose-emoji-panel span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.compose-attachment-summary strong {
  font-size: 12px;
  font-weight: 950;
}

.compose-attachment-summary span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-attachment-summary small {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.conversation-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 100%;
  padding: 32px;
  text-align: center;
}

.contact-files-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
}

.file-library-list {
  display: grid;
  gap: 10px;
}

.file-library-row {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.file-library-row {
  grid-template-columns: minmax(220px, 2fr) minmax(110px, 0.8fr) minmax(140px, 1fr) minmax(90px, 0.5fr) minmax(150px, 0.8fr);
  align-items: center;
}

.file-library-row > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.file-library-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-library-row span {
  min-width: 0;
  color: var(--muted);
}

.email-page-head {
  margin-bottom: 14px;
}

.email-page-counts {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.email-page-counts strong {
  color: var(--ink);
  font-size: 16px;
}

.email-page-counts span {
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.email-inbox-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-tight);
}

.email-inbox-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(240px, 2fr) 28px minmax(70px, auto);
  gap: 14px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  background: oklch(98% 0.008 245);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.email-inbox-row:nth-child(even) {
  background: var(--surface);
}

.email-inbox-row:last-child {
  border-bottom: 0;
}

.email-inbox-row:hover,
.email-inbox-row:focus-visible {
  background: oklch(94% 0.025 245);
  outline: none;
}

.email-inbox-row.unread {
  font-weight: 800;
}

.email-inbox-sender,
.email-inbox-summary,
.email-inbox-summary strong,
.email-inbox-summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-inbox-summary {
  display: block;
}

.email-inbox-summary span {
  color: var(--muted);
  font-weight: 400;
}

.email-inbox-row time {
  color: var(--muted);
  font-size: 13px;
  font-weight: inherit;
  text-align: right;
  white-space: nowrap;
}

.email-inbox-attachment {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.email-inbox-attachment svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.file-list-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--border);
  background: oklch(99% 0.004 245);
}

.file-list-label {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border);
  background: oklch(96% 0.01 245);
  color: var(--muted);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.file-row {
  width: 100%;
  display: grid;
  gap: 5px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 13px 14px;
  text-align: left;
}

.file-row:hover,
.file-row.active {
  background: white;
}

.file-row.active {
  box-shadow: inset 4px 0 0 var(--primary);
}

.file-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row > span:not(.conversation-badges) {
  color: var(--muted);
  font-size: 12px;
}

.file-viewer-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: 18px;
}

.file-viewer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.file-viewer-head h2 {
  margin: 0 0 5px;
}

.file-viewer-frame {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.file-viewer-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.file-viewer-frame video,
.file-viewer-frame audio {
  max-width: min(100%, 920px);
}

.file-viewer-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.file-preview-empty {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 24px;
  text-align: center;
}

.file-management-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.file-tag-panel {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.file-tag-panel h3 {
  margin: 0 0 4px;
}

.file-tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form select {
  min-width: 138px;
}

.inline-form input[type="color"] {
  width: 48px;
  min-height: 36px;
  padding: 4px;
}

.wide-inline input[name="name"] {
  min-width: min(260px, 100%);
}

@media (max-width: 860px) {
  .conversation-compose {
    grid-template-columns: minmax(0, 1fr);
  }

  .compose-tool-wrap,
  .conversation-compose textarea,
  .conversation-compose > .button[type="submit"],
  .compose-attachment-summary {
    grid-column: 1;
    grid-row: auto;
  }

  .compose-attachments {
    left: 0;
    max-width: none;
  }

  .compose-attachment-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .compose-attachment-summary small {
    grid-column: auto;
  }

  .file-management-panel {
    grid-template-columns: minmax(0, 1fr);
  }
}

.tag-pill {
  background: white;
}

.modal-dialog {
  position: fixed;
  z-index: 10000;
  width: min(620px, calc(100vw - 32px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 34px 90px rgba(15, 23, 42, 0.2);
}

.modal-dialog.wide {
  width: min(760px, calc(100vw - 32px));
}

.modal-dialog::backdrop {
  z-index: 9999;
  background: rgba(15, 23, 42, 0.46);
}

.modal-dialog.contact-detail-dialog {
  position: fixed;
  inset: 0;
  width: 100dvw;
  height: 100dvh;
  max-width: 100dvw;
  max-height: 100dvh;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
}

.modal-body.contact-detail-body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  max-height: none;
  gap: 0;
  overflow: auto;
  padding: 0;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.modal-head h2 {
  margin: 0 0 6px;
}

.contact-modal-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 30px;
}

.contact-modal-tabs button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
}

.contact-modal-tabs button.active {
  border-color: var(--primary);
  background: oklch(94% 0.025 175);
  color: var(--primary-strong);
}

.profile-kv {
  display: grid;
  gap: 4px;
}

.profile-kv span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.modal-close {
  flex: 0 0 auto;
}

.modal-form {
  max-width: none;
}

.contact-search-select {
  display: grid;
  gap: 8px;
}

.contact-search-results {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 260px;
  overflow: auto;
  background: white;
}

.contact-search-option {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  background: white;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.contact-search-option:last-child {
  border-bottom: 0;
}

.contact-search-option:hover,
.contact-search-option.selected {
  background: oklch(96% 0.025 175);
}

.contact-search-option span,
.contact-search-empty {
  color: var(--muted);
  font-size: 12px;
}

.contact-search-empty {
  padding: 12px;
}

.suggestion-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}

.suggestion-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.email-fullscreen-dialog {
  width: min(1100px, calc(100vw - 28px));
  max-width: none;
  z-index: 11000;
}

.webmail-compose {
  overflow: hidden;
  padding: 0;
  border: 1px solid oklch(55% 0.012 245);
  border-radius: 8px;
  background: white;
  box-shadow: 0 22px 70px oklch(20% 0.02 245 / 0.28);
}

.webmail-compose-head {
  margin: 0;
  padding: 10px 12px;
  background: oklch(27% 0.014 245);
  color: white;
  border-bottom: 0;
}

.webmail-compose-head h2 {
  color: white;
  font-size: 14px;
  margin: 0;
}

.webmail-compose-head p {
  margin: 2px 0 0;
  color: oklch(86% 0.012 245);
  font-size: 12px;
}

.webmail-compose-head .button {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid oklch(76% 0.015 245 / 0.55);
  background: transparent;
}

.email-compose-fullscreen {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-rows: auto auto auto minmax(280px, 1fr) auto auto;
  gap: 0;
}

.email-original-preview {
  display: grid;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-subtle);
  max-height: 180px;
  overflow: auto;
}

.email-original-preview span {
  color: var(--muted);
  font-size: 12px;
}

.email-viewer-window {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto;
  gap: 0;
  overflow: hidden;
  padding: 0;
  border: 1px solid oklch(55% 0.012 245);
  border-radius: 8px;
  background: white;
  box-shadow: 0 22px 70px oklch(20% 0.02 245 / 0.28);
}

.email-viewer-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: oklch(98% 0.004 245);
}

.email-viewer-meta > div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--border);
}

.email-viewer-meta > div:last-child {
  border-right: 0;
}

.email-viewer-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.email-viewer-meta strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-viewer-content {
  overflow: auto;
  padding: 22px;
  background: white;
}

.email-viewer-content iframe {
  width: 100%;
  min-height: 100%;
  height: 62vh;
  border: 0;
  background: white;
}

.email-viewer-loading {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: oklch(97% 0.006 245);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.email-viewer-content pre {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.55;
}

.email-viewer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.email-compose-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 0;
}

.webmail-address-fields {
  border-bottom: 1px solid var(--border);
}

.webmail-address-fields .field {
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 0;
  min-height: 38px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.webmail-address-fields .field:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.webmail-address-fields .field input,
.webmail-address-fields .field select {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-width: 0;
  padding: 8px 0;
}

.webmail-address-fields .field input:focus,
.webmail-address-fields .field select:focus {
  border-color: transparent;
  box-shadow: none;
}

.email-compose-editor {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 0;
  border-radius: 0;
  outline: 0;
  padding: 18px 22px;
  font: inherit;
  line-height: 1.5;
}

.email-rich-editor {
  display: grid;
  grid-template-rows: auto auto minmax(260px, 1fr);
  min-height: 360px;
  background: white;
}

.email-rich-status {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.email-rich-status span {
  font-weight: 800;
}

.email-rich-status button {
  border: 0;
  background: transparent;
  color: var(--primary-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.email-format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: oklch(96.5% 0.006 245);
}

.email-editor-hidden-file {
  display: none;
}

.email-format-toolbar button,
.email-format-toolbar select,
.toolbar-color {
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 7px;
}

.email-format-toolbar select {
  border-color: var(--border);
  background: white;
  max-width: 130px;
}

.email-format-toolbar button:hover,
.toolbar-color:hover {
  border-color: var(--border);
  background: white;
}

.toolbar-color {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.toolbar-color input {
  width: 18px;
  height: 18px;
  border: 0;
  padding: 0;
  background: transparent;
}

.toolbar-separator {
  width: 1px;
  height: 22px;
  margin: 0 3px;
  background: var(--border);
}

.email-compose-editor.rich {
  min-height: 260px;
  overflow: auto;
  white-space: normal;
}

.email-editor-canvas {
  position: relative;
  min-height: 260px;
}

.email-compose-editor.rich:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.email-compose-editor.rich blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--ink-soft);
}

.email-compose-editor.rich img {
  max-width: 100%;
  height: auto;
  cursor: nwse-resize;
}

.email-editor-image-selected {
  outline: 2px solid oklch(53% 0.14 255);
  outline-offset: 2px;
}

.email-image-resize-frame {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  border: 1px solid oklch(53% 0.14 255);
  box-shadow: 0 0 0 1px white;
}

.email-image-resize-frame button {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 2px;
  padding: 0;
  background: oklch(53% 0.14 255);
  pointer-events: auto;
}

.email-image-resize-frame .nw {
  left: -7px;
  top: -7px;
  cursor: nwse-resize;
}

.email-image-resize-frame .ne {
  right: -7px;
  top: -7px;
  cursor: nesw-resize;
}

.email-image-resize-frame .sw {
  left: -7px;
  bottom: -7px;
  cursor: nesw-resize;
}

.email-image-resize-frame .se {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

.email-compose-actions {
  display: flex;
  justify-content: flex-end;
}

.webmail-compose-actions {
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: oklch(96% 0.006 245);
}

.webmail-compose-actions .button:first-child {
  min-height: 32px;
  border-radius: 4px;
  background: oklch(53% 0.14 255);
}

.email-editor-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: oklch(97% 0.006 245);
}

.email-editor-tabs button {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  font-weight: 800;
}

.email-editor-tabs button.active {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.email-render-preview,
.email-text-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.5;
}

.email-text-preview.compact {
  max-height: 120px;
  overflow: auto;
  margin: 8px 0 0;
}

.email-render-preview {
  min-height: 320px;
  overflow: auto;
}

.webmail-compose .email-render-preview {
  border: 0;
  border-radius: 0;
  padding: 18px 22px;
}

.email-render-preview pre {
  white-space: pre-wrap;
  font: inherit;
}

.email-attachment-panel {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: oklch(98% 0.004 245);
}

.email-attachment-panel input[type="file"] {
  display: none;
}

.email-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.email-attachment-list .pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.email-attachment-list button {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-weight: 900;
}

.user-bulk-actions {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.user-bulk-actions form,
.user-bulk-actions button {
  width: 100%;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 22% 18%, oklch(88% 0.04 175 / 0.95), transparent 28%),
    linear-gradient(120deg, oklch(98% 0.012 245), oklch(93% 0.018 245));
}

.admin-login-page {
  background:
    linear-gradient(120deg, oklch(97% 0.006 245), oklch(91% 0.018 250));
}

.login-shell {
  width: min(480px, 100%);
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
  border: 1px solid oklch(84% 0.018 245);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 34px 90px rgba(15, 23, 42, 0.17);
}

.login-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: white;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(135deg, oklch(24% 0.04 248), oklch(33% 0.08 176));
}

.admin-login-panel {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), transparent 40%),
    linear-gradient(135deg, oklch(21% 0.04 250), oklch(36% 0.075 250));
}

.login-panel::after {
  content: "";
  position: absolute;
  inset: auto 34px 34px auto;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
}

.login-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.login-panel h1 {
  max-width: 360px;
  margin: 0;
  font-size: 48px;
}

.login-panel p {
  max-width: 390px;
  margin: 18px 0 auto;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.55;
}

.login-ledger {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.login-ledger span {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 7px 11px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 13px;
}

.login-form {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 46px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

.notice {
  border: 1px solid oklch(82% 0.07 45);
  border-radius: 7px;
  background: oklch(96% 0.03 58);
  color: oklch(38% 0.09 42);
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
}

.notice.success {
  border-color: oklch(78% 0.08 175);
  background: oklch(96% 0.025 175);
  color: var(--primary-strong);
}

.empty-state {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.qr-panel {
  width: 176px;
  min-height: 176px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.qr-panel.compact {
  width: 132px;
  min-height: 132px;
  padding: 8px;
}

.qr-panel svg {
  width: 154px;
  height: 154px;
  display: block;
}

.qr-panel img {
  width: 154px;
  height: 154px;
  display: block;
}

.qr-panel.compact svg {
  width: 112px;
  height: 112px;
}

.qr-panel.compact img {
  width: 112px;
  height: 112px;
}

.compact-contact-dialog {
  width: min(900px, calc(100vw - 32px));
}

.compact-contact-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

.compact-contact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.tagged-file-viewer {
  margin-top: 16px;
}

.tagged-file-group {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.tagged-file-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.tagged-file-group summary::-webkit-details-marker {
  display: none;
}

.tagged-file-list {
  display: grid;
  border-top: 1px solid var(--border);
}

.tagged-file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.tagged-file-row:last-child {
  border-bottom: 0;
}

.tagged-file-row:hover {
  background: var(--surface-subtle);
}

.tagged-file-row span:first-child {
  display: grid;
  gap: 3px;
}

@media (max-width: 720px) {
  .compact-contact-form {
    grid-template-columns: 1fr;
  }

  .tagged-file-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .main {
    padding: 20px 16px 28px;
  }

  .dashboard-header {
    display: grid;
  }

  .dashboard-leaders {
    grid-template-columns: 1fr;
  }

  .page-title-row,
  .account-section-head,
  .modal-head,
  .suggestion-row {
    display: grid;
  }

  .page-actions {
    justify-content: stretch;
  }

  .page-actions .button {
    width: 100%;
  }

  .inline-form {
    display: grid;
  }

  .inline-form select,
  .inline-form input,
  .inline-form .button {
    width: 100%;
  }

  .contact-detail-grid,
  .attachment-grid {
    grid-template-columns: 1fr;
  }

  .contact-detail-grid {
    padding: 16px;
  }

  .detail-panel.full {
    margin: 0 16px 16px;
  }

  .contact-detail-body > .modal-head {
    padding: 16px;
  }

  .contact-edit-form {
    grid-template-columns: 1fr;
  }

  .contact-detail-title {
    align-items: flex-start;
  }

  .conversation-page {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .conversation-sidebar {
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .conversation-panel {
    min-height: 70vh;
  }

  .conversation-panel-head {
    align-items: flex-start;
  }

  .conversation-channel-tabs {
    width: 100%;
    margin-left: 0;
  }

  .conversation-channel-tabs.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .contact-files-shell {
    grid-template-columns: 1fr;
  }

  .email-inbox-row {
    grid-template-columns: minmax(90px, 0.65fr) minmax(120px, 1.5fr) 22px minmax(58px, auto);
    gap: 8px;
    padding-inline: 9px;
  }

  .email-inbox-summary span {
    display: none;
  }

  .file-list-panel {
    max-height: 34vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .file-viewer-panel {
    min-height: 70vh;
  }

  .file-viewer-head {
    display: grid;
  }

  .message-bubble {
    width: min(100%, 680px);
  }

  .live-status {
    justify-content: center;
    width: 100%;
  }

  .bar-row {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: 280px;
    padding: 30px;
  }

  .login-panel h1 {
    font-size: 36px;
  }

  .login-form {
    padding: 30px;
  }
}

/* Compact contact directory and inline profile editor */
.contact-account-section {
  margin-bottom: 14px;
}

.contact-account-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  padding: 10px 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.contact-account-head > span:first-child {
  display: grid;
  gap: 2px;
}

.contact-account-head strong {
  font-size: 15px;
}

.contact-account-head small,
.contact-account-count {
  color: var(--muted);
  font-size: 12px;
}

.contact-account-count {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contact-account-count b {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 16px;
}

.contact-list-shell {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-tight);
}

.contact-list-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(180px, 1.5fr) minmax(140px, 1fr) minmax(100px, 0.7fr) minmax(80px, auto);
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 9px 12px;
  background: oklch(98% 0.008 245);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.contact-list-row:nth-child(even) {
  background: var(--surface);
}

.contact-list-row:last-child {
  border-bottom: 0;
}

.contact-list-row:hover,
.contact-list-row:focus-visible {
  background: oklch(94% 0.025 245);
  outline: none;
}

.contact-list-row .contact-avatar {
  width: 38px;
  height: 38px;
}

.contact-list-identity {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.contact-list-identity strong,
.contact-list-identity small,
.contact-list-phone,
.contact-list-files {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-list-identity small,
.contact-list-phone,
.contact-list-tag,
.contact-list-files {
  color: var(--muted);
  font-size: 13px;
}

.contact-list-tag i,
.contact-profile-tags span,
.contact-file-group summary span {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border: 1px solid color-mix(in oklch, var(--tag-color) 55%, transparent);
  border-radius: 999px;
  padding: 3px 8px;
  background: color-mix(in oklch, var(--tag-color) 10%, white);
  color: var(--tag-color);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.modal-dialog.contact-detail-dialog.contact-profile-dialog {
  inset: 0;
  width: min(720px, calc(100dvw - 32px));
  height: min(860px, calc(100dvh - 32px));
  min-height: 520px;
  max-width: 720px;
  max-height: calc(100dvh - 32px);
  margin: auto;
  overflow: hidden;
  border: 1px solid oklch(83% 0.012 245);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 28px 90px oklch(20% 0.025 245 / 0.32);
}

.contact-profile {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface);
}

.contact-profile-head {
  z-index: 2;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  background: color-mix(in oklch, var(--surface) 94%, var(--surface-subtle));
}

.contact-profile-head > strong {
  font-size: 15px;
}

.contact-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.contact-icon-button:hover,
.contact-icon-button.active {
  background: var(--surface-subtle);
  color: var(--primary-strong);
}

.contact-icon-button svg,
.contact-photo-overlay svg,
.contact-save-status svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.contact-profile-scroll {
  overflow: auto;
  overscroll-behavior: contain;
}

.contact-profile-hero {
  display: grid;
  justify-items: center;
  padding: 42px 24px 28px;
  text-align: center;
}

.contact-photo-control {
  position: relative;
  width: 156px;
  height: 156px;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
}

.contact-photo-control.editable {
  cursor: pointer;
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px oklch(74% 0.09 175);
}

.contact-profile-photo {
  width: 156px;
  height: 156px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(145deg, oklch(88% 0.04 190), oklch(82% 0.055 250));
}

.contact-profile-photo.fallback {
  color: var(--primary-strong);
  font-size: 38px;
  font-weight: 850;
}

.contact-photo-overlay {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px 18px;
  background: linear-gradient(transparent, rgba(8, 20, 30, 0.82));
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.contact-inline-input,
.contact-inline-notes {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font: inherit;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.contact-inline-input {
  width: min(100%, 460px);
  padding: 5px 10px;
  text-align: center;
}

.contact-name-input {
  margin-top: 20px;
  font-size: 24px;
  font-weight: 850;
}

.contact-company-input {
  color: var(--muted);
  font-size: 15px;
}

.contact-inline-input:not([readonly]),
.contact-inline-notes:not([readonly]) {
  border-color: var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

.contact-inline-input:not([readonly]):focus,
.contact-inline-notes:not([readonly]):focus,
.contact-inline-select select:focus {
  border-color: oklch(65% 0.12 175);
  outline: 0;
  box-shadow: 0 0 0 3px oklch(84% 0.07 175 / 0.42);
}

.contact-phone-display {
  width: min(100%, 440px);
  display: grid;
  gap: 3px;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 16px;
  background: var(--surface-subtle);
  text-align: left;
}

.contact-phone-display span {
  color: oklch(49% 0.13 155);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.contact-phone-display strong {
  font-size: 15px;
}

.contact-phone-display small {
  color: var(--muted);
  font-size: 11px;
}

.contact-inline-select {
  width: min(100%, 440px);
  display: grid;
  gap: 6px;
  margin-top: 14px;
  text-align: left;
}

.contact-inline-select span,
.contact-profile-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contact-inline-select select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--surface-subtle);
  color: var(--ink);
}

.contact-profile-tags {
  min-height: 28px;
  margin-top: 15px;
}

.contact-profile-tags small {
  color: var(--muted);
}

.contact-profile-section {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
}

.contact-inline-notes {
  width: 100%;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.contact-inline-notes[readonly] {
  resize: none;
  padding-inline: 0;
}

.contact-profile-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.contact-profile-section-title > div {
  display: grid;
  gap: 3px;
}

.contact-profile-section-title small,
.contact-profile-empty {
  color: var(--muted);
  font-size: 12px;
}

.contact-profile-section-title > span {
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-subtle);
  font-size: 12px;
  font-weight: 800;
}

.contact-file-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-top: 8px;
}

.contact-file-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.contact-file-group summary::-webkit-details-marker {
  display: none;
}

.contact-file-group summary b {
  color: var(--muted);
  font-size: 12px;
}

.contact-file-group > div {
  display: grid;
  border-top: 1px solid var(--border);
}

.contact-file-group a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}

.contact-file-group a:last-child {
  border-bottom: 0;
}

.contact-file-group a:hover {
  background: var(--surface-subtle);
}

.contact-file-group a > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.contact-file-group a strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.contact-file-group a small {
  color: var(--muted);
  font-size: 11px;
}

.contact-profile-actions {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  background: color-mix(in oklch, var(--surface) 94%, var(--surface-subtle));
}

.contact-save-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: auto;
  color: oklch(46% 0.12 155);
  font-size: 13px;
  font-weight: 800;
}

.contact-save-status svg {
  width: 18px;
}

@media (max-width: 760px) {
  .contact-list-row {
    grid-template-columns: 42px minmax(0, 1fr) minmax(80px, auto);
    gap: 10px;
  }

  .contact-list-phone,
  .contact-list-tag {
    display: none;
  }

  .modal-dialog.contact-detail-dialog.contact-profile-dialog {
    width: 100dvw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .contact-profile-hero {
    padding: 32px 18px 24px;
  }

  .contact-profile-photo,
  .contact-photo-control {
    width: 132px;
    height: 132px;
  }

  .contact-profile-section {
    padding-inline: 18px;
  }

  .contact-file-group a {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }
}

/* Searchable file library */
.file-filter-bar { display: grid; grid-template-columns: minmax(240px, 1.8fr) repeat(4, minmax(130px, .8fr)) auto; gap: 8px; align-items: center; margin-bottom: 10px; }
.file-filter-bar select, .file-filter-bar > button, .file-search-box, .file-filter-combobox { min-height: 40px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; }
.file-filter-bar select { min-width: 0; padding: 0 10px; }
.file-filter-bar > button { padding: 0 13px; color: var(--primary-strong); cursor: pointer; font-size: 12px; font-weight: 800; }
.file-search-box { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 7px; align-items: center; padding: 0 11px; }
.file-search-box:focus-within { border-color: oklch(65% .12 175); box-shadow: 0 0 0 3px oklch(84% .07 175 / .42); }
.file-search-box svg { width: 18px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 2; }
.file-search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; }
.file-result-summary { margin: 0 2px 8px; color: var(--muted); font-size: 12px; }
.file-result-summary strong { color: var(--ink); }
.file-inbox-shell { overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-tight); }
.file-inbox-row { width: 100%; min-width: 0; display: grid; grid-template-columns: 34px minmax(190px, 1.7fr) minmax(150px, 1fr) minmax(110px, .8fr) minmax(90px, .8fr) minmax(72px, .5fr) minmax(70px, auto); gap: 10px; align-items: center; border: 0; border-bottom: 1px solid var(--border); padding: 8px 11px; background: oklch(98% .008 245); color: inherit; cursor: pointer; font: inherit; text-align: left; }
.file-inbox-row:nth-child(even) { background: var(--surface); }
.file-inbox-row:last-child { border-bottom: 0; }
.file-inbox-row:hover, .file-inbox-row:focus-visible { background: oklch(94% .025 245); outline: none; }
.file-type-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: oklch(92% .03 245); color: oklch(42% .1 245); font-size: 12px; font-weight: 900; }
.file-type-icon.type-pdf { background: oklch(94% .035 25); color: oklch(50% .16 25); }
.file-type-icon.type-image { background: oklch(94% .045 155); color: oklch(44% .12 155); }
.file-type-icon.type-video, .file-type-icon.type-audio { background: oklch(94% .045 305); color: oklch(46% .12 305); }
.file-type-icon.type-sheet { background: oklch(94% .045 145); color: oklch(43% .12 145); }
.file-type-icon.type-archive { background: oklch(94% .045 75); color: oklch(46% .12 75); }
.file-inbox-name, .file-inbox-source { min-width: 0; display: grid; gap: 2px; }
.file-inbox-name strong, .file-inbox-name small, .file-inbox-source strong, .file-inbox-source small, .file-inbox-client, .file-inbox-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-inbox-name strong { font-size: 13px; }
.file-inbox-name small, .file-inbox-source small, .file-inbox-client, .file-inbox-type, .file-inbox-tags small, .file-inbox-row time { color: var(--muted); font-size: 11px; }
.file-inbox-source strong { font-size: 12px; }
.file-inbox-tags { min-width: 0; display: flex; gap: 4px; overflow: hidden; }
.file-inbox-tags i { display: inline-flex; flex: 0 1 auto; overflow: hidden; border: 1px solid color-mix(in oklch, var(--tag-color) 55%, transparent); border-radius: 999px; padding: 2px 7px; background: color-mix(in oklch, var(--tag-color) 10%, white); color: var(--tag-color); font-style: normal; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.file-inbox-row time { text-align: right; white-space: nowrap; }
.file-filter-combobox { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.file-filter-combobox > input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 0 10px; background: transparent; color: inherit; font: inherit; }
.file-filter-combobox > button { border: 0; padding: 0 10px; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }
.file-filter-options { position: absolute; z-index: 30; top: calc(100% + 5px); left: 0; right: 0; max-height: 250px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 5px; background: var(--surface); box-shadow: 0 16px 44px oklch(20% .025 245 / .18); }
.file-filter-options button, .file-filter-options span { width: 100%; display: block; border: 0; border-radius: 7px; padding: 8px; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.file-filter-options button:hover { background: var(--surface-subtle); }
.modal-backdrop { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 16px; background: oklch(15% .02 245 / .58); backdrop-filter: blur(8px); }
.file-modal-dialog { width: min(900px, 100%); height: min(820px, calc(100dvh - 32px)); overflow: hidden; border: 1px solid oklch(80% .02 245); border-radius: 20px; background: var(--surface); box-shadow: 0 32px 100px oklch(12% .03 245 / .42); }
.file-modal-head { height: 64px; display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; gap: 10px; align-items: center; border-bottom: 1px solid var(--border); padding: 0 14px; }
.file-modal-head > div { min-width: 0; display: grid; gap: 2px; text-align: center; }
.file-modal-head strong, .file-modal-head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-modal-head small { color: var(--muted); font-size: 11px; }
.file-modal-body { height: calc(100% - 64px); display: grid; grid-template-rows: minmax(0, 1fr) auto; background: linear-gradient(145deg, oklch(20% .03 245), oklch(13% .02 245)); }
.file-modal-preview { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 22px; }
.file-modal-preview img, .file-modal-preview video { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; box-shadow: 0 16px 60px #0008; }
.file-modal-preview audio { width: min(560px, 100%); }
.file-modal-preview iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: white; }
.file-modal-fallback { display: grid; justify-items: center; gap: 12px; color: white; }
.file-modal-fallback > span { width: 92px; height: 92px; display: grid; place-items: center; border-radius: 24px; background: oklch(70% .14 175); font-size: 38px; font-weight: 900; }
.file-modal-fallback a { color: oklch(88% .1 175); }
.file-modal-meta { border-top: 1px solid var(--border); padding: 16px 20px; background: var(--surface); }
.file-modal-meta > div { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 12px; padding: 5px 0; }
.file-modal-meta span { color: var(--muted); font-size: 12px; }
.file-modal-meta form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .45fr) auto; gap: 12px; align-items: end; }
.file-modal-meta form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.file-modal-meta input, .file-modal-meta select { min-height: 40px; border: 1px solid var(--border); border-radius: 9px; padding: 0 10px; background: var(--surface); color: var(--ink); font: inherit; }
.file-modal-meta form > div { display: flex; gap: 7px; }
.whatsapp-media-preview { width: min(720px, 100%); height: min(760px, calc(100dvh - 32px)); display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; overflow: hidden; border: 1px solid oklch(78% .02 175); border-radius: 20px; background: oklch(17% .025 245); box-shadow: 0 30px 100px #0008; }
.whatsapp-media-preview header { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; padding: 0 12px; color: white; text-align: center; }
.whatsapp-media-preview header button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: white; cursor: pointer; font-size: 28px; }
.whatsapp-media-stage { min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 20px; }
.whatsapp-media-stage img, .whatsapp-media-stage video { max-width: 100%; max-height: 100%; border-radius: 12px; object-fit: contain; }
.whatsapp-media-stage audio { width: min(520px, 100%); }
.whatsapp-media-preview footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 14px; background: oklch(23% .025 245); }
.whatsapp-media-preview textarea { resize: none; border: 1px solid oklch(55% .02 245); border-radius: 12px; padding: 11px; background: oklch(29% .025 245); color: white; font: inherit; }
.attachment-row:is(button) { width: 100%; border: 0; font: inherit; text-align: left; cursor: pointer; }
.message-attachment-card:is(button) { width: 100%; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@media (max-width: 820px) {
  .file-filter-bar { grid-template-columns: 1fr 1fr; }
  .file-search-box { grid-column: 1 / -1; }
  .file-inbox-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
  .file-inbox-source, .file-inbox-client, .file-inbox-tags, .file-inbox-type { display: none; }
  .file-modal-meta form { grid-template-columns: 1fr; }
}
@media (max-width: 1100px) {
  .file-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-search-box { grid-column: 1 / -1; }
  .file-inbox-row { grid-template-columns: 34px minmax(160px, 1.6fr) minmax(130px, 1fr) minmax(80px, .7fr) minmax(70px, auto); }
  .file-inbox-tags, .file-inbox-type { display: none; }
}
@media (max-width: 680px) {
  .file-filter-bar { grid-template-columns: 1fr; }
  .file-search-box { grid-column: auto; }
  .file-inbox-row { grid-template-columns: 32px minmax(0, 1fr) minmax(65px, auto); gap: 8px; }
  .file-inbox-source { grid-column: 2; }
  .file-inbox-client { display: none; }
  .file-inbox-row time { grid-column: 3; grid-row: 1; }
}

/* Operations home */
.home-eyebrow { color: oklch(52% .13 190); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.admin-home { display: grid; gap: 18px; }
.admin-hero { min-height: 220px; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; overflow: hidden; position: relative; border-radius: 24px; padding: 34px; background: linear-gradient(125deg, oklch(20% .05 248), oklch(30% .09 210)); color: white; box-shadow: 0 24px 70px rgb(15 23 42 / .2); }
.admin-hero::after { content: ""; position: absolute; width: 360px; height: 360px; right: -100px; top: -180px; border: 55px solid oklch(76% .14 177 / .22); border-radius: 50%; }
.admin-hero > * { position: relative; z-index: 1; }
.admin-hero h1 { max-width: 700px; margin: 9px 0 10px; font-family: "Aptos Display", "Segoe UI", sans-serif; font-size: clamp(32px, 4vw, 54px); letter-spacing: -.04em; }
.admin-hero p { max-width: 680px; margin: 0; color: rgb(255 255 255 / .7); font-size: 16px; }
.admin-live { min-width: 210px; display: flex; gap: 11px; align-items: center; border: 1px solid rgb(255 255 255 / .16); border-radius: 16px; padding: 14px 16px; background: rgb(255 255 255 / .09); backdrop-filter: blur(12px); }
.admin-live div { display: grid; gap: 3px; }.admin-live small { color: rgb(255 255 255 / .62); }
.admin-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.admin-summary { display: grid; gap: 7px; position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 18px; padding: 20px; background: white; box-shadow: var(--shadow-tight); }
.admin-summary::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--tone); }
.admin-summary > span { color: var(--muted); font-size: 12px; font-weight: 800; }.admin-summary > strong { font-size: 30px; letter-spacing: -.04em; }.admin-summary > small { color: var(--ink-soft); }
.tone-blue { --tone: oklch(57% .15 245); }.tone-green { --tone: oklch(59% .14 165); }.tone-violet { --tone: oklch(58% .15 305); }.tone-orange { --tone: oklch(68% .15 65); }
.admin-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); gap: 18px; }
.admin-panel { border: 1px solid var(--border); border-radius: 20px; padding: 22px; background: white; box-shadow: var(--shadow-tight); }
.admin-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }.admin-panel h2 { margin: 5px 0 0; font-family: "Aptos Display", "Segoe UI", sans-serif; font-size: 22px; }
.panel-note { border-radius: 999px; padding: 6px 10px; background: var(--surface-subtle); color: var(--muted); font-size: 11px; font-weight: 850; }
.staff-bars { display: grid; gap: 15px; }.staff-bar { display: grid; grid-template-columns: minmax(150px, .75fr) minmax(180px, 1.4fr) 70px; gap: 14px; align-items: center; }.staff-bar > div:first-child { min-width: 0; display: flex; align-items: center; gap: 8px; }.staff-bar > div strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }.staff-bar > b { text-align: right; font-size: 12px; }
.presence-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: oklch(70% .02 245); box-shadow: 0 0 0 4px oklch(92% .01 245); }.presence-dot.online { background: oklch(62% .17 155); box-shadow: 0 0 0 4px oklch(92% .05 155); }
.staff-bar-track { height: 10px; overflow: hidden; border-radius: 999px; background: oklch(94% .014 245); }.staff-bar-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, oklch(62% .15 190), oklch(61% .15 155)); }
.admin-donut-wrap { display: flex; align-items: center; justify-content: center; gap: 28px; min-height: 180px; }.admin-donut { --clients: 0%; width: 150px; aspect-ratio: 1; display: grid; place-content: center; position: relative; border-radius: 50%; background: conic-gradient(oklch(58% .15 165) var(--clients), oklch(88% .08 65) 0); }.admin-donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: white; }.admin-donut strong,.admin-donut span { position: relative; z-index: 1; text-align: center; }.admin-donut strong { font-size: 30px; }.admin-donut span { color: var(--muted); font-size: 11px; }
.chart-legend { display: grid; gap: 11px; }.chart-legend > span { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }.chart-legend i { width: 9px; height: 9px; border-radius: 3px; }.chart-legend i.wa { background: oklch(58% .15 165); }.chart-legend i.mail { background: oklch(70% .14 65); }.chart-legend i.linked { background: oklch(58% .15 245); }.chart-legend strong { color: var(--ink); }
.response-columns { height: 245px; display: flex; align-items: stretch; gap: 18px; overflow-x: auto; padding: 4px 4px 0; }.response-column { min-width: 78px; flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 5px; text-align: center; }.response-column-bars { min-height: 150px; display: flex; align-items: flex-end; justify-content: center; gap: 6px; border-bottom: 1px solid var(--border); }.response-column-bars span { width: 20px; min-height: 4px; border-radius: 6px 6px 0 0; }.response-column-bars .wa { background: oklch(60% .15 165); }.response-column-bars .mail { background: oklch(66% .15 245); }.response-column > strong { font-size: 12px; }.response-column > small { color: var(--muted); font-size: 10px; }
.admin-table-wrap { overflow-x: auto; }.admin-staff-table { width: 100%; border-collapse: collapse; }.admin-staff-table th { color: var(--muted); font-size: 10px; letter-spacing: .05em; text-align: left; text-transform: uppercase; }.admin-staff-table th,.admin-staff-table td { border-bottom: 1px solid var(--border); padding: 12px 10px; white-space: nowrap; }.admin-staff-table td { font-size: 12px; }.admin-staff-table td:first-child { display: grid; gap: 2px; }.admin-staff-table td small { color: var(--muted); }.status-pill { display: inline-flex; border-radius: 999px; padding: 5px 8px; background: var(--surface-subtle); color: var(--muted); font-size: 10px; font-weight: 850; }.status-pill.online { background: oklch(94% .05 155); color: oklch(43% .12 155); }
@media (max-width: 1100px) { .admin-summary-grid { grid-template-columns: repeat(2, 1fr); }.admin-dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .admin-hero { align-items: flex-start; flex-direction: column; padding: 24px; }.admin-summary-grid { grid-template-columns: 1fr; }.staff-bar { grid-template-columns: minmax(110px, .8fr) 1fr 58px; }.admin-donut-wrap { flex-direction: column; } }
