/* ============================================================
   LECTOR MAIL — Minimalist Theme
   Inspired by Linear / Notion / Vercel
   Pure whites, hairline borders, zero gradients
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ── */
:root {
  --bg: #ffffff;
  --bg-page: #fafafa;
  --bg-hover: #f5f5f5;
  --bg-active: #f0f0f0;
  --text-1: #111111;
  --text-2: #444444;
  --text-3: #888888;
  --border: #e5e5e5;
  --border-dark: #d0d0d0;
  --accent: #111111;
  --accent-inv: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #2563eb;
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --radius: 6px;
  --radius-sm: 4px;
  --transition: 0.15s ease;
}

/* ── Reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

/* ────────────────────────────────────────────
   AUTH (login / install)
   ──────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg-page);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
}

.auth-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.auth-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-logo span {
  color: var(--text-3);
  font-weight: 400;
}

.auth-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.auth-card p.subtitle {
  color: var(--text-3);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* ────────────────────────────────────────────
   FORMS
   ──────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.form-control {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--text-1);
}

.form-control::placeholder {
  color: #bbb;
}

select.form-control {
  cursor: pointer;
}

/* ────────────────────────────────────────────
   BUTTONS
   ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.4;
}

/* Primary = solid black */
.btn-primary {
  background: var(--accent);
  color: var(--accent-inv);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: #333;
  border-color: #333;
}

/* Secondary = ghost outlined */
.btn-secondary {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text-2);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-dark);
}

.btn-success {
  background: var(--bg);
  border-color: #bbf7d0;
  color: var(--success);
}

.btn-success:hover {
  background: #f0fdf4;
}

