/* ===========================================================================
   EPICENTRO — Gestión Sísmica · Django Admin Theme
   Visual direction: Consola (dense GIS console — bordered panels, squared, mono)
   Light-mode only · System fonts only · No CDN
   Based on design by Claude Design (claude.ai/design).
   =========================================================================== */

/* ---- 1. DESIGN TOKENS --------------------------------------------------- */
:root,
html[data-theme="light"],
html[data-theme="dark"] {
  /* Brand (LOCKED) */
  --epi-green:        #00602d;
  --epi-green-dark:   #004d24;
  --epi-green-darker: #003a1b;
  --epi-red:          #f91d21;
  --epi-red-dark:     #d3171b;

  /* Brand tints */
  --epi-green-050: #eef6f1;
  --epi-green-100: #ddeee4;
  --epi-green-200: #c2e0ce;
  --epi-green-600: #1f8a4d;
  --epi-red-050:   #fdebec;
  --epi-red-100:   #f9d4d6;

  /* Surfaces — Consola: slightly cooler canvas */
  --epi-canvas:   #e9efeb;
  --epi-raised:   #ffffff;
  --epi-sunken:   #f4f7f5;
  --epi-sunken-2: #eaf0ec;

  /* Borders */
  --epi-border:        #dde5e0;
  --epi-border-strong: #cbd6cf;
  --epi-hairline:      #e7ede9;

  /* Text hierarchy */
  --epi-text:        #15201b;
  --epi-text-2:      #3a463f;
  --epi-text-muted:  #61716a;
  --epi-text-faint:  #8a988f;
  --epi-on-dark:     #ffffff;
  --epi-on-dark-dim: #cfe3d6;

  /* Status */
  --epi-ok:      #1f8a4d;  --epi-ok-bg:   #e7f4ec;  --epi-ok-bd:   #bfe2cc;
  --epi-info:    #2563c9;  --epi-info-bg: #e9f1fc;  --epi-info-bd: #c4d9f4;
  --epi-warn:    #b26a00;  --epi-warn-bg: #fff3df;  --epi-warn-bd: #f3dcae;
  --epi-err:     #d3171b;  --epi-err-bg:  #fdecec;  --epi-err-bd:  #f3c4c5;

  /* Radii — Consola: sharp */
  --epi-r-sm:  3px;
  --epi-r:     4px;
  --epi-r-lg:  5px;
  --epi-r-pill: 999px;

  /* Elevation — Consola: no shadows */
  --epi-shadow-1:   none;
  --epi-shadow-2:   0 2px 6px rgba(8,40,24,.10);
  --epi-shadow-pop: 0 12px 40px rgba(8,30,18,.22);
  --epi-ring:       0 0 0 3px rgba(0,96,45,.22);

  /* Type */
  --epi-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --epi-mono: "Cascadia Code", "SF Mono", ui-monospace, "Consolas", "Roboto Mono", "DejaVu Sans Mono", monospace;

  /* Layout — Consola: tighter gutter, wider max content */
  --epi-gutter: 20px;

  /* ---- Map onto Django admin CSS variables ---- */
  --primary:                  var(--epi-green);
  --secondary:                var(--epi-green-dark);
  --accent:                   var(--epi-red);
  --primary-fg:               #fff;
  --body-bg:                  var(--epi-canvas);
  --body-fg:                  var(--epi-text);
  --body-quiet-color:         var(--epi-text-muted);
  --body-medium-color:        var(--epi-text-2);
  --body-loud-color:          var(--epi-text);
  --header-bg:                var(--epi-green);
  --header-color:             #fff;
  --header-link-color:        #fff;
  --header-branding-color:    #fff;
  --breadcrumbs-bg:           var(--epi-raised);
  --breadcrumbs-fg:           var(--epi-text);
  --breadcrumbs-link-fg:      var(--epi-green);
  --link-fg:                  var(--epi-green);
  --link-hover-color:         var(--epi-green-dark);
  --link-selected-fg:         var(--epi-green-dark);
  --hairline-color:           var(--epi-hairline);
  --border-color:             var(--epi-border);
  --button-bg:                var(--epi-green);
  --button-fg:                #fff;
  --button-hover-bg:          var(--epi-green-dark);
  --default-button-bg:        var(--epi-green);
  --default-button-hover-bg:  var(--epi-green-dark);
  --delete-button-bg:         var(--epi-red-dark);
  --delete-button-hover-bg:   #b31216;
  --selected-bg:              var(--epi-green-050);
  --selected-row:             var(--epi-green-100);
  --darkened-bg:              var(--epi-sunken);
  --message-success-bg:       var(--epi-ok-bg);
  --message-info-bg:          var(--epi-info-bg);
  --message-warning-bg:       var(--epi-warn-bg);
  --message-error-bg:         var(--epi-err-bg);
  color-scheme: light;
}

