/* CSS Variables for theming */
:root {
  /* Colors */
  --background: oklch(1 0 0);
  --foreground: oklch(0.145 0 0);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.145 0 0);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.145 0 0);
  --primary: oklch(0.205 0 0);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.97 0 0);
  --secondary-foreground: oklch(0.205 0 0);
  --muted: oklch(0.97 0 0);
  --muted-foreground: oklch(0.556 0 0);
  --accent: oklch(0.97 0 0);
  --accent-foreground: oklch(0.205 0 0);
  --highlight: oklch(0.94 0.045 230);
  --highlight-foreground: oklch(0.32 0.05 230);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.577 0.245 27.325);
  --border: oklch(0.922 0 0);
  --input: oklch(0.922 0 0);
  --ring: oklch(0.708 0 0);
  --radius: 0.625rem;
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.145 0 0);
  --sidebar-primary: oklch(0.205 0 0);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.97 0 0);
  --sidebar-accent-foreground: oklch(0.205 0 0);
  --sidebar-border: oklch(0.922 0 0);
  --sidebar-ring: oklch(0.708 0 0);
}

.dark {
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.145 0 0);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.145 0 0);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.985 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --accent: oklch(0.269 0 0);
  --accent-foreground: oklch(0.985 0 0);
  --highlight: oklch(0.32 0.05 230);
  --highlight-foreground: oklch(0.94 0.03 230);
  --destructive: oklch(0.396 0.141 25.723);
  --destructive-foreground: oklch(0.637 0.237 25.331);
  --border: oklch(0.269 0 0);
  --input: oklch(0.269 0 0);
  --ring: oklch(0.439 0 0);
  --sidebar: oklch(0.205 0 0);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: oklch(0.488 0.243 264.376);
  --sidebar-primary-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.269 0 0);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: oklch(0.269 0 0);
  --sidebar-ring: oklch(0.439 0 0);
}

/* Base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
    "Droid Sans", "Helvetica Neue", sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Global layout helpers for legacy templates */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.row {
  display: flex;
}

.space-between {
  justify-content: space-between;
}

.align-center {
  align-items: center;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.topbar .container {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--foreground);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: calc(var(--radius) - 2px);
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 0.9rem;
  text-transform: uppercase;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.brand-text {
  font-size: 1rem;
}

.version {
  font-size: 0.85rem;
  color: var(--muted-foreground);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 1.25rem 0.75rem;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: calc(var(--radius) - 3px);
  text-decoration: none;
  color: var(--muted-foreground);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.tab:hover {
  color: var(--foreground);
  background: var(--muted);
  border-color: var(--border);
}

.nav-user {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--muted-foreground);
}

.footer {
  padding: 1.5rem 0 2rem;
  color: var(--muted-foreground);
  font-size: 0.9rem;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

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

.footer a:hover {
  text-decoration: underline;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 256px;
  background-color: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  width: 2rem;
  border-radius: var(--radius);
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.sidebar-logo-icon .logo-image {
  display: block;
  height: 1.4rem;
  width: 1.4rem;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.sidebar-logo-subtitle {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.sidebar-group {
  margin-bottom: 1.5rem;
}

.sidebar-group-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted-foreground);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu-item {
  margin-bottom: 0.25rem;
}

.sidebar-menu-button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
  color: var(--sidebar-foreground);
  transition: all 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  text-align: left;
}

.sidebar-menu-button:hover {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}

.sidebar-menu-button.active {
  background-color: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
  font-weight: 500;
}

.sidebar-menu-button svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 1rem;
}

.theme-toggle-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
}

.theme-toggle-label {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 256px;
  padding: 1.5rem;
}

/* Typography */
h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
}

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

