/* Potez Digital "ledger" tokens, same as the Potez CRM (potez-crm-platform/frontend/app.html). Single light look on purpose. */
:root {
  --page: #F6F4EE; --surface: #FBFAF7; --line: #D8D3C6; --line-strong: #C4BDAD;
  --ink: #0E1E36; --muted: #56606F; --soft: #ECE8DF;
  --success: #1E7350; --success-soft: #E1EDE5;
  --accent-strong: #7A5A00; --accent-soft: #F4EBCF;
  --danger: #B4473F; --danger-strong: #8A2A2A; --danger-soft: #F5E3DF; --danger-edge: #E5C2BB;
  --on-fill: #F6F4EE; --scrim: rgba(14, 30, 54, .32);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-md: 14px; --r-lg: 20px; --shadow-pop: 0 12px 32px rgba(14, 30, 54, .14);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 16px; z-index: 10; }
.skip:focus { left: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.nowrap, td.nowrap { white-space: nowrap; }

/* layout: fixed left nav + workspace */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.3px; padding: 4px 10px 4px; }
.brand span { color: var(--success); margin-left: -5px; }
.office-name { font-size: 13px; color: var(--muted); padding: 0 12px 16px; }
#nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; font-weight: 700; min-height: 44px; text-decoration: none; }
#nav a:hover { background: var(--soft); }
#nav a[aria-current="page"] { background: var(--ink); color: var(--on-fill); }
#nav .count { margin-left: auto; font-size: 12px; background: var(--danger-soft); color: var(--danger-strong); border-radius: 6px; padding: 1px 8px; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.account { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: var(--r-md); background: var(--page); border: 1px solid var(--line); }
.account form { margin: 0; }
.acct { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 4px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: var(--on-fill); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.acct-text { display: flex; flex-direction: column; min-width: 0; line-height: 18px; }
.acct-text b { font-size: 14px; overflow-wrap: anywhere; }
.acct-text small { font-size: 12px; color: var(--muted); }
.acct-out { width: 36px; height: 36px; border-radius: 10px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.acct-out:hover { background: var(--danger-soft); color: var(--danger-strong); }
main { min-width: 0; width: 100%; max-width: 1320px; margin-inline: auto; padding: 28px 32px 64px; outline: none; display: flex; flex-direction: column; gap: 20px; }

.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; }
.eyebrow { font: 700 12px/16px var(--font); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -.3px; margin-top: 6px; }
.h2 { font-size: 18px; line-height: 24px; font-weight: 700; }
.h3 { font-size: 15px; line-height: 20px; font-weight: 700; }
.h3.spaced { margin-top: 20px; }
.sub { margin-top: 4px; color: var(--muted); }
.lbl { font: 600 13px/18px var(--font); color: var(--muted); }
.big { font-size: 34px; line-height: 42px; font-weight: 700; letter-spacing: -.5px; }
.big.bad { color: var(--danger-strong); }
.big .of { font-size: 16px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* buttons + chips (CRM) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 700; font-size: 15px; line-height: 20px; cursor: pointer; min-height: 44px; white-space: nowrap; text-decoration: none; }
.btn.p { background: var(--ink); color: var(--on-fill); }
.btn.g { background: var(--soft); color: var(--ink); }
.btn.o { background: var(--page); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn.d { background: var(--page); color: var(--danger-strong); box-shadow: inset 0 0 0 1px var(--danger-edge); }
.btn.sm { padding: 6px 12px; font-size: 13px; line-height: 18px; min-height: 34px; }
.btn.link { background: none; padding: 2px 4px; min-height: 0; text-decoration: underline; font-weight: 600; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--on-fill); box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 6px; padding: 3px 10px; font: 700 12px/18px var(--font); white-space: nowrap; }
.cg { background: var(--success-soft); color: var(--success); }
.cy { background: var(--accent-soft); color: var(--accent-strong); }
.cr { background: var(--danger-soft); color: var(--danger-strong); }
.cn { background: var(--page); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; margin-right: 5px; }
.due-soon { color: var(--danger-strong); font-weight: 600; font-size: 13px; }

/* cards, tiles, grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card.wide { grid-column: 1 / -1; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.link-tile { text-decoration: none; }
.link-tile:hover { border-color: var(--ink); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.callout { background: var(--success-soft); border-radius: 10px; padding: 10px 14px; }
.empty { padding: 20px; text-align: center; color: var(--muted); font-weight: 600; background: var(--page); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }

/* charts: single series, ink bars, current month muted */
.chart { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 12px; }
.chart .vl { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .bar-g path { fill: var(--ink); }
.chart .bar-g.partial path { fill: var(--muted); }
.chart .bar-g:hover path { opacity: .8; }
.chart details { font-size: 13px; }
.chart summary { cursor: pointer; color: var(--muted); font-weight: 600; }
table.mini { margin-top: 6px; width: auto; }
table.mini td, table.mini th { padding: 4px 12px 4px 0; border: 0; }

/* goal bar with target marker */
.goal { display: flex; align-items: center; gap: 10px; }
.goal .bar { position: relative; flex: 1; height: 12px; background: var(--page); border: 1px solid var(--line-strong); border-radius: 6px; min-width: 80px; }
.goal .bar i { display: block; height: 100%; border-radius: 6px; background: var(--ink); transition: width .4s; }
.goal .bar i.met { background: var(--success); }
.goal .bar b { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--danger-strong); transform: translateX(-1px); }
.goal .num { font-weight: 700; min-width: 3.5em; text-align: right; }

/* lists: activity feed, risk list, tasks */
.feed, .risk, .tasks { list-style: none; margin: 0; padding: 0; }
.feed li, .risk li, .tasks li { display: grid; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.feed li:first-child, .risk li:first-child, .tasks li:first-child { border-top: 0; }
.feed li { grid-template-columns: auto minmax(0, 1fr) auto; }
.feed li.portal .avatar { background: var(--success); }
.feed li.auto .avatar { background: var(--muted); }
.risk li { grid-template-columns: 70px minmax(0, 1fr) auto; }
.tasks li { grid-template-columns: minmax(0, 1fr) auto; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.person { display: flex; gap: 10px; align-items: center; font-weight: 400; }

/* clients table */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; }
button.stat { cursor: pointer; border-top: 4px solid var(--ink); }
button.stat:hover { background: var(--soft); }
button.stat[aria-pressed="true"] { background: var(--ink); color: var(--on-fill); }
button.stat[aria-pressed="true"] span { color: var(--on-fill); }
.stat strong { font-size: 26px; line-height: 32px; }
.stat span { color: var(--muted); font-size: 14px; font-weight: 600; }
.stat .hint { font-size: 12px; font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar .info { color: var(--muted); font-size: 14px; flex: 1; }
.toolbar .inline { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.toolbar .inline select { width: auto; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
.table-wrap.flat { border: 0; border-radius: 0; background: none; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { text-align: left; padding: 14px 16px; font-weight: 700; }
th, td { padding: 10px 12px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
tbody th { font-weight: 400; }
thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); white-space: nowrap; font-weight: 700; }
tbody tr:hover { background: var(--page); }
tbody tr.selected { background: var(--soft); }
tbody tr.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--success-soft); } }
@media (prefers-reduced-motion: reduce) { tbody tr.flash, .pulse { animation: none; } .goal .bar i { transition: none; } }
td.check, th.check { width: 40px; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ink); }
.client-name { font-weight: 700; }
.who { color: var(--ink); }
.docs-list { color: var(--muted); max-width: 22ch; font-size: 13px; }

/* forms */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; background: var(--page); min-height: 42px; width: 100%; }
input[readonly] { color: var(--muted); }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
textarea { min-height: 110px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 700; font-size: 13px; }
.unit { display: flex; align-items: center; gap: 8px; }
.unit span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.cols3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.save-bar { grid-column: 1 / -1; position: sticky; bottom: 0; background: var(--page); padding: 12px 0; border-top: 1px solid var(--line); }

/* client detail */
.back { font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); margin-top: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.seg button { border: 0; background: var(--page); padding: 6px 12px; cursor: pointer; min-height: 36px; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-fill); font-weight: 700; }
.checklist, .deadlines, .rows { list-style: none; margin: 0; padding: 0; }
.checklist label, .deadlines label { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.deadlines li, .rows li { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.deadlines li:first-child, .rows li:first-child { border-top: 0; }

/* notices, automation */
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.recipients { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 4px 12px; max-height: 420px; overflow-y: auto; background: var(--page); }
.recipients label, .radios label, .switch { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.recipients label + label { border-top: 1px solid var(--line); }
.recipients input, .radios input, .switch input { margin-top: 2px; flex: none; }
.radios { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 8px; margin: 0; }
.radios legend { font-weight: 700; padding: 0 4px; }
.radios:disabled { opacity: .6; }
.next { background: var(--soft); border-radius: 10px; padding: 10px 14px; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* dialog + toast */
dialog.dlg { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--shadow-pop); color: var(--ink); background: var(--surface); }
dialog.dlg::backdrop { background: var(--scrim); }
.dlg-body { padding: 20px 24px; display: grid; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--page); position: sticky; bottom: 0; }
.from-note { background: var(--soft); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.mail { border: 1px solid var(--line); border-radius: 10px; background: var(--page); }
.mail dl { margin: 0; padding: 10px 14px; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.mail dt { color: var(--muted); }
.mail dd { margin: 0; overflow-wrap: anywhere; }
.mail pre { margin: 0; padding: 14px; white-space: pre-wrap; font: inherit; font-size: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--on-fill); padding: 12px 18px; border-radius: 10px; max-width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-pop); opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.show { opacity: 1; }

/* login */
.login-wrap { min-height: 100vh; max-width: none; display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); gap: 14px; }
.login .brand { padding: 0; }
.error { background: var(--danger-soft); color: var(--danger-strong); border-radius: 10px; padding: 10px 14px; }

/* tablet */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .office-name { display: none; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .account { margin: 0 0 0 auto; }
  main { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* sidebar client search */
.search { padding: 0 4px 12px; }
.search input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--page); }

/* horizontal bars (breakdowns) */
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 5.5em; gap: 12px; align-items: center; font-size: 14px; }
.hbars .hb { height: 10px; background: var(--page); border-radius: 5px; overflow: hidden; }
.hbars .hb i { display: block; height: 100%; background: var(--ink); border-radius: 5px; }
.hbars .num { text-align: right; font-weight: 700; }

/* goals dialog */
.goal-edit { list-style: none; margin: 0; padding: 0; }
.goal-edit li { display: grid; grid-template-columns: 1fr minmax(140px, 220px) 4em; gap: 4px 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.goal-edit li:first-child { border-top: 0; }
.goal-edit input[type=range] { width: 100%; accent-color: var(--ink); }
.goal-edit output { font-weight: 700; text-align: right; }
.goal-edit .gb { grid-column: 1 / -1; }

/* integrations */
.conn-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.conn { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.conn .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; flex: none; }
.conn ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.conn .btn { align-self: start; margin-top: auto; }
.conn-head { display: flex; gap: 12px; align-items: start; }
.conn-head b { display: inline-block; margin-bottom: 4px; }
.callout.warn { background: var(--accent-soft); color: var(--ink); }
.callout.warn a { font-weight: 700; margin-left: 6px; }

/* document upload */
.upload { display: grid; gap: 12px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 16px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-md); background: var(--page); cursor: pointer; text-align: center; }
.drop:hover, .drop.over { border-color: var(--ink); background: var(--soft); }
#up-file:focus-visible + .drop { outline: 2px solid var(--ink); outline-offset: 2px; }
.picked { font-weight: 600; font-size: 14px; color: var(--success); overflow-wrap: anywhere; }
.up-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.up-fields .field { flex: 1 1 200px; }
.search input::-webkit-calendar-picker-indicator { display: none !important; }