/* ---- 2. RESET / GLOBALS ------------------------------------------------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--epi-canvas);
  color: var(--epi-text);
  font-family: var(--epi-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--epi-green); text-decoration: none; }
a:hover { color: var(--epi-green-dark); text-decoration: underline; }
::selection { background: var(--epi-green-200); }

/* Focus ring */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--epi-green);
  outline-offset: 2px;
}

/* Broad content color reset so Django admin's internal elements inherit correctly */
#content, #content h1, #content h2, #content h3, #content h4,
#content p, #content li, #content label,
fieldset, .aligned .form-row,
.results th, .results td {
  color: var(--epi-text);
}
.help, .helptext, .quiet { color: var(--epi-text-muted); }

/* ---- 3. HEADER (Consola: gradient + red bottom border) ------------------ */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: linear-gradient(180deg, var(--epi-green) 0%, var(--epi-green-dark) 100%);
  color: #fff;
  padding: var(--epi-gutter);
  border-bottom: 2px solid var(--epi-red);
  box-shadow: none;
  position: relative;
  z-index: 30;
}

/* Brand block */
.epi-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.epi-brand-mark {
  width: 32px; height: 32px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}
.epi-brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#site-name { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.15; }
#site-name a, #site-name a:link, #site-name a:visited { color: #fff !important; text-decoration: none; }
.epi-sub {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--epi-on-dark-dim); line-height: 1.1;
}

/* User tools — structural fix: no raw text nodes as flex items */
#user-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  text-transform: none;
}
.epi-welcome {
  font-size: 11.5px; font-weight: 500; letter-spacing: .04em;
  text-transform: uppercase; color: var(--epi-on-dark-dim); white-space: nowrap;
}
.epi-welcome strong { color: #fff; font-weight: 700; }

.epi-userlinks { display: flex; align-items: center; gap: 10px; }
.epi-userlinks a,
.epi-userlinks button {
  font-family: inherit;
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: #fff !important; opacity: .92;
  background: none; border: 0; padding: 0; margin: 0; line-height: 1; cursor: pointer;
  text-decoration: none;
}
.epi-userlinks a:hover,
.epi-userlinks button:hover { opacity: 1; text-decoration: underline; }
.epi-userlinks .sep { color: rgba(255,255,255,.45); font-size: 11px; user-select: none; }
#logout-form { display: inline-flex; align-items: center; margin: 0; padding: 0; }

/* Avatar chip */
.epi-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px; letter-spacing: 0; text-transform: none;
  background: rgba(255,255,255,.16); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

/* ---- 4. BREADCRUMBS ----------------------------------------------------- */
.breadcrumbs {
  background: var(--epi-raised);
  border-bottom: 1px solid var(--epi-border-strong);
  padding: 10px var(--epi-gutter);
  font-size: 12.5px;
  color: var(--epi-text-muted);
}
.breadcrumbs a { color: var(--epi-green); }

/* ---- 5. PAGE SHELL ------------------------------------------------------ */
#content-main { max-width: 1500px; }
#content h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; letter-spacing: -.01em; }

/* ---- 6. MODULE / CARD (Consola: strong border, no shadow) --------------- */
.module,
#changelist-filter,
.inline-group {
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-lg);
  box-shadow: none;
  overflow: hidden;
}

/* Card / module header — Consola: dark green background, white uppercase text */
.module > h2,
.module > caption,
fieldset.module > h2,
.inline-group > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--epi-green-dark);
  color: #fff !important;
  border-bottom: 1px solid var(--epi-border-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin: 0;
}

