:root {
  --bg: #12141a;
  --surface: #1b1e27;
  --border: #2b2f3b;
  --text: #e7e8ec;
  --text-muted: #9297a6;
  --primary: #4c9a6a;
  --primary-hover: #3c8256;
  --error: #f27272;
  --success: #5fc998;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #dde0e6;
  --text: #1c1e24;
  --text-muted: #666b78;
  --primary: #3c8256;
  --primary-hover: #316b47;
  --error: #c8392f;
  --success: #2f9968;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav .brand {
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
}

.nav .brand .sidebar-logo {
  display: block;
  max-height: 32px;
  max-width: 220px;
  object-fit: contain;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
}

.nav a:hover,
.nav a.active {
  color: var(--primary);
}

.nav a.nav-logout {
  margin-left: auto;
}

.agent-id-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.nav-menu {
  position: relative;
  margin-left: auto;
}

.hamburger-btn {
  width: auto;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 1.1rem;
  line-height: 1;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.nav-menu-dropdown[hidden] {
  display: none;
}

.nav-menu-dropdown a {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.nav-menu-dropdown a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 320px;
}

#my-stats-modal .modal-panel {
  width: 420px;
}

.trigger-list-panel {
  width: min(1100px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
}

.trigger-text-body {
  margin-top: 0.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

#trigger-text-modal textarea {
  margin-top: 0.5rem;
}

#trigger-text-modal .btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#trigger-text-modal .btn-row button {
  width: auto;
  margin-top: 0;
}

#edit-agent-modal .modal-panel {
  width: 640px;
}

#payroll-modal .modal-panel {
  width: 480px;
}

#trigger-history-modal .modal-panel {
  width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.trigger-history-row {
  margin-top: 1rem;
}

.trigger-history-btn {
  width: auto;
}

.payroll-download-row {
  display: flex;
  gap: 0.5rem;
}

.payroll-download-row button {
  width: auto;
  flex: 1;
}

.photo-lightbox-panel {
  width: auto;
  max-width: min(90vw, 640px);
  text-align: center;
}

.photo-lightbox-panel img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius);
  display: block;
  margin: 0 auto 1rem;
}

.modal-panel h2 {
  font-size: 1.15rem;
  margin: 0 0 1.25rem;
}

.modal-panel .btn-secondary {
  margin-top: 1.5rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  font-size: 0.92rem;
}

.setting-row + .setting-row {
  border-top: 1px solid var(--border);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.15s;
}

.switch input:checked + .switch-slider {
  background: var(--primary);
}

.switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.notification-banner {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--success);
  color: #0d2418;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.7rem 1.1rem;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}

.notification-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

.container {
  max-width: 420px;
  margin: 3.5rem auto;
  padding: 0 1.5rem;
}

.container.wide {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 1.25rem;
}

p.subtitle {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  margin-top: 1rem;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

#create-form input[type="email"],
#create-form input[type="password"],
#create-form input[type="text"] {
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.lang-dropdown-wrap {
  position: relative;
  display: inline-block;
  min-width: 220px;
}

.lang-dropdown-btn {
  width: 100%;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.lang-dropdown-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.lang-dropdown-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.lang-dropdown-popup[hidden] {
  display: none;
}

input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  background: var(--primary);
  color: white;
  width: 100%;
}

button:hover {
  background: var(--primary-hover);
}

.btn-row {
  margin-top: 1.4rem;
}

.btn-danger {
  background: var(--error);
}

.btn-danger:hover {
  filter: brightness(90%);
}

.btn-inline {
  width: auto;
  flex-shrink: 0;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

#block-chat-confirm-btn {
  white-space: nowrap;
  align-self: flex-start;
  border: 1px solid transparent;
}

#block-chat-cancel-btn {
  margin-top: 0;
}

