/* ── Layout ─────────────────────────────────────────── */

body {
  background: #f0f0f0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: 100%;
  max-width: 400px;
  height: 450px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Nav bar ─────────────────────────────────────────── */

.app-nav {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-nav .brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: #212529;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-nav .brand i {
  color: #dc3545;
  font-size: 1rem;
}

.app-nav .back-btn {
  color: #6c757d;
  text-decoration: none;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 6px;
  transition: background 0.15s;
}

.app-nav .back-btn:hover {
  background: #f8f9fa;
  color: #212529;
}

.app-nav .page-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #495057;
  margin-left: auto;
  margin-right: auto;
}

.app-nav .spacer {
  width: 48px;
}

/* ── Page content ────────────────────────────────────── */

.app-content {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #adb5bd;
  margin-bottom: 8px;
}

.divider {
  height: 1px;
  background: #f0f0f0;
  margin: 12px 0;
}

/* ── Utility ─────────────────────────────────────────── */

.btn-red {
  background: #dc3545;
  color: #fff;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-red:hover {
  background: #bb2d3b;
}

/* ── Dashboard ───────────────────────────────────────── */

.stat-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
  flex: 1;
}

.stat-card .stat-value {
  font-size: 1rem;
  font-weight: 700;
  color: #212529;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.68rem;
  color: #6c757d;
  margin-top: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f9fa;
  border: none;
  text-decoration: none;
  color: #212529;
  font-size: 0.85rem;
  font-weight: 500;
  transition: background 0.15s;
  width: 100%;
}

.nav-btn:hover {
  background: #e9ecef;
  color: #212529;
}

.nav-btn i {
  font-size: 1rem;
  color: #6c757d;
  width: 20px;
  text-align: center;
}

.nav-btn .nav-btn-arrow {
  margin-left: auto;
  color: #adb5bd;
  font-size: 0.8rem;
}

/* ── Delete page ─────────────────────────────────────── */

.delete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  background: #f8f9fa;
  border-radius: 8px;
  gap: 8px;
}

.delete-row .delete-label {
  font-size: 0.84rem;
  color: #495057;
  font-weight: 500;
}

.delete-row input[type="number"] {
  width: 52px;
  font-size: 0.82rem;
  padding: 2px 6px;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  background: #fff;
  color: #212529;
  text-align: center;
}

.delete-row input[type="number"]:focus {
  outline: none;
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220,53,69,0.12);
}

.delete-row--stacked {
  flex-direction: column;
  align-items: flex-start;
}

.range-toggle {
  display: flex;
  background: #e9ecef;
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}

.range-toggle-btn {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #6c757d;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}

.range-toggle-btn.active {
  background: #fff;
  color: #212529;
  box-shadow: 0 1px 3px rgba(0,0,0,0.10);
}

.range-input-zone {
  position: relative;
  width: 100%;
  height: 38px;
}

.range-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
  display: flex;
  align-items: center;
}

.date-range-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.date-range-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #adb5bd;
}

.date-input {
  font-size: 0.75rem;
  padding: 3px 7px;
  border: 1px solid #dee2e6;
  border-radius: 5px;
  background: #fff;
  color: #212529;
  width: 100%;
  cursor: pointer;
}

.date-input:focus {
  outline: none;
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220,53,69,0.12);
}

.delete-warning {
  font-size: 0.72rem;
  color: #856404;
  background: #fff9e6;
  border: 1px solid #ffe69c;
  border-radius: 7px;
  padding: 7px 10px;
  text-align: center;
}

/* ── Email browser ───────────────────────────────────── */

.emails-layout {
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
}

.emails-layout .email-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.emails-layout .email-footer {
  flex-shrink: 0;
}

.filter-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid #dee2e6;
  background: #fff;
  color: #6c757d;
  transition: all 0.15s;
  cursor: pointer;
}

.filter-btn.active,
.filter-btn:hover {
  background: #212529;
  border-color: #212529;
  color: #fff;
}

/* Drag states */
.filter-btn[draggable="true"] {
  cursor: grab;
}

.filter-btn.dragging {
  opacity: 0.35;
  cursor: grabbing;
}

.filter-btn.drag-over {
  outline: 2px dashed #adb5bd;
  outline-offset: 2px;
}

