:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-strong: #fdfefe;
  --surface-warm: #fff8f2;
  --text: #101828;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #e8f0ff;
  --primary-rgb: 29, 78, 216;
  --accent-rgb: 15, 118, 110;
  --sidebar-bg: #111827;
  --sidebar-bg-start: #0f172a;
  --sidebar-bg-mid: #111827;
  --sidebar-bg-end: #101827;
  --sidebar-border: #1f2937;
  --sidebar-text: #d0d7e2;
  --sidebar-active: #243145;
  --success: #067647;
  --danger: #b42318;
  --radius-lg: 12px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 28px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(
      circle at top left,
      rgba(var(--primary-rgb), 0.09),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(var(--accent-rgb), 0.08),
      transparent 24%
    ),
    linear-gradient(180deg, #f6f8fc 0%, #eef3f8 100%);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--text);
}

.small {
  font-size: 0.84rem;
  color: var(--muted);
}

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

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(
      circle at top,
      rgba(var(--primary-rgb), 0.16),
      transparent 30%
    ),
    linear-gradient(
      180deg,
      var(--sidebar-bg-start) 0%,
      var(--sidebar-bg-mid) 46%,
      var(--sidebar-bg-end) 100%
    );
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
  overflow-x: hidden;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #f5f8fd;
  text-decoration: none;
  margin-bottom: 10px;
}

.app-brand:hover {
  text-decoration: none;
}

.app-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--primary-hover), var(--primary));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 18px rgba(var(--primary-rgb), 0.22);
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.app-brand-mark-logo {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.22);
  overflow: hidden;
}

.app-brand-mark-logo img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.app-brand-text {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
}

.app-nav-link {
  color: var(--sidebar-text);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition:
    background-color 120ms ease,
    color 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.app-nav-link:hover {
  text-decoration: none;
  color: #ffffff;
  background: rgba(31, 41, 55, 0.74);
  border-color: rgba(148, 163, 184, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.app-nav-link.is-active {
  color: #ffffff;
  background: linear-gradient(
    180deg,
    rgba(var(--primary-rgb), 0.32),
    rgba(var(--primary-rgb), 0.2)
  );
  border-color: rgba(var(--primary-rgb), 0.46);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.app-sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #223047;
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(246, 248, 252, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(228, 231, 236, 0.86);
  padding: 14px 24px;
}

.topbar-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.topbar-user {
  margin-top: 3px;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.topbar-status {
  display: flex;
  align-items: center;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--primary-rgb), 0.24);
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(var(--primary-rgb), 0.12);
}

.app-content {
  padding: 22px;
}

.page-stack {
  display: grid;
  gap: 16px;
}

.inbox-page .app-main {
  height: 100vh;
  overflow: hidden;
}

.inbox-page .app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

.inbox-page .page-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}

.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-layout {
  width: min(940px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  background: var(--surface);
  border: 1px solid rgba(228, 231, 236, 0.9);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(16, 24, 40, 0.14);
}

.auth-hero {
  padding: 38px;
  background:
    radial-gradient(
      circle at top left,
      rgba(37, 99, 235, 0.14),
      transparent 34%
    ),
    linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  border-right: 1px solid var(--border);
  color: var(--text);
}

.auth-hero h1 {
  font-size: 1.6rem;
  line-height: 1.3;
  margin-bottom: 12px;
}

.auth-panel {
  padding: 34px 30px;
}

.auth-panel h2 {
  margin-bottom: 4px;
}

.flash-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  gap: 10px;
}

.flash-list li {
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.88rem;
  border: 1px solid transparent;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.05);
}

.flash-success {
  background: #ecfdf3;
  color: #05603a;
  border-color: #abefc6;
}

.flash-error {
  background: #fef3f2;
  color: #912018;
  border-color: #fecdca;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  border-radius: 22px;
  background:
    radial-gradient(
      circle at top left,
      rgba(37, 99, 235, 0.08),
      transparent 24%
    ),
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.98),
      rgba(248, 250, 252, 0.98)
    );
  box-shadow: 0 16px 34px rgba(16, 24, 40, 0.06);
  margin-bottom: 0;
}

