/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:    #1a2f4e;
  --blue:    #0078d4;
  --blue-lt: #e8f3fc;
  --green:   #107c10;
  --orange:  #d83b01;
  --orange-lt: #fff3cd;
  --red:     #d13438;
  --red-lt:  #fde7e9;
  --gray:    #605e5c;
  --gray-lt: #f3f2f1;
  --border:  #e1dfdd;
  --white:   #ffffff;
  --shadow:  0 2px 8px rgba(0,0,0,.08);
  --radius:  8px;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: #f0f2f5;
  color: #323130;
  min-height: 100vh;
}

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  background: var(--navy);
  color: var(--white);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

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

.logo { font-size: 26px; }

.topbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.topbar-title h1 span { color: #5bc4f5; }
.topbar-title .mailbox { font-size: 11px; color: #a9c5e8; margin-top: 1px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-block {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c8d8ea;
}

.label-sm { opacity: .7; }

/* Connection dot */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-on  { background: #5acd5a; box-shadow: 0 0 0 3px rgba(90,205,90,.25); }
.dot-off { background: #888; }
.dot-err { background: #f66; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary   { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: #006cc1; }
.btn-secondary { background: rgba(255,255,255,.12); color: var(--white); }
.btn-secondary:hover { background: rgba(255,255,255,.22); }

.btn-danger-outline {
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--orange);
  padding: 5px 12px;
  font-size: 12px;
}
.btn-danger-outline:hover { background: rgba(216,59,1,.08); }

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

/* ── Settings panel ────────────────────────────────────────────────── */
.settings-panel {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: max-height .3s ease;
}

.settings-panel.hidden { display: none; }

.settings-inner {
  padding: 24px;
  max-width: 480px;
}

.settings-inner h2 {
  font-size: 16px;
  margin-bottom: 20px;
  color: var(--navy);
}

.form-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row label {
  width: 160px;
  font-size: 13px;
  color: var(--gray);
  flex-shrink: 0;
}

.form-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: var(--font);
  width: 120px;
  outline: none;
  transition: border-color .15s;
}
.form-row input:focus { border-color: var(--blue); }

.input-group { display: flex; align-items: center; gap: 8px; }
.unit { font-size: 12px; color: var(--gray); }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

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

/* Error banner */
.error-banner {
  background: var(--red-lt);
  border: 1px solid #f1b8ba;
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #a4262c;
}
.error-banner.hidden { display: none; }

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-title h2 { font-size: 16px; color: var(--navy); }

.help-text { font-size: 12px; color: var(--gray); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue   { background: var(--blue-lt); color: var(--blue); }
.badge-orange { background: var(--orange-lt); color: var(--orange); }

/* Scanning indicator */
.scanning {
  font-size: 12px;
  color: var(--blue);
  animation: pulse 1s infinite;
}
.scanning.hidden { display: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ── Table ─────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
  overflow-x: auto;
}

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

thead tr {
  background: var(--navy);
  color: var(--white);
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #faf9f8; }

td {
  padding: 11px 16px;
  font-size: 13px;
  vertical-align: middle;
}

/* Column widths */
.col-date       { width: 150px; white-space: nowrap; }
.col-from       { width: 220px; }
.col-subject    { }
.col-importance { width: 110px; }

/* Empty state */
.empty-row td {
  text-align: center;
  color: var(--gray);
  padding: 40px;
  font-style: italic;
}

/* Unread rows */
tr.unread td { font-weight: 600; }

/* New email highlight */
tr.new-email { animation: highlight-new 3s ease-out forwards; }
@keyframes highlight-new {
  0%   { background: #dff6dd; }
  100% { background: transparent; }
}

/* High importance row */
tr.importance-high td:first-child {
  border-left: 4px solid var(--red);
}

/* Importance badges */
.imp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.imp-high   { background: var(--red-lt);  color: var(--red); }
.imp-normal { background: var(--gray-lt); color: var(--gray); }
.imp-low    { background: #f0f0f0;        color: #999; }

/* Sender display */
.from-name  { font-weight: 500; display: block; }
.from-email { font-size: 11px; color: var(--gray); display: block; }

/* Date display */
.date-full { display: block; }
.date-rel  { font-size: 11px; color: var(--gray); }

/* ── Disappeared section ───────────────────────────────────────────── */
.disappeared-section { margin-top: 8px; }

.disappeared-section .table-wrapper {
  border: 2px solid #f7c948;
}

.disappeared-header { background: transparent; }

.disappeared-section thead tr { background: #b35a00; }

.disappeared-section tbody tr { background: #fffbf0; }
.disappeared-section tbody tr:hover { background: #fff3cd; }

.disappeared-section.hidden { display: none; }

/* Disappeared at badge */
.dis-at {
  font-size: 11px;
  color: var(--orange);
  font-weight: 600;
}
