/* ==========================================================================
   LancersTech: design system ("Sage & Sand")
   Deep sage greens on warm neutrals. No external fonts or assets (CSP: self only).
   ========================================================================== */

:root {
  /* brand */
  --brand-900: #12352a;
  --brand-800: #1a4636;
  --brand-700: #215a45;
  --brand-600: #2d6a4f;
  --brand-500: #40916c;
  --brand-400: #52b788;
  --brand-200: #b7e4c7;
  --brand-100: #d8f3dc;
  --brand-50:  #eef8f0;

  /* neutrals (warm) */
  --bg: #f6f5f0;
  --bg-deep: #efede6;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --text: #1c2622;
  --text-2: #3d4a44;
  --muted: #6b766f;
  --border: #e5e2d9;
  --border-strong: #d4d0c4;

  /* semantic */
  --ok: #2d6a4f;       --ok-bg: #e3f4e8;
  --warn: #9a5b06;     --warn-bg: #fdf1dc;
  --danger: #b03a2e;   --danger-bg: #fbe9e6;
  --neutral-bg: #eeece5;

  /* legacy aliases used by older markup */
  --primary: var(--brand-600);
  --primary-text: #fff;
  --card: var(--surface);

  /* shape & depth */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(28, 38, 34, .05);
  --shadow-sm: 0 1px 3px rgba(28, 38, 34, .06), 0 1px 2px rgba(28, 38, 34, .04);
  --shadow-md: 0 6px 18px -6px rgba(28, 38, 34, .12), 0 2px 6px rgba(28, 38, 34, .05);
  --shadow-lg: 0 18px 40px -12px rgba(18, 53, 42, .25);
  --ring: 0 0 0 3px rgba(64, 145, 108, .28);

  /* motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast: 140ms;
  --t: 220ms;
  --t-slow: 420ms;

  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --font-display: "Inter Display", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;

  --sidebar-w: 248px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--brand-200); color: var(--brand-900); }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.015em; color: var(--text); }
h1 { font-size: 1.65rem; line-height: 1.2; font-weight: 700; margin: 0 0 18px; }
h2 { font-size: 1.08rem; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: .98rem; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 12px; }
small { font-size: .82rem; }

a {
  color: var(--brand-600);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--brand-800); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--neutral-bg);
  color: var(--brand-800);
  padding: 1px 6px;
  border-radius: 5px;
}

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

.icon { flex: none; display: inline-block; vertical-align: -3px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.spaced { margin-top: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ==========================================================================
   App shell: sidebar + content
   ========================================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--brand-900) 0%, #15402f 100%);
  color: #d9e9df;
  padding: 18px 14px;
  z-index: 40;
  transition: transform var(--t-slow) var(--ease);
}
.sidebar::after {
  /* soft light leak, purely decorative */
  content: "";
  position: absolute;
  inset: auto -60px -80px auto;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(82, 183, 136, .22), transparent 70%);
  pointer-events: none;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 22px;
  color: #fff; font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em;
  text-decoration: none;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  color: #fff;
  box-shadow: 0 6px 14px -4px rgba(82, 183, 136, .55), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform var(--t) var(--ease-spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }

.nav-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
  color: rgba(217, 233, 223, .5);
  padding: 14px 12px 6px;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: rgba(225, 238, 230, .78);
  font-weight: 500; font-size: .93rem;
  text-decoration: none;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.side-nav a .icon { opacity: .8; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease-spring); }
.side-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.side-nav a:hover .icon { opacity: 1; transform: translateX(1px) scale(1.06); }
.side-nav a.active {
  background: rgba(183, 228, 199, .14);
  color: #fff;
  font-weight: 600;
}
.side-nav a.active::before {
  content: "";
  position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 4px; border-radius: 0 4px 4px 0;
  background: var(--brand-400);
  animation: grow-y var(--t-slow) var(--ease) both;
}
.side-nav a.active .icon { opacity: 1; color: var(--brand-200); }

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 14px 6px 2px;
  display: flex; align-items: center; gap: 10px;
  position: relative; z-index: 1;
}
.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-800);
  font-weight: 700; font-size: .85rem; text-transform: uppercase;
}
.sidebar-foot .who { min-width: 0; flex: 1; line-height: 1.25; }
.sidebar-foot .who strong { display: block; color: #fff; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { display: block; color: rgba(217, 233, 223, .6); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot form { margin: 0; }
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: inherit; cursor: pointer;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.sidebar .icon-btn { color: rgba(225, 238, 230, .75); }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.icon-btn:active { transform: scale(.92); }

.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.mobile-bar { display: none; }

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px 36px 24px;
  flex: 1;
}