.message {
  margin-top: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.message.error {
  background: rgba(242, 114, 114, 0.12);
  color: var(--error);
}

.message.success {
  background: rgba(95, 201, 152, 0.12);
  color: var(--success);
}

.restart-alert-banner {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: rgba(242, 114, 114, 0.16);
  border: 1px solid var(--error);
  color: var(--error);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.favourited-alert-banner {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: #ff1493;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.report-review-banner {
  margin: 0 0 1rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: rgba(76, 124, 240, 0.12);
  flex-shrink: 0;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.report-review-banner .btn-secondary {
  width: auto;
  flex-shrink: 0;
}

.report-review-banner[hidden] {
  display: none;
}

.no-results {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem 0;
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.queue-table th,
.queue-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.queue-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.queue-table tr:last-child td {
  border-bottom: none;
}

.queue-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.queue-table th.sortable:hover {
  color: var(--text);
}

.sort-indicator {
  margin-left: 0.3em;
}

.queue-table tr.clickable {
  cursor: pointer;
}

.queue-table tr.clickable:hover {
  background: rgba(255, 255, 255, 0.03);
}

.last-message-preview {
  color: var(--text-muted);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr 320px;
  grid-template-rows: minmax(0, 1fr);
  gap: 1.25rem;
  width: 100%;
  margin: 1.5rem 0;
  padding: 0 1.5rem;
  box-sizing: border-box;
  height: calc(100vh - 100px);
}

.side-panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  overflow-y: auto;
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.panel-photo-btn {
  all: unset;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 0;
  border-radius: 50%;
}

.panel-photo-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.panel-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1.05rem;
  overflow: hidden;
}

.panel-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-panel .panel-photo {
  background: var(--border);
  color: var(--text-muted);
}

.panel-header-info {
  min-width: 0;
  padding-top: 0.15rem;
}

.vip-star {
  color: #d4af37;
  margin-left: 0.3rem;
}

.panel-header-info h2 {
  font-size: 1rem;
  margin: 0 0 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.panel-header-meta span:empty {
  display: none;
}

.panel-header-meta span:not(:last-child)::after {
  content: "\2022";
  margin-left: 0.35rem;
  color: var(--border);
}

.credits-display {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

.credits-display .credits-label {
  color: var(--text-muted);
}

#user-credits {
  font-weight: 700;
}

.panel-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-family: inherit;
  padding: 0.6rem 0 0.3rem;
  margin-top: 0.75rem;
  cursor: pointer;
  text-align: left;
}

.panel-section-toggle:hover {
  color: var(--text);
}

.panel-section-toggle[hidden] {
  display: none;
}

.panel-section-toggle-arrow {
  display: inline-block;
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}

.panel-section-toggle.expanded .panel-section-toggle-arrow {
  transform: rotate(90deg);
}

.panel-details {
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
  margin-top: 1rem;
  padding-right: 0.4rem;
}

.panel-detail-fields {
  margin: 0;
}

.panel-detail-field {
  display: grid;
  grid-template-columns: 92px 1fr;
  column-gap: 0.5rem;
  align-items: baseline;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}

.panel-detail-field:first-child {
  padding-top: 0;
}

.panel-detail-field dt {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.panel-detail-field dd {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.25;
  word-wrap: break-word;
}

.panel-about-me {
  flex-shrink: 0;
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.3;
}

.memo-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.memo-section h3 {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

.memo-section button {
  margin-top: 0.75rem;
}

#memo-list {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.memo-list-item {
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.memo-list-item:hover {
  border-color: var(--primary);
}

.memo-list-item.editing {
  border-color: var(--primary);
  background: rgba(76, 154, 106, 0.08);
}

.memo-list-item .memo-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.memo-list-item .memo-when {
  margin-left: auto;
}

.memo-delete-btn {
  width: auto;
  padding: 0 0.15rem;
  background: none;
  border: none;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.6;
}

.memo-delete-btn:hover {
  opacity: 1;
  color: var(--error);
}

.memo-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

.memo-badge-name {
  background: #3b82f6;
}

.memo-badge-city {
  background: #eab308;
  color: #1c1e24;
}

.memo-badge-age {
  background: #8b5cf6;
}

.memo-badge-job {
  background: #f97316;
}

.memo-badge-sexual-interests {
  background: #ec4899;
}

.memo-badge-family {
  background: #22c55e;
}

.memo-badge-custom {
  background: #6b7280;
}

.memo-list-item .memo-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.memo-list-item .memo-when {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.7;
  flex-shrink: 0;
}

textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  resize: vertical;
}

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

.chat-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.chat-id-badge {
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}

.response-countdown {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--success);
}

.response-countdown.response-countdown-urgent {
  color: var(--error);
}

.date-divider {
  align-self: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  margin: 0.4rem 0;
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-height: 0;
}

.bubble {
  max-width: 70%;
  padding: 0.6rem 0.85rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.35;
  word-wrap: break-word;
}

.bubble .meta {
  display: block;
  font-size: 0.72rem;
  opacity: 0.7;
  margin-bottom: 0.15rem;
}

.bubble.from-user {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.bubble.from-profile {
  align-self: flex-end;
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble.message-reported {
  border: 2px solid var(--error);
  background: rgba(242, 114, 114, 0.35);
}

.message-agent-label {
  display: block;
  width: auto;
  margin: 0.3rem 0 0 auto;
  padding: 0;
  background: none;
  border: none;
  color: inherit;
  opacity: 0.75;
  font-size: 0.72rem;
  text-decoration: underline;
  text-align: right;
}

.message-agent-label:hover {
  opacity: 1;
  background: none;
}

.report-menu {
  min-width: 210px;
  margin-top: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
  color: var(--text);
  font-weight: 400;
}

.report-menu[hidden] {
  display: none;
}

.report-menu-item {
  width: 100%;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 6px;
  text-align: left;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.report-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.report-menu-other {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.2rem;
  padding: 0 0.2rem;
}

.report-menu-other input[type="text"] {
  flex: 1;
}

.report-menu-other button {
  width: auto;
  flex-shrink: 0;
}

.report-menu .message {
  margin-top: 0.3rem;
}

#reply-section {
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

.chat-input-row #chat-input {
  flex: 1;
  margin-top: 0;
  resize: none;
}

.chat-input-row button {
  width: auto;
  flex-shrink: 0;
}

.emoji-picker-wrap {
  position: relative;
  flex-shrink: 0;
  display: flex;
}

#emoji-picker-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.5rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#emoji-picker-btn:hover {
  background: var(--bg);
}

.emoji-picker-popup {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 0.4rem;
  display: flex;
  flex-direction: column;
  width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 20;
}

.emoji-picker-popup[hidden] {
  display: none;
}

.emoji-picker-search {
  width: 100%;
  flex-shrink: 0;
  margin-bottom: 0.4rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.emoji-picker-tabs {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
  margin-bottom: 0.4rem;
  flex-shrink: 0;
}

.emoji-picker-tab {
  width: auto;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
}

.emoji-picker-tab:hover {
  background: var(--bg);
}

.emoji-picker-tab.active {
  background: var(--bg);
  outline: 1px solid var(--border);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.15rem;
  max-height: 220px;
  overflow-y: auto;
}

.emoji-picker-item {
  width: auto;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0.5rem;
  cursor: pointer;
}

.emoji-picker-item:hover {
  background: var(--bg);
}

.chat-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

#char-counter.char-counter-invalid {
  color: var(--error);
  font-weight: 600;
}

.short-allowance-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 400;
  cursor: pointer;
}

.short-allowance-row input {
  width: auto;
}

select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.checkout-row {
  display: flex;
  gap: 1rem;
}

.delay-input-row {
  display: flex;
  gap: 0.6rem;
}

.delay-input-row input[type="number"] {
  flex: 1;
}

.delay-input-row select {
  width: auto;
  flex-shrink: 0;
}

.checkout-row > div {
  flex: 1;
}

.date-filter-apply-wrap {
  display: flex;
  align-items: flex-end;
}

#stats-date-filter-row > div {
  flex: 0 0 auto;
}

.stats-date-fields {
  display: flex;
  gap: 0.5rem;
}

#stats-date-filter-row .date-filter-apply-wrap {
  gap: 0.5rem;
}

#stats-apply-btn,
#stats-payroll-btn {
  width: auto;
  white-space: nowrap;
}

