/*
 * Wachatly Dashboard Styles
 * Modern WhatsApp-inspired Dark/Light design system
 */

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-hover: #f5f6f8;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --border: #e9edef;
  --border-strong: #d1d7db;
  
  --text: #111b21;
  --text-muted: #667781;
  --text-light: #8696a0;

  --accent: #00a884;
  --accent-hover: #008f70;
  --accent-light: rgba(0, 168, 132, 0.1);
  --accent-text: #ffffff;

  --topbar-bg: #008069;
  --topbar-text: #ffffff;
  --topbar-muted: rgba(255, 255, 255, 0.8);

  --chat-bg: #efeae2;
  --chat-pattern: radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 0);
  
  --bubble-customer: #ffffff;
  --bubble-customer-text: #111b21;
  
  --bubble-admin: #d9fdd3;
  --bubble-admin-text: #111b21;
  
  --bubble-bot: #e7f8f3;
  --bubble-bot-text: #111b21;
  
  --bubble-system: #ffffff;
  --bubble-system-text: #54656f;

  --waiting: #b45309;
  --waiting-bg: #fef3c7;
  --waiting-border: #fde68a;

  --active-bot: #0369a1;
  --active-bot-bg: #e0f2fe;

  --active-admin: #15803d;
  --active-admin-bg: #dcfce7;

  --closed: #4b5563;
  --closed-bg: #f3f4f6;

  --danger: #ea4335;
  --danger-bg: #fce8e6;
  --danger-hover: #d93025;

  --focus: #00a884;
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 3px rgba(11, 20, 26, 0.08);
  --shadow: 0 4px 12px rgba(11, 20, 26, 0.08);
  --shadow-lg: 0 8px 24px rgba(11, 20, 26, 0.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #0b141a;
  --surface: #111b21;
  --surface-hover: #202c33;
  --surface-glass: rgba(17, 27, 33, 0.85);
  --border: #222d34;
  --border-strong: #2a3942;

  --text: #e9edef;
  --text-muted: #8696a0;
  --text-light: #667781;

  --accent: #00a884;
  --accent-hover: #02b38d;
  --accent-light: rgba(0, 168, 132, 0.18);
  --accent-text: #111b21;

  --topbar-bg: #111b21;
  --topbar-text: #e9edef;
  --topbar-muted: #8696a0;

  --chat-bg: #0b141a;
  --chat-pattern: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);

  --bubble-customer: #202c33;
  --bubble-customer-text: #e9edef;

  --bubble-admin: #005c4b;
  --bubble-admin-text: #e9edef;

  --bubble-bot: #1c2d37;
  --bubble-bot-text: #e9edef;

  --bubble-system: #182229;
  --bubble-system-text: #8696a0;

  --waiting: #f59e0b;
  --waiting-bg: rgba(245, 158, 11, 0.15);
  --waiting-border: rgba(245, 158, 11, 0.3);

  --active-bot: #38bdf8;
  --active-bot-bg: rgba(56, 189, 248, 0.15);

  --active-admin: #4ade80;
  --active-admin-bg: rgba(74, 222, 128, 0.15);

  --closed: #9ca3af;
  --closed-bg: rgba(156, 163, 175, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.25s ease, color 0.25s ease;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  left: 1rem;
  top: 0;
}

/* Base App Layout */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Topbar Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: var(--topbar-bg);
  color: var(--topbar-text);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  z-index: 20;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--topbar-text);
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--topbar-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: var(--transition);
}

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

.nav a[aria-current="page"] {
  color: var(--topbar-text);
  background: rgba(255, 255, 255, 0.18);
  font-weight: 600;
}

.nav .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e53e3e;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.2;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.user-role {
  font-size: 0.75rem;
  color: var(--topbar-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Theme Toggle Button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--topbar-text);
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .sun-icon {
  display: block;
}
[data-theme="dark"] .moon-icon {
  display: none;
}
[data-theme="light"] .sun-icon {
  display: none;
}
[data-theme="light"] .moon-icon {
  display: block;
}

/* Flash error banner */
#flash {
  position: absolute;
  top: 4.5rem;
  right: 1.5rem;
  z-index: 50;
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Main Content Area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.content-wide {
  max-width: 100%;
  padding: 0;
  height: calc(100vh - 57px);
  overflow: hidden;
}

/* ---------- Inbox Structure ---------- */
.inbox {
  display: flex;
  height: 100%;
  background: var(--surface);
  position: relative;
}

.inbox-sidebar {
  width: 380px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

/* Search Bar */
.inbox-search {
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  width: 15px;
  height: 15px;
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.45rem 0.75rem 0.45rem 2.2rem;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.search-submit {
  display: none;
}

/* Filters */
.inbox-filters {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.filter-links {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  overflow-x: auto;
  scrollbar-width: none;
  width: 100%;
}

.filter-links::-webkit-scrollbar {
  display: none;
}

.filter {
  padding: 0.35rem 0.75rem;
  border-radius: 16px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
}

.filter:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.filter[aria-current="true"] {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

/* Conversation List */
.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.conversation-list li {
  border-bottom: 1px solid var(--border);
}

.conversation-link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.1rem;
  color: inherit;
  transition: var(--transition);
  position: relative;
}

.conversation-link:hover {
  background: var(--surface-hover);
}

.conversation-link[aria-current="true"] {
  background: var(--surface-hover);
  border-left: 4px solid var(--accent);
  padding-left: calc(1.1rem - 4px);
}

.conversation-header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.2rem;
}

.conversation-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--text-light);
}

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

.conversation-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: auto;
}

