/* ══════════════════════════════════════════════════════════════════
   CoreWebbers CRM — shared design system
   Used by both the admin panel and the client portal. The two differ
   only by the accent variables set on <body class="theme-admin|client">
   ══════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo,
               Consolas, 'Liberation Mono', monospace;

  --bg: #f1f5f9;
  --white: #ffffff;
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --sidebar-w: 250px;
  --radius: 14px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,.07);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);

  --red: #dc2626;   --red-bg: #fee2e2;   --red-ink: #991b1b;
  --amber: #d97706; --amber-bg: #fef3c7; --amber-ink: #92400e;
  --green: #16a34a; --green-bg: #dcfce7; --green-ink: #166534;
  --blue: #2563eb;  --blue-bg: #dbeafe;  --blue-ink: #1d4ed8;
  --violet:#7c3aed; --violet-bg:#ede9fe; --violet-ink:#5b21b6;
  --slate-bg: #f1f5f9; --slate-ink: #475569;
}

body.theme-admin {
  --sidebar: #0f172a;
  --sidebar-active: #3b82f6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-grad: linear-gradient(135deg, #3b82f6, #2563eb);
  --accent-soft: rgba(37,99,235,.12);
  --hero-grad: linear-gradient(135deg, #1e3a8a, #2563eb 85%);
}

body.theme-client {
  --sidebar: #064e3b;
  --sidebar-active: #34d399;
  --accent: #059669;
  --accent-dark: #047857;
  --accent-grad: linear-gradient(135deg, #059669, #047857);
  --accent-soft: rgba(5,150,105,.12);
  --hero-grad: linear-gradient(135deg, #065f46, #059669 85%);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11';
  letter-spacing: -0.006em;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: var(--accent); }

/* ── Typography ──────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 800; letter-spacing: -0.02em; }

/* Inter ships true tabular figures. Turning them on keeps every money
   column, stat tile and total lined up digit-for-digit instead of the
   ragged edge you get from proportional numerals. */
.crm-table .num, .crm-table td, .crm-table th,
.stat-val, .hero-stat .val, .pipe-step .pv, .progress-meta,
.tab-count, .nav-badge, .badge, .bubble-time, .tl-meta {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

/* Reference numbers, tokens and cron lines read as data, not prose. */
code, kbd, samp, pre, .mono {
  font-family: var(--font-mono);
  font-size: .86em;
  font-variant-ligatures: none;
}
code {
  background: rgba(15, 23, 42, .06);
  padding: .1rem .38rem;
  border-radius: 5px;
  color: #0f172a;
  white-space: nowrap;
}
.alert-crm code { background: rgba(15, 23, 42, .09); }

/* Money and identifiers that must never wrap mid-value. */
.cell-strong, .stat-val, .hero-stat .val { font-feature-settings: 'tnum' 1; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar); display: flex; flex-direction: column;
  z-index: 1000; overflow-y: auto; transition: transform .3s ease;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }

.sidebar-brand {
  padding: 1.35rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .7rem; text-decoration: none;
}
.sidebar-brand .logo-icon {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .95rem; flex-shrink: 0;
}
.sidebar-brand .name { color: #fff; font-weight: 800; font-size: .98rem; line-height: 1.2; letter-spacing: -.01em; }
.sidebar-brand .sub  { color: rgba(255,255,255,.45); font-size: .71rem; margin-top: .1rem; }

.nav-section-label {
  font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.28); padding: 1.1rem 1.25rem .35rem; margin: 0;
}
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .6rem 1.25rem;
  color: rgba(255,255,255,.62); text-decoration: none; transition: all .15s;
  border-left: 3px solid transparent; font-size: .86rem;
}
.nav-item:hover, .nav-item.active {
  color: #fff; background: rgba(255,255,255,.07); border-left-color: var(--sidebar-active);
}
.nav-item i { width: 17px; text-align: center; font-size: .85rem; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff; border-radius: 20px;
  font-size: .66rem; font-weight: 800; padding: .1rem .45rem; min-width: 19px; text-align: center;
}
.nav-badge.amber { background: var(--amber); }
.nav-badge.blue  { background: var(--blue); }