.page-header h1 {
  margin: 0;
  font-size: 1.65rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 62ch;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.page-actions form {
  margin: 0;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid rgba(228, 231, 236, 0.92);
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(16, 24, 40, 0.05);
  padding: 18px;
  margin-bottom: 0;
}

.panel-title {
  margin: 0 0 6px;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.panel-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.section-stack {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.kpi {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(248, 250, 252, 0.98)
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.kpi-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  margin-top: 8px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: #fff;
}

.error-summary-cell {
  display: grid;
  gap: 4px;
}

.error-summary-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

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

tbody tr:hover {
  background: #fafcff;
}

form p {
  margin: 0 0 11px;
}

label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 5px;
}

input,
select,
textarea,
button {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.9rem;
  font-family: inherit;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.form-stack > p {
  display: grid;
  gap: 7px;
  margin: 0;
}

.form-stack > p label {
  margin-bottom: 0;
}

.form-stack > p .helptext {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.form-stack ul.errorlist {
  list-style: none;
  padding: 8px 10px;
  margin: 0;
  display: grid;
  gap: 4px;
  border-radius: 12px;
  border: 1px solid #fecdca;
  background: #fef3f2;
  color: #912018;
  font-size: 0.81rem;
}

.form-stack > .small {
  margin-top: -6px;
}

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

.form-actions button,
.form-actions .button-link {
  width: auto;
  min-width: 140px;
}

.form-shell {
  max-width: 920px;
}

.form-shell-narrow {
  max-width: 760px;
}

.content-grid {
  display: grid;
  gap: 16px;
}

.content-grid-aside {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.8fr);
  align-items: start;
}

.info-banner {
  border: 1px solid #dbe7ff;
  border-radius: 18px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7ff 100%);
  color: #1d2939;
}

.info-banner strong {
  display: inline-block;
  margin-bottom: 4px;
}

.info-banner-warm {
  border-color: #f8d7c8;
  background: linear-gradient(180deg, #fff9f6 0%, #fff5ef 100%);
}

.info-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.meta-item {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(180deg, #fff 0%, #fafcff 100%);
}

.meta-item-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}

.meta-item-value {
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.action-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.action-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.05);
}

.action-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.status-boolean {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-boolean::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(16, 24, 40, 0.06);
}

.status-boolean.is-true {
  background: #ecfdf3;
  color: #067647;
}

.status-boolean.is-false {
  background: #fef3f2;
  color: #b42318;
}

.auth-hero-list {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.auth-hero-list li {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.58);
}

.auth-hero-list strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.auth-hero-list span {
  color: var(--muted);
  font-size: 0.84rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(29, 78, 216, 0.15);
  border-color: #93b4ff;
}

button,
.button-link {
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
}

button:hover,
.button-link:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

button.button-danger,
.button-link.button-danger {
  background: #b42318;
  border-color: #912018;
  color: #fff;
}

button.button-danger:hover,
.button-link.button-danger:hover {
  background: #912018;
}

.button-link {
  display: inline-flex;
  width: auto;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}

.table-action-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 12px;
  border: 1px solid #d6e4ff;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: #1d4ed8;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.08);
}

.table-action-link::after {
  content: ">";
  font-size: 0.72rem;
  line-height: 1;
  opacity: 0.78;
}

.table-action-link:hover {
  text-decoration: none;
  background: #ffffff;
  border-color: #93b4ff;
  box-shadow: 0 10px 22px rgba(29, 78, 216, 0.12);
}

.table-action-link.table-action-link-danger {
  border-color: #fecaca;
  background: linear-gradient(180deg, #ffffff 0%, #fff5f5 100%);
  color: #b42318;
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.12);
}

.table-action-link.table-action-link-danger:hover {
  border-color: #fca5a5;
  color: #912018;
  box-shadow: 0 10px 20px rgba(180, 35, 24, 0.18);
}

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

.table-inline-form {
  margin: 0;
}

.table-inline-form button {
  width: auto;
}

.button-secondary {
  background: #344054;
}

.button-secondary:hover {
  background: #1d2939;
}

.ghost-button {
  border: 1px solid #344054;
  background: transparent;
  color: #d0d7e2;
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-weight: 600;
}

.ghost-button:hover {
  background: #1f2937;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.inline-form button {
  width: auto;
  min-width: 100px;
}

.inline-switch-stack {
  display: grid;
  gap: 8px;
}

.inline-switch-stack .admin-switch-ui {
  margin-bottom: 0;
}

.inline-switch-stack .admin-switch-title {
  font-size: 0.84rem;
}

.form-error-list,
.field-error-list {
  display: grid;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid #fecdca;
  background: #fef3f2;
  color: #912018;
  padding: 9px 11px;
  font-size: 0.82rem;
}

.field-error-list {
  margin-top: 7px;
  padding: 8px 10px;
}

.field-help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.status-pill,
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.76rem;
  font-weight: 600;
  background: #eef4ff;
  color: #1e3a8a;
}

