@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface-1: #ffffff;
  --surface-2: #f2f3f8;
  --surface-3: #e9ebf3;
  --border: #e6e8f0;
  --text-primary: #111322;
  --text-secondary: #4b5068;
  --text-muted: #8a8fa6;
  --grid: #eef0f5;
  --accent: #5b4cf0;
  --accent-2: #2a78d6;
  --accent-soft: #eeecfe;
  --accent-ink: #4535d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --critical: #d03b3b;
  --critical-soft: #fdecec;
  --good: #0ca30c;
  --shadow-sm: 0 1px 2px rgba(17, 19, 34, .04), 0 1px 3px rgba(17, 19, 34, .05);
  --shadow-md: 0 4px 24px -6px rgba(17, 19, 34, .10), 0 2px 6px rgba(17, 19, 34, .04);
  --shadow-lg: 0 24px 60px -12px rgba(30, 20, 90, .25);
  --sidebar-bg: #0f1020;
  --sidebar-ink: #a9acc6;
  --sidebar-ink-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(124, 108, 255, .18);
  --radius: 16px;
  --radius-sm: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0c14;
    --surface-1: #151624;
    --surface-2: #1c1d2e;
    --surface-3: #25273b;
    --border: #262839;
    --text-primary: #f1f2f8;
    --text-secondary: #b8bbd0;
    --text-muted: #7f839c;
    --grid: #232536;
    --accent: #7c6cff;
    --accent-2: #3987e5;
    --accent-soft: #24214a;
    --accent-ink: #b3a9ff;
    --series-1: #3987e5;
    --series-2: #d95926;
    --critical-soft: #3a1b1f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 6px 24px -6px rgba(0, 0, 0, .5);
    --sidebar-bg: #0a0b12;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c14;
  --surface-1: #151624;
  --surface-2: #1c1d2e;
  --surface-3: #25273b;
  --border: #262839;
  --text-primary: #f1f2f8;
  --text-secondary: #b8bbd0;
  --text-muted: #7f839c;
  --grid: #232536;
  --accent: #7c6cff;
  --accent-2: #3987e5;
  --accent-soft: #24214a;
  --accent-ink: #b3a9ff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --critical-soft: #3a1b1f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 24px -6px rgba(0, 0, 0, .5);
  --sidebar-bg: #0a0b12;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text-primary);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-primary, button.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0;
  border-radius: 10px; padding: 9px 16px; font-weight: 600;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.btn-block { width: 100%; padding: 12px 16px; }
.btn-ghost, button.ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-1); color: var(--text-secondary); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; font-weight: 500; transition: background .12s, color .12s;
}
.btn-ghost:hover:not(:disabled), button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text-primary); }
.btn-danger, button.danger {
  background: var(--critical-soft); color: var(--critical); border: 1px solid transparent;
  border-radius: 10px; padding: 7px 12px; font-weight: 600;
}
.btn-danger:hover { border-color: var(--critical); }
.chip-btn {
  background: var(--surface-2); color: var(--text-secondary); border: 0; border-radius: 999px;
  padding: 4px 11px; font-size: 12px; font-weight: 600;
}
.chip-btn:hover { background: var(--surface-3); color: var(--text-primary); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: 0; color: inherit;
}
.icon-btn:hover { background: var(--sidebar-hover); }

