@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Plus+Jakarta+Sans:wght@400;600&display=swap");

:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1caed7;
  --accent-dark: #1493b8;
  --primary: #1caed7;
  --success: #16a34a;
  --error: #dc2626;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #dff5fb 0%, transparent 60%),
              radial-gradient(900px 500px at 90% -20%, #e9f4ff 0%, transparent 60%),
              var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: linear-gradient(90deg, #0f172a 0%, #0b2a3a 60%, #0f172a 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  font-family: "Space Grotesk", "Plus Jakarta Sans", sans-serif;
}
.brand-logo {
  height: 26px;
  width: auto;
}
.topbar nav a {
  color: #e5e7eb;
  margin-left: 10px;
  text-decoration: none;
  background: rgba(255,255,255,0.08);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,0.18); }

.container {
  max-width: 1100px;
  margin: 28px auto;
  padding: 0 20px 50px;
}

.card {
  background: var(--card);
  padding: 18px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.alert {
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #0b4a6f; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--card);
  padding: 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 600; }

form label { display: block; margin-top: 12px; font-weight: 600; overflow: visible; }
form input, form select, form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-top: 6px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(28, 174, 215, 0.18);
}
button, .button {
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
button:hover, .button:hover { background: var(--accent-dark); }
button.secondary {
  background: #e2f4fa;
  color: #0b2a3a;
}
button.secondary:hover { background: #c8ecf6; }
.button.secondary {
  background: #e2f4fa;
  color: #0b2a3a;
}
.button.secondary:hover { background: #c8ecf6; }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.6);
  border-top-color: #fff;
  border-radius: 50%;
  margin-left: 8px;
  display: none;
  animation: spin 0.8s linear infinite;
}

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

.help {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 12px;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 11px;
  font-weight: 700;
  position: relative;
  cursor: help;
  z-index: 9999;
}

.info::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 24px;
  background: #111827;
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
  width: 280px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 9999;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.info::before {
  content: "";
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #111827 transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.info:hover::after,
.info:hover::before {
  opacity: 1;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 14px;
  align-items: end;
  background: var(--card);
  padding: 12px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.filter-group {
  display: flex;
  flex-direction: column;
}
.filter-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.filter-group input,
.filter-group select {
  margin-top: 0;
}
.filter-wide {
  grid-column: span 2;
}
.filter-actions {
  align-self: end;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}

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

.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex: 0 0 auto;
}

.setup-checklist {
  background: #ffffff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin: 16px auto 0;
  padding: 12px 18px;
}

.setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setup-title {
  font-weight: 700;
  font-size: 14px;
}

.setup-progress {
  flex: 1;
  height: 8px;
  background: #e8eef5;
  border-radius: 999px;
  overflow: hidden;
}
.setup-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #5fd0ee);
  width: 0;
}

.setup-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.setup-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 10px;
}
.setup-step.done {
  color: #0f766e;
  background: #ecfdf5;
}

.field {
  position: relative;
}
.field .input-icon {
  position: absolute;
  left: 12px;
  top: 38px;
  color: #94a3b8;
  pointer-events: none;
}
.field input,
.field select,
.field textarea {
  padding-left: 36px;
}

.empty-state {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  color: var(--muted);
}

.inline { display: inline-block; margin-right: 6px; }
pre { white-space: pre-wrap; word-break: break-word; background: #f3f4f6; padding: 8px; border-radius: 6px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e2f4fa;
  color: #0b2a3a;
  margin-left: 6px;
}

.badge-ham { background: #dcfce7; color: #166534; }
.badge-quarantine { background: #fef9c3; color: #854d0e; }
.badge-trash { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: #e2e8f0; color: #334155; }
.badge-new { background: rgba(28, 174, 215, 0.16); color: #0b6f8c; }

.suggestion-list {
  display: grid;
  gap: 8px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.suggestion-meta {
  font-size: 12px;
  color: var(--muted);
}

.email-cell {
  min-width: 260px;
}
.email-meta {
  font-size: 12px;
  color: var(--muted);
}
.email-subject {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  color: #0b3a4a;
}
.email-subject:hover {
  color: var(--primary);
}

table tbody tr {
  transition: background 0.2s ease;
}
table tbody tr:hover {
  background: #f7fbfd;
}
.email-viewed {
  background: #f8fafc;
  opacity: 0.85;
}
.email-viewed .email-subject {
  color: #5b6b76;
}
.email-viewed .email-meta {
  color: #8a9aa6;
}
.email-new td:first-child {
  border-left: 4px solid var(--accent);
}
.email-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.date-range {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr);
  gap: 8px;
}
.date-range input {
  margin-top: 6px;
  width: auto;
  flex: 1 1 0;
}

table tbody td {
  font-size: 14px;
}

.score-grid {
  display: grid;
  gap: 4px;
  font-size: 13px;
}
.score-grid strong {
  font-weight: 700;
}
.spam-score {
  font-weight: 700;
}
.spam-score-med {
  color: #b58100;
}
.spam-score-high {
  color: #b42318;
}
.ai-pop {
  margin-top: 8px;
  position: relative;
}
.ai-pop summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ffffff;
  background: var(--primary);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.ai-pop summary::-webkit-details-marker { display: none; }
.ai-pop[open] summary { background: #1594bb; }
.ai-pop-panel {
  position: absolute;
  z-index: 20;
  left: 0;
  top: 24px;
  min-width: 240px;
  max-width: 320px;
  background: #ffffff;
  color: #1f2933;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.ai-pop-panel * {
  color: #1f2933;
}
.ai-pop-title {
  font-weight: 700;
  font-size: 12px;
  margin: 6px 0 4px;
}
.ai-list {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: #1f2933;
}
.actions-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.usage-card {
  text-align: left;
}
.usage-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.usage-value {
  font-size: 20px;
  font-weight: 700;
  margin: 6px 0;
}
.usage-sub {
  font-size: 12px;
  color: var(--muted);
}
.usage-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: end;
  gap: 6px;
  height: 140px;
  padding: 10px 0 4px;
}
.usage-bar {
  background: var(--primary);
  border-radius: 8px 8px 2px 2px;
  min-height: 2px;
}
.usage-bar.alt {
  background: #0b6f8c;
}
.usage-axis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pagination-meta {
  color: var(--muted);
  font-size: 12px;
}
.pagination-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.pagination .button {
  margin-top: 0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 13px;
}
.pagination .button.active {
  background: var(--accent);
  color: #fff;
}
.pagination-ellipsis {
  color: var(--muted);
  padding: 0 6px;
}
.pagination-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pagination-jump label {
  font-size: 12px;
  color: var(--muted);
}
.pagination-jump input[type="number"] {
  width: 90px;
  margin-top: 0;
}
.learning-list {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}
.learning-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.learning-main {
  flex: 1 1 auto;
  min-width: 0;
}
.learning-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.learning-subject {
  font-weight: 700;
  color: #0b3a4a;
  margin-bottom: 4px;
}
.learning-from {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.learning-snippet {
  font-size: 13px;
  color: #2f4a55;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.actions-row form.inline {
  margin: 0;
}

.actions-row select {
  width: auto;
  min-width: 160px;
}

.actions-row button {
  white-space: nowrap;
}