/* Dashboard module table overrides */
.dashboard .module table th,
.dashboard .module table td { background: var(--epi-raised); }

/* ---- 7. BUTTONS --------------------------------------------------------- */
.button,
input[type=submit],
input[type=button],
.submit-row input,
a.button,
a.deletelink,
.submit-row a.deletelink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  padding: 9px 15px;
  border-radius: var(--epi-r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--epi-green);
  color: #fff;
  box-shadow: none;
  transition: background .12s;
  text-decoration: none;
}
.button:hover, input[type=submit]:hover, input[type=button]:hover {
  background: var(--epi-green-dark);
  color: #fff;
  text-decoration: none;
}
.button:focus-visible,
input[type=submit]:focus-visible,
input[type=button]:focus-visible,
.submit-row input:focus-visible,
a.button:focus-visible,
a.deletelink:focus-visible,
.submit-row a.deletelink:focus-visible {
  outline: none;
  box-shadow: var(--epi-ring);
}
.button.default,
input[type=submit].default,
.submit-row input.default {
  background: var(--epi-green);
  color: #fff;
}
.button.default:hover,
input[type=submit].default:hover { background: var(--epi-green-dark); }

/* Object-tools (History, View on site) — calm secondary style */
.object-tools { display: flex; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.object-tools a:link,
.object-tools a:visited {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--epi-raised);
  color: var(--epi-text) !important;
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: none;
}
.object-tools a:hover {
  background: var(--epi-sunken);
  text-decoration: none;
  color: var(--epi-text) !important;
}

/* Delete / cancel buttons */
.button.cancel-link,
a.deletelink,
.submit-row a.deletelink {
  background: var(--epi-red-dark);
  color: #fff;
  height: auto;
  min-height: 0;
}
.submit-row a.deletelink,
.submit-row p.deletelink-box a.deletelink {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  font: inherit !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  padding: 9px 15px !important;
  border-radius: var(--epi-r-sm) !important;
  border: 1px solid transparent !important;
  box-shadow: none !important;
  height: auto !important;
  min-height: 0 !important;
}
.button.cancel-link:hover,
a.deletelink:hover,
.submit-row a.deletelink:hover {
  background: #b31216;
  color: #fff;
}

/* ---- 8. FORMS ----------------------------------------------------------- */
label { font-size: 13px; font-weight: 600; color: var(--epi-text-2); }
.help, .helptext { color: var(--epi-text-muted); font-size: 12px; }

input[type=text], input[type=number], input[type=email], input[type=url],
input[type=password], input[type=search], textarea, select {
  font: inherit;
  font-size: 13.5px;
  color: var(--epi-text);
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  padding: 8px 10px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--epi-green);
  box-shadow: var(--epi-ring);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--epi-text-faint); }
textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2361716a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 32px;
  cursor: pointer;
}
/* Aligned form rows — two-column label/field grid, Consola: 12.5px
   The grid has to target the actual label+field pairing, not `.form-row`
   itself. Django nests a single-field row as
   `.form-row > div > .flex-container > (label, field)`, so gridding
   `.form-row` directly gave it exactly one grid item — confined to the
   200px label column — and the field's real content was dead-clipped there
   by `.form-row`'s own `overflow: hidden`, no matter how much page width
   was actually free to its right. Multi-field rows (`.form-multiline`) are
   left alone here; they lay out with Django's own flex rules. Checkbox rows
   are also excluded: Django renders those as checkbox-then-label (not
   label-then-field), so gridding them would strand the checkbox alone in
   the 200px column with its label off in the 1fr one. */
.aligned .form-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--epi-hairline);
  font-size: 12.5px;
}
.aligned .form-row:last-child { border-bottom: 0; }
.aligned .form-row > div > .flex-container:not(.checkbox-row) {
  display: grid;
  grid-template-columns: 200px minmax(0,1fr);
  gap: 6px 16px;
  align-items: start;
}
.aligned .form-row > div > .flex-container:not(.checkbox-row) > label { padding-top: 8px; text-align: left; }

