:root {
  --ink: #20150f;
  --muted: #667085;
  --line: #dce3eb;
  --soft: #f4f7fa;
  --paper: #ffffff;
  --green: #00866b;
  --green-soft: #e8fbf3;
  --amber: #b85b08;
  --amber-soft: #fff4df;
  --blue: #006894;
  --blue-soft: #e3f4fc;
  --red: #b42318;
  --red-soft: #fff0ee;
  --brown: #4b2c1d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--soft); font-size: 14px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.panel-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 66px;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.panel-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
}
.brand-icon svg { width: 26px; fill: none; stroke: white; stroke-width: 1.8; }
.panel-brand h1 { margin: 0; font-size: 21px; }
.panel-brand p { margin: 3px 0 0; color: #526784; }
.header-actions { display: flex; gap: 10px; align-items: center; }

.button, .icon-button, .file-link, .mini-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: #10233e;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.button { min-height: 44px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; }
.button.primary { background: var(--green); border-color: var(--green); color: white; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button { width: 44px; height: 44px; font-size: 23px; }
.file-link, .mini-button { display: inline-flex; padding: 7px 10px; align-items: center; font-size: 13px; }
.mini-button { color: var(--brown); }
.button:hover, .icon-button:hover, .file-link:hover, .mini-button:hover { filter: brightness(.97); }

.page { max-width: 1600px; margin: 0 auto; padding: 18px 20px 38px; }
.panel, .metric-grid article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.notice, .environment-banner {
  margin-bottom: 14px;
  border: 1px solid #8be5c4;
  border-radius: 6px;
  padding: 12px 16px;
  background: var(--green-soft);
  color: #063c31;
}
.notice.danger { border-color: #f0a59d; background: var(--red-soft); color: var(--red); }
.notice a { color: inherit; font-weight: 800; margin-left: 8px; }
.environment-banner { display: flex; justify-content: space-between; gap: 16px; background: var(--amber-soft); border-color: #efbf76; color: #7a3d00; }
.environment-banner.production { background: var(--green-soft); border-color: #8be5c4; color: #063c31; }
.environment-banner strong { letter-spacing: .04em; }

.health-panel { padding: 16px; margin-bottom: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.section-heading h2, .history-heading h2 { margin: 0; font-size: 19px; }
.section-heading p, .history-heading p { color: #536b8a; margin: 4px 0 0; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status.neutral { background: #eef2f6; color: #435269; }
.status.accepted { background: #ccf8e5; color: #006644; }
.status.voided { background: #d6f5ee; color: #006454; }
.status.pending { background: var(--blue-soft); color: var(--blue); }
.status.review, .status.rejected { background: var(--red-soft); color: var(--red); }
.status.beta { background: var(--amber-soft); color: var(--amber); text-transform: uppercase; }

.health-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.health-grid article { min-height: 64px; padding: 11px 13px; background: #f7f9fb; border-radius: 7px; }
.health-grid span, .metric-grid span { display: block; color: #58708f; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.health-grid strong { display: block; margin-top: 6px; font-size: 17px; }
.health-grid small { display: block; margin-top: 3px; color: var(--muted); }
.alerts { margin-top: 10px; }
.alert { padding: 9px 12px; border: 1px solid #efbf76; border-radius: 7px; background: var(--amber-soft); color: #734011; font-size: 13px; }
.alert + .alert { margin-top: 8px; }
.alert.ok { background: var(--green-soft); border-color: #8be5c4; color: #075a47; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.metric-grid article { min-height: 88px; padding: 16px; }
.metric-grid strong { display: block; margin-top: 8px; font-size: 26px; }
.metric-grid .green { color: var(--green); }
.metric-grid .blue { color: var(--blue); }
.metric-grid .amber { color: var(--amber); }

.history-heading { padding: 16px 18px 13px; }
.filters {
  display: grid;
  grid-template-columns: 165px 165px 165px 205px minmax(220px, 1fr) auto auto;
  gap: 10px;
  padding: 14px;
  background: #f7f9fb;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  align-items: end;
}
.filters label, .print-form label { color: #526784; font-size: 13px; font-weight: 800; text-transform: uppercase; }
.filters input, .filters select, .print-form input {
  width: 100%;
  min-height: 42px;
  margin-top: 5px;
  padding: 0 12px;
  border: 1px solid #d5deea;
  border-radius: 6px;
  background: white;
  color: #132238;
}
.loading { padding: 12px 14px; color: var(--blue); font-weight: 700; }
.history-panel > .notice { margin: 12px 14px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th { padding: 12px 14px; text-align: left; background: #eef3f8; color: #425b79; font-size: 12px; text-transform: uppercase; }
td { padding: 14px; vertical-align: middle; border-top: 1px solid #e8edf3; }
tbody tr:nth-child(odd) { background: #fff; }
tbody tr:nth-child(even) { background: #fbfcfd; }
.cpe-code { font-weight: 850; color: #081a32; }
.cpe-type, .secondary { display: block; margin-top: 5px; color: #58708f; font-size: 13px; }
.amount { font-size: 16px; font-weight: 850; white-space: nowrap; }
.file-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.dossier-action { min-width: 190px; }
.dossier-button { min-height: 38px; padding: 0 13px; color: var(--green); border-color: #8bcdbf; }
.empty { margin: 0; padding: 28px; text-align: center; color: var(--muted); }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: #536b8a; }
.pagination .button { min-height: 42px; padding: 0 15px; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(18, 25, 35, .62); }
.modal-card { width: min(680px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 9px; background: white; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.modal-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 3px 0 0; }
.eyebrow { margin: 0; color: var(--green); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.modal-subtitle { margin: 5px 0 0; color: var(--muted); }
.representation-modal { z-index: 60; }
.dossier-modal-card { width: min(1180px, 100%); height: min(820px, calc(100vh - 40px)); display: flex; flex-direction: column; overflow: hidden; }
.dossier-modal-card > header { flex: 0 0 auto; }
.dossier-layout { display: grid; flex: 1 1 auto; grid-template-columns: minmax(260px, 330px) minmax(0, 1fr); min-height: 0; }
.dossier-list { min-height: 0; overflow-y: auto; padding: 12px; border-right: 1px solid var(--line); background: #f7f9fb; overscroll-behavior: contain; }
.dossier-item {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #132238;
  cursor: pointer;
}
.dossier-item + .dossier-item { margin-top: 7px; }
.dossier-item:hover { background: white; border-color: var(--line); }
.dossier-item.active { background: var(--green-soft); border-color: #8bcdbf; box-shadow: inset 3px 0 0 var(--green); }
.dossier-item span { color: #58708f; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.dossier-item strong { font-size: 14px; }
.dossier-item small { color: var(--muted); line-height: 1.35; }
.dossier-detail { min-width: 0; min-height: 0; overflow-y: auto; padding: 22px; overscroll-behavior: contain; }
.dossier-detail-card { max-width: 760px; }
.dossier-detail-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.dossier-detail-heading h3 { margin: 4px 0 0; font-size: 23px; }
.dossier-badges { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.dossier-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.dossier-meta-item { min-height: 62px; padding: 11px 13px; border: 1px solid #e1e7ee; border-radius: 7px; background: #fbfcfd; }
.dossier-meta-item span { display: block; color: #58708f; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.dossier-meta-item strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.dossier-section { margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.dossier-section h4 { margin: 0 0 10px; font-size: 14px; }
.dossier-response { padding: 12px 14px; border-radius: 7px; background: #f7f9fb; color: #304963; }
.dossier-response p { margin: 5px 0 0; overflow-wrap: anywhere; }
.evidence-note { margin: 11px 0 0; padding: 11px 13px; border-left: 4px solid var(--blue); border-radius: 4px; background: var(--blue-soft); color: #174f6b; line-height: 1.45; }
.ticket-preview { margin: 18px 22px; padding: 18px; max-height: 44vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: #f7f4ee; white-space: pre-wrap; font: 13px/1.42 ui-monospace, SFMono-Regular, Consolas, monospace; }
.print-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 12px; padding: 0 22px; }
.modal-help { padding: 0 22px 20px; color: var(--muted); font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 70; max-width: 420px; padding: 14px 18px; border-radius: 7px; background: #16261f; color: white; box-shadow: 0 10px 30px rgba(0,0,0,.22); }

@media (max-width: 1280px) {
  .filters { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
  .search-field { grid-column: span 2; }
}
@media (max-width: 820px) {
  .panel-header { padding: 12px 16px; }
  .page { padding: 18px 12px 34px; }
  .health-grid, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-field { grid-column: 1 / -1; }
  .modal { padding: 10px; }
  .dossier-modal-card { height: calc(100vh - 20px); }
  .dossier-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .dossier-list { display: flex; gap: 8px; max-height: 150px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); }
  .dossier-item { min-width: 230px; }
  .dossier-item + .dossier-item { margin-top: 0; }
  .dossier-detail { padding: 18px; }
}
@media (max-width: 520px) {
  .panel-brand p { max-width: 190px; }
  .brand-icon { width: 43px; height: 43px; }
  .button { padding: 0 13px; }
  .health-grid, .metric-grid, .filters, .print-form { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
  .environment-banner, .section-heading, .pagination { align-items: flex-start; flex-direction: column; }
  .metric-grid article { min-height: 96px; }
  .modal-card > header { padding: 16px; }
  .dossier-detail { padding: 16px; }
  .dossier-meta { grid-template-columns: 1fr; }
}
