/* ==========================================================================
   Velvora Portal — design system
   ========================================================================== */

:root {
  --bg:            #f4f5fa;
  --surface:       #ffffff;
  --surface-2:     #fafbff;
  --line:          #e6e8f0;
  --line-strong:   #d5d9e6;
  --text:          #10131c;
  --text-2:        #4a5169;
  --muted:         #7c8399;

  --brand:         #5b4df5;
  --brand-2:       #8b5cf6;
  --brand-soft:    #eeecff;
  --brand-ink:     #3d31c9;

  --ok:            #0f9d63;
  --ok-soft:       #e4f8ee;
  --warn:          #b26a00;
  --warn-soft:     #fff4e2;
  --danger:        #d92d3f;
  --danger-soft:   #fdecee;
  --info:          #0b7bb8;
  --info-soft:     #e6f4fb;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow-sm:     0 1px 2px rgba(16,19,28,.05), 0 1px 3px rgba(16,19,28,.04);
  --shadow-md:     0 4px 12px rgba(16,19,28,.06), 0 12px 28px -8px rgba(16,19,28,.10);
  --shadow-lg:     0 24px 64px -16px rgba(16,19,28,.22);
  --ring:          0 0 0 3px rgba(91,77,245,.18);
  --sidebar-w:     248px;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.014em; }

svg { display: block; }

/* ---------------------------------- shell -------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background:
    radial-gradient(120% 80% at 0% 0%, #232a52 0%, transparent 55%),
    linear-gradient(180deg, #12172c 0%, #0d1122 100%);
  color: #d8dcec;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 18px -6px rgba(139,92,246,.9);
}

.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.brand-sub  { font-size: 11px; color: #8b93b4; letter-spacing: .1em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }

.nav-label {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: #6f7899; padding: 14px 10px 6px;
}

.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: #c3c9e0; font-size: 14px; font-weight: 550;
  transition: background .16s ease, color .16s ease;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active {
  background: linear-gradient(180deg, rgba(91,77,245,.95), rgba(91,77,245,.78));
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(91,77,245,.95);
}
.nav a svg { width: 17px; height: 17px; opacity: .9; }

.sidebar-foot { margin-top: auto; padding-top: 18px; }

.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.07);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #5b4df5, #8b5cf6);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: #fff; flex: 0 0 auto;
}
.userchip .who { min-width: 0; flex: 1; }
.userchip .who strong {
  display: block; font-size: 13px; color: #fff; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.userchip .who span { font-size: 11px; color: #8b93b4; }

.icon-btn {
  border: 0; background: transparent; color: #98a0be;
  padding: 6px; border-radius: 8px; cursor: pointer; line-height: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------------------------------- main --------------------------------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 32px;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .crumb { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.content { padding: 28px 32px 56px; max-width: 1180px; width: 100%; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }
.page-head .spacer { margin-left: auto; }

/* -------------------------------- buttons -------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .06s ease, box-shadow .16s ease, background .16s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand) 0%, #4b3ee0 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(16,19,28,.12), 0 8px 20px -8px rgba(91,77,245,.7);
}
.btn-primary:hover { filter: brightness(1.06); text-decoration: none; }

.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c3c8d8; text-decoration: none; }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #f7ccd1; }
.btn-danger:hover { background: #fbdde1; text-decoration: none; }

.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* --------------------------------- cards --------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 20px; }

/* --------------------------------- stats --------------------------------- */