/* Django's default widget widths are fixed in `em`s regardless of how much
   page width is actually free (`.vTextField`/`.vUUIDField` 20em, `.vURLField`
   30em, `.vLargeTextField`/`.vXMLLargeTextField` 48em — see admin/css/forms.css).
   Stretch these text-ish widgets to fill their field column instead — but
   only inside the single-field grid above: `.form-multiline` rows (e.g. the
   Levantamiento form's paired dist_ptos/dist_canales/offset_min/offset_max)
   deliberately keep Django's flex layout, and forcing each of their inputs
   to 100% width would blow past its half of the row. Deliberately narrow
   types (dates, integers, raw-id widgets) are left as-is. */
.aligned .form-row > div > .flex-container:not(.checkbox-row) .vTextField,
.aligned .form-row > div > .flex-container:not(.checkbox-row) .vUUIDField,
.aligned .form-row > div > .flex-container:not(.checkbox-row) .vURLField,
.aligned .form-row > div > .flex-container:not(.checkbox-row) .vLargeTextField,
.aligned .form-row > div > .flex-container:not(.checkbox-row) .vXMLLargeTextField {
  width: 100%;
  max-width: 100%;
}

fieldset.module { margin-bottom: 16px; }

/* ---- 8b. RELATED-FIELD WIDGET WRAPPERS ---------------------------------- */
/* FK (single-select): select + icon links on ONE line */
.related-widget-wrapper:not(:has(select[multiple])) {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  max-width: 100%;
}
.related-widget-wrapper:not(:has(select[multiple])) select {
  flex: 1;
  min-width: 0;
}
/* M2M (multi-select): field takes full width, icon links go below */
.related-widget-wrapper:has(select[multiple]) {
  display: block;
}
.related-widget-wrapper:has(select[multiple]) .related-widget-wrapper-link {
  margin-top: 6px;
  margin-right: 4px;
}
/* Boxed neutral icon button */
.related-widget-wrapper-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  background: var(--epi-raised);
  cursor: pointer;
  text-decoration: none;
  transition: border-color .12s, background .12s;
}
.related-widget-wrapper-link img {
  width: 15px;
  height: 15px;
  filter: grayscale(1) opacity(.55);
  display: block;
}
.related-widget-wrapper-link.add-related:hover,
.related-widget-wrapper-link.change-related:hover {
  border-color: var(--epi-green);
  background: var(--epi-green-050);
}
.related-widget-wrapper-link.add-related:hover img,
.related-widget-wrapper-link.change-related:hover img { filter: none; }
.related-widget-wrapper-link.delete-related:hover {
  border-color: var(--epi-err);
  background: var(--epi-err-bg);
}
.related-widget-wrapper-link.delete-related:hover img { filter: none; }
.related-widget-wrapper-link.view-related:hover {
  border-color: var(--epi-info);
  background: var(--epi-info-bg);
}
.related-widget-wrapper-link.view-related:hover img { filter: none; }

/* ---- 9. SUBMIT ROW ------------------------------------------------------ */
.submit-row {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-top: 20px;
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-lg);
  box-shadow: 0 -2px 8px rgba(8,30,18,.08);
}
.submit-row p.deletelink-box { margin: 0; }

/* ---- 10. CHANGELIST TABLE ----------------------------------------------- */
#result_list {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#result_list thead th {
  background: var(--epi-sunken);
  color: var(--epi-text-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--epi-border-strong);
  white-space: nowrap;
}
#result_list thead th a { color: var(--epi-text-2); }
#result_list thead th.sorted { color: var(--epi-green-dark); background: var(--epi-green-050); }
#result_list thead th.sorted a { color: var(--epi-green-dark); }
#result_list tbody td,
#result_list tbody th {
  padding: 7px 12px;
  border-bottom: 1px solid var(--epi-hairline);
  color: var(--epi-text);
  vertical-align: middle;
  line-height: 1.4;
  height: auto;
}
td.action-checkbox {
  width: 38px;
  text-align: center;
  vertical-align: middle;
  padding: 0 8px;
}
#result_list tbody tr:nth-child(even) { background: #fbfdfc; }
#result_list tbody tr:hover { background: var(--epi-green-050); }
#result_list tbody tr.selected { background: var(--epi-green-100); }
#result_list tbody tr.selected:hover { background: var(--epi-green-100); }
#result_list .field-__str__ a,
#result_list .field-designacion a,
.results tbody td a {
  font-weight: 600;
  color: var(--epi-green-dark);
}
#result_list input[type=checkbox],
#result_list input[type=checkbox].action-select {
  width: 16px;
  height: 16px;
  accent-color: var(--epi-green);
}
/* Designacion column: clamp long names to 2 lines */
#result_list .field-designacion { max-width: 300px; }
#result_list .field-designacion a {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
/* Bloques column: names, not a count. Most rows are one short code, but the
   two country-wide levantamientos carry 20+ and would stretch the table, so
   the cell is clipped and the full list stays in the title tooltip. */