/* entrance animation for page content */
.page-enter > * { animation: rise var(--t-slow) var(--ease) both; }
.page-enter > *:nth-child(2) { animation-delay: 40ms; }
.page-enter > *:nth-child(3) { animation-delay: 80ms; }
.page-enter > *:nth-child(4) { animation-delay: 120ms; }
.page-enter > *:nth-child(5) { animation-delay: 160ms; }
.page-enter > *:nth-child(6) { animation-delay: 200ms; }
.page-enter > *:nth-child(n+7) { animation-delay: 240ms; }

/* page header */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand-500); margin-bottom: 6px;
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .88rem; color: var(--muted); margin-bottom: 14px;
}
.back-link .icon { transition: transform var(--t) var(--ease); }
.back-link:hover { color: var(--brand-700); text-decoration: none; }
.back-link:hover .icon { transform: translateX(-3px); }

/* ==========================================================================
   Cards, stats, grids
   ========================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 .icon { color: var(--brand-500); }
.card > .actions:first-child { justify-content: space-between; margin-top: 0; margin-bottom: 14px; }
.card > .actions:first-child h2 { margin: 0; }
.card-sub { color: var(--muted); margin-top: -6px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.grid.two > .card { margin-bottom: 0; }
.grid.two + .card, .grid.two + .grid.two { margin-top: 20px; }

.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
  animation: rise var(--t-slow) var(--ease) both;
}
.grid > .stat:nth-child(2) { animation-delay: 50ms; }
.grid > .stat:nth-child(3) { animation-delay: 100ms; }
.grid > .stat:nth-child(4) { animation-delay: 150ms; }
.grid > .stat:nth-child(5) { animation-delay: 200ms; }
.grid > .stat:nth-child(6) { animation-delay: 250ms; }
.grid > .stat:nth-child(n+7) { animation-delay: 300ms; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.stat .stat-icon {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand-50); color: var(--brand-600);
  margin-bottom: 12px;
  transition: transform var(--t) var(--ease-spring);
}
.stat:hover .stat-icon { transform: scale(1.08) rotate(-4deg); }
.stat .stat-icon.warn { background: var(--warn-bg); color: var(--warn); }
.stat .stat-icon.danger { background: var(--danger-bg); color: var(--danger); }
.stat .stat-icon.sand { background: var(--neutral-bg); color: var(--text-2); }
.stat .label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.stat .value {
  font-family: var(--font-display);
  font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em;
  line-height: 1.2; margin: 2px 0 2px;
  font-variant-numeric: tabular-nums;
}
.stat .muted { font-size: .84rem; }
.stat > a { display: inline-flex; align-items: center; gap: 4px; font-size: .86rem; margin-top: 6px; }
.stat > a .icon { transition: transform var(--t) var(--ease); }
.stat > a:hover .icon { transform: translateX(3px); }

/* ==========================================================================
   Forms
   ========================================================================== */
label { display: block; font-weight: 600; font-size: .9rem; color: var(--text-2); margin: 16px 0 6px; }
label .muted { font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=search], input[type=url], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit; font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
input::placeholder, textarea::placeholder { color: #a3aaa5; }
input:hover, select:hover, textarea:hover { border-color: #bfbaa9; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
  background: #fff;
}
input[readonly], textarea[readonly] { background: var(--surface-2); }
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
textarea#embed-snippet { font-family: var(--mono); font-size: .85rem; min-height: 80px; color: var(--brand-800); background: var(--brand-50); border-color: var(--brand-200); }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b766f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  cursor: pointer;
}
input[type=file] { padding: 8px; cursor: pointer; background: var(--surface-2); border-style: dashed; }
input[type=file]::file-selector-button {
  font: inherit; font-size: .86rem; font-weight: 600;
  margin-right: 12px; padding: 7px 12px;
  border: 0; border-radius: 7px;
  background: var(--brand-100); color: var(--brand-800);
  cursor: pointer;
  transition: background var(--t) var(--ease);
}
input[type=file]:hover::file-selector-button { background: var(--brand-200); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-600); width: 16px; height: 16px; cursor: pointer; }

