/* =============================================================================
   AIMatric Email AgenticAI — design system
   Palette + typography lifted directly from aimatric.com (Inter, orange/teal/navy)
   ========================================================================== */

:root {
  /* Brand orange (primary) */
  --orange-400: #FB923C;
  --orange-500: #F97316;
  --orange-600: #EA580C;
  /* Brand teal (secondary) */
  --teal-50:  #EDFBFD;
  --teal-100: #D0F4FA;
  --teal-200: #8CE4F0;
  --teal-300: #4ECEE0;
  --teal-400: #20B2C8;
  --teal-500: #1292A4;
  --teal-600: #108090;
  --teal-700: #0E6E7C;
  --teal-800: #0C5C68;
  --teal-900: #0A4A54;
  /* Navy / slate */
  --navy-700: #334155;
  --navy-800: #1E293B;
  --navy-900: #0F172A;
  /* Neutral scale */
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #E2E8F0;
  --gray-400: #CBD5E1;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --white: #FFFFFF;
  --success: #10B981;
  --danger:  #EF4444;
  --warning: #F59E0B;

  /* Semantic */
  --bg: #F6F8FB;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E8EDF3;

  /* Signature gradients */
  --grad-brand: linear-gradient(135deg, var(--navy-900) 0%, var(--teal-700) 100%);
  --grad-hero:  linear-gradient(135deg, #0B1220 0%, #0A4A54 55%, #0E6E7C 100%);
  --grad-orange: linear-gradient(135deg, var(--orange-500) 0%, var(--orange-600) 100%);
  --grad-teal:  linear-gradient(135deg, var(--teal-400) 0%, var(--teal-600) 100%);
  --grad-success: linear-gradient(135deg, #34D399 0%, #059669 100%);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --shadow-glow: 0 12px 40px rgba(249, 115, 22, 0.28);
  --ring: 0 0 0 4px rgba(249, 115, 22, 0.18);

  --nav-h: 72px;
  --bs-primary: #F97316;
  --bs-primary-rgb: 249, 115, 22;
}

/* ----------------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}
a { color: var(--teal-600); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--teal-800); }
::selection { background: rgba(249, 115, 22, 0.22); }

h1, h2, h3, h4, h5 { font-weight: 700; letter-spacing: -0.02em; color: var(--navy-900); }
.text-muted-2 { color: var(--muted) !important; }
.eyebrow {
  text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 700; color: var(--teal-600);
}
.fw-800 { font-weight: 800; }

/* gradient text */
.text-gradient {
  background: var(--grad-orange);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-gradient-teal {
  background: var(--grad-teal);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* --------------------------------------------------------------------- navbar */
.app-nav {
  position: sticky; top: 0; z-index: 1030;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.app-nav .brand-logo { height: 30px; }
.app-nav .nav-link {
  color: var(--gray-700); font-weight: 600; font-size: .94rem;
  padding: .5rem .9rem; border-radius: 10px; position: relative;
  transition: all .18s ease; display: inline-flex; align-items: center; gap: .5rem;
}
.app-nav .nav-link:hover { color: var(--navy-900); background: var(--gray-100); }
.app-nav .nav-link.active { color: var(--orange-600); background: rgba(249, 115, 22, 0.10); }
.app-nav .nav-link i { font-size: 1.05rem; }

.avatar-chip {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .82rem;
  background: var(--grad-brand); box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------------- buttons */
.btn { font-weight: 600; border-radius: 12px; padding: .6rem 1.15rem; transition: all .18s ease; border: 1px solid transparent; }
.btn:active { transform: translateY(1px); }
.btn-brand { background: var(--grad-orange); color: #fff; box-shadow: var(--shadow-glow); }
.btn-brand:hover { color: #fff; filter: brightness(1.04); box-shadow: 0 16px 44px rgba(249,115,22,.36); transform: translateY(-1px); }
.btn-teal { background: var(--grad-teal); color: #fff; box-shadow: 0 10px 30px rgba(18,146,164,.28); }
.btn-teal:hover { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--navy-800); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: var(--gray-300); background: var(--gray-50); color: var(--navy-900); }
.btn-soft-danger { background: rgba(239,68,68,.10); color: var(--danger); }
.btn-soft-danger:hover { background: rgba(239,68,68,.16); color: var(--danger); }
.btn-lg { padding: .8rem 1.5rem; font-size: 1.02rem; }
.btn i { vertical-align: -1px; }

/* --------------------------------------------------------------------- cards */
.card-soft {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card-soft:hover { box-shadow: var(--shadow); }
.lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #fff; }
.card-pad { padding: 1.4rem 1.5rem; }

.section-title { font-size: 1.06rem; font-weight: 700; color: var(--navy-900); }

/* stat cards */
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  color: #fff; font-size: 1.4rem; box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 2.1rem; font-weight: 800; line-height: 1; color: var(--navy-900); letter-spacing: -.03em; }
.stat-card .stat-label { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat-card .stat-spark { position: absolute; right: -10px; bottom: -10px; opacity: .06; font-size: 6rem; }
.bg-i-orange { background: var(--grad-orange); }
.bg-i-teal { background: var(--grad-teal); }
.bg-i-navy { background: var(--grad-brand); }
.bg-i-success { background: var(--grad-success); }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .28rem .7rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
}
.chip-teal { background: var(--teal-50); color: var(--teal-700); }
.chip-orange { background: rgba(249,115,22,.10); color: var(--orange-600); }
.chip-success { background: rgba(16,185,129,.12); color: #047857; }
.chip-gray { background: var(--gray-100); color: var(--gray-600); }
.chip-danger { background: rgba(239,68,68,.10); color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--success); box-shadow: 0 0 0 0 rgba(16,185,129,.7); animation: pulse-ring 1.8s infinite; }
.dot-idle { background: var(--gray-400); }

/* status pill with live pulse */
.status-pill {
  display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; font-size: .82rem;
  padding: .4rem .85rem; border-radius: 999px;
}
.status-connected { background: rgba(16,185,129,.12); color: #047857; }
.status-disconnected { background: var(--gray-100); color: var(--gray-600); }
.status-error { background: rgba(239,68,68,.10); color: var(--danger); }

/* avatars */
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .9rem;
}

/* ----------------------------------------------------------------- mail list */
.mail-row {
  display: flex; align-items: center; gap: 1rem; padding: .95rem 1.1rem;
  border-radius: 14px; border: 1px solid transparent; transition: all .15s ease; cursor: pointer;
}
.mail-row:hover { background: var(--gray-50); border-color: var(--border); transform: translateX(2px); }
.mail-row.unread { background: linear-gradient(90deg, rgba(249,115,22,.05), transparent 60%); }
.mail-row.unread .mail-subject { font-weight: 700; color: var(--navy-900); }
.mail-subject { font-weight: 600; color: var(--navy-800); }
.mail-snippet { color: var(--muted); font-size: .88rem; }
.mail-meta { color: var(--gray-500); font-size: .78rem; white-space: nowrap; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange-500); flex: 0 0 auto; }

/* ------------------------------------------------------------------ timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--teal-200), var(--gray-200));
}
.tl-item { position: relative; padding-bottom: 1.1rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -28px; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: .62rem; box-shadow: 0 0 0 4px #fff;
}
.tl-info { background: var(--teal-500); }
.tl-success { background: var(--success); }
.tl-warning { background: var(--warning); }
.tl-error { background: var(--danger); }
.tl-text { font-size: .9rem; color: var(--navy-800); font-weight: 500; }
.tl-time { font-size: .74rem; color: var(--gray-500); }

/* ------------------------------------------------------------------ bar chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.bar {
  width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px;
  background: var(--grad-teal); min-height: 4px;
  transition: height .9s cubic-bezier(.22,1,.36,1);
  animation: grow-up .9s cubic-bezier(.22,1,.36,1) both;
}
.bar-label { font-size: .72rem; color: var(--gray-500); font-weight: 600; }

/* --------------------------------------------------------------------- forms */
.form-label { font-weight: 600; color: var(--navy-800); font-size: .88rem; margin-bottom: .35rem; }
.form-control, .form-select {
  border-radius: 12px; border: 1px solid var(--gray-300); padding: .7rem .9rem;
  font-size: .95rem; transition: all .15s ease; background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--orange-400); box-shadow: var(--ring); outline: none;
}
.input-icon { position: relative; }
.input-icon .form-control { padding-left: 2.6rem; }
.input-icon > i { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--gray-500); }
.form-text { color: var(--muted); font-size: .8rem; }

/* --------------------------------------------------------------- empty state */
.empty {
  text-align: center; padding: 3rem 1.5rem; color: var(--muted);
}
.empty .empty-ico {
  width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 1rem;
  display: grid; place-items: center; font-size: 2.2rem; color: var(--teal-600);
  background: var(--teal-50); animation: float 4s ease-in-out infinite;
}

/* ---------------------------------------------------------------- auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
@media (max-width: 900px) { .auth-wrap { grid-template-columns: 1fr; } .auth-brand { display: none !important; } }

.auth-brand {
  position: relative; overflow: hidden; color: #fff;
  background: var(--grad-hero);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 3rem 3.2rem;
}
.auth-brand .orb {
  position: absolute; border-radius: 50%; filter: blur(8px); opacity: .55;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.55), transparent 60%);
  animation: float 9s ease-in-out infinite;
}
.auth-brand .orb.o1 { width: 320px; height: 320px; top: -60px; right: -40px;
  background: radial-gradient(circle at 30% 30%, rgba(249,115,22,.55), transparent 62%); animation-duration: 11s; }
.auth-brand .orb.o2 { width: 260px; height: 260px; bottom: -50px; left: -30px;
  background: radial-gradient(circle at 30% 30%, rgba(78,206,224,.5), transparent 62%); animation-duration: 13s; }
.auth-brand .orb.o3 { width: 160px; height: 160px; top: 40%; left: 55%;
  background: radial-gradient(circle at 30% 30%, rgba(16,185,129,.45), transparent 62%); animation-duration: 8s; }
.auth-grid-overlay {
  position: absolute; inset: 0; opacity: .25;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 40%, #000 0%, transparent 75%);
}
.auth-brand-content { position: relative; z-index: 2; }
.auth-logo-mark {
  width: 60px; height: 60px; border-radius: 18px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22); display: grid; place-items: center;
  backdrop-filter: blur(6px); box-shadow: 0 12px 30px rgba(0,0,0,.25);
}
.auth-feature { display: flex; align-items: flex-start; gap: .9rem; margin-top: 1.2rem; }
.auth-feature .fi {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto; display: grid; place-items: center;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); color: #fff; font-size: 1.1rem;
}
.auth-feature h6 { color: #fff; margin: 0 0 .15rem; font-weight: 700; }
.auth-feature p { color: rgba(255,255,255,.72); margin: 0; font-size: .88rem; }

.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.mascot-float { animation: float 5s ease-in-out infinite; filter: drop-shadow(0 18px 30px rgba(0,0,0,.35)); }

/* ---------------------------------------------------------- connect (oauth) */
.provider-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.provider-head { background: var(--grad-hero); color: #fff; padding: 1.6rem 1.7rem; position: relative; overflow: hidden; }
.provider-head .ph-orb { position: absolute; right: -30px; top: -30px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(249,115,22,.5), transparent 60%); filter: blur(4px); }
.step-num {
  width: 30px; height: 30px; border-radius: 9px; background: var(--teal-50); color: var(--teal-700);
  font-weight: 800; display: grid; place-items: center; font-size: .9rem; flex: 0 0 auto;
}
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: .85rem; }
.kv .v { font-weight: 600; color: var(--navy-800); font-size: .9rem; }
code.tok { background: var(--gray-100); padding: .15rem .45rem; border-radius: 6px; font-size: .82rem; color: var(--navy-800); }

/* ------------------------------------------------------------------ toasts */
.toast-stack { position: fixed; top: calc(var(--nav-h) + 14px); right: 18px; z-index: 1080; width: 360px; max-width: calc(100vw - 36px); }
.toast-card {
  display: flex; gap: .8rem; align-items: flex-start; background: #fff; border: 1px solid var(--border);
  border-left: 4px solid var(--teal-500); border-radius: 12px; padding: .9rem 1rem; box-shadow: var(--shadow-lg);
  animation: slide-in-right .5s cubic-bezier(.22,1,.36,1) both;
}
.toast-card.success { border-left-color: var(--success); }
.toast-card.error { border-left-color: var(--danger); }
.toast-card.warning { border-left-color: var(--warning); }
.toast-ico { font-size: 1.2rem; line-height: 1.3; }
.toast-card.success .toast-ico { color: var(--success); }
.toast-card.error .toast-ico { color: var(--danger); }
.toast-card.info .toast-ico { color: var(--teal-600); }

/* attachments */
.att-card { display: flex; align-items: center; gap: .8rem; padding: .7rem .85rem; border: 1px solid var(--border);
  border-radius: 12px; transition: all .15s ease; background: #fff; }
.att-card:hover { border-color: var(--gray-300); box-shadow: var(--shadow-sm); }
.att-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 1.1rem; flex: 0 0 auto; }

/* spinner (htmx) */
.htmx-indicator { opacity: 0; transition: opacity .2s ease; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ---------------------------------------------------------------- animations */
@keyframes fade-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); }
  70% { box-shadow: 0 0 0 10px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}
@keyframes grow-up { from { height: 0 !important; opacity: .3; } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.9); } 60% { transform: scale(1.02); } 100% { opacity: 1; transform: scale(1); } }
@keyframes shimmer { 100% { background-position: 200% 0; } }

/* entrance helpers */
.reveal { animation: fade-up .6s cubic-bezier(.22,1,.36,1) both; }
.reveal-1 { animation-delay: .05s; } .reveal-2 { animation-delay: .12s; }
.reveal-3 { animation-delay: .19s; } .reveal-4 { animation-delay: .26s; }
.reveal-5 { animation-delay: .33s; } .reveal-6 { animation-delay: .4s; }
.pop { animation: pop-in .5s cubic-bezier(.22,1.4,.36,1) both; }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* page shell */
.page { max-width: 1200px; margin: 0 auto; padding: 1.8rem 1.25rem 4rem; }
.page-hero {
  background: var(--grad-hero); color: #fff; border-radius: var(--radius-lg);
  padding: 1.9rem 2rem; position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.page-hero .ph-orb1 { position: absolute; right: -40px; top: -50px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(249,115,22,.5), transparent 60%); filter: blur(6px); animation: float 10s ease-in-out infinite; }
.page-hero .ph-orb2 { position: absolute; left: 30%; bottom: -70px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(78,206,224,.4), transparent 60%); filter: blur(8px); animation: float 12s ease-in-out infinite; }
.page-hero h1 { color: #fff; }
.page-hero .lead { color: rgba(255,255,255,.82); }