#result_list .field-get_bloques {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#result_list .field-get_estado { text-align: center; }

/* Status pills */
.epi-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--epi-r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.epi-status--ok    { background: var(--epi-ok-bg);   color: var(--epi-ok);   }
.epi-status--warn  { background: var(--epi-warn-bg);  color: var(--epi-warn); }
.epi-status--error { background: var(--epi-err-bg);   color: var(--epi-err);  }

/* Action bar above changelist */
#changelist-form .actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--epi-sunken);
  border-bottom: 1px solid var(--epi-border);
  font-size: 12.5px;
}
#changelist-form .actions label { font-weight: 500; color: var(--epi-text-muted); }
#changelist-form .actions select {
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  padding: 5px 28px 5px 9px;
  font: inherit;
  font-size: 12.5px;
  color: var(--epi-text);
  background: var(--epi-raised);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7c74' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  cursor: pointer;
}
#changelist-form .actions button.button {
  padding: 5px 14px;
  border: 1px solid var(--epi-green);
  border-radius: var(--epi-r-sm);
  background: var(--epi-raised);
  color: var(--epi-green-dark);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
#changelist-form .actions button.button:hover { background: var(--epi-green-050); }

/* Search toolbar */
#toolbar {
  padding: 10px var(--epi-gutter);
  background: var(--epi-sunken);
  border-bottom: 1px solid var(--epi-border);
}
/* Django provides its own search icon via <label><img> — style input only */
#toolbar form { display: inline-flex; align-items: center; gap: 6px; }
#toolbar label { display: flex; align-items: center; opacity: .55; }
#toolbar label img { width: 15px; height: 15px; }
#searchbar {
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  min-width: 260px;
}
#searchbar:focus {
  border-color: var(--epi-green);
  box-shadow: var(--epi-ring);
  outline: none;
}
#changelist-search input[type="submit"] {
  padding: 7px 14px;
  border: 1px solid var(--epi-green);
  border-radius: var(--epi-r-sm);
  background: var(--epi-sunken);
  color: var(--epi-green-dark);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
#changelist-search input[type="submit"]:hover {
  background: var(--epi-green-050);
  border-color: var(--epi-green-dark);
}

/* Pagination */
.paginator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--epi-border);
  color: var(--epi-text-muted);
  font-size: 12.5px;
}
.paginator a, .paginator .this-page {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--epi-border);
  border-radius: var(--epi-r-sm);
  background: var(--epi-raised);
  color: var(--epi-text-2);
  font-weight: 600;
  font-size: 12px;
  text-decoration: none;
}
.paginator a:hover { background: var(--epi-sunken); text-decoration: none; }
.paginator .this-page { background: var(--epi-green); color: #fff; border-color: var(--epi-green); }

/* Filter sidebar — Consola: dark green header */
#changelist-filter { align-self: start; }
#changelist-filter h2 {
  margin: 0;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff;
  background: var(--epi-green-dark);
  border-bottom: 1px solid var(--epi-border);
}
#changelist-filter h3 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--epi-text-muted);
  padding: 10px 16px 0;
}
/* Django 6 uses <details>/<summary> for each filter section */
#changelist-filter details {
  border-top: 1px solid var(--epi-hairline);
}
#changelist-filter details summary {
  list-style: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--epi-text-muted);
  padding: 9px 16px 7px;
  user-select: none;
}
#changelist-filter details summary::-webkit-details-marker { display: none; }
/* Django's changelists.css injects '→'/'↓' via ::before — suppress it */
#changelist-filter details > summary::before,
#changelist-filter details[open] > summary::before { content: ''; }
#changelist-filter details[open] summary { color: var(--epi-text-2); }
#changelist-filter ul {
  list-style: none;
  margin: 0;
  padding: 2px 10px 10px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--epi-border-strong) transparent;
}
#changelist-filter a {
  display: block;
  padding: 5px 9px;
  border-radius: var(--epi-r-sm);
  color: var(--epi-text-2);
  font-size: 13px;
}
#changelist-filter a:hover { background: var(--epi-sunken); text-decoration: none; }
#changelist-filter li.selected a {
  background: var(--epi-green-050);
  color: var(--epi-green-dark);
  font-weight: 600;
}

