/* ============================================================================
   PHASE 2.6 — Design tokens (single source of truth). Calm, trustworthy fintech:
   deep-blue primary used sparingly, white cards on a soft off-white page, semantic
   status colours for MEANING only, one spacing scale, ~8px radius, one soft shadow,
   tabular numerals for money/tables. All components below consume these tokens.
   ============================================================================ */
:root{
  /* neutrals */
  --bg:#f6f7f9; --surface:#ffffff; --surface-2:#f9fafb;
  --ink:#111827; --ink-soft:#374151; --muted:#6b7280;
  --line:#e5e7eb; --line-strong:#d1d5db;
  /* primary — deep blue, for primary actions + accents only */
  --brand:#1d4ed8; --brand-hover:#1b45bd; --brand-active:#1e3a8a;
  --brand-soft:#eef3ff; --brand-ring:rgba(29,78,216,.30);
  /* semantic status — meaning only, never decoration */
  --green:#16a34a; --green-soft:#e8f6ed; --amber:#d97706; --amber-soft:#fdf1e3;
  --red:#dc2626; --red-soft:#fdeceb; --violet:#6d28d9; --violet-soft:#f1ecfd;
  /* spacing scale (4/8) */
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px; --s7:48px;
  /* radius + one soft elevation */
  --radius:8px; --radius-sm:6px; --radius-lg:12px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.05);
  --shadow:0 1px 3px rgba(16,24,40,.08),0 1px 2px rgba(16,24,40,.04);
  --shadow-md:0 4px 12px rgba(16,24,40,.08),0 2px 4px rgba(16,24,40,.04);
  /* type */
  --font:'Inter',system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:var(--font);background:var(--bg);color:var(--ink);font-size:14px;line-height:1.5;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
