:root {
  --navy: #101827;
  --navy-soft: #192437;
  --blue: #1677ff;
  --blue-dark: #0868e8;
  --blue-soft: #eaf3ff;
  --ink: #172033;
  --muted: #6e7787;
  --line: #e5e8ee;
  --surface: #ffffff;
  --canvas: #f4f6f9;
  --danger: #d94242;
  --shadow: 0 18px 50px rgba(26, 39, 65, 0.14);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
a,
input,
textarea,
select {
  outline-color: var(--blue);
}

button {
  cursor: pointer;
}

.app-body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

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

.sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 18px 12px 14px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 0%, rgba(42, 120, 255, 0.22), transparent 30%),
    var(--navy);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 0 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.brand-logo {
  display: block;
  width: 165px;
  height: auto;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
}

.brand-product {
  align-self: flex-end;
  margin: 0 0 5px 6px;
  color: #9ab3d8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.primary-nav {
  flex: 1;
  padding-top: 16px;
  overflow-y: auto;
}

.nav-section + .nav-section {
  margin-top: 10px;
}

.nav-section-title {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  color: #b9c5d7;
  background: transparent;
  border: 0;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-align: left;
  text-transform: uppercase;
}

.nav-section-title:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: #79aaff;
  font-size: 13px;
}

.nav-chevron {
  transition: transform 0.2s ease;
}