.stat-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  margin-bottom: 22px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat::after {
  content: ""; position: absolute; inset: 0 0 auto auto;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle at 70% 30%, rgba(91,77,245,.10), transparent 68%);
  transform: translate(28%, -34%);
  pointer-events: none;
}
.stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
}
.stat-ico svg { width: 17px; height: 17px; }
.stat-ico.green { background: var(--ok-soft); color: var(--ok); }
.stat-ico.amber { background: var(--warn-soft); color: var(--warn); }
.stat-ico.red   { background: var(--danger-soft); color: var(--danger); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 550; letter-spacing: .01em; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* --------------------------------- chart --------------------------------- */

.chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 8px 2px 0; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 46px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #7c6cff 0%, #5b4df5 100%);
  min-height: 4px;
  transition: filter .16s ease, transform .16s ease;
  position: relative;
}
.bar:hover { filter: brightness(1.1); transform: scaleY(1.02); }
.bar.zero { background: #eceefa; }
.bar-val { font-size: 11px; font-weight: 650; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar-lbl { font-size: 11.5px; color: var(--muted); }

/* --------------------------------- table --------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 650;
  padding: 11px 16px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th:first-child { border-top-left-radius: var(--radius); }
table.data th:last-child  { border-top-right-radius: var(--radius); }
table.data td {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  vertical-align: middle; color: var(--text-2);
}
table.data tbody tr:hover td { background: #fbfbff; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--text); }
table.data .strong { color: var(--text); font-weight: 600; }
table.data .preview { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* --------------------------------- pills --------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.sent      { background: var(--ok-soft);     color: var(--ok);     border-color: #c6eede; }
.pill.opened    { background: #f0eeff;            color: #4b3ee0;       border-color: #dcd7ff; }
.pill.simulated { background: var(--info-soft);   color: var(--info);   border-color: #cbe7f5; }
.pill.queued    { background: var(--warn-soft);   color: var(--warn);   border-color: #ffe2b8; }
.pill.failed    { background: var(--danger-soft); color: var(--danger); border-color: #f7ccd1; }

/* --------------------------------- forms --------------------------------- */

.form-grid { display: grid; gap: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 7px; }

.input, textarea.input, select.input {
  width: 100%; font: inherit; font-size: 14.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 11px; padding: 12px 14px; outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input::placeholder { color: #a6acc0; }
.input:focus, textarea.input:focus { border-color: var(--brand); box-shadow: var(--ring); }
textarea.input { resize: vertical; min-height: 132px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(217,45,63,.12); }

.phone-row { display: flex; gap: 10px; align-items: stretch; }
.phone-row .input { flex: 1; }

.locked {
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  border-radius: 12px; padding: 14px 16px;
}
.locked .tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand-ink); background: var(--brand-soft);
  padding: 3px 8px; border-radius: 6px; margin-bottom: 10px;
}
.locked pre {
  margin: 0; font-size: 12.5px; line-height: 1.65; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* -------------------------------- notices -------------------------------- */

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: 12px; font-size: 13.5px;
  border: 1px solid transparent; margin-bottom: 18px;
}
.notice svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.notice strong { font-weight: 650; }
.notice.info { background: var(--info-soft); border-color: #cbe7f5; color: #08587f; }
.notice.ok   { background: var(--ok-soft);   border-color: #c6eede; color: #0a6b45; }
.notice.warn { background: var(--warn-soft); border-color: #ffe2b8; color: #7d4c00; }
.notice.err  { background: var(--danger-soft); border-color: #f7ccd1; color: #8f1c2b; }

/* -------------------------------- toolbar -------------------------------- */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted);
}
.search .input { padding-left: 36px; }

/* ------------------------------- pagination ------------------------------ */

.pager { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.pager .spacer { margin-left: auto; }
.pager .count { font-size: 12.5px; color: var(--muted); }
.page-num {
  min-width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--line-strong);
  font-size: 13px; color: var(--text-2); background: var(--surface);
}
.page-num:hover { background: var(--surface-2); text-decoration: none; }
.page-num.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 650; }

/* --------------------------------- empty --------------------------------- */

.empty { padding: 56px 20px; text-align: center; }
.empty .ico {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.empty .ico svg { width: 24px; height: 24px; }
.empty h3 { font-size: 15px; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }

/* --------------------------------- login --------------------------------- */

.login-page {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
}

.login-aside {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, #1a1f3d 0%, #0e1226 55%, #141a35 100%);
  color: #fff; padding: 56px 56px 44px;
  display: flex; flex-direction: column;
}
.login-aside::before,
.login-aside::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(60px);
}
.login-aside::before {
  width: 420px; height: 420px; right: -140px; top: -120px;
  background: radial-gradient(circle, rgba(91,77,245,.55), transparent 70%);
}
.login-aside::after {
  width: 360px; height: 360px; left: -120px; bottom: -140px;
  background: radial-gradient(circle, rgba(139,92,246,.40), transparent 70%);
}
.login-aside > * { position: relative; z-index: 1; }
.login-aside h2 {
  font-size: 33px; line-height: 1.18; letter-spacing: -.03em;
  margin-top: auto; max-width: 13ch;
}
.login-aside p { color: #a6aecb; font-size: 14.5px; max-width: 34ch; margin-top: 14px; }
.login-aside .feat { display: grid; gap: 12px; margin-top: 30px; }
.login-aside .feat div { display: flex; gap: 10px; align-items: center; font-size: 13.5px; color: #c7cde4; }
.login-aside .feat svg { width: 16px; height: 16px; color: #8b5cf6; flex: 0 0 auto; }

.login-main { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 384px; }
.login-card h1 { font-size: 25px; letter-spacing: -.025em; }
.login-card .lead { color: var(--muted); font-size: 14px; margin: 8px 0 26px; }

.login-card .field { margin-bottom: 16px; }

.key-row { position: relative; }
.key-row .toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 650; cursor: pointer; padding: 6px 8px; border-radius: 7px;
}
.key-row .toggle:hover { background: var(--surface-2); color: var(--text-2); }

.login-foot { margin-top: 26px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* --------------------------------- misc ---------------------------------- */

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.stack-2 > * + * { margin-top: 16px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 10px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

.msg-block {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; font-size: 13px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2);
}

.dot-sep { color: var(--line-strong); }

/* ------------------------------- responsive ------------------------------ */

@media (max-width: 980px) {
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .shell { display: block; }
  .topbar { padding: 14px 18px; }
  .content { padding: 20px 18px 44px; }
  .menu-btn { display: inline-flex !important; }
  .scrim {
    position: fixed; inset: 0; background: rgba(10,13,24,.45);
    z-index: 55; backdrop-filter: blur(2px);
  }
  table.data .preview { max-width: 160px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}

.menu-btn { display: none; }

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

/* ------------------------- handoff page additions ------------------------ */

/* the recipient pills double as copy buttons */
button.pill {
  cursor: pointer; font: inherit; border: 1px solid #cbe7f5;
  -webkit-tap-highlight-color: transparent;
}
button.pill:hover { border-color: var(--info); }
button.pill.copied,
.btn.copied { background: var(--ok-soft); color: var(--ok); border-color: #c6eede; }

/* draws the eye to the only control that can open the Gmail app */
.pulse { animation: pulse-ring 1.8s ease-out infinite; }
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(91, 77, 245, .45); }
  70%  { box-shadow: 0 0 0 12px rgba(91, 77, 245, 0); }
  100% { box-shadow: 0 0 0 0 rgba(91, 77, 245, 0); }
}