.email-list {
  max-height: 240px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.email-list::-webkit-scrollbar        { width: 4px; }
.email-list::-webkit-scrollbar-track  { background: transparent; }
.email-list::-webkit-scrollbar-thumb  { background: #dee2e6; border-radius: 4px; }

.email-item {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  gap: 8px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.12s;
}

.email-item:last-child { border-bottom: none; }
.email-item:hover      { background: #fafafa; }

.email-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e9ecef;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #6c757d;
  flex-shrink: 0;
}

.email-meta {
  flex: 1;
  min-width: 0;
}

.email-sender {
  font-size: 0.78rem;
  font-weight: 600;
  color: #212529;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-subject {
  font-size: 0.72rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Scrollable stat card ────────────────────────────── */

.stat-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 8px;
  gap: 0;
}

.stat-scroll-btn {
  background: none;
  border: none;
  color: #adb5bd;
  font-size: 0.62rem;
  padding: 1px 4px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.12s;
}

.stat-scroll-btn:hover {
  color: #6c757d;
}

/* ── Stats page ──────────────────────────────────────── */

.stats-compact {
  padding: 12px 16px;
}

.stats-compact .section-label {
  margin-bottom: 4px;
}

.stats-compact .stat-card {
  padding: 6px 10px;
}

.stats-compact .stat-value {
  font-size: 0.85rem;
}

.stats-compact .stat-label {
  font-size: 0.62rem;
  margin-top: 1px;
}

.chart-wrap {
  width: 160px;
  flex-shrink: 0;
}

#category-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name {
  font-size: 0.74rem;
  color: #495057;
  width: 85px;
  flex-shrink: 0;
}

.legend-bar-track {
  flex: 1;
  height: 5px;
  background: #e9ecef;
  border-radius: 3px;
  overflow: hidden;
}

.legend-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.legend-count {
  font-size: 0.7rem;
  color: #6c757d;
  width: 44px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Inactive accounts ───────────────────────────────── */

.account-list {
  max-height: 280px;
  overflow-y: auto;
}

.account-list::-webkit-scrollbar        { width: 4px; }
.account-list::-webkit-scrollbar-track  { background: transparent; }
.account-list::-webkit-scrollbar-thumb  { background: #dee2e6; border-radius: 4px; }

.account-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: #f8f9fa;
  border-radius: 7px;
}

.account-name { color: #212529; }
[data-theme="dark"] .account-name { color: #f0f0f0; }

.account-item input[type="checkbox"] {
  accent-color: #dc3545;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.account-email {
  font-size: 0.78rem;
  color: #212529;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-days {
  font-size: 0.7rem;
  color: #adb5bd;
  flex-shrink: 0;
}

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

/* ── Mode toggle button ───────────────────────────────── */

#mode-toggle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid #dee2e6;
  background: #f8f9fa;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

#mode-toggle:hover {
  background: #e9ecef;
  border-color: #ced4da;
}

#mode-toggle img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

[data-theme="dark"] #mode-toggle {
  background: #2a2a2a;
  border-color: #444;
}

[data-theme="dark"] #mode-toggle:hover {
  background: #333;
  border-color: #555;
}

/* ── Dark mode ───────────────────────────────────────── */

[data-theme="dark"] body {
  background: #121212;
}

[data-theme="dark"] .app-shell {
  background: #1e1e1e;
  box-shadow: 0 4px 24px rgba(0,0,0,0.40);
}

[data-theme="dark"] .app-nav {
  background: #1e1e1e;
  border-bottom-color: #2d2d2d;
}

[data-theme="dark"] .app-nav .brand {
  color: #f0f0f0;
}

[data-theme="dark"] .app-nav .back-btn {
  color: #adb5bd;
}

[data-theme="dark"] .app-nav .back-btn:hover {
  background: #2a2a2a;
  color: #f0f0f0;
}

[data-theme="dark"] .app-nav .page-title {
  color: #ccc;
}

[data-theme="dark"] .app-content {
  color: #f0f0f0;
}

[data-theme="dark"] .section-label {
  color: #6c757d;
}

[data-theme="dark"] .divider {
  background: #2d2d2d;
}

[data-theme="dark"] .stat-card {
  background: #2a2a2a;
}

[data-theme="dark"] .stat-card .stat-value {
  color: #f0f0f0;
}

[data-theme="dark"] .stat-card .stat-label {
  color: #adb5bd;
}

[data-theme="dark"] .nav-btn {
  background: #2a2a2a;
  color: #f0f0f0;
}

[data-theme="dark"] .nav-btn:hover {
  background: #333;
  color: #f0f0f0;
}

[data-theme="dark"] .nav-btn i {
  color: #adb5bd;
}

[data-theme="dark"] .nav-btn .nav-btn-arrow {
  color: #555;
}

[data-theme="dark"] .delete-row {
  background: #2a2a2a;
}

[data-theme="dark"] .delete-row .delete-label {
  color: #ccc;
}

[data-theme="dark"] .delete-row input[type="number"] {
  background: #1e1e1e;
  border-color: #444;
  color: #f0f0f0;
}

[data-theme="dark"] .range-toggle {
  background: #333;
}

[data-theme="dark"] .range-toggle-btn {
  color: #adb5bd;
}

[data-theme="dark"] .range-toggle-btn.active {
  background: #1e1e1e;
  color: #f0f0f0;
}

[data-theme="dark"] .date-input {
  background: #1e1e1e;
  border-color: #444;
  color: #f0f0f0;
}

[data-theme="dark"] .filter-btn {
  background: #2a2a2a;
  border-color: #444;
  color: #adb5bd;
}

[data-theme="dark"] .filter-btn.active,
[data-theme="dark"] .filter-btn:hover {
  background: #f0f0f0;
  border-color: #f0f0f0;
  color: #212529;
}

[data-theme="dark"] .email-list {
  border-color: #333;
}

[data-theme="dark"] .email-item {
  border-bottom-color: #2a2a2a;
}

[data-theme="dark"] .email-item:hover {
  background: #2a2a2a;
}

[data-theme="dark"] .email-avatar {
  background: #333;
  color: #adb5bd;
}

[data-theme="dark"] .email-sender {
  color: #f0f0f0;
}

[data-theme="dark"] .email-subject {
  color: #adb5bd;
}

[data-theme="dark"] .account-item {
  background: #2a2a2a;
}

[data-theme="dark"] .account-email {
  color: #f0f0f0;
}

[data-theme="dark"] .account-days {
  color: #6c757d;
}

[data-theme="dark"] .legend-name {
  color: #ccc;
}

[data-theme="dark"] .legend-bar-track {
  background: #333;
}

[data-theme="dark"] .legend-count {
  color: #adb5bd;
}

[data-theme="dark"] .login-title {
  color: #f0f0f0;
}