/* ---- 10b. COLLAPSIBLE FILTER SIDEBAR (global) --------------------------- */
/* Toggle button injected into .object-tools by filters_toggle.js. Styled to
   match the object-tools buttons. */
.epi-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--epi-raised);
  color: var(--epi-text);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-sm);
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
}
.epi-filter-toggle:hover { background: var(--epi-sunken); }
.epi-filter-toggle:focus-visible {
  outline: 2px solid var(--epi-green);
  outline-offset: 1px;
}
.epi-filter-toggle svg { flex: none; opacity: .85; }

/* "×" close button on the filter header (hides the sidebar). */
.epi-filter-hide {
  float: right;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: -2px -4px 0 8px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--epi-r-sm);
  background: transparent;
  color: var(--epi-text-muted);
  cursor: pointer;
}
.epi-filter-hide:hover { background: var(--epi-sunken); color: var(--epi-text); }
.epi-filter-hide:focus-visible {
  outline: 2px solid var(--epi-green);
  outline-offset: 1px;
}

/* The reopen button (and its object-tools slot) shows only while collapsed.
   Scoped under .object-tools to outrank Django base.css's
   ".object-tools li { display: inline-block }" on specificity. */
.object-tools .epi-filter-toggle-item { display: none; }
.epi-filters-collapsed .object-tools .epi-filter-toggle-item { display: inline-flex; }

/* Collapsed state: hide the sidebar and reclaim its width for the results.
   The :has(#changelist-filter) rule in Django's changelists.css caps the
   results at calc(100% - 270px) even while the sidebar is display:none, so it
   must be overridden here too. */
.epi-filters-collapsed #changelist-filter { display: none; }
.epi-filters-collapsed #changelist .changelist-form-container:has(#changelist-filter) > div {
  max-width: 100%;
}

/* ---- 11. TABULAR INLINE ------------------------------------------------- */
.tabular thead th {
  background: var(--epi-sunken-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--epi-text-muted);
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--epi-border);
}
.tabular tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--epi-hairline);
}
.tabular tbody tr:hover { background: var(--epi-green-050); }
.tabular .add-row {
  padding: 8px 16px;
  background: var(--epi-sunken);
  border-top: 1px solid var(--epi-border);
}
.tabular .add-row a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
}

/* ---- 12. MESSAGES / ALERTS ---------------------------------------------- */
.messagelist {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.messagelist li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 16px;
  border-radius: var(--epi-r);
  border: 1px solid var(--epi-border);
  border-left-width: 4px;
  background: var(--epi-raised);
  font-size: 13.5px;
  color: var(--epi-text);
}
.messagelist li.success {
  background: var(--epi-ok-bg);
  border-color: var(--epi-ok-bd);
  border-left-color: var(--epi-ok);
}
.messagelist li.info {
  background: var(--epi-info-bg);
  border-color: var(--epi-info-bd);
  border-left-color: var(--epi-info);
}
.messagelist li.warning {
  background: var(--epi-warn-bg);
  border-color: var(--epi-warn-bd);
  border-left-color: var(--epi-warn);
}
.messagelist li.error {
  background: var(--epi-err-bg);
  border-color: var(--epi-err-bd);
  border-left-color: var(--epi-err);
}