.check { display: flex; align-items: center; gap: 9px; font-weight: 400; color: var(--text); margin: 10px 0; cursor: pointer; }
.error-text { color: var(--danger); font-size: .85rem; margin-top: 4px; display: inline-block; }
form p.muted, .card p.muted { font-size: .88rem; }

fieldset { border: 0; padding: 0; margin: 16px 0 0; }
fieldset legend { font-weight: 600; font-size: .9rem; color: var(--text-2); margin-bottom: 6px; }
fieldset input { margin-bottom: 8px; }

.faq-row {
  display: grid; gap: 8px;
  padding: 14px; margin-top: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
  animation: rise var(--t) var(--ease) both;
}

.color-row { display: flex; gap: 12px; align-items: center; }
.color-row input[type=color] {
  width: 56px; height: 42px; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; cursor: pointer;
  transition: transform var(--t) var(--ease-spring);
}
.color-row input[type=color]:hover { transform: scale(1.05); }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--brand-700);
  background: linear-gradient(180deg, var(--brand-500) -40%, var(--brand-600) 100%);
  color: #fff;
  font: inherit; font-size: .92rem; font-weight: 600; line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(18, 53, 42, .2), inset 0 1px 0 rgba(255, 255, 255, .14);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease);
}
.btn:hover {
  color: #fff;
  text-decoration: none;
  background: linear-gradient(180deg, var(--brand-500) -10%, var(--brand-700) 100%);
  box-shadow: 0 6px 16px -6px rgba(45, 106, 79, .6), inset 0 1px 0 rgba(255, 255, 255, .14);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0) scale(.98); box-shadow: 0 1px 2px rgba(18, 53, 42, .2); }
.btn:focus-visible { box-shadow: var(--ring); border-radius: 9px; }
.btn .icon { transition: transform var(--t) var(--ease); }
.btn:hover .icon-slide { transform: translateX(3px); }

.btn.secondary {
  background: var(--surface);
  color: var(--brand-700);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn.secondary:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-800); box-shadow: var(--shadow-sm); }

