/* Veyro CRM — "Lapis" design system
   Deep navy chrome, lapis-blue accent, sky-blue secondary. 8px grid. Onest (Latin + Cyrillic). */
:root {
  --bg: #EEF3FB;
  --bg-glow-1: rgba(30, 91, 255, .10);
  --bg-glow-2: rgba(34, 184, 240, .10);
  --surface: #FFFFFF;
  --surface-2: #F5F8FE;
  --glass: rgba(255, 255, 255, .72);
  --ink: #0B1638;
  --ink-2: #44506B;
  --ink-3: #7C88A3;
  --line: #DDE4F2;
  --line-2: #C6D1E8;
  --accent: #1E5BFF;
  --accent-2: #22B8F0;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6EDFF;
  --grad: linear-gradient(135deg, #1E5BFF 0%, #3D7BFF 45%, #22B8F0 100%);
  --navy-1: #070F2B;
  --navy-2: #0F1F55;
  --danger: #E5364B;
  --danger-soft: #FDECEE;
  --ok: #10935A;
  --ok-soft: #E4F6EC;
  --warn: #C27803;
  --focus: #1E5BFF;
  --shadow-sm: 0 1px 2px rgba(11, 22, 56, .06), 0 2px 6px rgba(30, 91, 255, .05);
  --shadow: 0 2px 4px rgba(11, 22, 56, .05), 0 10px 28px rgba(30, 91, 255, .10);
  --shadow-lg: 0 24px 60px rgba(11, 22, 56, .22);
  --r-s: 8px;
  --r-m: 14px;
  --sidebar: 240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #060C22; --bg-glow-1: rgba(30, 91, 255, .22); --bg-glow-2: rgba(34, 184, 240, .12);
    --surface: #0E1836; --surface-2: #121E42; --glass: rgba(14, 24, 54, .72);
    --ink: #E8EEFF; --ink-2: #A9B6D6; --ink-3: #7584A8; --line: #1C2A55; --line-2: #2A3B70;
    --accent: #4D7FFF; --accent-soft: #15265C; --danger: #FF6B7D; --danger-soft: #3A1520; --ok: #3DD68C; --ok-soft: #0F3324;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 10px 30px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #060C22; --bg-glow-1: rgba(30, 91, 255, .22); --bg-glow-2: rgba(34, 184, 240, .12);
  --surface: #0E1836; --surface-2: #121E42; --glass: rgba(14, 24, 54, .72);
  --ink: #E8EEFF; --ink-2: #A9B6D6; --ink-3: #7584A8; --line: #1C2A55; --line-2: #2A3B70;
  --accent: #4D7FFF; --accent-soft: #15265C; --danger: #FF6B7D; --danger-soft: #3A1520; --ok: #3DD68C; --ok-soft: #0F3324;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow: 0 10px 30px rgba(0,0,0,.35); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 400 14px/1.5 "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 24px; letter-spacing: -.015em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Buttons & inputs ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--grad); border-color: transparent; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 18px rgba(30, 91, 255, .35);
}
.btn.primary:hover { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 10px 26px rgba(30, 91, 255, .45); transform: translateY(-1px); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn { width: 38px; padding: 0; justify-content: center; }

label.f { display: block; margin-bottom: 16px; }
label.f > span { display: block; margin-bottom: 6px; font-weight: 500; color: var(--ink-2); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=search], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[type=color] { width: 46px; height: 40px; padding: 3px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); cursor: pointer; }
.has-err input, .has-err select { border-color: var(--danger); }
.field-err { color: var(--danger); font-size: 13px; margin-top: 6px; }
.hint { color: var(--ink-3); font-size: 13px; margin-top: 6px; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row > * { flex: 1; min-width: 0; }

/* Flash & toasts */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; background: var(--ok-soft); color: var(--ok); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 80; }
.toast {
  background: var(--navy-2); color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); max-width: 380px;
  animation: toast-in .35s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }

/* Brand mark: a bevelled 3D tile */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.02em; color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800;
  background: var(--grad);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), inset 0 -3px 0 rgba(0,0,0,.18), 0 6px 14px rgba(30,91,255,.45);
}