/* ---- 13. ERROR STATES (preserve verbose emoji errors) ------------------- */
.errornote {
  background: #fff5f5;
  border: 2px solid var(--epi-err);
  border-radius: var(--epi-r);
  padding: 14px 18px;
  margin: 0 0 20px;
  font-size: 14.5px;
  font-weight: 700;
  color: #b91c1c;
  box-shadow: 0 4px 12px rgba(220,38,38,.12);
  display: flex;
  align-items: center;
  gap: 10px;
}
.errornote::before { content: "⚠️"; font-size: 1.2rem; }

.errorlist {
  background: #fff5f5;
  border: 1px solid var(--epi-err-bd);
  border-radius: var(--epi-r-sm);
  padding: 10px 14px 10px 38px;
  margin: 8px 0;
  list-style: none;
  position: relative;
}
.errorlist::before { content: "❌"; position: absolute; left: 12px; top: 10px; font-size: 1rem; }
.errorlist li { margin: 3px 0; color: #b91c1c; font-weight: 600; font-size: 13px; }

.form-row.errors {
  background: #fff7f7;
  border-left: 4px solid var(--epi-err);
  border-radius: var(--epi-r-sm);
}
.form-row.errors label { color: var(--epi-err); font-weight: bold; }
.form-row.errors input,
.form-row.errors select,
.form-row.errors textarea {
  border: 1.5px solid var(--epi-err) !important;
  background: #fffafa !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.10) !important;
}

.debug-errors {
  background: var(--epi-warn-bg);
  border: 2px solid var(--epi-warn);
  border-radius: var(--epi-r);
  padding: 14px 18px;
  margin: 0 0 20px;
  font-family: var(--epi-mono);
  font-size: 12.5px;
  color: #7a4a00;
}
.debug-errors h3 {
  margin: 0 0 10px;
  font-size: 13px;
  color: #7a4a00;
  border-bottom: 1px solid var(--epi-warn-bd);
  padding-bottom: 6px;
  font-family: var(--epi-sans);
  font-weight: 700;
}
.debug-errors pre {
  background: #fff;
  border: 1px solid var(--epi-warn-bd);
  border-radius: 4px;
  padding: 10px;
  margin: 8px 0;
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ---- 14. POPUP / DJANGO ADMIN MODAL ------------------------------------- */
.selector { font-size: 13px; }
.selector select {
  border-radius: var(--epi-r-sm);
  border-color: var(--epi-border-strong);
}

/* ---- 15. DASHBOARD ------------------------------------------------------ */
.epi-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.epi-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--epi-text-faint);
  margin-bottom: 4px;
}
.epi-page-sub {
  color: var(--epi-text-muted);
  font-size: 13.5px;
  margin: 2px 0 0;
}
.epi-page-head h1 { margin: 0 0 3px; }

.epi-dash {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 1100px) { .epi-dash { grid-template-columns: 1fr; } }

.epi-primary-zone { margin-bottom: 24px; }

.epi-zone-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--epi-text-faint);
  margin: 0 0 12px;
}
.epi-zone-label svg { color: var(--epi-green); flex: none; }
.epi-zone-label .rule { flex: 1; height: 1px; background: var(--epi-border); }

.epi-hero-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 820px) { .epi-hero-tiles { grid-template-columns: 1fr; } }

.epi-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-lg);
  padding: 16px;
  box-shadow: none;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: border-color .14s;
}
.epi-tile:hover { border-color: var(--epi-green); text-decoration: none; color: inherit; }
.epi-tile-ico {
  width: 40px;
  height: 40px;
  border-radius: var(--epi-r);
  display: grid;
  place-items: center;
  background: var(--epi-green-050);
  color: var(--epi-green);
  flex: none;
}
.epi-tile h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--epi-text); }
.epi-tile p  { margin: 0; font-size: 12px; color: var(--epi-text-muted); line-height: 1.45; flex: 1; }
.epi-tile-foot {
  display: flex;
  align-items: center;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--epi-hairline);
}
.epi-tile-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--epi-green);
}

/* Model groups */
.epi-groups { display: flex; flex-direction: column; gap: 14px; }