.recipient-filter-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.recipient-filter-row > div {
  flex: 1;
}

.variable-tag-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.trigger-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .trigger-layout {
    grid-template-columns: 1fr;
  }
}

.profile-picker {
  position: relative;
}

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

.profile-picker-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
}

.profile-picker-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.profile-picker-popup {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.3rem;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.profile-picker-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 500;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}

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

.profile-picker-btn .profile-thumb,
.profile-picker-item .profile-thumb {
  width: 32px;
  height: 32px;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 1.5rem;
}

.profile-form-field-full {
  grid-column: 1 / -1;
}

.queue-table .row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.queue-table button {
  width: auto;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.queue-table button.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.queue-table button.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

#blocked-tbody button {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.queue-table input[type="password"].inline-password {
  width: 140px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  margin-top: 0;
  display: inline-block;
}

.queue-table select.site-multiselect {
  width: 260px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  margin-top: 0;
}

.languages-cell span {
  margin-right: 0.5rem;
}

.status-active {
  color: var(--success);
}

.status-suspended {
  color: var(--text-muted);
}

.online-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.online-dot-online {
  background: var(--success);
}

.online-dot-offline {
  background: var(--text-muted);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 220px;
  background: #0d0f14;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  overflow-y: auto;
}

.sidebar-brand {
  color: var(--text);
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0 1.5rem 1.5rem;
}