a{color:inherit}
/* Money + tabular figures line up in columns (lining, tabular numerals). */
.tnum,.num,.kpi .v,.goal .gv,.sumcard .v,.stat .num,table td,table th,.appt-time b,.dl .when b{font-variant-numeric:tabular-nums lining-nums;font-feature-settings:'tnum' 1,'lnum' 1}
/* Accessible keyboard focus on every interactive element. */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--brand);outline-offset:2px;border-radius:var(--radius-sm)}
.app{display:flex;min-height:100vh}
.sidebar{width:248px;background:var(--surface);border-right:1px solid var(--line);padding:22px 16px;display:flex;flex-direction:column;gap:3px;position:sticky;top:0;height:100vh;overflow-y:auto}
.sidebar::-webkit-scrollbar{width:7px}
.sidebar::-webkit-scrollbar-thumb{background:#d2d8e2;border-radius:8px}
.sidebar::-webkit-scrollbar-track{background:transparent}
.brand{display:flex;align-items:center;gap:11px;padding:6px 10px 20px;text-decoration:none}
.brand .logo{width:38px;height:38px;border-radius:var(--radius);background:var(--brand);display:grid;place-items:center;color:#fff;font-weight:700;font-size:17px}
.brand b{font-size:15.5px;letter-spacing:-.2px}
.brand small{display:block;color:var(--muted);font-size:11px;font-weight:500}
.nav-label{font-size:10.5px;color:var(--muted);text-transform:uppercase;letter-spacing:.6px;margin:11px 12px 4px;font-weight:600}
.nav a{display:flex;align-items:center;gap:11px;padding:7.5px 12px;border-radius:10px;color:var(--ink-soft);text-decoration:none;font-weight:500;font-size:13.5px;cursor:pointer}
.nav a:hover{background:#f3f6fb;color:var(--ink)}
.nav a.active{background:var(--brand-soft);color:var(--brand);font-weight:600}
.nav a .ic{width:18px;height:18px;flex:none;opacity:.7}
.nav a.active .ic,.nav a:hover .ic{opacity:1}
.nav a .badge{margin-left:auto;background:var(--red);color:#fff;font-size:11px;font-weight:600;padding:1px 7px;border-radius:20px}
.side-foot{margin-top:auto;border-top:1px solid var(--line);padding-top:14px;display:flex;align-items:center;gap:10px;padding-left:8px}
.avatar{width:34px;height:34px;border-radius:50%;background:#dfe6f2;color:#41506a;display:grid;place-items:center;font-weight:700;font-size:13px}
.main{flex:1;display:flex;flex-direction:column;min-width:0}
.topbar{height:64px;background:rgba(255,255,255,.85);backdrop-filter:blur(8px);border-bottom:1px solid var(--line);display:flex;align-items:center;gap:16px;padding:0 28px;position:sticky;top:0;z-index:5}
.search{flex:1;max-width:440px;display:flex;align-items:center;gap:9px;background:var(--surface-2);border:1px solid var(--line);border-radius:var(--radius);padding:9px 13px;color:var(--muted)}
.search:focus-within{background:var(--surface);border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-ring);color:var(--ink)}
.search input{border:none;background:none;outline:none;flex:1;font-size:13.5px;color:var(--ink)}
.top-actions{margin-left:auto;display:flex;align-items:center;gap:10px}
.icon-btn{width:40px;height:40px;border-radius:var(--radius);border:1px solid var(--line);background:var(--surface);display:grid;place-items:center;cursor:pointer;position:relative;color:var(--ink-soft);text-decoration:none;transition:background .12s,border-color .12s,color .12s}
.icon-btn:hover{background:var(--surface-2);border-color:var(--line-strong);color:var(--ink)}
.icon-btn svg{width:18px;height:18px;display:block}
.icon-btn .dot{position:absolute;top:9px;right:10px;width:8px;height:8px;border-radius:50%;background:var(--red);border:2px solid var(--surface)}
/* Buttons — one component, four variants (primary / secondary / ghost / danger). */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;background:var(--brand);color:#fff;border:1px solid var(--brand);padding:9px 16px;border-radius:var(--radius);font-weight:600;font-size:13.5px;cursor:pointer;font-family:inherit;text-decoration:none;white-space:nowrap;line-height:1.2;transition:background .12s,border-color .12s,color .12s,box-shadow .12s}
.btn:hover{background:var(--brand-hover);border-color:var(--brand-hover)}
.btn:active{background:var(--brand-active);border-color:var(--brand-active)}
.btn svg{width:16px;height:16px;flex:none}
.btn.secondary{background:var(--surface);color:var(--ink);border-color:var(--line-strong)}
.btn.secondary:hover{background:var(--surface-2);border-color:var(--muted)}
.btn.ghost{background:transparent;color:var(--ink-soft);border-color:transparent}
.btn.ghost:hover{background:var(--surface-2);color:var(--ink)}
.btn.danger{background:var(--red);color:#fff;border-color:var(--red)}
.btn.danger:hover{filter:brightness(.94)}
.btn.sm{padding:6px 11px;font-size:12.5px;border-radius:var(--radius-sm)}
/* Ghost-danger: subtle destructive action (inline ✕ / "Supprimer" in tables + forms). */
.btn.ghost.danger{background:transparent;color:var(--red);border-color:transparent}
.btn.ghost.danger:hover{background:var(--red-soft);color:var(--red)}
.btn[disabled],.btn:disabled{opacity:.5;cursor:not-allowed}
/* Compact width modifiers for numeric controls (replace ad-hoc inline widths). */
.input.w-xs{width:92px}.input.w-sm{width:130px}.input.w-md{width:200px}
.content{padding:26px 28px 48px;max-width:1240px;width:100%}
.page-head{display:flex;align-items:flex-end;justify-content:space-between;margin-bottom:22px;flex-wrap:wrap;gap:12px}
.page-head h1{font-size:23px;letter-spacing:-.4px}
.page-head .sub{color:var(--muted);font-size:13.5px;margin-top:3px}
.today{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);padding:18px 20px;margin-bottom:22px;box-shadow:var(--shadow-sm)}
.today-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:14px}
.th-l{display:flex;align-items:center;gap:13px}
.th-ico{width:40px;height:40px;border-radius:var(--radius);background:var(--brand);display:grid;place-items:center;flex:none}
.th-l b{font-size:15px;display:block}
.th-l span{color:var(--ink-soft);font-size:12.5px}
.today-head a{color:var(--brand);font-size:12.5px;text-decoration:none;font-weight:600;cursor:pointer}
.today-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.appt{display:flex;align-items:center;gap:13px;background:var(--surface-2);border:1px solid var(--line);border-radius:var(--radius);padding:13px 15px}
.appt-time{width:64px;flex:none;text-align:center;border-right:1px solid var(--line);padding-right:12px}
.appt-time b{display:block;font-size:17px;font-weight:700;line-height:1.1}
.appt-time span{font-size:11px;color:var(--muted)}
.stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:24px}
.stat{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow-sm)}
.stat .row{display:flex;align-items:center;justify-content:space-between}
.stat .ico{width:42px;height:42px;border-radius:12px;display:grid;place-items:center}
.stat .num{font-size:28px;font-weight:700;letter-spacing:-.5px;margin-top:12px}
.stat .lbl{color:var(--ink-soft);font-size:13px;margin-top:2px}
.trend{font-size:12px;font-weight:600;padding:3px 9px;border-radius:20px}
.t-up{color:var(--green);background:var(--green-soft)}
.t-warn{color:var(--amber);background:var(--amber-soft)}
.t-red{color:var(--red);background:var(--red-soft)}
.grid-2{display:grid;grid-template-columns:1.55fr 1fr;gap:18px}
.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);overflow:hidden}
.panel .ph{display:flex;align-items:center;justify-content:space-between;padding:16px 18px;border-bottom:1px solid var(--line)}
.panel .ph h3{font-size:14.5px;font-weight:650}
.panel .ph a{color:var(--brand);font-size:12.5px;text-decoration:none;font-weight:600}
.list-item{display:flex;align-items:center;gap:13px;padding:13px 18px;border-bottom:1px solid var(--line);cursor:pointer;text-decoration:none;color:inherit}
.list-item:last-child{border-bottom:none}
.list-item:hover{background:#f8fafc}
.ci{width:38px;height:38px;border-radius:10px;display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}
.li-main{flex:1;min-width:0}
.li-main b{font-size:13.5px;font-weight:600;display:block}
.li-main span{color:var(--muted);font-size:12.5px}
/* Badges / pills — one component, status colours only. `.badge` and `.pill` are aliases. */
.pill,.badge{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;padding:3px 10px;border-radius:999px;white-space:nowrap;line-height:1.4}
.p-green{color:var(--green);background:var(--green-soft)}
.p-amber{color:var(--amber);background:var(--amber-soft)}
.p-red{color:var(--red);background:var(--red-soft)}
.p-blue{color:var(--brand);background:var(--brand-soft)}
.p-gray{color:var(--ink-soft);background:#eef1f6}
.p-violet{color:var(--violet);background:var(--violet-soft)}
/* Canonical card (alias of .panel; use for new content). */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-lg);box-shadow:var(--shadow-sm)}
.card.pad{padding:20px}
/* Status text helpers (semantic colour on plain text — e.g. money owed in red). */
.tx-green{color:var(--green)}.tx-amber{color:var(--amber)}.tx-red{color:var(--red)}.tx-blue{color:var(--brand)}
.dl{display:flex;align-items:center;gap:13px;padding:13px 18px;border-bottom:1px solid var(--line)}
.dl:last-child{border-bottom:none}
.dl .when{width:46px;text-align:center;flex:none}
.dl .when b{display:block;font-size:18px;font-weight:700;line-height:1}
.dl .when span{font-size:10.5px;color:var(--muted);text-transform:uppercase}
.progress{height:6px;background:#eef1f6;border-radius:6px;overflow:hidden;margin-top:7px}
.progress i{display:block;height:100%;border-radius:6px}
.toolbar{display:flex;align-items:center;gap:10px;margin-bottom:16px;flex-wrap:wrap}
.seg{display:flex;background:#eef1f6;border-radius:11px;padding:3px}
.seg a{border:none;background:none;padding:7px 14px;border-radius:9px;font-weight:600;font-size:13px;color:var(--ink-soft);cursor:pointer;text-decoration:none}
.seg a.on{background:var(--surface);color:var(--ink);box-shadow:var(--shadow-sm)}
table{width:100%;border-collapse:collapse;background:var(--surface)}
thead th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.5px;color:var(--muted);font-weight:600;padding:12px 18px;border-bottom:1px solid var(--line);background:var(--surface-2)}
tbody td{padding:13px 18px;border-bottom:1px solid var(--line);font-size:13.5px;color:var(--ink)}
tbody tr:last-child td{border-bottom:none}
tbody tr{cursor:pointer}
tbody tr:hover{background:var(--surface-2)}
/* Numeric columns: right-aligned, tabular (money lines up). Add class="num" to th/td. */
th.num,td.num,.num{text-align:right}
td.num,.num{white-space:nowrap}
[dir="rtl"] th.num,[dir="rtl"] td.num{text-align:left}
tfoot td,tfoot th{padding:12px 18px;font-size:13px;border-top:1px solid var(--line-strong)}
.cell-name{display:flex;align-items:center;gap:12px}
.cell-name b{font-weight:600}
.cell-name span{color:var(--muted);font-size:12px;display:block}
.breadcrumb{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;margin-bottom:18px}
.breadcrumb a{color:var(--brand);text-decoration:none;cursor:pointer;font-weight:500}
.breadcrumb .sep{opacity:.5}
.client-head{display:flex;align-items:center;gap:18px;background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:20px;box-shadow:var(--shadow-sm);margin-bottom:20px;flex-wrap:wrap}
.client-head .big-av{width:62px;height:62px;border-radius:16px;display:grid;place-items:center;font-weight:700;font-size:22px;flex:none}
.client-head h2{font-size:19px;letter-spacing:-.3px}
.client-head .meta{color:var(--muted);font-size:13px;margin-top:3px;display:flex;gap:14px;flex-wrap:wrap}
.client-head .meta span{display:flex;align-items:center;gap:5px}
.client-head .ha{margin-left:auto;display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap}
.client-head .ha form{display:inline-flex}
.folders{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-bottom:8px}
.folder{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow-sm);cursor:pointer;transition:transform .12s,box-shadow .12s;text-decoration:none;color:inherit;display:block}
.folder:hover{transform:translateY(-2px);box-shadow:var(--shadow)}
.folder .fic{width:46px;height:46px;border-radius:12px;display:grid;place-items:center;margin-bottom:14px;font-size:20px}
.folder b{font-size:14px;font-weight:650;display:block}
.folder span{color:var(--muted);font-size:12.5px}
/* period archive: collapsible year → month folders (view-level calendar grouping) */
.period-year{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);margin-bottom:12px;overflow:hidden}
.period-year>summary{display:flex;align-items:center;gap:10px;padding:14px 18px;cursor:pointer;font-weight:650;font-size:15px;color:var(--ink);list-style:none}
.period-year>summary::-webkit-details-marker{display:none}
.period-year>summary::before,.period-month>summary::before{content:'';flex:none;width:8px;height:8px;border-right:2px solid var(--muted);border-bottom:2px solid var(--muted);transform:rotate(-45deg);transition:transform .15s;margin-top:-2px}
.period-year[open]>summary::before,.period-month[open]>summary::before{transform:rotate(45deg)}
.period-year>summary .pcount,.period-month>summary .pcount{margin-left:auto;color:var(--muted);font-weight:500;font-size:12.5px}
/* audit month-navigator per-month count: inherit the button's text colour (white when active, ink when ghost) */
.pcount-inline{color:currentColor;opacity:.75;font-weight:500}
.period-year>.pbody{padding:4px 14px 12px}
.period-month{border:1px solid var(--line);border-radius:12px;margin:8px 0;overflow:hidden}
.period-month>summary{display:flex;align-items:center;gap:9px;padding:11px 15px;cursor:pointer;font-weight:600;font-size:13.5px;color:var(--ink-soft);list-style:none}
.period-month>summary::-webkit-details-marker{display:none}
.period-month>.pbody{padding:0 6px 8px}
.period-month>.pbody .table{margin:0}
.section-title{font-size:13px;font-weight:650;color:var(--ink-soft);margin:24px 4px 14px;text-transform:uppercase;letter-spacing:.5px}
.docrow{display:flex;align-items:center;gap:13px;padding:13px 16px;background:var(--surface);border:1px solid var(--line);border-radius:12px;margin-bottom:9px;cursor:pointer}
.docrow:hover{background:#f8fafc}
.docrow .ftype{width:38px;height:46px;border-radius:7px;background:var(--red-soft);color:var(--red);display:grid;place-items:center;font-size:10px;font-weight:700;flex:none}
.docrow .dmeta{flex:1}
.docrow .dmeta b{font-size:13.5px;font-weight:600;display:block}
.docrow .dmeta span{color:var(--muted);font-size:12px}
.ai-tag{display:inline-flex;align-items:center;gap:5px;font-size:11.5px;font-weight:600;color:var(--violet);background:var(--violet-soft);padding:3px 9px;border-radius:20px}
.note{background:var(--brand-soft);border:1px solid #d4e2ff;color:#2b4f9e;border-radius:12px;padding:12px 16px;font-size:12.5px;display:flex;gap:10px;margin:6px 0 22px}
/* forms */
.form-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:24px;max-width:760px}
.form-row{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:16px}
.field{display:flex;flex-direction:column;gap:6px}
.field.full{grid-column:1 / -1}
.field label{font-size:12.5px;font-weight:600;color:var(--ink-soft)}
/* Unified form controls — one style for every input/select/textarea across the app
   (the payments select + amount input adopt these too). */
.input,.select,.textarea,.field input,.field select,.field textarea{
  width:100%;border:1px solid var(--line-strong);border-radius:var(--radius);padding:9px 12px;
  font-size:13.5px;font-family:inherit;color:var(--ink);background:var(--surface);outline:none;
  transition:border-color .12s,box-shadow .12s}
.input:hover,.select:hover,.textarea:hover,.field input:hover,.field select:hover,.field textarea:hover{border-color:var(--muted)}
.input:focus,.select:focus,.textarea:focus,.field input:focus,.field select:focus,.field textarea:focus{
  border-color:var(--brand);box-shadow:0 0 0 3px var(--brand-ring)}
.input::placeholder,.textarea::placeholder,.field input::placeholder,.field textarea::placeholder{color:var(--muted)}
.textarea,.field textarea{resize:vertical}
/* AI suggestion card (flow message composer): themed proposition + aligned action row. */
.ai-suggest{margin-top:10px;background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:12px 14px;box-shadow:var(--shadow-sm)}
.ai-suggest-head{font-size:12px;font-weight:600;color:var(--ink-soft);display:flex;align-items:center;gap:8px;margin-bottom:8px}
.ai-suggest-body{white-space:pre-wrap;background:var(--surface-2);border:1px solid var(--line);border-radius:9px;
  padding:10px 12px;font-size:13px;color:var(--ink);line-height:1.5;max-height:220px;overflow:auto}
.ai-suggest-warn{color:var(--amber,#b7791f);font-size:11.5px;margin-top:8px}
.ai-suggest-actions{display:flex;gap:8px;margin-top:10px}
/* Native select: custom chevron, no OS look. */
.select,.field select{appearance:none;-webkit-appearance:none;padding-right:34px;cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 11px center}
[dir="rtl"] .select,[dir="rtl"] .field select{padding-right:12px;padding-left:34px;background-position:left 11px center}
/* Checkboxes/radios pick up the brand colour. */
input[type=checkbox],input[type=radio]{accent-color:var(--brand);width:16px;height:16px;cursor:pointer}
/* Styled file input (fixes the primitive default). */
input[type=file]{font-size:12.5px;color:var(--ink-soft)}
input[type=file]::file-selector-button{font-family:inherit;font-weight:600;font-size:12.5px;color:var(--ink);background:var(--surface);border:1px solid var(--line-strong);border-radius:var(--radius-sm);padding:7px 12px;margin-right:10px;cursor:pointer;transition:background .12s,border-color .12s}
input[type=file]::file-selector-button:hover{background:var(--surface-2);border-color:var(--muted)}
[dir="rtl"] input[type=file]::file-selector-button{margin-right:0;margin-left:10px}
.form-actions{display:flex;gap:10px;margin-top:8px}
.hint{color:var(--muted);font-size:12px}
/* stats */
.goal-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px;margin-bottom:18px}
.goal{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow-sm)}
.goal .gv{font-size:24px;font-weight:700;margin-top:8px}
.goal .gv small{font-size:14px;color:var(--muted);font-weight:600}
.muted{color:var(--muted)}
.flash{background:var(--green-soft);border:1px solid #bde8d2;color:#157a4c;border-radius:12px;padding:12px 16px;font-size:13px;margin-bottom:18px}
@media(max-width:1000px){.stats,.goal-grid{grid-template-columns:repeat(2,1fr)}.grid-2,.today-grid{grid-template-columns:1fr}.folders{grid-template-columns:repeat(2,1fr)}.form-row{grid-template-columns:1fr}}

/* ---- extra section styles ---- */
.kanban{display:grid;grid-template-columns:repeat(6,1fr);gap:12px;align-items:start}
.kcol{background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:10px;min-height:120px}
.kcol h4{font-size:12px;font-weight:650;color:var(--ink-soft);margin-bottom:10px;display:flex;justify-content:space-between;align-items:center}
.kcol h4 .cnt{background:var(--surface);border:1px solid var(--line);border-radius:20px;padding:1px 8px;font-size:11px;color:var(--muted)}
.kcard{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:11px;margin-bottom:9px;box-shadow:var(--shadow-sm)}
.kcard b{font-size:13px;display:block;margin-bottom:3px}
.kcard span{color:var(--muted);font-size:11.5px;display:block}
.kcard .val{color:var(--green);font-weight:600;font-size:12px;margin-top:5px}
.timeline{position:relative;padding-left:8px}
.tl-item{display:flex;gap:13px;padding:13px 0;border-bottom:1px solid var(--line)}
.tl-ico{width:36px;height:36px;border-radius:10px;background:var(--bg);display:grid;place-items:center;font-size:16px;flex:none}
.summary{display:flex;gap:16px;flex-wrap:wrap;margin-bottom:18px}
.sumcard{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:14px 18px;box-shadow:var(--shadow-sm);min-width:170px}
.sumcard .v{font-size:21px;font-weight:700;margin-top:4px;white-space:nowrap}
.checkbtn{width:24px;height:24px;border-radius:7px;border:1.5px solid var(--line);background:var(--surface);cursor:pointer;display:grid;place-items:center;color:var(--green)}
.checkbtn.done{background:var(--green-soft);border-color:var(--green)}
.mini-form{display:flex;gap:10px;flex-wrap:wrap;align-items:end;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:14px;margin-bottom:18px;box-shadow:var(--shadow-sm)}
.mini-form .field{min-width:150px}
.api-row{display:flex;align-items:center;gap:12px;padding:14px 0;border-bottom:1px solid var(--line)}
.api-row .field{flex:1}
.dotstat{display:inline-block;width:8px;height:8px;border-radius:50%;margin-right:6px}

/* ---- clickable dashboard cards & rows ---- */
a.stat{text-decoration:none;color:inherit;display:block;transition:transform .12s,box-shadow .12s,border-color .12s}
a.stat:hover{transform:translateY(-2px);box-shadow:var(--shadow);border-color:#cdd6e4}
a.stat .lbl .go{opacity:0;color:var(--brand);font-weight:700;transition:opacity .12s;margin-left:2px}
a.stat:hover .lbl .go{opacity:1}
.dl.clk{cursor:pointer}
.dl.clk:hover{background:#eef2f8}

/* reflowing form grid: hidden fields drop out, others fill the row (no gaps) */
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:6px}
.form-grid .full{grid-column:1 / -1}
@media(max-width:1000px){.form-grid{grid-template-columns:1fr}}

/* multi-client checklist */
.checklist{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-height:220px;overflow-y:auto;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:12px}
.chk{display:flex;align-items:center;gap:8px;font-size:13px;background:var(--surface);border:1px solid var(--line);border-radius:9px;padding:8px 10px;cursor:pointer}
.chk input{width:auto}
@media(max-width:1000px){.checklist{grid-template-columns:1fr 1fr}}
/* copyable variable chips */
.varchips{display:flex;flex-wrap:wrap;gap:8px;margin-top:10px}
.varchip{display:inline-flex;align-items:center;gap:6px;background:var(--violet-soft);color:var(--violet);border:1px solid #ddd4fb;border-radius:8px;padding:5px 10px;font-size:12.5px;font-weight:600;cursor:pointer;font-family:inherit}
.varchip:hover{background:#e7e0fb}
.varchip .lbl{color:var(--ink-soft);font-weight:500}
.varchip.copied{background:var(--green-soft);color:var(--green);border-color:#bde8d2}

/* ---- language dropdown ---- */
.langmenu{position:relative}
.langmenu summary{list-style:none;cursor:pointer;font-weight:600;font-size:13px}
.langmenu summary::-webkit-details-marker{display:none}
.langlist{position:absolute;top:48px;right:0;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);padding:6px;min-width:170px;z-index:30;display:flex;flex-direction:column;gap:2px}
.langlist a{padding:9px 12px;border-radius:8px;text-decoration:none;color:var(--ink-soft);font-size:13.5px;display:flex;gap:9px;align-items:center}
.langlist a:hover{background:#f3f6fb;color:var(--ink)}
.langlist a.on{background:var(--brand-soft);color:var(--brand);font-weight:600}

/* ---- RTL (Arabic) ---- */
[dir="rtl"] .sidebar{border-right:none;border-left:1px solid var(--line)}
[dir="rtl"] .nav a .badge{margin-left:0;margin-right:auto}
[dir="rtl"] .top-actions{margin-left:0;margin-right:auto}
[dir="rtl"] .client-head .ha{margin-left:0;margin-right:auto}
[dir="rtl"] .side-foot{padding-left:0;padding-right:8px}
[dir="rtl"] .icon-btn .dot{right:auto;left:10px}
[dir="rtl"] .langlist{right:auto;left:0}
[dir="rtl"] .appt-time{border-right:none;border-left:1px solid var(--line);padding-right:0;padding-left:12px}
[dir="rtl"] .dl .when,[dir="rtl"] .when{text-align:center}
[dir="rtl"] .page-head .sub,[dir="rtl"] .li-main span{direction:rtl}

/* ---- statistics dashboard ---- */
.kpi-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}
.kpi{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:16px 18px;box-shadow:var(--shadow-sm)}
.kpi .lbl{color:var(--ink-soft);font-size:12.5px}
.kpi .v{font-size:23px;font-weight:700;margin-top:6px;letter-spacing:-.4px}
.kpi .sub{color:var(--muted);font-size:11.5px;margin-top:2px}
.charts-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px;margin-bottom:22px}
.chart-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow-sm);padding:18px}
.chart-card h3{font-size:14.5px;font-weight:650;margin-bottom:14px}
.chart-wrap{position:relative;height:270px}
@media(max-width:1000px){.kpi-grid{grid-template-columns:repeat(2,1fr)}.charts-grid{grid-template-columns:1fr}}

/* ---------- Boss-only DGI chat agent (AI_PLAN Task 2) ---------- */
.agent-fab{position:fixed;right:22px;bottom:22px;width:54px;height:54px;border-radius:50%;
  background:var(--brand);color:#fff;border:none;display:grid;place-items:center;cursor:pointer;
  box-shadow:var(--shadow);z-index:60;transition:background .12s,transform .12s}
.agent-fab:hover{background:var(--brand-hover);transform:translateY(-1px)}
.agent-panel{position:fixed;right:22px;bottom:86px;width:380px;max-width:calc(100vw - 32px);
  height:520px;max-height:calc(100vh - 120px);background:var(--surface);border:1px solid var(--line);
  border-radius:var(--radius-lg);box-shadow:var(--shadow);z-index:60;display:flex;flex-direction:column;overflow:hidden}
.agent-panel[hidden]{display:none}
.agent-head{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 16px;
  border-bottom:1px solid var(--line);background:var(--surface-2)}
.agent-title{font-weight:650;font-size:14px}
.agent-sub{font-size:11.5px;margin-top:2px}
.agent-x{background:none;border:none;font-size:22px;line-height:1;color:var(--muted);cursor:pointer;padding:0 4px}
.agent-x:hover{color:var(--ink)}
.agent-log{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:10px}
.agent-msg{font-size:13px;line-height:1.5;padding:10px 12px;border-radius:12px;max-width:88%;word-wrap:break-word}
.agent-bot{background:var(--surface-2);border:1px solid var(--line);color:var(--ink);align-self:flex-start;border-bottom-left-radius:4px}
.agent-user{background:var(--brand);color:#fff;align-self:flex-end;border-bottom-right-radius:4px}
.agent-pending{color:var(--muted);font-style:italic}
.agent-typing{display:inline-flex;gap:5px;align-items:center;padding:12px 14px}
.agent-dot{width:7px;height:7px;border-radius:50%;background:var(--muted);opacity:.4;animation:agentBlink 1.2s infinite ease-in-out}
.agent-dot:nth-child(2){animation-delay:.2s}
.agent-dot:nth-child(3){animation-delay:.4s}
@keyframes agentBlink{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
.agent-send:disabled{opacity:.55;cursor:default}
.agent-err{color:var(--red,#c0392b)}
.agent-src{margin-top:8px;display:flex;flex-wrap:wrap;gap:5px}
.agent-srcchip{display:inline-block;background:var(--violet-soft,#f0ecfb);color:var(--violet,#6b4fd8);
  border:1px solid #ddd4fb;border-radius:7px;padding:2px 7px;font-size:11px;font-weight:600}
.agent-form{display:flex;gap:8px;padding:12px;border-top:1px solid var(--line);background:var(--surface)}
.agent-input{flex:1;min-width:0}
.agent-send{flex:none}
.agent-disabled{padding:14px 16px;border-top:1px solid var(--line);font-size:12.5px}

/* ---------- Settings → Assistant IA (key field + detect result) ---------- */
.api-row.ai-row{align-items:flex-end;flex-wrap:wrap}
.key-input{position:relative;display:flex;align-items:center}
.key-input input{flex:1;padding-right:40px}
.key-eye{position:absolute;right:6px;top:50%;transform:translateY(-50%);background:none;border:none;
  cursor:pointer;font-size:15px;line-height:1;opacity:.55;padding:4px}
.key-eye:hover,.key-eye.on{opacity:1}
[dir="rtl"] .key-input input{padding-right:12px;padding-left:40px}
[dir="rtl"] .key-eye{right:auto;left:6px}
.api-result{font-size:12.5px;font-weight:600}
.api-result.ok{color:var(--green)}
.api-result.err{color:var(--red)}
