:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #17242c;
  --muted: #60727d;
  --line: #dce5e9;
  --line-strong: #c8d5da;
  --teal: #0a7280;
  --teal-dark: #075561;
  --teal-soft: #e4f5f6;
  --blue: #315b9b;
  --blue-soft: #eaf0fb;
  --green: #237a53;
  --green-soft: #e7f5ee;
  --amber: #a16207;
  --amber-soft: #fff6dc;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 12px 34px rgba(29, 52, 61, 0.08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(10, 114, 128, 0.08), transparent 30rem),
    var(--bg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-header {
  height: 74px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto minmax(280px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #0a8190, #075561);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 18px rgba(10, 114, 128, 0.2);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.mode-switch {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}
.mode-button {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 8px;
  padding: 8px 20px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
  text-decoration: none;
}
.mode-button.active { color: var(--teal-dark); background: white; box-shadow: 0 2px 8px rgba(29,52,61,.1); }

.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 700;
}
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #28a66a; box-shadow: 0 0 0 3px rgba(40,166,106,.12); }

.primary-button, .secondary-button, .ghost-button {
  border-radius: 9px;
  padding: 9px 14px;
  font-weight: 700;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.primary-button { border: 1px solid var(--teal); color: white; background: var(--teal); }
.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line-strong); color: var(--ink); background: white; }
.secondary-button:hover { border-color: #9aabb3; background: #f9fbfc; }
.ghost-button { border: 1px solid transparent; color: var(--teal-dark); background: transparent; }
.ghost-button:hover { background: var(--teal-soft); }

main { min-height: calc(100vh - 74px); }

.empty-state {
  width: min(800px, calc(100% - 40px));
  margin: 8vh auto 0;
  padding: 44px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--teal-dark);
  background: var(--teal-soft);
  font-family: var(--mono);
  font-weight: 800;
}
.empty-state h2 { margin: 0; font-size: 29px; letter-spacing: -.03em; }
.empty-state > p { margin: 10px 0 26px; color: var(--muted); }
.paste-input {
  width: 100%;
  height: 190px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 16px;
  color: var(--ink);
  background: #fbfcfd;
  font: 13px/1.55 var(--mono);
  text-align: left;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(29,52,61,.03);
}
.paste-input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(10,114,128,.1); }
.empty-actions { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }
.privacy-note { margin-top: 22px; color: var(--muted); font-size: 12px; }

.workspace { padding: 16px 20px 24px; }
.context-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 12px;
}
.message-identity, .workspace-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.identity-chip {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: white;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}
.identity-chip.strong { color: white; background: var(--teal); border-color: var(--teal); }
.client-label { color: var(--muted); font-size: 12px; font-weight: 700; }
select, input[type="search"], .compare-options input {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  outline: none;
}
select:focus, input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,114,128,.1); }