.btn.danger { background: linear-gradient(180deg, #c4503f -40%, var(--danger) 100%); border-color: #922f25; }
.btn.danger:hover { background: linear-gradient(180deg, #c4503f -10%, #962f24 100%); box-shadow: 0 6px 16px -6px rgba(176, 58, 46, .55); }

.btn.link {
  background: none; border: 0; box-shadow: none;
  color: var(--muted); padding: 2px 4px; font-weight: 500;
}
.btn.link:hover { color: var(--brand-700); background: none; box-shadow: none; transform: none; text-decoration: underline; text-underline-offset: 3px; }
td .btn.link:last-child:hover, form[data-confirm] .btn.link:hover { color: var(--danger); }

.btn.sm { padding: 6px 11px; font-size: .84rem; border-radius: 8px; }
.btn[disabled], .btn.is-loading { opacity: .7; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; margin-left: 4px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.actions > h1 { margin: 0; }
.container > .actions:first-child, .page-enter > .actions:first-child { justify-content: space-between; margin: 0 0 8px; }
.bot-title { margin-top: 0; gap: 12px; }
.bot-title h1 { margin: 0; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
  font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr { transition: background var(--t-fast) var(--ease); }
tbody tr:hover { background: var(--brand-50); }
tbody tr:last-child td { border-bottom: 0; }
td a { font-weight: 600; }
td .muted { font-size: .86rem; }

/* filters bar */
.filters {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 18px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card .filters { padding: 0; border: 0; box-shadow: none; background: none; margin: 16px 0 0; }
.filters > * { flex: 1 1 160px; }
.filters label { margin-top: 0; }
.filters .check { margin: 4px 0; }
.filters .btn { flex: 0 0 auto; }

/* ==========================================================================
   Badges, alerts, meters
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .76rem; font-weight: 600; text-transform: capitalize; letter-spacing: .01em;
  background: var(--neutral-bg); color: var(--text-2);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.pulse::before { animation: pulse-dot 1.6s var(--ease) infinite; }

.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: 18px;
  font-size: .93rem;
  animation: slide-down var(--t-slow) var(--ease) both;
}
.alert > .icon { margin-top: 1px; }
.alert .alert-body { flex: 1; min-width: 0; }
.alert.success { background: var(--ok-bg); color: #1d4a37; border-color: #c4e6cf; }
.alert.success > .icon { color: var(--ok); }
.alert.error { background: var(--danger-bg); color: #7e271e; border-color: #f2cbc4; }
.alert.error > .icon { color: var(--danger); }
.alert.warn { background: var(--warn-bg); color: #6e4105; border-color: #f3dcb0; }
.alert.warn > .icon { color: var(--warn); }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.alert ul { margin: 0; padding-left: 18px; }
.alert .alert-close { margin: -6px -8px -6px 0; width: 30px; height: 30px; color: inherit; opacity: .6; }
.alert .alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.alert.is-leaving { animation: fade-out var(--t) var(--ease) forwards; }

progress.meter {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; margin-top: 12px;
  border: 0; border-radius: 99px; overflow: hidden;
  background: var(--neutral-bg);
  color: var(--brand-500);
}
progress.meter::-webkit-progress-bar { background: var(--neutral-bg); border-radius: 99px; }
progress.meter::-webkit-progress-value { background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); border-radius: 99px; transition: width .9s var(--ease); }
progress.meter::-moz-progress-bar { background: linear-gradient(90deg, var(--brand-400), var(--brand-600)); border-radius: 99px; }
progress.meter.warn::-webkit-progress-value { background: linear-gradient(90deg, #e0a43a, var(--warn)); }
progress.meter.warn::-moz-progress-bar { background: linear-gradient(90deg, #e0a43a, var(--warn)); }
progress.meter.danger::-webkit-progress-value { background: linear-gradient(90deg, #d9705f, var(--danger)); }
progress.meter.danger::-moz-progress-bar { background: linear-gradient(90deg, #d9705f, var(--danger)); }

/* processing banner */
.processing {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-50); color: var(--brand-800);
  font-size: .9rem; font-weight: 500;
}
.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--brand-200); border-top-color: var(--brand-600); border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* empty states */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .empty-icon {
  display: grid; place-items: center;
  width: 64px; height: 64px; margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
  color: var(--brand-600);
  animation: float 4s ease-in-out infinite;
}
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

/* ==========================================================================
   Key-value lists, pagination
   ========================================================================== */
dl.kv { display: grid; grid-template-columns: 190px 1fr; gap: 10px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .9rem; }
dl.kv dd { margin: 0; font-weight: 500; }

.pagination { display: flex; gap: 8px; margin-top: 18px; align-items: center; justify-content: center; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: .88rem;
}
.pagination a { transition: background var(--t) var(--ease), border-color var(--t) var(--ease); }
.pagination a:hover { background: var(--brand-50); border-color: var(--brand-200); text-decoration: none; }
.pagination span.muted { border-color: transparent; background: none; }

/* ==========================================================================
   Bot pages: header + tabs
   ========================================================================== */
.bot-hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.bot-avatar {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 15px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 8px 18px -8px rgba(45, 106, 79, .7);
}
.bot-hero h1 { margin: 0; }
.bot-hero .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .86rem; margin-top: 3px; }
.bot-hero .meta code { font-size: .78rem; }

.tabs {
  display: flex; gap: 4px; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 24px;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 12px 12px;
  color: var(--muted); font-weight: 500; font-size: .9rem;
  text-decoration: none; white-space: nowrap;
  border-radius: 8px 8px 0 0;
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
}
.tabs a::after {
  content: "";
  position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  border-radius: 2px;
  background: var(--brand-600);
  transform: scaleX(0);
  transition: transform var(--t) var(--ease);
}
.tabs a:hover { color: var(--text); background: rgba(45, 106, 79, .05); text-decoration: none; }
.tabs a:hover::after { transform: scaleX(.4); background: var(--brand-200); }
.tabs a.active { color: var(--brand-700); font-weight: 600; }
.tabs a.active::after { transform: scaleX(1); background: var(--brand-600); }

/* bot cards (bots index) */
.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.bot-card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
  animation: rise var(--t-slow) var(--ease) both;
}
.bot-grid > .bot-card:nth-child(2) { animation-delay: 60ms; }
.bot-grid > .bot-card:nth-child(3) { animation-delay: 120ms; }
.bot-grid > .bot-card:nth-child(n+4) { animation-delay: 180ms; }
.bot-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }
.bot-card .top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.bot-card .bot-avatar { width: 44px; height: 44px; border-radius: 13px; }
.bot-card h3 { margin: 0; font-size: 1.05rem; }
.bot-card h3 a { color: var(--text); }
.bot-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* whole card clickable */
.bot-card .figures { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.bot-card .figure { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.bot-card .figure strong { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.bot-card .figure span { font-size: .78rem; color: var(--muted); }
.bot-card .links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; position: relative; z-index: 1; }
.bot-card .links a {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .82rem; padding: 5px 10px; border-radius: 8px;
  background: var(--brand-50); color: var(--brand-700);
  transition: background var(--t) var(--ease), transform var(--t-fast) var(--ease);
}
.bot-card .links a:hover { background: var(--brand-100); text-decoration: none; transform: translateY(-1px); }
.bot-card.new {
  align-items: center; justify-content: center; text-align: center; gap: 8px;
  border: 2px dashed var(--border-strong); background: transparent; box-shadow: none;
  color: var(--muted); min-height: 200px; text-decoration: none;
}
.bot-card.new:hover { border-color: var(--brand-400); color: var(--brand-700); background: var(--brand-50); text-decoration: none; }
.bot-card.new .plus {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  transition: transform var(--t) var(--ease-spring);
}
.bot-card.new:hover .plus { transform: rotate(90deg) scale(1.08); }

/* step numbers (embed page) */
.step {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-600); color: #fff;
  font-size: .8rem; font-weight: 700;
}

/* ==========================================================================
   Transcript
   ========================================================================== */
.transcript { display: flex; flex-direction: column; gap: 14px; background: var(--surface-2); }
.t-msg {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  animation: rise var(--t-slow) var(--ease) both;
}
.t-visitor { align-self: flex-end; background: var(--brand-600); border-color: var(--brand-600); color: #fff; border-bottom-right-radius: 4px; }
.t-visitor .t-meta { color: rgba(255, 255, 255, .75); }
.t-visitor .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.t-bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: var(--shadow-xs); }
.t-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.t-meta { font-size: .78rem; color: var(--muted); margin-bottom: 4px; }
.t-bot .t-meta:last-child { margin: 8px 0 0; padding-top: 8px; border-top: 1px dashed var(--border); }

/* ==========================================================================
   Appearance live preview (mirrors the widget's look)
   ========================================================================== */
.preview-stage {
  position: relative; height: 440px;
  border-radius: var(--radius);
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(183, 228, 199, .45), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(239, 230, 210, .9), transparent 50%),
    var(--bg-deep);
  border: 1px solid var(--border);
  --pv: #2d6a4f; --pv-on: #fff;
}
.preview-stage::before {
  /* faux website skeleton */
  content: "";
  position: absolute; left: 22px; top: 24px; width: 46%; height: 140px;
  background:
    linear-gradient(#fff, #fff) 0 0 / 70% 14px no-repeat,
    linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7)) 0 30px / 100% 10px no-repeat,
    linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7)) 0 50px / 85% 10px no-repeat,
    linear-gradient(rgba(255,255,255,.7), rgba(255,255,255,.7)) 0 70px / 92% 10px no-repeat;
  border-radius: 6px;
}
.pv-panel {
  position: absolute; bottom: 70px; right: 16px; width: 270px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .28);
  overflow: hidden; font-size: 13px;
  animation: pop-in .5s var(--ease-spring) both .15s;
  transition: right var(--t-slow) var(--ease), left var(--t-slow) var(--ease);
}
.pv-header { display: flex; gap: 9px; align-items: center; padding: 12px; background: var(--pv); color: var(--pv-on); transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.pv-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.pv-body { padding: 12px; display: flex; flex-direction: column; gap: 9px; background: #f8f8f5; min-height: 160px; }
.pv-msg { padding: 8px 11px; border-radius: 12px; max-width: 85%; animation: rise .4s var(--ease) both; }
.pv-msg:nth-child(2) { animation-delay: .45s; }
.pv-bot { background: #fff; border: 1px solid #e7e5de; align-self: flex-start; }
.pv-visitor { background: var(--pv); color: var(--pv-on); align-self: flex-end; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.pv-launcher {
  position: absolute; bottom: 16px; right: 16px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--pv); color: var(--pv-on);
  font-weight: 600; font-size: 13px;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .3);
  transition: background var(--t) var(--ease), color var(--t) var(--ease), right var(--t-slow) var(--ease), left var(--t-slow) var(--ease);
}
.preview-stage.left .pv-panel, .preview-stage.left .pv-launcher { right: auto; left: 16px; }
.preview-stage.left::before { left: auto; right: 22px; }

/* ==========================================================================
   Guest (auth) layout
   ========================================================================== */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}
.auth-aside {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px;
  color: #e3f1e7;
  background:
    radial-gradient(circle at 15% 10%, rgba(82, 183, 136, .35), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(183, 228, 199, .18), transparent 45%),
    linear-gradient(160deg, var(--brand-800) 0%, var(--brand-900) 70%);
}
.auth-aside::before {
  /* subtle dot grid */
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}
.auth-aside > * { position: relative; }
.auth-aside .brand { padding: 0; }
.auth-pitch h2 { color: #fff; font-size: 2.1rem; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 14px; max-width: 460px; }
.auth-pitch p { color: rgba(227, 241, 231, .78); font-size: 1.02rem; max-width: 440px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.auth-points li { display: flex; align-items: center; gap: 10px; color: rgba(227, 241, 231, .9); font-size: .95rem; }
.auth-points .icon { color: var(--brand-400); }

/* animated demo chat in the aside */
.demo-chat { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin-top: 34px; }
.demo-chat .bubble {
  padding: 10px 14px; border-radius: 16px; font-size: .9rem; line-height: 1.45;
  opacity: 0; animation: bubble-in .6s var(--ease) forwards;
}
.demo-chat .bubble.v { align-self: flex-end; background: var(--brand-400); color: var(--brand-900); font-weight: 500; border-bottom-right-radius: 4px; animation-delay: .4s; }
.demo-chat .bubble.b { align-self: flex-start; background: rgba(255, 255, 255, .1); color: #f0f7f2; border: 1px solid rgba(255, 255, 255, .12); border-bottom-left-radius: 4px; backdrop-filter: blur(6px); animation-delay: 1.6s; }
.demo-chat .typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .1); opacity: 0; animation: typing-show 1.2s var(--ease) .9s forwards; }
.demo-chat .typing span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .7); animation: blink 1s infinite; }
.demo-chat .typing span:nth-child(2) { animation-delay: .15s; }
.demo-chat .typing span:nth-child(3) { animation-delay: .3s; }
.auth-aside .fineprint { font-size: .82rem; color: rgba(227, 241, 231, .5); }