.btn-danger {
  background: var(--bg);
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-warning {
  background: var(--bg);
  border-color: #fde68a;
  color: var(--warning);
}

.btn-info {
  background: var(--bg);
  border-color: #bfdbfe;
  color: var(--info);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.65rem 1.5rem;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ────────────────────────────────────────────
   APP LAYOUT
   ──────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 0 1rem;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 26px;
  height: 26px;
  background: var(--text-1);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-brand>span {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand>span em {
  color: var(--text-3);
  font-style: normal;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.5rem;
  overflow-y: auto;
}

.nav-section-title {
  padding: 0.4rem 0.5rem 0.2rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.45rem 0.6rem;
  color: var(--text-3);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 400;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  margin-bottom: 1px;
}

.nav-item:hover {
  color: var(--text-1);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--text-1);
  background: var(--bg-active);
  font-weight: 500;
}

.nav-item .nav-icon {
  font-size: 0.85rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-footer {
  padding: 0.75rem 0.75rem;
  border-top: 1px solid var(--border);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: default;
}

.user-pill:hover {
  background: var(--bg-hover);
}

.avatar {
  width: 26px;
  height: 26px;
  background: var(--text-1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--bg);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-info .name {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .role {
  font-size: 0.68rem;
  color: var(--text-3);
}

.logout-btn {
  color: var(--text-3);
  text-decoration: none;
  font-size: 1rem;
  transition: color var(--transition);
  flex-shrink: 0;
}

.logout-btn:hover {
  color: var(--danger);
}

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 199;
}

.sidebar-overlay.active {
  display: block;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}

.hamburger:hover {
  background: var(--bg-hover);
}

.hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-2);
  border-radius: 1px;
}

.page-content {
  padding: 1.5rem 2rem;
  flex: 1;
  max-width: 1200px;
}

/* ────────────────────────────────────────────
   DIVIDER SECTION TITLES
   ──────────────────────────────────────────── */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

/* ────────────────────────────────────────────
   STATS GRID
   ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg);
  padding: 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.stat-icon {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.stat-icon.purple,
.stat-icon.blue,
.stat-icon.green,
.stat-icon.orange {}

/* emoji handles color */
.stat-info .value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-info .label {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* ────────────────────────────────────────────
   CARDS
   ──────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-2);
}

.card-body {
  padding: 1.25rem;
}

/* ────────────────────────────────────────────
   TABLES
   ──────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-page);
}

tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-page);
}

.td-truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ────────────────────────────────────────────
   BADGES
   ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 500;
  border: 1px solid;
}

.badge-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.badge-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.badge-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.badge-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.badge-purple {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}

/* ────────────────────────────────────────────
   ALERTS
   ──────────────────────────────────────────── */
.alert {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

/* ────────────────────────────────────────────
   FILTER BAR
   ──────────────────────────────────────────── */
.filter-bar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

/* ────────────────────────────────────────────
   ACCOUNT CARDS
   ──────────────────────────────────────────── */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.account-card {
  background: var(--bg);
  padding: 1.1rem 1.25rem;
  transition: background var(--transition);
}

.account-card:hover {
  background: var(--bg-page);
}

.account-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.provider-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--bg-page);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.account-name {
  font-weight: 600;
  font-size: 0.85rem;
}

.account-email {
  font-size: 0.75rem;
  color: var(--text-3);
}

.account-meta {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.account-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ────────────────────────────────────────────
   CHECKBOX
   ──────────────────────────────────────────── */
.custom-check {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.custom-check input[type=checkbox] {
  width: 14px;
  height: 14px;
  accent-color: var(--text-1);
  cursor: pointer;
}

/* ────────────────────────────────────────────
   MODAL
   ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  transform: translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color var(--transition);
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

/* ────────────────────────────────────────────
   SPINNER
   ──────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-top-color: var(--text-1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ────────────────────────────────────────────
   TOAST
   ──────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
  max-width: calc(100vw - 2rem);
}

.toast {
  background: var(--text-1);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.2s ease;
  min-width: 240px;
  max-width: 340px;
  font-size: 0.8rem;
}

.toast.success {
  background: #166534;
}

.toast.error {
  background: #991b1b;
}

.toast.info {
  background: #1e40af;
}

@keyframes slideIn {
  from {
    transform: translateX(110%);
    opacity: 0;
  }

  to {
    transform: none;
    opacity: 1;
  }
}

/* ────────────────────────────────────────────
   PAGINATION
   ──────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 1rem 0 0;
  flex-wrap: wrap;
}

.page-btn {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--transition);
  text-decoration: none;
}

.page-btn:hover {
  background: var(--bg-hover);
}

.page-btn.active {
  background: var(--text-1);
  border-color: var(--text-1);
  color: var(--bg);
}

/* ────────────────────────────────────────────
/* ────────────────────────────────────────────
   LUCIDE ICONS
   ──────────────────────────────────────────── */
[data-lucide],
svg.lucide {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.nav-icon[data-lucide],
.nav-icon svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

.nav-item.active .nav-icon[data-lucide],
.nav-item.active .nav-icon svg {
  opacity: 1;
}

.btn [data-lucide],
.btn svg.lucide {
  width: 13px;
  height: 13px;
}

.stat-icon [data-lucide],
.stat-icon svg.lucide {
  width: 20px;
  height: 20px;
  stroke-width: 1.5;
}

/* ────────────────────────────────────────────
   UTILITIES

   ──────────────────────────────────────────── */
.text-muted {
  color: var(--text-3);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-accent {
  color: var(--text-1);
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 0.5rem;
}

.gap-2 {
  gap: 1rem;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.w-100 {
  width: 100%;
}

.fs-sm {
  font-size: 0.78rem;
}

.fw-600 {
  font-weight: 600;
}

/* ────────────────────────────────────────────
   RESPONSIVE — Tablet (≤900px)
   ──────────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --sidebar-w: 200px;
  }

  .page-content {
    padding: 1.25rem 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ────────────────────────────────────────────
   RESPONSIVE — Mobile (≤768px)
   ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .page-content {
    padding: 1rem;
  }

  .topbar {
    padding: 0 1rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .btn {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
  }

  .auth-card {
    padding: 1.5rem 1.25rem;
  }

  #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
  }

  .modal {
    padding: 1.1rem;
  }
}

/* ────────────────────────────────────────────
   RESPONSIVE — Small (≤480px)
   ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .btn-lg {
    padding: 0.55rem 1.1rem;
  }
}