.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.user-pill {
  display: flex; align-items: center; gap: .65rem; background: rgba(255,255,255,.07);
  border-radius: 10px; padding: .6rem .8rem; margin-bottom: .45rem;
}
.user-pill .avatar {
  width: 31px; height: 31px; border-radius: 9px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .72rem; font-weight: 800; flex-shrink: 0;
}
.user-pill .uname { color: #fff; font-weight: 600; font-size: .82rem; }
.user-pill .urole { color: rgba(255,255,255,.45); font-size: .69rem; }
.btn-logout-nav {
  display: flex; align-items: center; gap: .5rem; color: rgba(255,255,255,.5);
  text-decoration: none; font-size: .81rem; padding: .3rem 0; transition: color .2s;
}
.btn-logout-nav:hover { color: #f87171; }

/* ── Shell ───────────────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  background: var(--white); min-height: 58px; padding: .5rem 1.5rem;
  border-bottom: 1px solid var(--border); display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; position: sticky; top: 0; z-index: 900;
  box-shadow: 0 1px 4px rgba(0,0,0,.04); flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.topbar .page-title { font-weight: 800; font-size: 1rem; letter-spacing: -.01em; }
.topbar .page-sub { font-size: .76rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.sidebar-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .6rem; cursor: pointer; color: var(--text);
}
.back-btn {
  display: inline-flex; align-items: center; gap: .4rem; color: var(--muted);
  text-decoration: none; font-size: .84rem; transition: color .2s; white-space: nowrap;
}
.back-btn:hover { color: var(--text); }
.page { padding: 1.5rem; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: none; border-radius: 9px; padding: .52rem 1.05rem; font-size: .84rem;
  font-weight: 700; cursor: pointer; text-decoration: none; transition: all .18s;
  font-family: inherit; line-height: 1.4; white-space: nowrap;
}
.btn-primary { background: var(--accent-grad); color: #fff; box-shadow: 0 2px 8px var(--accent-soft); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 14px var(--accent-soft); color: #fff; }
.btn-outline { background: var(--white); border: 1px solid var(--border); color: #334155; }
.btn-outline:hover { background: #f8fafc; border-color: var(--muted-light); color: var(--text); }
.btn-ghost { background: var(--slate-bg); color: #334155; }
.btn-ghost:hover { background: #e2e8f0; color: var(--text); }
.btn-success { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; }
.btn-success:hover { color: #fff; opacity: .92; }
.btn-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.btn-danger:hover { color: #fff; opacity: .92; }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-warning:hover { color: #fff; opacity: .92; }
.btn-sm { padding: .34rem .8rem; font-size: .78rem; border-radius: 8px; }
.btn-lg { padding: .75rem 1.5rem; font-size: .92rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-icon {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: .32rem .55rem; cursor: pointer; font-size: .78rem; color: var(--muted);
  transition: all .18s; line-height: 1.4; text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-icon.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-bg); }

/* ── Cards ───────────────────────────────────────────────────────── */
.card-box {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 1.35rem;
}
.card-box-head {
  padding: .95rem 1.2rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
}
.card-box-head h6 { margin: 0; font-weight: 800; font-size: .88rem; display: flex; align-items: center; gap: .5rem; }
.card-box-body { padding: 1.2rem; }
.card-box-body.tight { padding: .85rem 1.2rem; }

/* ── Stat tiles ──────────────────────────────────────────────────── */
.stats-grid { display: grid; gap: 1rem; margin-bottom: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat-card {
  background: var(--white); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-md); border: 1px solid var(--border);
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
}
a.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); color: inherit; }
.stat-accent-bar { height: 4px; width: 100%; }
.stat-card-body { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.stat-icon {
  width: 38px; height: 38px; border-radius: 11px; display: flex;
  align-items: center; justify-content: center; font-size: .88rem; flex-shrink: 0;
}
.stat-val { font-size: 1.6rem; font-weight: 800; line-height: 1.05; letter-spacing: -.025em; word-break: break-all; }
.stat-val.sm { font-size: 1.25rem; }
.stat-lbl { font-size: .71rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .045em; }
.stat-note { font-size: .73rem; color: var(--muted-light); }

.ic-blue   { background: linear-gradient(135deg,#dbeafe,#bfdbfe); color: #1d4ed8; }
.ic-indigo { background: linear-gradient(135deg,#e0e7ff,#c7d2fe); color: #4338ca; }
.ic-violet { background: linear-gradient(135deg,#ede9fe,#ddd6fe); color: #6d28d9; }
.ic-teal   { background: linear-gradient(135deg,#ccfbf1,#99f6e4); color: #0d9488; }
.ic-green  { background: linear-gradient(135deg,#dcfce7,#bbf7d0); color: #16a34a; }
.ic-amber  { background: linear-gradient(135deg,#fef3c7,#fde68a); color: #d97706; }
.ic-red    { background: linear-gradient(135deg,#fee2e2,#fecaca); color: #dc2626; }
.ic-pink   { background: linear-gradient(135deg,#fce7f3,#fbcfe8); color: #db2777; }
.ic-slate  { background: linear-gradient(135deg,#f1f5f9,#e2e8f0); color: #475569; }

.bar-blue   { background: linear-gradient(90deg,#1d4ed8,#60a5fa); }
.bar-indigo { background: linear-gradient(90deg,#4338ca,#818cf8); }
.bar-violet { background: linear-gradient(90deg,#6d28d9,#a78bfa); }
.bar-teal   { background: linear-gradient(90deg,#0d9488,#2dd4bf); }
.bar-green  { background: linear-gradient(90deg,#16a34a,#4ade80); }
.bar-amber  { background: linear-gradient(90deg,#d97706,#fbbf24); }
.bar-red    { background: linear-gradient(90deg,#dc2626,#f87171); }
.bar-pink   { background: linear-gradient(90deg,#db2777,#f472b6); }
.bar-slate  { background: linear-gradient(90deg,#475569,#94a3b8); }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.crm-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.crm-table th {
  padding: .65rem .85rem; font-size: .69rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border);
  white-space: nowrap; text-align: left; background: #fbfcfe;
}
.crm-table td { padding: .8rem .85rem; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.crm-table tbody tr:last-child td { border-bottom: none; }
.crm-table tbody tr:hover td { background: #f8fafc; }
.crm-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crm-table .ctr { text-align: center; }
.cell-strong { font-weight: 700; font-size: .87rem; }
.cell-muted  { color: var(--muted); font-size: .8rem; }

/* ── Badges & pills ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .32rem; border-radius: 20px;
  padding: .2rem .65rem; font-size: .71rem; font-weight: 700; white-space: nowrap; line-height: 1.5;
}
.badge i { font-size: .68rem; }
.badge-soft { background: var(--slate-bg); color: var(--slate-ink); }
.badge-red    { background: var(--red-bg);    color: var(--red-ink); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-ink); }
.badge-green  { background: var(--green-bg);  color: var(--green-ink); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-ink); }
.badge-violet { background: var(--violet-bg); color: var(--violet-ink); }

/* Priority */
.pri-badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 20px; padding: .18rem .6rem; font-size: .69rem; font-weight: 700; }
.pri-low    { background: #f1f5f9; color: #64748b; }
.pri-normal { background: #dbeafe; color: #1d4ed8; }
.pri-high   { background: #fef3c7; color: #92400e; }
.pri-urgent { background: #fee2e2; color: #991b1b; animation: urgentPulse 2s infinite; }
@keyframes urgentPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.3); } 50% { box-shadow: 0 0 0 4px rgba(239,68,68,0); } }

/* Avatars */
.avatar-circle {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent-grad);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .74rem; flex-shrink: 0;
}
.avatar-circle.sm { width: 26px; height: 26px; font-size: .64rem; border-radius: 7px; }
.avatar-circle.lg { width: 46px; height: 46px; font-size: .95rem; border-radius: 13px; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert-crm {
  border-radius: 12px; padding: .8rem 1.05rem; display: flex; align-items: flex-start;
  gap: .6rem; font-size: .86rem; margin-bottom: 1.15rem; line-height: 1.5;
}
.alert-crm i { margin-top: .15rem; flex-shrink: 0; }
.alert-crm.success { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
.alert-crm.error   { background: #fee2e2; border: 1px solid #fca5a5; color: #7f1d1d; }
.alert-crm.warn    { background: #fef3c7; border: 1px solid #fde68a; color: #78350f; }
.alert-crm.info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.alert-crm ul { margin: 0; padding-left: 1.1rem; }

/* Dismissible alerts: the close control sits inside the flex row, pushed right. */
.alert-crm { position: relative; }
.alert-crm .alert-close {
  margin-left: auto; align-self: flex-start; flex-shrink: 0;
  background: none; border: none; cursor: pointer; color: inherit;
  opacity: .45; padding: .15rem .3rem; line-height: 1; font-size: .9rem;
  border-radius: 6px; transition: opacity .15s ease, background .15s ease;
}
.alert-crm .alert-close:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.alert-crm .alert-close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 1px; }
.alert-crm.dismissing {
  animation: alertOut .22s ease forwards;
  overflow: hidden;
}
@keyframes alertOut {
  to { opacity: 0; transform: translateY(-6px); max-height: 0;
       margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}

/* ── Work ledger ─────────────────────────────────────────────────── */
.ledger-kinds { display: flex; flex-wrap: wrap; gap: .4rem; }
.kind-chip {
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 20px; padding: .3rem .75rem;
  font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--white);
  text-transform: none; letter-spacing: 0; margin: 0; user-select: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
/* The filter bar uppercases its labels; these chips are controls, not captions. */
.filter-bar .kind-chip { text-transform: none; letter-spacing: 0; font-size: .8rem; margin: 0; display: inline-flex; }
.kind-chip input { accent-color: var(--kc); margin: 0 .1rem 0 0; }
.kind-chip i { color: var(--kc); font-size: .75rem; }
.kind-chip:has(input:checked) { border-color: var(--kc); color: var(--text); background: color-mix(in srgb, var(--kc) 8%, white); }

.ledger-month-head { position: sticky; top: 58px; z-index: 5; background: var(--white); border-radius: var(--radius) var(--radius) 0 0; }
.ledger-body { padding: .3rem 0; }
.ledger-day {
  display: grid; grid-template-columns: 74px 1fr; gap: 0 .2rem;
  padding: .55rem 1.2rem; border-bottom: 1px solid var(--border-soft);
}
.ledger-day:last-child { border-bottom: none; }
.ledger-date {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: .35rem; line-height: 1.05; font-variant-numeric: tabular-nums;
}
.ledger-date .d { font-size: 1.45rem; font-weight: 800; letter-spacing: -.03em; }
.ledger-date .m { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ledger-date .w { font-size: .66rem; color: var(--muted-light); margin-top: .12rem; }

.ledger-events { list-style: none; margin: 0; padding: 0 0 0 1.1rem; position: relative; }
.ledger-events::before {
  content: ''; position: absolute; left: .35rem; top: .7rem; bottom: .7rem;
  width: 2px; background: var(--border); border-radius: 2px;
}
.ledger-event {
  position: relative; display: grid; grid-template-columns: 44px 30px 1fr auto;
  gap: .6rem; align-items: start; padding: .5rem .5rem .5rem 0;
  border-radius: 10px; transition: background .14s ease;
}
.ledger-event:hover { background: #f8fafc; }
.ledger-event::before {
  content: ''; position: absolute; left: -.97rem; top: 1rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--kc); box-shadow: 0 0 0 3px var(--white);
}
.ledger-seq {
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted-light);
  padding-top: .38rem; text-align: right; font-variant-numeric: tabular-nums;
}
.ledger-icon {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  color: var(--kc); background: color-mix(in srgb, var(--kc) 12%, white); font-size: .78rem;
}
.ledger-main { min-width: 0; }
.ledger-title { font-weight: 700; font-size: .9rem; line-height: 1.35; }
.ledger-title a { color: var(--text); text-decoration: none; }
.ledger-title a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.ledger-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem;
  margin-top: .25rem; font-size: .76rem; color: var(--muted);
}
.ledger-meta i { font-size: .66rem; margin-right: .25rem; opacity: .7; }
.ledger-meta .kind-label { color: var(--kc); font-weight: 700; }
.ledger-proj { color: var(--muted); text-decoration: none; }
.ledger-proj:hover { color: var(--accent); }
.ledger-detail {
  margin-top: .4rem; font-size: .82rem; color: #334155; line-height: 1.55;
  background: #f8fafc; border: 1px solid var(--border-soft); border-radius: 8px; padding: .45rem .65rem;
  word-break: break-word;
}
details.ledger-detail summary { cursor: pointer; list-style: none; }
details.ledger-detail summary::-webkit-details-marker { display: none; }
details.ledger-detail summary::after { content: ' more'; color: var(--accent); font-weight: 600; }
details.ledger-detail[open] summary { display: none; }
.ledger-amount {
  font-weight: 800; font-size: .88rem; white-space: nowrap; padding-top: .35rem;
  font-variant-numeric: tabular-nums;
}
.ledger-amount.in { color: var(--green); }
.ledger-amount.out { color: var(--red); }
.ledger-amount small { font-size: .7rem; font-weight: 600; }

@media (max-width: 700px) {
  .ledger-day { grid-template-columns: 1fr; padding: .6rem .8rem; }
  .ledger-date { flex-direction: row; gap: .35rem; align-items: baseline; padding: 0 0 .3rem; }
  .ledger-event { grid-template-columns: 30px 1fr; }
  .ledger-seq { display: none; }
  .ledger-amount { grid-column: 2; padding-top: 0; }
}
@media print {
  .ledger-month-head { position: static; }
  .ledger-month { break-inside: auto; }
  .ledger-day { break-inside: avoid; }
}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.form-group { margin-bottom: 1rem; }
.form-lbl {
  font-size: .79rem; font-weight: 700; color: #334155;
  margin-bottom: .32rem; display: block;
}
.form-lbl .req { color: var(--red); }
.form-ctrl {
  width: 100%; padding: .62rem .85rem; border: 1.5px solid var(--border);
  border-radius: 9px; font-size: .87rem; background: #f9fafb; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
  font-family: inherit; color: var(--text);
}
.form-ctrl:focus { border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.form-ctrl { resize: vertical; min-height: 86px; line-height: 1.55; }
select.form-ctrl { cursor: pointer; }
.form-hint { font-size: .74rem; color: var(--muted); margin-top: .28rem; line-height: 1.45; }
.form-row-inline { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.check-row { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: #334155; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* Filter bar */
.filter-bar {
  background: var(--white); border-radius: var(--radius); border: 1px solid var(--border);
  padding: .95rem 1.15rem; margin-bottom: 1.15rem; display: flex; flex-wrap: wrap;
  gap: .65rem; align-items: flex-end; box-shadow: var(--shadow-sm);
}
.filter-bar label { font-size: .71rem; font-weight: 800; color: #334155; text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: .28rem; }
.filter-bar .fb-field { flex: 0 0 auto; }
.filter-bar .fb-field.grow { flex: 1 1 180px; min-width: 160px; }
.filter-bar .form-ctrl { padding: .48rem .72rem; font-size: .83rem; background: #f8fafc; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs-bar {
  display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.2rem;
  background: var(--white); border-radius: var(--radius) var(--radius) 0 0;
  overflow-x: auto; box-shadow: var(--shadow-sm);
}
.tab-btn {
  display: inline-flex; align-items: center; gap: .5rem; padding: .8rem 1.25rem;
  border: none; background: none; font-weight: 700; font-size: .84rem; cursor: pointer;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: all .2s; white-space: nowrap; font-family: inherit; text-decoration: none;
}
.tab-btn:hover { color: #334155; background: #f8fafc; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: linear-gradient(to bottom, var(--accent-soft), transparent); }
.tab-count { font-size: .69rem; font-weight: 800; padding: .14rem .5rem; border-radius: 20px; background: var(--slate-bg); color: var(--slate-ink); min-width: 20px; text-align: center; }
.tab-btn.active .tab-count { background: var(--accent); color: #fff; }
.tab-panel { display: none; animation: fadeIn .2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Hero header ─────────────────────────────────────────────────── */
.hero {
  background: var(--hero-grad); border-radius: var(--radius-lg); padding: 1.4rem 1.5rem;
  margin-bottom: 1.4rem; display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1.1rem; color: #fff;
}
.hero h3 { color: #fff; font-weight: 800; margin: 0 0 .3rem; font-size: 1.25rem; letter-spacing: -.02em; }
.hero .hero-sub { color: rgba(255,255,255,.78); font-size: .84rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.hero .hero-sub a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }
.hero-stats { display: flex; gap: .7rem; flex-wrap: wrap; }
.hero-stat {
  background: rgba(255,255,255,.12); border-radius: 13px; padding: .6rem 1.05rem;
  text-align: center; border: 1px solid rgba(255,255,255,.2); min-width: 92px;
}
.hero-stat .val { color: #fff; font-weight: 800; font-size: 1.15rem; line-height: 1.15; letter-spacing: -.02em; }
.hero-stat .lbl { color: rgba(255,255,255,.68); font-size: .66rem; margin-top: .2rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.hero-chip {
  display: inline-flex; align-items: center; gap: .35rem; background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25); border-radius: 20px; padding: .2rem .7rem;
  font-size: .72rem; font-weight: 700; color: #fff;
}

/* ── Progress ────────────────────────────────────────────────────── */
.progress-track { height: 7px; border-radius: 5px; background: #e2e8f0; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg,#22c55e,#16a34a); transition: width .4s ease; }
.progress-fill.partial { background: linear-gradient(90deg,#f59e0b,#d97706); }
.progress-fill.low     { background: linear-gradient(90deg,#ef4444,#dc2626); }
.progress-meta { display: flex; justify-content: space-between; font-size: .74rem; color: var(--muted); margin-top: .3rem; }

/* ── Timeline ────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ''; position: absolute; left: 6px; top: .4rem; bottom: .4rem; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 1rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -1.4rem; top: .28rem; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--white); box-shadow: 0 0 0 2px var(--border); }
.tl-title { font-size: .85rem; font-weight: 700; }
.tl-meta { font-size: .74rem; color: var(--muted); margin-top: .12rem; }
.tl-body { font-size: .83rem; color: #334155; margin-top: .3rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }

/* ── Pipeline strip ──────────────────────────────────────────────── */
.pipeline { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; }
.pipe-step {
  flex: 1 1 0; min-width: 118px; background: var(--white); border: 1px solid var(--border);
  border-radius: 12px; padding: .75rem .85rem; text-decoration: none; color: inherit;
  transition: all .2s; border-top: 3px solid var(--border);
}
.pipe-step:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: inherit; }
.pipe-step .pv { font-size: 1.35rem; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.pipe-step .pl { font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-top: .3rem; }
.pipe-step .pm { font-size: .72rem; color: var(--muted-light); margin-top: .15rem; }

/* ── File pills ──────────────────────────────────────────────────── */
.file-pill {
  display: inline-flex; align-items: center; gap: .5rem; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 9px; padding: .45rem .8rem;
  font-size: .81rem; text-decoration: none; color: #334155; transition: all .2s; max-width: 100%;
}
.file-pill:hover { background: #f1f5f9; border-color: var(--muted-light); color: var(--text); transform: translateY(-1px); }
.file-pill .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.file-pill .fmeta { color: var(--muted-light); font-size: .72rem; }

/* ── Message / note boxes ────────────────────────────────────────── */
.msg-box {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem .95rem; font-size: .85rem; white-space: pre-wrap; word-break: break-word;
  color: #334155; line-height: 1.6;
}
.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .85rem 1.4rem; }
.kv { min-width: 0; }
.kv .k { font-size: .69rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .18rem; }
.kv .v { font-size: .87rem; font-weight: 600; word-break: break-word; }
.kv .v.muted { color: var(--muted); font-weight: 500; }

/* ── Change-request cards ────────────────────────────────────────── */
.cr-card {
  background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border);
  margin-bottom: 1rem; overflow: hidden; transition: box-shadow .2s;
}
.cr-card:hover { box-shadow: var(--shadow-md); }
.cr-card.st-open        { border-left: 5px solid #dc2626; }
.cr-card.st-in_progress { border-left: 5px solid #2563eb; }
.cr-card.st-admin_done  { border-left: 5px solid #d97706; }
.cr-card.st-closed      { border-left: 5px solid #16a34a; }
.cr-card.st-on_hold     { border-left: 5px solid #8b5cf6; }
.cr-card.st-rejected    { border-left: 5px solid #64748b; }
.cr-head {
  padding: .75rem 1.1rem; border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap;
  background: #fbfcfe;
}
.cr-head .cr-num {
  font-size: .74rem; color: var(--muted); font-weight: 800; background: #f1f5f9;
  padding: .1rem .5rem; border-radius: 6px; border: 1px solid var(--border);
}
.cr-title { font-weight: 700; font-size: .9rem; }
.cr-body { padding: 1.1rem; }
.cr-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }

.waiting-box {
  background: linear-gradient(135deg,#fffbeb,#fef9c3); border: 1px solid #fde68a;
  border-radius: 11px; padding: .75rem 1rem; display: flex; align-items: center; gap: .7rem;
}
.waiting-box .dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; animation: pulse 1.5s infinite; flex-shrink: 0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,.5); } 70% { box-shadow: 0 0 0 8px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
.waiting-box .txt { font-size: .83rem; color: #78350f; font-weight: 600; }
.waiting-box .time { font-size: .75rem; color: #92400e; margin-top: .1rem; }
.done-note {
  color: #059669; font-size: .81rem; font-weight: 600; display: flex; align-items: center;
  gap: .45rem; background: #ecfdf5; border-radius: 8px; padding: .4rem .75rem; width: fit-content;
}

/* ── Conversation thread ─────────────────────────────────────────── */
.thread-toggle {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft);
  border: 1px solid transparent; border-radius: 8px; padding: .28rem .75rem;
  font-size: .74rem; font-weight: 700; color: var(--accent); cursor: pointer; transition: all .15s;
}
.thread-toggle:hover { filter: brightness(.96); }
.thread-toggle.has-unread { background: #fef3c7; color: #92400e; }
.thread-body { display: none; margin-top: .8rem; }
.thread-body.open { display: block; animation: fadeIn .15s ease; }
.chat-bubble { display: flex; gap: .55rem; margin-bottom: .6rem; }
.chat-bubble.client { flex-direction: row-reverse; }
.bubble-avatar {
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: .66rem; font-weight: 800; flex-shrink: 0; color: #fff;
}
.bubble-avatar.admin  { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.bubble-avatar.client { background: linear-gradient(135deg,#059669,#047857); }
.bubble-content { max-width: 78%; min-width: 0; }
.bubble-name { font-size: .67rem; font-weight: 700; color: var(--muted); margin-bottom: .2rem; }
.chat-bubble.client .bubble-name { text-align: right; }
.bubble-msg { padding: .55rem .75rem; border-radius: 12px; font-size: .82rem; line-height: 1.5; word-break: break-word; }
.chat-bubble.admin  .bubble-msg { background: #eff6ff; color: #1e3a5f; border-radius: 2px 12px 12px 12px; }
.chat-bubble.client .bubble-msg { background: #ecfdf5; color: #064e3b; border-radius: 12px 2px 12px 12px; }
.bubble-time { font-size: .66rem; color: var(--muted-light); margin-top: .18rem; }
.chat-bubble.client .bubble-time { text-align: right; }
.reply-form { margin-top: .8rem; background: #f8fafc; border: 1.5px solid var(--border); border-radius: 11px; padding: .8rem; }
.reply-form textarea { width: 100%; padding: .5rem .7rem; border: 1.5px solid var(--border); border-radius: 9px; font-size: .83rem; background: #fff; resize: vertical; min-height: 66px; outline: none; font-family: inherit; }
.reply-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.collapse-toggle {
  display: inline-flex; align-items: center; gap: .35rem; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 8px; padding: .26rem .7rem;
  font-size: .73rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s;
}
.collapse-toggle:hover { background: #f1f5f9; color: #334155; }
.collapse-body { display: none; margin-top: .7rem; border-top: 1px solid var(--border-soft); padding-top: .7rem; }
.collapse-body.open { display: block; animation: fadeIn .15s ease; }

/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state {
  background: var(--white); border-radius: var(--radius-lg); text-align: center;
  padding: 3.2rem 1.25rem; border: 1px dashed var(--border);
}
.empty-state i.big { font-size: 2.8rem; color: #cbd5e1; display: block; margin-bottom: .9rem; }
.empty-state h5 { color: #334155; margin: 0 0 .35rem; font-size: 1rem; font-weight: 700; }
.empty-state p  { color: var(--muted); font-size: .86rem; margin: 0 0 1rem; }
.empty-inline { text-align: center; padding: 2.4rem 1rem; color: var(--muted); font-size: .87rem; }
.empty-inline i { font-size: 2.2rem; opacity: .22; display: block; margin-bottom: .7rem; }

/* ── Modals (Bootstrap overrides) ────────────────────────────────── */
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { border-bottom: 1px solid var(--border-soft); padding: 1.1rem 1.4rem; }
.modal-title { font-weight: 800; font-size: .98rem; display: flex; align-items: center; gap: .5rem; }
.modal-body { padding: 1.4rem; }
.modal-footer { border-top: 1px solid var(--border-soft); padding: .9rem 1.4rem; gap: .5rem; }

/* Bootstrap makes a modal scroll by treating .modal-body as a flex child of
   .modal-content, so it can shrink and take the overflow. Our modals wrap the
   body and footer in a <form>, which breaks that chain: the form is not a flex
   container, so the body never shrinks, the footer is pushed past the bottom of
   the screen and .modal-content (overflow:hidden) simply clips it.
   Making the form the flex column restores the intended behaviour. */
.modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.modal-dialog-scrollable .modal-body { overflow-y: auto; min-height: 0; }

/* Never let a modal grow past the screen, even without the scrollable class. */
.modal-content { max-height: calc(100vh - 1rem); }
.modal-dialog-scrollable .modal-content { max-height: 100%; }

/* A visible, unobtrusive scrollbar inside modal bodies. */
.modal-body::-webkit-scrollbar { width: 9px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; border: 2px solid var(--white); }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--muted-light); }

@media (max-width: 575.98px) {
  .modal-dialog { margin: .5rem; }
}

/* ── Utilities ───────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-xs { gap: .3rem; } .gap-sm { gap: .5rem; } .gap-md { gap: .8rem; } .gap-lg { gap: 1.2rem; }
.mt-0 { margin-top: 0; } .mt-sm { margin-top: .5rem; } .mt-md { margin-top: 1rem; } .mt-lg { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-sm { margin-bottom: .5rem; } .mb-md { margin-bottom: 1rem; } .mb-lg { margin-bottom: 1.5rem; }
.text-muted { color: var(--muted); }
.text-red { color: var(--red); } .text-green { color: var(--green); }
.text-amber { color: var(--amber); } .text-blue { color: var(--blue); }
.text-violet { color: var(--violet); } .text-indigo { color: #4f46e5; } .text-teal { color: #0d9488; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.inline-form { display: inline; }
.text-sm { font-size: .8rem; } .text-xs { font-size: .73rem; }
.fw-bold { font-weight: 700; } .fw-800 { font-weight: 800; }
.nowrap { white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.35rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; }
.divider { height: 1px; background: var(--border); margin: 1.1rem 0; }

/* ── Mobile ──────────────────────────────────────────────────────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; }
.sidebar-overlay.show { display: block; }
@media (max-width: 900px) {
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .page { padding: 1rem; }
  .topbar { padding: .5rem 1rem; }
  .hero { padding: 1.15rem; }
  .hero-stats { width: 100%; }
  .hero-stat { flex: 1 1 auto; min-width: 78px; }
}

/* ══════════════════════════════════════════════════════════════════
   Motion & polish
   Restrained on purpose: this is a tool people use all day, so motion
   confirms actions and guides the eye rather than performing.
   Everything here is switched off under prefers-reduced-motion.
   ══════════════════════════════════════════════════════════════════ */

/* ── Page entrance: a short, staggered settle ── */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.page > .stats-grid,
.page > .card-box,
.page > .filter-bar,
.page > .pipeline,
.page > .hero,
.page > .grid-2,
.page > .tabs-bar,
.page > .alert-crm,
.reveal {
  animation: riseIn .38s cubic-bezier(.22, 1, .36, 1) both;
}
.page > *:nth-child(1) { animation-delay: .01s; }
.page > *:nth-child(2) { animation-delay: .05s; }
.page > *:nth-child(3) { animation-delay: .09s; }
.page > *:nth-child(4) { animation-delay: .13s; }
.page > *:nth-child(5) { animation-delay: .16s; }
.page > *:nth-child(n+6) { animation-delay: .19s; }

/* Stat tiles settle one after another rather than all at once. */
.stats-grid .stat-card { animation: riseIn .42s cubic-bezier(.22, 1, .36, 1) both; }
.stats-grid .stat-card:nth-child(1) { animation-delay: .04s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: .08s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: .12s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: .16s; }
.stats-grid .stat-card:nth-child(5) { animation-delay: .20s; }
.stats-grid .stat-card:nth-child(6) { animation-delay: .24s; }
.stats-grid .stat-card:nth-child(n+7) { animation-delay: .28s; }

/* ── Interaction feedback ── */
.card-box { transition: box-shadow .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1); }
.card-box:hover { box-shadow: var(--shadow-md); }

.btn { position: relative; overflow: hidden; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-icon:active { transform: scale(.92); }

.crm-table tbody tr { transition: background .14s ease; }
.crm-table tbody tr:hover td { background: #f8fafc; }

.nav-item { transition: color .16s ease, background .16s ease, border-left-color .16s ease, padding-left .16s ease; }
.nav-item:hover { padding-left: 1.45rem; }

.pipe-step { transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, background .2s ease; }
.pipe-step.is-active { box-shadow: inset 0 0 0 1px var(--accent); }

.file-pill, .badge { transition: transform .16s ease, background .16s ease; }

/* Progress bars grow into place rather than snapping. */
.progress-fill { transition: width .7s cubic-bezier(.22, 1, .36, 1); }

/* ── Attention, used sparingly: money you are owed ── */
@keyframes softPulse {
  0%, 100% { box-shadow: var(--shadow-md); }
  50%      { box-shadow: 0 6px 22px rgba(219, 39, 119, .28); }
}
.stat-card.pulse-alert { animation: riseIn .42s cubic-bezier(.22,1,.36,1) both, softPulse 2.8s ease-in-out 1s infinite; }

/* ── Quick entry rows ── */
.quick-row {
  display: grid;
  grid-template-columns: 1fr 150px auto 38px;
  gap: .5rem;
  margin-bottom: .5rem;
  animation: riseIn .22s ease both;
}
.quick-row .form-ctrl { padding: .5rem .7rem; font-size: .87rem; }
@media (max-width: 560px) {
  .quick-row { grid-template-columns: 1fr 96px auto 34px; }
  .free-toggle span { display: none; }
}

/* Charge / Free switch on a quick-entry row */
.free-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--border); background: var(--white); color: var(--violet-ink);
  border-radius: 10px; padding: 0 .7rem; font-size: .78rem; font-weight: 700;
  cursor: pointer; transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.free-toggle:hover { border-color: var(--violet); }
.free-toggle.is-free { background: var(--green-bg); color: var(--green-ink); border-color: #86efac; }

/* ── Toast ── */
#toastHost {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 1200;
  display: flex; flex-direction: column; gap: .5rem; align-items: flex-end;
  pointer-events: none;
}
.toast {
  background: var(--sidebar); color: #fff;
  border-radius: 11px; padding: .72rem 1rem;
  font-size: .86rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  display: flex; align-items: center; gap: .6rem;
  max-width: min(360px, calc(100vw - 2rem));
  animation: toastIn .3s cubic-bezier(.22, 1, .36, 1) both;
  pointer-events: auto;
}
.toast.out { animation: toastOut .25s ease forwards; }
.toast i { color: #4ade80; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ── Flash messages arrive rather than appear ── */
.alert-crm { animation: riseIn .34s cubic-bezier(.22, 1, .36, 1) both; }

/* ── Modal entrance softened ── */
.modal.fade .modal-dialog { transition: transform .26s cubic-bezier(.22, 1, .36, 1), opacity .2s ease; }

/* ── Focus that is actually visible ── */
.btn:focus-visible, .btn-icon:focus-visible, .form-ctrl:focus-visible,
.nav-item:focus-visible, .tab-btn:focus-visible, .pipe-step:focus-visible,
.stat-card:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Empty states feel less dead ── */
.empty-inline i, .empty-state i.big { transition: transform .3s ease; }
.empty-state:hover i.big { transform: translateY(-3px); }

/* ── WhatsApp actions ── */
.btn-wa { background: linear-gradient(135deg, #25d366, #128c7e); color: #fff; }
.btn-wa:hover { color: #fff; opacity: .92; }
.btn-icon.wa { color: #128c7e; }
.btn-icon.wa:hover { border-color: #25d366; background: #dcfce7; color: #075e54; }

/* ── Quick Entry (phone first) ── */
.quick-wrap { max-width: 560px; margin: 0 auto; }
.seg-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; padding: .3rem;
  background: var(--white); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 1rem;
}
.seg-switch a {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .65rem; border-radius: 10px; font-weight: 700; font-size: .92rem;
  color: var(--muted); text-decoration: none; transition: background .18s ease, color .18s ease;
}
.seg-switch a.active { background: var(--accent-grad); color: #fff; box-shadow: var(--shadow-sm); }
.form-ctrl-lg { padding: .72rem .9rem; font-size: 1rem; border-radius: 11px; }
.form-ctrl-sm { padding: .3rem .5rem; font-size: .82rem; }
.quick-card .form-group { margin-bottom: .9rem; }
.quick-pair { gap: .7rem; }
@media (max-width: 900px) { .quick-pair.form-grid.two { grid-template-columns: 1fr 1fr; } }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .9rem; }
.choice-row.wrap { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.choice { margin: 0; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  display: flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .7rem .5rem; border: 1.5px solid var(--border); border-radius: 11px;
  font-weight: 700; font-size: .9rem; color: var(--muted); background: var(--white);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.choice input:checked + span { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.today-list { list-style: none; margin: 0; padding: .3rem 0; }
.today-list li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: .6rem; align-items: center;
  padding: .55rem 1.2rem; border-bottom: 1px solid var(--border-soft);
}
.today-list li:last-child { border-bottom: none; }
.today-list .ti {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--amber-bg); color: var(--amber-ink); font-size: .8rem;
}
.today-list .ti.pay { background: var(--green-bg); color: var(--green-ink); }
.today-list .tt { min-width: 0; }
.today-list .tt strong { display: block; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-list .tt small, .today-list .ta small { color: var(--muted); font-size: .72rem; }
.today-list .ta { font-weight: 800; font-size: .88rem; text-align: right; }
.today-list .ta small { display: block; font-weight: 600; }
/* Select2 pickers, matched to the large form controls */
.quick-card .select2-container .select2-selection--single {
  height: auto; min-height: 48px; padding: .55rem 2.2rem .55rem .9rem;
  border: 1px solid var(--border); border-radius: 11px; background: #f8fafc;
  display: flex; align-items: center;
}
.quick-card .select2-container--default .select2-selection--single .select2-selection__rendered {
  padding: 0; line-height: 1.35; font-size: 1rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quick-card .select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--muted-light); }
.quick-card .select2-container--default .select2-selection--single .select2-selection__arrow { height: 100%; right: .6rem; }
.quick-card .select2-container--open .select2-selection--single,
.quick-card .select2-container--focus .select2-selection--single { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--white); }
body .select2-dropdown { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-lg); font-family: var(--font-sans); }
body .select2-container--default .select2-search--dropdown { padding: .6rem; }
body .select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border); border-radius: 9px; padding: .6rem .75rem; font-size: 1rem; outline: none;
}
body .select2-container--default .select2-search--dropdown .select2-search__field:focus { border-color: var(--accent); }
body .select2-container--default .select2-results > .select2-results__options { max-height: 320px; }
body .select2-results__option { padding: .6rem .85rem; font-size: .92rem; }
body .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable { background: var(--accent); }
body .select2-container--default .select2-results__option--selected { background: var(--accent-soft); color: var(--accent-dark); }
.s2-opt strong { display: block; font-weight: 600; }
.s2-opt small { display: block; font-size: .75rem; opacity: .75; }

.install-hint {
  display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem;
  border: 1px dashed var(--border); border-radius: 12px; background: var(--white);
}
.install-hint[hidden] { display: none; }
@media (max-width: 768px) {
  body.theme-admin .page:has(.quick-wrap) { padding: .75rem; }
}

/* ── WhatsApp import ── */
.import-grid { align-items: start; }
.steps { margin: 0 0 .4rem; padding-left: 1.1rem; line-height: 1.7; color: #334155; }
.import-table td { vertical-align: top; }
.import-msg {
  margin-top: .35rem; font-size: .78rem; color: #334155; line-height: 1.5;
  background: #f0fdf4; border: 1px solid #dcfce7; border-radius: 4px 10px 10px 10px; padding: .4rem .6rem;
  max-height: 9.5rem; overflow: auto;
}
.import-msg .who { display: block; font-weight: 700; color: #128c7e; font-size: .72rem; margin-bottom: .1rem; }
.import-row[hidden] { display: none; }
.sender-chip { --kc: #128c7e; }
textarea.mono { font-size: .8rem; line-height: 1.55; }

/* ── Income by financial year ── */
.fy-chart { display: flex; align-items: flex-end; gap: .5rem; height: 170px; overflow-x: auto; }
.fy-col { flex: 1; min-width: 42px; display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.fy-col.future { opacity: .35; }
.fy-bars { display: flex; align-items: flex-end; gap: 3px; height: 122px; }
.fy-bars span { width: 14px; border-radius: 5px 5px 0 0; animation: growUp .6s cubic-bezier(.22, 1, .36, 1) both; transform-origin: bottom; }
.fy-bars .in { background: linear-gradient(180deg, #4ade80, #16a34a); }
.fy-bars .out { background: linear-gradient(180deg, #fca5a5, #dc2626); }
.fy-val { font-size: .68rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.fy-lbl { font-size: .72rem; color: var(--muted); }
.fy-legend { display: flex; align-items: center; gap: .4rem; margin-top: .7rem; font-size: .75rem; color: var(--muted); }
.fy-legend span { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: .6rem; }
.fy-legend span:first-child { margin-left: 0; }
.fy-legend .in { background: #16a34a; } .fy-legend .out { background: #dc2626; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ── Payment split ── */
.row-settled td { opacity: .5; }
.hide-settled .row-settled { display: none; }
.row-settled:hover td { opacity: .85; }

/* ── Close-out checklist ── */
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.checklist li { display: flex; align-items: center; gap: .55rem; font-size: .84rem; color: var(--muted); }
.checklist li i { font-size: .8rem; color: var(--muted-light); width: 16px; }
.checklist li.done { color: var(--text); }
.checklist li.done i { color: var(--green); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .nav-item:hover { padding-left: 1.25rem; }
}

@media print {
  .sidebar, .topbar, .sidebar-overlay, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: #fff; }
  .card-box { box-shadow: none; break-inside: avoid; }
}