.chip-muted {
  background: #f2f4f7;
  color: #475467;
}

.empty-state {
  border: 1px dashed #d0d5dd;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
  padding: 22px;
}

.pre-block {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  padding: 11px;
  white-space: pre-wrap;
  font-size: 0.84rem;
  overflow: auto;
}

.messenger {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr) minmax(
      280px,
      320px
    );
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.inbox-page .messenger {
  flex: 1;
  min-height: 0;
  height: auto;
}

.messenger-list,
.thread-panel,
.details-panel {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messenger-list {
  padding: 14px;
  gap: 12px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.92),
    rgba(248, 250, 252, 0.98)
  );
}

.messenger-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.messenger-list-header h2 {
  margin: 0;
  font-size: 1.14rem;
  letter-spacing: -0.02em;
}

.messenger-filter {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.conversation-list {
  margin-top: 2px;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.conversation-card {
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 18px;
  padding: 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.04);
}

.conversation-card:hover {
  text-decoration: none;
  border-color: #c8d5ea;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(16, 24, 40, 0.07);
}

.conversation-card.is-active {
  border-color: #93b4ff;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
  box-shadow: 0 18px 30px rgba(29, 78, 216, 0.08);
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  color: #1d4ed8;
  font-weight: 700;
  font-size: 0.82rem;
}

.conversation-main {
  min-width: 0;
}

.conversation-top,
.conversation-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conversation-title {
  margin: 0;
  font-size: 0.89rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-preview {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 0 6px;
}

.thread-panel {
  padding: 0;
  overflow: hidden;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96),
    rgba(248, 250, 252, 0.98)
  );
}

.thread-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.96);
}

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

.thread-header-actions form {
  margin: 0;
}

.thread-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.thread-subtitle {
  margin-top: 3px;
}

.thread-messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(
      circle at top left,
      rgba(37, 99, 235, 0.05),
      transparent 24%
    ),
    linear-gradient(180deg, #fbfcfe 0%, #f7f9fc 100%);
}

.message-row {
  display: flex;
}

.message-row.inbound {
  justify-content: flex-start;
}

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

.message-row.system {
  justify-content: center;
}

.message-bubble {
  max-width: min(64%, 540px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 9px 11px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.04);
}

