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

:root {
  /* Brand */
  --navy:    #0F172A;
  --navy2:   #1E293B;
  --navy3:   #334155;
  --amber:   #F59E0B;
  --amber-dk:#D97706;
  --slate:   #64748B;
  --slate-lt:#94A3B8;
  --red:     #EF4444;
  --green:   #22C55E;
  --blue:    #3B82F6;

  /* Semantic — light mode */
  --bg:       #F1F5F9;
  --surface:  #FFFFFF;
  --border:   #E8EDF2;
  --off:      #F8FAFC;
  --white:    #FFFFFF;
  --text-h:   #0F172A;
  --text-body:#334155;
  --text-mute:#64748B;
  --text-dim: #94A3B8;
  --red-lt:   #FEF2F2;
  --green-lt: #F0FDF4;
  --blue-lt:  #EFF6FF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:    0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}

[data-theme="dark"] {
  --bg:       #111827;
  --surface:  #1E293B;
  --border:   #2D3A4A;
  --off:      #182030;
  --white:    #1E293B;
  --text-h:   #F1F5F9;
  --text-body:#CBD5E1;
  --text-mute:#94A3B8;
  --text-dim: #475569;
  --red-lt:   #450A0A;
  --green-lt: #052E16;
  --blue-lt:  #172554;
  --navy3:    #CBD5E1;
  --slate:    #94A3B8;
  --slate-lt: #475569;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow:    0 4px 12px rgba(0,0,0,0.4);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-body);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── NAV ── */
#app-nav {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand-text {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.07); }
.nav-link.active { color: var(--amber); font-weight: 700; background: rgba(245,158,11,0.1); }
.nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.nav-icon-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.nav-icon-btn:hover { color: #fff; border-color: rgba(255,255,255,0.25); background: rgba(255,255,255,0.07); }
.nav-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.55);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.nav-logout:hover { color: #fff; border-color: rgba(255,255,255,0.3); }

/* ── PAGE WRAPPER ── */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-h);
  letter-spacing: -0.4px;
}
.page-sub {
  font-size: 14px;
  color: var(--text-mute);
  margin-top: 3px;
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 16px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-amber  { background: var(--amber);  color: var(--navy); box-shadow: 0 1px 2px rgba(245,158,11,0.25); }
.btn-navy   { background: var(--navy);   color: #fff; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-body);
}
.btn-outline:hover { border-color: var(--text-mute); opacity: 1; }
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-mute);
  padding: 6px 10px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text-h); opacity: 1; }
.btn-red {
  background: var(--red-lt);
  color: var(--red);
  border: 1px solid #FECACA;
}
[data-theme="dark"] .btn-red { border-color: #7F1D1D; }
.btn-sm { font-size: 12px; padding: 6px 12px; border-radius: 7px; }

/* ── FORMS ── */
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 140px; }
label.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
input.field, select.field {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-h);
  background: var(--off);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input.field:focus, select.field:focus {
  border-color: var(--amber);
  background: var(--surface);
}