.epi-modgroup {
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-lg);
  box-shadow: none;
  overflow: hidden;
}
.epi-modgroup-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--epi-green-dark);
  border-bottom: 1px solid rgba(0,0,0,.12);
}
.epi-modgroup-head svg { color: rgba(255,255,255,.6); flex: none; }
.epi-modgroup-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff !important;
  background: none;
  border: none;
  padding: 0;
  line-height: 1.4;
}
.epi-modgroup-head .badge {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,.18);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.epi-modlist { display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .epi-modlist { grid-template-columns: 1fr; } }

.epi-modrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--epi-hairline);
  border-right: 1px solid var(--epi-hairline);
}
/* Right column: no right border */
.epi-modrow:nth-child(even) { border-right: none; }
/* If odd total, last odd item spans both — still no right border needed */
.epi-modrow:last-child:nth-child(odd) { border-right: none; }

.epi-modrow .name {
  font-weight: 600;
  font-size: 13px;
  color: var(--epi-green-dark);
  flex: 1;
  text-decoration: none;
}
.epi-modrow .name:hover { text-decoration: underline; }

.epi-mini {
  width: 26px;
  height: 26px;
  border-radius: var(--epi-r-sm);
  display: grid;
  place-items: center;
  border: 1px solid var(--epi-border);
  background: var(--epi-raised);
  color: var(--epi-text-muted);
  text-decoration: none;
  flex: none;
  cursor: pointer;
}
.epi-mini:hover { text-decoration: none; }
.epi-mini.add:hover { color: var(--epi-green-600); background: var(--epi-ok-bg); border-color: var(--epi-ok-bd); }
.epi-mini.chg:hover { color: var(--epi-green); background: var(--epi-green-050); border-color: var(--epi-green-200); }

/* Recent actions panel */
.epi-recent {
  background: var(--epi-raised);
  border: 1px solid var(--epi-border-strong);
  border-radius: var(--epi-r-lg);
  box-shadow: none;
  overflow: hidden;
  position: sticky;
  top: 18px;
}
.epi-recent h2 {
  margin: 0;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #fff !important;
  background: var(--epi-green-dark);
  border-bottom: 1px solid rgba(0,0,0,.12);
  display: flex;
  align-items: center;
  gap: 9px;
}
.epi-recent h2 svg { color: rgba(255,255,255,.6); flex: none; }
.epi-recent ul { list-style: none; margin: 0; padding: 6px; }
.epi-recent li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--epi-r-sm);
}
.epi-recent li:hover { background: var(--epi-sunken); }
.epi-recent .dot {
  width: 24px;
  height: 24px;
  border-radius: var(--epi-r-sm);
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 1px;
}
.epi-recent .dot.add { background: var(--epi-ok-bg);   color: var(--epi-ok);   }
.epi-recent .dot.chg { background: var(--epi-info-bg); color: var(--epi-info); }
.epi-recent .dot.del { background: var(--epi-err-bg);  color: var(--epi-err);  }
.epi-recent .ra-title { font-size: 13px; font-weight: 600; color: var(--epi-text); line-height: 1.3; }
.epi-recent .ra-title a { color: var(--epi-text); text-decoration: none; }
.epi-recent .ra-title a:hover { color: var(--epi-green-dark); text-decoration: underline; }
.epi-recent .ra-model { font-size: 11px; color: var(--epi-text-faint); letter-spacing: .01em; margin-top: 1px; }
.epi-recent-empty { padding: 16px; color: var(--epi-text-faint); font-size: 13px; }

/* ---- 16. MISC OVERRIDES ------------------------------------------------- */
/* Light-mode locked — hide the dark/light toggle that ships with Django admin */
.theme-toggle,
.theme-toggle-button,
#toggle-nav-sidebar { display: none !important; }

/* Tile count: big mono number + unit */
.epi-tile-count {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--epi-mono);
  color: var(--epi-green-dark);
  line-height: 1;
}
.epi-tile-count small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--epi-sans);
  color: var(--epi-text-faint);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
}

/* ---- 17. REDUCED MOTION ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Golden-sample questionnaire callout on the admin index (temporary). */
.epi-callout-validacion {
  background: var(--epi-info-bg);
  border: 1px solid var(--epi-info-bd);
  border-radius: 6px;
  color: var(--epi-text);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 18px;
  padding: 12px 16px;
}

.epi-callout-validacion a {
  font-weight: 700;
  margin-left: 6px;
}