.nav-section-title.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-section-links {
  display: grid;
  gap: 3px;
  margin-top: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px 8px 40px;
  color: #c5cfdd;
  border-radius: 9px;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: var(--navy-soft);
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.sidebar-version {
  margin: 4px 12px 0 40px;
  padding-top: 10px;
  color: #74849c;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.nav-inbox {
  gap: 10px;
}

.inbox-dot {
  width: 8px;
  height: 8px;
  margin-left: -20px;
  background: #6f7f94;
  border-radius: 50%;
}

.nav-inbox.active .inbox-dot {
  background: #4f9cff;
  box-shadow: 0 0 0 4px rgba(79, 156, 255, 0.15);
}

.profile-nav {
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.profile-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border-radius: 11px;
}

.profile-card:hover,
.profile-card.active {
  background: rgba(255, 255, 255, 0.06);
}

.profile-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.profile-copy strong {
  overflow: hidden;
  color: #fff;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy small,
.logout-link {
  color: #8e9db2;
  font-size: 11px;
}

.logout-link {
  display: block;
  padding: 6px 10px 2px 50px;
}

.logout-link:hover {
  color: #fff;
}

.avatar {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, #5a9eff, #176ae1);
  border-radius: 50%;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.avatar-small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.avatar-large {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.content {
  min-width: 0;
  min-height: 0;
}

.content-messenger {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.content-page {
  height: 100vh;
  padding: 34px;
  overflow: auto;
  color: var(--ink);
  background: var(--canvas);
}

.messenger-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}

.conversation-panel {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #fbfcfe;
  border-right: 1px solid var(--line);
}

.conversation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding: 19px 20px 12px;
}

.conversation-panel-header h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 25px;
  letter-spacing: -0.04em;
}

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

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: #586274;
  background: #f1f3f7;
  border: 0;
  border-radius: 50%;
  font-weight: 800;
}

.icon-button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.primary-icon-button {
  color: #fff;
  background: var(--blue);
  font-size: 18px;
}

.primary-icon-button:hover {
  color: #fff;
  background: var(--blue-dark);
}

.conversation-search {
  display: flex;
  align-items: center;
  margin: 0 16px 12px;
  padding: 0 12px;
  color: #8992a1;
  background: #eef1f5;
  border: 1px solid transparent;
  border-radius: 10px;
}

.conversation-search:focus-within {
  background: #fff;
  border-color: #a9c9f8;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.conversation-search input {
  width: 100%;
  height: 38px;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.conversation-list {
  flex: 1;
  min-height: 0;
  padding: 0 8px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #c6ced9 transparent;
  scrollbar-width: thin;
}

.conversation-item {
  position: relative;
  border-radius: 12px;
}

.conversation-item + .conversation-item {
  margin-top: 2px;
}

.conversation-item:hover {
  background: #f0f3f8;
}

.conversation-item.selected {
  background: var(--blue-soft);
}

.conversation-link {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 11px;
  min-height: 92px;
  align-items: center;
  padding: 10px 30px 10px 10px;
}

.conversation-avatar {
  width: 44px;
  height: 44px;
  color: #35506f;
  background: linear-gradient(145deg, #e8eef7, #ccd8e8);
  font-size: 13px;
}

.conversation-item:nth-child(3n+2) .conversation-avatar {
  color: #5c456c;
  background: linear-gradient(145deg, #f1e9f7, #dfcdec);
}

.conversation-item:nth-child(3n+3) .conversation-avatar {
  color: #376050;
  background: linear-gradient(145deg, #e6f3ee, #cce4da);
}

.conversation-copy,
.conversation-line {
  min-width: 0;
}

.conversation-copy {
  display: grid;
  gap: 3px;
}

.conversation-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conversation-line strong,
.conversation-subtitle,
.conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-line strong {
  color: #222b3a;
  font-size: 14px;
}

.conversation-line time {
  flex: 0 0 auto;
  color: #9299a5;
  font-size: 10px;
}

.conversation-subtitle {
  color: #626d7e;
  font-size: 11px;
}

.conversation-preview {
  color: #8a929e;
  font-size: 12px;
}

.conversation-item.unread .conversation-line strong,
.conversation-item.unread .conversation-preview {
  color: var(--ink);
  font-weight: 700;
}

.unread-badge {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
  transform: translateY(-50%);
}

.conversation-edit {
  position: absolute;
  top: 7px;
  right: 7px;
  display: none;
  width: 25px;
  height: 25px;
  padding: 0;
  color: #7d8796;
  background: rgba(255, 255, 255, 0.85);
  border: 0;
  border-radius: 50%;
  font-size: 10px;
}

.conversation-item:hover .conversation-edit,
.conversation-edit:focus {
  display: block;
}

.conversation-item:hover .unread-badge {
  display: none;
}

.conversation-loading,
.conversation-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  color: #929aa7;
}

.conversation-empty {
  flex-direction: column;
  gap: 5px;
  padding: 24px;
  text-align: center;
}

.conversation-empty strong {
  color: #626c7b;
  font-size: 13px;
}

.conversation-empty span {
  font-size: 12px;
}

.loading-dot {
  width: 6px;
  height: 6px;
  margin: 3px;
  background: #aeb6c2;
  border-radius: 50%;
  animation: pulse 1s infinite alternate;
}

.loading-dot:nth-child(2) { animation-delay: 0.2s; }
.loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  to { opacity: 0.3; transform: translateY(-3px); }
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: #fff;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.chat-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-contact-copy {
  min-width: 0;
}

.chat-contact h2 {
  margin: 0 0 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-contact p {
  margin: 0;
  overflow: hidden;
  color: #7e8795;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  min-height: 0;
  padding: 28px clamp(22px, 5vw, 72px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #c6ced9 transparent;
  scrollbar-width: thin;
  background:
    radial-gradient(circle at 50% -20%, rgba(22, 119, 255, 0.045), transparent 32%),
    #fff;
}

.message-row {
  display: flex;
  width: 100%;
  margin: 4px 0 12px;
}

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

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

.message-stack {
  display: flex;
  max-width: min(68%, 680px);
  flex-direction: column;
}

.message-row.outgoing .message-stack {
  align-items: flex-end;
}

.message-row.incoming .message-stack {
  align-items: flex-start;
}

.message-bubble {
  padding: 9px 13px 10px;
  color: #202634;
  background: #edf0f4;
  border-radius: 18px 18px 18px 5px;
  font-size: 14px;
  line-height: 1.38;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message-row.outgoing .message-bubble {
  color: #fff;
  background: linear-gradient(180deg, #2687ff, #0875f6);
  border-radius: 18px 18px 5px 18px;
  box-shadow: 0 3px 10px rgba(19, 119, 245, 0.16);
}

.message-image {
  display: block;
  max-width: min(320px, 100%);
  max-height: 360px;
  margin-bottom: 5px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 5px 18px rgba(26, 38, 59, 0.14);
  cursor: zoom-in;
}

.expired-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 11px 13px;
  color: #697486;
  background: #f0f2f5;
  border: 1px solid #e2e5ea;
  border-radius: 13px;
}

.expired-attachment > span:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  color: #8c96a5;
  background: #fff;
  border-radius: 50%;
}

.expired-attachment > span:last-child {
  display: grid;
  gap: 2px;
}

.expired-attachment strong {
  color: #586375;
  font-size: 12px;
}

.expired-attachment small {
  color: #929aa7;
  font-size: 10px;
}

.message-time {
  margin: 4px 6px 0;
  color: #a0a7b1;
  font-size: 9px;
}

.message-empty,
.empty-chat-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: 100%;
  color: #8b94a2;
  text-align: center;
}

.message-empty span {
  color: #687282;
  font-size: 13px;
  font-weight: 700;
}

.message-empty small {
  margin-top: 4px;
  font-size: 11px;
}

.chat-panel-empty {
  display: block;
  background:
    radial-gradient(circle at 50% 42%, rgba(22, 119, 255, 0.07), transparent 22%),
    #fff;
}

.empty-chat-state h2 {
  margin: 15px 0 5px;
  color: var(--ink);
  font-size: 20px;
}

.empty-chat-state p {
  max-width: 330px;
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.5;
}

.empty-chat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 58px;
  color: #fff;
  background: linear-gradient(145deg, #57a1ff, #1677ff);
  border-radius: 28px 28px 28px 10px;
  box-shadow: 0 12px 30px rgba(22, 119, 255, 0.23);
  font-size: 24px;
  letter-spacing: 3px;
}

.composer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  padding: 12px 20px 16px;
  background: #fff;
  border-top: 1px solid #f0f1f4;
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
}

.attachment-form {
  flex: 0 0 auto;
}

.attachment-form input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.composer-action,
.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
}

.composer-action {
  color: #667184;
  background: #eef1f5;
  font-size: 23px;
  cursor: pointer;
}

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

.composer-form {
  display: flex;
  flex: 1;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.composer-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.composer-field textarea {
  display: block;
  width: 100%;
  min-height: 38px;
  max-height: 110px;
  padding: 9px 48px 8px 14px;
  resize: none;
  color: var(--ink);
  background: #f5f6f8;
  border: 1px solid #e2e5ea;
  border-radius: 19px;
  outline: 0;
  font-size: 14px;
  line-height: 19px;
}

.composer-field textarea:focus {
  background: #fff;
  border-color: #9cc5fb;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.09);
}

.countdown {
  position: absolute;
  right: 14px;
  bottom: 11px;
  color: #a1a8b2;
  font-size: 9px;
}

.countdown-low {
  color: #d9792b;
  font-weight: 700;
}

.send-button {
  flex: 0 0 auto;
  color: #fff;
  background: var(--blue);
  font-size: 20px;
  font-weight: 800;
  transition: transform 0.12s ease, background 0.12s ease;
}

.send-button:hover:not(:disabled) {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.send-button:disabled {
  color: #aab1bc;
  background: #e5e8ed;
  cursor: default;
}

.composer-status {
  min-height: 0;
  padding: 0 64px 5px;
  color: var(--danger);
  background: #fff;
  font-size: 10px;
  text-align: right;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 17px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.button-primary {
  color: #fff;
  background: var(--blue);
}

.button-primary:hover {
  color: #fff;
  background: var(--blue-dark);
}

.button-secondary {
  color: #4b5668;
  background: #eef1f5;
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 50px;
  background: rgba(7, 11, 18, 0.92);
}

.image-viewer.open {
  display: flex;
}

.image-viewer img {
  max-width: 90vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 10px;
}

.image-viewer-close {
  position: absolute;
  top: 20px;
  right: 28px;
  color: #fff;
  background: transparent;
  border: 0;
  font-size: 38px;
}

.app-modal {
  display: none;
  position: relative;
  width: min(92vw, 520px);
  padding: 0;
  overflow: visible;
  vertical-align: middle;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.app-modal iframe {
  display: block;
  width: 100%;
  height: 430px;
  border: 0;
}

.app-modal-new-message {
  width: min(94vw, 720px);
}

.app-modal-new-message iframe {
  height: min(86vh, 660px);
  min-height: min(560px, 86vh);
  border-radius: 16px;
}

.app-modal-contact {
  width: min(92vw, 470px);
}

.app-modal-contact iframe {
  height: 500px;
}

.app-modal-user {
  width: min(94vw, 620px);
}

.app-modal-user iframe {
  height: min(76vh, 690px);
  border-radius: 16px;
}

.app-modal-user-edit {
  width: min(94vw, 680px);
}

.app-modal-user-edit iframe {
  height: min(82vh, 720px);
}

.modal a.close-modal {
  top: 12px !important;
  right: 12px !important;
  z-index: 20;
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  height: 32px !important;
  color: transparent;
  background: #edf0f4 !important;
  background-image: none !important;
  border: 1px solid #dfe3e9;
  border-radius: 50%;
  box-shadow: 0 3px 9px rgba(24, 34, 52, 0.12);
  text-indent: 0 !important;
  overflow: hidden;
}

.modal a.close-modal::before {
  content: "×";
  color: #596476;
  font-size: 21px;
  font-weight: 500;
  line-height: 1;
}

.modal a.close-modal:hover {
  background: #e1e5eb !important;
}

.admin-dialog {
  display: none;
  position: relative;
  width: min(92vw, 500px);
  padding: 0;
  overflow: visible;
  vertical-align: middle;
  color: var(--ink);
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  text-align: left;
}

.admin-dialog-wide {
  width: min(94vw, 620px);
}

.admin-dialog-body {
  max-height: min(78vh, 720px);
  padding: 28px 28px 26px;
  overflow-y: auto;
  border-radius: 16px;
}

.admin-dialog-body .modal-form-header {
  padding-right: 42px;
}

.blocker {
  z-index: 1000 !important;
  background: rgba(10, 17, 28, 0.68) !important;
  backdrop-filter: blur(5px);
}

/* Forms displayed inside modal iframes */
.modal-body {
  min-height: 100vh;
  padding: 0;
  color: var(--ink);
  background: #fff;
}

.modal-form-shell {
  padding: 25px 26px 28px;
}

.modal-form-header {
  margin-bottom: 20px;
}

.modal-form-header h1 {
  margin: 0 0 5px;
  font-size: 21px;
  letter-spacing: -0.035em;
}

.modal-form-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #596476;
  font-size: 11px;
  font-weight: 750;
}

.field input,
.field textarea,
.field select,
.modal-search {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #f7f8fa;
  border: 1px solid #dfe3e9;
  border-radius: 9px;
  outline: 0;
  font-size: 13px;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.modal-search:focus {
  background: #fff;
  border-color: #9cc5fb;
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.09);
}

.field input[readonly] {
  color: #6d7787;
  background: #eef1f4;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
}

.form-actions .delete-action {
  margin-right: auto;
  color: var(--danger);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 700;
}

.contact-picker {
  max-height: 145px;
  margin-top: 12px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.contact-picker-item {
  display: block;
  width: 100%;
  padding: 9px 11px;
  color: #4f5a6b;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  text-align: left;
}

.contact-picker-item[hidden] {
  display: none;
}

.contact-picker-item:last-child {
  border-bottom: 0;
}

.contact-picker-item:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.new-message-modal-body .field textarea {
  min-height: 96px;
}

.new-message-modal-body .contact-picker {
  max-height: 180px;
}

.form-notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  color: #286344;
  background: #eaf7f0;
  border-radius: 8px;
  font-size: 12px;
}

/* Existing administration pages */
.admin-page {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.admin-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.admin-page-header h1 {
  margin: 4px 0 5px;
  color: var(--ink);
  font-size: 28px;
  letter-spacing: -0.04em;
}

.admin-page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-toolbar,
.admin-toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-search {
  position: relative;
  width: min(300px, 38vw);
}

.admin-search::before {
  content: "⌕";
  position: absolute;
  top: 50%;
  left: 12px;
  color: #8992a1;
  transform: translateY(-50%);
}

.admin-search input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 34px !important;
  background: #f7f8fa !important;
}

.admin-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(34, 48, 75, 0.06);
}

.admin-table-wrap {
  overflow-x: auto;
}

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

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

.admin-table th {
  color: #707a8a;
  background: #fafbfc;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0 !important;
}

.admin-table tbody tr:hover {
  background: #fbfdff;
}

.admin-table .cell-primary {
  color: var(--ink);
  font-weight: 700;
}

.admin-table .cell-secondary {
  display: block;
  margin-top: 3px;
  color: #8a93a1;
  font-size: 11px;
}

.admin-link-button {
  padding: 0;
  color: var(--blue);
  background: transparent !important;
  border: 0;
  font-weight: 700;
  text-align: left;
}

.admin-link-button:hover {
  color: var(--blue-dark);
}

.status-badge,
.permission-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
}

.status-badge,
.permission-badge {
  min-width: 28px;
  min-height: 25px;
  padding: 4px 8px;
}

.status-active,
.permission-yes {
  color: #277a4f;
  background: #e8f7ef;
}

.status-archived,
.permission-no {
  color: #8a6470;
  background: #f4edf0;
}

.count-badge {
  min-width: 30px;
  min-height: 30px;
  color: #516075;
  background: #eef1f5;
}

.archive-toggle,
.checkbox-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #667184;
  font-size: 12px;
  cursor: pointer;
}

.archive-toggle input,
.checkbox-card input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

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

.checkbox-card {
  min-height: 42px;
  padding: 10px 12px;
  background: #f7f8fa;
  border: 1px solid #e1e5ea;
  border-radius: 9px;
}

.admin-empty {
  padding: 50px 20px !important;
  color: #8992a1;
  text-align: center !important;
}

.admin-notice {
  margin-bottom: 16px;
  padding: 11px 14px;
  color: #286344;
  background: #eaf7f0;
  border: 1px solid #d7efe2;
  border-radius: 10px;
  font-size: 12px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 20px;
}

.profile-card-panel {
  padding: 26px;
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.profile-summary .avatar {
  width: 58px;
  height: 58px;
  font-size: 18px;
}

.profile-summary h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.profile-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.password-requirements {
  margin: 0;
  padding-left: 18px;
  color: #798394;
  font-size: 11px;
  line-height: 1.7;
}

.two-column-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.content-page center {
  display: block;
  max-width: 1100px;
  margin: 0 auto;
  padding: 25px;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(34, 48, 75, 0.06);
}

.content-page table {
  max-width: 100%;
  color: var(--ink);
  border: 0;
  border-collapse: collapse;
}

.content-page td,
.content-page th {
  padding: 8px;
  border: 0;
}

.content-page hr {
  height: 1px;
  margin: 0;
  background: var(--line);
  border: 0;
}

.content-page a {
  color: var(--blue);
}

.content-page input,
.content-page textarea,
.content-page select {
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #dce1e8;
  border-radius: 8px;
}

.content-page button,
.content-page input[type="submit"] {
  padding: 8px 13px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 8px;
  font-weight: 700;
}

/* Keep the legacy page defaults from overriding modern admin controls. */
.content-page .admin-link-button {
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-weight: 700;
}

.content-page .admin-link-button:hover,
.content-page .admin-link-button:focus {
  color: var(--blue);
  background: transparent;
}

.content-page .icon-button,
.content-page a.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  color: #667184;
  background: #eef1f5;
  border: 0;
  border-radius: 50%;
}

.content-page .icon-button:hover,
.content-page a.icon-button:hover {
  color: var(--blue);
  background: var(--blue-soft);
}

.content-page .button,
.content-page a.button {
  min-height: 38px;
  padding: 0 17px;
  border-radius: 10px;
  font-weight: 700;
}

.content-page .button-primary,
.content-page a.button-primary {
  color: #fff;
  background: var(--blue);
}

.content-page .button-primary:hover,
.content-page a.button-primary:hover {
  color: #fff;
  background: var(--blue-dark);
}

.content-page .form-actions .delete-action {
  padding: 0;
  color: var(--danger);
  background: transparent;
  border: 0;
}

.content-page .archive-toggle input,
.content-page .checkbox-card input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--blue);
}

