:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --ink: #1a1f36;
  --ink-2: #4b5168;
  --muted: #7a8099;
  --line: #e4e6ee;
  --line-2: #eef0f5;
  --brand: #15224c;
  --brand-ink: #ffffff;
  --accent: #0fbed1;
  --accent-ink: #0a7d8c;
  --link: #0a7d8c;
  --brand-soft: #e5f8fa;
  --side: #15224c;
  --side-ink: #c3c9dc;
  --ok: #2f9e6b;
  --ok-soft: #e6f6ee;
  --warn: #d9822b;
  --warn-soft: #fdf1e3;
  --over: #d6455d;
  --over-soft: #fdeaee;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 26, 51, .05), 0 1px 1px rgba(20, 26, 51, .03);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14.5px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; margin-bottom: 14px; }
h3 { font-size: 15px; font-weight: 650; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.warn-text { color: var(--warn); }
.over-text { color: var(--over); font-weight: 600; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 22px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; flex: none; }
.brand-text { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-text small { display: block; font-weight: 500; font-size: 12px; color: var(--side-ink); opacity: .8; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a, .sidebar-foot > a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); font-weight: 500; }
.sidebar nav a svg { width: 18px; height: 18px; fill: currentColor; opacity: .75; flex: none; }
.sidebar nav a:hover, .sidebar-foot > a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.sidebar nav a.active svg { opacity: 1; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; }
.sidebar-foot .avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.sidebar-foot .who { line-height: 1.2; color: #fff; font-size: 13.5px; }
.sidebar-foot .who small { display: block; color: var(--side-ink); font-size: 12px; }
.sidebar-foot form { padding: 4px 10px; }
.sidebar-foot .link-btn { color: var(--side-ink); font-size: 13px; }
.main { padding: 28px 34px 60px; min-width: 0; max-width: 1400px; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { margin: 6px 0 12px; }

/* ---------- Cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin-bottom: 0; }
.card-head a { font-size: 13px; white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-wide-left { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.narrow { max-width: 640px; }
.note-card { background: #fffbea; border-color: #f3e6b0; }
.empty { text-align: center; padding: 48px 20px; }
.empty-small { color: var(--muted); margin: 6px 0; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); box-shadow: var(--shadow); }
.kpi:hover { border-color: #cdd3e6; text-decoration: none; }
.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi strong { display: block; font-size: 26px; margin-top: 4px; font-weight: 700; letter-spacing: -.02em; }
.kpi-accent { background: var(--brand-soft); border-color: #b3ebf1; }
.kpi-accent strong { color: var(--accent-ink); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f8fb; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #22336b; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,.04); }
.btn-danger { background: var(--surface); color: var(--over); border-color: #f2c3cc; }
.btn-danger:hover { background: var(--over-soft); }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--over); }
form.inline { display: inline; }

/* ---------- Forms ---------- */
.form label { display: block; font-weight: 550; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.form label > input, .form label > select, .form label > textarea, .filters input, .filters select, .comment-form textarea, .comment-form select { display: block; width: 100%; margin-top: 5px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #d5d9e5; border-radius: 8px; padding: 8px 11px; min-height: 36px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 190, 209, .25); }
input:disabled { background: #f4f5f8; color: var(--muted); }
.form .check, .check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink-2); font-size: 13.5px; }
.check input { width: 16px; height: 16px; min-height: 0; margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-error { color: var(--over); font-weight: 500; margin-left: 6px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.chips { display: flex; gap: 6px; margin: -6px 0 14px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: #f7f8fb; border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.chips button:hover { border-color: var(--accent); color: var(--accent-ink); }
.compact-form { border-top: 1px solid var(--line-2); margin-top: 14px; padding-top: 14px; }
.compact-form h3 { margin-bottom: 10px; font-size: 14px; }
.danger-zone { margin-top: 8px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.segmented strong { display: block; color: var(--ink); font-size: 14px; }
.segmented small { color: var(--muted); font-weight: 500; }
.segmented input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
[data-type-label] { display: none; }
#packageForm[data-type="bank"] [data-type-label="bank"], #packageForm[data-type="monthly"] [data-type-label="monthly"] { display: revert; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 14px 16px; }
.filters label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); min-width: 130px; }
.filters label.grow { flex: 1; min-width: 200px; }
.filters label.check { min-width: 0; padding-bottom: 8px; }
.filters-actions { display: flex; gap: 6px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }
.row-link:hover td { background: #fafbfd; }
.table-compact td, .table-compact th { padding: 6px 8px; font-size: 13px; }
.table-summary { margin: 0 0 10px; color: var(--ink-2); }
tr.inactive td, li.inactive { opacity: .55; }
.pager { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.pager a { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 7px; border: 1px solid var(--line); color: var(--ink-2); padding: 0 8px; }
.pager a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .gap { color: var(--muted); padding: 0 4px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f5; color: var(--ink-2); white-space: nowrap; vertical-align: 1px; }
.badge-new { background: #e7f0ff; color: #2f5bd3; }
.badge-in_progress { background: #fff4e0; color: #b26a12; }
.badge-waiting { background: #f1eafe; color: #7046c9; }
.badge-resolved { background: var(--ok-soft); color: #23805a; }
.badge-prio-high { background: var(--warn-soft); color: #b8681b; }
.badge-prio-urgent { background: var(--over-soft); color: var(--over); }
.badge-prio-low { background: #f1f3f6; color: var(--muted); }
.badge-src { background: var(--brand-soft); color: var(--accent-ink); }
.badge-internal { background: #fff6d6; color: #8a6d00; }
.badge-state-ok { background: var(--ok-soft); color: #23805a; }
.badge-state-warn { background: var(--warn-soft); color: #b8681b; }
.badge-state-over { background: var(--over-soft); color: var(--over); }
.badge-state-expired, .badge-state-upcoming { background: #eef0f5; color: var(--muted); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-ink); background: var(--brand-soft); border-radius: 6px; padding: 2px 7px; }

/* ---------- Flash ---------- */
.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--ok-soft); border-color: #bfe5d1; color: #1d6b4b; }
.flash-error { background: var(--over-soft); border-color: #f3c3cc; color: #a8293f; }
.flash-info { background: var(--brand-soft); border-color: #b3ebf1; color: var(--accent-ink); }

/* ---------- Gauges ---------- */
.gauge { margin: 6px 0 2px; }
.gauge-bar { height: 8px; background: #eceef4; border-radius: 99px; overflow: hidden; }
.gauge-bar span { display: block; height: 100%; border-radius: 99px; background: var(--ok); transition: width .4s; }
.gauge-warn .gauge-bar span { background: var(--warn); }
.gauge-over .gauge-bar span { background: var(--over); }
.gauge-expired .gauge-bar span, .gauge-upcoming .gauge-bar span { background: #b7bccb; }
.gauge-text { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.gauge-big .gauge-bar { height: 12px; }
.gauge-big .gauge-text { font-size: 14px; margin-top: 8px; }
.mini-pkg { margin: 2px 0 8px; font-size: 12.5px; }
.mini-pkg:last-child { margin-bottom: 0; }

.pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; margin-bottom: 4px; }
.pkg-card h3 { margin-top: 8px; font-size: 17px; }
.pkg-card .card-head p { margin: 2px 0 0; font-size: 13px; }
.pkg-card.state-warn { border-top: 3px solid var(--warn); }
.pkg-card.state-over { border-top: 3px solid var(--over); }
.pkg-card.state-ok { border-top: 3px solid var(--ok); }
.months { margin-top: 14px; }
.months summary { cursor: pointer; color: var(--link); font-size: 13px; font-weight: 550; margin-bottom: 8px; }

.watch-list { list-style: none; margin: 0; padding: 0; }
.watch-list li { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.watch-list li:last-child { border-bottom: 0; }
.watch-list li > span { display: block; font-size: 12.5px; }

/* ---------- Client hero ---------- */
.pkg-hero h2 { font-size: 20px; margin: 10px 0 2px; }
.pkg-hero > .muted { margin: 0; }
.pkg-month { font-weight: 650; margin: 12px 0 0; }
.donut-row { display: flex; align-items: center; gap: 28px; margin: 18px 0 8px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut circle { fill: none; stroke-width: 12; }
.donut-bg { stroke: #eceef4; }
.donut-fg { stroke: var(--ok); stroke-linecap: round; }
.state-warn .donut-fg { stroke: var(--warn); }
.state-over .donut-fg { stroke: var(--over); }
.donut-big { font-size: 22px; font-weight: 750; fill: var(--ink); letter-spacing: -.02em; }
.donut-small { font-size: 11px; fill: var(--muted); }
.pkg-figures { margin: 0; display: grid; gap: 10px; flex: 1; min-width: 180px; }
.pkg-figures div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.pkg-figures dt { color: var(--muted); }
.pkg-figures dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.notice { border-radius: 8px; padding: 9px 12px; font-weight: 500; margin: 10px 0 0; }
.notice-warn { background: var(--warn-soft); color: #9a5714; }
.notice-over { background: var(--over-soft); color: #a8293f; }

.ticket-list, .plain-list, .user-list { list-style: none; margin: 0; padding: 0; }
.ticket-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.ticket-list li:last-child { border-bottom: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.plain-list li:last-child { border-bottom: 0; }
.user-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.user-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12.5px; white-space: nowrap; }

/* ---------- Ticket detail ---------- */
.prose { white-space: normal; word-wrap: break-word; color: var(--ink); }
.details { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; font-weight: 500; }
.details dd.big { font-size: 20px; font-weight: 700; }
.thread { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.thread li { background: #f7f8fb; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; }
.thread li.from-client { background: var(--brand-soft); border-color: #c6eef3; }
.thread li.internal { background: #fffbea; border-color: #f3e6b0; }
.thread-meta { font-size: 13px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment-actions { display: flex; gap: 14px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.comment-actions select { width: auto; margin: 0; }

.key-reveal { border-color: #bfe5d1; background: var(--ok-soft); }
.key { display: block; background: #fff; border: 1px solid #bfe5d1; border-radius: 8px; padding: 10px 12px; font-size: 14px; word-break: break-all; user-select: all; }

/* ---------- Auth ---------- */
.public { background: radial-gradient(1200px 600px at 10% -10%, #d6f4f7, transparent), var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: 0 10px 40px rgba(20, 26, 51, .08); }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card > p.muted { margin: 0 0 20px; }
.brand-center { justify-content: center; color: var(--ink); padding-bottom: 24px; }
.auth-links { text-align: center; margin: 16px 0 0; font-size: 13.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-wide-left, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .brand-text small { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .sidebar nav a { padding: 7px 9px; font-size: 13px; }
  .sidebar-foot { border: 0; padding: 0; margin-left: auto; display: flex; align-items: center; }
  .sidebar-foot .who { display: none; }
  .main { padding: 18px 14px 40px; }
  .row-2, .segmented { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 20px; }
}

/* Ajustements */
.form label.check > input, .filters label.check > input { display: inline-block; width: 16px; height: 16px; min-height: 0; margin: 0; flex: none; }
.user-list li { flex-direction: column; gap: 4px; }
.user-actions { flex-direction: row; gap: 14px; align-items: center; }
.user-actions form { display: inline; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.pkg-figures { max-width: 480px; }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); }
.steps li { margin-bottom: 6px; }
.pkg-children { list-style: none; margin: 14px 0 4px; padding: 12px 0 0; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.pkg-child-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.pkg-children .gauge { margin: 4px 0 0; }
.pkg-children .gauge-bar { height: 5px; }

/* Identité Web Omega */
.brand-logo { display: block; padding: 4px 8px 22px; }
.brand-logo img { display: block; width: 100%; max-width: 190px; height: auto; }
.brand-logo small { display: block; color: var(--side-ink); font-size: 12px; margin-top: 8px; letter-spacing: .02em; }
.brand-logo:hover { text-decoration: none; }
.sidebar nav a.active { box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-foot .avatar { background: var(--accent); color: var(--brand); }
.auth-logo { display: block; margin: 0 auto 26px; width: 230px; max-width: 100%; height: auto; }
.pager a.active { background: var(--brand); border-color: var(--brand); }
@media (max-width: 760px) {
  .brand-logo { padding: 0 8px 0 0; }
  .brand-logo img { max-width: 140px; }
  .brand-logo small { display: none; }
}
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.watch-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.reason { font-weight: 600; }
.reason-0 { color: var(--over); }
.reason-1, .reason-2 { color: var(--warn); }
.card-links { display: flex; gap: 14px; font-size: 13px; white-space: nowrap; }

/* Graphique heures par mois */
.usage-legend { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin: -4px 0 8px; }
.usage-budget { display: inline-flex; align-items: center; gap: 8px; }
.usage-budget i { display: inline-block; width: 22px; border-top: 2px dashed var(--ink-2); }
.usage-chart { display: block; width: 100%; height: auto; overflow: visible; }
.usage-chart .grid { stroke: var(--line-2); stroke-width: 1; }
.usage-chart .baseline { stroke: #c9cedd; stroke-width: 1; }
.usage-chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.usage-chart .fill { fill: var(--accent); }
.usage-chart .bar.current .fill { fill: #7fdbe6; }
.usage-chart .hit { fill: transparent; }
.usage-chart .bar:hover .fill { fill: var(--brand); }
.usage-chart .bar:hover .hit { fill: rgba(21, 34, 76, .04); }
.usage-chart .budget { stroke: var(--ink-2); stroke-width: 2; stroke-dasharray: 6 5; pointer-events: none; }
.usage-table { margin-top: 8px; }
.usage-table summary { cursor: pointer; color: var(--link); font-size: 13px; font-weight: 550; }
.usage-table table { margin-top: 8px; max-width: 420px; }
