/* Flowline Studio client portal */
:root {
  --blue: #2563eb; --blue-dark: #1d4ed8; --blue-soft: #eff4ff; --blue-ink: #1d4ed8;
  --ink: #101828; --ink-2: #344054; --muted: #667085; --faint: #98a2b3;
  --line: #e4e7ec; --line-2: #f0f2f5;
  --bg: #f8fafc; --surface: #ffffff; --raised: #ffffff; --navy: #0d1b35;
  --good: #067647; --good-bg: #ecfdf3; --warn: #b54708; --warn-bg: #fffaeb; --bad: #b42318; --bad-bg: #fef3f2; --info: #1d4ed8; --info-bg: #eff4ff; --neutral: #475467; --neutral-bg: #f2f4f7;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -12px rgba(16,24,40,.12);
  --radius: 12px;
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink); background: var(--surface);
  font-synthesis: none; text-rendering: optimizeLegibility;
}
:root[data-theme="dark"] {
  --blue: #3b7bff; --blue-dark: #5b92ff; --blue-soft: #14233f; --blue-ink: #8db3ff;
  --ink: #eef2f8; --ink-2: #cdd5e2; --muted: #96a3b8; --faint: #6f7d94;
  --line: #243049; --line-2: #1b2640;
  --bg: #0b1220; --surface: #0b1220; --raised: #121c31; --navy: #070d1a;
  --good: #4ade80; --good-bg: #0f2a1d; --warn: #fbbf24; --warn-bg: #2d2410; --bad: #f87171; --bad-bg: #331617; --info: #8db3ff; --info-bg: #14233f; --neutral: #b4bfd1; --neutral-bg: #1b2640;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--surface); color: var(--ink); }
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a, input, textarea, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 0; }
.ic { flex: none; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-emblem { width: 38px; height: 38px; display: inline-flex; flex: 0 0 38px; align-items: center; justify-content: center; }
.brand-emblem img { width: 100%; height: 100%; display: block; object-fit: contain; }
:root[data-theme="dark"] .brand-emblem img { filter: invert(1); }
.brand-wordmark { display: flex; flex-direction: column; gap: 2px; color: var(--ink); line-height: 1; }
.brand-wordmark > span { font-size: 15px; font-weight: 600; letter-spacing: 4px; }
.brand-wordmark small { font-size: 8px; font-weight: 600; letter-spacing: 5px; text-align: center; }
.topbar .brand-emblem { width: 34px; height: 34px; flex-basis: 34px; }
.topbar .brand-wordmark > span { font-size: 13px; letter-spacing: 3.3px; }
.topbar .brand-wordmark small { font-size: 7px; letter-spacing: 4px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .15s; }
.btn:hover { background: var(--line-2); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn.lg { min-height: 52px; font-size: 14px; border-radius: 10px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); transform: translateY(-1px); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
:root[data-theme="dark"] .btn.danger { color: #1a0505; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.text-link { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 0; color: var(--blue-ink); font-size: 12px; font-weight: 650; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

/* ---------- forms ---------- */
input, textarea, select { font-size: 14px; }
.field, .login-form input:not([type=checkbox]), .form-stack input:not([type=range]):not([type=checkbox]), .form-stack textarea, .form-stack select { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s; }
.form-stack textarea { padding: 12px 14px; resize: vertical; min-height: 100px; line-height: 1.5; }
.field:focus, .login-form input:focus, .form-stack input:focus, .form-stack textarea:focus, .form-stack select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.form-stack { display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.help { font-size: 11px; font-weight: 400; color: var(--faint); }
.form-error { min-height: 18px; margin: 0; color: var(--bad); font-size: 12px; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input { flex: 1; accent-color: var(--blue); }
.range-row output { min-width: 44px; text-align: right; font-weight: 700; font-size: 14px; }
.search { position: relative; display: inline-flex; align-items: center; }
.search > span { position: absolute; left: 11px; color: var(--faint); display: grid; pointer-events: none; }
.search input { height: 38px; min-height: 38px !important; width: 220px; padding: 0 12px 0 34px !important; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); outline: none; font-size: 13px; }
.search input:focus { border-color: var(--blue); }
.search.wide input { width: min(380px, 100%); }
.toolbar { display: flex; margin: 0 0 16px; }

/* ---------- auth ---------- */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(430px, 1fr) minmax(420px, .92fr); }
.auth-card { width: min(480px, calc(100% - 64px)); margin: auto; padding: 40px 0; }
.auth-top { display: flex; align-items: center; justify-content: space-between; }
.auth-copy { margin: 84px 0 36px; }
.eyebrow, .side-label, .side-footer, .nav-caption { font-size: 10px; letter-spacing: 1.55px; font-weight: 700; color: var(--muted); }
.auth-copy h1 { font: 800 clamp(38px, 4.6vw, 54px)/1.08 Manrope, Inter, sans-serif; letter-spacing: -2.5px; margin: 18px 0 16px; }
.auth-copy h1 span { color: var(--blue); }
.auth-copy p { max-width: 365px; color: var(--muted); font-size: 14px; line-height: 1.8; margin: 0; }
.login-form { display: grid; gap: 11px; }
.login-form label { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.remember-option { display: flex; align-items: center; gap: 9px; min-height: 30px; color: var(--muted) !important; font-size: 12px !important; font-weight: 500 !important; cursor: pointer; }
.remember-option input { width: 16px !important; height: 16px; min-height: 16px !important; margin: 0; accent-color: var(--blue); }
.auth-foot { margin-top: 52px; padding-top: 22px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--faint); font-size: 11px; }
.auth-foot a { color: var(--blue-ink); text-decoration: none; font-weight: 600; }
.auth-foot .admin-access { margin-left: auto; }
.auth-side { position: relative; overflow: hidden; background: var(--navy); color: #fff; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; padding: 10%; }
.side-content { position: relative; z-index: 1; max-width: 480px; }
.side-label { color: #b6c6e3; display: flex; align-items: center; gap: 9px; }
.live-dot { width: 7px; height: 7px; background: #60a5fa; border-radius: 50%; box-shadow: 0 0 14px #60a5fa; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.side-heading { font: 800 clamp(48px, 6vw, 74px)/1.04 Manrope, Inter, sans-serif; letter-spacing: -4px; margin: 38px 0 20px; }
.side-heading em { font-style: normal; color: #7da8ff; }
.side-content p { max-width: 340px; color: #aab8cf; font-size: 14px; line-height: 1.85; }
.side-footer { position: absolute; top: calc(100vh - 90px); left: 0; right: 0; display: flex; justify-content: space-between; gap: 16px; color: #7f91ae; font-size: 9px; white-space: nowrap; }
.side-orb { position: absolute; border: 1px solid #ffffff12; border-radius: 50%; pointer-events: none; }
.orb-one { width: 700px; height: 700px; right: -350px; top: -200px; box-shadow: 0 0 0 80px #ffffff04, 0 0 0 160px #ffffff03; }
.orb-two { width: 360px; height: 360px; right: 12%; bottom: -220px; background: radial-gradient(circle, #2563eb28, transparent 70%); }
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell ---------- */
.app-shell { min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.topbar { height: 68px; background: var(--raised); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(16px, 4vw, 56px); position: sticky; top: 0; z-index: 10; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-ink); font-weight: 700; }
.layout { max-width: 1280px; margin: auto; padding: 32px clamp(16px, 4vw, 48px) 64px; display: grid; grid-template-columns: 212px minmax(0, 1fr); gap: 36px; }
.sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 100px; align-self: start; }
.nav-caption { margin: 4px 12px 10px; }
.nav-btn { position: relative; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: var(--muted); font-size: 13px; font-weight: 500; text-decoration: none; transition: background .15s, color .15s; }
.nav-btn:hover { background: var(--line-2); color: var(--ink); }
.nav-btn.active { background: var(--blue-soft); color: var(--blue-ink); font-weight: 650; }
.nav-short { display: none; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--blue); color: #fff; font-size: 11px; font-weight: 700; }
.content { min-width: 0; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0 0 24px; }
.page-heading h1 { font: 800 28px/1.15 Manrope, Inter, sans-serif; letter-spacing: -1px; margin: 0 0 7px; }
.page-heading p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.6; }

/* ---------- cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card, .panel { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card { text-align: left; display: block; width: 100%; transition: transform .15s, border-color .15s; }
button.stat-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.stat-card.static { cursor: default; }
.muted-label { font-size: 10px; color: var(--faint); letter-spacing: 1px; font-weight: 700; text-transform: uppercase; }
.stat-card .muted-label { letter-spacing: .65px; text-transform: none; font-size: 11px; }
.stat-value { font: 800 28px Manrope, Inter, sans-serif; margin-top: 12px; letter-spacing: -.8px; }
.stat-value.sm { font-size: 20px; letter-spacing: -.4px; overflow-wrap: anywhere; }
.stat-sub { font-size: 11px; color: var(--faint); margin-top: 5px; }
.panel { margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { font: 700 15px Manrope, Inter, sans-serif; margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.two-col.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.two-col .panel { margin-bottom: 0; }
.two-col + .panel, .two-col { margin-bottom: 16px; }

/* attention */
.attn-wrap { display: grid; gap: 10px; margin-bottom: 18px; }
.attn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 15px 18px; border: 1px solid; border-radius: var(--radius); text-align: left; background: var(--raised); transition: transform .15s; }
.attn:not(.static):hover { transform: translateX(3px); }
.attn > span { flex: 1; display: grid; gap: 2px; }
.attn strong { font-size: 14px; } .attn small { font-size: 12px; opacity: .85; }
.attn.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.attn.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.attn.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--info); }
.attn.good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 25%, transparent); color: var(--good); }
.attn.static { cursor: default; }

/* badges */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }

/* project */
.project-top { display: flex; align-items: center; gap: 22px; }
.project-name { font: 700 18px Manrope, Inter, sans-serif; margin-bottom: 6px; }
.project-meta { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.project-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.ring { position: relative; flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 9; }
.ring-fg { fill: none; stroke: var(--blue); stroke-width: 9; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring span { font: 800 20px Manrope, Inter, sans-serif; letter-spacing: -.5px; }
.stepper { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 26px 0 4px; padding: 0; }
.stepper li { position: relative; display: grid; justify-items: center; gap: 8px; font-size: 11px; color: var(--faint); text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--line); }
.stepper li:first-child::before { display: none; }
.stepper .dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--raised); border: 2px solid var(--line); font-weight: 700; font-size: 11px; }
.stepper li.done, .stepper li.current { color: var(--ink); }
.stepper li.done::before, .stepper li.current::before { background: var(--blue); }
.stepper li.done .dot { background: var(--blue); border-color: var(--blue); color: #fff; }
.stepper li.current .dot { border-color: var(--blue); color: var(--blue-ink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); }
.stepper li.current { font-weight: 650; }
.hold-note { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; font-size: 12px; color: var(--warn); }

/* timeline + feed */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl-item { position: relative; display: flex; gap: 16px; padding: 0 0 22px; }
.tl-item::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent); flex: none; }
.tl-body { min-width: 0; flex: 1; }
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.tl-body p { margin: 5px 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.tl-body time { font-size: 11px; color: var(--faint); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed button { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 11px 6px; border: 0; background: none; text-align: left; border-radius: 8px; }
.feed button:hover { background: var(--line-2); }
.feed-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-ink); flex: none; }
.feed-tx { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: 13px; }
.feed-tx strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-tx small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed time { font-size: 11px; color: var(--faint); white-space: nowrap; padding-top: 2px; }

/* lists */
.list-row { padding: 14px 0; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.list-row:first-of-type { border-top: 0; }
.list-title { font-weight: 600; color: var(--ink-2); overflow-wrap: anywhere; }
.list-meta { font-size: 11px; color: var(--faint); margin-top: 3px; }
.file-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-ink); font-size: 10px; font-weight: 800; letter-spacing: .5px; flex: none; }
.inv-right { display: grid; justify-items: end; gap: 5px; text-align: right; }
.inv-actions { display: flex; align-items: center; gap: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--raised); border-radius: 20px; padding: 6px 13px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--blue-soft); color: var(--blue-ink); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 36px 16px; text-align: center; color: var(--faint); font-size: 12px; }
.empty-state strong { color: var(--ink-2); font-size: 13px; }
.approval { padding: 16px 0; border-top: 1px solid var(--line-2); }
.approval:first-child { border-top: 0; padding-top: 0; }
.approval-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.approval-desc { margin: 5px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.approval-resp { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--neutral-bg); font-size: 12px; color: var(--ink-2); }
.approval-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.contact-card .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* chat */
.chat { padding: 0; overflow: hidden; }
.chat .panel-head { padding: 18px 20px 0; margin-bottom: 8px; }
.thread { height: min(52vh, 520px); min-height: 280px; overflow-y: auto; padding: 8px 20px 16px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.thread .empty-state { margin: auto; }
.day-sep { text-align: center; margin: 14px 0 8px; }
.day-sep span { font-size: 10px; letter-spacing: .8px; font-weight: 700; color: var(--faint); text-transform: uppercase; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: min(78%, 520px); padding: 10px 14px 8px; border-radius: 16px; background: var(--neutral-bg); font-size: 13px; line-height: 1.55; }
.mine .bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.theirs .bubble { border-bottom-left-radius: 5px; }
.bubble-who { font-size: 10px; font-weight: 700; letter-spacing: .4px; opacity: .7; margin-bottom: 2px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble time { display: block; text-align: right; font-size: 10px; opacity: .6; margin-top: 3px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--raised); }
.composer textarea { flex: 1; min-height: 44px; max-height: 160px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); resize: none; outline: none; line-height: 1.45; }
.composer textarea:focus { border-color: var(--blue); }
.composer .btn { min-height: 44px; border-radius: 12px; }

