:root {
  --bg: #050816;
  --bg-elevated: #0b1120;
  --bg-card: #020617;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.16);
  --accent-secondary: #38bdf8;
  --danger: #ef4444;
  --text: #e5e7eb;
  --text-soft: #9ca3af;
  --border: #1f2937;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 24px 80px rgba(15, 23, 42, 0.9);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #22c55e10, transparent 60%),
    radial-gradient(circle at bottom, #0ea5e910, transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-root {
  display: flex;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

.sidebar {
  width: 260px;
  padding: 24px 20px;
  border-right: 1px solid #111827;
  background: linear-gradient(
      160deg,
      rgba(15, 23, 42, 0.8),
      rgba(15, 23, 42, 0.98)
    ),
    radial-gradient(circle at top left, #22c55e15, transparent 60%);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: radial-gradient(circle at top, #22c55e40, #22c55e15);
  box-shadow: 0 14px 40px rgba(34, 197, 94, 0.4);
}

.logo-title {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.logo-subtitle {
  font-size: 12px;
  color: var(--text-soft);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.nav-btn:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  transform: translateX(2px);
}

.nav-btn.active {
  background: linear-gradient(90deg, #22c55e33, transparent);
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hint {
  font-size: 11px;
  color: var(--text-soft);
  line-height: 1.4;
}

.main {
  flex: 1;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left h1 {
  margin: 0;
  font-size: 22px;
}

.topbar-subtitle {
  font-size: 13px;
  color: var(--text-soft);
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(15, 23, 42, 0.9);
}

.badge-green {
  border-color: rgba(34, 197, 94, 0.5);
  color: #bbf7d0;
}

.section {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.section.active {
  display: flex;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-header h2 {
  margin: 0;
  font-size: 18px;
}

.section-actions {
  display: flex;
  gap: 10px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.charts-grid {
  margin-top: 10px;
}

.card {
  background: radial-gradient(circle at top left, #22c55e10, transparent 55%),
    radial-gradient(circle at bottom right, #0ea5e910, transparent 55%),
    rgba(15, 23, 42, 0.96);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.card-body.stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-soft);
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
}

.stat-value.green {
  color: #4ade80;
}

.stat-value.red {
  color: #f87171;
}

.cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-card,
.proxy-card {
  background: rgba(15, 23, 42, 0.96);
  border-radius: var(--radius-md);
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1.6fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.account-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-email {
  font-size: 14px;
  font-weight: 500;
}

.account-meta {
  font-size: 11px;
  color: var(--text-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid rgba(31, 41, 55, 0.9);
}

.pill.green {
  border-color: rgba(34, 197, 94, 0.7);
  color: #a7f3d0;
}

.pill.red {
  border-color: rgba(248, 113, 113, 0.7);
  color: #fecaca;
}

.pill.blue {
  border-color: rgba(56, 189, 248, 0.7);
  color: #bae6fd;
}

.account-actions,
.proxy-actions {
  display: flex;
  gap: 6px;
}

.primary-btn,
.ghost-btn {
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s ease, transform 0.08s ease,
    box-shadow 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #16a34a);
  color: #022c22;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.45);
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(34, 197, 94, 0.6);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.35);
}

.ghost-btn {
  background: rgba(15, 23, 42, 0.96);
  color: var(--text-soft);
  border: 1px solid rgba(55, 65, 81, 0.9);
}

.ghost-btn:hover {
  background: rgba(31, 41, 55, 0.96);
  color: var(--text);
}

.full-width {
  width: 100%;
  justify-content: center;
}

.logs-list {
  background: rgba(15, 23, 42, 0.96);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(31, 41, 55, 0.9);
  padding: 10px 0;
  max-height: 420px;
  overflow-y: auto;
}

.log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 6px 14px;
  border-bottom: 1px solid rgba(31, 41, 55, 0.7);
}

.log-row:last-child {
  border-bottom: none;
}

.log-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.log-message {
  color: var(--text);
}

.log-meta {
  color: var(--text-soft);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.9);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.hidden {
  pointer-events: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: 360px;
  max-width: 90vw;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 18px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.95);
  padding: 18px 18px 14px;
  display: none;
  flex-direction: column;
  gap: 10px;
}

.modal.active {
  display: flex;
}

.modal h3 {
  margin: 0 0 4px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.field span {
  color: var(--text-soft);
}

.field input {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.96);
  color: var(--text);
  font-size: 13px;
}

.field input:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.7);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.empty-state {
  font-size: 13px;
  color: var(--text-soft);
}

.chart-bar {
  margin-top: 4px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}

.chart-segment {
  flex: 1;
  border-radius: 8px;
  background: rgba(30, 64, 175, 0.35);
  position: relative;
  overflow: hidden;
}

.chart-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), #16a34a);
}

.chart-label {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #e5e7eb;
}

.chart-caption {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #d1d5db;
}

.imap-grid {
  display: grid;
  grid-template-columns: 0.95fr 1.35fr;
  gap: 18px;
}

.imap-cheatsheet {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.imap-row {
  display: grid;
  grid-template-columns: 0.9fr 1.3fr 0.8fr;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(55, 65, 81, 0.7);
  background: rgba(15, 23, 42, 0.7);
  font-size: 12px;
}

.imap-domain {
  color: #e5e7eb;
  font-weight: 600;
}

.imap-host,
.imap-port {
  color: var(--text-soft);
}

.toggle-row {
  margin-top: 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(55, 65, 81, 0.7);
  background: rgba(15, 23, 42, 0.7);
}

.toggle-title {
  font-size: 13px;
  font-weight: 600;
}

.toggle-sub {
  font-size: 11px;
  color: var(--text-soft);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(148, 163, 184, 0.25);
  border: 1px solid rgba(55, 65, 81, 0.8);
  transition: 0.15s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 2px;
  background: #e5e7eb;
  transition: 0.15s;
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.switch input:checked + .slider {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.65);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
  background: #bbf7d0;
}

@media (max-width: 1000px) {
  .imap-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-root {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-footer {
    margin-top: 0;
    margin-left: auto;
    max-width: 260px;
  }
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #22c55e40, transparent 55%),
    rgba(2, 6, 23, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.login-card {
  width: 100%;
  max-width: 360px;
  margin: 16px;
  padding: 20px 20px 16px;
  border-radius: 20px;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 32px 90px rgba(15, 23, 42, 0.98);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card h2 {
  margin: 0;
  font-size: 20px;
}

.login-sub {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text-soft);
}

.login-error {
  margin-top: 6px;
  min-height: 16px;
  font-size: 12px;
  color: #fecaca;
}

.login-overlay.hidden {
  display: none;
}