.message-row.outbound .message-bubble {
  background: linear-gradient(180deg, #f5f8ff 0%, #ebf2ff 100%);
  border-color: #cad8ff;
}

.message-row.system .message-bubble {
  background: #f2f4f7;
  border-color: #e4e7ec;
}

.message-text {
  white-space: pre-line;
  word-break: break-word;
  font-size: 0.87rem;
  line-height: 1.35;
}

.message-meta {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.message-status {
  display: inline-flex;
  align-items: center;
}

.message-warning-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #fecdca;
  background: #fff6f5;
  color: #b42318;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.message-warning-indicator-icon {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #b42318;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

.thread-error-modal {
  width: min(440px, calc(100vw - 28px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.thread-error-modal::backdrop {
  background: rgba(16, 24, 40, 0.5);
  backdrop-filter: blur(2px);
}

.thread-error-modal-card {
  position: relative;
  overflow: hidden;
  border-radius: inherit;
  border: 1px solid #f8d5c8;
  background: linear-gradient(180deg, #fff9f6 0%, #ffffff 36%);
  box-shadow: 0 26px 70px rgba(16, 24, 40, 0.22);
}

.thread-error-modal-card::before {
  content: "";
  display: block;
  height: 5px;
  background: linear-gradient(90deg, #f97316 0%, #dc2626 100%);
}

.thread-error-modal-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 24px 24px 18px;
}

.thread-error-modal-icon-wrap {
  padding-top: 2px;
}

.thread-error-modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ef4444, #c2410c);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(194, 65, 12, 0.24);
}

.thread-error-modal-copy {
  min-width: 0;
}

.thread-error-modal-eyebrow {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #c2410c;
}

.thread-error-modal-title {
  margin: 8px 0 0;
  font-size: 1.12rem;
  line-height: 1.25;
  color: #7c2d12;
  letter-spacing: -0.01em;
}

.thread-error-modal-body {
  margin: 10px 0 0;
  max-width: 32ch;
  color: #7a3b12;
  font-size: 0.92rem;
  line-height: 1.5;
}

.thread-error-modal-actions {
  padding: 16px 24px 24px;
  border-top: 1px solid #f6e7de;
  justify-content: flex-end;
  background: rgba(255, 255, 255, 0.92);
}

.thread-error-modal-actions button {
  min-width: 104px;
  border-radius: 12px;
  padding-inline: 18px;
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.16);
}

.message-error {
  margin-top: 4px;
  color: var(--danger);
  font-size: 0.78rem;
}

.message-error-card {
  margin-top: 8px;
  border: 1px solid #fecdca;
  border-radius: 10px;
  background: #fef3f2;
  padding: 8px 9px;
}

.message-error-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.message-error-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #912018;
}

.error-code-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #fff;
  color: #912018;
  border: 1px solid #fda29b;
  white-space: nowrap;
}

.error-help-text {
  margin-top: 4px;
  color: #7a271a;
  font-size: 0.76rem;
  line-height: 1.35;
}

.message-error-link {
  display: inline-flex;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}

.message-error-details {
  margin-top: 6px;
}

.message-error-details-list {
  margin-top: 6px;
  display: grid;
  gap: 8px;
}

.message-error-detail-item {
  border-top: 1px solid #fecdca;
  padding-top: 6px;
}

.message-template-header {
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.message-template-footer {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.3;
}

.message-actions-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.message-action-chip {
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.82rem;
  line-height: 1.3;
  background: #ffffff;
}

.message-list-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 2px;
}

.message-media-card {
  border: 1px solid #d0d5dd;
  border-radius: 10px;
  padding: 8px 10px;
  background: #ffffff;
}

.message-row.outbound .message-media-card {
  background: #f8fbff;
  border-color: #bfd2ff;
}

.message-media-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #475467;
}

.message-media-file {
  margin-top: 5px;
  font-size: 0.84rem;
  line-height: 1.35;
  word-break: break-word;
}

.message-media-preview-link {
  display: block;
  margin-top: 8px;
}

.message-media-preview-link:hover {
  text-decoration: none;
}

.message-media-preview,
.message-video-player {
  display: block;
  width: min(100%, 280px);
  max-height: 280px;
  border-radius: 8px;
  background: #0f172a;
  object-fit: cover;
}

.message-audio-player {
  display: block;
  width: min(100%, 280px);
  margin-top: 8px;
}

.message-media-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.message-media-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 74px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #344054;
  font-size: 0.8rem;
  font-weight: 600;
}