input, select {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s; min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.muted { color: var(--text-muted); }
.error { color: var(--critical); min-height: 1.2em; margin: 4px 0 0; font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ------------------------------------------------------------------ login */
.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 16px; overflow: hidden;
  background: radial-gradient(1200px 600px at 10% -10%, #2b1f7a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #0d4a8f 0%, transparent 55%), #0b0c18;
}
.login-bg span { position: fixed; border-radius: 50%; filter: blur(70px); opacity: .55; pointer-events: none; }
.login-bg span:nth-child(1) { width: 380px; height: 380px; background: #6d5dfc; top: -80px; left: 12%; }
.login-bg span:nth-child(2) { width: 320px; height: 320px; background: #2a78d6; bottom: -60px; right: 10%; }
.login-bg span:nth-child(3) { width: 220px; height: 220px; background: #c04fd8; top: 55%; left: -60px; opacity: .35; }
.login-card {
  position: relative; width: 100%; max-width: 400px; padding: 36px 32px 28px;
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: 22px; box-shadow: var(--shadow-lg);
}
.login-logo { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); margin-bottom: 18px; }
.login-card h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.login-card > p { margin: 6px 0 0; }
.login-card form { display: flex; flex-direction: column; gap: 16px; margin-top: 26px; }
.login-card input { padding: 12px 14px; }
.btn-primary.loading .btn-label::after { content: "…"; }

/* ------------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  background: var(--sidebar-bg); color: var(--sidebar-ink); padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px; color: var(--sidebar-ink-strong); }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand small { display: block; color: var(--sidebar-ink); font-size: 12px; }
#tabs { display: flex; flex-direction: column; gap: 3px; flex: 1; }
#tabs button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: transparent; color: var(--sidebar-ink); border: 0; border-radius: 10px; padding: 10px 12px; font-weight: 500;
  transition: background .12s, color .12s;
}
#tabs button:hover { background: var(--sidebar-hover); color: var(--sidebar-ink-strong); }
#tabs button.active { background: var(--sidebar-active); color: var(--sidebar-ink-strong); box-shadow: inset 3px 0 0 #8d7fff; }
#tabs button.active svg { color: #a99eff; }
#tabs button[hidden] { display: none; }
.side-foot { border-top: 1px solid rgba(255,255,255,.07); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 6px; min-width: 0; }
.me strong { display: block; color: var(--sidebar-ink-strong); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { display: block; font-size: 12px; text-transform: capitalize; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #6d5dfc, #2a78d6); color: #fff; font-weight: 700; text-transform: uppercase;
}
.side-actions { display: flex; gap: 4px; padding: 0 2px; }
.side-actions .icon-btn { color: var(--sidebar-ink); }
.side-actions .icon-btn:hover { color: #fff; }

.content { min-width: 0; }
.pagehead {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 12px;
  padding: 18px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.pagehead h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.pagehead p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.menu-btn { display: none; color: var(--text-primary); }
.menu-btn:hover { background: var(--surface-2); }
.scrim { display: none; }
main { padding: 24px 32px 56px; max-width: 1560px; }
h2.section {
  display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 650; margin: 34px 0 14px;
  color: var(--text-primary); letter-spacing: -.01em;
}
h2.section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
h2.section:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; gap: 14px; align-items: flex-start; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tile .ico {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
}
.tile .ico svg { width: 20px; height: 20px; }
.tile .body { min-width: 0; }
.tile .label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; }
.tile .value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.tile .note { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

/* ------------------------------------------------------------------ cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 18px; }
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; min-width: 0; box-shadow: var(--shadow-sm);
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 12px; }
.card-head h3 { font-size: 14px; font-weight: 600; margin: 0; letter-spacing: -.005em; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 380px; }
.legend { display: flex; gap: 16px; color: var(--text-secondary); font-size: 12.5px; margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.empty { color: var(--text-muted); padding: 36px 0; text-align: center; }
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 80px 0; color: var(--text-muted); text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .tile:hover { transform: none; } }

/* ------------------------------------------------------------------ tables */
.tbl-wrap { overflow: auto; max-height: 440px; border-radius: var(--radius-sm); }
.tbl-wrap.free { max-height: none; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.wrap { white-space: normal; min-width: 200px; }
th {
  color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  position: sticky; top: 0; background: var(--surface-1); z-index: 1;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-primary); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.selected td { background: var(--accent-soft) !important; color: var(--accent-ink); font-weight: 600; }
td .null { color: var(--text-muted); font-style: italic; opacity: .7; }
td .masked { color: var(--text-muted); letter-spacing: .05em; }
.cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: block; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 600; }
.badge.grey { background: var(--surface-2); color: var(--text-secondary); }

/* ------------------------------------------------------------------ explorer */
.explorer { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.explorer .list { max-height: calc(100vh - 260px); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 160px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 16px; height: 16px; }
.search input { width: 100%; padding-left: 34px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 14px; color: var(--text-secondary); flex-wrap: wrap; }
.pill { display: inline-flex; gap: 6px; align-items: center; color: var(--text-muted); font-size: 12.5px; }

.banner {
  display: flex; gap: 10px; align-items: center;
  background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--radius-sm);
  padding: 12px 16px; margin-bottom: 18px; font-size: 13px;
}
dialog {
  background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border);
  border-radius: 18px; padding: 24px; width: min(92vw, 400px); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(10, 10, 25, .45); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h3 { margin: 0 0 4px; font-size: 18px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) { .explorer { grid-template-columns: 1fr; } .explorer .list { max-height: 320px; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 30; left: 0; top: 0; width: 260px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(10,10,25,.45); }
  .menu-btn { display: inline-grid; }
  .pagehead { padding: 12px 16px; }
  main { padding: 18px 16px 48px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 12px; }
  .tile { padding: 14px; gap: 10px; }
  .tile .ico { width: 36px; height: 36px; }
  .tile .value { font-size: 19px; }
}

/* ================================================================== invoices module */
:root {
  --tone-good-bg: #e3f6e6; --tone-good-ink: #11772a;
  --tone-warn-bg: #fff1d6; --tone-warn-ink: #8a5300;
  --tone-bad-bg: #fde8e8; --tone-bad-ink: #b42323;
  --tone-info-bg: #e3eefc; --tone-info-ink: #1d5fb4;
  --tone-violet-bg: #eeecfe; --tone-violet-ink: #4535d6;
  --tone-grey-bg: #eef0f5; --tone-grey-ink: #4b5068;
  --tone-muted-bg: #f2f3f8; --tone-muted-ink: #8a8fa6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tone-good-bg: #12301b; --tone-good-ink: #6fd98a;
    --tone-warn-bg: #362810; --tone-warn-ink: #f2bd5e;
    --tone-bad-bg: #3a1b1f; --tone-bad-ink: #ff8a8a;
    --tone-info-bg: #142a47; --tone-info-ink: #7fb5f5;
    --tone-violet-bg: #24214a; --tone-violet-ink: #b3a9ff;
    --tone-grey-bg: #25273b; --tone-grey-ink: #b8bbd0;
    --tone-muted-bg: #1c1d2e; --tone-muted-ink: #7f839c;
  }
}
:root[data-theme="dark"] {
  --tone-good-bg: #12301b; --tone-good-ink: #6fd98a;
  --tone-warn-bg: #362810; --tone-warn-ink: #f2bd5e;
  --tone-bad-bg: #3a1b1f; --tone-bad-ink: #ff8a8a;
  --tone-info-bg: #142a47; --tone-info-ink: #7fb5f5;
  --tone-violet-bg: #24214a; --tone-violet-ink: #b3a9ff;
  --tone-grey-bg: #25273b; --tone-grey-ink: #b8bbd0;
  --tone-muted-bg: #1c1d2e; --tone-muted-ink: #7f839c;
}
.badge.tone-good { background: var(--tone-good-bg); color: var(--tone-good-ink); }
.badge.tone-warn { background: var(--tone-warn-bg); color: var(--tone-warn-ink); }
.badge.tone-bad { background: var(--tone-bad-bg); color: var(--tone-bad-ink); }
.badge.tone-info { background: var(--tone-info-bg); color: var(--tone-info-ink); }
.badge.tone-violet { background: var(--tone-violet-bg); color: var(--tone-violet-ink); }
.badge.tone-grey { background: var(--tone-grey-bg); color: var(--tone-grey-ink); }
.badge.tone-muted { background: var(--tone-muted-bg); color: var(--tone-muted-ink); text-decoration: line-through; }
.badge { white-space: nowrap; }

.inv-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.inv-search { flex: 1 1 320px; }
.inv-search input { padding-top: 11px; padding-bottom: 11px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg button { background: transparent; border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 500; color: var(--text-secondary); }
.seg button.on { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow-sm); font-weight: 600; }
.count-pill { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }

.status-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.status-chip {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface-1);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
  transition: background .12s, border-color .12s, color .12s;
}
.status-chip:hover { border-color: var(--text-muted); color: var(--text-primary); }
.status-chip .n { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 600; }
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-chip.tone-good .dot { background: var(--tone-good-ink); }
.status-chip.tone-warn .dot { background: var(--tone-warn-ink); }
.status-chip.tone-bad .dot { background: var(--tone-bad-ink); }
.status-chip.tone-info .dot { background: var(--tone-info-ink); }
.status-chip.tone-violet .dot { background: var(--tone-violet-ink); }
.status-chip.tone-grey .dot, .status-chip.tone-muted .dot { background: var(--tone-muted-ink); }
.status-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.status-chip.on .n { color: var(--accent-ink); }

.adv-panel { margin-bottom: 14px; }
.adv-panel[hidden] { display: none; }
.adv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.adv-grid fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px 14px; margin: 0; min-width: 0; }
.adv-grid legend { font-weight: 650; font-size: 12.5px; color: var(--text-secondary); padding: 0 6px; }
.adv-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 10px; }
.adv-fields .field > span { font-size: 12px; }
.adv-fields input, .adv-fields select { width: 100%; padding: 7px 10px; }