/* Utility classes */
.space-y-6 > * + * {
  margin-top: 1.5rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.self-end {
  align-self: flex-end;
}

/* Grid */
.grid {
  display: grid;
}

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

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.gap-4 {
  gap: 1rem;
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Card */
.card {
  background-color: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-padded {
  padding: 1rem;
}

.card-header {
  padding: 1.5rem;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
}

.card-header .card-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.card-content {
  padding: 1.5rem;
  padding-top: 0;
}

.card-header + .card-content {
  padding-top: 0;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  /* Added default height and padding for all buttons */
  height: 2.5rem;
  padding: 0 1rem;
  gap: 0.5rem;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-sm {
  height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
}

.btn-outline:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
}

.btn-ghost:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.btn-icon {
  height: 2rem;
  width: 2rem;
  padding: 0;
}

.btn svg {
  width: 1rem;
  height: 1rem;
}

.btn svg + span {
  margin-left: 0.5rem;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  transition: all 0.2s;
  white-space: nowrap;
}

.badge-default {
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.badge-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-destructive {
  background-color: var(--destructive);
  color: white;
}

.badge-outline {
  background-color: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
}

.badge-success {
  background-color: rgba(34, 197, 94, 0.1);
  color: rgb(34, 197, 94);
}

.badge-compact {
  font-size: 0.625rem;
  padding: 0.125rem 0.4rem;
}

/* Table */
.table-wrapper {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--card);
  /* Allow dropdown menus to render outside table bounds while preserving horizontal scroll. */
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
  /* Prevent table from shrinking below content */
  table-layout: auto;
}

thead {
  border-bottom: 1px solid var(--border);
  /* Added background for header */
  background-color: var(--muted);
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  /* Prevent header cells from wrapping */
  white-space: nowrap;
}

th.text-right {
  text-align: right;
}

/* Added text-center class for th elements */
th.text-center {
  text-align: center;
}

td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
}

td.text-right {
  text-align: right;
}

/* Added text-center class for td elements */
td.text-center {
  text-align: center;
}

td.font-medium {
  font-weight: 500;
}

td.font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

tr:hover td {
  background-color: var(--muted);
}

details.alias-accordion {
  width: 100%;
}

.alias-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.alias-summary span + span {
  margin-left: 0.2rem;
}

.alias-summary + .alias-summary {
  margin-top: 0.25rem;
}

details.alias-accordion > summary.alias-summary {
  cursor: pointer;
}

details.alias-accordion > .alias-summary {
  margin-left: 0.75rem;
}

details.alias-accordion[open] > summary.alias-summary .alias-extra {
  display: none;
}

.alias-list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alias-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
}

.alias-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.alias-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Added specific width classes for table columns */
.w-80 {
  width: 80px;
}

.w-100 {
  width: 100px;
}

.w-120 {
  width: 120px;
}

.w-140 {
  width: 140px;
}

.w-180 {
  width: 180px;
}

/* Select */
.select-wrapper {
  flex: 1;
  min-width: 200px;
}

.select-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  display: block;
}

.select {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background-color: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

.select:focus {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Icons */
.icon {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.icon-lg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background-color: transparent;
  color: var(--foreground);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.theme-toggle-btn:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

.theme-toggle-btn svg {
  width: 1rem;
  height: 1rem;
}

html:not(.dark) #lightIcon {
  display: block;
}

html.dark #darkIcon {
  display: block;
}

#lightIcon,
#darkIcon {
  display: none;
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
  }

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

/* Flex wrapping */
.flex-wrap {
  flex-wrap: wrap;
}

.min-w-200 {
  min-width: 200px;
}

.flex-1 {
  flex: 1;
}

/* Text sizing */
.text-2xl {
  font-size: 1.5rem;
  line-height: 2rem;
}

.text-3xl {
  font-size: 1.875rem;
  line-height: 2.25rem;
}

.text-sm {
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.text-xs {
  font-size: 0.75rem;
  line-height: 1rem;
}

.text-lg {
  font-size: 1.125rem;
  line-height: 1.75rem;
}

.muted {
  color: var(--muted-foreground);
}

/* Font weights */
.font-bold {
  font-weight: 700;
}

.font-semibold {
  font-weight: 600;
}

.font-medium {
  font-weight: 500;
}

/* Tracking */
.tracking-tight {
  letter-spacing: -0.025em;
}

/* Padding */
.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.pt-6 {
  padding-top: 1.5rem;
}

.pb-2 {
  padding-bottom: 0.5rem;
}

.pb-4 {
  padding-bottom: 1rem;
}

.pr-4 {
  padding-right: 1rem;
}

.py-8 {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Margin */
.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 0.75rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-neg-6 {
  margin-top: -0.375rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.75rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.my-3 {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Width */
.w-full {
  width: 100%;
}

.max-w-280 {
  max-width: 280px;
}

.min-w-220 {
  min-width: 220px;
}

.break-all {
  word-break: break-all;
}

.is-hidden {
  display: none;
}

#mailboxModal[data-provider="imap"] .provider-gmail,
#mailboxModal[data-provider="imap"] .provider-hosted {
  display: none;
}

#mailboxModal[data-provider="gmail"] .provider-imap,
#mailboxModal[data-provider="gmail"] .provider-hosted {
  display: none;
}

#mailboxModal[data-provider="hosted"] .provider-imap,
#mailboxModal[data-provider="hosted"] .provider-gmail {
  display: none;
}

/* Text alignment */

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

/* Widths */
.w-140 {
  width: 140px;
}

.w-180 {
  width: 180px;
}

/* Added modal, form, switch, dropdown, and alert styles for mailboxes page */

/* Modal Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

#routeModal .modal-content {
  min-width: 60vw;
  max-width: 1100px;
  width: 90%;
}

.modal-content.modal-lg {
  max-width: 800px;
}

.modal-content.modal-xl {
  max-width: 900px;
  width: 90%;
}

.modal-content.modal-preview {
  max-width: 1200px;
  width: 60vw;
  height: 60vh;
  display: flex;
  flex-direction: column;
}

.modal-content.modal-preview .modal-body {
  flex: 1;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  min-height: 0;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.modal-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin: 0.25rem 0 0 0;
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.range-rtl {
  direction: rtl;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.mailbox-preview-grid {
  display: grid;
  grid-template-columns: 1fr auto 3fr;
  /* gap: 1rem; */
  height: 100%;
  align-items: stretch;
  position: relative;
}