.sidebar-logo {
  display: block;
  max-width: 100%;
  max-height: 56px;
  object-fit: contain;
}

.logo-preview {
  display: block;
  max-width: 220px;
  max-height: 72px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.7rem 1.5rem;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--primary);
}

.sidebar-nav-section {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem 1.5rem 0.3rem;
}

.sidebar-nav a.sidebar-nav-sub {
  padding-left: 2.4rem;
  font-size: 0.9rem;
}

.sidebar-nav-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  border-left: 3px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav-toggle:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-toggle-arrow {
  display: inline-block;
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}

.sidebar-nav-toggle.expanded .sidebar-nav-toggle-arrow {
  transform: rotate(90deg);
}

.sidebar-submenu {
  display: flex;
  flex-direction: column;
}

.sidebar-submenu[hidden] {
  display: none;
}

.sidebar-submenu a {
  padding-left: 2.5rem;
  font-size: 0.9rem;
}

#site-form .profile-form-grid {
  grid-template-columns: repeat(3, 1fr);
}

.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}

.manual-steps-list {
  margin: 0.5rem 0 0;
  padding-left: 1.3rem;
  color: var(--text);
  font-size: 0.9rem;
}

.manual-steps-list li {
  margin-bottom: 0.4rem;
}

.site-group-header td {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}

.site-group-header .site-group-slug {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

.site-sub-row td:first-child {
  padding-left: 2rem;
}

.site-group-header,
.site-sub-row {
  cursor: pointer;
}

.site-group-header:hover td,
.site-sub-row:hover td {
  background: rgba(255, 255, 255, 0.05);
}

#site-detail-modal .modal-panel {
  width: 480px;
}

.sidebar-logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 1rem 1.5rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-logout:hover {
  color: var(--text);
}

.main-content {
  margin-left: 220px;
  min-height: 100vh;
}

.site-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-top: 0.5rem;
}

.site-checklist.inline {
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
}

.site-checklist-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 400;
  margin: 0;
}

.site-checklist-item input {
  width: auto;
}