/* ===================================================================== */
/* Guest pages: animated 3D scene                                         */
/* ===================================================================== */
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: var(--bg); }
.guest-side {
  position: relative; overflow: hidden; padding: 44px 48px; display: flex; flex-direction: column; justify-content: space-between;
  color: #D6E2FF; background: radial-gradient(120% 90% at 20% 10%, #16307F 0%, var(--navy-2) 35%, var(--navy-1) 100%);
  isolation: isolate;
}
.guest-side .brand { color: #fff; position: relative; z-index: 3; }
.guest-copy { position: relative; z-index: 3; max-width: 480px; margin-top: auto; margin-bottom: 36px; }
.guest-copy::before { content: ""; position: absolute; inset: -40px -60px -30px -48px; z-index: -1; background: radial-gradient(closest-side, rgba(7,15,43,.75), transparent); }
.guest-copy h2 { font-size: 40px; line-height: 1.08; letter-spacing: -.03em; font-weight: 700; color: #fff; margin-bottom: 14px; }
.guest-copy h2 span { background: linear-gradient(90deg, #8FB2FF, #5FE0FF); -webkit-background-clip: text; background-clip: text; color: transparent; }
.guest-copy p { color: #A9BCEB; font-size: 16px; }
.lang-switch { position: relative; z-index: 3; display: flex; gap: 14px; font-size: 13px; }
.lang-switch a { color: #C6D4FF; opacity: .7; }
.lang-switch a[aria-current] { opacity: 1; font-weight: 600; color: #fff; }

/* Aurora light */
.aurora { position: absolute; inset: -20%; z-index: 0; filter: blur(60px); opacity: .85; pointer-events: none; }
.aurora i { position: absolute; border-radius: 50%; mix-blend-mode: screen; animation: drift 18s ease-in-out infinite alternate; }
.aurora i:nth-child(1) { width: 46%; height: 46%; left: 8%; top: 18%; background: #1E5BFF; }
.aurora i:nth-child(2) { width: 38%; height: 38%; right: 6%; top: 8%; background: #22B8F0; animation-duration: 22s; animation-delay: -6s; }
.aurora i:nth-child(3) { width: 40%; height: 40%; left: 30%; bottom: 0; background: #5B3DFF; opacity: .7; animation-duration: 26s; animation-delay: -12s; }
@keyframes drift { to { transform: translate(8%, -6%) scale(1.15); } }
.grid-floor {
  position: absolute; inset: auto -30% -40% -30%; height: 80%; z-index: 1; pointer-events: none;
  background-image: linear-gradient(rgba(120,160,255,.18) 1px, transparent 1px), linear-gradient(90deg, rgba(120,160,255,.18) 1px, transparent 1px);
  background-size: 48px 48px; transform: perspective(600px) rotateX(70deg); transform-origin: top;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, transparent 95%);
  mask-image: linear-gradient(to bottom, transparent, #000 30%, transparent 95%);
  animation: floor 8s linear infinite;
}
@keyframes floor { to { background-position: 0 48px; } }

/* Floating isometric board */
.scene { position: absolute; inset: 0; z-index: 2; perspective: 1400px; pointer-events: none; }
.scene-board {
  position: absolute; right: -10%; top: 4%; width: 600px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  transform-style: preserve-3d; transform: rotateX(56deg) rotateZ(-34deg);
  transition: transform .4s ease-out;
}
.scene-col { transform-style: preserve-3d; display: grid; gap: 12px; align-content: start; }
.scene-head {
  height: 34px; border-radius: 8px 0 0 8px; color: #fff; font-size: 12px; font-weight: 600; display: flex; align-items: center; padding: 0 14px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
  animation: drop .9s cubic-bezier(.2, .9, .25, 1.15) both;
}
.scene-card {
  height: 74px; border-radius: 10px; background: rgba(255,255,255,.96); padding: 12px 14px; display: grid; gap: 7px; align-content: start;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 18px 30px rgba(3, 10, 40, .45);
  border-left: 4px solid var(--c, #1E5BFF);
  animation: drop .9s cubic-bezier(.2, .9, .25, 1.15) both, bob 6s ease-in-out infinite alternate;
}
.scene-card b { display: block; height: 8px; border-radius: 4px; background: #CFDAF5; }
.scene-card b:first-child { width: 70%; background: #0B1638; opacity: .85; }
.scene-card b:nth-child(2) { width: 45%; background: var(--c, #1E5BFF); }
.scene-card b:nth-child(3) { width: 85%; }
@keyframes drop { from { opacity: 0; transform: translateZ(260px) translateY(-40px); } }
@keyframes bob { from { transform: translateZ(10px); } to { transform: translateZ(34px); } }

/* Form side */
.guest-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; position: relative; overflow: hidden; }
.guest-main::before {
  content: ""; position: absolute; width: 520px; height: 520px; right: -200px; top: -200px; border-radius: 50%;
  background: radial-gradient(circle, var(--bg-glow-1), transparent 70%); pointer-events: none;
}
.guest-card {
  position: relative; width: 100%; max-width: 420px; padding: 36px; border-radius: 20px;
  background: var(--glass); backdrop-filter: blur(16px); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: rise .8s .15s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.guest-card h1 { margin-bottom: 6px; }
.guest-card .sub { color: var(--ink-3); margin-bottom: 24px; }
.guest-card .btn.primary { width: 100%; justify-content: center; height: 44px; font-size: 15px; }
.guest-foot { margin-top: 20px; color: var(--ink-3); }
@media (max-width: 960px) {
  .guest { grid-template-columns: 1fr; }
  .guest-side { min-height: 280px; padding: 28px 24px; }
  .guest-copy h2 { font-size: 28px; }
  .scene-board { width: 420px; right: -55%; top: -12%; opacity: .3; }
}

/* ===================================================================== */
/* App shell                                                              */
/* ===================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  color: #C9D6FF; background: linear-gradient(180deg, var(--navy-2) 0%, var(--navy-1) 100%);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.06);
}
.sidebar .brand { color: #fff; padding: 0 4px; }
.org-switch select { height: 38px; font-weight: 600; background: rgba(255,255,255,.07); color: #fff; border-color: rgba(255,255,255,.14); }
.org-switch select option { color: #0B1638; }
.nav { display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; }
.nav a, .nav .soon {
  display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 10px;
  color: #B4C4F0; text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
}
.nav a > span, .nav .soon > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] {
  background: var(--grad); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 8px 20px rgba(30, 91, 255, .45);
}
.nav .soon { color: #6E80B4; cursor: default; }
.nav .soon em { margin-left: auto; font-style: normal; font-size: 10.5px; border: 1px solid rgba(255,255,255,.15); border-radius: 99px; padding: 0 7px; white-space: nowrap; flex: none; }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 4px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: #fff; }
.me:hover, .me[aria-current] { background: rgba(255,255,255,.07); text-decoration: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 11.5px; box-shadow: 0 2px 6px rgba(30,91,255,.4);
}
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; box-shadow: none; }
.avatar.none { background: var(--line-2); color: var(--ink-3); }
.me small { display: block; color: #8EA1D6; font-size: 12px; }
.sidebar .btn.ghost { color: #B4C4F0; }
.sidebar .btn.ghost:hover { color: #fff; background: rgba(255,255,255,.07); }

.main {
  min-width: 0; display: flex; flex-direction: column;
  background:
    radial-gradient(800px 500px at 85% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(700px 500px at 10% 110%, var(--bg-glow-2), transparent 70%),
    var(--bg);
}
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 14px 28px;
  background: var(--glass); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin-right: auto; font-size: 22px; }
.menu-btn { display: none; }
.page { padding: 28px; }
.page-narrow { max-width: 800px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 22px; box-shadow: var(--shadow-sm); }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 16px; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 270px; transform: translateX(-100%); transition: transform .25s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .page { padding: 16px; }
}

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-weight: 500; color: var(--ink-3); font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* Dashboard */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 18px 22px; box-shadow: var(--shadow-sm);
}
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, var(--bg-glow-1), transparent 70%); }
.stat:first-child { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 12px 30px rgba(30,91,255,.35); }
.stat:first-child span { color: rgba(255,255,255,.85); }
.stat b { display: block; font-size: 32px; font-weight: 700; letter-spacing: -.03em; }
.stat span { color: var(--ink-3); font-size: 13px; }
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 200px 1fr 170px; gap: 14px; align-items: center; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.bar-fill { height: 100%; border-radius: 99px; box-shadow: inset 0 1px 0 rgba(255,255,255,.4); animation: grow 1s cubic-bezier(.2,.9,.3,1) both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(0); } }
.bar-row .num { text-align: right; font-weight: 600; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .bar-row { grid-template-columns: 1fr; gap: 4px; } .bar-row .num { text-align: left; } }

/* ===================================================================== */
/* Kanban board                                                           */
/* ===================================================================== */
.board-tools {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 28px;
  background: var(--glass); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.board-tools input[type=search] {
  width: 260px; padding-left: 36px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237C88A3' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center;
}
.board-tools select { width: auto; min-width: 160px; }
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(290px, 1fr); gap: 14px;
  padding: 20px 28px 28px; overflow-x: auto; align-items: start; min-height: calc(100vh - 150px);
  perspective: 1600px;
}
.col { display: flex; flex-direction: column; max-height: calc(100vh - 180px); min-width: 0; }
.col-head {
  position: relative; height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 28px 0 16px; color: var(--stage-ink, #fff); font-weight: 600;
  border-radius: 10px 0 0 10px;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 0 100%);
  background-color: var(--stage);
  background-image: linear-gradient(180deg, rgba(255,255,255,.2), rgba(255,255,255,0) 65%);
}
.col-head .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-head .count { flex: none; font-weight: 600; font-size: 13px; padding: 1px 9px; border-radius: 99px; background: rgba(255,255,255,.25); }
.col-sum {
  margin: 10px 0; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; letter-spacing: -.02em; color: var(--ink);
  background: var(--glass); border: 1px dashed var(--line-2);
}
.col-head, .col-sum, .card, .col-empty { flex: none; }
.col-body {
  padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 120px; align-content: start; flex: 1;
  border-radius: 12px; transition: background .15s;
}
.col.drop .col-body { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-empty { color: var(--ink-3); font-size: 13px; text-align: center; padding: 22px 8px; border: 1.5px dashed var(--line-2); border-radius: 12px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 14px 12px 18px;
  cursor: grab; display: grid; gap: 8px; text-align: left; color: inherit; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stage); }
.card:hover { transform: translateY(-3px) rotateX(4deg); box-shadow: var(--shadow); border-color: var(--line-2); }
.card.dragging { opacity: .4; transform: scale(.98); }
.card.pending { opacity: .7; }
.card .t { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card .t strong { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.card .v { font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: var(--ink); }
.card .v.zero { color: var(--ink-3); font-weight: 500; }
.card .ph { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 13px; font-weight: 500; }
.card .ph svg.i { width: 14px; height: 14px; }
.card .fl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; font-size: 12.5px; margin: 0; }
.card .fl dt { color: var(--ink-3); }
.card .fl dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--ink-2); }
.card .fl dd span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .ft { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-3); padding-top: 8px; border-top: 1px solid var(--line); }
.card .prio-high { color: var(--danger); font-weight: 600; }
.drop-marker { height: 4px; background: var(--grad); border-radius: 2px; margin: -3px 0; box-shadow: 0 0 10px rgba(30,91,255,.6); }
.board-empty { margin: 24px 28px 0; }

/* Drawer & dialogs */
.scrim { position: fixed; inset: 0; background: rgba(6, 12, 34, .45); backdrop-filter: blur(3px); z-index: 40; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100vw); background: var(--surface); z-index: 45;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .3s cubic-bezier(.2,.9,.3,1);
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer header { display: flex; align-items: center; gap: 8px; padding: 16px 22px; background: var(--grad); color: #fff; }
.drawer header h2 { margin-right: auto; font-size: 18px; }
.drawer header .btn { color: #fff; }
.drawer header .btn:hover { background: rgba(255,255,255,.15); border-color: transparent; }
.drawer .body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer .stage-pill { border-left: 5px solid var(--stage); }
dialog {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink);
  width: min(580px, calc(100vw - 32px)); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .28s cubic-bezier(.2,.9,.3,1.15); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
dialog::backdrop { background: rgba(6, 12, 34, .5); backdrop-filter: blur(3px); }
dialog form > header { padding: 18px 22px; border-bottom: 1px solid var(--line); }
dialog .dbody { padding: 22px; max-height: 70vh; overflow-y: auto; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.dups { border: 1px solid var(--warn); background: rgba(194,120,3,.06); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.dups ul { margin: 8px 0 0; padding-left: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 12px; }
.timeline li::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--line-2); margin-top: 4px; box-shadow: 0 0 0 4px var(--surface-2); }
.timeline li.note::before { background: var(--accent); }
.timeline li.stage::before { background: var(--accent-2); }
.timeline .b { white-space: pre-wrap; margin-top: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--navy-1); color: #CFE0FF; border-radius: 12px; padding: 14px; overflow-x: auto; white-space: pre; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, monospace; font-size: 13px; }
.stage-row { display: grid; grid-template-columns: 24px 1fr 54px 150px auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.stage-row .grip { cursor: grab; color: var(--ink-3); }
.stage-row.dragging { opacity: .5; }
@media (max-width: 700px) { .stage-row { grid-template-columns: 24px 1fr 54px; } .stage-row > :nth-child(n+4) { grid-column: 2 / -1; } }

/* ===================================================================== */
/* Welcome animation: plays once after login                              */
/* ===================================================================== */
.intro {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; pointer-events: none;
  background: radial-gradient(90% 90% at 50% 40%, #17348C 0%, var(--navy-2) 40%, var(--navy-1) 100%);
  clip-path: circle(150% at 50% 50%);
  animation: intro-out .9s 1.5s cubic-bezier(.7, 0, .2, 1) forwards;
  perspective: 900px;
}
.intro-cube { width: 96px; height: 96px; position: relative; transform-style: preserve-3d; animation: cube 1.6s cubic-bezier(.3, .9, .3, 1) forwards; }
.intro-cube i {
  position: absolute; inset: 0; border-radius: 22px; display: grid; place-items: center; color: #fff; font: 800 48px/1 "Onest", sans-serif; font-style: normal;
  background: var(--grad); box-shadow: inset 0 2px 0 rgba(255,255,255,.4), 0 0 60px rgba(34,184,240,.45);
}
.intro-cube i:nth-child(1) { transform: translateZ(48px); }
.intro-cube i:nth-child(2) { transform: rotateY(90deg) translateZ(48px); filter: brightness(.8); }
.intro-cube i:nth-child(3) { transform: rotateY(180deg) translateZ(48px); filter: brightness(.7); }
.intro-cube i:nth-child(4) { transform: rotateY(-90deg) translateZ(48px); filter: brightness(.85); }
.intro-cube i:nth-child(5) { transform: rotateX(90deg) translateZ(48px); filter: brightness(1.1); }
.intro-cube i:nth-child(6) { transform: rotateX(-90deg) translateZ(48px); filter: brightness(.6); }
.intro-word { position: absolute; top: calc(50% + 86px); color: #fff; font: 700 28px/1 "Onest", sans-serif; letter-spacing: .02em; animation: word .8s .7s both; }
.intro-ring { position: absolute; width: 220px; height: 220px; border-radius: 50%; border: 2px solid rgba(95,224,255,.5); animation: ring 1.4s .2s ease-out both; }
@keyframes cube { 0% { transform: rotateX(-30deg) rotateY(-200deg) scale(.3); opacity: 0; } 60% { opacity: 1; } 100% { transform: rotateX(-12deg) rotateY(20deg) scale(1); } }
@keyframes word { from { opacity: 0; transform: translateY(14px); letter-spacing: .4em; } }
@keyframes ring { from { transform: scale(.2); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
@keyframes intro-out { to { clip-path: circle(0% at 50% 50%); opacity: 0; } }
.intro-on .sidebar { animation: side-in .8s 1.7s cubic-bezier(.2,.9,.3,1) both; }
.intro-on .topbar, .intro-on .board-tools { animation: rise .7s 1.8s cubic-bezier(.2,.9,.3,1) both; }
.intro-on .col { animation: col-in .9s cubic-bezier(.2, .9, .25, 1.1) both; animation-delay: calc(1.9s + var(--i, 0) * .09s); transform-origin: top center; }
.intro-on .card { animation: card-in .7s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(2.15s + var(--i, 0) * .09s + var(--j, 0) * .05s); }
@keyframes side-in { from { transform: translateX(-60px); opacity: 0; } }
@keyframes col-in { from { opacity: 0; transform: translateZ(-400px) rotateX(35deg) translateY(60px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(30px) rotateX(-25deg) scale(.95); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .intro { display: none; }
}

/* ---- Lead page ------------------------------------------------------ */
.lead-page { display: grid; gap: 16px; max-width: 1280px; }
.lead-hero { padding: 20px 22px 16px; }
.lead-hero-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.lead-hero-name { flex: 1; min-width: 200px; }
.lead-hero-name h2 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
.lead-hero-act { display: flex; gap: 8px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; border-radius: 16px; }
.stagebar { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.stagebar form { display: contents; }
.sb {
  flex: 1 1 0; min-width: 104px; height: 40px; border: 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 0 16px 0 20px; display: flex; align-items: center; justify-content: center; list-style: none;
  color: var(--ink-2); background: var(--surface-2);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
  transition: background .2s, color .2s, transform .15s;
}
.sb::-webkit-details-marker { display: none; }
.sb span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stagebar form:first-child .sb { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 10px 0 0 10px; }
.sb:not([disabled]):hover { background: color-mix(in srgb, var(--stage) 22%, var(--surface-2)); color: var(--ink); }
.sb.done { background-color: var(--stage); color: var(--stage-ink, #fff); background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 70%); }
.sb.cur { box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.sb[disabled] { cursor: default; }
.sb.lost, .sb-lost[open] > .sb { background: var(--stage); color: #fff; }
.sb-lost { position: relative; flex: 1 1 0; min-width: 110px; display: flex; }
.sb-lost > .sb { flex: 1; }
.sb-pop { position: absolute; right: 0; top: 46px; z-index: 30; width: 280px; box-shadow: var(--shadow-lg); }
.lead-grid { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 16px; align-items: start; }
.lead-info h3, .lead-side h3 { font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.lead-info h3.sub { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.kv { margin: 0; display: grid; gap: 2px; }
.kv > div { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; padding: 3px 0; }
.kv dt { color: var(--ink-3); font-size: 13px; line-height: 1.3; }
.kv dd { margin: 0; min-width: 0; }
.kv input, .kv select { height: 34px; border-color: transparent; background: transparent; padding: 0 8px; font-weight: 500; }
.kv input:hover, .kv select:hover { border-color: var(--line); background: var(--surface-2); }
.kv input:focus, .kv select:focus { border-color: var(--accent); background: var(--surface); }
.kv .empty input { font-weight: 400; }
.kv dd.pair { display: flex; gap: 6px; }
.kv dd.pair select { width: 90px; flex: none; }
.kv.static dd { padding: 6px 8px; font-weight: 500; word-break: break-word; }
.kv .owner { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; font-weight: 500; }
.lead-save { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.lead-side { display: grid; gap: 16px; min-width: 0; }
.lead-side .panel + .panel { margin-top: 0; }
.composer { display: grid; gap: 10px; justify-items: start; }
.composer textarea { min-height: 76px; width: 100%; }
.calls h3 .i { color: var(--accent); }
@media (max-width: 900px) {
  .lead-grid { grid-template-columns: 1fr; }
  .kv > div { grid-template-columns: 110px 1fr; }
}

/* ---- Funnel templates, forms, fields --------------------------------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.tpl { border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; display: grid; gap: 12px; align-content: start; background: var(--surface-2); }
.tpl-head { display: grid; gap: 2px; }
.tpl-head .muted { font-size: 13px; }
.tpl-strip { display: flex; gap: 2px; }
.tpl-strip i { flex: 1; height: 10px; background: var(--stage); clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 50%, calc(100% - 4px) 100%, 0 100%); }
.tpl-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.tpl-list li { display: flex; align-items: center; gap: 8px; }
.tpl .btn { justify-self: start; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.form-list { display: grid; gap: 8px; }
.form-opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface); flex-wrap: wrap; }
.form-opt.on, .form-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.form-opt input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.form-name { flex: 1; display: grid; min-width: 160px; }
.field-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.lead-page > *, .lead-grid > * { min-width: 0; }

/* ---- Lead modal --------------------------------------------------------- */
dialog.lead-modal {
  width: min(1180px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg);
  box-shadow: var(--shadow-lg); overflow: auto; color: var(--ink);
}
dialog.lead-modal[open] { animation: lm-in .22s cubic-bezier(.2,.8,.2,1); }
dialog.lead-modal::backdrop { background: rgba(5, 10, 30, .55); backdrop-filter: blur(4px); }
@keyframes lm-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.lead-modal-body { padding: 18px; }
.lead-modal-loading { padding: 60px; text-align: center; color: var(--ink-3); }
.lead-modal .lead-hero { position: sticky; top: -18px; z-index: 5; }
.pill.lock { background: var(--surface-2); color: var(--ink-3); margin-left: 6px; }
.kv input[readonly]:hover { border-color: transparent; background: transparent; }
@media (max-width: 640px) {
  dialog.lead-modal { width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; margin: 0; }
  .lead-modal-body { padding: 10px; }
}
dialog.lead-modal:focus, dialog.lead-modal:focus-visible { outline: none; }

/* ---- v0.5: nav badges, wallpaper, avatars ------------------------------ */
.nav a .badge { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; background: rgba(255,255,255,.16); color: #fff; flex: none; }
.nav a .badge.hot { background: #F0465A; box-shadow: 0 0 0 3px rgba(240,70,90,.25); }
body.has-wall .main {
  background: linear-gradient(var(--veil), var(--veil)), var(--wall);
  background-attachment: fixed; background-size: cover;
}
:root { --veil: rgba(238, 243, 251, .30); }
:root[data-theme="dark"] { --veil: rgba(6, 12, 34, .45); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --veil: rgba(6, 12, 34, .45); } }
body.has-wall .col-sum, body.has-wall .col-empty { background: var(--glass); backdrop-filter: blur(10px); }
body.has-wall .board-tools { background: var(--glass); backdrop-filter: blur(14px); }
.avatar.photo { background-size: cover; background-position: center; color: transparent; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; border: 4px solid var(--surface); box-shadow: var(--shadow); }
.who { display: inline-flex; align-items: center; gap: 10px; }
.count-pill { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; margin-left: 4px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty-state .i { width: 40px; height: 40px; opacity: .5; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 4px 0 12px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg a { padding: 6px 12px; border-radius: 9px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.seg a:hover { text-decoration: none; color: var(--ink); background: var(--surface); }
.seg a.on { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(30,91,255,.3); }

/* Card chips */
.card .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.chip .i { width: 13px; height: 13px; }
.chip.paid { background: var(--ok-soft); color: var(--ok); }
.chip.task { background: var(--accent-soft); color: var(--accent); }
.chip.task.late { background: var(--danger-soft); color: var(--danger); animation: pulse-late 1.6s ease-in-out infinite; }
@keyframes pulse-late { 50% { box-shadow: 0 0 0 4px rgba(229,54,75,.15); } }

/* Composer tabs (note / task / payment) */
.composer-tabs > input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.ctabs { display: flex; gap: 4px; margin: -6px 0 14px; border-bottom: 1px solid var(--line); }
.ctabs label { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.ctabs label .i { width: 15px; height: 15px; }
.cpane { display: none; }
.composer-tabs > input:nth-of-type(1):checked ~ .cp-note,
.composer-tabs > input:nth-of-type(2):checked ~ .cp-task,
.composer-tabs > input:nth-of-type(3):checked ~ .cp-pay { display: grid; gap: 4px; }
.cp-note { justify-items: start; }
.cp-note textarea { width: 100%; min-height: 76px; }
.composer-tabs > input:nth-of-type(1):checked ~ .ctabs label:nth-child(1),
.composer-tabs > input:nth-of-type(2):checked ~ .ctabs label:nth-child(2),
.composer-tabs > input:nth-of-type(3):checked ~ .ctabs label:nth-child(3) { color: var(--accent); border-bottom-color: var(--accent); }
.cpane .btn { justify-self: start; }

/* Task and payment lists */
.tasklist, .paylist, .inbox, .rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tasklist li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.tasklist li.late { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.tasklist li.late small { color: var(--danger); }
.tasklist li.done { opacity: .6; }
.tasklist li.done strong { text-decoration: line-through; }
.tasklist form { display: contents; }
.tick { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); background: transparent; cursor: pointer; color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; transition: .15s; }
.tick:hover { border-color: var(--ok); background: var(--ok-soft); }
li.done .tick { background: var(--ok); border-color: var(--ok); }
.tl-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.tl-main small { color: var(--ink-3); }
.tl-lead { font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.tl-lead .i { width: 13px; height: 13px; }
.paylist li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.paylist li:last-child { border-bottom: 0; }
.pay-total { margin-left: auto; color: var(--ok); font-weight: 700; }
.paid-sum strong { color: var(--ok); padding: 0 8px; }

/* Tasks page */
.tasks-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.task-new { margin-left: auto; position: relative; }
.task-new > summary { list-style: none; }
.task-new > summary::-webkit-details-marker { display: none; }
.task-new > form { position: absolute; right: 0; top: 48px; z-index: 30; width: min(440px, 92vw); box-shadow: var(--shadow-lg); }
.task-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.task-cols .panel + .panel { margin-top: 0; }
.task-col h3 { display: flex; align-items: center; gap: 6px; font-size: 15px; margin: 0 0 12px; }
.tc-overdue h3 { color: var(--danger); }
.tc-overdue .count-pill { background: var(--danger-soft); color: var(--danger); }

/* Finance */
.fin-tools { gap: 10px; flex-wrap: wrap; padding: 0 0 16px; background: none; border: 0; position: static; }
.fin-tools input[type=date] { width: auto; }
.fin-stats { grid-template-columns: 2fr 1fr 1fr; }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.fin-grid .panel + .panel { margin-top: 0; }
.fin h3 { font-size: 15px; margin: 0 0 14px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; align-items: center; gap: 12px; font-size: 14px; }
.hbars li i { height: 10px; border-radius: 99px; background: var(--surface-2); position: relative; overflow: hidden; }
.hbars li i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--grad); border-radius: 99px; }
@media (max-width: 760px) { .fin-stats { grid-template-columns: 1fr; } }

/* Inbox */
.inbox li { display: flex; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); }
.inbox li.unread { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.ib-ico { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--grad); color: #fff; }
.t-payment .ib-ico { background: linear-gradient(135deg, #10935A, #3DD68C); }
.t-task .ib-ico { background: linear-gradient(135deg, #7C5CFF, #22B8F0); }

/* Automation */
.auto-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.auto-hero > div { flex: 1; min-width: 240px; }
.auto-hero h2 { margin: 0 0 4px; }
.rules li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.rules li.off { opacity: .55; }
.rule-flow { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 240px; }
.rf { padding: 4px 10px; border-radius: 8px; font-size: 13.5px; }
.rf.when { background: var(--surface-2); color: var(--ink-3); font-weight: 600; }
.rf.trig { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rf.arrow { color: var(--ink-3); padding: 0; }
.rf.act { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.rule-act { display: flex; align-items: center; gap: 6px; }
.switch { width: 44px; height: 26px; border-radius: 99px; border: 0; background: var(--line-2); position: relative; cursor: pointer; transition: .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--ok); }
.switch.on i { left: 21px; }

/* Profile */
.profile-card { padding: 0; overflow: hidden; }
.pc-cover { height: 130px; background: var(--grad); }
.pc-body { display: flex; align-items: flex-end; gap: 18px; padding: 0 22px 20px; margin-top: -48px; flex-wrap: wrap; }
.pc-name { flex: 1; min-width: 180px; }
.pc-name h2 { margin: 0 0 2px; }
.pc-actions { display: flex; gap: 8px; }
.pc-actions form { margin: 0; }
.wall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.wall { border: 2px solid var(--line); border-radius: 14px; padding: 6px; background: var(--surface); cursor: pointer; display: grid; gap: 6px; font: inherit; font-size: 13px; font-weight: 500; color: var(--ink-2); transition: .15s; }
.wall:hover { border-color: var(--accent); transform: translateY(-2px); }
.wall.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent); }
.wall-prev { height: 70px; border-radius: 9px; display: block; }
.wall-prev.default { background: radial-gradient(at 80% 0%, var(--bg-glow-1), transparent 60%), var(--bg); border: 1px dashed var(--line-2); }

/* Read-only stage bar: shows where the lead is; stage changes happen in the comment form */
.stagebar.readonly .sb { cursor: default; }
.stagebar.readonly .sb:hover { background: var(--surface-2); color: var(--ink-2); }
.stagebar.readonly .sb.done:hover, .stagebar.readonly .sb.lost:hover { background-color: var(--stage); color: var(--stage-ink, #fff); }
.stagebar.readonly .sb:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 10px 0 0 10px; }
.stagebar .sb.lost { background: var(--stage); color: #fff; }
.stage-pick select { font-weight: 600; }
[data-stage-form] .stage-hint { display: none; margin: 2px 0 6px; }
[data-stage-form].moving .stage-hint { display: block; color: var(--accent); font-weight: 500; }
[data-stage-form].moving .stage-pick select { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.card.flash-hl { animation: card-hl 2.4s ease-out; }
@keyframes card-hl { 0%, 30% { box-shadow: 0 0 0 3px var(--accent), 0 14px 40px rgba(30,91,255,.45); transform: translateY(-3px); } 100% { box-shadow: var(--shadow-sm); } }
.stagebar.readonly { justify-content: flex-start; }
.stagebar.readonly .sb { flex: 0 1 190px; }
.stagebar .sb.rest { flex: 0 0 auto; background: transparent; color: var(--ink-3); font-weight: 500; border: 0; padding-left: 22px; }
.stagebar .sb.done:not(.cur) { opacity: .78; }
[data-stage-form] .won-hint { display: none; color: var(--warn); font-weight: 600; margin: 2px 0 6px; }
[data-stage-form].need-pay .won-hint { display: block; }
.receipt-pick input[type=file] { padding: 8px; border: 1px dashed var(--line-2); border-radius: 10px; width: 100%; background: var(--surface-2); }
.receipt-link { font-size: 13px; font-weight: 600; }
.form-opt { display: grid; gap: 10px; }
.form-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; cursor: pointer; }
.form-main input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.form-owners { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding-left: 30px; }
.fo-label { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.fo-hint { flex-basis: 100%; margin: 2px 0 0; }
.chip-check { cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check > span { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 4px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 500; transition: .15s; }
.chip-check input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.chip-check input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Search + filter bar ------------------------------------------------ */
.fbar-wrap { position: relative; display: flex; gap: 10px; padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(14px); z-index: 25; }
.fbar-pipe select { height: 44px; width: auto; }
.fbar { flex: 1; max-width: 900px; }
.fbar-box { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 44px; padding: 4px 6px 4px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); cursor: text; transition: border-color .15s, box-shadow .15s; }
.fbar-box:focus-within, .fpanel-open .fbar-box { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.fbar-ico { display: grid; place-items: center; color: var(--ink-3); }
.fbar-ico .i { width: 18px; height: 18px; }
.fbar-box input[type=search] { flex: 1; min-width: 160px; border: 0; height: 34px; padding: 0 6px; box-shadow: none; background: transparent; }
.fbar-box input[type=search]:focus { box-shadow: none; }
.fchip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 12px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; }
.fchip:hover { text-decoration: none; filter: brightness(1.08); }
.fchip .i { width: 14px; height: 14px; opacity: .8; }
.fbar-clear, .fbar-go { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; }
.fbar-clear:hover, .fbar-go:hover { background: var(--surface-2); color: var(--ink); }
.fbar-go { background: var(--grad); color: #fff; }
.fbar-go:hover { background: var(--grad); color: #fff; filter: brightness(1.1); }
.fbar-go .i, .fbar-clear .i { width: 17px; height: 17px; }
.fpanel { position: absolute; left: 28px; top: calc(100% - 6px); width: min(900px, calc(100vw - 56px)); display: grid; grid-template-columns: 220px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: lm-in .18s ease-out; }
.fp-presets { display: grid; align-content: start; gap: 2px; padding: 14px; background: var(--surface-2); border-right: 1px solid var(--line); }
.fp-presets a { padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; }
.fp-presets a:hover { background: var(--surface); text-decoration: none; color: var(--ink); }
.fp-presets a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fp-fields { padding: 18px 20px; display: grid; gap: 2px; }
.fp-actions { display: flex; gap: 8px; align-items: center; justify-content: center; padding-top: 8px; }
@media (max-width: 760px) {
  .fbar-wrap { padding: 10px 12px; }
  .fpanel { left: 12px; width: calc(100vw - 24px); grid-template-columns: 1fr; }
  .fp-presets { grid-auto-flow: column; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---- Plans ---------------------------------------------------------------- */
.billing { display: grid; gap: 18px; max-width: 1200px; }
.plan-now { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.plan-now h2 { margin: 2px 0; font-size: 26px; }
.usage { flex: 1; min-width: 280px; display: grid; gap: 10px; }
.u-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.u-row i { height: 8px; border-radius: 99px; background: var(--surface-2); position: relative; overflow: hidden; }
.u-row i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--grad); }
.u-row i.hot::after { background: linear-gradient(90deg, #F5A524, #F0465A); }
.period-toggle { justify-self: center; display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.period-toggle button { border: 0; background: transparent; padding: 8px 18px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.period-toggle button.on { background: var(--grad); color: #fff; }
.period-toggle em { font-style: normal; font-size: 12px; margin-left: 4px; color: var(--ok); }
.period-toggle button.on em { color: #D9FFE9; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: stretch; }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 24px 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s; }
.plan-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.plan-card.best { border: 2px solid var(--accent); box-shadow: 0 18px 50px rgba(30,91,255,.22); }
.plan-card.cur { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 60%); }
.plan-card h3 { margin: 0; font-size: 20px; }
.pc-desc { margin: 0; font-size: 13.5px; min-height: 38px; }
.ribbon { position: absolute; top: -12px; right: 18px; background: var(--grad); color: #fff; font-size: 12px; font-weight: 700; padding: 4px 12px; border-radius: 99px; }
.price b { font-size: 30px; letter-spacing: -.03em; }
.price span { color: var(--ink-3); font-size: 14px; }
.feat { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; font-size: 14px; }
.feat li { display: flex; gap: 8px; }
.feat li::before { content: "✓"; color: var(--ok); font-weight: 800; }
.feat li.no { color: var(--ink-3); text-decoration: line-through; }
.feat li.no::before { content: "–"; color: var(--ink-3); }
.plan-card .btn { justify-content: center; }
.cur-btn { background: var(--surface-2); color: var(--ink-3); cursor: default; }

/* Side arrows on the board */
.board-nav {
  position: fixed; z-index: 15; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%; border: 0;
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(10px);
  box-shadow: 0 6px 22px rgba(11, 22, 56, .22), inset 0 0 0 1px var(--line);
  transition: transform .15s, background .15s, opacity .2s; opacity: .85;
}
.board-nav:hover { transform: scale(1.08); opacity: 1; background: var(--surface); }
.board-nav:active { transform: scale(.96); }
.board-nav .i { width: 24px; height: 24px; stroke-width: 2.4; }
.board-nav[hidden] { display: none !important; }
body.nav-open .board-nav, dialog[open] ~ .board-nav { display: none; }
@media (max-width: 760px) { .board-nav { width: 42px; height: 42px; margin-top: -21px; } }
.board-nav { width: 56px; height: 56px; margin-top: -28px; }
.board-nav:hover { background: var(--accent); color: #fff; box-shadow: 0 8px 26px rgba(30,91,255,.45); }
.add-org > summary { list-style: none; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; cursor: pointer; }
.add-org > summary::-webkit-details-marker { display: none; }
.add-org-form { margin-top: 18px; max-width: 640px; }
.new-org-link { border: 2px solid var(--ok); }
.page > .panel + details.panel, .page > details.panel + .panel { margin-top: 16px; }
.agent-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.agent-hero > div:nth-child(2) { flex: 1; min-width: 220px; }
.agent-hero h2 { margin: 0 0 4px; }
.agent-ava { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; background: var(--grad); box-shadow: 0 10px 26px rgba(30,91,255,.35); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.steps { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 18px; counter-reset: st; }
.steps li { position: relative; padding-left: 44px; counter-increment: st; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); }
.steps li.done::before { content: "✓"; background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li .hint { margin: 2px 0 8px; }
.agent-how { margin: 0 0 10px; padding-left: 18px; display: grid; gap: 8px; color: var(--ink-2); }
.inbox li.lvl-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.inbox .ib-ico { background: var(--surface-2); font-size: 18px; }
.conn { border: 2px solid var(--line-2); transition: border-color .3s, background .3s; }
.conn.is-on { border-color: var(--ok); background: linear-gradient(135deg, var(--ok-soft), var(--surface) 70%); }
.conn-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.conn-head h2 { margin: 0; }
.conn-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 5px var(--danger-soft); }
.conn.is-on .conn-dot { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); animation: conn-pulse 2s infinite; }
@keyframes conn-pulse { 50% { box-shadow: 0 0 0 9px transparent; } }
.conn-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.conn-list li { display: grid; grid-template-columns: 24px auto 1fr; align-items: center; gap: 10px; font-size: 14px; }
.conn-list li i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line-2); }
.conn-list li i::after { content: "…"; color: var(--ink-3); }
.conn-list li.ok i { background: var(--ok); border-color: var(--ok); } .conn-list li.ok i::after { content: "✓"; color: #fff; }
.conn-list li.bad i { background: var(--danger); border-color: var(--danger); } .conn-list li.bad i::after { content: "✕"; color: #fff; }
.conn-list li.wait i::after { content: "…"; }
.conn-list small { color: var(--ink-3); overflow-wrap: anywhere; }
.conn-list li.bad small { color: var(--danger); }
.pending-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin: 6px 0 10px; border-radius: 12px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); animation: lm-in .3s ease-out; }
.pending-box form { margin: 0; }
.exp { max-width: 860px; }
.exp .panel h2 { margin-bottom: 14px; }
.exp-seg { margin-bottom: 4px; }
.exp-seg label { padding: 6px 12px; border-radius: 9px; color: var(--ink-2); font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.exp-seg label:hover { color: var(--ink); background: var(--surface); }
.exp-seg label.on { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(30,91,255,.3); }
.exp-seg input { position: absolute; opacity: 0; pointer-events: none; }
.exp-seg label:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.exp-dates { margin-top: 12px; max-width: 420px; }
.exp-stages { display: flex; flex-wrap: wrap; gap: 8px; }
.exp-stage { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; cursor: pointer; background: var(--surface); }
.exp-stage:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.exp-stage input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.exp-stage i { width: 9px; height: 9px; border-radius: 50%; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; margin-left: 8px; padding: 0; }
.exp-go { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px; border-radius: var(--r-m); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.exp-go strong { font-size: 22px; transition: opacity .15s; }
.exp-go .hint { display: block; color: var(--danger); }
