* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f1117;
  --bg-surface: #161822;
  --bg-hover: #1c1f2e;
  --bg-active: #222640;
  --border: #262a3a;
  --text: #e1e3eb;
  --text-muted: #8b8fa3;
  --text-dim: #5c6072;
  --accent: #4f8ff7;
  --accent-dim: #2a4a8a;
  --unread-border: #4f8ff7;
  --badge-bg: #4f8ff7;
  --badge-text: #fff;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 6px;
  --sidebar-w: 260px;
  --detail-w: 340px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}

.service-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.service-group-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

.service-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.service-item:hover { background: var(--bg-hover); }
.service-item.active { background: var(--bg-active); }
.service-item.active .service-label { font-weight: 600; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot[data-status="connected"] { background: var(--green); }
.status-dot[data-status="stale"] { background: var(--amber); }
.status-dot[data-status="disconnected"] { background: var(--red); }
.status-dot[data-status="unknown"] { background: var(--text-dim); }

.service-icon { font-size: 14px; flex-shrink: 0; }

.service-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.account-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.unread-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.unread-badge.hidden { display: none; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 4px 0;
}

/* ─── Feed ─────────────────────────────────────────── */

.feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
}

.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.filter-bar { display: flex; gap: 4px; }

.filter-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { color: var(--text); border-color: var(--text-dim); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }

.feed-actions { display: flex; gap: 8px; }

.action-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.action-btn:hover { color: var(--text); border-color: var(--text-dim); }

.feed-list {
  flex: 1;
  overflow-y: auto;
}

.feed-empty, .detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  gap: 4px;
}
.feed-empty p, .detail-empty p { font-size: 14px; }
.feed-empty-sub { font-size: 12px !important; }

.feed-loading {
  padding: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}
.feed-loading.hidden { display: none; }

/* ─── Feed Item ────────────────────────────────────── */

.feed-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}
.feed-item:hover { background: var(--bg-hover); }
.feed-item.selected { background: var(--bg-active); }
.feed-item.unread { border-left-color: var(--unread-border); }
.feed-item.unread .feed-item-sender { font-weight: 600; }

.feed-item-icon {
  font-size: 18px;
  flex-shrink: 0;
  padding-top: 2px;
}

.feed-item-body {
  flex: 1;
  min-width: 0;
}

.feed-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.feed-item-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}
.badge-outlook { background: #1a3a6a; color: #5b9aff; }
.badge-gmail { background: #3a1a1a; color: #ff6b6b; }
.badge-teams { background: #1a2a4a; color: #7b8fff; }
.badge-slack { background: #2a1a3a; color: #c47bff; }
.badge-whatsapp { background: #1a3a2a; color: #34d399; }
.badge-sms { background: #2a2a1a; color: #fbbf24; }
.badge-calendar { background: #1a3a3a; color: #5be8d0; }

.feed-item-account {
  font-size: 11px;
  color: var(--text-dim);
}

.feed-item-sender {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.feed-item-time {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

/* ─── Detail Pane ──────────────────────────────────── */

.detail {
  width: var(--detail-w);
  min-width: var(--detail-w);
  background: var(--bg-surface);
  overflow-y: auto;
}

.detail-content { padding: 20px 16px; }
.detail-content.hidden { display: none; }

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.detail-account {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-sender {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.detail-preview {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.detail-full {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 16px;
  white-space: pre-wrap;
}
.detail-full:empty { display: none; }

.detail-meta {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-bottom: 16px;
}

.detail-meta-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.meta-label { color: var(--text-dim); }
.meta-value { color: var(--text-muted); }

.open-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}
.open-btn:hover { background: var(--accent); color: #fff; }
.open-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.open-arrow { font-size: 15px; }

/* ─── Scrollbar ────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

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

.hidden { display: none !important; }
