/* ==========================================================================
   SOLO — Freelance Studio Platform · Shared Design System
   --------------------------------------------------------------------------
   "platform.css" — one stylesheet for the whole product (admin panel +
   client portal). Every page links to ../shared/platform.css and
   ../shared/platform.js.

   DESIGN TOKENS ............ colors, radii, shadows, motion
   BASE ..................... reset, typography, utilities
   APP SHELL ................ centered 1280px shell, sidebar + main
   SIDEBAR .................. dark nav, groups, upgrade card
   TOPBAR ................... profile, search pill, icon buttons
   POPUPS ................... search dropdown + notifications dropdown
   ========================================================================== */

/* Self-hosted Inter (variable font, weights 100-900) — no third-party
   requests on the critical path; the Google Fonts <link> was render-blocking
   every page load. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-var.woff2') format('woff2');
}

/* ============================
   1. DESIGN TOKENS
   ============================ */
:root {
  /* Surfaces */
  --bg:        #eef3f5;
  --shell-bg:  #f1f6f7;
  --shell:     #202023;          /* dark sidebar */
  --panel:     #ffffff;
  --text:      #101116;
  --muted:     #7c818a;
  --line:      #e7e9ef;
  --field-bg:  #ffffff;

  /* Brand + accents */
  --brand:     #4f59f5;
  --brand-2:   #6c74ff;
  --brand-soft:#e9ebff;          /* focus ring tint */
  --green:     #22bf67;
  --orange:    #ff6728;
  --yellow:    #f1c51b;
  --red:       #ff4f57;
  --teal:      #0fb5a8;
  --purple:    #7a5cff;

  /* Pastel card tints */
  --lavender:  #d8dafb;
  --mint:      #c7efd7;
  --peach:     #f9dccc;
  --cream:     #f5edb9;
  --sky:       #d3e9fb;
  --rose:      #fbd9e2;

  /* Shape + depth */
  --radius:    22px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow:    0 18px 50px rgba(35, 43, 61, .08);
  --shadow-sm: 0 2px 8px rgba(39, 47, 66, .05);
  --shadow-lg: 0 28px 80px rgba(38, 44, 69, .18);

  /* Layout */
  --shell-width: 248px;
  --mobile-nav: 76px;

  /* Spacing scale (4px base) — utilities: .m-/.mt-/.mb-/.p- 1,2,3,4,5,6,8,10 */
  --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px;  --sp-8: 32px; --sp-10: 40px;

  /* Type — the ONE sans stack (loaded via Google Fonts in layouts) */
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Motion */
  --ease:      cubic-bezier(.22, .9, .28, 1);
  --dur:       .22s;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}