input[type="file"] {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.profile-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.profile-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
}

.photo-thumb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.photo-thumb-item {
  position: relative;
  width: 84px;
  height: 84px;
}

.photo-thumb-item img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0.4rem 0;
}

.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.photo-strip-item {
  position: relative;
  width: 64px;
  height: 64px;
  cursor: pointer;
}

.photo-strip-item img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  border: 2px solid transparent;
}

.photo-strip-item.selected img {
  border-color: var(--primary);
}

.photo-strip-item.already-sent::after {
  content: "\2713";
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

#photo-preview-area {
  margin-top: 0.75rem;
  text-align: center;
}

#photo-preview-area img {
  max-width: 260px;
  max-height: 260px;
  border-radius: var(--radius);
  object-fit: contain;
}

#photo-preview-area button {
  display: block;
  width: auto;
  margin: 0.5rem auto 0;
}

.bubble img {
  max-width: 220px;
  max-height: 220px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.bubble .meta + img,
.bubble img + .bubble-body {
  margin-top: 0.4rem;
}

.chat-message-photo {
  cursor: pointer;
}

#photo-lightbox {
  background: rgba(0, 0, 0, 0.6);
}

.photo-lightbox-inner {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
}

.photo-lightbox-inner img {
  display: block;
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#photo-lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

#photo-lightbox-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

.gift-message-img {
  max-width: 72px;
  max-height: 72px;
  display: block;
  border-radius: 8px;
}

.bubble-body {
  display: block;
}

.photo-thumb-item .btn-delete-photo {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: var(--error);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1;
  border: 2px solid var(--surface);
}

.sites-cell span {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.78rem;
  margin: 0 0.25rem 0.25rem 0;
  color: var(--text-muted);
}

.sites-dropdown summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sites-dropdown summary:hover {
  color: var(--text);
}

.sites-dropdown-list {
  margin-top: 0.35rem;
}

.multi-select {
  position: relative;
  margin-top: 0.5rem;
}

.multi-select-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}

.multi-select-field:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.multi-select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-value.is-empty {
  color: var(--text-muted);
}