.message-media-link:hover {
  text-decoration: none;
  background: #f8fafc;
}

.thread-composer {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  background: rgba(255, 255, 255, 0.98);
}

.thread-composer textarea {
  min-height: 36px;
  max-height: 180px;
  overflow-y: hidden;
  resize: none;
}

.thread-composer button {
  width: auto;
  min-width: 96px;
}

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

.composer-actions button {
  width: auto;
  min-width: 74px;
}

.composer-actions .icon-button {
  min-width: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.composer-actions .icon-button svg {
  width: 18px;
  height: 18px;
}

.composer-actions .is-recording {
  background: #b42318;
}

.composer-actions .is-recording:hover {
  background: #912018;
}

.details-panel {
  padding: 12px;
  gap: 12px;
  overflow: auto;
}

.details-panel section {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(228, 231, 236, 0.92);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 12px 24px rgba(16, 24, 40, 0.04);
}

.details-panel h3,
.details-panel h4 {
  margin: 0 0 7px;
}

.details-list {
  display: grid;
  gap: 6px;
  font-size: 0.84rem;
}

.details-list div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

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

.note-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #fff;
}

.note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.note-delete-form {
  margin: 0;
}

.note-delete-btn {
  width: auto;
  min-width: 68px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

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

.advanced-tool-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.interactive-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: start;
}

#rowsContainer .interactive-item-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.interactive-item-row button {
  width: auto;
}

.app-modal {
  width: min(760px, 92vw);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  background: #fff;
  color: var(--text);
}

.app-modal::backdrop {
  background: rgba(16, 24, 40, 0.45);
}

.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.app-modal-header h4 {
  margin: 0;
}

.app-modal-close {
  width: auto;
  min-width: 34px;
  padding: 6px 9px;
  line-height: 1;
  font-size: 1rem;
}

.app-modal-body {
  padding: 12px;
}

.app-modal-body-bottom-space {
  padding-bottom: 20px;
}

.app-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.interactive-modal-actions {
  margin-top: 14px;
}

.app-modal-actions button {
  width: auto;
}

details summary {
  cursor: pointer;
  color: #344054;
}

.panel-tight {
  margin-bottom: 0;
}

.panel-heading-tight {
  margin: 0 0 8px;
}

.admin-user-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 12px;
  align-items: start;
}

.admin-user-layout-single {
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
}

.admin-user-main,
.admin-user-sidebar,
.admin-number-stack,
.admin-form-stack {
  display: grid;
  gap: 12px;
}

.admin-section-card,
.admin-summary-card,
.admin-summary-hero,
.admin-number-card {
  margin-bottom: 0;
}

.admin-section-head,
.admin-subcard-head,
.admin-number-head,
.admin-summary-hero-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-section-head {
  margin-bottom: 12px;
}

.admin-subcard-head {
  margin-bottom: 10px;
}

.admin-subcard-head h3,
.admin-summary-hero-main h2,
.admin-number-head h2 {
  margin: 0;
}

.admin-summary-eyebrow {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
}

.admin-summary-name {
  margin: 6px 0 0;
  font-size: 1.4rem;
}

.admin-summary-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-form-field {
  min-width: 0;
}

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