/* ============================
   2. BASE
   ============================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

h1, h2, h3, h4 { letter-spacing: -.02em; }

/* Small layout utilities */
.row            { display: flex; align-items: center; gap: 10px; }
.row-between    { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap           { flex-wrap: wrap; }
.grow           { flex: 1; min-width: 0; }
/* Spacing utilities — 4px base scale (standardized; legacy .mt-1..3 remapped:
   .mt-1 was 8px→4px, .mt-2 was 16px→8px, .mt-3 was 24px→12px) */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.m-1 { margin: var(--sp-1); } .m-2 { margin: var(--sp-2); }
.m-3 { margin: var(--sp-3); } .m-4 { margin: var(--sp-4); }
.m-5 { margin: var(--sp-5); } .m-6 { margin: var(--sp-6); }
.m-8 { margin: var(--sp-8); } .m-10 { margin: var(--sp-10); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); } .mt-10 { margin-top: var(--sp-10); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); } .mb-10 { margin-bottom: var(--sp-10); }
.p-1 { padding: var(--sp-1); } .p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); } .p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); } .p-6 { padding: var(--sp-6); }
.p-8 { padding: var(--sp-8); } .p-10 { padding: var(--sp-10); }
.muted          { color: var(--muted); }
.small          { font-size: 12px; }
.tiny           { font-size: 11px; }
.strong         { font-weight: 700; }
.ellipsis       { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden         { display: none !important; }
.text-right     { text-align: right; }
.text-center    { text-align: center; }


/* ============================
   3. APP SHELL
   Max width 1280px (fits a 1280x720 screen), unlimited height.
   ============================ */
.app-shell {
  width: min(1280px, calc(100% - 48px));
  min-height: calc(100vh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: var(--shell-width) minmax(0, 1fr);
  overflow: hidden;
  border-radius: 32px;
  background: var(--shell-bg);
  box-shadow: var(--shadow-lg);
  animation: shellIn .45s var(--ease);
}

@keyframes shellIn {
  from { opacity: 0; transform: translateY(10px) scale(.998); }
  to   { opacity: 1; transform: none; }
}

.main {
  min-width: 0;
  padding: 26px 26px 34px;
  background: var(--shell-bg);
}


/* ============================
   4. SIDEBAR
   ============================ */
.sidebar {
  background: var(--shell);
  color: #fff;
  padding: 34px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3a3a3f transparent;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px 24px;
  font-size: 24px; font-weight: 800; letter-spacing: -.8px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 10px; flex: 0 0 30px;
  background: linear-gradient(140deg, var(--brand) 10%, var(--purple) 90%);
  display: grid; place-items: center; color: #fff;
  font-size: 16px; font-weight: 900;
  box-shadow: 0 6px 16px rgba(79, 89, 245, .45);
  transition: transform .3s var(--ease);
}
.brand:hover .brand-mark { transform: rotate(-10deg) scale(1.06); }

.nav-group { display: grid; gap: 4px; }
.nav-label {
  margin: 14px 10px 4px; color: #a6a8b1;
  font-size: 11px; text-transform: uppercase; letter-spacing: .14em;
}
.nav-item {
  border: 0; width: 100%; padding: 12px 14px; border-radius: 14px;
  background: transparent; color: #bfc0c7;
  display: flex; align-items: center; gap: 12px;
  font-size: 14.5px; text-align: left; position: relative;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.nav-item.active { background: #fff; color: #17181b; font-weight: 700; }
.nav-item.active::before {
  content: ""; position: absolute; left: -18px; top: 20%;
  width: 4px; height: 60%; border-radius: 0 4px 4px 0; background: var(--brand-2);
}
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; flex: 0 0 20px; font-size: 16px; }
.nav-count {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: rgba(255,255,255,.12);
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.nav-item.active .nav-count { background: var(--brand-soft); color: var(--brand); }

/* Sidebar footer card */
.upgrade {
  margin-top: auto; border-radius: 24px; padding: 18px 16px;
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(145deg, #3d54f6, #6a5cff);
}
.upgrade::after {
  content: ""; position: absolute; right: -34px; top: -34px;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.25), transparent 70%);
}
.upgrade h3 { margin: 0 0 6px; font-size: 17px; }
.upgrade p { margin: 0 0 12px; color: #dce2ff; line-height: 1.5; font-size: 12px; }
.upgrade .btn { width: 100%; }


/* ============================
   5. TOPBAR
   ============================ */
.topbar {
  min-height: 80px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; position: relative; z-index: 60;
}
.profile { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 48px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 16px;
  background: linear-gradient(145deg, #5c7190, #adc2db);
  border: 3px solid #e9eef2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .08);
}
.avatar.sm { width: 34px; height: 34px; flex-basis: 34px; font-size: 12px; border-width: 2px; }
.avatar.lg { width: 64px; height: 64px; flex-basis: 64px; font-size: 22px; }
.avatar.g1 { background: linear-gradient(145deg, #4f59f5, #9a6bff); }
.avatar.g2 { background: linear-gradient(145deg, #22bf67, #7fe0a8); }
.avatar.g3 { background: linear-gradient(145deg, #ff6728, #ffb03a); }
.avatar.g4 { background: linear-gradient(145deg, #0fb5a8, #6fe3d4); }
.avatar.g5 { background: linear-gradient(145deg, #e0497a, #ff9db8); }
.profile strong { display: block; font-size: 15px; }
.profile small { color: var(--muted); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 10px; position: relative; }

.search-wrap { position: relative; }
.search {
  width: 280px; height: 50px; border: 0; border-radius: 999px;
  background: #fff; padding: 0 18px 0 46px; outline: none;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .03);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23101418' stroke-width='1.8'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 16px center;
  transition: box-shadow var(--dur) var(--ease), width var(--dur) var(--ease);
}
.search:focus { box-shadow: 0 0 0 4px var(--brand-soft), 0 3px 12px rgba(0,0,0,.05); }
.search::placeholder { color: #a3a8b1; }

.icon-btn {
  width: 50px; height: 50px; border: 0; border-radius: 50%;
  background: #fff; display: grid; place-items: center;
  position: relative; font-size: 19px; color: var(--text);
  box-shadow: 0 3px 12px rgba(0, 0, 0, .03);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.icon-btn:active { transform: scale(.94); }
.badge {
  position: absolute; right: 5px; top: 5px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid #fff;
  animation: badgePop .4s var(--ease);
}
@keyframes badgePop { 0% { transform: scale(.4); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }


/* ============================
   6. POPUPS — search + notifications dropdowns
   ============================ */
.popup {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 380px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 20px;
  box-shadow: 0 24px 70px rgba(35, 43, 61, .22);
  border: 1px solid var(--line);
  opacity: 0; transform: translateY(-8px) scale(.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  z-index: 120; overflow: hidden;
}
.popup.open { opacity: 1; transform: none; pointer-events: auto; }
.popup-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
}
.popup-head h3 { margin: 0; font-size: 15px; }
.unread-pill {
  display: inline-block; vertical-align: 1px;
  font-size: 11px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 999px; padding: 2px 9px;
  margin-left: 2px; white-space: nowrap;
}
.popup-head .link-btn {
  border: 0; background: none; color: var(--brand);
  font-size: 12px; font-weight: 700;
}
.popup-body { max-height: 380px; overflow-y: auto; padding: 4px 8px 10px; }
.popup-foot {
  padding: 10px 16px; border-top: 1px solid var(--line);
  text-align: center; font-size: 12px; color: var(--muted);
}

.search-popup { right: auto; left: 0; transform-origin: top left; width: 420px; }
.search-section-label {
  padding: 10px 10px 4px; font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.search-hit {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: none; text-align: left;
  padding: 10px; border-radius: 12px;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.search-hit:hover { background: #f4f5ff; transform: translateX(3px); }
.search-hit .hit-icon {
  width: 36px; height: 36px; border-radius: 12px; flex: 0 0 36px;
  display: grid; place-items: center; font-size: 16px; background: #eef0ff; color: var(--brand);
}
.search-hit strong { display: block; font-size: 13px; }
.search-hit small { color: var(--muted); font-size: 11px; }
.search-hit .hit-tag {
  margin-left: auto; font-size: 10px; font-weight: 700; color: var(--muted);
  background: #f1f3f6; padding: 4px 9px; border-radius: 999px; flex: 0 0 auto;
}
.search-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.notif { display: flex; gap: 12px; padding: 11px 10px; border-radius: 12px; transition: background var(--dur); }
.notif:hover { background: #f7f8fb; }
.notif .notif-icon {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 38px;
  display: grid; place-items: center; font-size: 16px;
}
.notif p { margin: 0; font-size: 13px; line-height: 1.45; }
.notif time { font-size: 11px; color: var(--muted); }
.notif .unread-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
  margin-left: auto; margin-top: 6px; flex: 0 0 8px;
}
.notif.read { opacity: .62; }
.notif.read .unread-dot { display: none; }

/* ==========================================================================
   7. PAGES + ENTRANCE ANIMATIONS
   ========================================================================== */
.page-heading { margin: 8px 0 18px; }
.page-heading h1 { margin: 0; font-size: clamp(23px, 3vw, 30px); letter-spacing: -.8px; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 640px; }
.page-heading .row-between { align-items: flex-start; }

/* Staggered reveal-on-load. Add class="reveal" to any block;
   JS assigns increasing --d delays per section. */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in {
  opacity: 1; transform: none;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
  transition-delay: var(--d, 0ms);
}

/* Count-up numbers */
[data-count] { font-variant-numeric: tabular-nums; }


/* ==========================================================================
   8. CARDS + PANELS
   ========================================================================== */
.panel, .stat-card, .metric-card, .tool-card, .card {
  position: relative;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.panel { padding: 20px 18px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }

.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 16px;
}
.panel-title h2 { margin: 0; font-size: 16.5px; }
.panel-title p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card { min-height: 142px; padding: 20px 16px 14px; overflow: hidden; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card::after {
  content: ""; position: absolute; width: 104px; height: 104px;
  right: -22px; bottom: -38px; border-radius: 36px; opacity: .22;
  background: repeating-linear-gradient(135deg, transparent 0 11px, rgba(255,255,255,.85) 12px 15px);
  pointer-events: none;
}
.lavender { background: var(--lavender); }
.mint     { background: var(--mint); }
.peach    { background: var(--peach); }
.cream    { background: var(--cream); }
.sky      { background: var(--sky); }
.rose     { background: var(--rose); }

.stat-head { display: flex; justify-content: space-between; align-items: center; color: #20222a; font-weight: 650; font-size: 13.5px; }
.round-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 15px; flex: 0 0 32px;
}
.round-icon.blue { background: #5962ff; } .round-icon.green { background: #25bc68; }
.round-icon.orange { background: #ff6a2a; } .round-icon.yellow { background: #e7c615; }
.round-icon.teal { background: #0fb5a8; } .round-icon.pink { background: #e0497a; }
.stat-number { font-size: 26px; font-weight: 800; margin-top: 20px; letter-spacing: -.6px; }
.trend { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.up { color: #1d9e57; font-weight: 700; } .down { color: #e5484f; font-weight: 700; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.metric-card { min-height: 140px; padding: 18px 16px; overflow: hidden; }
.metric-card::after {
  content: ""; position: absolute; right: -12px; bottom: -62px;
  width: 150px; height: 120px; border-radius: 50%;
  border: 22px solid rgba(255,255,255,.22);
  box-shadow: 0 0 0 22px rgba(255,255,255,.12); pointer-events: none;
}
.metric-label { display: flex; align-items: center; gap: 9px; font-size: 13.5px; font-weight: 650; }
.metric-value { margin-top: 22px; font-size: 25px; font-weight: 800; }
.metric-sub { color: var(--muted); font-size: 11.5px; margin-top: 5px; }

.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.tool-card { border: 1px solid var(--line); padding: 20px; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tool-card h3 { margin: 12px 0 6px; font-size: 15px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.tool-symbol {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center; font-size: 19px;
  background: #eceeff; color: #525cff;
}

.two-col { display: grid; grid-template-columns: minmax(0, 2.05fr) minmax(280px, .95fr); gap: 18px; }
.two-col.rev { grid-template-columns: minmax(280px, .95fr) minmax(0, 2.05fr); }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }


/* ==========================================================================
   9. BUTTONS
   Premium feel: soft press scale, hover lift, sheen sweep on primary.
   ========================================================================== */
.btn {
  border: 0; border-radius: 999px; padding: 12px 20px;
  font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease), filter var(--dur);
  position: relative; overflow: hidden; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { color: #fff; background: linear-gradient(135deg, #4f59f5, #6a5cff); box-shadow: 0 8px 20px rgba(79, 89, 245, .32); }
.btn-primary:hover { box-shadow: 0 12px 26px rgba(79, 89, 245, .42); filter: brightness(1.05); }
.btn-primary::after { /* sheen sweep */
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%;
  left: -60%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-20deg); transition: left .6s var(--ease);
}
.btn-primary:hover::after { left: 130%; }

.btn-secondary { color: #22252b; background: #eef1f4; }
.btn-secondary:hover { background: #e3e8ee; }
.btn-success { color: #fff; background: linear-gradient(135deg, #22bf67, #3ddc84); box-shadow: 0 8px 20px rgba(34, 191, 103, .3); }
.btn-danger  { color: #fff; background: linear-gradient(135deg, #ff5c64, #ff7a59); box-shadow: 0 8px 20px rgba(255, 92, 100, .3); }
.btn-ghost   { color: var(--brand); background: var(--brand-soft); }
.btn-ghost:hover { background: #dfe3ff; }
.btn-outline { color: var(--text); background: #fff; border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-dark    { color: #fff; background: #202023; }
.btn-sm { padding: 8px 14px; font-size: 12px; }
.btn-lg { padding: 15px 28px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 50%; }

/* Back-compat aliases used by older markup */
.primary, .secondary, .danger { border: 0; border-radius: 999px; padding: 12px 19px; font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; transition: transform var(--dur) var(--ease), filter var(--dur); }
.primary { color: #fff; background: linear-gradient(135deg, #4f59f5, #6a5cff); box-shadow: 0 8px 20px rgba(79,89,245,.3); }
.secondary { color: #22252b; background: #eef1f4; }
.danger { color: #fff; background: linear-gradient(135deg, #ff5c64, #ff7a59); }
.primary:hover, .secondary:hover, .danger:hover { transform: translateY(-1px); filter: brightness(1.04); }
.primary:active, .secondary:active, .danger:active { transform: scale(.96); }


/* ==========================================================================
   10. FORMS — inputs highlight on focus, keep rounded corners
   ========================================================================== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; align-content: start; }
.field.full { grid-column: 1 / -1; }
.field > label, .field legend {
  font-size: 12.5px; font-weight: 700; color: #2a2d34;
  display: flex; align-items: center; gap: 6px;
}
.field .hint { font-size: 11.5px; color: var(--muted); }
.req { color: var(--red); font-weight: 800; }

.input, .select, .select-large {
  width: 100%; border: 1.5px solid #e1e6eb; outline: none;
  background: var(--field-bg); color: var(--text);
  border-radius: 10px; padding: 13px 17px; font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background var(--dur) var(--ease);
}
/* .textarea intentionally excluded: textareas stay square (see below — explicit product direction). */
.textarea { border-radius: 0; min-height: 120px; resize: vertical; line-height: 1.55; }
/* Square corners on every textarea-class input AND the rich-text editor
   chrome (explicit product direction — overrides the old 6px radius). */
textarea.textarea, textarea.input, .rte, .rte-toolbar .tb-select, .rt-toolbar { border-radius: 0 !important; }
select.input, .select, .select-large {
  appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237c818a' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.select { border: 0; background-color: #f3f6f7; border-radius: 10px; padding: 9px 34px 9px 14px; font-size: 12px; color: #24272e; }

/* THE focus highlight: brand border + soft glow ring */
.input:focus, .textarea:focus, .select:focus, .select-large:focus,
.rte-content:focus-within, .search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft), 0 2px 10px rgba(79, 89, 245, .08);
  background: #fff;
}
.field:focus-within > label { color: var(--brand); }
.input::placeholder, .textarea::placeholder { color: #a6abb4; }
.input:disabled, .textarea:disabled { background: #f3f5f7; color: var(--muted); cursor: not-allowed; }
.input.is-invalid { border-color: var(--red); box-shadow: 0 0 0 4px rgba(255, 79, 87, .12); }
.field .error-msg { font-size: 11.5px; color: var(--red); font-weight: 600; }

.input-group { position: relative; }
.input-group .input { padding-left: 44px; }
.input-group .prefix-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 16px; pointer-events: none;
}
.input-group .suffix { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; font-weight: 700; }

/* Checkboxes / radios — custom, rounded, animated */
.check, .radio { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; user-select: none; }
.check input, .radio input { position: absolute; opacity: 0; pointer-events: none; }
.check .box, .radio .box {
  width: 22px; height: 22px; border-radius: 8px; flex: 0 0 22px;
  border: 1.5px solid #d4d9e0; background: #fff; display: grid; place-items: center;
  transition: all var(--dur) var(--ease); font-size: 13px; color: #fff;
}
.radio .box { border-radius: 50%; }
.check input:checked + .box { background: var(--brand); border-color: var(--brand); box-shadow: 0 4px 10px rgba(79,89,245,.35); }
.check input:checked + .box::after { content: "✓"; animation: checkPop .25s var(--ease); }
.radio input:checked + .box { border-color: var(--brand); border-width: 6px; box-shadow: 0 4px 10px rgba(79,89,245,.3); }
.check input:focus-visible + .box, .radio input:focus-visible + .box { box-shadow: 0 0 0 4px var(--brand-soft); }
@keyframes checkPop { 0% { transform: scale(.4); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* Switch */
.switch { width: 46px; height: 27px; padding: 3px; border: 0; border-radius: 999px; background: #d9dde3; transition: background var(--dur) var(--ease); flex: 0 0 46px; }
.switch::after {
  content: ""; display: block; width: 21px; height: 21px; border-radius: 50%;
  background: #fff; transition: transform var(--dur) var(--ease); box-shadow: 0 2px 5px rgba(0,0,0,.12);
}
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(19px); }

/* File dropzone */
.dropzone {
  border: 2px dashed #d4d9e0; border-radius: 18px; background: #fafbfc;
  padding: 28px 18px; text-align: center; cursor: pointer;
  transition: border-color var(--dur), background var(--dur), transform var(--dur) var(--ease);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand); background: #f4f5ff; transform: scale(1.005); }
.dropzone .dz-icon { font-size: 30px; }
.dropzone p { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.dropzone strong { color: var(--brand); }

/* Action rows — on mobile these stick to the bottom above the nav */
.form-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.form-actions.end { justify-content: flex-end; }
.form-actions.between { justify-content: space-between; }

/* Segmented control */
.segmented { display: inline-flex; background: #eef1f4; border-radius: 999px; padding: 4px; gap: 2px; }
.segmented button {
  border: 0; background: none; border-radius: 999px; padding: 9px 18px;
  font-size: 13px; font-weight: 650; color: var(--muted);
  transition: all var(--dur) var(--ease);
}
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }

/* Range slider */
input[type="range"].slider { -webkit-appearance: none; width: 100%; height: 6px; border-radius: 999px; background: #e6e9ef; outline: none; }
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 6px solid var(--brand); box-shadow: 0 3px 8px rgba(79,89,245,.4); cursor: pointer;
}

/* ==========================================================================
   11. TABLES
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
/* Auto-injected by platform.js around any .table not already wrapped. */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 13px; min-width: 620px; }
.table th {
  text-align: left; color: var(--muted); font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; padding: 0 14px 2px; white-space: nowrap;
}
/* Rich tables: sticky header inside the scroll wrapper. */
.table thead th {
  position: sticky; top: 0; z-index: 5;
  background: #f5f6fb; padding-top: 10px;
  box-shadow: inset 0 -1px 0 var(--line);
}
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td { padding: 13px 14px; background: #fafaff; vertical-align: middle; }
.table tbody tr { transition: transform var(--dur) var(--ease); }
.table tbody tr:hover td { background: #f3f4ff; }
.table tbody tr:hover { transform: translateX(2px); }
.table td:first-child { border-radius: 14px 0 0 14px; font-weight: 650; }
.table td:last-child { border-radius: 0 14px 14px 0; }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Status pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: #eef1f4; color: #3c4048;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.is-active, .pill.is-paid, .pill.is-signed, .pill.is-accepted, .pill.is-approved, .pill.is-sent-ok { background: #dcf5e5; color: #157f3d; }
.pill.is-pending, .pill.is-draft, .pill.is-review { background: #fff4d1; color: #a07d00; }
.pill.is-overdue, .pill.is-failed, .pill.is-declined { background: #ffdee0; color: #d33a42; }
.pill.is-sent, .pill.is-viewed, .pill.is-info, .pill.is-onhold { background: #e2e5ff; color: #3f49d6; }
.pill.is-partial { background: #ffe9d6; color: #c05a10; }
.pill.solid { color: #fff; }
.pill.solid::before { background: #fff; }
.pill.solid.is-active, .pill.solid.is-paid { background: var(--green); }
.pill.solid.is-overdue { background: var(--red); }

/* Pulsing live dot */
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); display: inline-block; box-shadow: 0 0 0 4px #e4e5ff; animation: livePulse 1.4s infinite; }
@keyframes livePulse { 50% { box-shadow: 0 0 0 7px #e4e5ff; opacity: .6; } }

/* Avatars stack */
.avatar-group { display: flex; align-items: center; }
.avatar-group .avatar { margin-left: -10px; border-color: #fff; }
.avatar-group .avatar:first-child { margin-left: 0; }
.avatar-group .more {
  width: 34px; height: 34px; border-radius: 50%; margin-left: -10px;
  background: #eef1f4; border: 2px solid #fff; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: var(--muted);
}

/* ==========================================================================
   12. TABS / PROGRESS / TIMELINE / MISC
   ========================================================================== */
/* Pill tab bar (glass) — active tab gets the brand gradient.
   (Replaces the old underline .tabs, which had zero template usage.) */
.tabs {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px;
  border-radius: 999px; max-width: 100%; overflow-x: auto;
  margin: 0 0 18px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}
.tab {
  border: 0; background: none; border-radius: 999px; padding: 10px 18px;
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.tab.active { background: var(--grad-brand); color: #fff; box-shadow: var(--glow-brand-soft); }

.progress { height: 10px; background: #edf0f4; border-radius: 999px; overflow: hidden; }
.progress > i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  width: 0; transition: width 1s var(--ease);
}
.progress.green > i { background: linear-gradient(90deg, #22bf67, #5fe39a); }
.progress.orange > i { background: linear-gradient(90deg, #ff6728, #ffab5e); }

.timeline { display: grid; gap: 0; position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline-item { position: relative; padding: 0 0 20px; }
.timeline-item:last-child { padding-bottom: 2px; }
.timeline-item::before {
  content: ""; position: absolute; left: -24px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.timeline-item.done::before { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 4px #dcf5e5; }
.timeline-item p { margin: 2px 0 0; font-size: 13px; }
.timeline-item time { font-size: 11.5px; color: var(--muted); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .big, .empty-state .es-icon { font-size: 44px; margin-bottom: 10px; animation: floaty 3s ease-in-out infinite; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.callout {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius-sm);
  background: #f4f5ff; border: 1px solid #e2e5ff; font-size: 13px; line-height: 1.55;
}
.callout.warn { background: #fff8e6; border-color: #f5e3ae; }
.callout.ok { background: #eefaf3; border-color: #bfe9d2; }
.callout .ci { font-size: 18px; flex: 0 0 auto; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: right; }

/* CSS bar chart — bars animate from --h on load via platform.js */
.chart-wrap { height: 220px; position: relative; }
.bar-chart { height: 100%; display: grid; grid-template-columns: repeat(8, 1fr); gap: 14px; align-items: end; padding: 6px 2px 24px; }
.bar-group { height: 100%; display: flex; justify-content: center; align-items: flex-end; gap: 4px; position: relative; }
.bar {
  width: 26px; border-radius: 12px 12px 6px 6px; min-height: 10px;
  background: repeating-linear-gradient(135deg, #eaf0f2 0 5px, #f7f9fa 5px 9px);
  height: 0; transition: height 1s var(--ease);
}
.bar.highlight { background: linear-gradient(180deg, var(--brand-2), var(--brand)); box-shadow: 0 6px 16px rgba(79,89,245,.35); }
.bar.green { background: linear-gradient(180deg, #3ddc84, #22bf67); }
.bar.orange { background: linear-gradient(180deg, #ffab5e, #ff6728); }
.bar-label { position: absolute; bottom: -20px; font-size: 10.5px; color: #16181e; font-weight: 600; }

/* Skeleton shimmer */
.skeleton {
  border-radius: 10px; background: linear-gradient(90deg, #edf0f4 25%, #f7f9fb 50%, #edf0f4 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   13. RICH TEXT EDITOR  (progressive: data-rte="basic|advanced")
   Any <textarea data-rte> is upgraded by platform.js. Basic = formatting +
   lists + links. Advanced (contracts/proposals) adds headings, alignment,
   colors, quotes, tables, horizontal rules.
   ========================================================================== */
.rte { border: 1.5px solid #e1e6eb; border-radius: 6px; background: #fff; overflow: hidden; transition: border-color var(--dur), box-shadow var(--dur); }
.rte:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 8px 10px; background: #f7f8fb; border-bottom: 1px solid var(--line);
}
.rte-toolbar .tb-btn {
  border: 0; background: none; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 9px; font-size: 14px; color: #3c4048;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: background var(--dur), color var(--dur), transform var(--dur);
}
.rte-toolbar .tb-btn:hover { background: #e9ebff; color: var(--brand); }
.rte-toolbar .tb-btn:active { transform: scale(.9); }
.rte-toolbar .tb-btn.on { background: var(--brand); color: #fff; }
.rte-toolbar .tb-btn b { font-weight: 800; }
.rte-toolbar .tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.rte-toolbar .tb-select { border: 0; background: #fff; border-radius: 8px; padding: 6px 8px; font-size: 12px; font-weight: 650; color: #3c4048; cursor: pointer; }
.rte-content {
  min-height: 140px; max-height: 480px; overflow-y: auto;
  padding: 14px 16px; font-size: 14px; line-height: 1.65; outline: none;
}
.rte-advanced .rte-content { min-height: 320px; }
.rte-content:empty::before { content: attr(data-placeholder); color: #a6abb4; pointer-events: none; }
.rte-content h1, .rte-content h2, .rte-content h3 { margin: .7em 0 .35em; letter-spacing: -.02em; }
.rte-content h1 { font-size: 1.7em; } .rte-content h2 { font-size: 1.4em; } .rte-content h3 { font-size: 1.15em; }
.rte-content blockquote { margin: 10px 0; padding: 8px 14px; border-left: 4px solid var(--brand); background: #f4f5ff; border-radius: 0 10px 10px 0; color: #3c4048; }
.rte-content table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.rte-content table td, .rte-content table th { border: 1px solid #dfe3ea; padding: 8px 10px; }
.rte-content table th { background: #f4f5ff; text-align: left; }
.rte-content hr { border: 0; border-top: 2px solid var(--line); margin: 14px 0; }
.rte-foot { display: flex; justify-content: space-between; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); background: #fafbfc; }

/* ==========================================================================
   14. SIGNATURE PAD
   ========================================================================== */
.sig-wrap { border: 1.5px solid #e1e6eb; border-radius: 18px; background: #fff; overflow: hidden; }
.sig-tabs { display: flex; gap: 4px; padding: 8px; background: #f7f8fb; border-bottom: 1px solid var(--line); }
.sig-tabs button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 9px; font-size: 13px; font-weight: 700; color: var(--muted); transition: all var(--dur); }
.sig-tabs button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.sig-pad { position: relative; height: 190px; background:
  linear-gradient(#fff, #fff),
  repeating-linear-gradient(0deg, transparent 0 31px, #f0f2f6 31px 32px);
}
.sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.sig-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #b9bec7; font-size: 14px; pointer-events: none;
}
.sig-type { padding: 26px 18px; display: none; }
.sig-type input {
  width: 100%; border: 0; border-bottom: 2px solid var(--line); outline: none;
  font-size: 34px; text-align: center; padding: 8px;
  font-family: "Segoe Script", "Brush Script MT", cursive; color: #2b3a67;
  transition: border-color var(--dur);
}
.sig-type input:focus { border-color: var(--brand); }
.sig-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sig-preview { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #f6fff9; border: 1.5px dashed #bfe9d2; border-radius: 18px; }
.sig-preview img { max-height: 64px; background: #fff; border-radius: 8px; padding: 4px 10px; }
.sig-stamp { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 30px; color: #2b3a67; }

/* ==========================================================================
   15. MODAL
   ========================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(24, 26, 34, .5); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: min(560px, 100%); max-height: calc(100vh - 60px); overflow-y: auto;
  background: #fff; border-radius: 26px; padding: 26px;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px) scale(.97); transition: transform .3s var(--ease);
}
.modal-overlay.open .modal-card { transform: none; animation: modalPop .32s var(--ease); }
@keyframes modalPop { 0% { transform: scale(.94) translateY(10px); } 60% { transform: scale(1.015); } 100% { transform: none; } }
.modal-card.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-head p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.modal-x { border: 0; background: #f1f3f6; width: 34px; height: 34px; border-radius: 50%; font-size: 15px; flex: 0 0 34px; transition: all var(--dur); }
.modal-x:hover { background: #e4e8ee; transform: rotate(90deg); }

/* ==========================================================================
   16. TOASTS — stacked popup notifications (platform.js)
   ========================================================================== */
.toast-wrap {
  position: fixed; right: 24px; bottom: 24px; z-index: 400;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  pointer-events: none; max-width: calc(100vw - 48px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 11px;
  background: #202023; color: #fff; font-size: 13.5px; line-height: 1.45;
  padding: 14px 16px; border-radius: 16px; min-width: 260px; max-width: 380px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .3);
  transform: translateX(120%); opacity: 0;
  transition: transform .38s var(--ease), opacity .3s;
  position: relative; overflow: hidden;
}
.toast.show { transform: none; opacity: 1; }
.toast.hide { transform: translateX(30%); opacity: 0; }
.toast .t-icon {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center; font-size: 15px; font-weight: 800;
}
.toast.success .t-icon { background: rgba(34, 191, 103, .22); color: #5fe39a; }
.toast.error   .t-icon { background: rgba(255, 92, 100, .22); color: #ff8f96; }
.toast.info    .t-icon { background: rgba(79, 89, 245, .25);  color: #a9afff; }
.toast.warning .t-icon { background: rgba(241, 197, 27, .22); color: #ffd94d; }
.toast .t-close { border: 0; background: none; color: #9a9ca5; font-size: 15px; margin-left: 4px; }
.toast .t-close:hover { color: #fff; }
.toast .t-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: tBar 4s linear forwards; }
.toast.success .t-bar { background: var(--green); } .toast.error .t-bar { background: var(--red); }
.toast.info .t-bar { background: var(--brand-2); } .toast.warning .t-bar { background: var(--yellow); }
@keyframes tBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ==========================================================================
   17. DOCUMENT STYLES — proposals, contracts, invoices (print-ready)
   ========================================================================== */
.doc {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: clamp(24px, 4vw, 56px); max-width: 820px; margin: 0 auto;
  font-size: 14.5px; line-height: 1.75; color: #23262d;
}
.doc h1 { font-size: 30px; margin: 0 0 4px; }
.doc h2 { font-size: 20px; margin: 28px 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.doc h3 { font-size: 16px; margin: 20px 0 6px; }
.doc p { margin: 8px 0; }
.doc ul, .doc ol { margin: 8px 0; padding-left: 22px; }
.doc li { margin: 4px 0; }
.doc blockquote { margin: 12px 0; padding: 10px 16px; border-left: 4px solid var(--brand); background: #f6f7ff; border-radius: 0 12px 12px 0; }
.doc table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13.5px; }
.doc table th, .doc table td { border: 1px solid #e3e7ee; padding: 10px 12px; text-align: left; }
.doc table th { background: #f4f6fa; }
.doc .doc-cover { text-align: center; padding: 30px 0 10px; }
.doc .doc-meta { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 18px 0; font-size: 13px; color: var(--muted); }
.doc .doc-meta strong { color: var(--text); }
.doc .sig-block { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 34px; }
.doc .sig-line { border-top: 1.5px solid #23262d; padding-top: 8px; font-size: 12.5px; color: var(--muted); min-height: 110px; }
.doc .sig-line .sig-stamp { min-height: 56px; display: flex; align-items: flex-end; }
.doc .watermark {
  display: inline-block; padding: 6px 16px; border-radius: 999px; font-size: 12px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase;
}
.watermark.signed { background: #dcf5e5; color: #157f3d; }
.watermark.pending { background: #fff4d1; color: #a07d00; }
.watermark.draft { background: #eef1f4; color: #5b606b; }

.invoice-totals { margin-left: auto; width: min(320px, 100%); font-size: 13.5px; }
.invoice-totals .row-between { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.invoice-totals .grand { font-size: 18px; font-weight: 800; border-bottom: 0; padding-top: 10px; }
.stamp-paid {
  display: inline-block; border: 3px solid var(--green); color: var(--green);
  font-weight: 900; letter-spacing: .18em; text-transform: uppercase; font-size: 15px;
  padding: 8px 22px; border-radius: 12px; transform: rotate(-8deg); opacity: .9;
}

/* ==========================================================================
   18. MESSAGES + CHECKLISTS + FILES
   ========================================================================== */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; max-width: 82%; }
.msg .bubble { padding: 12px 16px; border-radius: 18px; font-size: 13.5px; line-height: 1.55; }
.msg.them { align-self: flex-start; }
.msg.them .bubble { background: #f1f3f6; border-radius: 18px 18px 18px 6px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bubble { background: linear-gradient(135deg, var(--brand), #6a5cff); color: #fff; border-radius: 18px 18px 6px 18px; }
.msg time { display: block; font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.msg.me time { text-align: right; color: rgba(255,255,255,.75); }

.checklist { display: grid; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: #fafaff; border-radius: var(--radius-sm); font-size: 13.5px;
  transition: background var(--dur), transform var(--dur) var(--ease);
}
.check-item:hover { background: #f3f4ff; transform: translateX(2px); }
.check-item.done span.task { text-decoration: line-through; color: var(--muted); }
.check-item .task-due { margin-left: auto; font-size: 11px; color: var(--muted); flex: 0 0 auto; }

.file-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: var(--radius-sm); transition: background var(--dur);
}
.file-row:hover { background: #f7f8fb; }
.file-row .f-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; background: #eef0ff; color: var(--brand); flex: 0 0 40px; }
.file-row strong { display: block; font-size: 13px; }
.file-row small { color: var(--muted); font-size: 11px; }

/* Stepper (multi-step wizards) */
.stepper { display: flex; gap: 6px; margin-bottom: 22px; }
.stepper .step { flex: 1; text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); position: relative; padding-top: 22px; }
.stepper .step::before {
  content: attr(data-n); position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%; background: #eef1f4; color: var(--muted);
  display: grid; place-items: center; font-size: 12px; transition: all var(--dur);
}
.stepper .step::after { content: ""; position: absolute; top: 12px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 2px; background: var(--line); }
.stepper .step:first-child::after { display: none; }
.stepper .step.done { color: var(--green); }
.stepper .step.done::before { content: "✓"; background: var(--green); color: #fff; }
.stepper .step.done::after { background: var(--green); }
.stepper .step.now { color: var(--brand); }
.stepper .step.now::before { background: var(--brand); color: #fff; box-shadow: 0 0 0 5px var(--brand-soft); }

/* ==========================================================================
   19. MOBILE ACTION BAR — form buttons stick to the bottom on mobile
   Add class "sticky-mobile" to any .form-actions row. On desktop it is a
   normal row; on mobile it pins above the bottom nav with a blur backdrop.
   ========================================================================== */
@media (max-width: 760px) {
  .form-actions.sticky-mobile {
    position: sticky; bottom: calc(var(--mobile-nav) + 10px); z-index: 90;
    background: rgba(255, 255, 255, .88); backdrop-filter: blur(14px);
    border: 1px solid var(--line); border-radius: 20px;
    padding: 10px; margin: 18px -2px 0;
    box-shadow: 0 12px 34px rgba(35, 43, 61, .16);
  }
  .form-actions.sticky-mobile .btn,
  .form-actions.sticky-mobile .primary,
  .form-actions.sticky-mobile .secondary,
  .form-actions.sticky-mobile .danger { flex: 1; padding: 14px 10px; }
}

/* ==========================================================================
   20. MOBILE BOTTOM NAV
   ========================================================================== */
.mobile-nav {
  display: none; position: fixed; left: 12px; right: 12px; bottom: 10px;
  height: var(--mobile-nav); border-radius: 25px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 16px 40px rgba(35, 42, 61, .2);
  backdrop-filter: blur(18px); z-index: 100;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
}
.mobile-nav a, .mobile-nav button {
  border: 0; background: transparent; color: #8b9098; border-radius: 17px;
  display: grid; place-items: center; gap: 2px; font-size: 9.5px; font-weight: 600;
  transition: all var(--dur) var(--ease);
}
.mobile-nav a.active, .mobile-nav button.active { color: var(--brand); background: #eff0ff; font-weight: 800; }
.mobile-nav .mn-icon { font-size: 20px; line-height: 1; }

/* ==========================================================================
   21. RESPONSIVE
   ========================================================================== */
@media (max-width: 1100px) {
  :root { --shell-width: 216px; }
  .stats-grid, .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .two-col.rev { grid-template-columns: 1fr; }
  .tool-grid, .three-col { grid-template-columns: repeat(2, 1fr); }
  .form-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  body { background: var(--bg); }
  .app-shell {
    width: 100%; min-height: 100vh; margin: 0; border-radius: 0;
    display: block; box-shadow: none; animation: none;
  }
  .sidebar { display: none; }
  .main { padding: 12px 13px calc(var(--mobile-nav) + 28px); }
  .topbar { min-height: 66px; gap: 10px; }
  .profile strong { font-size: 13.5px; }
  .profile small { display: none; }
  .avatar { width: 42px; height: 42px; flex-basis: 42px; }
  .search { width: 44px; height: 44px; padding: 0; font-size: 0; background-position: center; }
  .search:focus { width: 150px; font-size: 14px; padding: 0 14px 0 40px; background-position: 12px center; }
  .search-popup { position: fixed; top: 70px; left: 12px; right: 12px; width: auto; }
  .icon-btn { width: 44px; height: 44px; }
  .popup { position: fixed; top: 70px; right: 12px; width: calc(100vw - 24px); }
  .stats-grid { gap: 10px; }
  .stat-card { min-height: 128px; padding: 15px 13px; border-radius: 19px; }
  .stat-number { font-size: 21px; margin-top: 16px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric-card { min-height: 124px; border-radius: 19px; padding: 15px 13px; }
  .metric-value { font-size: 20px; margin-top: 16px; }
  .panel { padding: 16px 14px; border-radius: 20px; }
  .tool-grid, .three-col { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .doc { padding: 22px 18px; border-radius: 18px; }
  .doc .sig-block { grid-template-columns: 1fr; }
  .mobile-nav { display: grid; }
  .toast-wrap { right: 12px; left: 12px; bottom: calc(var(--mobile-nav) + 14px); align-items: stretch; }
  .toast { max-width: none; }
  .modal-card { padding: 20px 16px; border-radius: 22px; }
  .chart-wrap { height: 190px; }
  .bar { width: 18px; }
  .bar-chart { gap: 6px; }
  .msg { max-width: 92%; }
  .invoice-totals { width: 100%; }
}

@media (max-width: 420px) {
  .stat-number { font-size: 19px; }
  .page-heading h1 { font-size: 24px; }
  .form-actions .btn { flex: 1; }
}

/* ==========================================================================
   22. PRINT — clean documents for invoices / contracts / proposals
   ========================================================================== */
@media print {
  body { background: #fff; }
  .app-shell { display: block; width: 100%; margin: 0; box-shadow: none; border-radius: 0; }
  .sidebar, .topbar, .mobile-nav, .toast-wrap, .form-actions,
  .no-print, .popup, .modal-overlay { display: none !important; }
  .main { padding: 0; }
  .doc { box-shadow: none; border-radius: 0; max-width: none; }
  .reveal { opacity: 1; transform: none; }
  a { text-decoration: none; }
}

/* ==========================================================================
   23. RICH TABLES — filter / sort / pagination chrome
   (behavior lives in platform.js; applied to every table.table,
   opt out per table with data-table-plain)
   ========================================================================== */
.dt-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.dt-info { font-size: 12px; color: var(--muted); font-weight: 600; }
.dt-filter input {
  width: 220px; height: 42px; border: 1.5px solid #e1e6eb; border-radius: 999px;
  padding: 0 16px 0 42px; font-size: 13px; outline: none; background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' viewBox='0 0 24 24' fill='none' stroke='%237c818a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), width var(--dur) var(--ease);
}
.dt-filter input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); width: 260px;
}
.dt-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dt-pagesize { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.dt-pagesize select {
  height: 34px; border: 1.5px solid #e1e6eb; border-radius: 10px; background: #fff;
  font-size: 12.5px; font-weight: 600; color: var(--text); padding: 0 8px; outline: none; cursor: pointer;
}
.dt-pagesize select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.dt-export {
  height: 34px; padding: 0 14px; border: 1.5px solid #e1e6eb; border-radius: 10px;
  background: #fff; font-size: 12.5px; font-weight: 700; color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dt-export:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.dt-export:active { transform: scale(.96); }

/* ==========================================================================
   24. SALES BANNER — full-width client dashboard carousel
   (markup in client/dashboard.twig; rotation in platform.js)
   ========================================================================== */
.sales-banner {
  position: relative; margin: 0 0 22px; border-radius: 18px; overflow: hidden;
  box-shadow: 0 18px 44px -18px rgba(31, 38, 66, .35);
  background: linear-gradient(120deg, #eef1ff, #f7f4ff);
}
.sb-track { position: relative; aspect-ratio: 21 / 7; min-height: 180px; }
.sb-slide {
  position: absolute; inset: 0; opacity: 0; transform: scale(1.015);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  pointer-events: none;
}
.sb-slide.is-active { opacity: 1; transform: none; pointer-events: auto; }
.sb-slide img, .sb-slide a { display: block; width: 100%; height: 100%; }
.sb-slide img { object-fit: cover; }
.sb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: #20233a; font-size: 24px; line-height: 1;
  display: grid; place-items: center; opacity: 0;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  box-shadow: 0 8px 20px rgba(20, 24, 48, .25);
}
.sales-banner:hover .sb-arrow, .sales-banner:focus-within .sb-arrow { opacity: 1; }
.sb-arrow:hover { transform: translateY(-50%) scale(1.08); }
.sb-prev { left: 14px; } .sb-next { right: 14px; }
.sb-dots {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(20, 24, 48, .28); backdrop-filter: blur(6px);
}
.sb-dot {
  width: 9px; height: 9px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .55); padding: 0;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.sb-dot.is-active { background: #fff; transform: scale(1.25); }
@media (max-width: 640px) {
  .sb-track { aspect-ratio: 16 / 9; min-height: 150px; }
  .sb-arrow { opacity: 1; width: 36px; height: 36px; }
}

/* Settings — sales banner slot previews */
.banner-slot .banner-preview img {
  width: 100%; max-height: 220px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--line); display: block; margin-bottom: 14px;
}
.banner-empty {
  border: 1.5px dashed #d5dae3; border-radius: 12px; padding: 26px;
  text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px;
  background: #fafbfd;
}
.banner-slot .form-row { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.danger-text { color: var(--red); }
table.table th.sortable {
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
table.table th.sortable:hover { color: var(--brand); }
table.table th.sortable::after {
  content: " ⇅"; color: #c3c8d1; font-size: 10px;
}
table.table th.sorted-asc::after { content: " ▲"; color: var(--brand); }
table.table th.sorted-desc::after { content: " ▼"; color: var(--brand); }
table.table th.sorted-asc,
table.table th.sorted-desc { color: var(--brand); }

.dt-pages {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  margin-top: 14px; flex-wrap: wrap;
}
.dt-pages button {
  min-width: 38px; height: 38px; padding: 0 10px;
  border: 1.5px solid var(--line); background: #fff; border-radius: 12px;
  font-size: 13px; font-weight: 700; color: #3c4048;
  transition: all var(--dur) var(--ease);
}
.dt-pages button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.dt-pages button:active:not(:disabled) { transform: scale(.93); }
.dt-pages button.active { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 6px 14px rgba(79, 89, 245, .35); }
.dt-pages button:disabled { opacity: .35; cursor: default; }

/* ==========================================================================
   24. PREMIUM MOBILE APP FEEL
   - Bottom-sheet modals, instant tap response, snappier motion on touch,
     press states on interactive elements.
   ========================================================================== */
html { -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, .nav-item { touch-action: manipulation; }

@media (pointer: coarse) {
  :root { --dur: .16s; } /* snappier on touch devices */
  .btn:active, .icon-btn:active { transform: scale(.94); }
  .nav-item:active { transform: scale(.97); }
  .tool-card:active, .stat-card:active { transform: scale(.98); }
}

@media (max-width: 760px) {
  /* Modals become bottom sheets — the native app pattern */
  .modal-overlay { place-items: end center; padding: 0; }
  .modal-card {
    width: 100%; max-width: 100%;
    border-radius: 26px 26px 0 0;
    max-height: 88vh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .modal-overlay.open .modal-card { animation: sheetUp .34s var(--ease); }
  @keyframes sheetUp {
    from { transform: translateY(80px); opacity: .5; }
    to   { transform: none; opacity: 1; }
  }

  /* Advanced table chrome compacts */
  .dt-filter input { width: 150px; }
  .dt-filter input:focus { width: 170px; }
  .dt-controls { margin-bottom: 8px; }

  /* Headings stack their actions full-width for thumbs */
  .page-heading .row-between { flex-direction: column; align-items: stretch; }
  .page-heading .row-between .btn { width: 100%; }

  /* Toasts already dock above the nav; keep them thumb-reachable */
  .toast { font-size: 13px; }
}

/* ==========================================================================
   25. CLIENT CHAT WIDGET — iOS-style floating chat
   ========================================================================== */
.chat-fab {
  position: fixed; right: 22px; bottom: 26px; z-index: 1200;
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #4f59f5, #7a5af8); color: #fff; font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(79, 89, 245, .45);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chat-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 16px 36px rgba(79, 89, 245, .55); }
.chat-fab:active { transform: scale(.92); }
.chat-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px;
  background: #ff3b30; color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid #fff; animation: pop .3s var(--ease);
}

.chat-panel {
  position: fixed; right: 22px; bottom: 98px; z-index: 1200;
  width: min(378px, calc(100vw - 28px)); height: min(560px, calc(100dvh - 220px));
  min-height: 380px; background: #f2f2f7; border-radius: 24px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(20, 22, 40, .35);
  opacity: 0; transform: translateY(24px) scale(.96); pointer-events: none;
  transition: opacity .28s var(--ease), transform .28s var(--ease);
}
.chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid #e5e5ea;
}
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #4f59f5, #7a5af8); color: #fff;
  font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.chat-head strong { display: block; font-size: 14px; }
.chat-status { font-size: 11.5px; color: #34c759; display: flex; align-items: center; gap: 5px; }
.chat-status i { width: 7px; height: 7px; border-radius: 50%; background: #34c759; display: inline-block; }
.chat-close { margin-left: auto; border: none; background: #e9e9ee; width: 30px; height: 30px; border-radius: 50%; color: #666; cursor: pointer; font-size: 13px; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.chat-row { display: flex; flex-direction: column; max-width: 78%; margin-bottom: 8px; }
.chat-row.me { align-self: flex-end; align-items: flex-end; }
.chat-row.them { align-self: flex-start; align-items: flex-start; }
.chat-row .bubble {
  padding: 9px 13px; font-size: 14.5px; line-height: 1.4; word-wrap: break-word;
  border-radius: 20px;
}
.chat-row.me .bubble { background: #007aff; color: #fff; border-bottom-right-radius: 6px; }
.chat-row.them .bubble { background: #e9e9eb; color: #111; border-bottom-left-radius: 6px; }
.chat-time { font-size: 10px; color: #aeaeb2; margin-top: 3px; padding: 0 6px; }
.chat-typing { display: flex; gap: 5px; padding: 4px 16px 10px; }
.chat-typing[hidden] { display: none; }
.chat-typing span { width: 8px; height: 8px; border-radius: 50%; background: #c7c7cc; animation: tblink 1.1s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes tblink { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-input {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid #e5e5ea;
}
.chat-input input {
  flex: 1; height: 40px; border: 1px solid #d1d1d6; border-radius: 999px;
  padding: 0 16px; font-size: 14.5px; outline: none; background: #fff; min-width: 0;
}
.chat-input input:focus { border-color: #007aff; box-shadow: 0 0 0 3px rgba(0, 122, 255, .15); }
.chat-plus {
  width: 36px; height: 36px; flex: none; border-radius: 50%; border: none;
  background: #e9e9ee; color: #555; font-size: 20px; cursor: pointer; line-height: 1;
}
.chat-send {
  width: 38px; height: 38px; flex: none; border-radius: 50%; border: none; cursor: pointer;
  background: #007aff; color: #fff; font-size: 18px; font-weight: 800;
  transition: transform var(--dur) var(--ease);
}
.chat-send:active { transform: scale(.88); }
.chat-demo-note { font-size: 10.5px; color: #aeaeb2; text-align: center; padding: 6px 10px 8px; background: #fff; }

/* ==========================================================================
   26. AI + VOICE SEARCH
   ========================================================================== */
.search-modes { display: flex; gap: 6px; margin-left: auto; }
.smode {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 6px 12px; cursor: pointer; color: #555;
  transition: all var(--dur) var(--ease);
}
.smode.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.mic-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: #eef0ff; font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease);
}
.mic-btn:hover { background: #e0e4ff; transform: translateY(-50%) scale(1.08); }
.mic-btn.listening { background: #ff3b30; animation: micpulse 1.2s infinite; }
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, .5); } 50% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); } }
.search-wrap { position: relative; }
.search-wrap .search { padding-right: 52px; }
.ai-panel { padding: 4px 2px; }
.ai-answer {
  background: linear-gradient(135deg, #f4f5ff, #faf5ff);
  border: 1.5px solid #e2e5ff; border-radius: 16px; padding: 14px 16px;
  font-size: 14px; line-height: 1.55; color: #2b2e36; min-height: 70px;
}
.ai-caret { display: inline-block; width: 2px; height: 15px; background: var(--brand); vertical-align: -2px; animation: caretblink .7s steps(1) infinite; }
@keyframes caretblink { 50% { opacity: 0; } }
.ai-link { margin-top: 10px; }
.ai-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ai-chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; cursor: pointer; color: #3c4048;
  transition: all var(--dur) var(--ease);
}
.ai-chip:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.ai-chip:active { transform: scale(.95); }

/* ==========================================================================
   27. MOBILE NAV — 6-column variant
   ========================================================================== */
.mobile-nav.cols-6 { grid-template-columns: repeat(6, 1fr); }
.mobile-nav.cols-6 .mnav-item { font-size: 9.5px; gap: 1px; }
.mobile-nav.cols-6 .mnav-icon { font-size: 19px; }

/* ==========================================================================
   27. MOBILE NAV — 6-column variant
   ========================================================================== */
.mobile-nav.cols-6 { grid-template-columns: repeat(6, 1fr); }
.mobile-nav.cols-6 .mnav-item { font-size: 9.5px; gap: 1px; }
.mobile-nav.cols-6 .mnav-icon { font-size: 19px; }

/* ==========================================================================
   27b. MOBILE NAV — "More" drawer (bottom sheet with the full navigation)
   Hidden on desktop; the drawer/backdrop only exist below 760px.
   ========================================================================== */
.mnav-backdrop, .mnav-drawer { display: none; }

@media (max-width: 760px) {
  /* Chat docks above the bottom nav, thumb-reachable */
  .chat-fab { right: 16px; bottom: 92px; width: 56px; height: 56px; }
  .chat-panel {
    right: 0; left: 0; bottom: 0; width: 100%;
    height: calc(100dvh - 76px); max-height: none; border-radius: 24px 24px 0 0;
  }
  .chat-panel.open { animation: sheetUp .32s var(--ease); }
  .popup.search-popup { width: calc(100vw - 32px); }
  .search-modes { margin-left: 0; }
  .popup-head { flex-wrap: wrap; gap: 8px; }

  /* ---- "More" bottom sheet ---- */
  .mnav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 140;
    background: rgba(13, 18, 32, .45);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .mnav-backdrop.open { opacity: 1; pointer-events: auto; }
  .mnav-drawer {
    display: block; position: fixed; left: 12px; right: 12px;
    bottom: calc(var(--mobile-nav) + 16px); z-index: 141;
    max-height: min(62vh, 480px); overflow-y: auto; -webkit-overflow-scrolling: touch;
    background: rgba(255, 255, 255, .97); border-radius: 22px;
    box-shadow: 0 24px 60px rgba(35, 42, 61, .28);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    padding: 6px 8px calc(10px + env(safe-area-inset-bottom));
    transform: translateY(14px); opacity: 0; pointer-events: none;
    transition: transform .24s var(--ease), opacity .2s ease;
  }
  .mnav-drawer.open { transform: none; opacity: 1; pointer-events: auto; }
  .mnav-drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px 4px;
  }
  .mnav-drawer-head strong { font-size: 15px; }
  .mnav-close {
    border: 0; background: #eef0f6; width: 32px; height: 32px;
    border-radius: 50%; font-size: 14px; color: #555a63; cursor: pointer;
  }
  .mnav-group {
    margin: 10px 12px 2px; font-size: 11px; text-transform: uppercase;
    letter-spacing: .06em; color: var(--muted, #6b7280);
  }
  .mnav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 14px;
    color: #23262b; font-weight: 600; font-size: 14px; text-decoration: none;
  }
  .mnav-link .mn-icon { font-size: 19px; width: 26px; text-align: center; flex: 0 0 auto; }
  .mnav-link.active { color: var(--brand); background: #eff0ff; }
  .mnav-link .nav-count { margin-left: auto; }
  body.mnav-open { overflow: hidden; }

  /* ---- Client portal: the desktop header nav wraps badly on phones; the
     bottom bar (client_mobile_nav) takes over navigation instead. ---- */
  .client-top .client-nav { display: none; }
  .client-body { padding-bottom: calc(var(--mobile-nav) + 28px); }
}

/* ==========================================================================
   28. VOICE INPUTS, AI GENERATOR PANELS, COMPARE / DIFF VIEWS
   ========================================================================== */
/* Voice input wrapper — mic docks at the far right of the field */
[data-voice-input] { position: relative; display: block; }
[data-voice-input] input,
[data-voice-input] textarea { padding-right: 54px !important; width: 100%; }
[data-voice-input] .mic-btn { right: 10px; }

/* AI generator panel */
.ai-gen-panel {
  border: 1.5px solid #e2e5ff; border-radius: 20px; padding: 18px;
  background: linear-gradient(135deg, #f7f8ff 0%, #fdf7ff 100%);
  position: relative; overflow: hidden;
}
.ai-gen-panel::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, #4f59f5, #9a6bff, #4f59f5);
}
.ai-gen-panel h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ai-gen-panel .row { display: flex; gap: 10px; margin-top: 10px; }
.ai-gen-panel .row .btn { flex: none; }
.ai-thinking { display: none; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ai-thinking.on { display: flex; }
.ai-thinking .dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); display: inline-block; margin-right: 4px; animation: tblink 1.1s infinite; }
.ai-thinking .dots span:nth-child(2) { animation-delay: .18s; }
.ai-thinking .dots span:nth-child(3) { animation-delay: .36s; }

/* Side-by-side compare (client change requests + admin review) */
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.compare-pane {
  background: #fff; border: 1.5px solid var(--line); border-radius: 18px;
  overflow: hidden;
}
.compare-pane .pane-head {
  padding: 12px 16px; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1.5px solid var(--line);
}
.compare-pane.orig .pane-head { background: #f6f7f9; color: #555; }
.compare-pane.mod .pane-head { background: #f2f4ff; color: var(--brand); }
.compare-pane .pane-body { padding: 16px; font-size: 14px; line-height: 1.7; }
.compare-pane .pane-body h4 { margin: 12px 0 6px; font-size: 14px; }
.compare-pane .pane-body h4:first-child { margin-top: 0; }
.diff-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 12px 0; }
.diff-view ins, .diff-legend ins {
  background: #d3f9dd; color: #0d6b2e; text-decoration: none;
  border-radius: 4px; padding: 1px 3px;
}
.diff-view del, .diff-legend del {
  background: #ffe1e1; color: #b42323; text-decoration: line-through;
  border-radius: 4px; padding: 1px 3px;
}
.cmp-tabs { display: none; gap: 8px; margin-bottom: 12px; }
.cmp-tabs .btn { flex: 1; }

/* Bottom signature block (client doc views) */
.sign-block {
  margin-top: 26px; border: 1.5px solid var(--line); border-radius: 20px;
  padding: 20px; background: linear-gradient(135deg, #f7f8ff, #fff);
}
.sign-block h3 { margin-bottom: 4px; }
.sign-block .sig-status { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0; }

@media (max-width: 860px) {
  .compare-grid { grid-template-columns: 1fr; }
  .compare-grid.tabbed .compare-pane { display: none; }
  .compare-grid.tabbed .compare-pane.show { display: block; }
  .cmp-tabs { display: flex; }
  .ai-gen-panel .row { flex-direction: column; }
  .ai-gen-panel .row .btn { width: 100%; }
}

/* ==========================================================================
   29. DESIGN SYSTEM UPGRADE (0A) — premium light glassmorphism
   --------------------------------------------------------------------------
   Evolutionary layer: every rule below is ADDITIVE. No existing class was
   removed or renamed; core definitions above are only *enhanced* (same
   selectors, richer values). Keyframes: riseIn, btnFlow, brandBreathe.
   New utilities for later workstreams: .glass, .glass-strong, .reveal-1..4,
   .reveal-auto(-1..4), .msg-bubble-in/.msg-bubble-out, .timeline-event,
   .avatar-circle(.sm/.lg), .dropdown(.open) + .dropdown-menu, .modal-glass,
   .tab-bar + .tab-badge, .kbd, .empty-state.dashed, .table.stack (opt-in
   mobile card tables), .table-sticky-head, .stack-mobile, .text-gradient.
   Bug fixes folded in: --ink and (in agent4.css) --border were referenced
   but never defined.
   ========================================================================== */

/* ---- 29a. Extended design tokens ---- */
:root {
  /* Glass surfaces */
  --glass-bg:          rgba(255, 255, 255, .62);
  --glass-bg-strong:   rgba(255, 255, 255, .86);
  --glass-border:      rgba(255, 255, 255, .65);
  --glass-edge:        rgba(16, 17, 22, .08);
  --glass-blur:        18px;
  --glass-sat:         1.4;
  --glass-shadow:      0 18px 50px rgba(35, 43, 61, .10);
  --glass-shadow-lg:   0 30px 70px rgba(35, 43, 61, .16);

  /* Page gradient wash (very light, premium) */
  --wash-1: #f5f2fe;   /* soft lavender */
  --wash-2: #eef4fe;   /* pale sky */
  --wash-3: #edfaf3;   /* mint whisper */

  /* Brand gradients */
  --grad-brand:        linear-gradient(135deg, #4f59f5 0%, #6a5cff 55%, #8a5cf6 100%);
  --grad-brand-anim:   linear-gradient(135deg, #4f59f5, #6a5cff, #8a5cf6, #4f59f5);
  --grad-sheen:        linear-gradient(100deg, transparent, rgba(255, 255, 255, .42), transparent);

  /* Glow shadows */
  --glow-brand:        0 10px 28px rgba(79, 89, 245, .38);
  --glow-brand-lg:     0 16px 38px rgba(79, 89, 245, .48);
  --glow-brand-soft:   0 6px 18px rgba(79, 89, 245, .20);

  /* Motion */
  --dur-slow: .55s;
  --dur-med:  .32s;
  --ease-spring: cubic-bezier(.34, 1.45, .64, 1);

  /* Previously referenced but undefined — now defined */
  --ink: #17181b;
}

/* ---- 29b. Premium page background ---- */
body {
  background:
    radial-gradient(1200px 620px at 6% -6%, rgba(122, 92, 255, .10), transparent 60%),
    radial-gradient(1000px 540px at 96% -2%, rgba(79, 89, 245, .09), transparent 60%),
    radial-gradient(940px 720px at 50% 112%, rgba(15, 181, 168, .09), transparent 60%),
    linear-gradient(160deg, var(--wash-1) 0%, var(--wash-2) 48%, var(--wash-3) 100%);
  background-attachment: fixed;
}

/* Allow sticky descendants (topbar) to work while keeping the shell's
   rounded clipping. `overflow: clip` degrades to `hidden` where unsupported. */
.app-shell { overflow: hidden; overflow: clip; }

/* ---- 29c. Glass utilities ---- */
.glass {
  background:
    linear-gradient(155deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .42) 60%, rgba(255, 255, 255, .58)),
    var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, .7);
}
.glass-strong {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-lg);
}

/* ---- 29d. Frosted cards + panels (existing classes, upgraded) ---- */
.card, .panel {
  background:
    linear-gradient(155deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .42) 60%, rgba(255, 255, 255, .58)),
    var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform var(--dur-med) var(--ease),
              box-shadow var(--dur-med) var(--ease),
              border-color var(--dur) var(--ease);
}
.card:hover, .panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow-lg);
  border-color: rgba(255, 255, 255, .85);
}

/* ---- 29e. Reveal stagger utilities (pair with existing .reveal/.in) ---- */
.reveal-1 { --d: 70ms; }
.reveal-2 { --d: 150ms; }
.reveal-3 { --d: 230ms; }
.reveal-4 { --d: 310ms; }

/* Pure-CSS reveal on load (no JS needed) */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
.reveal-auto   { animation: riseIn .6s var(--ease) both; }
.reveal-auto-1 { animation: riseIn .6s var(--ease) .08s both; }
.reveal-auto-2 { animation: riseIn .6s var(--ease) .16s both; }
.reveal-auto-3 { animation: riseIn .6s var(--ease) .24s both; }
.reveal-auto-4 { animation: riseIn .6s var(--ease) .32s both; }

/* ---- 29f. Premium buttons ---- */
.btn {
  transition: transform var(--dur-med) var(--ease), box-shadow var(--dur-med) var(--ease),
              background var(--dur-med) var(--ease), filter var(--dur), border-color var(--dur);
}
.btn-primary {
  background: var(--grad-brand-anim);
  background-size: 220% 220%;
  box-shadow: var(--glow-brand);
}
.btn-primary:hover {
  box-shadow: var(--glow-brand-lg);
  filter: brightness(1.04);
  animation: btnFlow 2.6s var(--ease) infinite;
}
@keyframes btnFlow {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}
.btn-secondary {
  background: rgba(238, 241, 244, .82);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-edge);
}
.btn-secondary:hover { background: rgba(227, 232, 238, .92); }
.btn-success:hover { box-shadow: 0 12px 28px rgba(34, 191, 103, .44); filter: brightness(1.05); }
.btn-danger:hover  { box-shadow: 0 12px 28px rgba(255, 92, 100, .44); filter: brightness(1.05); }
.btn-ghost:hover { background: #e2e6ff; box-shadow: var(--glow-brand-soft); }
.btn-outline {
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.btn-dark:hover { box-shadow: 0 12px 28px rgba(32, 32, 35, .35); }

/* Premium keyboard-focus ring */
.btn:focus-visible, .icon-btn:focus-visible,
.nav-item:focus-visible, .dt-pages button:focus-visible,
.ai-chip:focus-visible, .smode:focus-visible,
.segmented button:focus-visible, .tab-bar .tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(79, 89, 245, .55);
}

/* ---- 29g. Frosted form fields ---- */
.input, .textarea, .select-large {
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.input:focus, .textarea:focus, .select-large:focus {
  box-shadow: 0 0 0 4px var(--brand-soft), 0 4px 16px rgba(79, 89, 245, .12);
}
.select {
  background-color: rgba(243, 246, 247, .85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-edge);
}
.rte, .sig-wrap {
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* ---- 29h. Soft-gradient status pills ---- */
.pill {
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 6px rgba(35, 43, 61, .06);
  background: linear-gradient(135deg, #eef1f4, #e4e8ee);
}
.pill.is-active, .pill.is-paid, .pill.is-signed, .pill.is-accepted,
.pill.is-approved, .pill.is-sent-ok { background: linear-gradient(135deg, #ddf6e6, #c8eed6); }
.pill.is-pending, .pill.is-draft, .pill.is-review { background: linear-gradient(135deg, #fff5d3, #ffedb8); }
.pill.is-overdue, .pill.is-failed, .pill.is-declined { background: linear-gradient(135deg, #ffe0e2, #ffd0d4); }
.pill.is-sent, .pill.is-viewed, .pill.is-info, .pill.is-onhold { background: linear-gradient(135deg, #e4e7ff, #d3d8ff); }
.pill.is-partial { background: linear-gradient(135deg, #ffead7, #ffdfc2); }
.pill.solid.is-active, .pill.solid.is-paid { background: linear-gradient(135deg, #22bf67, #3ddc84); }
.pill.solid.is-overdue { background: linear-gradient(135deg, #ff5c64, #ff7a59); }

/* ---- 29i. Tables — softer, frosted rows ---- */
.table td { background: rgba(250, 250, 255, .78); }
.table tbody tr:hover td { background: rgba(240, 242, 255, .94); }
.table-wrap {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #c9cede transparent;
}
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: #c9cede; border-radius: 8px; }
/* Opt-in sticky header for tall tables */
.table-sticky-head thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--shell-bg); padding-top: 8px; padding-bottom: 10px;
}

/* ---- 29j. Sidebar — keep dark, add premium gradient + glow ---- */
.sidebar {
  background: linear-gradient(175deg, #242429 0%, #1b1b21 55%, #222633 100%);
}
.nav-item { border: 1px solid transparent; }
.nav-item:hover { border-color: rgba(255, 255, 255, .06); }
.nav-item.active {
  background: var(--grad-brand);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--glow-brand);
  border-color: rgba(255, 255, 255, .18);
}
.nav-item.active::before {
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, .9);
}
.nav-item.active .nav-count { background: rgba(255, 255, 255, .22); color: #fff; }
.nav-item.active .nav-icon { filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .25)); }
.upgrade {
  background: linear-gradient(145deg, #4f59f5, #7a5cff 60%, #9a5cf6);
  box-shadow: var(--glow-brand-soft);
  border: 1px solid rgba(255, 255, 255, .18);
}

/* ---- 29k. Topbar — frosted, sticky, floating pill ---- */
.topbar {
  position: sticky; top: 12px; z-index: 80;
  /* Opaque enough that page content scrolling underneath stays out of
     sight (was rgba .62 — stat cards showed through illegibly). */
  background: rgba(255, 255, 255, .88);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 10px 16px;
  box-shadow: var(--glass-shadow);
}
.search, .icon-btn {
  background: rgba(255, 255, 255, .82);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-edge);
}
.popup {
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-border);
}

/* ---- 29l. Chat bubbles (standalone, for messenger module) ---- */
.msg-bubble-in, .msg-bubble-out {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-wrap: break-word;
  width: fit-content;
}
.msg-bubble-in {
  align-self: flex-start;
  background: rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-edge);
  border-bottom-left-radius: 6px;
  color: var(--text);
}
.msg-bubble-out {
  align-self: flex-end;
  margin-left: auto;
  background: linear-gradient(135deg, var(--brand), #6a5cff);
  border-bottom-right-radius: 6px;
  color: #fff;
  box-shadow: var(--glow-brand-soft);
}

/* ---- 29m. Timeline alias (.timeline-event works like .timeline-item) ---- */
.timeline-item, .timeline-event { position: relative; padding: 0 0 20px; }
.timeline-item:last-child, .timeline-event:last-child { padding-bottom: 2px; }
.timeline-item::before, .timeline-event::before {
  content: ""; position: absolute; left: -24px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}
.timeline-item.done::before, .timeline-event.done::before {
  background: var(--green); border-color: var(--green); box-shadow: 0 0 0 4px #dcf5e5;
}
.timeline-item p, .timeline-event p { margin: 2px 0 0; font-size: 13px; }
.timeline-item time, .timeline-event time { font-size: 11.5px; color: var(--muted); }
.timeline-item .ev-title, .timeline-event .ev-title { font-weight: 700; font-size: 13.5px; }

/* ---- 29n. Avatar circle (gradient initials) ---- */
.avatar-circle {
  width: 40px; height: 40px; flex: 0 0 auto;
  border-radius: 50%; display: inline-grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--brand), var(--purple));
  border: 2px solid rgba(255, 255, 255, .7);
  box-shadow: 0 4px 12px rgba(79, 89, 245, .28);
  text-transform: uppercase; user-select: none;
}
.avatar-circle.sm { width: 30px; height: 30px; font-size: 11px; border-width: 1.5px; }
.avatar-circle.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-circle.g-green { background: linear-gradient(135deg, #22bf67, #7fe0a8); box-shadow: 0 4px 12px rgba(34, 191, 103, .28); }
.avatar-circle.g-orange { background: linear-gradient(135deg, #ff6728, #ffb03a); box-shadow: 0 4px 12px rgba(255, 103, 40, .28); }
.avatar-circle.g-teal { background: linear-gradient(135deg, #0fb5a8, #6fe3d4); box-shadow: 0 4px 12px rgba(15, 181, 168, .28); }
.avatar-circle.g-pink { background: linear-gradient(135deg, #e0497a, #ff9db8); box-shadow: 0 4px 12px rgba(224, 73, 122, .28); }

/* ---- 29o. Glass dropdown menu ---- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 150;
  min-width: 210px; padding: 8px; border-radius: 18px;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow-lg);
  opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.dropdown-menu.left { left: 0; right: auto; transform-origin: top left; }
.dropdown.open .dropdown-menu, .dropdown-menu.open {
  opacity: 1; transform: none; pointer-events: auto;
}
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: none; border-radius: 12px; padding: 10px 12px;
  font-size: 13.5px; font-weight: 600; color: var(--text); text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur);
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: rgba(79, 89, 245, .09); color: var(--brand); }
.dropdown-menu a.danger-item, .dropdown-menu button.danger-item { color: var(--red); }
.dropdown-menu a.danger-item:hover, .dropdown-menu button.danger-item:hover { background: rgba(255, 79, 87, .08); color: var(--red); }
.dropdown-menu .dd-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.dropdown-menu .dd-head {
  padding: 8px 12px 4px; font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
}

/* ---- 29p. Frosted modal variant + overlay polish ---- */
.modal-overlay {
  background: rgba(30, 32, 44, .42);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
}
.modal-glass {
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  backdrop-filter: blur(26px) saturate(1.5);
  border: 1px solid var(--glass-border);
}

/* ---- 29q. Tab bar (segmented premium tabs) with badge ---- */
.tab-bar {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px;
  border-radius: 999px; max-width: 100%; overflow-x: auto;
  background: rgba(255, 255, 255, .62);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-sm);
}
.tab-bar .tab {
  border: 0; background: none; border-radius: 999px; padding: 10px 18px;
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all var(--dur) var(--ease);
}
.tab-bar .tab:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.tab-bar .tab.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.tab-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--grad-brand); color: #fff; font-size: 10.5px; font-weight: 800;
  display: inline-grid; place-items: center; line-height: 1;
  box-shadow: var(--glow-brand-soft);
}
.tab-bar .tab:not(.active) .tab-badge { background: rgba(79, 89, 245, .14); color: var(--brand); box-shadow: none; }

/* ---- 29r. Misc new utilities ---- */
.kbd {
  display: inline-block; padding: 3px 8px; border-radius: 7px;
  background: linear-gradient(180deg, #fff, #eef1f5);
  border: 1px solid #dfe3ea; border-bottom-width: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px; font-weight: 700; color: #3c4048; white-space: nowrap;
}
.text-gradient {
  background: linear-gradient(115deg, #4f59f5 10%, #8a5cf6 55%, #0fb5a8 115%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.empty-state.dashed {
  border: 2px dashed #d4d9e0; border-radius: var(--radius);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.stack-mobile { /* no-op on desktop */ }

/* ---- 29s. Responsive additions (mobile-first, additive) ---- */
@media (max-width: 768px) {
  /* Generic stack helper: any .row/.row-between with .stack-mobile stacks */
  .row.stack-mobile, .row-between.stack-mobile { flex-direction: column; align-items: stretch; }
  .row.stack-mobile > .btn, .row-between.stack-mobile > .btn { width: 100%; }

  /* Grids collapse to one column */
  .stats-grid, .metrics-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 0; }
  .metric-card { min-height: 0; }

  /* Table wrapper: frosted, clear scroll affordance */
  .table-wrap {
    background: var(--glass-bg);
    border: 1px solid var(--glass-edge);
    border-radius: 16px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  /* Opt-in stacked-card tables: <table class="table stack"> + data-label on td */
  .table.stack, .table.stack thead, .table.stack tbody,
  .table.stack tr, .table.stack th, .table.stack td { display: block; width: 100%; }
  .table.stack { min-width: 0; border-spacing: 0; }
  .table.stack thead { display: none; }
  .table.stack tbody tr {
    background: var(--glass-bg-strong);
    border: 1px solid var(--glass-edge);
    border-radius: 16px;
    margin-bottom: 10px; padding: 6px 2px;
    box-shadow: var(--shadow-sm);
  }
  .table.stack tbody tr:hover { transform: none; }
  .table.stack td {
    background: none !important; border-radius: 0 !important;
    padding: 9px 16px; display: flex; justify-content: space-between;
    align-items: baseline; gap: 14px; text-align: right;
  }
  .table.stack td::before {
    content: attr(data-label);
    font-size: 10.5px; font-weight: 800; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted); text-align: left; flex: 0 0 auto;
  }
  .table.stack td:empty { display: none; }
  .table.stack .row-actions { justify-content: flex-end; }

  /* Topbar pill compacts on small screens */
  .topbar { top: 8px; padding: 8px 12px; border-radius: 20px; gap: 8px; }

  /* Chat bubbles breathe a little wider on phones */
  .msg-bubble-in, .msg-bubble-out { max-width: 88%; }

  /* Tab bar scrolls edge-to-edge */
  .tab-bar { max-width: calc(100vw - 26px); }
}

@media (max-width: 420px) {
  .dropdown-menu { min-width: 180px; }
}

/* ---- 29t. Print: flatten glass so documents stay clean ---- */
@media print {
  .glass, .glass-strong, .card, .panel,
  .msg-bubble-in, .dropdown-menu, .modal-glass, .empty-state.dashed {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: #fff !important;
    box-shadow: none !important;
  }
  body { background: #fff !important; }
  .topbar { position: static; box-shadow: none; }
  .nav-item.active { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- 29u. Phase 4H: rich composer toolbar + camera upload button ---- */
.rt-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 6px 8px;
  background: rgba(255,255,255,.6); border: 1px solid var(--glass-edge);
  border-radius: 12px;
}
.rt-btn {
  min-width: 34px; height: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13.5px; font-weight: 800; line-height: 1;
  color: var(--ink); background: rgba(255,255,255,.85);
  border: 1px solid var(--glass-edge); border-radius: 9px; cursor: pointer;
}
.rt-btn:hover { border-color: var(--brand); color: var(--brand); }
.rt-btn-bold { font-weight: 900; }
.rt-btn-italic { font-style: italic; }
.rt-hint { margin-left: auto; font-size: 11px; color: var(--muted); }
@media (max-width: 560px) { .rt-hint { display: none; } }

/* Camera capture: progressive enhancement — hidden on desktop pointers,
   shown on touch devices / narrow screens. Harmless where unsupported:
   the input simply degrades to the regular file picker. */
.camera-btn {
  display: none; align-items: center; gap: 6px;
  margin-top: 8px;
}
@media (pointer: coarse), (max-width: 760px) {
  .camera-btn { display: inline-flex; }
}

/* ---- 29v. Phase 4H: design compare ---- */
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compare-pane {
  border: 1px solid var(--glass-edge); border-radius: 14px; overflow: hidden;
  background: rgba(255,255,255,.7);
}
.compare-pane .cp-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--glass-edge);
  font-size: 13px;
}
.compare-pane .cp-body { padding: 10px; text-align: center; background:
  repeating-conic-gradient(#f4f5fb 0% 25%, #ffffff 0% 50%) 0 0 / 24px 24px; }
.compare-pane img, .compare-pane embed, .compare-pane iframe {
  max-width: 100%; height: auto; max-height: 60vh; border-radius: 8px;
}
.compare-pane embed, .compare-pane iframe { width: 100%; height: 60vh; }
.compare-slider-wrap { position: relative; overflow: hidden; border-radius: 8px; }
.compare-slider-wrap img.cmp-base { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.compare-slider-wrap img.cmp-after {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
.compare-slider-handle {
  position: absolute; top: 0; bottom: 0; width: 3px; background: var(--brand);
  box-shadow: 0 0 8px rgba(0,0,0,.35); pointer-events: none;
}
.compare-slider-handle::after {
  content: "◂ ▸"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 6px 10px; white-space: nowrap;
}
@media (max-width: 760px) { .compare-grid { grid-template-columns: 1fr; } }

/* ---- 4A. Project types + milestone gates ---- */
.stack { display: grid; gap: 10px; }

.milestone-row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .6);
}
.milestone-row.is-done { opacity: .75; }
.milestone-row.is-waiting { border-color: #f0c96a; background: linear-gradient(135deg, #fffdf4, #fff8e2); }

/* Milestone status pills (status enum values as classes). */
.pill.is-awaiting_client { background: linear-gradient(135deg, #fff5d3, #ffedb8); color: #a07d00; }
.pill.is-in_progress { background: linear-gradient(135deg, #e4e7ff, #d3d8ff); color: #3f49d6; }
.pill.is-complete { background: linear-gradient(135deg, #ddf6e6, #c8eed6); color: #157f3d; }
.pill.is-waiting { background: linear-gradient(135deg, #fff5d3, #ffedb8); color: #a07d00; }

/* Client milestone timeline 0 → 100. */
.tl-step { display: flex; gap: 14px; padding: 0 0 18px; position: relative; }
.tl-step::before {
  content: ""; position: absolute; left: 17px; top: 40px; bottom: 0;
  width: 2px; background: var(--line); border-radius: 2px;
}
.tl-step:last-child { padding-bottom: 2px; }
.tl-step:last-child::before { display: none; }
.tl-step.is-done::before { background: var(--green); }
.tl-dot {
  flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  background: linear-gradient(135deg, #eef1f4, #e4e8ee);
  border: 1px solid var(--line); color: var(--muted);
}
.tl-step.is-done .tl-dot { background: linear-gradient(135deg, #22bf67, #3ddc84); color: #fff; border-color: transparent; }
.tl-step.is-waiting .tl-dot { background: linear-gradient(135deg, #ffd76a, #ffb347); color: #6b4a00; border-color: transparent; }
.tl-step.is-gated { opacity: .55; }
.tl-body { min-width: 0; }

.panel.is-highlight {
  border: 1.5px solid #f0c96a;
  background: linear-gradient(135deg, rgba(255, 253, 244, .92), rgba(255, 248, 226, .92));
}

@media (max-width: 640px) {
  .milestone-row .row { flex-wrap: wrap; }
}

/* ==========================================================================
   30. DESIGN SYSTEM FIX (2026-09-24) — fonts, spacing, component classes
   Standardizes card padding, defines previously-undefined classes used by
   templates (.page-head), and adds the component primitives other agents
   depend on. Additive — existing selectors were changed only where noted.
   ========================================================================== */

/* ---- 30a. Standard card padding + radius ---- */
.card, .panel, .glass { padding: var(--sp-6); border-radius: 18px; }

/* ---- 30b. Page header (used by comms, errors, usage-billing, secret-notes, settings, users) ---- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin: 8px 0 18px;
}
.page-head .crumbs, .page-head .breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: 12.5px; color: var(--muted); margin: 0 0 6px;
}
.page-head .crumbs a, .page-head .breadcrumb a { color: var(--muted); font-weight: 600; }
.page-head .crumbs a:hover, .page-head .breadcrumb a:hover { color: var(--brand); }
.page-head .crumbs > *:not(:first-child)::before, .page-head .breadcrumb > *:not(:first-child)::before {
  content: "›"; margin-right: 6px; opacity: .55;
}
.page-head h1, .page-head .page-title {
  margin: 0; font-size: clamp(23px, 3vw, 30px); letter-spacing: -.8px;
}
.page-head > div > p, .page-head .page-sub {
  margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 640px;
}
.page-head .page-actions {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .page-actions .btn { flex: 1; justify-content: center; }
}

/* ---- 30c. Empty state — CTA button row (extends existing .empty-state) ---- */
.empty-state .es-actions {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 18px;
}

/* ---- 30d. Table scroll wrapper — never page-level horizontal scroll ---- */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent 100%);
}

/* ---- 30e. Settings layout — side nav + content ---- */
.settings-layout {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--sp-6); align-items: start;
}
.settings-sidenav {
  position: sticky; top: 16px; padding: var(--sp-4);
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  box-shadow: var(--glass-shadow);
}
.side-group {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted);
  margin: var(--sp-4) var(--sp-2) var(--sp-2);
}
.side-group:first-child { margin-top: 0; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.side-link:hover { color: var(--text); background: rgba(255, 255, 255, .55); }
.side-link.active {
  background: var(--grad-brand); color: #fff;
  box-shadow: var(--glow-brand-soft);
}
@media (max-width: 900px) {
  /* (settings-layout is flex; the sidenav collapse lives in settings.css) */
}

/* ---- 30f. Comms timeline pills ---- */
.badge-channel-sms, .badge-channel-email, .badge-inbound, .badge-outbound {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 800; letter-spacing: .02em; white-space: nowrap;
}
.badge-channel-sms  { background: rgba(79, 89, 245, .12); color: #4b53e8; }
.badge-channel-email { background: rgba(15, 181, 168, .14); color: #0a8a7f; }
.badge-inbound       { background: rgba(34, 191, 103, .14); color: #15803d; }
.badge-outbound      { background: rgba(122, 92, 255, .13); color: #6a3fd4; }

/* ---- 30g. Debug-sweep: previously unstyled components -------------------
   These classes were in use by templates but had no style definitions
   anywhere (found by automated template-vs-CSS audit, 2026-09-24). */

/* Definition-list detail blocks (invoice/contract/proposal/client/file/
   call/support detail panels). */
.detail-list { margin: 0; display: grid; }
.detail-list > div {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 18px; padding: 9px 2px; font-size: 13.5px;
  border-bottom: 1px dashed rgba(15,23,42,.09);
}
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted, #6b7280); font-weight: 600; flex: 0 0 auto; }
.detail-list dd { margin: 0; font-weight: 650; text-align: right; min-width: 0; }

/* Kanban boards (leads, project tasks). */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.kanban-col {
  background: rgba(255,255,255,.55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--glass-edge, rgba(15,23,42,.08));
  border-radius: 16px; padding: 12px; min-height: 140px;
  display: grid; gap: 10px; align-content: start;
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(35,43,61,.05));
}
.kanban-col > h3 { margin: 0; padding: 2px 4px 8px; font-size: 13px; font-weight: 750; letter-spacing: .02em; display: flex; align-items: center; justify-content: space-between; }
.kanban-col .count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; font-size: 12px; font-weight: 750;
  background: rgba(79,89,245,.1); color: var(--brand, #4f46e5);
}
.kanban-card {
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.08); border-radius: 12px; padding: 12px 13px;
  box-shadow: 0 2px 8px rgba(35,43,61,.05);
  transition: transform var(--dur, .18s) var(--ease, ease), box-shadow var(--dur, .18s) var(--ease, ease);
}
.kanban-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(35,43,61,.1); }
.kanban-card > strong { font-size: 13.5px; }
.kanban-add { border-style: dashed; background: transparent; }

/* Unread indicators (notifications inbox). */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d4d9e0; flex: 0 0 8px; }
.dot-unread { background: var(--brand, #4f46e5); box-shadow: 0 0 0 3px rgba(79,89,245,.18); }
tr.row-unread, .row-unread { background: rgba(79,89,245,.045); }

/* Card headers (error detail, secret notes, meter detail). */
.card-head { padding: 18px 22px 0; }
.card-head h3 { margin: 0; font-size: 15.5px; letter-spacing: -.01em; }
.card-head + .card-body { padding-top: 12px; }

/* Drag handles (provider drag-to-order tables). */
.drag-handle { cursor: grab; color: #b6bcc7; font-size: 15px; letter-spacing: 1px; user-select: none; white-space: nowrap; }
.drag-handle:active { cursor: grabbing; }
tr.dragging .drag-handle { color: var(--brand, #4f46e5); }

/* Alert variants (base .alert lives in agent4.css). */
.alert-danger { border: 1.5px solid #f3a8a8; background: rgba(254,242,242,.92); color: #991b1b; }
.alert-success { border: 1.5px solid #93d8a7; background: rgba(240,253,244,.92); color: #166534; }

/* Small select (kanban card stage pickers). */
.select-sm { padding: 7px 30px 7px 11px; font-size: 12.5px; border-radius: 9px; min-height: 0; width: auto; max-width: 100%; }

/* Back links (auth + misc flows). */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted, #6b7280); text-decoration: none; }
.back-link:hover { color: var(--brand, #4f46e5); }

/* ---- 30h. Debug-sweep batch 2 (2026-09-24) ------------------------------- */

/* Pill variants used across 9+ templates (base .pill in agent4.css). */
.pill-ok { background: #dcfce7; color: #15803d; }
.pill-warn { background: #fef3c7; color: #b45309; }

/* Stat cards container + labels (AI usage dashboard). */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted, #6b7280); margin-bottom: 6px; }

/* Document body (contract/proposal detail). */
.doc-body { font-size: 14.5px; line-height: 1.75; color: #23262d; }
.doc-body p { margin: 0 0 1em; }

/* Client vault lock screen + footnote. */
.lock-hero { text-align: center; padding: 34px 20px 10px; display: grid; gap: 10px; justify-items: center; }
.lock-glyph { font-size: 40px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(79,89,245,.25)); }
.lock-hero h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.lock-hero p { margin: 0; color: var(--muted, #6b7280); font-size: 13.5px; max-width: 380px; }
.footnote { font-size: 12px; color: var(--muted, #6b7280); text-align: center; margin: 18px 0 4px; }

/* Single-purpose utilities referenced by templates. */
.nowrap { white-space: nowrap; }

/* Inline single-action forms (webhook key rotation etc.). */
.form-inline { display: inline-flex; align-items: center; gap: 10px; }
.form-inline-fields { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   33. Project view polish (2026-09-25)
   Count badges on project tabs, deadline date badges, overdue kanban cards,
   and chat-style message bubbles. All mobile-safe.
   ========================================================================== */

/* Count badge inside .tab links (admin + client project views). */
.tab-badge {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: rgba(15, 23, 42, .09);
  font-size: 11px; font-weight: 800; line-height: 1;
}
.tab.active .tab-badge { background: rgba(255, 255, 255, .28); color: #fff; }

/* Calendar-style date badge used on deadline rows. */
.dl-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px;
  background: var(--sky); border: 1px solid rgba(15, 23, 42, .06);
}
.dl-date b { font-size: 17px; line-height: 1.1; letter-spacing: -.02em; }
.dl-date small { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dl-date.is-over { background: #ffe9e9; border-color: rgba(229, 72, 79, .25); }
.dl-date.is-over b { color: #d33; }
.dl-date.is-over small { color: #d33; }

/* Overdue task cards get a red edge. */
.kanban-card.is-overdue { border-left: 3px solid #e5484f; }

/* Chat-style message list (admin project messages tab). */
.chat-list { display: grid; gap: 12px; max-width: 780px; }
.msg { display: flex; }
.msg.in { justify-content: flex-start; }
.msg.out { justify-content: flex-end; }
.msg-bubble {
  max-width: min(100%, 540px); padding: 12px 14px; border-radius: 16px;
  background: #fff; border: 1px solid var(--glass-edge, rgba(15, 23, 42, .08));
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(35, 43, 61, .05));
  font-size: 13.5px; overflow-wrap: anywhere;
}
.msg.in .msg-bubble { border-top-left-radius: 6px; }
.msg.out .msg-bubble {
  border-top-right-radius: 6px;
  background: linear-gradient(135deg, #f5f3ff, #eef4ff);
}
.msg-bubble p { overflow-wrap: anywhere; }
.msg-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; font-size: 11px; color: var(--muted);
}

@media (max-width: 640px) {
  .msg-bubble { max-width: 100%; }
}

/* ============================
   Drive-style file manager
   ============================ */
.drive { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 16px; align-items: start; }
.drive-side { padding: 18px 16px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.drive-nav { display: flex; flex-direction: column; gap: 2px; margin: 14px 0 6px; }
.drive-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: 13.5px;
}
.drive-nav a span:first-child { width: 20px; text-align: center; }
.drive-nav a:hover { background: rgba(15, 23, 42, .05); }
.drive-nav a.active { background: var(--brand-soft); color: var(--brand); }
.drive-lib h4, .drive-storage h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 14px 0 6px;
}
.dtree { border-radius: 10px; }
.dtree summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; list-style: none;
}
.dtree summary::-webkit-details-marker { display: none; }
.dtree summary:hover { background: rgba(15, 23, 42, .05); }
.dtree summary::before { content: '▸'; color: var(--muted); font-size: 11px; }
.dtree[open] summary::before { content: '▾'; }
.dt-ic { width: 18px; text-align: center; }
.dt-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-kids { display: flex; flex-direction: column; margin: 2px 0 6px 26px; }
.dt-kids a {
  padding: 6px 10px; border-radius: 8px; font-size: 12.5px;
  color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dt-kids a:hover { background: rgba(15, 23, 42, .05); }
.dt-kids a.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.drive-storage .meter {
  height: 8px; border-radius: 999px; background: #eef1f4; overflow: hidden; margin: 6px 0;
}
.drive-storage .meter i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.drive-storage small { color: var(--muted); font-size: 12px; }

.drive-main { min-width: 0; }
.drive-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { font-size: 16px; font-weight: 700; margin-right: auto; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumb-sep { color: var(--muted); margin: 0 6px; font-weight: 400; }
.crumbs .current { color: var(--text); }
.drive-search { flex: 1 1 180px; max-width: 320px; }
.drive-sort { flex: 0 0 auto; }

.drive-sect { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 6px; }
.folder-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
  text-decoration: none; color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.folder-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, 0 8px 24px rgba(16, 24, 40, .08)); }
.folder-card .f-ic { font-size: 26px; }
.folder-card .f-tx { min-width: 0; }
.folder-card .f-tx strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-card .f-tx small { color: var(--muted); font-size: 12px; }

.files-center { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.file-card {
  position: relative; border-radius: 14px; padding: 18px 14px 14px;
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
  min-width: 0;
}
.file-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md, 0 8px 24px rgba(16, 24, 40, .08)); }
.file-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.file-kebab {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 16px; line-height: 1;
  cursor: pointer; opacity: 0; transition: opacity .15s;
}
.file-card:hover .file-kebab, .file-card:focus-within .file-kebab { opacity: 1; }
.file-kebab:hover { background: rgba(15, 23, 42, .07); color: var(--text); }
.f-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 4px; }
.f-thumb { font-size: 40px; text-align: center; margin: 6px 0 10px; }
.f-body { min-width: 0; }
.f-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-meta { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.f-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-flags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* list view: same markup, row presentation */
.files-center.view-list { grid-template-columns: 1fr; gap: 8px; }
.files-center.view-list .file-card { display: flex; align-items: center; gap: 14px; padding: 10px 14px; }
.files-center.view-list .f-thumb { font-size: 26px; margin: 0; }
.files-center.view-list .f-body { flex: 1; min-width: 0; }
.files-center.view-list .f-name { font-size: 13.5px; }
.files-center.view-list .f-meta, .files-center.view-list .f-sub { display: inline; margin: 0 8px 0 0; }
.files-center.view-list .f-flags { margin: 0 0 0 auto; }
.files-center.view-list .file-kebab { position: static; opacity: 1; margin-left: auto; }
.files-center.view-list .f-badges { position: static; }

/* preview drawer */
.file-drawer {
  position: fixed; top: 0; right: 0; z-index: 70;
  width: 380px; max-width: 94vw; height: 100dvh;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(16, 24, 40, .14);
  padding: 20px; overflow-y: auto;
  transform: translateX(105%); transition: transform .26s ease;
}
.file-drawer.open { transform: none; }
.pv-icon { font-size: 64px; text-align: center; margin: 24px 0 12px; }
.pv-meta { font-size: 13px; line-height: 1.7; color: var(--text); margin-bottom: 16px; }
.pv-meta .muted { color: var(--muted); }

/* context menu */
.ctx-menu {
  position: fixed; z-index: 90; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(16, 24, 40, .18);
  padding: 6px;
}
.ctx-menu button {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 8px;
  padding: 9px 12px; font-size: 13.5px; color: var(--text); cursor: pointer;
}
.ctx-menu button:hover { background: rgba(15, 23, 42, .06); }
.ctx-menu button.danger { color: var(--red); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

@media (max-width: 960px) {
  .drive { grid-template-columns: 1fr; }
  .drive-side { position: static; max-height: none; }
  .drive-nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .drive-nav a { white-space: nowrap; }
  .drive-lib { display: none; }
  .crumbs { flex-basis: 100%; }
  .drive-search { max-width: none; }
}

/* ================= TIME TRACKING (FUTURE.md #3) ================= */
.timer-card { border-left: 4px solid var(--brand); }
.timer-active {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.timer-elapsed {
  font-size: 40px; font-weight: 800; letter-spacing: 1px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.timer-form .btn-lg { margin-top: 4px; }
.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 8px;
  background: #f4f6ff; border: 1px dashed var(--line); border-radius: 12px;
}
.entry-check { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
@media (max-width: 640px) {
  .timer-elapsed { font-size: 32px; }
  .timer-active .btn-lg { width: 100%; }
  .bulk-bar .btn { width: 100%; }
}

/* ---- 30. AI Agents utilities (single-codebase shared) ---- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; font-family: inherit; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.input-sm { height: 34px; font-size: 12.5px; }
.wizard-steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.wstep {
  padding: 8px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: #eef1f6; color: #8b9098;
}
.wstep.active { background: var(--brand); color: #fff; }
.wstep.done { background: #e4f7ec; color: #1c7a3d; }
.steps-list { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.steps-list li::marker { font-weight: 800; color: var(--brand); }
.danger-zone { border-color: #f3c1c1; }
.danger-zone .panel-title h2 { color: #b33737; }
@media (max-width: 760px) {
  .wstep { padding: 6px 10px; font-size: 11.5px; }
}