.insight-strip {
  display: grid;
  grid-template-columns: 110px 130px 120px 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card, .main-insight {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 11px 14px;
}
.stat-card span { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.stat-card small { color: var(--muted); font-size: 11px; }
.stat-card.attention span { color: var(--amber); }
.main-insight { display: flex; align-items: center; color: var(--muted); font-size: 13px; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(420px, .95fr);
  gap: 12px;
  min-height: calc(100vh - 242px);
}
.panel { background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 8px 26px rgba(29,52,61,.05); overflow: hidden; }
.message-panel, .investigation-panel { min-width: 0; }
.panel-toolbar { min-height: 75px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-toolbar h2 { margin: 0; font-size: 16px; }
.panel-toolbar p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.search-wrap { min-width: 290px; display: flex; align-items: center; gap: 8px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel-soft); }
.search-wrap input { width: 100%; border: 0; padding: 9px 0; background: transparent; box-shadow: none; }
kbd { color: #7b8d97; background: white; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 2px 5px; font: 10px var(--sans); }
.search-feedback { padding: 8px 16px; color: var(--teal-dark); background: var(--teal-soft); border-bottom: 1px solid #cbe6e8; font-size: 12px; }

.raw-message {
  height: calc(100vh - 330px);
  min-height: 430px;
  overflow: auto;
  padding: 10px 0 28px;
  background: #fbfcfd;
  font: 13px/1.75 var(--mono);
  tab-size: 2;
}
.segment-row {
  display: grid;
  grid-template-columns: 42px minmax(max-content, 1fr);
  min-width: max-content;
  border-left: 3px solid transparent;
  transition: background .1s ease, border-color .1s ease;
}
.segment-row:hover, .segment-row.selected { background: #eef8fa; border-left-color: var(--teal); }
.segment-row.linked-highlight { background: #d8f1f3; border-left-color: var(--teal); box-shadow: inset 0 0 0 1px #9ed8dc; }
.segment-row.search-hidden { display: none; }
.line-number { padding: 2px 10px 2px 0; color: #a1afb6; text-align: right; user-select: none; }
.segment-code { padding-right: 24px; white-space: pre; }
.segment-name { color: var(--blue); font-weight: 850; }
.raw-separator { color: #96a5ad; }
.field-token { border-radius: 4px; padding: 2px 1px; outline: 1px solid transparent; transition: background .1s ease, outline-color .1s ease; }
.field-token:hover { color: #064f59; background: #d9f1f3; outline-color: #acdadd; }
.field-token.selected { color: #064f59; background: #c7e9ed; outline-color: var(--teal); }
.field-token.linked-highlight { color: #064f59; background: #bde5e8; outline-color: var(--teal); }
.field-token.empty { display: inline-block; min-width: 7px; min-height: 1em; background: repeating-linear-gradient(135deg, #f4f6f7, #f4f6f7 2px, #e8edef 2px, #e8edef 4px); }
.field-token.search-match { background: #fff1a8; outline-color: #e2bf34; }
.missing-segment-row { min-width: max-content; color: #8f281f; background: #fff0ee; border-left-color: var(--red); box-shadow: inset 0 0 0 1px #f0bbb6; }
.missing-segment-row .segment-code { padding: 3px 24px 3px 0; font-family: var(--sans); font-weight: 750; }
.missing-segment-row .segment-name { color: var(--red); }

.context-inspector { min-height: 178px; padding: 16px 18px; background: linear-gradient(145deg, #f6fbfc, #ffffff 70%); border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.context-inspector h2 { margin: 7px 0 5px; font-size: 19px; letter-spacing: -.02em; }
.context-inspector > p { margin: 0; color: var(--muted); font-size: 13px; }
.context-meta { display: grid; grid-template-columns: minmax(120px, .7fr) 1fr; gap: 8px; margin-top: 13px; }
.context-meta > div { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.context-meta small { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.context-meta strong { display: block; margin-top: 3px; font-size: 12px; word-break: break-word; }
.expectation-badge { display: inline-flex; margin-top: 11px; padding: 6px 9px; border-radius: 7px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 750; }
.expectation-badge.required { color: var(--red); background: var(--red-soft); }
.expectation-badge.attendu, .expectation-badge.tolere { color: var(--green); background: var(--green-soft); }
.expectation-badge.bug_connu { color: var(--amber); background: var(--amber-soft); }
.expectation-badge.not_used { color: var(--muted); background: #edf1f3; }
.expectation-badge.recommended { color: var(--blue); background: var(--blue-soft); }
.expectation-detail { margin-top: 10px; padding: 10px; border-left: 3px solid var(--teal); border-radius: 0 8px 8px 0; background: white; }
.expectation-detail small { display: block; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.expectation-detail strong { display: block; margin-top: 3px; font-size: 12px; line-height: 1.4; }

.tab-list { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.tab-button { border: 0; border-bottom: 2px solid transparent; padding: 9px 10px 10px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 750; }
.tab-button.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.tab-button span { display: inline-grid; place-items: center; min-width: 19px; height: 19px; margin-left: 4px; padding: 0 5px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-size: 10px; }
.tab-content { height: calc(100vh - 530px); min-height: 270px; overflow: auto; padding: 12px; }

.finding-card { padding: 12px; margin-bottom: 8px; border: 1px solid var(--line); border-left: 4px solid #9aabb3; border-radius: 10px; background: white; cursor: pointer; }
.finding-card:hover, .finding-card:focus-visible { border-color: #80bbc0; background: #f7fcfc; box-shadow: 0 4px 12px rgba(29,52,61,.08); outline: none; }
.finding-card.erreur { border-left-color: var(--red); }
.finding-card.inhabituel, .finding-card.bug-connu { border-left-color: #d69a24; }
.finding-card.conforme { border-left-color: #42a478; }
.finding-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.finding-head strong { font-size: 13px; }
.category-badge { padding: 4px 7px; border-radius: 6px; color: var(--muted); background: #eef2f4; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.finding-card p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.finding-origin { margin-top: 7px; color: #7d8e97; font-size: 10px; }
.empty-panel { padding: 28px 18px; color: var(--muted); text-align: center; }

.summary-section { margin-bottom: 12px; }
.summary-section h3 { margin: 0 0 7px; color: var(--teal-dark); font-size: 10px; letter-spacing: .1em; }
.summary-line { width: 100%; display: flex; justify-content: space-between; gap: 16px; padding: 9px 10px; border: 0; border-bottom: 1px solid #edf1f3; color: var(--ink); background: white; text-align: left; }
.summary-line:hover { background: var(--teal-soft); }
.summary-line span { color: var(--muted); font-size: 11px; }
.summary-line strong { text-align: right; font-size: 12px; }

.structure-segment { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.structure-segment > button { width: 100%; display: flex; justify-content: space-between; padding: 9px 10px; border: 0; color: var(--ink); background: #f7f9fa; text-align: left; }
.structure-segment > button:hover { background: var(--teal-soft); }
.structure-segment small { color: var(--muted); }
.structure-fields { padding: 4px 8px 8px; }
.structure-field { width: 100%; display: grid; grid-template-columns: 90px 1fr; gap: 8px; padding: 6px; border: 0; color: var(--ink); background: white; text-align: left; font-size: 11px; }
.structure-field:hover { background: var(--teal-soft); }
.structure-field code { color: var(--blue); font-weight: 700; }

.field-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.field-table th { position: sticky; top: -12px; z-index: 2; padding: 8px; color: var(--muted); background: #f4f7f8; border-bottom: 1px solid var(--line); text-align: left; }
.field-table td { max-width: 230px; padding: 8px; border-bottom: 1px solid #edf1f3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-table tr { cursor: pointer; }
.field-table tbody tr:hover { background: var(--teal-soft); }
.field-table code { color: var(--blue); font-weight: 700; }

.hover-tooltip { position: fixed; z-index: 100; width: min(330px, calc(100vw - 28px)); padding: 11px 12px; color: white; background: #142b33; border: 1px solid #254752; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.22); pointer-events: none; }
.hover-tooltip strong { display: block; font-size: 12px; }
.hover-tooltip span { display: block; margin-top: 3px; color: #c8dadd; font-size: 10px; line-height: 1.4; }
.hover-tooltip em { display: inline-flex; margin-top: 7px; padding: 3px 6px; border-radius: 5px; color: #bbecf1; background: #214550; font-size: 9px; font-style: normal; font-weight: 700; }
.hover-tooltip small { display: block; margin-top: 6px; color: #d5e4e7; font-size: 9px; line-height: 1.4; }

.compare-view { height: calc(100vh - 74px); display: flex; flex-direction: column; overflow: hidden; padding: 18px 26px; }
.compare-heading { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 12px; }
.compare-heading h2 { margin: 5px 0; font-size: 22px; }
.compare-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.compare-inputs { flex: 0 0 min(31vh, 290px); min-height: 210px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.compare-message-card { min-width: 0; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: white; box-shadow: 0 5px 18px rgba(29,52,61,.045); }
.compare-message-head { flex: 0 0 auto; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px 7px 13px; border-bottom: 1px solid var(--line); background: #f8fafb; }
.compare-message-head > div:first-child { min-width: 90px; }
.compare-message-head strong, .compare-message-head span { display: block; }
.compare-message-head strong { font-size: 12px; }
.compare-message-head span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.compare-message-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.compare-message-actions button { white-space: nowrap; }
.compare-message-body { min-height: 0; flex: 1; position: relative; }
.compare-message-body textarea { width: 100%; height: 100%; resize: none; border: 0; border-radius: 0; padding: 11px 13px; color: var(--ink); background: white; font: 11px/1.65 var(--mono); outline: none; white-space: pre; overflow: auto; }
.compare-message-body textarea:focus { box-shadow: inset 0 0 0 2px rgba(10,114,128,.28); }
.compare-message-preview { height: 100%; overflow: auto; padding: 7px 0 14px; background: #fbfcfd; font: 11px/1.65 var(--mono); scrollbar-gutter: stable; }
.compare-preview-segment { display: grid; grid-template-columns: 34px minmax(max-content, 1fr); min-width: max-content; border-left: 3px solid transparent; transition: background .12s ease, border-color .12s ease, box-shadow .12s ease; }
.compare-preview-segment .line-number { padding-right: 7px; }
.compare-preview-segment code { padding-right: 18px; white-space: pre; }
.compare-preview-segment .segment-name { margin-right: 0; }
.compare-preview-segment.difference-highlight { color: #064f59; background: #cdecef; border-left-color: var(--teal); box-shadow: inset 0 0 0 1px #8fcdd2; }
.compare-preview-segment.compare-missing-marker { color: #8f281f; background: #fff0ee; border-left-color: var(--red); box-shadow: inset 0 0 0 1px #f0bbb6; }
.compare-preview-segment.compare-missing-marker .segment-name { color: var(--red); }
.compare-options { flex: 0 0 auto; display: flex; align-items: center; gap: 16px; margin: 10px 0 7px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.compare-options label { color: var(--muted); font-size: 11px; font-weight: 700; }
.compare-options .checkbox { display: flex; align-items: center; gap: 6px; }
.compare-options .primary-button { margin-left: auto; }
.compare-summary { flex: 0 0 auto; margin: 2px 0 7px; color: var(--muted); font-size: 12px; }
.compare-results { min-height: 130px; flex: 1 1 auto; display: grid; align-content: start; gap: 8px; overflow-y: scroll; padding: 1px 8px 14px 1px; scrollbar-gutter: stable; }
.difference-card { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; transition: border-color .12s ease, box-shadow .12s ease, background .12s ease; }
.difference-card:hover, .difference-card:focus-visible { border-color: #80bbc0; background: #f9fdfd; box-shadow: 0 5px 14px rgba(29,52,61,.08); outline: none; }
.difference-ref code { display: block; color: var(--blue); font-weight: 800; }
.difference-ref span { display: inline-flex; margin-top: 5px; color: var(--muted); font-size: 9px; }
.difference-value { min-width: 0; padding: 8px; border-radius: 7px; background: #f7f9fa; font: 11px/1.4 var(--mono); overflow-wrap: anywhere; }
.difference-expectation { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px 10px; padding: 7px 9px; border-left: 3px solid var(--blue); border-radius: 0 7px 7px 0; color: var(--muted); background: var(--blue-soft); font-size: 10px; line-height: 1.4; }
.difference-expectation strong { color: var(--blue); }
.difference-expectation span { min-width: 0; }
.difference-card.ignored { opacity: .64; }

.admin-view { padding: 26px; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1500px; margin: 0 auto 18px; }
.admin-heading h2 { margin: 6px 0; font-size: 25px; }
.admin-heading p { margin: 0; color: var(--muted); }
.admin-security { display: flex; align-items: center; gap: 10px; min-width: 280px; padding: 12px 14px; border: 1px solid #cce8dc; border-radius: 12px; color: var(--green); background: var(--green-soft); }
.admin-security strong, .admin-security small { display: block; }
.admin-security strong { font-size: 12px; }
.admin-security small { margin-top: 2px; color: #54806b; font-size: 10px; }
.admin-layout { display: grid; grid-template-columns: 280px minmax(640px, 1fr); gap: 12px; max-width: 1500px; min-height: calc(100vh - 190px); margin: 0 auto; }
.admin-clients { min-height: 560px; }
.admin-sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 14px; border-bottom: 1px solid var(--line); }
.admin-sidebar-head > div { display: flex; align-items: center; gap: 7px; }
.admin-sidebar-head h3 { margin: 0; font-size: 15px; }
.admin-sidebar-head span { display: inline-grid; place-items: center; min-width: 21px; height: 21px; border-radius: 11px; color: var(--teal-dark); background: var(--teal-soft); font-size: 10px; font-weight: 800; }
.compact { padding: 7px 10px; font-size: 11px; }
.admin-client-list { padding: 8px; }
.admin-client-item { width: 100%; display: grid; grid-template-columns: 38px 1fr 8px; align-items: center; gap: 9px; margin-bottom: 5px; padding: 9px; border: 1px solid transparent; border-radius: 10px; color: var(--ink); background: transparent; text-align: left; }
.admin-client-item:hover { background: var(--panel-soft); }
.admin-client-item.active { border-color: #b8dde0; background: var(--teal-soft); }
.client-avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--teal-dark); background: white; border: 1px solid var(--line); font-size: 11px; font-weight: 850; }
.admin-client-item strong, .admin-client-item small { display: block; }
.admin-client-item strong { font-size: 12px; }
.admin-client-item small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.client-state { width: 7px; height: 7px; border-radius: 50%; background: #31a66e; }
.client-state.off { background: #b3bec3; }
.admin-list-empty, .admin-inline-empty { padding: 28px 16px; color: var(--muted); text-align: center; font-size: 11px; }
.admin-list-empty p { margin: 5px 0 0; }
.admin-editor { min-height: 620px; }
.admin-empty { display: grid; place-items: center; align-content: center; min-height: 600px; padding: 40px; color: var(--muted); text-align: center; }
.admin-empty h3 { margin: 5px 0; color: var(--ink); }
.admin-empty p { max-width: 480px; margin: 4px auto; }
.admin-editor-head { display: flex; justify-content: space-between; gap: 20px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.admin-editor-head h3 { margin: 5px 0 0; font-size: 21px; }
.admin-version { text-align: right; }
.admin-version span, .admin-version small { display: block; }
.admin-version span { color: var(--teal-dark); font-size: 11px; font-weight: 800; }
.admin-version small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 18px 20px; }
.admin-form-grid label, .rule-grid label, .signature-head label { color: var(--muted); font-size: 10px; font-weight: 750; }
.admin-form-grid input, .admin-form-grid textarea, .rule-grid input, .rule-grid textarea, .rule-grid select, .signature-card input, .signature-card select { width: 100%; margin-top: 5px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 9px; color: var(--ink); background: white; outline: none; }
.admin-form-grid textarea, .rule-grid textarea { resize: vertical; }
.admin-form-grid input:focus, .admin-form-grid textarea:focus, .rule-grid input:focus, .rule-grid textarea:focus, .signature-card input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,114,128,.09); }
.span-two { grid-column: span 2; }
.span-four { grid-column: span 4; }
.admin-checkbox { display: flex; align-items: center; gap: 8px; }
.admin-checkbox input { width: auto; margin: 0; }
.admin-section { border-top: 1px solid var(--line); }
.support-section { padding: 0; }
.support-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; cursor: pointer; list-style: none; }
.support-section > summary::-webkit-details-marker { display: none; }
.support-section > summary:hover { background: var(--panel-soft); }
.support-section > summary strong, .support-section > summary small { display: block; }
.support-section > summary strong { font-size: 13px; }
.support-section > summary small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.summary-chevron { color: var(--muted); transition: transform .15s ease; }
.support-section[open] .summary-chevron { transform: rotate(180deg); }
.support-help { margin: 0; padding: 0 20px 10px; color: var(--muted); font-size: 10px; }
.message-support-editor { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 7px; max-height: 330px; padding: 0 20px 16px; overflow: auto; }
.message-support-row { display: grid; grid-template-columns: 1fr 135px; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.message-support-row code { color: var(--blue); font-size: 10px; font-weight: 750; }
.message-support-row select { width: 100%; padding: 5px 6px; font-size: 9px; }
.admin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 20px 10px; }
.admin-section-head h4 { margin: 0; font-size: 14px; }
.admin-section-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.signature-editor, .rule-editor { padding: 0 20px 16px; }
.signature-card, .rule-card { margin-top: 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-soft); overflow: hidden; }
.signature-head { display: grid; grid-template-columns: 1fr 260px 30px; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: white; }
.signature-head strong, .signature-head small { display: block; }
.signature-head strong { font-size: 12px; }
.signature-head small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.signature-head select { margin-top: 3px; padding: 6px 8px; font-size: 10px; }
.condition-list { padding: 8px 12px 2px; }
.condition-row { display: grid; grid-template-columns: 130px 14px 1fr 30px; align-items: center; gap: 7px; margin-bottom: 6px; }
.condition-row > span { color: var(--muted); text-align: center; }
.condition-row input { margin: 0; font: 11px var(--mono); }
.icon-button { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: white; font-size: 16px; }
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-button.danger:hover { color: var(--red); border-color: #efb7b1; background: var(--red-soft); }
.inline-add { margin: 4px 12px 10px; padding: 4px 0; border: 0; color: var(--teal-dark); background: transparent; font-size: 10px; font-weight: 750; }
.rule-card-head { display: grid; grid-template-columns: 130px 1fr 30px; align-items: center; gap: 8px; padding: 10px 12px; color: var(--muted); background: white; border-bottom: 1px solid var(--line); font-size: 10px; }
.rule-card-head code { color: var(--blue); font-weight: 800; }
.rule-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 10px; padding: 12px; }
.rule-grid input, .rule-grid select, .rule-grid textarea { font-size: 11px; }
.history-section { background: #fbfcfd; }
.admin-history { display: grid; gap: 5px; padding: 0 20px 16px; }
.admin-history > div:not(.admin-inline-empty) { display: grid; grid-template-columns: 42px 1fr auto; gap: 8px; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.admin-history span { color: var(--teal-dark); font: 700 10px var(--mono); }
.admin-history strong { font-size: 10px; }
.admin-history small { color: var(--muted); font-size: 9px; }
.admin-savebar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
.admin-savebar span { flex: 1; color: var(--muted); font-size: 10px; }
.danger-button { border: 1px solid #efb7b1; border-radius: 9px; padding: 8px 12px; color: var(--red); background: var(--red-soft); font-weight: 700; }
.danger-button:hover { background: #ffe2de; }

.toast { position: fixed; right: 20px; bottom: 20px; z-index: 120; max-width: 380px; padding: 12px 14px; color: white; background: #17343d; border-radius: 10px; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1100px) {
  .app-header { grid-template-columns: 1fr auto; }
  .mode-switch { order: 3; grid-column: 1 / -1; justify-self: center; margin-top: -8px; }
  .app-header { height: 104px; }
  main { min-height: calc(100vh - 104px); }
  .compare-view { height: calc(100vh - 104px); }
  .workspace-grid { grid-template-columns: 1fr; }
  .raw-message { height: 520px; }
  .tab-content { height: 420px; }
  .admin-layout { grid-template-columns: 230px 1fr; }
  .rule-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .span-four { grid-column: span 2; }
  .message-support-editor { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@media (max-width: 760px) {
  .app-header { padding: 0 14px; }
  .brand p, .privacy-pill { display: none; }
  .header-actions { gap: 5px; }
  .empty-state { margin-top: 24px; padding: 24px; }
  .workspace { padding: 10px; }
  .context-bar, .panel-toolbar, .compare-heading { align-items: flex-start; flex-direction: column; }
  .insight-strip { grid-template-columns: repeat(3, 1fr); }
  .main-insight { grid-column: 1 / -1; }
  .search-wrap { min-width: 100%; width: 100%; }
  .compare-view { height: auto; min-height: calc(100vh - 104px); overflow: visible; padding: 16px; }
  .compare-inputs { flex-basis: auto; grid-template-columns: 1fr; }
  .compare-message-card { height: 260px; }
  .compare-message-head { align-items: flex-start; flex-direction: column; }
  .compare-message-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .compare-options { align-items: stretch; flex-direction: column; }
  .compare-options .primary-button { margin-left: 0; }
  .compare-results { max-height: 460px; }
  .difference-card { grid-template-columns: 1fr; }
  .difference-expectation { grid-column: 1; }
  .admin-view { padding: 12px; }
  .admin-heading { align-items: flex-start; flex-direction: column; }
  .admin-security { width: 100%; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-clients { min-height: 0; }
  .admin-form-grid, .rule-grid { grid-template-columns: 1fr; }
  .span-two, .span-four { grid-column: span 1; }
  .signature-head { grid-template-columns: 1fr 30px; }
  .signature-head label { grid-row: 2; grid-column: 1 / -1; }
  .condition-row { grid-template-columns: 92px 12px 1fr 30px; }
  .message-support-editor { grid-template-columns: 1fr; }
  .admin-savebar { align-items: stretch; flex-direction: column; }
}