.auth-main {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 40px 24px;
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 420px;
  animation: rise .55s var(--ease) both;
}
.auth-card .mobile-brand { display: none; }
.auth-card h1 { font-size: 1.75rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 22px; }
.auth-card form .btn[type=submit]:only-child, .auth-card .actions .btn[type=submit] { min-width: 140px; }
.auth-card .actions.stack .btn[type=submit] { width: 100%; padding: 11px 16px; }
.auth-card .below { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: .92rem; }
.auth-card .site-footer { padding: 24px 0 0; text-align: left; }

/* legacy narrow layout (unused by new guest layout, kept for safety) */
.narrow { max-width: 440px; margin: 48px auto; padding: 0 16px; }

/* ==========================================================================
   Legal / public pages
   ========================================================================== */
.public-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: rgba(246, 245, 240, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.public-top .brand { padding: 0; color: var(--text); }
.public-top .brand:hover { color: var(--text); }
.legal { max-width: 780px; }
.legal-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 40px; box-shadow: var(--shadow-xs); }
.legal h2 { font-size: 1.12rem; margin-top: 28px; }
.legal p, .legal li { color: var(--text-2); }

.site-footer { text-align: center; color: var(--muted); font-size: .84rem; padding: 26px 16px 32px; }
.site-footer a { color: var(--muted); font-weight: 500; }
.site-footer a:hover { color: var(--brand-700); }