.mailbox-preview-pane {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  margin-left: 1rem;
}

.mailbox-preview-right {
  gap: 0.75rem;
  min-width: 0;
}

.mailbox-preview-right-row {
  display: flex;
  padding: 1rem 0;
}

.mailbox-preview-right-row.right-align {
  justify-content: flex-end;
}

.mailbox-preview-json {
  flex: 1;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--card);
  padding: 0.75rem;
  overflow: auto;
  position: relative;
}

.json-preview {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--foreground);
  max-width: 100%;
}

.json-preview.no-wrap {
  white-space: pre;
  overflow-x: auto;
}

.preview-actions {
  position: absolute;
  top: 0.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.25rem;
}

.mailbox-preview-left-top {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 0.75rem 0 0.75rem 0;
}

.mailbox-preview-left-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.mailbox-preview-message {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
  cursor: pointer;
}

.mailbox-preview-message:last-child {
  border-bottom: none;
}

.mailbox-preview-message:hover {
  background-color: var(--muted);
}

.mailbox-preview-message.selected {
  background-color: var(--highlight);
  border-color: var(--highlight);
}

.mailbox-preview-message h4 {
  margin: 0 0 0.25rem 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.mailbox-preview-message .meta {
  font-size: 0.85rem;
  color: var(--muted-foreground);
  margin: 0.15rem 0;
}

.preview-divider {
  width: 1px;
  background: var(--border);
  border-radius: 999px;
  height: 100%;
  align-self: stretch;
}

@media (max-width: 960px) {
  .modal-content.modal-preview {
    width: 90vw;
    height: 80vh;
  }

  .mailbox-preview-grid {
    grid-template-columns: 1fr;
  }

  .preview-divider {
    display: none;
  }
}

@media (max-width: 960px) {
  .modal-content.modal-preview {
    width: 90vw;
    height: 80vh;
  }

  .mailbox-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Form Styles */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
  padding-bottom: 1rem;
}

details.advanced {
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.75rem;
  background: var(--background);
}

details.advanced summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

details.advanced[open] summary {
  margin-bottom: 0.75rem;
}

.json-editor {
  width: 100%;
  min-height: 240px;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

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

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  transition: border-color 0.2s;
  min-height: 2.5rem;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.input::placeholder {
  color: var(--muted-foreground);
}

.input-with-button {
  display: flex;
  gap: 0.5rem;
}

.input-with-button .input {
  flex: 1;
}

/* Switch Styles */
.switch-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.switch-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--foreground);
  display: block;
}

.switch-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--muted);
  transition: 0.3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

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

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

/* Dropdown Styles */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 0.25rem;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-label {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--foreground);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background-color 0.2s;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--accent);
}

.dropdown-item:disabled,
.dropdown-item[disabled] {
  color: var(--muted-foreground);
  cursor: not-allowed;
  opacity: 0.6;
}

.dropdown-item:disabled:hover,
.dropdown-item[disabled]:hover {
  background: transparent;
}

.dropdown-item.text-destructive {
  color: var(--destructive);
}

.dropdown-separator {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.list-compact {
  margin: 0 0 8px 18px;
}

.code-block {
  background: var(--muted);
  border: 1px solid var(--border);
  display: block;
}

/* Alert Styles */
.alert {
  padding: 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid;
}

.alert-success {
  background: hsl(142, 76%, 95%);
  color: hsl(142, 76%, 36%);
  border-color: hsl(142, 76%, 85%);
}

.alert-error {
  background: hsl(0, 84%, 95%);
  color: hsl(0, 84%, 40%);
  border-color: hsl(0, 84%, 85%);
}

.alert-warning {
  background: hsl(38, 100%, 94%);
  color: hsl(30, 94%, 35%);
  border-color: hsl(38, 100%, 85%);
}

.alert-info {
  background: var(--muted);
  color: var(--foreground);
  border-color: var(--border);
}

.flash-banner {
  margin: 0 auto 1rem;
  max-width: 720px;
}

.verification-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: none;
  margin-bottom: 1rem;
}