/* Status Pills */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-waiting_for_admin {
  background: var(--waiting-bg);
  color: var(--waiting);
  border: 1px solid var(--waiting-border);
  animation: pulseWait 2s infinite;
}

@keyframes pulseWait {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.status-bot_active {
  background: var(--active-bot-bg);
  color: var(--active-bot);
}

.status-admin_active {
  background: var(--active-admin-bg);
  color: var(--active-admin);
}

.status-closed {
  background: var(--closed-bg);
  color: var(--closed);
}

/* ---------- Thread Panel (Right Side) ---------- */
.thread-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  background-image: var(--chat-pattern);
  background-size: 20px 20px;
  height: 100%;
  position: relative;
}

.thread-panel .empty {
  margin: auto;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* Thread Header */
.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.thread-contact {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.btn-back-mobile {
  display: none;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
}

.thread-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.thread-subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.thread-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Thread Messages Scroll Area */
.thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.message {
  max-width: 65%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  position: relative;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.15s ease-out;
  line-height: 1.45;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Message Direction & Sender Styling */
.message-inbound {
  align-self: flex-start;
  background: var(--bubble-customer);
  color: var(--bubble-customer-text);
  border-top-left-radius: 2px;
}

.message-outbound {
  align-self: flex-end;
  border-top-right-radius: 2px;
}

.message-sender-admin {
  background: var(--bubble-admin);
  color: var(--bubble-admin-text);
}

.message-sender-bot {
  background: var(--bubble-bot);
  color: var(--bubble-bot-text);
}

.message-sender-system {
  align-self: center;
  max-width: 85%;
  background: var(--bubble-system);
  color: var(--bubble-system-text);
  font-size: 0.82rem;
  padding: 0.4rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: none;
  text-align: center;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

.sender-tag {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}

.message-body {
  margin: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}

.delivery-tick {
  font-size: 0.85rem;
  line-height: 1;
}

.delivery-tick-read {
  color: #027eb5;
}

[data-theme="dark"] .delivery-tick-read {
  color: #53bdeb;
}

.delivery-tick.status-read {
  color: #027eb5;
}

[data-theme="dark"] .delivery-tick.status-read {
  color: #53bdeb;
}

.message-failed {
  border: 1px solid var(--danger);
  background: var(--danger-bg);
}

/* Composer Area */
.composer-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
}

.canned-replies {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: none;
}

.canned-replies::-webkit-scrollbar {
  display: none;
}

.chip-reply {
  padding: 0.35rem 0.75rem;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.chip-reply:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.composer textarea {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: var(--transition);
}

.composer textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.composer-locked {
  margin: 0;
  padding: 0.8rem 1.2rem;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 0.88rem;
  text-align: center;
  border-top: 1px solid var(--border);
}

.composer-locked-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(234, 67, 53, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

.load-more-container {
  display: flex;
  justify-content: center;
  padding: 0.25rem 0 0.5rem 0;
  width: 100%;
}

.load-more-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}

.load-more-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--accent);
}

/* Forms & Cards (Settings, Admins, Audit, Login) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin-top: 0;
  margin-bottom: 1.2rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.field {
  margin-bottom: 1.2rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  transition: var(--transition);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  outline: none;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.field-check label {
  margin-bottom: 0;
  cursor: pointer;
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-actions-sticky {
  position: sticky;
  bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  z-index: 15;
}

/* Role Badges */
.badge-role {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-role-OWNER {
  background: rgba(147, 51, 234, 0.12);
  color: #9333ea;
  border: 1px solid rgba(147, 51, 234, 0.25);
}

[data-theme="dark"] .badge-role-OWNER {
  background: rgba(192, 132, 252, 0.15);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.3);
}

.badge-role-ADMIN {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(0, 168, 132, 0.25);
}

.badge-role-AGENT {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.notice {
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  margin-bottom: 1.2rem;
  font-weight: 500;
}

.error {
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  margin-bottom: 1.2rem;
  font-weight: 500;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.table th {
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.table tr:hover td {
  background: var(--surface-hover);
}

.table code {
  background: var(--bg);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--accent);
}

/* Login Page Styling */
.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-card h1 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
}

.auth-card .form {
  margin-top: 1.5rem;
  text-align: left;
}

/* Search highlighting */
mark {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.1rem 0.2rem;
  border-radius: 2px;
  font-weight: 600;
}

/* Dark mode mark styling */
[data-theme="dark"] mark {
  background: rgba(0, 168, 132, 0.3);
  color: #6ee7b7;
}

/* Responsive Mobile Rules */
@media (max-width: 768px) {
  .topbar {
    padding: 0.6rem 0.8rem;
    gap: 0.5rem;
  }
  .brand span {
    display: none;
  }
  .nav {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .nav::-webkit-scrollbar {
    display: none;
  }
  .nav a {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
  }
  .user-info {
    display: none;
  }
  .inbox-sidebar {
    width: 100%;
  }
  .inbox.has-selected .inbox-sidebar {
    display: none;
  }
  .inbox:not(.has-selected) .thread-panel {
    display: none;
  }
  .btn-back-mobile {
    display: inline-flex;
  }
  .message {
    max-width: 85%;
  }
}