footer {
  padding: 18px;
  color: #929aa7;
  font-size: 11px;
  text-align: center;
}

.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: linear-gradient(145deg, #0d1625, #182842);
}

/* Authentication and MFA */
.auth-page {
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding: 32px;
  background:
    radial-gradient(circle at 15% 0%, rgba(42, 120, 255, 0.22), transparent 34%),
    linear-gradient(145deg, #0d1625, #182842);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(390px, 1.22fr);
  width: min(960px, 100%);
  min-height: 580px;
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  box-shadow: 0 30px 85px rgba(0, 0, 0, 0.32);
}

.auth-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 38px;
  color: #fff;
  background:
    radial-gradient(circle at 30% 20%, rgba(66, 139, 255, 0.32), transparent 36%),
    var(--navy);
}

.auth-brand-panel div {
  display: grid;
  gap: 6px;
}

.auth-brand-panel span {
  color: #78aaff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.auth-brand-panel strong {
  max-width: 220px;
  font-size: 24px;
  line-height: 1.2;
}

.auth-logo {
  width: min(230px, 100%);
  height: auto;
  filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
}

.auth-card {
  align-self: center;
  width: 100%;
  padding: 48px 54px;
}

.auth-card-header {
  margin-bottom: 26px;
}

.auth-card-header h1 {
  margin: 6px 0 7px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.auth-card-header p,
.auth-help,
.mfa-setup-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-version {
  margin: 28px 0 0;
  color: #9aa3b1;
  font-size: 10px;
  letter-spacing: 0.02em;
  text-align: center;
}

.auth-version span {
  padding: 0 5px;
}

.auth-form {
  gap: 16px;
}

.auth-submit,
.auth-wide-button {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
}

.auth-help {
  margin-top: 18px;
  text-align: center;
}

.auth-error {
  margin-bottom: 18px;
  padding: 11px 13px;
  color: #9c3131;
  background: #fff0f0;
  border: 1px solid #f4d5d5;
  border-radius: 10px;
  font-size: 12px;
}

.auth-back-link {
  display: block;
  margin-top: 18px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.mfa-enrollment-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
  margin-bottom: 25px;
}

.mfa-qr-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 210px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(24, 34, 52, 0.08);
}