/* ── TABLES ── */
.tbl-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--off);
}
th:first-child { border-radius: 8px 0 0 0; }
th:last-child  { border-radius: 0 8px 0 0; }
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-body);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--off); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: 0.2px;
}
.badge-red    { background: #FEE2E2; color: #991B1B; }
.badge-amber  { background: #FEF3C7; color: #92400E; }
.badge-blue   { background: var(--blue-lt); color: #1D4ED8; }
.badge-green  { background: var(--green-lt); color: #15803D; }
.badge-gray   { background: var(--off); color: var(--text-mute); border: 1px solid var(--border); }
[data-theme="dark"] .badge-red   { background: #450A0A; color: #FCA5A5; }
[data-theme="dark"] .badge-amber { background: #451A03; color: #FCD34D; }
[data-theme="dark"] .badge-blue  { background: #172554; color: #93C5FD; }
[data-theme="dark"] .badge-green { background: #052E16; color: #86EFAC; }

/* ── PLATFORM BADGE ── */
.plat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}
.plat-gmail   { background: #FDECEA; color: #C62828; }
.plat-outlook { background: #E3F2FD; color: #1565C0; }
.plat-slack   { background: #F3E5F5; color: #6A1B9A; }
.plat-teams   { background: #EDE7F6; color: #4527A0; }
.plat-sms     { background: #FFF8E1; color: #F57F17; }
.plat-phone   { background: var(--green-lt); color: #15803D; }
.plat-default { background: var(--off); color: var(--text-mute); }

/* ── FILTER CHIPS ── */
.filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chips {
  display: inline-flex;
  gap: 8px;
  padding: 0 16px;
}
.f-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 24px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  user-select: none;
}
.f-chip:hover { background: var(--off); color: var(--text-body); }
.f-chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.f-chip-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── INBOX / ALERTS HEADER ── */
.inbox-header,
.alerts-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.inbox-title,
.alerts-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-h);
  letter-spacing: -0.4px;
  flex-shrink: 0;
}
.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--off);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  padding: 0 10px;
  gap: 7px;
  max-width: 340px;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--amber); }
.search-wrap svg { flex-shrink: 0; color: var(--text-mute); }
.search-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-h);
  outline: none;
  padding: 7px 0;
}
.search-wrap input::placeholder { color: var(--text-dim); }
.ack-toggle {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.ack-toggle:hover { color: var(--text-h); border-color: var(--text-mute); }

/* ── INBOX / ALERTS CARD ── */
.inbox-card,
.alerts-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 20px 20px;
  box-shadow: var(--shadow-sm);
}

/* ── MESSAGE ROW ── */
.msg-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  cursor: default;
}
.msg-row:last-child { border-bottom: none; }
.msg-row:hover { background: var(--off); }
.msg-row.is-link { cursor: pointer; }
.msg-plat { flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px; overflow: hidden; }
.msg-plat svg { display: block; }
.msg-body { flex: 1; min-width: 0; }
.msg-sender { font-size: 13px; font-weight: 700; color: var(--text-h); display: flex; align-items: center; gap: 6px; }
.msg-subject { font-size: 13px; color: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-snippet { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-right { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.msg-time { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.msg-ack-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--amber);
  color: var(--navy);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.msg-ack-btn:hover { opacity: 0.85; }
.msg-ack-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.msg-priority-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── PLATFORM CONNECT CARD ── */
.plat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.plat-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  transition: box-shadow 0.15s;
}
.plat-card:hover { box-shadow: var(--shadow); }
.plat-card.connected { border-color: #BBF7D0; background: var(--green-lt); }
[data-theme="dark"] .plat-card.connected { border-color: #14532D; background: #052E16; }
.plat-card-header { display: flex; align-items: center; gap: 10px; }
.plat-card-name { font-size: 15px; font-weight: 800; color: var(--text-h); }
.plat-card-email { font-size: 12px; color: var(--text-mute); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.on  { background: var(--green); }
.status-dot.off { background: var(--border); }

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-mute);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty p { font-size: 15px; }

/* ── LOADING ── */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-mute);
  font-size: 14px;
}
.spinner-sm {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(15,23,42,0.12);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
[data-theme="dark"] .spinner-sm { border-color: rgba(255,255,255,0.1); border-top-color: var(--amber); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--navy2);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
}
.toast.toast-success { background: var(--navy2); }
.toast.toast-error   { background: #991B1B; }
.toast.toast-show    { transform: translateX(-50%) translateY(0); }

/* ── MISC ── */
.text-muted { color: var(--text-mute); font-size: 13px; }
.section-gap { margin-top: 28px; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── LEGACY ALERT ROWS (keep for backward compat) ── */
.alert-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: none; }
.alert-body { flex: 1; min-width: 0; }
.alert-sender { font-size: 14px; font-weight: 700; color: var(--text-h); margin-bottom: 2px; }
.alert-subject { font-size: 13px; color: var(--text-body); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-snippet { font-size: 13px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.alert-actions { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.alert-time { font-size: 12px; color: var(--text-dim); white-space: nowrap; }

@media (max-width: 640px) {
  .nav-links { gap: 0; }
  .nav-link  { padding: 6px 8px; font-size: 12.5px; gap: 4px; }
  .nav-brand-text { display: none; }
  .page { padding: 20px 16px 48px; }
  .form-row { flex-direction: column; }
  .plat-grid { grid-template-columns: 1fr; }
  .inbox-card, .alerts-card { margin: 12px; }
}