.verification-banner a {
  font-weight: 600;
}

.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 3000;
  pointer-events: none;
}

.toast-container .alert {
  pointer-events: auto;
  min-width: 260px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition: opacity 0.2s;
}

.toast-fade {
  opacity: 0;
}

.text-destructive {
  color: var(--destructive);
}

.btn-danger {
  background-color: #d32f2f;
  color: white;
  font-weight: 600;
}

.btn-danger:hover {
  background-color: #b71c1c;
}

:root[data-theme="dark"] .alert-success,
.dark .alert-success {
  background: hsl(142, 76%, 10%);
  color: hsl(142, 76%, 70%);
  border-color: hsl(142, 76%, 20%);
}

:root[data-theme="dark"] .alert-error,
.dark .alert-error {
  background: hsl(0, 84%, 10%);
  color: hsl(0, 84%, 70%);
  border-color: hsl(0, 84%, 20%);
}

/* Animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0;
}

.page-description {
  color: var(--muted-foreground);
}

/* Multi-colored Progress Bar for Settings */
.progress-bar-segmented {
  width: 100%;
  height: 0.5rem;
  display: block;
}

.progress-bar-shell {
  border-radius: 9999px;
  overflow: hidden;
}

.progress-segment-green {
  fill: rgb(22, 101, 52);
}

.progress-segment-yellow {
  fill: rgb(133, 77, 14);
}

.progress-segment-orange {
  fill: rgb(154, 52, 18);
}

.progress-segment-red {
  fill: rgb(153, 27, 27);
}

.progress-fill-green {
  fill: rgb(34, 197, 94);
}

.progress-fill-yellow {
  fill: rgb(234, 179, 8);
}

.progress-fill-orange {
  fill: rgb(249, 115, 22);
}

.progress-fill-red {
  fill: rgb(239, 68, 68);
}

/* Backfill progress bar */
.backfill-progress {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 1rem;
}

.backfill-progress-track {
  width: 100%;
  height: 0.5rem;
  border-radius: 9999px;
  background: var(--muted);
  overflow: hidden;
}

.backfill-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.2s ease;
}

.usage-item {
  padding: 0.5rem 0;
}

.usage-bar {
  width: 100%;
  height: 10px;
  display: block;
}

.usage-bar-track {
  fill: var(--muted);
  stroke: var(--border);
  stroke-width: 1;
}

.usage-bar-fill--ok {
  fill: #4caf50;
}

.usage-bar-fill--warn {
  fill: #f0ad4e;
}

.usage-bar-fill--danger {
  fill: #d9534f;
}

.auth-layout {
  min-height: 100vh;
  padding: 2.5rem 1.5rem;
  /* background: linear-gradient(135deg, var(--muted) 0%, var(--background) 55%); */
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-grid {
  width: min(1100px, 100%);
  display: grid;
  gap: 1.5rem;
  align-items: stretch;
}

@media (min-width: 960px) {
  .auth-grid {
    grid-template-columns: 1.05fr 0.95fr;
  }
}

.auth-card,
.auth-panel {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.08);
}

.auth-card {
  padding: 1.75rem;
  width: 100%;
}

.auth-layout > .auth-card {
  max-width: 520px;
}

.auth-panel {
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: linear-gradient(135deg, var(--card) 0%, var(--muted) 100%);
  border-color: var(--border);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-logo {
  height: 3rem;
  width: 3rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.12);
}

.auth-eyebrow {
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-panel h2 {
  margin: 0.15rem 0 0 0;
  font-size: 1.3rem;
}

.auth-panel p {
  margin: 0;
  color: var(--muted-foreground);
}

.auth-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.auth-meta-item {
  padding: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--muted);
}

.auth-meta-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.auth-meta-value {
  display: block;
  font-weight: 600;
}

.auth-card h1 {
  margin: 0.25rem 0 0.25rem;
}

.auth-card .auth-lead,
.auth-card p.lead {
  margin: 0 0 1.25rem;
  color: var(--muted-foreground);
}

.auth-card .form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.auth-card .auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  align-items: stretch;
}

.auth-actions-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.auth-card .auth-actions a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-card .auth-actions a:hover {
  text-decoration: underline;
}

.auth-footer {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--muted-foreground);
  text-align: center;
}

.auth-footer a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-alert {
  margin-bottom: 1rem;
}

.auth-error-list {
  margin: 0;
  padding-left: 1.1rem;
}

.text-small {
  font-size: 0.9rem;
}

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