.mfa-qr-card img,
.mfa-qr-card canvas {
  display: block;
}

.mfa-setup-copy {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #596476;
  font-size: 11px;
  font-weight: 750;
}

.copy-field {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 10px;
}

.copy-field code {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  padding: 10px 11px;
  overflow-wrap: anywhere;
  color: #34445c;
  background: #f4f6f9;
  border: 1px solid #dfe3e9;
  border-radius: 9px;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.copy-field .button {
  min-height: 42px;
}

.mfa-confirm-form {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.mfa-code-input {
  font-size: 19px !important;
  font-weight: 750;
  letter-spacing: 0.18em;
  text-align: center;
}

.recovery-code-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 13px;
  padding: 16px;
  background: #f4f6f9;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.recovery-code-panel code {
  padding: 8px;
  color: #34445c;
  background: #fff;
  border: 1px solid #e0e4e9;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-align: center;
}

.mfa-status-card {
  display: grid;
  gap: 12px;
}

.mfa-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mfa-status-line strong {
  font-size: 13px;
}

.mfa-status-line > div > span {
  color: var(--muted);
  font-size: 11px;
}

.mfa-admin-reset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 24px;
  padding: 15px;
  background: #fff8f8;
  border: 1px solid #f1dada;
  border-radius: 10px;
}

