/* ORMdoo Admin - Dark Mode Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #1e293b;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #334155;
  --border-color: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #3b82f6;
  --accent-green: #22c55e;
  --accent-yellow: #eab308;
  --accent-red: #ef4444;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

/* Header / Topbar */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.3);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dot {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-dot::after {
  content: 'O';
  color: white;
  font-weight: 700;
  font-size: 20px;
}

.brand-text .eyebrow {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 500;
}

.brand-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn.ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn.primary {
  background: var(--accent-blue);
  color: white;
}

.btn.primary:hover {
  background: #2563eb;
}

.btn.danger {
  background: var(--accent-red);
  color: white;
}

.btn.danger:hover {
  background: #dc2626;
}

.btn.sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-warning {
  background: var(--accent-yellow);
  color: #1e293b;
}

.btn-warning:hover {
  background: #ca8a04;
}

.btn-info {
  background: var(--accent-cyan);
  color: #1e293b;
}

.btn-info:hover {
  background: #0891b2;
}

.btn-success {
  background: var(--accent-green);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
}

.btn-danger {
  background: var(--accent-red);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Main Content */
.main-content {
  padding: 24px;
  max-width: 1600px;
  margin: 0 auto;
}

.main-content.grid-2 {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 24px;
  max-width: 1400px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.2);
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-card:nth-child(1) .value { color: var(--accent-blue); }
.stat-card:nth-child(2) .value { color: var(--accent-green); }
.stat-card:nth-child(3) .value { color: var(--accent-yellow); }

/* Card Panel */
.card {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.2);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-header .hint {
  font-size: 13px;
  color: var(--text-muted);
}

.card-body {
  padding: 24px;
}

/* Table Actions */
.table-actions {
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  gap: 12px;
  align-items: center;
}

/* Table Styles */
.table-container {
  overflow-x: auto;
}

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

thead {
  background: var(--bg-secondary);
}

thead th {
  padding: 14px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s ease;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: 16px 20px;
  vertical-align: middle;
  font-size: 13px;
  color: var(--text-secondary);
}

tbody td:not(:last-child) {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Actions column - no width constraint */
tbody td:last-child {
  white-space: normal;
  min-width: 320px;
}

/* Instance Name */
.instance-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.instance-link {
  color: var(--accent-blue);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: color 0.2s ease;
}

.instance-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

.instance-name .icon-link {
  font-size: 14px;
  opacity: 0.7;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-version {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-production {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-staging {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.badge-active {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-inactive {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badges-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Action Buttons Group */
.actions-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.action-stack {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

.form-group small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Checkbox */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.checkbox-line:hover {
  border-color: var(--accent-blue);
}

.checkbox-line span {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Toggle Switch */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  background: var(--border-color);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle input[type="checkbox"]::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: all 0.2s ease;
}

.toggle input[type="checkbox"]:checked {
  background: var(--accent-green);
}

.toggle input[type="checkbox"]:checked::before {
  left: 20px;
}

.toggle span {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.form-actions .btn {
  padding: 10px 20px;
}

/* Alerts */
.alert {
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
}

.alert-warning {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: #fde047;
}

.alert-info {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #67e8f9;
}

.alert strong {
  display: block;
  margin-bottom: 8px;
}

.alert ul {
  margin: 0;
  padding-left: 20px;
}

.alert li {
  margin: 4px 0;
  font-size: 13px;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-content {
  background: var(--bg-card);
  margin: 5% auto;
  border-radius: 16px;
  width: 90%;
  max-width: 700px;
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.5);
  animation: slideIn 0.3s ease;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-header h3 span {
  color: var(--accent-blue);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Config Modal Pre */
.modal-body pre {
  background: #0d1117;
  color: #c9d1d9;
  padding: 20px;
  border-radius: 8px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  border: 1px solid #30363d;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
}

/* Loading Spinner */
.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Auth Page (Login) */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-page .shell {
  width: 100%;
  max-width: 400px;
}

.auth-page .brand {
  justify-content: center;
  margin-bottom: 32px;
}

.auth-page .card {
  padding: 32px;
}

.auth-page .card h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
  text-align: center;
}

.auth-page .card form label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.auth-page .card form input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.auth-page .card form input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.auth-page .card form input::placeholder {
  color: var(--text-muted);
}

.auth-page .card form .btn {
  width: 100%;
  padding: 12px 20px;
  margin-top: 8px;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

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

  .nav-actions {
    gap: 8px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
    height: auto;
    min-height: 64px;
    flex-direction: column;
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .nav-actions {
    width: 100%;
    justify-content: center;
  }

  .main-content {
    padding: 16px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  thead th,
  tbody td {
    padding: 12px 10px;
  }

  .badges-group {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-actions {
    flex-wrap: wrap;
  }

  /* Phase 1: Tables - scrollable container */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }

  .table-container::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to left, var(--bg-card), transparent);
    pointer-events: none;
    opacity: 0.8;
  }

  /* Phase 2: Modals */
  .modal-content {
    width: 95%;
    margin: 2% auto;
    max-height: 90vh;
    border-radius: 12px;
  }

  .modal-body {
    padding: 16px;
    max-height: 70vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-header h3 {
    font-size: 16px;
  }

  /* Phase 4: Boutons Actions */
  .actions-group, .action-stack {
    gap: 6px;
  }

  .btn.sm, .btn-sm {
    padding: 5px 8px;
    font-size: 11px;
  }

  /* Phase 5: Typographie */
  .brand-text h1 {
    font-size: 18px;
  }

  .card-header h2 {
    font-size: 16px;
  }

  .stat-card .value {
    font-size: 28px;
  }

  /* Phase 6: Espacements */
  .stat-card {
    padding: 16px;
  }

  .card-body {
    padding: 16px;
  }

  .card-header {
    padding: 16px;
  }
}

/* ============================================
   MOBILE STYLES (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
  /* Phase 1: Tables - card layout - Force full width on all elements */
  .card-body {
    padding: 0 !important;
  }

  .table-container {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .table-container::after {
    display: none !important;
  }

  table {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: block !important;
    width: 100% !important;
  }

  tbody tr {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-sizing: border-box !important;
  }

  tbody tr:hover {
    background: var(--bg-card-hover);
  }

  tbody td {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    padding: 8px 0 !important;
    border-bottom: 1px solid var(--border-color);
    max-width: none !important;
    white-space: normal !important;
    text-overflow: initial !important;
    overflow: visible !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }

  tbody td:last-child {
    border-bottom: none !important;
    min-width: auto !important;
    padding-top: 12px !important;
    display: block !important;
    width: 100% !important;
  }

  tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    margin-right: 12px;
    min-width: 80px;
  }

  tbody td:last-child::before {
    display: none;
  }

  /* Actions group in last cell takes full width */
  tbody td:last-child .actions-group,
  tbody td:last-child .action-stack {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }

  tbody td:last-child .actions-group .btn,
  tbody td:last-child .action-stack .btn,
  tbody td:last-child .actions-group button,
  tbody td:last-child .action-stack button,
  .actions-group .btn.btn-sm,
  .actions-group button.btn-sm {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }

  /* Phase 2: Modals - fullscreen */
  .modal-content {
    width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    max-height: 100vh;
  }

  .modal-body {
    max-height: calc(100vh - 70px);
  }

  /* Phase 3: Formulaires */
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .form-group {
    margin-bottom: 16px;
  }

  .form-input {
    padding: 10px 12px;
  }

  /* Phase 4: Boutons Actions */
  .actions-group {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .actions-group .btn,
  .actions-group button {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
    box-sizing: border-box !important;
  }

  .action-stack {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 8px !important;
  }

  .action-stack .btn,
  .action-stack button {
    width: 100% !important;
    justify-content: center !important;
    display: flex !important;
    box-sizing: border-box !important;
  }

  /* Phase 5: Typographie */
  .brand-text h1 {
    font-size: 16px;
  }

  .stat-card .value {
    font-size: 24px;
  }

  .stat-card .label {
    font-size: 11px;
  }

  /* Phase 6: Espacements */
  .main-content {
    padding: 12px;
  }

  .stat-card {
    padding: 12px;
  }

  .empty-state {
    padding: 40px 16px;
  }

  /* Phase 7: Topbar */
  .topbar {
    padding: 12px;
  }

  .logo-dot {
    width: 32px;
    height: 32px;
  }

  .logo-dot::after {
    font-size: 16px;
  }

  .brand-text .eyebrow {
    font-size: 10px;
  }

  .nav-actions .btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Phase 8: Auth Page */
  .auth-page .card {
    padding: 20px;
  }

  .auth-page .card h2 {
    font-size: 18px;
  }

  /* Badges on mobile */
  .badges-group {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
  }

  .badge {
    padding: 3px 8px;
    font-size: 11px;
  }

  /* Instance name on mobile */
  .instance-name {
    justify-content: flex-end;
  }

  .instance-link {
    font-size: 14px;
  }

  /* Table actions on mobile */
  .table-actions {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Cards */
  .card {
    border-radius: 8px;
  }

  /* Stats grid */
  .stats-grid {
    gap: 12px;
    margin-bottom: 16px;
  }
}

/* ============================================
   SMALL MOBILE (max-width: 375px - iPhone SE)
   ============================================ */
@media (max-width: 375px) {
  .brand {
    gap: 8px;
  }

  .logo-dot {
    width: 28px;
    height: 28px;
  }

  .logo-dot::after {
    font-size: 14px;
  }

  .brand-text h1 {
    font-size: 14px;
  }

  .brand-text .eyebrow {
    font-size: 9px;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .btn {
    padding: 5px 8px;
    font-size: 10px;
  }

  .main-content {
    padding: 8px;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-card .value {
    font-size: 20px;
  }

  .stat-card .label {
    font-size: 10px;
  }

  .card-header h2 {
    font-size: 14px;
  }

  tbody td {
    font-size: 12px;
  }

  tbody td::before {
    font-size: 10px;
    min-width: 70px;
  }

  .btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .btn.sm, .btn-sm {
    padding: 4px 6px;
    font-size: 10px;
  }

  .modal-header h3 {
    font-size: 14px;
  }

  .modal-body {
    padding: 12px;
  }

  .form-input {
    padding: 8px 10px;
    font-size: 13px;
  }

  .auth-page .card {
    padding: 16px;
  }

  .auth-page .card h2 {
    font-size: 16px;
    margin-bottom: 20px;
  }
}

/* ============================================
   TOUCH TARGETS - Ensure minimum 44px height
   ============================================ */
@media (max-width: 768px) {
  .btn, .btn-sm, .btn.sm {
    min-height: 44px;
    min-width: 44px;
  }

  .modal-close {
    min-width: 44px;
    min-height: 44px;
  }

  .toggle input[type="checkbox"] {
    min-width: 44px;
    min-height: 28px;
  }

  input[type="checkbox"] {
    min-width: 24px;
    min-height: 24px;
  }
}

/* ============================================
   LANDSCAPE ORIENTATION FIXES
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
  .modal-content {
    margin: 1% auto;
    max-height: 95vh;
  }

  .modal-body {
    max-height: 70vh;
  }

  .auth-page {
    padding: 10px;
  }
}

/* ============================================
   TABS
   ============================================ */
.tabs-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  bottom: -2px;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ============================================
   FILTERS ROW
   ============================================ */
.filters-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#pageInfo {
  color: var(--text-secondary);
  font-size: 14px;
}

/* ============================================
   EMAIL DETAILS
   ============================================ */
.email-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row strong {
  color: var(--text-secondary);
  font-weight: 600;
}

.message-box {
  background: var(--bg-input);
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
}

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 12px;
  border-radius: 6px;
  color: var(--accent-red);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.modal-body {
  padding: 0;
}

@media (max-width: 768px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    white-space: nowrap;
  }
}

/* ============================================
   EMAIL MODAL
   ============================================ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.2s ease-out;
}

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

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--text-primary);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

textarea.form-input {
  resize: vertical;
  min-height: 120px;
  font-family: inherit;
  line-height: 1.5;
}

/* Responsive modal */
@media (max-width: 768px) {
  .modal {
    padding: 10px;
  }

  .modal-content {
    padding: 16px;
  }

  .modal-header h2 {
    font-size: 18px;
  }
}

/* ============================================
   ADMIN PASSWORD DISPLAY
   ============================================ */
.admin-passwd {
  display: inline-block;
  padding: 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: all;
}

.admin-passwd:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.1);
}

.admin-passwd:active {
  transform: scale(0.98);
}

.text-muted {
  color: var(--text-muted);
  font-style: italic;
}