/* tables (admin) */
.admin-layout { max-width: 1200px; margin: auto; padding: 36px 24px 60px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); white-space: nowrap; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.mini-bar { width: 110px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin-bottom: 4px; }
.mini-bar span { display: block; height: 100%; background: var(--blue); }

/* modal + toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(8, 13, 26, .55); backdrop-filter: blur(3px); animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(480px, 100%); max-height: calc(100dvh - 40px); overflow: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px -12px rgba(0,0,0,.4); animation: pop .18s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h2 { font: 700 17px Manrope, Inter, sans-serif; margin: 0; }
.modal-body { padding: 14px 20px 20px; }
.modal-intro { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); margin-bottom: 10px; }
.code-box code { font: 700 17px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; overflow-wrap: anywhere; user-select: all; }
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; justify-items: end; }
.toast { display: flex; align-items: center; gap: 9px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 10px; background: #101828; color: #fff; font-size: 13px; box-shadow: 0 12px 32px rgba(16,24,40,.3); animation: pop .2s ease; }
.toast.err { background: #b42318; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }

/* ---------- responsive ---------- */
@media (max-width: 980px) { .two-col, .two-col.wide-left { grid-template-columns: 1fr; } }
@media (max-width: 850px) {
  .auth-shell { display: block; }
  .auth-card { width: min(100% - 40px, 520px); min-height: 100dvh; padding: max(26px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: center; }
  .auth-copy { margin: clamp(40px, 9vh, 72px) 0 28px; }
  .auth-copy h1 { font-size: clamp(38px, 9.2vw, 52px); letter-spacing: -2px; }
  .auth-copy p { font-size: 15px; }
  .auth-side { display: none; }
  .auth-foot { margin-top: 30px; }
  .auth-foot .admin-access { margin-left: 0; flex: 0 0 100%; padding-top: 12px; border-top: 1px solid var(--line-2); }
  .auth-foot .admin-access a { display: inline-flex; min-height: 40px; align-items: center; }
  .brand-emblem { width: 40px; height: 40px; flex-basis: 40px; }
  .topbar { height: auto; min-height: 60px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
  .user-name { display: none; }
  .layout { grid-template-columns: 1fr; gap: 0; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .sidebar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 20; flex-direction: row; gap: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--raised); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -12px rgba(16,24,40,.18); }
  .nav-caption, .nav-text { display: none; }
  .nav-short { display: block; font-size: 9.5px; font-weight: 600; }
  .nav-btn { flex: 1; min-width: 0; flex-direction: column; justify-content: center; gap: 3px; padding: 7px 2px; border-radius: 10px; }
  .nav-badge { position: absolute; top: 2px; left: 50%; margin: 0 0 0 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .page-heading h1 { font-size: 24px; }
  .card-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 16px; }
  .stat-value { margin-top: 8px; }
  .panel { padding: 16px; }
  .project-top { gap: 16px; }
  .thread { height: 50vh; padding: 8px 14px 14px; }
  .bubble { max-width: 88%; }
  .list-row.invoice { flex-wrap: wrap; }
  .admin-layout { padding: 22px 14px calc(30px + env(safe-area-inset-bottom)); }
  .admin-layout .page-heading { flex-wrap: wrap; }
  table { min-width: 640px; }
  input, textarea, select { font-size: 16px !important; }
  .btn { min-height: 44px; } .btn.sm { min-height: 38px; }
  .search { width: 100%; } .search input { width: 100%; }
  #toasts { right: 12px; left: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); justify-items: stretch; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; }
}
@media (max-width: 520px) {
  .attn { padding: 13px 14px; }
  .stepper li { font-size: 10px; }
  .project-top { flex-direction: column; align-items: flex-start; }
}
@media print { .topbar, .sidebar, #toasts { display: none !important; } }


/* ---------- Flowline refinement pass ---------- */
:root {
  --blue: #2864e8;
  --blue-dark: #1f55cf;
  --blue-soft: #edf3ff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,.025), 0 12px 32px -22px rgba(16,24,40,.22);
}
:root[data-theme="dark"] {
  --blue: #6c9aff;
  --blue-dark: #8aafff;
  --blue-soft: #182946;
  --shadow: 0 8px 28px -20px rgba(0,0,0,.65);
}
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }
.btn, .icon-btn, .nav-btn, .chip { transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease; }
.btn { border-radius: 11px; }
.btn.primary { box-shadow: 0 4px 12px -7px var(--blue); }
.btn.primary:active, .btn:active { transform: scale(.985); }
.icon-btn { width: 40px; height: 40px; border: 1px solid var(--line); background: var(--raised); }
.brand { gap: 10px; }
.brand-emblem { overflow: hidden; border-radius: 11px; }
.brand-emblem img { border-radius: inherit; }
.brand-wordmark > span { letter-spacing: 3.6px; }
.auth-shell { background: var(--surface); }
.auth-card { width: min(460px, calc(100% - 64px)); }
.auth-copy { margin-top: clamp(54px, 9vh, 92px); }
.auth-copy h1 { letter-spacing: -2.8px; }
.auth-copy p { max-width: 390px; }
.login-form { gap: 12px; }
.login-form input:not([type=checkbox]) { min-height: 52px; border-radius: 12px; padding-inline: 15px; background: var(--bg); }
.login-form .btn { min-height: 52px; margin-top: 4px; }
.remember-option { width: fit-content; user-select: none; }
.auth-side { background: radial-gradient(ellipse at 75% 80%, #193c78 0%, transparent 48%), #0a1730; }
.side-heading { letter-spacing: -4.5px; }
.topbar { backdrop-filter: saturate(180%) blur(18px); background: color-mix(in srgb, var(--raised) 92%, transparent); }
.layout { max-width: 1360px; grid-template-columns: 224px minmax(0,1fr); gap: clamp(24px,4vw,56px); }
.sidebar { padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--raised); box-shadow: var(--shadow); }
.nav-caption { padding: 6px 8px 4px; }
.nav-btn { min-height: 44px; border-radius: 10px; }
.nav-btn.active { box-shadow: inset 2px 0 0 var(--blue); }
.content { min-width: 0; }
.page-heading { align-items: center; margin-bottom: 22px; }
.page-heading h1 { letter-spacing: -1.25px; }
.card-grid { gap: 16px; }
.stat-card, .panel { border-radius: 16px; box-shadow: var(--shadow); }
.stat-card { padding: 22px; }
.stat-value { letter-spacing: -1.1px; }
.panel { padding: 22px; }
.panel-head { margin-bottom: 18px; }
.project-top { gap: 24px; }
.list-row { padding-block: 15px; }
.empty-state { padding: 44px 18px; }
.chat { padding: 0; }
.chat .panel-head { padding: 20px 22px 0; }
.composer { padding: 16px 20px; }
.composer textarea { font-size: 16px; }
.modal { border-radius: 18px; }
.modal-backdrop { backdrop-filter: blur(7px); }
.code-box { border-radius: 12px; }
#toasts { bottom: max(20px, env(safe-area-inset-bottom)); }
.admin-layout { max-width: 1320px; }
.admin-layout .panel { overflow: hidden; }
.table-wrap { border-radius: 10px; }
th { padding-block: 15px; }
td { padding-block: 15px; }

@media (min-width: 851px) {
  .auth-card { padding-block: 56px; }
  .layout { padding-top: 42px; }
  .sidebar { top: 92px; }
  .stat-card:hover { border-color: color-mix(in srgb, var(--blue) 28%, var(--line)); }
  .panel:hover { border-color: color-mix(in srgb, var(--blue) 12%, var(--line)); }
}
@media (max-width: 850px) {
  html, body { overscroll-behavior-x: none; }
  .auth-card { width: min(calc(100% - 44px), 480px); padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .auth-copy { margin: clamp(46px, 8vh, 72px) 0 30px; }
  .auth-copy h1 { font-size: clamp(37px, 10vw, 48px); letter-spacing: -2.4px; }
  .auth-foot { line-height: 1.7; }
  .topbar { min-height: 64px; padding-inline: 16px; }
  .topbar .brand-emblem { width: 32px; height: 32px; flex-basis: 32px; }
  .topbar .brand-wordmark > span { font-size: 12px; letter-spacing: 2.8px; }
  .topbar .brand-wordmark small { font-size: 7px; letter-spacing: 3.5px; }
  .user-chip { gap: 7px; }
  .user-chip .btn { min-height: 38px; padding-inline: 11px; }
  .layout { padding: 24px 16px calc(100px + env(safe-area-inset-bottom)); }
  .sidebar { left: 0; right: 0; bottom: 0; padding: 7px 5px max(7px, env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; border-left: 0; border-right: 0; border-bottom: 0; display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 2px; }
  .nav-btn { min-height: 58px; padding: 7px 1px 5px; gap: 4px; border-radius: 10px; }
  .nav-btn .ic { width: 19px; height: 19px; }
  .nav-short { font-size: 9px; letter-spacing: -.1px; line-height: 1.1; }
  .nav-btn.active { box-shadow: none; background: var(--blue-soft); }
  .nav-badge { top: 1px; left: calc(50% + 3px); }
  .page-heading { gap: 12px; margin-bottom: 18px; }
  .page-heading h1 { font-size: 25px; }
  .page-heading p { font-size: 12px; }
  .card-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .stat-card { min-width: 0; padding: 15px; }
  .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-value { font-size: 24px; overflow-wrap: anywhere; }
  .stat-sub { line-height: 1.4; }
  .panel { padding: 17px; margin-bottom: 12px; }
  .two-col, .two-col.wide-left { gap: 12px; }
  .project-top { flex-direction: row; align-items: center; gap: 15px; }
  .stepper { margin-top: 22px; }
  .stepper li { font-size: 9px; gap: 7px; }
  .thread { height: min(54dvh, 540px); min-height: 260px; }
  .composer { padding: 12px; gap: 8px; }
  .composer .btn { min-width: 46px; padding-inline: 12px; }
  .admin-layout { padding: 22px 14px calc(28px + env(safe-area-inset-bottom)); }
  .admin-layout .card-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .admin-layout .stat-card { padding: 13px; }
  .admin-layout .stat-value { font-size: 22px; }
  .table-wrap { margin-inline: -4px; }
  table { min-width: 660px; }
  input, textarea, select { font-size: 16px !important; }
  .field, .login-form input:not([type=checkbox]), .form-stack input:not([type=range]):not([type=checkbox]), .form-stack textarea, .form-stack select { scroll-margin-bottom: 120px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: min(90dvh, 760px); padding-bottom: env(safe-area-inset-bottom); }
  #toasts { left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); }
}
@media (max-width: 390px) {
  .layout { padding-inline: 12px; }
  .nav-short { font-size: 8px; }
  .nav-btn .ic { width: 18px; height: 18px; }
  .topbar { padding-inline: 12px; }
  .topbar .brand { gap: 7px; }
  .topbar .brand-wordmark > span { font-size: 11px; letter-spacing: 2.3px; }
  .user-chip .btn { padding-inline: 8px; font-size: 11px; }
  .card-grid { gap: 8px; }
  .stat-card { padding: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