.mfa-admin-reset > div {
  display: grid;
  gap: 3px;
}

.mfa-admin-reset strong {
  font-size: 12px;
}

.mfa-admin-reset span {
  color: var(--muted);
  font-size: 11px;
}

.mfa-admin-reset .delete-action {
  color: var(--danger);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 750;
}

.user-edit-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-top: 22px;
}

.user-edit-footer .mfa-admin-reset {
  margin-top: 0;
}

.user-edit-footer > .button {
  min-width: 124px;
}

.form-notice-error {
  color: #9c3131;
  background: #fff0f0;
}

.logo-glow,
.loginlogo-glow {
  filter: drop-shadow(0 5px 14px rgba(255, 255, 255, 0.18));
}

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .brand-logo { width: 132px; }
  .messenger-shell { grid-template-columns: 305px minmax(0, 1fr); }
  .message-stack { max-width: 78%; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 8px; }
  .brand-logo { width: 52px; object-fit: cover; object-position: left; }
  .brand-product,
  .nav-section-title span:not(.nav-section-icon),
  .nav-link span:not(.inbox-dot),
  .nav-section-links .nav-link:not(.nav-inbox),
  .sidebar-version,
  .profile-copy,
  .logout-link { display: none; }
  .nav-section-title { display: flex; justify-content: center; padding: 9px; }
  .nav-link { justify-content: center; padding: 9px; }
  .inbox-dot { width: 11px; height: 11px; margin: 0; }
  .profile-card { justify-content: center; }
  .messenger-shell { grid-template-columns: minmax(250px, 39%) minmax(0, 1fr); }
  .conversation-panel-header { padding-inline: 13px; }
  .conversation-panel-header h1 { font-size: 21px; }
  .conversation-search { margin-inline: 10px; }
  .messages { padding-inline: 15px; }
  .message-stack { max-width: 88%; }
  .admin-page-header { align-items: flex-start; flex-direction: column; }
  .admin-toolbar { align-items: stretch; flex-direction: column; }
  .admin-toolbar-group { flex-wrap: wrap; }
  .admin-search { width: 100%; }
  .profile-layout { grid-template-columns: 1fr; }
  .auth-page { padding: 18px; }
  .auth-shell { grid-template-columns: 1fr; min-height: 0; }
  .auth-brand-panel { min-height: 145px; padding: 24px 28px; }
  .auth-brand-panel strong { font-size: 18px; }
  .auth-logo { width: 190px; }
  .auth-card { padding: 34px 30px; }
}

@media (max-width: 560px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .messenger-shell { grid-template-columns: 1fr; }
  .conversation-panel { display: none; }
  .messenger-shell.no-selection .conversation-panel { display: flex; }
  .messenger-shell.no-selection .chat-panel { display: none; }
  .content-page { padding: 14px; }
  .two-column-fields,
  .checkbox-grid { grid-template-columns: 1fr; }
  .user-edit-footer { grid-template-columns: 1fr; }
  .user-edit-footer > .button { width: 100%; }
  .app-modal-new-message iframe {
    height: 88vh;
    min-height: 0;
  }
  .auth-page { padding: 0; background: #fff; }
  .auth-shell { border: 0; border-radius: 0; box-shadow: none; }
  .auth-brand-panel { min-height: 120px; padding: 20px 22px; }
  .auth-brand-panel div { display: none; }
  .auth-card { padding: 30px 22px; }
  .mfa-enrollment-grid { grid-template-columns: 1fr; }
  .mfa-qr-card { width: 212px; margin: 0 auto; }
}
}