/* ==========================================================================
   Keyframes
   ========================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(-6px); height: 0; padding-top: 0; padding-bottom: 0; margin: 0; border-width: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(1.6); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes typing-show { 0% { opacity: 0; } 15%, 80% { opacity: 1; } 100% { opacity: 0; height: 0; padding: 0; margin: -10px 0 0; } }
@keyframes blink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .nav-backdrop {
    position: fixed; inset: 0; z-index: 30;
    background: rgba(18, 30, 25, .4);
    backdrop-filter: blur(2px);
    animation: backdrop-in var(--t) var(--ease);
  }
  .main { margin-left: 0; }
  .mobile-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 20;
    padding: 10px 16px;
    background: rgba(246, 245, 240, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-bar .brand { padding: 0; color: var(--text); font-size: .98rem; }
  .mobile-bar .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
  .mobile-bar .icon-btn { color: var(--text); }
  .mobile-bar .icon-btn:hover { background: var(--bg-deep); }
  .container { padding: 22px 16px 16px; }

  .auth { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card .mobile-brand { display: flex; margin-bottom: 28px; padding: 0; color: var(--text); }
  .auth-card .mobile-brand:hover { color: var(--text); }
}
@media (min-width: 961px) { .nav-backdrop { display: none; } }

@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 10px; }
  .card { padding: 18px 16px; }
  .legal-body { padding: 24px 18px; }
  .t-msg { max-width: 92%; }
  .public-top { padding: 12px 16px; }
  .preview-stage { height: 400px; }
  .pv-panel { width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .demo-chat .bubble { opacity: 1; }
}

@media print {
  .sidebar, .mobile-bar, .site-footer, .tabs, .actions, form { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}

/* auth form helpers */
.actions.split { justify-content: space-between; margin-top: 12px; }
.actions.split .check { margin: 0; }
.auth-card .actions.stack { margin-top: 22px; }
.auth-card .empty { padding: 10px 0 0; }
.page-head .actions { margin-top: 0; }
.actions:has(> h1) { justify-content: space-between; margin: 0 0 20px; }

/* error pages */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 30% 20%, rgba(183, 228, 199, .4), transparent 45%), var(--bg); }
.error-card { text-align: center; max-width: 440px; animation: rise .55s var(--ease) both; }
.error-card .empty-icon { display: grid; place-items: center; width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 20px;
  background: linear-gradient(135deg, var(--brand-50), var(--brand-100)); color: var(--brand-600); animation: float 4s ease-in-out infinite; }
.error-code { font-size: .8rem; font-weight: 700; letter-spacing: .14em; color: var(--brand-500); margin-bottom: 6px; }
.error-card .actions { justify-content: center; }

@media (max-width: 640px) {
  .grid:has(> .stat) { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 1.45rem; }
  .stat .stat-icon { width: 32px; height: 32px; margin-bottom: 8px; }
  .page-head { margin-bottom: 18px; }
}

/* sub-sections inside a card */
.card h3 { margin: 26px 0 6px; padding-top: 20px; border-top: 1px solid var(--border); }
.card h3:first-child, .empty h3, .bot-card h3, .card .empty h3 { margin-top: 0; padding-top: 0; border-top: 0; }
