:root {
  --ink: #18212f;
  --muted: #627084;
  --line: #dfe5ef;
  --panel: #ffffff;
  --bg: #f5f7fb;
  --primary: #0e7c86;
  --primary-strong: #075e66;
  --accent: #c05621;
  --ok: #138a52;
  --warn: #b7791f;
  --danger: #b42318;
  --shadow: 0 20px 45px rgba(31, 42, 68, .10);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
.shell { min-height: 100vh; display: flex; }
.sidebar { width: 280px; padding: 24px; background: #101820; color: white; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: center; color: white; }
.brand-mark { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; background: var(--primary); font-weight: 800; }
.brand small, .user-card small { display: block; color: #a8b4c4; margin-top: 2px; }
.nav { display: grid; gap: 8px; }
.nav a { color: #eaf0f7; padding: 11px 12px; border-radius: 8px; }
.nav a:hover { background: rgba(255,255,255,.08); }
.user-card { margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: rgba(255,255,255,.05); }
.link-button { border: 0; background: transparent; color: #f7d08a; padding: 8px 0 0; cursor: pointer; }
.danger-text { color: var(--danger); font-weight: 800; padding: 0; }
.actions { display: flex; gap: 12px; align-items: center; }
.actions form { margin: 0; }
.content { flex: 1; padding: 36px; min-width: 0; }
.auth-content { display: grid; place-items: center; background: linear-gradient(135deg, #10202a 0%, #14424a 45%, #f2f5f8 45%); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
h1 { margin: 0; font-size: 34px; line-height: 1.1; }
h2 { margin: 0 0 16px; font-size: 19px; }
.eyebrow { color: var(--accent); font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }
.panel, .form-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: var(--shadow); }
.login-panel { width: min(1120px, calc(100vw - 32px)); display: grid; grid-template-columns: .95fr 1.25fr; gap: 28px; align-items: center; }
.login-copy { color: white; padding: 26px; }
.login-copy h1 { font-size: 46px; max-width: 620px; }
.login-copy p { color: #dbe7ef; font-size: 18px; line-height: 1.6; }
.login-form { min-height: 430px; display: flex; flex-direction: column; justify-content: center; }
.login-forms { display: grid; gap: 16px; align-items: stretch; }
.login-forms .form-card { min-height: 0; }
.register-form { display: grid; gap: 15px; }
.auth-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bot-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ticket-detail { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.metrics article { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 20px; box-shadow: var(--shadow); }
.metrics span { font-size: 36px; font-weight: 850; display: block; }
.metrics small, .muted, .hint { color: var(--muted); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.segmented { display: inline-flex; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; margin: 0 0 18px; }
.segmented a { border-radius: 6px; padding: 9px 12px; color: var(--muted); font-weight: 800; }
.segmented a.active { background: var(--primary); color: white; }
.segmented a span { margin-left: 6px; border-radius: 999px; padding: 2px 7px; background: #eef3f8; color: var(--ink); font-size: 12px; }
.segmented a.active span { background: rgba(255,255,255,.22); color: white; }
.table-wrap { overflow-x: auto; }
.table-filter { display: grid; grid-template-columns: minmax(220px, 360px) auto; gap: 10px 14px; align-items: end; margin: 0 0 14px; }
.table-filter label { grid-column: 1 / -1; color: var(--muted); font-size: 13px; font-weight: 800; }
.table-filter input { min-width: 0; }
.table-filter-count { color: var(--muted); font-weight: 800; font-size: 13px; padding-bottom: 11px; }
.table-filter-empty td { color: var(--muted); text-align: center; font-weight: 750; background: #f9fbfd; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 13px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th.sortable-header { cursor: pointer; user-select: none; position: relative; padding-right: 24px; }
th.sortable-header:hover { color: var(--primary-strong); background: #f7fafc; }
th.sortable-header:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
th.sortable-header::after { content: "↕"; position: absolute; right: 8px; color: #9aa7b8; font-size: 12px; }
th.sortable-header[data-sort-direction="asc"]::after { content: "↑"; color: var(--primary); }
th.sortable-header[data-sort-direction="desc"]::after { content: "↓"; color: var(--primary); }
tbody tr.clickable-row { cursor: pointer; transition: background-color .14s ease, box-shadow .14s ease; }
tbody tr.clickable-row:hover { background: #eef7f8; }
tbody tr.clickable-row.is-selected { background: #dff1f3; box-shadow: inset 4px 0 0 var(--primary); }
tbody tr.clickable-row:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
tbody tr.admin-selected-row { background: #dff1f3; box-shadow: inset 4px 0 0 var(--primary); }
.ticket-row.status-row-pris_en_charge,
.ticket-row.status-row-en_cours,
.ticket-row.status-row-attribue { background: #fff8db; }
.ticket-row.status-row-fermes { background: #e8f2ff; }
.ticket-row.status-row-cloture_utilisateur,
.ticket-row.status-row-cloture_auto,
.ticket-row.status-row-archive { background: #e9f8ef; }
.ticket-row.status-row-pause { background: #f4eadf; }
.ticket-row.status-row-pris_en_charge:hover,
.ticket-row.status-row-en_cours:hover,
.ticket-row.status-row-attribue:hover { background: #ffefad; }
.ticket-row.status-row-fermes:hover { background: #d7eaff; }
.ticket-row.status-row-cloture_utilisateur:hover,
.ticket-row.status-row-cloture_auto:hover,
.ticket-row.status-row-archive:hover { background: #d6f0df; }
.ticket-row.status-row-pause:hover { background: #ead8c6; }
.compact { max-height: 590px; overflow: auto; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-weight: 700; }
.pill, .status { border-radius: 999px; padding: 5px 9px; display: inline-flex; background: color-mix(in srgb, var(--pill, var(--primary)) 16%, white); color: var(--pill, var(--primary)); font-weight: 750; }
.status { background: #edf4f7; color: #1d5661; }
.status.large { font-size: 15px; padding: 8px 12px; }
.private-status { background: #f7e9ff; color: #6a2c86; margin-left: 8px; }
.button { border: 1px solid var(--line); border-radius: 8px; padding: 11px 15px; background: #fff; color: var(--ink); font-weight: 800; cursor: pointer; display: inline-flex; justify-content: center; }
.button.primary { background: var(--primary); color: white; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-strong); }
.icon-button { width: 38px; height: 38px; padding: 0; align-items: center; }
.full { width: 100%; }
.form-stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid #cdd6e3; border-radius: 8px; padding: 11px 12px; font: inherit; color: var(--ink); background: white; }
input.field-dirty:not([type="checkbox"]):not([type="radio"]), select.field-dirty, textarea.field-dirty { border-color: #d66b6b; animation: field-dirty-pulse 1.8s ease-in-out infinite; }
input.field-saved:not([type="checkbox"]):not([type="radio"]), select.field-saved, textarea.field-saved { border-color: #52a86f; box-shadow: 0 0 0 3px rgba(19, 138, 82, .12); }
.field-dirty.check, .field-dirty.service-option { border-color: #d66b6b; animation: field-dirty-pulse 1.8s ease-in-out infinite; }
.field-saved.check, .field-saved.service-option { border-color: #52a86f; background: #f1fbf5; }
.field-change-indicator { justify-self: start; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; background: #fff3f0; color: #9b2c2c; font-size: 0; font-weight: 850; }
.field-change-indicator::before { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-radius: 3px; box-shadow: inset 0 4px 0 rgba(155, 44, 44, .18); transform: rotate(0deg); }
.field-change-indicator::after { content: ""; width: 17px; height: 2px; background: currentColor; margin-left: -15px; transform: rotate(-42deg); transform-origin: center; }
.field-change-indicator.is-saved { background: #effaf4; color: var(--ok); }
.field-change-indicator.is-saved::before { border-radius: 50%; box-shadow: none; }
.field-change-indicator.is-saved::after { width: 8px; height: 4px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; background: transparent; margin-left: -11px; transform: rotate(-45deg); }
@keyframes field-dirty-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, .10); }
  50% { box-shadow: 0 0 0 3px rgba(180, 35, 24, .14); }
}
select.has-priority-color { border-color: var(--priority-color); box-shadow: inset 4px 0 0 var(--priority-color); }
.priority-preview { border-radius: 999px; padding: 5px 9px; display: inline-flex; width: fit-content; background: color-mix(in srgb, var(--pill, var(--primary)) 16%, white); color: var(--pill, var(--primary)); font-weight: 750; }
.pending-attachment-list { border: 1px solid #cbd6ff; border-radius: 8px; background: #f7f9ff; padding: 10px; display: grid; gap: 6px; color: var(--ink); }
.pending-attachment-list strong { font-size: 13px; }
.pending-attachment-item { display: block; color: var(--muted); overflow-wrap: anywhere; font-weight: 650; }
.native-combobox-select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.combobox { position: relative; }
.combobox-input { padding-right: 36px; }
.combobox-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow: auto; border: 1px solid #cdd6e3; border-radius: 8px; background: white; box-shadow: var(--shadow); padding: 4px; }
.combobox-option { width: 100%; border: 0; background: transparent; text-align: left; padding: 10px 11px; border-radius: 6px; cursor: pointer; color: var(--ink); font: inherit; }
.combobox-option:hover, .combobox-option.is-selected { background: #eef7f8; color: var(--primary-strong); }
textarea { resize: vertical; }
.alert { border: 1px solid #f2b8ad; background: #fff3f0; color: var(--danger); padding: 12px; border-radius: 8px; }
.notice { border: 1px solid #d7c48b; background: #fff9e8; color: #6f4b10; padding: 12px 14px; border-radius: 8px; font-weight: 750; line-height: 1.45; }
.toast { border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; font-weight: 750; }
.toast.success { border: 1px solid #b9e5cc; background: #effaf4; color: var(--ok); }
.toast.error { border: 1px solid #f2b8ad; background: #fff3f0; color: var(--danger); }
.upload-zone { border: 1px dashed #aab8ca; border-radius: 8px; padding: 18px; background: #f9fbfd; display: grid; gap: 4px; color: var(--muted); }
.readonly-box { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f9fbfd; display: grid; gap: 6px; align-content: start; }
.readonly-box span { color: var(--muted); }
.privacy-option { border: 1px solid #cbd6ff; border-radius: 8px; background: #f7f9ff; padding: 12px; display: grid; gap: 6px; }
.privacy-option p { margin: 0; }
.details { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 750; }
.ticket-context-panel { margin-bottom: 20px; }
.context-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.context-block { border: 1px solid var(--line); border-radius: 8px; background: #f9fbfd; padding: 14px; display: grid; gap: 5px; min-width: 0; }
.context-block span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.context-block strong { font-size: 16px; overflow-wrap: anywhere; }
.context-block small { color: var(--muted); overflow-wrap: anywhere; }
.inline-select-form { margin: 0; }
.inline-select-form select { min-width: 180px; padding: 8px 10px; }
.context-block .inline-select-form select { min-width: 100%; }
.emergency-fields { border: 1px solid #f0c27a; border-radius: 8px; background: #fff9ec; padding: 14px; display: grid; gap: 12px; }
.timeline { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.timeline article { border-radius: 8px; padding: 14px; max-width: min(760px, 86%); }
.message-event.mine { align-self: flex-end; }
.message-event.theirs { align-self: flex-start; }
.message-event.staff-message { background: #fff3bd; border: 1px solid #efd27a; border-left: 4px solid #d39b16; }
.message-event.client-message { background: #e9f8ef; border: 1px solid #b9e5cc; border-left: 4px solid var(--ok); }
.message-event.mine { box-shadow: 0 10px 24px rgba(31, 42, 68, .08); }
.timeline article.opening-event { border-style: solid; }
.timeline article.internal { background: #fff8f1; border-color: #efc08c; border-left-color: var(--accent); }
.timeline article.system-event { align-self: center; width: min(680px, 100%); max-width: min(680px, 100%); background: #f6f8fb; border: 1px solid var(--line); color: var(--muted); text-align: center; padding: 10px 14px; }
.system-event strong { color: var(--ink); }
.system-event p { margin: 6px 0 0; font-size: 13px; }
.timeline article.attachment-event { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.attachment-event a { border: 1px solid #cbd6ff; border-radius: 8px; padding: 9px 11px; background: white; color: var(--ink); font-weight: 800; display: grid; gap: 2px; min-width: 220px; }
.attachment-event a span { color: var(--muted); font-size: 12px; font-weight: 650; }
.timeline small { display: block; color: var(--muted); margin-top: 3px; }
.comment-form { display: grid; gap: 12px; }
.comment-locked { margin-top: 14px; }
.attachment-list { display: grid; gap: 10px; }
.attachment-list a { border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; justify-content: space-between; gap: 12px; color: var(--ink); background: #f9fbfd; }
.attachment-list span { color: var(--muted); }
.attachment-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.report-panel { margin-bottom: 20px; }
.take-panel { border-color: #b9e5cc; background: #fbfffd; }
.visibility-command { display: grid; gap: 14px; margin-bottom: 20px; justify-items: start; }
.viewer-panel { width: min(760px, 100%); }
.viewer-list { display: grid; gap: 10px; }
.viewer-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f9fbfd; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.viewer-item div { display: grid; gap: 2px; min-width: 0; }
.viewer-item span:not(.status) { color: var(--muted); overflow-wrap: anywhere; }
.ticket-actions { display: grid; gap: 20px; margin-bottom: 20px; }
.admin-command { display: grid; gap: 14px; }
.admin-command-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.action-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.action-row form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(16, 24, 32, .48); display: grid; place-items: center; padding: 22px; }
.modal-panel { width: min(620px, 100%); max-height: calc(100vh - 44px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: var(--shadow); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.service-picker { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 8px; }
.service-picker legend { color: var(--muted); font-weight: 800; padding: 0 6px; }
.service-option { background: #f9fbfd; border: 1px solid var(--line); border-radius: 8px; padding: 10px; color: var(--ink); }
.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.admin-tile { min-height: 140px; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); }
.admin-tile strong { font-size: 20px; }
.admin-tile span { color: var(--muted); }
.muted-tile { opacity: .68; }
.empty-state { width: min(620px, 100%); margin: 80px auto; background: white; border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
@media (max-width: 960px) {
  .shell { display: block; }
  .sidebar { width: auto; height: auto; position: static; }
  .content { padding: 22px; }
  .grid.two, .login-panel, .ticket-detail, .metrics, .admin-grid, .context-grid { grid-template-columns: 1fr; }
  .auth-content { min-height: 100vh; background: #f2f5f8; }
  .login-copy { color: var(--ink); padding: 0; }
  .login-copy p { color: var(--muted); }
  .login-copy h1 { font-size: 34px; }
}