.active-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.active-tags:empty { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 4px 3px 11px; font-size: 12.5px; max-width: 100%;
}
.tag.ctx { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.tag button { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.tag button:hover { background: var(--surface-3); }
.tag svg { width: 13px; height: 13px; }

.inv-tiles { margin-bottom: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.inv-tiles .tile .value { font-size: 19px; }
.tile.tile-bad .ico { background: var(--tone-bad-bg); color: var(--tone-bad-ink); }

.inv-card { position: relative; transition: opacity .15s; }
.inv-card.busy { opacity: .6; pointer-events: none; }
.inv-card.busy::after {
  content: ""; position: absolute; top: 18px; right: 20px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.inv-wrap { margin: 0 -8px; }
.inv-table td { vertical-align: top; }
.inv-table .cell-main { display: flex; align-items: center; gap: 6px; }
.inv-table .clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.inv-table .sub, table .sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; display: flex; gap: 4px; align-items: center; }
.sub svg { width: 12px; height: 12px; }
.inv-table td.wrap-sm { white-space: normal; min-width: 110px; max-width: 160px; font-size: 12.5px; }
.inv-table td.actions { white-space: nowrap; text-align: right; }
.strong { font-weight: 650; }
.late { color: var(--tone-bad-ink); font-weight: 600; }
.link { color: var(--accent-ink); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.link.strong { font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.link-chip {
  display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--tone-info-bg); color: var(--tone-info-ink);
  font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.link-chip.slot { background: var(--tone-violet-bg); color: var(--tone-violet-ink); }
.link-chip:hover { filter: brightness(.95); text-decoration: underline; }
.more { font-size: 12px; }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 8px; color: var(--text-secondary); }
.icon-btn.sm:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn.sm svg { width: 16px; height: 16px; }
a.btn-ghost, a.chip-btn { text-decoration: none; }

/* drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 10, 25, .38); opacity: 0; pointer-events: none; transition: opacity .18s; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(880px, 100vw); display: flex; flex-direction: column;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease; outline: none; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
body.drawer-lock { overflow: hidden; }
.drawer-top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.crumbs { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: center; font-size: 12.5px; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--accent-ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .cur { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--text-muted); }
.drawer-body { flex: 1; overflow: auto; padding: 20px 24px 40px; }
.sheet-head { margin-bottom: 14px; }
.sheet-head .kicker { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sheet-head .title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0; }
.sheet-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.sheet-actions { margin-top: 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs button {
  background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; font-weight: 500;
  color: var(--text-secondary); white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.on { color: var(--accent-ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { background: var(--surface-3); color: var(--text-secondary); border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.sheet-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sheet-sec { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; min-width: 0; }
.sheet-sec h4 { margin: 0 0 10px; font-size: 13px; font-weight: 650; }
.sheet-sec .empty { padding: 14px 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; margin: 0;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; }
.facts dt { color: var(--text-muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.amounts { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 16px; }
.amounts > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-variant-numeric: tabular-nums; }
.amounts > div:last-child { border-bottom: 0; }
.amounts span { color: var(--text-secondary); }
.amounts .total { font-size: 16px; border-bottom-style: solid; }
.amounts .total span { color: var(--text-primary); font-weight: 600; }
.amounts .due strong { color: var(--tone-bad-ink); }
.amounts .ok strong { color: var(--tone-good-ink); }
.rel-list { display: flex; flex-direction: column; gap: 10px; }
.rel-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.rel-card.slim { padding: 9px 12px; }
.sheet-sec .rel-card { background: var(--surface-2); border-color: transparent; }
.rel-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rel-amt { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }
.rel-meta { color: var(--text-secondary); font-size: 12.5px; margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rel-meta svg, .slot-when svg { width: 14px; height: 14px; color: var(--text-muted); }
.rel-actions { margin-top: 10px; gap: 6px; }
.slot-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.slot-time { display: inline-flex; gap: 4px; align-items: center; background: var(--tone-violet-bg); color: var(--tone-violet-ink); border-radius: 6px; padding: 1px 8px; font-weight: 600; font-size: 12.5px; }
.slot-time svg { color: inherit; }
.via { margin-left: auto; color: var(--text-muted); font-size: 11.5px; font-style: italic; }
.remark { white-space: pre-line; margin: 8px 0 0; color: var(--text-secondary); font-size: 13px; overflow-wrap: anywhere; }
.slot-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.slot-hero > div, .mini-tiles > div { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.slot-hero span, .mini-tiles span { display: block; color: var(--text-muted); font-size: 12px; }
.slot-hero strong, .mini-tiles strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini-tiles .due strong { color: var(--tone-bad-ink); }
.partner { display: flex; flex-direction: column; gap: 5px; }
.partner .line { display: flex; gap: 8px; align-items: flex-start; color: var(--text-secondary); font-size: 13px; }
.partner .line svg { width: 15px; height: 15px; margin-top: 2px; color: var(--text-muted); }
table.mini th, table.mini td { padding: 7px 10px; }
table.mini tfoot td { border-top: 1px solid var(--border); border-bottom: 0; }
tr.section-row td { background: var(--surface-2); font-weight: 650; }
tr.note-row td { color: var(--text-muted); font-style: italic; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 14px; }
.timeline > li { position: relative; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.timeline > li::before { content: ""; position: absolute; left: -23px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.tl-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.tl-head .badge { margin-left: auto; }
.tracking { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }

.print-sheet { display: none; }

@media (max-width: 860px) {
  .sheet-cols { grid-template-columns: 1fr; }
  .drawer-body { padding: 16px 16px 40px; }
}
/* table → stacked cards on phones */
@media (max-width: 760px) {
  .inv-search { flex-basis: 100%; }
  .inv-wrap { margin: 0; }
  .inv-table thead { display: none; }
  .inv-table, .inv-table tbody, .inv-table tr, .inv-table td { display: block; width: 100%; }
  .inv-table tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 8px 12px; }
  .inv-table tbody tr:hover td { background: transparent; }
  .inv-table td { border: 0; padding: 4px 0; white-space: normal; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .inv-table td.num { text-align: right; }
  .inv-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
  .inv-table td > div { min-width: 0; }
  .inv-table td.wrap-sm { max-width: none; }
  .inv-table td.actions { justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 6px; }
  .inv-table .clip { max-width: 60vw; }
  .inv-table .cell-main, .inv-table .chips, .inv-table .sub { justify-content: flex-end; }
  .mini-tiles { grid-template-columns: 1fr 1fr; }
}

/* print: only the invoice sheet */
@media print {
  html.printing body > *:not(.print-sheet) { display: none !important; }
  html.printing .print-sheet { display: block; color: #000; background: #fff; font-size: 12px; }
  .print-sheet .p-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
  .print-sheet .p-company { font-size: 18px; font-weight: 700; }
  .print-sheet .p-title { text-align: right; }
  .print-sheet h1 { font-size: 20px; margin: 0 0 6px; }
  .print-sheet .p-client { margin: 0 0 20px auto; width: 45%; border: 1px solid #ccc; border-radius: 6px; padding: 10px 12px; }
  .print-sheet table { width: 100%; border-collapse: collapse; }
  .print-sheet th, .print-sheet td { border-bottom: 1px solid #ddd; padding: 6px 8px; color: #000; position: static; background: #fff; }
  .print-sheet td.wrap { white-space: normal; }
  .print-sheet .p-totals { margin: 16px 0 0 auto; width: 45%; }
  .print-sheet .p-totals > div { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #eee; }
  .print-sheet .muted { color: #555; }
  .print-sheet .p-foot { margin-top: 30px; font-size: 10px; }
}
.inv-table th, .inv-table td { padding: 9px 10px; }
.inv-table .clip { max-width: 190px; }
.inv-table .sub.late { color: var(--tone-bad-ink); }
@media (max-width: 760px) {
  .inv-tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .inv-tiles .tile:first-child { grid-column: 1 / -1; }
  .inv-tiles .tile { padding: 12px; }
  .inv-tiles .tile .ico { display: none; }
  .inv-tiles .tile .value { font-size: 16px; }
  .facts { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
.inv-tiles .tile .value { font-size: 18px; white-space: nowrap; }
.inv-table td.wrap-sm .sub { display: block; }
.inv-table { font-size: 12.5px; }
.inv-table th, .inv-table td { padding: 8px 8px; }
.inv-table .clip { max-width: 160px; }
.inv-table .sub.num-sub { justify-content: flex-end; }
.inv-table td.wrap-sm { min-width: 0; max-width: 130px; }
@media (max-width: 760px) { .inv-table .clip { max-width: 60vw; } .inv-table td.wrap-sm { max-width: none; } }
.inv-table .clip { max-width: 150px; }
.inv-table tbody td:first-child, .inv-table thead th:first-child { position: sticky; left: 0; background: var(--surface-1); z-index: 1; }
.inv-table thead th:first-child { z-index: 2; }
.inv-table tbody tr:hover td:first-child { background: var(--surface-2); }
@media (max-width: 760px) { .inv-table tbody td:first-child { position: static; background: transparent; } }
.inv-table td:first-child { max-width: 150px; }
.inv-table td:first-child .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) { .inv-table td:first-child { max-width: none; } }
.inv-table td:first-child .cell-main { flex-wrap: wrap; row-gap: 2px; }
.inv-tiles .tile .value { font-size: 17px; }
@media print { html.printing, html.printing body { background: #fff; } }

/* ================================================================== devis / planning / grouping (v2) */
.company-quick { max-width: 230px; }
.inv-toolbar .seg button { display: inline-flex; align-items: center; gap: 6px; }
.inv-toolbar .seg svg { width: 15px; height: 15px; }
.adv-fields.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.icon-btn.xs { width: 22px; height: 18px; border-radius: 5px; color: var(--text-muted); }
.icon-btn.xs svg { width: 14px; height: 14px; }
.icon-btn.xs:hover:not(:disabled) { background: var(--surface-3); color: var(--text-primary); }
.icon-btn.xs:disabled { opacity: .3; }
textarea {
  font: inherit; color: inherit; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 11px; width: 100%; resize: vertical; min-height: 38px;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.tile.tile-bad .value { color: var(--tone-bad-ink); }

/* invoices grouped by company */
.co-groups { display: flex; flex-direction: column; gap: 10px; }
.co-group { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-1); overflow: hidden; }
.co-head {
  width: 100%; display: grid; grid-template-columns: 22px minmax(160px, 1fr) auto; align-items: center; gap: 12px;
  background: var(--surface-2); border: 0; padding: 12px 14px; text-align: left; color: inherit;
}
.co-head:hover { background: var(--surface-3); }
.co-chev svg { transition: transform .15s; color: var(--text-muted); }
.co-head[aria-expanded="true"] .co-chev svg { transform: rotate(90deg); }
.co-name { display: flex; flex-direction: column; min-width: 0; }
.co-name strong { font-size: 15px; }
.co-name .muted { font-size: 12.5px; }
.co-stats { display: flex; gap: 18px; flex-wrap: wrap; justify-content: flex-end; }
.co-stat { display: flex; flex-direction: column; align-items: flex-end; min-width: 92px; }
.co-stat span { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.co-stat strong { font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.co-stat.strong strong { font-size: 15px; }
.co-stat.due strong { color: var(--tone-bad-ink); }
.co-stat.ok strong { color: var(--tone-good-ink); }
.co-body { padding: 4px 8px 10px; }
.co-body.busy { opacity: .6; }
.co-body .pager { margin-top: 8px; }
@media (max-width: 860px) {
  .co-head { grid-template-columns: 22px 1fr; }
  .co-stats { grid-column: 1 / -1; justify-content: flex-start; gap: 10px 16px; }
  .co-stat { align-items: flex-start; min-width: 80px; }
}

/* modal */
dialog.modal { width: min(96vw, 560px); padding: 0; display: flex; flex-direction: column; max-height: 92vh; }
dialog.modal:not([open]) { display: none; }
dialog.modal.wide { width: min(96vw, 1120px); }
dialog.modal.busy { cursor: progress; }
dialog.modal.busy .modal-body { opacity: .7; pointer-events: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 16px 20px; overflow: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.confirm-msg { margin: 0 0 8px; }
.conflicts { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.conflicts li { margin: 3px 0; }
.conflict-box { border: 1px solid var(--tone-bad-ink); background: var(--tone-bad-bg); color: var(--tone-bad-ink); border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0; }
.conflict-box[hidden] { display: none; }
.conflict-box .strong { display: flex; align-items: center; gap: 6px; }
.conflict-box a { color: inherit; }

/* toasts */
.toasts { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: 13.5px; transition: opacity .3s, transform .3s; }
.toast.tone-good svg { color: var(--tone-good-ink); }
.toast.tone-bad { border-color: var(--tone-bad-ink); }
.toast.tone-bad svg { color: var(--tone-bad-ink); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* autocomplete */
.combo { position: relative; min-width: 0; }
.combo input { width: 100%; }
.combo-list { position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow: auto;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); }
.combo-list[hidden] { display: none; }
.combo-list li { padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.combo-list li.on, .combo-list li:hover { background: var(--accent-soft); }
.combo-main { font-weight: 500; }
.combo-sub { font-size: 12px; color: var(--text-muted); }
.combo-empty { color: var(--text-muted); cursor: default !important; }

/* column chooser */
.col-chooser { position: relative; }
.col-pop { position: absolute; z-index: 30; right: 0; top: calc(100% + 6px); width: 220px; padding: 12px; box-shadow: var(--shadow-md); }
.col-pop[hidden] { display: none; }
.col-opt { display: flex; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; }
.col-opt input { width: auto; }

/* quote editor */
.q-head-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.q-head-grid .span2 { grid-column: span 2; }
.q-head-grid input, .q-head-grid select { width: 100%; }
.q-sub { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
.q-lines-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.q-lines { width: 100%; }
.q-lines th { white-space: nowrap; }
.q-lines td { vertical-align: top; padding: 6px; }
.q-lines input, .q-lines select { width: 100%; padding: 6px 8px; }
.q-lines .num-in { width: 86px; text-align: right; }
.q-lines select { min-width: 150px; }
.q-prod { min-width: 260px; width: 40%; }
.q-prod textarea { margin-top: 6px; font-size: 13px; }
.q-handle { width: 40px; color: var(--text-muted); white-space: nowrap; }
.q-handle .grip { cursor: grab; display: inline-grid; vertical-align: top; padding-top: 6px; }
.q-arrows { display: inline-flex; flex-direction: column; }
.q-total { padding-top: 12px !important; white-space: nowrap; }
.q-del { width: 40px; }
.q-section td { background: var(--surface-2); }
.q-section input { font-weight: 650; }
.q-note input { font-style: italic; }
.q-lines tr.dragging { opacity: .4; }
.q-lines tr.drop-target td { box-shadow: inset 0 2px 0 var(--accent); }
.q-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; margin-top: 14px; align-items: start; }
.q-totals { margin: 0; }
.p-sign { margin-top: 30px; border: 1px dashed #999; padding: 12px; min-height: 80px; width: 50%; margin-left: auto; font-size: 11px; }
@media (max-width: 860px) {
  .q-head-grid { grid-template-columns: 1fr 1fr; }
  .q-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .q-head-grid { grid-template-columns: 1fr; } .q-head-grid .span2 { grid-column: auto; } }

/* planning */
.plan-toolbar { justify-content: space-between; }
.plan-nav { gap: 6px; }
.plan-period { font-weight: 650; font-size: 15px; margin-left: 6px; text-transform: capitalize; }
.plan-modes { flex-wrap: wrap; }
.plan-card { padding: 12px; }
.plan-card.busy { opacity: .6; }
.plan-hint { font-size: 12px; margin: 10px 2px 0; }
:root { --t1: #2a78d6; --t2: #0ca30c; --t3: #8a5cf0; --t4: #d03b3b; --t5: #e08a00; --t6: #0e9aa7; --t7: #8a6a4a; --t0: #6b7088; }
.ev {
  --c: var(--t0); position: relative; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 13%, var(--surface-1));
  border-radius: 6px; padding: 3px 6px; font-size: 11.5px; line-height: 1.3; overflow: hidden; cursor: pointer; user-select: none; margin-bottom: 3px;
}
.ev:hover { background: color-mix(in srgb, var(--c) 22%, var(--surface-1)); }
.ev.t1, .badge.type.t1 { --c: var(--t1); } .ev.t2, .badge.type.t2 { --c: var(--t2); } .ev.t3, .badge.type.t3 { --c: var(--t3); }
.ev.t4, .badge.type.t4 { --c: var(--t4); } .ev.t5, .badge.type.t5 { --c: var(--t5); } .ev.t6, .badge.type.t6 { --c: var(--t6); } .ev.t7, .badge.type.t7 { --c: var(--t7); }
.badge.type { --c: var(--t0); background: color-mix(in srgb, var(--c) 15%, var(--surface-1)); color: color-mix(in srgb, var(--c) 75%, var(--text-primary)); }
.ev-top { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-top svg { width: 12px; height: 12px; flex: none; }
.ev-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.st-cancel { opacity: .5; text-decoration: line-through; }
.ev.st-done { background: color-mix(in srgb, var(--c) 7%, var(--surface-2)); }
.ev.clash { outline: 2px solid var(--critical); outline-offset: -1px; }
.ev.clash .ev-top svg:first-child { color: var(--critical); }
.ev.dragging { opacity: .75; box-shadow: var(--shadow-md); z-index: 5; cursor: grabbing; }
.ev-abs { position: absolute; margin: 0; }
.ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.tg { --days: 7; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: auto; max-height: calc(100vh - 330px); min-height: 420px; }
.tg-head { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: 54px repeat(var(--days), minmax(120px, 1fr)); background: var(--surface-1); border-bottom: 1px solid var(--border); }
.tg-day { padding: 8px; font-size: 12.5px; font-weight: 600; text-transform: capitalize; border-left: 1px solid var(--grid); }
.tg-day.today { color: var(--accent-ink); background: var(--accent-soft); }
.tg-body { display: grid; grid-template-columns: 54px 1fr; }
.tg-gutter { background: var(--surface-1); }
.tg-hour { font-size: 11px; color: var(--text-muted); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.tg-cols { display: grid; grid-template-columns: repeat(var(--days), minmax(120px, 1fr)); }
.tg-col { position: relative; border-left: 1px solid var(--grid); }
.tg-col.today { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
.tg-cell { position: absolute; left: 0; right: 0; border-top: 1px solid var(--grid); }
.mo { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.mo-head { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.mo-cell { min-height: 112px; padding: 4px; border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); min-width: 0; }
.mo-cell.out { background: var(--surface-2); }
.mo-cell.out .mo-num { opacity: .5; }
.mo-cell.today { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.mo-num { font-size: 12px; font-weight: 650; margin-bottom: 3px; }
.mo-more { font-size: 11px; padding: 2px 8px; }
.drop-target { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft) !important; }
.bd-wrap { max-height: calc(100vh - 330px); }
.bd { table-layout: fixed; min-width: 980px; }
.bd th, .bd td { vertical-align: top; border-left: 1px solid var(--grid); }
.bd thead th { text-transform: capitalize; position: sticky; top: 0; z-index: 2; background: var(--surface-1); }
.bd .bd-name { width: 170px; position: sticky; left: 0; z-index: 1; background: var(--surface-1); text-align: left; }
.bd thead .bd-name { z-index: 3; }
.bd-cell { min-height: 60px; height: 60px; padding: 4px !important; }
.bd .today { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
tr.is-cancel td { opacity: .55; }
.plan-edit-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tech-box { display: flex; flex-wrap: wrap; gap: 6px; max-height: 170px; overflow: auto; margin-top: 8px; padding: 2px; }
.tech-opt { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.tech-opt input { width: auto; margin: 0; }
.tech-opt.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.avail { margin-top: 10px; font-size: 12.5px; }
.avail-row { padding: 3px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.avail .busy { background: var(--tone-warn-bg); color: var(--tone-warn-ink); border-radius: 6px; padding: 1px 6px; }
.avail .free { background: var(--tone-good-bg); color: var(--tone-good-ink); border-radius: 6px; padding: 1px 6px; }
.row.nowrap { flex-wrap: nowrap; }
.dur { padding-top: 9px; }
.dur.late { color: var(--tone-bad-ink); }
.plan-edit-cols .combo { margin-bottom: 8px; }
@media (max-width: 860px) {
  .plan-edit-cols { grid-template-columns: 1fr; }
  .tg-head, .tg-cols { grid-template-columns: 54px repeat(var(--days), minmax(110px, 1fr)); }
  .tg-cols { grid-template-columns: repeat(var(--days), minmax(110px, 1fr)); }
  .mo-cell { min-height: 80px; }
  .mo .ev-top { font-size: 10.5px; }
}
@media print { html.printing .p-sign { border-color: #999; } }
/* v2 polish */
.mod-quotes .inv-tiles, .mod-plan .inv-tiles { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.mod-quotes .inv-tiles .tile, .mod-plan .inv-tiles .tile { padding: 14px; gap: 10px; }
.mod-quotes .inv-tiles .tile .ico, .mod-plan .inv-tiles .tile .ico { width: 34px; height: 34px; }
.mod-quotes .inv-tiles .tile .value, .mod-plan .inv-tiles .tile .value { font-size: 17px; }
.mod-quotes .inv-table .clip { max-width: 140px; }
.plan-period { text-transform: none; }
.plan-period::first-letter { text-transform: uppercase; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); cursor: pointer; text-transform: capitalize; }
button.link:hover { text-decoration: underline; }
.tg-head { grid-template-columns: 54px repeat(var(--days), minmax(150px, 1fr)); }
.tg-cols { grid-template-columns: repeat(var(--days), minmax(150px, 1fr)); }
.tg-body { min-width: calc(54px + var(--days) * 150px); }
.tg-head { min-width: calc(54px + var(--days) * 150px); }
.row.nowrap input[type=time] { flex: 1; min-width: 118px; }
.q-sec-wrap { display: flex; align-items: center; gap: 8px; }
.q-sec-wrap input { flex: 1; min-width: 0; }
.bd th.bd-name { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text-primary); }
.bd th.bd-name .sub { font-weight: 500; color: var(--text-muted); font-size: 11.5px; }
.btn-danger { display: inline-flex; align-items: center; gap: 6px; }
.mod-plan.searching .plan-nav button { opacity: .4; pointer-events: none; }
.sub button.link { text-transform: none; font-size: inherit; }

/* Planning drawer: Paiements + Chronologie tabs */
.pay-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 4px; }
@media (max-width: 760px) { .pay-tiles { grid-template-columns: 1fr 1fr; } }
.chrono-tools { gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chrono-tools select { max-width: 100%; }
.chrono-subject { font-weight: 600; font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }
.timeline > li.chrono-note::before { background: var(--tone-info-ink, var(--accent)); }
.timeline details { margin-top: 6px; font-size: 13px; }
.timeline details summary { cursor: pointer; color: var(--accent-ink); }
.tabs button { white-space: nowrap; }