.theme-preview-inline {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.theme-preview-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.theme-preview-chip {
  width: 30px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(16, 24, 40, 0.16);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
  background: linear-gradient(120deg, #1d4ed8, #0f766e);
}

.theme-preview-chip-ocean {
  background: linear-gradient(120deg, #1d4ed8, #0f766e);
}

.theme-preview-chip-emerald {
  background: linear-gradient(120deg, #0f766e, #0891b2);
}

.theme-preview-chip-amber {
  background: linear-gradient(120deg, #b45309, #f59e0b);
}

.theme-preview-chip-orange {
  background: linear-gradient(120deg, #f0531e, #fb923c);
}

.theme-preview-chip-rose {
  background: linear-gradient(120deg, #be185d, #db2777);
}

.admin-form-field-checkbox {
  grid-column: span 2;
  border: 1px solid rgba(228, 231, 236, 0.92);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 14px 16px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.04);
}

.admin-checkbox-input {
  min-width: 0;
}

.admin-switch-wrap {
  position: relative;
}

.admin-switch-wrap input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.admin-switch-ui {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  cursor: pointer;
  margin-bottom: 0;
}

.admin-switch-track {
  width: 58px;
  height: 34px;
  border-radius: 999px;
  background: #d0d5dd;
  padding: 4px;
  box-shadow: inset 0 2px 6px rgba(16, 24, 40, 0.12);
  transition:
    background-color 140ms ease,
    box-shadow 140ms ease;
}

.admin-switch-thumb {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 6px 12px rgba(16, 24, 40, 0.16);
  transition: transform 140ms ease;
}

.admin-switch-wrap
  input[type="checkbox"]:checked
  + .admin-switch-ui
  .admin-switch-track {
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
}

.admin-switch-wrap
  input[type="checkbox"]:checked
  + .admin-switch-ui
  .admin-switch-thumb {
  transform: translateX(24px);
}

.admin-switch-wrap
  input[type="checkbox"]:focus
  + .admin-switch-ui
  .admin-switch-track,
.admin-switch-wrap
  input[type="checkbox"]:focus-visible
  + .admin-switch-ui
  .admin-switch-track {
  box-shadow:
    0 0 0 4px rgba(29, 78, 216, 0.14),
    inset 0 2px 6px rgba(16, 24, 40, 0.12);
}

.admin-switch-copy {
  min-width: 0;
}

.admin-switch-title {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text);
}

.admin-switch-description {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

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

.admin-form-actions button,
.admin-form-actions .button-link {
  width: auto;
  min-width: 140px;
}

.admin-number-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-number-head-actions {
  display: inline-flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
}

.admin-inline-delete-form {
  margin: 0;
}

.button-compact {
  width: auto;
  min-width: 88px;
  padding: 7px 12px;
  font-size: 0.78rem;
}

.admin-number-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-muted);
  margin-bottom: 12px;
}

.admin-number-meta div {
  display: grid;
  gap: 4px;
}

.admin-number-meta span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.admin-number-meta strong {
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
}

.admin-subcard {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  padding: 12px;
}

.admin-note-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.empty-state-spaced {
  margin: 14px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-10 {
  margin-top: 10px;
}

.mb-12 {
  margin-bottom: 12px;
}

@media (max-width: 1240px) {
  .messenger {
    grid-template-columns: minmax(270px, 310px) minmax(0, 1fr);
  }

  .details-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

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

  .app-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .app-content {
    padding: 14px;
  }

  .app-topbar {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .inbox-page .app-main,
  .inbox-page .app-content {
    height: auto;
    overflow: visible;
  }

  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 24px;
  }

  .auth-panel {
    padding: 22px;
  }

  .messenger {
    grid-template-columns: 1fr;
    min-height: auto;
    height: auto;
  }

  .messenger-list {
    max-height: 50vh;
  }

  .thread-panel {
    min-height: 62vh;
  }

  .thread-composer {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    justify-content: stretch;
  }

  .composer-actions button {
    flex: 1;
  }

  .advanced-tool-buttons {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form button {
    width: 100%;
  }

  .content-grid-aside {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .thread-error-modal {
    width: min(100vw - 24px, 440px);
  }

  .thread-error-modal-actions {
    justify-content: stretch;
  }

  .thread-error-modal-actions button {
    width: 100%;
  }

  .admin-user-layout,
  .admin-user-layout-single {
    grid-template-columns: 1fr;
  }

  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-form-field-span-2,
  .admin-form-field-checkbox {
    grid-column: span 1;
  }

  .admin-section-head,
  .admin-subcard-head,
  .admin-number-head,
  .admin-summary-hero-main {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-form-actions button,
  .admin-form-actions .button-link {
    width: 100%;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions button,
  .form-actions .button-link {
    width: 100%;
  }
}