.multi-select-caret {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.multi-select.open .multi-select-caret {
  transform: rotate(180deg);
}

.multi-select-menu {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.multi-select-option {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  margin: 0;
}

.multi-select-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.multi-select-option::before {
  content: '\2713';
  display: inline-block;
  width: 1.1rem;
  color: transparent;
}

.multi-select-option.selected {
  color: var(--primary);
}

.multi-select-option.selected::before {
  color: var(--primary);
}

.multi-select-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.checkbox-row input {
  width: auto;
}

.checkbox-row label {
  margin: 0;
  font-weight: 400;
  font-size: 0.88rem;
}

.btn-row-split {
  display: flex;
  gap: 0.75rem;
}

.btn-row-split button {
  width: auto;
}

.variable-tag-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.variable-tag-option input {
  width: auto;
  margin: 0;
}

.online-schedule-row {
  margin-bottom: 1.4rem;
}

.online-schedule-row:last-child {
  margin-bottom: 0;
}

.online-schedule-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.online-schedule-input-row input[type="number"] {
  width: 90px;
  flex: none;
}

.online-schedule-input-row span {
  color: var(--text-muted);
  font-size: 0.88rem;
}

#current-photo-preview {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

#current-photo-preview img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.profile-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.queue-table tbody tr.profile-row {
  cursor: pointer;
}

.queue-table tbody tr.profile-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.report-dismissed-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.dashboard-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.dashboard-filter-btn {
  width: auto;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.dashboard-filter-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.dashboard-filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.dashboard-graphs-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.dashboard-graph-panel {
  min-width: 0;
}

.dashboard-graph-panel h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.dashboard-graph-panel canvas {
  max-height: 260px;
}

.graph-summary {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.graph-summary strong {
  color: var(--text);
}

.profile-filters-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.profile-filters-row > div {
  flex: 1;
}

.pagination-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.pagination-row button {
  width: auto;
}

.pagination-row span {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.connection-status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  line-height: 1.5;
}

.connection-status .muted {
  opacity: 0.7;
}

.connection .btn-row,
.chat-site .btn-row,
#chat-site-add .btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.connection .btn-row button,
.chat-site .btn-row button,
#chat-site-add .btn-row button {
  width: auto;
}

.connection .btn-row button.btn-secondary,
.chat-site .btn-row button.btn-secondary,
#chat-site-add .btn-row button.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.chat-site .btn-row button.btn-danger {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
}

.chat-site .btn-row button.btn-danger:hover,
.chat-site .btn-row button.btn-danger[data-armed="yes"] {
  background: var(--error);
  color: white;
  filter: none;
}

.connection .btn-row button:disabled,
.chat-site .btn-row button:disabled {
  opacity: 0.5;
  cursor: default;
}

.admin-menu-toggle {
  display: none;
}

@media (max-width: 720px) {
  .sidebar-page .sidebar {
    position: sticky;
    top: 0;
    bottom: auto;
    z-index: 20;
    width: auto;
    max-height: 100vh;
    max-height: 100dvh;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-page .sidebar {
    gap: 0 0.75rem;
  }

  .sidebar-page .sidebar-brand {
    flex: 1 1 0;
    padding: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-page .sidebar-brand .sidebar-logo {
    max-height: 36px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
  }

  .sidebar-page .sidebar .admin-menu-toggle {
    flex: none;
  }

  .sidebar-page .sidebar .admin-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: auto;
    margin: 0;
    padding: 0.45rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
  }

  .sidebar-page .sidebar-nav,
  .sidebar-page .sidebar-logout {
    display: none;
    flex-basis: 100%;
  }

  .sidebar-page .sidebar.is-open .sidebar-nav {
    display: flex;
    margin: 0.6rem -1rem 0;
  }

  .sidebar-page .sidebar.is-open .sidebar-logout {
    display: block;
    margin: 0 -1rem;
  }

  .sidebar-page .main-content {
    margin-left: 0;
  }

  .sidebar-page .container.wide {
    margin: 1.25rem auto;
    padding: 0 1rem;
  }

  .sidebar-page .card {
    padding: 1.25rem;
  }

  .sidebar-page .checkout-row {
    flex-direction: column;
    gap: 0;
  }

  .sidebar-page .btn-row,
  .sidebar-page .row-actions {
    flex-wrap: wrap;
  }

  .sidebar-page .main-content select,
  .sidebar-page .main-content input,
  .sidebar-page .main-content textarea,
  .sidebar-page .modal-panel select,
  .sidebar-page .modal-panel input,
  .sidebar-page .modal-panel textarea {
    max-width: 100%;
  }

  .sidebar-page .main-content img,
  .sidebar-page .main-content pre,
  .sidebar-page .main-content .code-block {
    max-width: 100%;
  }

  .sidebar-page .main-content pre,
  .sidebar-page .main-content .code-block {
    overflow-x: auto;
  }

  .sidebar-page .modal-panel {
    max-width: calc(100vw - 2rem);
  }

  .sidebar-page .modal-panel img,
  .sidebar-page .modal-panel .code-block {
    max-width: 100%;
  }
}

@media (max-width: 560px) {
  .sidebar-page :is(.main-content, .modal-panel) table,
  .sidebar-page :is(.main-content, .modal-panel) tbody,
  .sidebar-page :is(.main-content, .modal-panel) tfoot,
  .sidebar-page :is(.main-content, .modal-panel) tr,
  .sidebar-page :is(.main-content, .modal-panel) td,
  .sidebar-page :is(.main-content, .modal-panel) tbody th,
  .sidebar-page :is(.main-content, .modal-panel) tfoot th {
    display: block;
    width: 100%;
  }

  .sidebar-page :is(.main-content, .modal-panel) table {
    border: none;
    background: transparent;
    overflow: visible;
  }

  .sidebar-page :is(.main-content, .modal-panel) thead {
    display: none;
  }

  .sidebar-page :is(.main-content, .modal-panel) tr {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
  }

  .sidebar-page :is(.main-content, .modal-panel) tr:last-child {
    margin-bottom: 0;
  }

  .sidebar-page :is(.main-content, .modal-panel) td,
  .sidebar-page :is(.main-content, .modal-panel) tr:last-child td,
  .sidebar-page :is(.main-content, .modal-panel) tbody th,
  .sidebar-page :is(.main-content, .modal-panel) tfoot th {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .sidebar-page :is(.main-content, .modal-panel) tr td:last-child,
  .sidebar-page :is(.main-content, .modal-panel) tr th:last-child {
    border-bottom: none;
  }

  .sidebar-page :is(.main-content, .modal-panel) tfoot tr {
    margin-top: 0.75rem;
  }

  .sidebar-page :is(.main-content, .modal-panel) td::before,
  .sidebar-page :is(.main-content, .modal-panel) tbody th::before,
  .sidebar-page :is(.main-content, .modal-panel) tfoot th::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .sidebar-page :is(.main-content, .modal-panel) td[data-label=""]::before,
  .sidebar-page :is(.main-content, .modal-panel) th[data-label=""]::before,
  .sidebar-page :is(.main-content, .modal-panel) td:not([data-label])::before {
    display: none;
  }

  .sidebar-page :is(.main-content, .modal-panel) td input:not([type="checkbox"]):not([type="radio"]),
  .sidebar-page :is(.main-content, .modal-panel) td select {
    width: 100%;
  }

  .sidebar-page :is(.main-content, .modal-panel) .last-message-preview {
    max-width: none;
  }

  .sidebar-page .trigger-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-page .btn-row-split {
    flex-wrap: wrap;
    position: relative;
  }

  .sidebar-page .btn-row-split .emoji-picker-wrap {
    position: static;
  }

  .sidebar-page .btn-row-split .emoji-picker-popup {
    width: 100%;
  }

  .sidebar-page .main-content .profile-form-grid,
  .sidebar-page #site-form .profile-form-grid {
    grid-template-columns: 1fr;
  }
}

.chat-pane-tabs {
  display: none;
}

@media (max-width: 720px), (max-height: 500px) {
  .agent-view .nav {
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .agent-view .nav .brand {
    min-width: 0;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .agent-view .nav .brand .sidebar-logo {
    max-height: 26px;
    max-width: 110px;
  }

  .agent-view .nav a {
    font-size: 0.88rem;
  }

  .agent-view .agent-id-badge {
    flex: 1 1 0;
    max-width: max-content;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
  }

  .agent-view .nav-menu {
    flex: none;
  }

  .agent-view .chat-pane-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
  }

  .agent-view .chat-pane-tab {
    flex: 1;
    width: auto;
    margin: 0;
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
  }

  .agent-view .chat-pane-tab[aria-selected="true"] {
    background: var(--primary);
    color: #fff;
  }

  .agent-view body:has(.chat-layout) {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .agent-view .nav {
    flex-shrink: 0;
  }

  .agent-view .chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0.5rem;
    gap: 0;
  }

  .agent-view .chat-layout > * {
    flex: 1;
    min-width: 0;
    min-height: 0;
  }

  .agent-view .chat-layout[data-pane="chat"] .side-panel,
  .agent-view .chat-layout[data-pane="user"] .chat-main,
  .agent-view .chat-layout[data-pane="user"] .profile-panel,
  .agent-view .chat-layout[data-pane="profile"] .chat-main,
  .agent-view .chat-layout[data-pane="profile"] .user-panel {
    display: none;
  }

  .agent-view .side-panel {
    padding: 1rem;
  }

  .agent-view .restart-alert-banner,
  .agent-view .favourited-alert-banner,
  .agent-view .report-review-banner {
    margin-bottom: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
  }

  .agent-view .report-review-banner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .agent-view .chat-meta {
    flex-wrap: wrap;
    gap: 0.2rem 0.75rem;
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
  }

  .agent-view .chat-id-badge,
  .agent-view .response-countdown {
    font-size: 0.85rem;
  }

  .agent-view .chat-window {
    padding: 0.6rem;
  }

  .agent-view .bubble {
    max-width: 85%;
  }

  .agent-view .bubble img {
    max-width: 100%;
  }

  .agent-view .report-menu {
    min-width: 0;
    max-width: 100%;
  }

  .agent-view .chat-input-row {
    gap: 0.4rem;
    margin-top: 0.5rem;
  }

  .agent-view .chat-meta-row {
    gap: 0.2rem 0.75rem;
    margin-top: 0.3rem;
    font-size: 0.75rem;
  }

  .agent-view .short-allowance-row {
    display: block;
    margin: 0;
    font-size: 0.75rem;
  }

  .agent-view .short-allowance-row input {
    margin: 0 0.3rem 0 0;
    vertical-align: middle;
  }

  .agent-view #photo-strip-label {
    margin: 0.3rem 0 0;
    font-size: 0.75rem;
  }

  .agent-view .photo-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.4rem;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
  }

  .agent-view .photo-strip-item {
    flex: none;
    width: 48px;
    height: 48px;
  }

  .agent-view #photo-preview-area:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.4rem;
    text-align: left;
  }

  .agent-view #photo-preview-area img {
    max-width: 72px;
    max-height: 72px;
  }

  .agent-view #photo-preview-area button {
    margin: 0;
  }

  .agent-view .emoji-picker-popup {
    width: min(300px, calc(100vw - 1.5rem));
  }

  .agent-view .emoji-picker-grid {
    max-height: min(220px, 30vh);
  }

  .agent-view .modal-panel,
  .agent-view #my-stats-modal .modal-panel {
    width: 320px;
    max-width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.25rem;
  }

  .agent-view .modal-panel .checkout-row {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .agent-view .modal-panel .checkout-row > div {
    flex: 1 1 120px;
  }

  .agent-view .modal-panel input[type="date"] {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
  }

  .agent-view .photo-lightbox-panel {
    width: auto;
  }

  .agent-view .photo-lightbox-panel img {
    max-height: calc(100dvh - 8rem);
  }

  .agent-view .container {
    margin: 1.5rem auto;
    padding: 0 1rem;
  }

  .agent-view .card {
    padding: 1.25rem;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .agent-view .chat-pane-tabs {
    order: 10;
    flex-basis: 100%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .agent-view .chat-pane-tabs {
    margin-left: auto;
  }

  .agent-view .chat-pane-tabs + .nav-menu {
    margin-left: 0;
  }

  .agent-view #photo-strip-label {
    display: none;
  }

  .agent-view .chat-layout {
    padding: 0.35rem 0.5rem;
  }

  .agent-view .chat-meta {
    margin-bottom: 0.25rem;
  }

  .agent-view .nav {
    padding: 0.3rem 0.75rem;
  }

  .agent-view .chat-pane-tab {
    padding: 0.25rem 0.75rem;
  }

  .agent-view .chat-input-row {
    margin-top: 0.35rem;
  }

  .agent-view .chat-input-row #chat-input {
    padding: 0.4rem 0.6rem;
  }

  .agent-view .chat-input-row button {
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }

  .agent-view .chat-meta-row {
    margin-top: 0.2rem;
  }

  .agent-view .photo-strip {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
  }

  .agent-view .photo-strip-item {
    width: 40px;
    height: 40px;
  }

  .agent-view .emoji-picker-popup {
    max-height: calc(100vh - 9.5rem);
    max-height: calc(100dvh - 9.5rem);
  }

  .agent-view .emoji-picker-grid {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}
