@font-face {
  font-family: "Pirulen";
  src: url("../fonts/pirulen.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #edf3f8;
  --sidebar: #08131d;
  --sidebar-2: #0d1d2b;
  --text: #111827;
  --muted: #64748b;
  --line: #dce3ea;
  --primary: #0a6ed1;
  --primary-strong: #0759aa;
  --success: #15803d;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(15, 23, 42, .07);
  --radius: 14px;
}

html[data-theme="dark"] {
  --bg: #0b1118;
  --surface: #121b24;
  --surface-2: #17222e;
  --surface-3: #1d2a37;
  --sidebar: #071019;
  --sidebar-2: #0b1824;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: #263241;
  --primary: #3b82f6;
  --primary-strong: #60a5fa;
  --success: #4ade80;
  --danger: #f87171;
  --shadow: 0 16px 36px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #dbe7f3;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.brand-icon-frame, .favorite-icon, .app-icon {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.brand-icon-frame {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 13px;
}

.brand > .brand-icon-frame,
.auth-brand > .brand-icon-frame {
  transform: translateY(-9px);
}

.brand-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-icon-fallback {
  display: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  place-items: center;
  background: linear-gradient(145deg, #0a6ed1, #54b4ff);
  color: white;
  font-weight: 900;
}

.image-broken > img { display: none; }
.image-broken > .brand-icon-fallback,
.image-broken > .app-icon-fallback { display: grid; }

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.brand-copy strong {
  font-family: "Pirulen", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .035em;
  color: white;
}

.brand-copy > span {
  margin-top: 5px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .34em;
  color: white;
}

.brand-copy small {
  margin-top: 7px;
  color: #9fb3cc;
  font-size: 11px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 22px;
}

.sidebar-nav a, .sidebar-footer > a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 10px;
  color: #b8c8d8;
  font-size: 14px;
  transition: .18s ease;
}

.menu-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: #91a8bc;
}

.menu-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-nav a:hover, .sidebar-footer > a:hover {
  color: white;
  background: rgba(255,255,255,.06);
}

.sidebar-nav a.active, .sidebar-footer > a.active {
  color: white;
  background: #0a6ed1;
}

.sidebar-nav a.active .menu-icon, .sidebar-footer > a.active .menu-icon { color: white; }

.nav-label {
  margin: 24px 13px 7px;
  color: #70869a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,.09);
}

.sidebar-user, .top-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sidebar-user {
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
}

.avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(59,130,246,.18);
  color: #93c5fd;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-user div:last-child, .top-user div:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.sidebar-user strong, .top-user strong {
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-user small, .top-user small { color: var(--muted); font-size: 10px; }
.sidebar-user small { color: #8fa4b7; }

.logout-button {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 9px;
  background: transparent;
  color: #b8c8d8;
  cursor: pointer;
}

.logout-button:hover { color: white; border-color: rgba(255,255,255,.2); }

.page-column { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 78px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top-search {
  width: min(460px, 48vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--muted);
}

.top-search input, .app-filter-input input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-icon,
.topbar-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-icon {
  color: var(--muted);
}

.icon-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.mobile-menu { display: none; }

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.top-user {
  margin-left: 0;
  padding-left: 0;
  border-left: 0;
}

.page-content { padding: 42px 36px 64px; }

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.page-heading.compact { margin-bottom: 24px; }

.page-heading h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 45px);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.page-heading.compact h1 { font-size: clamp(26px, 3vw, 36px); }

.page-heading p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.dashboard-section { margin-top: 30px; }

.section-heading, .panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.section-heading { margin-bottom: 16px; }
.section-heading h2, .panel-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.favorite-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.favorite-tile {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(15,23,42,.03);
  transition: transform .18s ease, border-color .18s ease;
}

.favorite-tile:hover { transform: translateY(-2px); border-color: var(--accent); }

.favorite-icon, .app-icon {
  background: transparent;
  color: var(--accent);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 14%, transparent);
}

.favorite-icon {
  width: 48px;
  height: 48px;
  border-radius: 13px;
}

.favorite-icon img, .app-icon img {
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: inherit;
  object-fit: cover;
}

.app-icon-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.favorite-icon:not(.image-broken) .app-icon-fallback,
.app-icon:not(.image-broken) img + .app-icon-fallback { display: none; }

.favorite-tile strong, .favorite-tile small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.favorite-tile strong { font-size: 14px; }
.favorite-tile small { color: var(--muted); font-size: 11px; }
.favorite-tile > span:last-child { color: var(--muted); }

.external-note {
  margin: 18px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.app-filter-input {
  width: min(280px, 100%);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.category-chips button {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.category-chips button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.app-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 5px 18px rgba(15,23,42,.025);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.app-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.app-card-link {
  min-height: 176px;
  display: flex;
  gap: 16px;
  padding: 22px 20px;
}

.app-card-disabled { cursor: not-allowed; opacity: .72; }

.app-icon {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 16px;
}

.app-card-copy { min-width: 0; flex: 1; }

.app-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.app-card h3 { margin: 1px 0 0; font-size: 16px; }
.external-arrow { color: var(--muted); }

.app-card p {
  min-height: 40px;
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.favorite-form {
  position: absolute;
  right: 13px;
  bottom: 12px;
  z-index: 4;
}

.favorite-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--surface-2);
  color: #f59e0b;
  cursor: pointer;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 190px;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state.small { min-height: 100px; }
.empty-state strong { color: var(--text); }

.flash {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
}

.flash-success { border-color: var(--success); color: var(--success); }
.flash-error { border-color: var(--danger); color: var(--danger); }

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(15,23,42,.03);
}

.panel-heading {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.counter {
  display: inline-flex;
  min-width: 28px;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: start;
}

.panel-wide { min-width: 0; }
.narrow-panel { max-width: 720px; }
.stack-form { display: grid; gap: 14px; }

.stack-form label, .inline-form label {
  display: grid;
  gap: 6px;
}

.stack-form label > span, .inline-form label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input, select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10,110,209,.13);
}

.checkbox-row {
  grid-template-columns: auto 1fr !important;
  align-items: center;
}

.checkbox-row input {
  width: 17px;
  min-height: 17px;
  height: 17px;
}

.checkbox-row span {
  color: var(--text) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 800;
  cursor: pointer;
}

.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-strong); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--text); }
.button-block { width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

td strong, td small { display: block; }
td small { margin-top: 2px; color: var(--muted); }
.text-link { color: var(--primary); font-weight: 800; }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.on::before { background: #22c55e; }
.status-dot.off::before { background: #f59e0b; }

.inline-form {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 22px;
}

.inline-form label { width: min(430px, 100%); }

.assignment-form { display: grid; gap: 20px; }

.assignment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.assignment-card {
  position: relative;
  min-height: 116px;
  display: flex;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.assignment-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.assignment-check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: transparent;
}

.assignment-card input:checked + .assignment-check {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.assignment-copy { display: flex; min-width: 0; flex-direction: column; }
.assignment-copy strong { font-size: 13px; }
.assignment-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.assignment-copy em { margin-top: auto; color: var(--primary); font-size: 10px; font-style: normal; font-weight: 800; }

.auth-page { background: #071019; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, .9fr) minmax(420px, 1.1fr);
}

.auth-brand-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(30px, 5vw, 72px);
  background:
    radial-gradient(circle at 20% 15%, rgba(59,130,246,.28), transparent 34%),
    linear-gradient(145deg, #06101a, #0b1e2e);
  color: white;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand > div:last-child { display: flex; flex-direction: column; }
.auth-brand strong {
  font-family: "Pirulen", Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: .035em;
}
.auth-brand span {
  margin-top: 6px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .34em;
}
.auth-brand small { margin-top: 8px; color: #9fb3cc; font-size: 12px; }

.auth-message { max-width: 540px; padding-bottom: 7vh; }
.auth-message h1 { margin: 0; font-size: clamp(42px, 5vw, 72px); line-height: 1; letter-spacing: -.05em; }
.auth-message p { max-width: 440px; margin: 22px 0 0; color: #a8bfd2; font-size: 18px; }

.auth-form-panel {
  display: grid;
  place-items: center;
  padding: 30px;
  background: var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  padding: clamp(26px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card-heading { margin-bottom: 26px; }
.auth-card-heading h2 { margin: 0; font-size: 30px; }
.auth-card-heading > p:last-child { margin: 8px 0 0; color: var(--muted); }

.sidebar-backdrop { display: none; }

@media (max-width: 1120px) {
  .app-grid, .assignment-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .favorite-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-105%);
    width: min(310px, 86vw);
    transition: transform .22s ease;
  }

  .sidebar-open .sidebar { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0,0,0,.48);
  }

  .sidebar-open .sidebar-backdrop { display: block; }
  .mobile-menu { display: block; }
  .topbar { height: 68px; padding: 0 16px; }
  .top-search { width: auto; flex: 1; }
  .top-actions { gap: 8px; padding-left: 10px; }
  .top-user div:last-child { display: none; }
  .page-content { padding: 28px 18px 50px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: auto; padding: 26px; }
  .auth-message { display: none; }
  .auth-form-panel { min-height: calc(100vh - 110px); padding: 20px; }
}

@media (max-width: 620px) {
  .page-heading, .section-heading { flex-direction: column; align-items: stretch; }
  .app-filter-input { width: 100%; }
  .app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .favorite-grid, .assignment-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .top-search { display: none; }
  .page-content { padding-inline: 12px; }
  .panel { padding: 17px; }

  .app-card-link {
    min-height: 204px;
    flex-direction: column;
    gap: 10px;
    padding: 14px 12px 46px;
  }

  .app-icon {
    flex-basis: 58px;
    width: 58px;
    height: 58px;
    border-radius: 15px;
  }

  .app-card-copy { width: 100%; }

  .app-card-title-row {
    align-items: center;
    gap: 6px;
  }

  .app-card h3 {
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .external-arrow {
    flex: 0 0 auto;
    font-size: 12px;
  }

  .app-card p {
    display: -webkit-box;
    min-height: 46px;
    margin: 5px 0 10px;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

  .status-pill {
    max-width: 100%;
    padding: 4px 7px;
    overflow: hidden;
    font-size: 9px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .favorite-form {
    right: 9px;
    bottom: 9px;
  }

  .favorite-button {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 380px) {
  .app-grid { gap: 8px; }
  .page-content { padding-inline: 9px; }

  .app-card-link {
    min-height: 198px;
    padding-inline: 10px;
  }

  .app-icon {
    flex-basis: 54px;
    width: 54px;
    height: 54px;
    border-radius: 14px;
  }

  .app-card h3 { font-size: 13px; }
}

/* CEDAPSA TEMPLATE REGISTRY — STAGE 3B */

.template-registry {
  display: grid;
  gap: 20px;
}

.template-registry__intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
}

.template-registry__intro h2 {
  margin: 4px 0 0;
}

.template-registry__intro > p {
  max-width: 560px;
  margin: 0;
  opacity: 0.76;
}

.template-registry__cards {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.template-card {
  display: grid;
  gap: 18px;
  min-width: 0;
  padding: 22px;
  border: 1px solid
    var(--ced-border, rgba(127,127,127,.22));
  border-radius: 18px;
  background:
    var(--ced-surface, rgba(255,255,255,.04));
}

.template-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.template-card__top h3 {
  margin: 5px 0 0;
  font-size: 1.05rem;
  line-height: 1.35;
}

.template-card__code {
  margin: 0;
  font-weight: 800;
  letter-spacing: .045em;
}

.template-card__description {
  margin: 0;
  opacity: .78;
  line-height: 1.55;
}

.template-card__meta {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.template-card__meta > div {
  min-width: 0;
  padding: 13px 14px;
  border-radius: 12px;
  background:
    var(--ced-surface-soft, rgba(127,127,127,.08));
}

.template-card__meta dt {
  margin-bottom: 5px;
  font-size: .78rem;
  opacity: .65;
}

.template-card__meta dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.template-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid
    var(--ced-border, rgba(127,127,127,.22));
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 750;
}

.template-status.is-active {
  background:
    rgba(40, 160, 90, .12);
}

.template-status.is-draft {
  background:
    rgba(210, 150, 30, .12);
}

.template-status.is-retired {
  opacity: .62;
}

.template-card__notice {
  padding: 13px 14px;
  border-radius: 12px;
  background:
    rgba(210, 150, 30, .10);
  font-size: .86rem;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .template-registry__intro {
    display: grid;
  }

  .template-registry__cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .template-card {
    padding: 18px;
  }

  .template-card__top {
    display: grid;
  }

  .template-status {
    justify-self: start;
  }

  .template-card__meta {
    grid-template-columns: 1fr;
  }
}

/* CEDAPSA F001 FORM — STAGE 3C-A */

.f001-form-shell {
  display: grid;
  gap: 20px;
  padding-bottom: 28px;
}

.f001-draft-banner,
.f001-system-bar,
.f001-section {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 18px;
}

.f001-draft-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
}

.f001-draft-banner strong {
  display: block;
  margin-top: 4px;
  font-size: 1.08rem;
}

.f001-draft-banner p:last-child {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.f001-status-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid rgba(210,150,30,.28);
  border-radius: 999px;
  background: rgba(210,150,30,.12);
  font-size: .8rem;
  font-weight: 800;
}

.f001-system-bar {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  overflow: hidden;
}

.f001-system-bar > div {
  padding: 15px 18px;
}

.f001-system-bar > div + div {
  border-left: 1px solid var(--line);
}

.f001-system-bar span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .77rem;
}

.f001-system-bar strong {
  font-size: .91rem;
}

.f001-section {
  padding: 22px;
}

.f001-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 20px;
}

.f001-section-heading h2 {
  margin: 4px 0 0;
  font-size: 1.18rem;
}

.f001-section-heading > p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.f001-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.f001-grid--inspection {
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
}

.f001-field {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
}

.f001-field--wide {
  grid-column: 1 / -1;
}

.f001-field > span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
}

.f001-field input,
.f001-field select,
.f001-field textarea {
  width: 100%;
}

.f001-field textarea {
  min-height: 90px;
  padding: 11px 12px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  outline: none;
}

.f001-field textarea:focus {
  border-color: var(--primary);
}

.f001-inspection-list {
  display: grid;
  gap: 14px;
}

.f001-inspection-row {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background:
    color-mix(
      in srgb,
      var(--surface) 92%,
      var(--text) 8%
    );
}

.f001-row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.f001-remove-row:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.f001-row-result {
  margin-top: 13px;
  color: var(--muted);
  font-size: .84rem;
}

.f001-add-row {
  margin-top: 15px;
}

.f001-result-options {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.f001-result-options label {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 112px;
  padding: 15px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.f001-result-options input {
  flex: 0 0 auto;
  margin-top: 3px;
}

.f001-result-options span {
  display: grid;
  gap: 6px;
}

.f001-result-options strong {
  line-height: 1.3;
}

.f001-result-options small {
  color: var(--muted);
  line-height: 1.45;
}

.f001-signature-grid {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.f001-signature-card {
  min-height: 120px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.f001-signature-card.is-required {
  border-style: solid;
  border-color:
    color-mix(
      in srgb,
      var(--primary) 42%,
      var(--line) 58%
    );
}

.f001-signature-card > span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .045em;
}

.f001-signature-card strong {
  display: block;
}

.f001-signature-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.45;
}

.f001-validation {
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.f001-validation.is-ok {
  border-color: rgba(40,160,90,.35);
  background: rgba(40,160,90,.08);
}

.f001-validation.is-error {
  border-color: rgba(210,90,70,.34);
  background: rgba(210,90,70,.08);
}

.f001-validation p {
  margin: 6px 0 0;
}

.f001-validation ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.f001-validation li + li {
  margin-top: 5px;
}

.f001-message {
  margin: 0;
  padding: 12px 14px;
  border-radius: 11px;
  background:
    color-mix(
      in srgb,
      var(--primary) 9%,
      transparent
    );
  line-height: 1.45;
}

.f001-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.f001-local-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
}

@media (max-width: 1120px) {
  .f001-grid--inspection {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .f001-signature-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .f001-draft-banner,
  .f001-section-heading {
    display: grid;
  }

  .f001-status-chip {
    justify-self: start;
  }

  .f001-system-bar {
    grid-template-columns: 1fr;
  }

  .f001-system-bar > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .f001-result-options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .f001-section {
    padding: 17px;
  }

  .f001-grid,
  .f001-grid--inspection,
  .f001-signature-grid {
    grid-template-columns: 1fr;
  }

  .f001-field--wide {
    grid-column: auto;
  }

  .f001-inspection-row {
    padding: 14px;
  }

  .f001-row-heading {
    align-items: flex-start;
  }

  .f001-actions {
    display: grid;
  }

  .f001-actions .button {
    width: 100%;
  }

  .f001-local-note {
    text-align: left;
  }
}

/* CEDAPSA F001 — RESULT RADIO FIX */

.f001-result-options label {
  min-width: 0;
}

.f001-result-options input[type="radio"] {
  appearance: auto;
  -webkit-appearance: radio;
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  max-width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 2px 0 0;
  padding: 0;
}

.f001-result-options label > span {
  flex: 1 1 auto;
  min-width: 0;
}

.f001-result-options label > span strong,
.f001-result-options label > span small {
  display: block;
  width: auto;
  overflow-wrap: normal;
  word-break: normal;
}

@media (max-width: 820px) {
  .f001-result-options label {
    min-height: auto;
  }
}

/* CEDAPSA F001 SIGNATURE CAPTURE — STAGE 3C-B */

.f001-signature-card__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.f001-signature-card__heading > span {
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.f001-signature-captured {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(40,160,90,.12);
  color: var(--text);
  font-size: .74rem;
}

.f001-signature-role {
  display: block;
}

.f001-signature-preview {
  display: grid;
  grid-template-columns:
    minmax(110px, 150px) 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.97);
  color: #111827;
}

.f001-signature-preview img {
  display: block;
  width: 100%;
  height: 58px;
  object-fit: contain;
  border-radius: 7px;
  background: #fff;
}

.f001-signature-preview > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.f001-signature-preview span,
.f001-signature-preview small {
  overflow-wrap: anywhere;
  color: #4b5563;
}

.f001-signature-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.f001-signature-delete {
  opacity: .8;
}

.f001-signature-backdrop {
  position: fixed;
  z-index: 5000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(5px);
}

.f001-signature-modal {
  display: grid;
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 22px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(0,0,0,.38);
}

.f001-signature-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.f001-signature-modal__header h2 {
  margin: 4px 0 0;
  font-size: 1.35rem;
}

.f001-signature-modal__header p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
}

.f001-signature-close {
  flex: 0 0 auto;
  font-size: 25px;
  line-height: 1;
}

.f001-signature-modal__identity {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.f001-signature-session {
  display: grid;
  grid-template-columns:
    auto auto 1fr;
  align-items: baseline;
  gap: 8px 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.f001-signature-session span,
.f001-signature-session small {
  color: var(--muted);
}

.f001-signature-session small {
  justify-self: end;
  text-align: right;
}

.f001-signature-pad-wrap {
  display: grid;
  gap: 10px;
}

.f001-signature-pad-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.f001-signature-pad-heading > div {
  display: grid;
  gap: 3px;
}

.f001-signature-pad-heading span {
  color: var(--muted);
  font-size: .82rem;
}

.f001-signature-canvas {
  display: block;
  width: 100%;
  height: min(48vh, 450px);
  min-height: 300px;
  border: 2px solid
    color-mix(
      in srgb,
      var(--primary) 35%,
      var(--line) 65%
    );
  border-radius: 14px;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
}

.f001-signature-error {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(210,90,70,.35);
  border-radius: 10px;
  background: rgba(210,90,70,.08);
}

.f001-signature-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 820px) {
  .f001-signature-backdrop {
    padding: 0;
  }

  .f001-signature-modal {
    width: 100vw;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
    padding:
      18px
      max(16px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }

  .f001-signature-modal__identity {
    grid-template-columns: 1fr;
  }

  .f001-signature-session {
    grid-template-columns: 1fr;
  }

  .f001-signature-session small {
    justify-self: start;
    text-align: left;
  }

  .f001-signature-canvas {
    height: min(46vh, 430px);
    min-height: 280px;
  }
}

@media (max-width: 620px) {
  .f001-signature-preview {
    grid-template-columns: 1fr;
  }

  .f001-signature-preview img {
    height: 76px;
  }

  .f001-signature-card__actions {
    display: grid;
  }

  .f001-signature-card__actions .button {
    width: 100%;
  }

  .f001-signature-modal__actions {
    display: grid;
  }

  .f001-signature-modal__actions .button {
    width: 100%;
  }

  .f001-signature-canvas {
    min-height: 240px;
  }
}

/* CEDAPSA QUALITY HISTORY — STAGE 3E */

.history-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.history-summary {
  display: grid;
  min-width: 130px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.history-summary span {
  color: var(--muted);
  font-size: .76rem;
}

.history-summary strong {
  margin-top: 3px;
  font-size: 1.35rem;
}

.history-filter-panel {
  display: grid;
  grid-template-columns:
    minmax(260px, 2fr)
    minmax(150px, 1fr)
    minmax(190px, 1fr)
    minmax(145px, .8fr)
    minmax(145px, .8fr)
    auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
}

.history-filter {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.history-filter > span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}

.history-filter input,
.history-filter select {
  width: 100%;
}

.history-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-list-panel,
.history-detail-section,
.history-detail-hero,
.history-detail-summary {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.history-list-panel {
  padding: 20px;
}

.history-list-heading,
.history-detail-section__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.history-list-heading {
  margin-bottom: 18px;
}

.history-list-heading h2,
.history-detail-section__heading h2 {
  margin: 4px 0 0;
  font-size: 1.16rem;
}

.history-list-heading > span,
.history-detail-section__heading > span {
  color: var(--muted);
  font-size: .83rem;
}

.history-table th {
  white-space: nowrap;
}

.history-table td {
  vertical-align: top;
}

.history-folio-link {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.history-folio-link:hover {
  color: var(--primary);
}

.history-table-secondary {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.history-movement-compact {
  display: grid;
  min-width: 190px;
  gap: 3px;
  font-size: .85rem;
}

.history-movement-compact > span:nth-child(2) {
  color: var(--muted);
}

.history-result-chip,
.history-closed-chip,
.history-verified-chip,
.history-locked-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 29px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.2;
}

.history-result-chip.is-positive,
.history-verified-chip {
  border-color: rgba(40,160,90,.34);
  background: rgba(40,160,90,.10);
}

.history-result-chip.is-warning {
  border-color: rgba(210,150,30,.34);
  background: rgba(210,150,30,.10);
}

.history-result-chip.is-negative {
  border-color: rgba(210,75,65,.34);
  background: rgba(210,75,65,.10);
}

.history-closed-chip,
.history-locked-chip {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 34%,
      var(--line) 66%
    );
  background:
    color-mix(
      in srgb,
      var(--primary) 9%,
      transparent
    );
}

.history-open-button {
  white-space: nowrap;
}

.history-mobile-list {
  display: none;
}

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.history-pagination .is-disabled {
  pointer-events: none;
  opacity: .42;
}

.history-page-number {
  color: var(--muted);
  font-size: .83rem;
}

.history-detail-back {
  margin-bottom: 14px;
}

.history-detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  margin-bottom: 18px;
}

.history-detail-hero h1 {
  margin: 5px 0 0;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  overflow-wrap: anywhere;
}

.history-detail-hero p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

.history-detail-state {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.history-detail-state small {
  color: var(--muted);
}

.history-detail-summary {
  display: grid;
  grid-template-columns:
    repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
}

.history-detail-summary > div {
  min-width: 0;
  padding: 15px 17px;
}

.history-detail-summary > div + div {
  border-left: 1px solid var(--line);
}

.history-detail-summary span:first-child {
  display: block;
  color: var(--muted);
  font-size: .76rem;
}

.history-detail-summary strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.history-detail-section {
  margin-bottom: 18px;
  padding: 21px;
}

.history-detail-section__heading {
  margin-bottom: 18px;
}

.history-kv-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.history-kv-grid > div {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-kv-grid dt,
.history-signature-meta dt {
  color: var(--muted);
  font-size: .75rem;
}

.history-kv-grid dd,
.history-signature-meta dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.history-kv-grid--single {
  grid-template-columns: 1fr;
  margin-top: 14px;
}

.history-kv-wide {
  grid-column: 1 / -1;
}

.history-kv-grid code,
.history-signature-meta code {
  font-size: .78rem;
  overflow-wrap: anywhere;
}

.history-route {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr)
    auto
    minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.history-route article {
  display: grid;
  gap: 5px;
  min-height: 105px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.history-route article > span,
.history-route article > small {
  color: var(--muted);
}

.history-route article strong {
  font-size: 1.08rem;
}

.history-route-arrow {
  color: var(--primary);
  font-size: 1.7rem;
  font-weight: 800;
}

.history-inspection-table td {
  vertical-align: top;
}

.history-signature-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.history-signature-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.history-signature-card__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px;
}

.history-signature-card__heading > div {
  display: grid;
  gap: 3px;
}

.history-signature-card__heading > div > span,
.history-signature-card__heading small {
  color: var(--muted);
}

.history-signature-image {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.history-signature-image img {
  display: block;
  width: 100%;
  max-height: 170px;
  object-fit: contain;
}

.history-signature-meta {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 15px;
}

.history-signature-meta > div {
  min-width: 0;
}

.history-timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-timeline li {
  position: relative;
  display: grid;
  grid-template-columns:
    38px 1fr;
  gap: 12px;
}

.history-timeline li:not(:last-child) {
  padding-bottom: 18px;
}

.history-timeline li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 36px;
  bottom: 0;
  width: 1px;
  background: var(--line);
}

.history-timeline-marker {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--primary) 42%,
      var(--line) 58%
    );
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  font-weight: 800;
  font-size: .78rem;
}

.history-timeline-content {
  min-width: 0;
  padding: 9px 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-timeline-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.history-timeline-heading time {
  color: var(--muted);
  font-size: .77rem;
  white-space: nowrap;
}

.history-timeline-content p {
  margin: 6px 0 0;
}

.history-timeline-content small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.history-integrity-panel {
  border-style: dashed;
}

@media (max-width: 1280px) {
  .history-filter-panel {
    grid-template-columns:
      repeat(3, minmax(0, 1fr));
  }

  .history-filter--search {
    grid-column: span 2;
  }

  .history-filter-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 920px) {
  .history-detail-summary {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .history-detail-summary > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .history-detail-summary > div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .history-signature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .history-page-heading,
  .history-detail-hero {
    display: grid;
  }

  .history-summary {
    justify-self: start;
  }

  .history-detail-state {
    justify-items: start;
  }

  .history-filter-panel {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .history-filter--search {
    grid-column: 1 / -1;
  }

  .history-filter-actions {
    grid-column: 1 / -1;
  }

  .history-table-wrap {
    display: none;
  }

  .history-mobile-list {
    display: grid;
    gap: 12px;
  }

  .history-mobile-card {
    display: grid;
    gap: 14px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
  }

  .history-mobile-card__heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .history-mobile-card__heading > div {
    display: grid;
    gap: 4px;
  }

  .history-mobile-card__heading small {
    color: var(--muted);
  }

  .history-mobile-kv {
    display: grid;
    gap: 9px;
    margin: 0;
  }

  .history-mobile-kv > div {
    display: grid;
    grid-template-columns:
      100px 1fr;
    gap: 10px;
  }

  .history-mobile-kv dt {
    color: var(--muted);
    font-size: .76rem;
  }

  .history-mobile-kv dd {
    margin: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 620px) {
  .history-filter-panel {
    grid-template-columns: 1fr;
  }

  .history-filter--search,
  .history-filter-actions {
    grid-column: auto;
  }

  .history-filter-actions {
    display: grid;
  }

  .history-filter-actions .button {
    width: 100%;
  }

  .history-list-panel,
  .history-detail-section,
  .history-detail-hero {
    padding: 16px;
  }

  .history-detail-summary,
  .history-kv-grid {
    grid-template-columns: 1fr;
  }

  .history-detail-summary > div + div,
  .history-detail-summary > div:nth-child(3),
  .history-detail-summary > div:nth-child(4) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .history-kv-wide {
    grid-column: auto;
  }

  .history-route {
    grid-template-columns: 1fr;
  }

  .history-route-arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  .history-list-heading,
  .history-detail-section__heading,
  .history-timeline-heading {
    display: grid;
  }

  .history-pagination {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .history-page-number {
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
  }

  .history-pagination .button {
    justify-content: center;
  }

  .history-mobile-card__heading {
    display: grid;
  }

  .history-mobile-kv > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* CEDAPSA CALIDAD RESPONSIVE SHELL TABLET V1 */

/* ---------------------------------------------------------
   CONTROL DE COLAPSO — ESCRITORIO
   --------------------------------------------------------- */

.sidebar {
  position: relative;
}

.sidebar-collapse-button,
.sidebar-mobile-close {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.045);
  color: #d9e7f4;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.sidebar-collapse-button:hover,
.sidebar-mobile-close:hover {
  border-color: rgba(255,255,255,.24);
  background: rgba(255,255,255,.09);
  color: #fff;
}

.sidebar-collapse-button {
  display: grid;
  width: 34px;
  height: 34px;
  margin:
    -2px 2px 10px
    auto;
  place-items: center;
  border-radius: 10px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.sidebar-mobile-close {
  display: none;
}

@media (min-width: 1121px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns:
      84px
      minmax(0, 1fr);
  }

  body.sidebar-collapsed .sidebar {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.sidebar-collapsed .brand {
    justify-content: center;
  }

  body.sidebar-collapsed .brand-copy {
    display: none;
  }

  body.sidebar-collapsed .nav-label {
    display: none;
  }

  body.sidebar-collapsed
    .sidebar-nav a,
  body.sidebar-collapsed
    .sidebar-footer > a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
  }

  body.sidebar-collapsed
    .sidebar-nav a
    .menu-label,
  body.sidebar-collapsed
    .sidebar-footer > a
    .menu-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.sidebar-collapsed
    .sidebar-nav
    .menu-icon,
  body.sidebar-collapsed
    .sidebar-footer
    .menu-icon {
    margin: 0;
  }

  body.sidebar-collapsed
    .sidebar-user {
    justify-content: center;
  }

  body.sidebar-collapsed
    .sidebar-user
    > div:last-child {
    display: none;
  }

  body.sidebar-collapsed
    .logout-button {
    display: none;
  }

  body.sidebar-collapsed
    .sidebar-collapse-button {
    margin-left: auto;
    margin-right: auto;
  }
}

/* ---------------------------------------------------------
   TABLET / TELEFONO — SIDEBAR OFF-CANVAS
   --------------------------------------------------------- */

@media (max-width: 1120px) {
  .app-shell,
  body.sidebar-collapsed
    .app-shell {
    grid-template-columns:
      minmax(0, 1fr);
  }

  .page-column {
    width: 100%;
    min-width: 0;
  }

  .sidebar {
    position: fixed;
    z-index: 110;
    top: 0;
    bottom: 0;
    left: 0;

    width:
      min(
        300px,
        calc(100vw - 48px)
      );
    height: 100dvh;

    overflow-x: hidden;
    overflow-y: auto;

    transform:
      translateX(-102%);

    transition:
      transform
      200ms
      ease;

    box-shadow:
      18px 0 50px
      rgba(0,0,0,.28);
  }

  body.sidebar-open
    .sidebar {
    transform:
      translateX(0);
  }

  .mobile-menu {
    display: grid !important;
    flex: 0 0 auto;
    place-items: center;
  }

  .sidebar-collapse-button {
    display: none;
  }

  .sidebar-mobile-close {
    position: absolute;
    z-index: 2;
    top: 14px;
    right: 12px;

    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;

    border-radius: 11px;

    font-size: 25px;
    line-height: 1;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 100;
    inset: 0;

    display: none;

    background:
      rgba(0,0,0,.56);

    backdrop-filter:
      blur(2px);
  }

  body.sidebar-open
    .sidebar-backdrop {
    display: block;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .topbar {
    width: 100%;
  }

  /*
   * En tablet se restablecen los textos completos
   * independientemente de la preferencia de
   * colapso guardada para escritorio.
   */
  .brand-copy,
  .menu-label,
  .sidebar-user
    > div:last-child,
  .logout-button {
    position: static;
    width: auto;
    height: auto;
    margin: initial;
    overflow: visible;
    clip: auto;
    white-space: normal;
  }
}

/* ---------------------------------------------------------
   HISTORIAL — FILTROS SIN REBASE
   --------------------------------------------------------- */

.history-filter-panel {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.history-filter-panel > * {
  min-width: 0;
}

.history-filter input,
.history-filter select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.history-filter-actions {
  min-width: 0;
}

.history-filter-actions
  .button {
  white-space: nowrap;
}

/*
 * Escritorio intermedio:
 * no forzar seis bloques en una sola línea.
 */
@media
  (min-width: 1121px)
  and
  (max-width: 1600px) {

  .history-filter-panel {
    grid-template-columns:
      repeat(
        3,
        minmax(0, 1fr)
      );
  }

  .history-filter--search {
    grid-column:
      span 2;
  }

  .history-filter-actions {
    grid-column:
      1 / -1;

    justify-content:
      flex-end;
  }
}

/*
 * Tablet:
 * el sidebar ya no consume ancho.
 * Los filtros utilizan dos columnas cómodas.
 */
@media (max-width: 1120px) {
  .history-filter-panel {
    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      );
  }

  .history-filter--search {
    grid-column:
      1 / -1;
  }

  .history-filter-actions {
    grid-column:
      1 / -1;

    justify-content:
      flex-end;
  }
}

@media (max-width: 620px) {
  .history-filter-panel {
    grid-template-columns:
      1fr;
  }

  .history-filter--search,
  .history-filter-actions {
    grid-column:
      auto;
  }

  .history-filter-actions {
    display: grid;

    grid-template-columns:
      repeat(
        2,
        minmax(0, 1fr)
      );
  }

  .history-filter-actions
    .button {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
}

/* ---------------------------------------------------------
   INPUT DATE — ICONO NATIVO SEGUN TEMA
   --------------------------------------------------------- */

html[data-theme="dark"]
  .history-filter
  input[type="date"] {
  color-scheme: dark;
}

html[data-theme="light"]
  .history-filter
  input[type="date"] {
  color-scheme: light;
}

.history-filter
  input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .88;
}

/* CEDAPSA CALIDAD SHELL RAIL V2 */

/* =========================================================
   ESCRITORIO > 1120
   Sidebar completo. Se elimina visualmente el modo colapsado.
   ========================================================= */

@media (min-width: 1121px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns:
      264px
      minmax(0, 1fr) !important;
  }

  .sidebar,
  body.sidebar-collapsed .sidebar {
    width: auto !important;
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  body.sidebar-collapsed .brand {
    justify-content: flex-start !important;
  }

  body.sidebar-collapsed .brand-copy,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-user > div:last-child,
  body.sidebar-collapsed .logout-button {
    display: revert !important;
  }

  body.sidebar-collapsed .sidebar-nav a,
  body.sidebar-collapsed .sidebar-footer > a {
    justify-content: flex-start !important;
    gap: 12px !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.sidebar-collapsed .menu-label {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
  }

  .sidebar-collapse-button {
    display: none !important;
  }

  .sidebar-mobile-close {
    display: none !important;
  }

  .mobile-menu {
    display: none !important;
  }
}

/* =========================================================
   TABLET 621–1120
   Rail permanente de iconos de 84px.
   Se expande temporalmente sobre el contenido.
   ========================================================= */

@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  .app-shell,
  body.sidebar-collapsed .app-shell {
    display: grid !important;
    grid-template-columns:
      84px
      minmax(0, 1fr) !important;
  }

  .page-column {
    grid-column: 2;
    min-width: 0;
    width: 100%;
  }

  .sidebar {
    position: sticky !important;
    z-index: 90;
    top: 0;
    left: auto;
    bottom: auto;

    grid-column: 1;
    grid-row: 1;

    width: 84px !important;
    height: 100dvh;

    padding:
      12px
      10px !important;

    overflow-x: hidden;
    overflow-y: auto;

    transform:
      none !important;

    box-shadow:
      none !important;

    transition:
      width 180ms ease,
      box-shadow 180ms ease;
  }

  /*
   * Marca compacta.
   */
  .sidebar .brand {
    justify-content: center !important;
    min-height: 66px;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar .brand-icon-frame {
    flex: 0 0 auto;
  }

  .sidebar .brand-copy {
    display: none !important;
  }

  /*
   * Separadores de sección no ocupan espacio
   * en el rail.
   */
  .sidebar .nav-label {
    height: 1px;
    margin: 10px 0;
    padding: 0;
    overflow: hidden;
    color: transparent;
    border-top:
      1px solid
      rgba(255,255,255,.10);
  }

  /*
   * Todos los accesos siguen presentes;
   * únicamente ocultamos visualmente la etiqueta.
   */
  .sidebar-nav a,
  .sidebar-footer > a {
    position: relative;

    display: flex !important;
    align-items: center;
    justify-content: center !important;

    min-width: 0;
    min-height: 52px;

    gap: 0 !important;

    padding:
      0 !important;

    border-radius: 13px;
  }

  .sidebar .menu-label {
    position: absolute !important;

    width: 1px !important;
    height: 1px !important;

    padding: 0 !important;
    margin: -1px !important;

    overflow: hidden !important;
    clip:
      rect(0, 0, 0, 0) !important;

    white-space: nowrap !important;
    border: 0 !important;
  }

  .sidebar .menu-icon {
    width: 23px;
    height: 23px;
    margin: 0 !important;
  }

  .sidebar-nav a.active {
    min-height: 56px;
  }

  /*
   * Botón » dentro del rail.
   */
  .sidebar-collapse-button {
    display: grid !important;

    width: 48px;
    height: 38px;

    margin:
      4px
      auto
      9px !important;

    place-items: center;

    border-radius: 12px;
  }

  .sidebar-mobile-close {
    display: none !important;
  }

  /*
   * Pie compacto: configuración + avatar.
   */
  .sidebar-user {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .sidebar-user > div:last-child {
    display: none !important;
  }

  .sidebar .logout-button {
    display: none !important;
  }

  /*
   * El hamburger de la topbar no se necesita
   * en tablet porque el rail siempre está visible.
   */
  .mobile-menu {
    display: none !important;
  }

  /*
   * EXPANDIDO
   * Conservamos los 84px reservados en el layout,
   * pero el panel se superpone al contenido.
   */
  body.sidebar-open .sidebar {
    position: fixed !important;

    top: 0;
    bottom: 0;
    left: 0;

    width:
      min(
        300px,
        calc(100vw - 56px)
      ) !important;

    height: 100dvh;

    padding:
      14px
      18px !important;

    transform:
      none !important;

    box-shadow:
      18px 0 52px
      rgba(0,0,0,.32) !important;
  }

  body.sidebar-open
    .sidebar
    .brand {
    justify-content:
      flex-start !important;

    padding-right: 44px;
  }

  body.sidebar-open
    .sidebar
    .brand-copy {
    display: block !important;
  }

  body.sidebar-open
    .sidebar
    .nav-label {
    height: auto;
    margin:
      16px
      10px
      7px;
    overflow: visible;
    color: inherit;
    border-top: 0;
  }

  body.sidebar-open
    .sidebar-nav a,
  body.sidebar-open
    .sidebar-footer > a {
    justify-content:
      flex-start !important;

    min-height: 44px;

    gap: 12px !important;

    padding:
      0
      12px !important;
  }

  body.sidebar-open
    .sidebar
    .menu-label {
    position: static !important;

    width: auto !important;
    height: auto !important;

    margin: 0 !important;

    overflow: visible !important;
    clip: auto !important;

    white-space: normal !important;
  }

  body.sidebar-open
    .sidebar-user {
    justify-content:
      flex-start !important;
  }

  body.sidebar-open
    .sidebar-user
    > div:last-child {
    display: block !important;
  }

  body.sidebar-open
    .sidebar
    .logout-button {
    display: flex !important;
  }

  /*
   * Al expandir usamos X para cerrar.
   * El botón » queda oculto.
   */
  body.sidebar-open
    .sidebar-collapse-button {
    display: none !important;
  }

  body.sidebar-open
    .sidebar-mobile-close {
    display: grid !important;
  }

  body.sidebar-open
    .sidebar-backdrop {
    display: block !important;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

/* =========================================================
   TELEFONO <= 620
   Mantiene off-canvas completo.
   ========================================================= */

@media (max-width: 620px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns:
      minmax(0, 1fr) !important;
  }

  .page-column {
    grid-column: 1;
  }

  .sidebar-collapse-button {
    display: none !important;
  }

  .mobile-menu {
    display: grid !important;
  }

  .sidebar {
    width:
      min(
        300px,
        calc(100vw - 48px)
      ) !important;

    transform:
      translateX(-102%) !important;
  }

  body.sidebar-open
    .sidebar {
    transform:
      translateX(0) !important;
  }

  body.sidebar-open
    .sidebar-mobile-close {
    display: grid !important;
  }
}

/* Mejor equilibrio del icono activo en el rail */
@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  .sidebar-nav a.active
    .menu-icon {
    width: 25px;
    height: 25px;
  }
}

/* CEDAPSA TABLET SIDEBAR LAYER FIX */

/*
 * El backdrop debe oscurecer únicamente el contenido
 * que queda detrás del menú.
 *
 * Sidebar expandido: 130
 * Backdrop:          100
 */
@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  body.sidebar-open .sidebar {
    z-index: 130 !important;
  }

  body.sidebar-open .sidebar-backdrop {
    z-index: 100 !important;

    background:
      rgba(0, 0, 0, .52);

    backdrop-filter:
      blur(2px);
    -webkit-backdrop-filter:
      blur(2px);
  }

  body.sidebar-open .sidebar-mobile-close {
    z-index: 2;
  }
}

/*
 * En teléfono aplicamos la misma regla:
 * el panel siempre debe permanecer por encima
 * del backdrop.
 */
@media (max-width: 620px) {

  body.sidebar-open .sidebar {
    z-index: 130 !important;
  }

  body.sidebar-open .sidebar-backdrop {
    z-index: 100 !important;
  }
}

/* CEDAPSA TABLET SIDEBAR POLISH V3 */

@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  /*
   * MENÚ EXPANDIDO
   * Reservar una zona exclusiva para el botón de cierre.
   */
  body.sidebar-open
    .sidebar
    .brand {
    position: relative;

    width: 100%;
    min-width: 0;

    padding-right:
      58px !important;

    box-sizing:
      border-box;
  }

  body.sidebar-open
    .sidebar
    .brand-copy {
    display: block !important;

    min-width: 0;
    max-width: 100%;

    overflow: hidden;
  }

  /*
   * El botón X ocupa su propia esquina y no invade
   * logotipo ni wordmark.
   */
  body.sidebar-open
    .sidebar-mobile-close {
    position: absolute;

    top: 13px;
    right: 12px;

    z-index: 5;

    display: grid !important;

    width: 38px;
    height: 38px;

    margin: 0;
    padding: 0;

    place-items: center;

    flex: 0 0 38px;

    border-radius: 11px;

    line-height: 1;
  }

  /*
   * IDENTIDAD DEL USUARIO
   * Avatar a la izquierda; nombre y rol en dos líneas.
   */
  body.sidebar-open
    .sidebar-user {
    display: flex !important;

    align-items: center;
    justify-content:
      flex-start !important;

    gap: 10px;

    min-width: 0;

    padding-left:
      10px !important;
    padding-right:
      10px !important;
  }

  body.sidebar-open
    .sidebar-user
    > div:last-child {
    display: grid !important;

    grid-template-columns:
      minmax(0, 1fr);

    gap: 2px;

    min-width: 0;

    line-height: 1.15;
  }

  body.sidebar-open
    .sidebar-user
    > div:last-child
    > * {
    display: block;

    min-width: 0;
    margin: 0;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.sidebar-open
    .sidebar-user
    strong {
    line-height: 1.2;
  }

  body.sidebar-open
    .sidebar-user
    small {
    line-height: 1.2;
  }

  /*
   * Mantener el botón de cerrar sesión separado
   * de la tarjeta de identidad.
   */
  body.sidebar-open
    .sidebar
    .logout-button {
    margin-top: 8px;
  }
}

/* CEDAPSA TABLET SIDEBAR NO CLOSE BUTTON V4 */

@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  /*
   * En tablet el menú se contrae mediante:
   * - backdrop
   * - navegación
   * - Escape
   *
   * Por lo tanto no se necesita botón X.
   */
  body.sidebar-open
    .sidebar-mobile-close {
    display: none !important;
  }

  /*
   * Recuperar para la marca el espacio
   * que anteriormente se reservaba al X.
   */
  body.sidebar-open
    .sidebar
    .brand {
    padding-right:
      0 !important;
  }

  body.sidebar-open
    .sidebar
    .brand-copy {
    max-width:
      calc(100% - 54px);
  }
}

/* CEDAPSA TABLET BRAND LAYOUT V5 */

@media
  (min-width: 621px)
  and
  (max-width: 1120px) {

  /*
   * En el menú expandido de tablet:
   * CEDAPSA arriba
   * CALIDAD debajo
   * se omite la línea descriptiva.
   */
  body.sidebar-open
    .sidebar
    .brand {
    align-items: flex-start !important;
  }

  body.sidebar-open
    .sidebar
    .brand-copy {
    display: flex !important;

    flex-direction: column;
    align-items: flex-start;
    justify-content: center;

    gap: 3px;

    min-width: 0;
    max-width:
      calc(100% - 58px);

    overflow: hidden;
  }

  body.sidebar-open
    .sidebar
    .brand-copy
    > * {
    flex: 0 0 auto;
    max-width: 100%;
  }

  /*
   * La última línea corresponde al descriptor
   * "Control y liberación". En tablet expandida
   * se elimina para mantener limpia la marca.
   */
  body.sidebar-open
    .sidebar
    .brand-copy
    > :last-child {
    display: none !important;
  }

  /*
   * Evitar que cualquier elemento de la marca
   * intente colocarse junto al siguiente.
   */
  body.sidebar-open
    .sidebar
    .brand-copy
    img,
  body.sidebar-open
    .sidebar
    .brand-copy
    svg,
  body.sidebar-open
    .sidebar
    .brand-copy
    span,
  body.sidebar-open
    .sidebar
    .brand-copy
    strong {
    display: block;
  }
}

/* CEDAPSA CALIDAD F002 VISUAL DRAFT V1 */

.f002-form-shell {
  --f002-photo-min-height: 260px;
}

.f002-photo-profile-note {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-subtle);
}

.f002-photo-profile-note strong {
  font-size: 0.86rem;
}

.f002-photo-profile-note span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.f002-photo-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.f002-photo-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height:
    var(--f002-photo-min-height);
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  background: var(--surface-subtle);
}

.f002-photo-card.has-photo {
  border-style: solid;
}

.f002-photo-card__heading {
  padding: 16px 16px 12px;
}

.f002-photo-card__heading > div {
  display: grid;
  gap: 4px;
}

.f002-photo-card__heading span {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(24, 119, 242, 0.12);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.f002-photo-card__heading strong {
  font-size: 0.95rem;
}

.f002-photo-card__heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.f002-photo-empty {
  display: grid;
  flex: 1;
  min-height: 250px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.f002-photo-empty > span {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 1.7rem;
}

.f002-photo-empty strong {
  color: var(--text);
}

.f002-photo-empty small {
  max-width: 260px;
  line-height: 1.5;
}

.f002-photo-preview {
  display: grid;
  min-height: 260px;
  max-height: 420px;
  place-items: center;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #050a0f;
}

.f002-photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
}

.f002-photo-meta {
  display: grid;
  gap: 3px;
  padding: 12px 16px 0;
  min-width: 0;
}

.f002-photo-meta strong,
.f002-photo-meta span,
.f002-photo-meta small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.f002-photo-meta strong {
  white-space: nowrap;
}

.f002-photo-meta span,
.f002-photo-meta small {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.f002-photo-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding: 16px;
}

.f002-photo-picker {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.f002-photo-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 820px) {
  .f002-photo-grid {
    grid-template-columns: 1fr;
  }

  .f002-photo-preview {
    min-height: 220px;
  }
}

@media (max-width: 620px) {
  .f002-photo-actions {
    flex-direction: column;
  }

  .f002-photo-actions .button,
  .f002-photo-picker {
    width: 100%;
    justify-content: center;
  }

  .f002-photo-empty {
    min-height: 210px;
  }
}

/* CEDAPSA F002 OFFICIAL BUTTON DISABLED V1 */

.f002-form-shell
  .f001-actions
  .button:disabled,
.f002-form-shell
  .f001-actions
  .button[disabled] {
  opacity: 0.46 !important;

  cursor: not-allowed !important;

  background:
    var(--surface-subtle) !important;

  border-color:
    var(--line) !important;

  color:
    var(--muted) !important;

  box-shadow:
    none !important;

  transform:
    none !important;

  filter:
    saturate(0.2);
}

.f002-form-shell
  .f001-actions
  .button:disabled:hover,
.f002-form-shell
  .f001-actions
  .button[disabled]:hover,
.f002-form-shell
  .f001-actions
  .button:disabled:focus,
.f002-form-shell
  .f001-actions
  .button[disabled]:focus {
  background:
    var(--surface-subtle) !important;

  border-color:
    var(--line) !important;

  color:
    var(--muted) !important;

  box-shadow:
    none !important;

  transform:
    none !important;
}

/* CEDAPSA F002 OFFICIAL HISTORY V1 */

.history-evidence-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.history-evidence-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-subtle);
}

.history-evidence-card__heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 16px;
}

.history-evidence-card__heading > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.history-evidence-card__heading > div > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.history-evidence-image {
  display: grid;
  min-height: 260px;
  max-height: 520px;
  place-items: center;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #050a0f;
}

.history-evidence-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 520px;
  object-fit: contain;
}

.history-evidence-card
  .history-signature-meta {
  padding: 14px 16px 16px;
}

.history-f002-observations {
  margin: 0;
  min-height: 70px;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-subtle);
  line-height: 1.6;
  white-space: pre-wrap;
}

.history-kv-wide {
  grid-column: 1 / -1;
}

.history-kv-wide code {
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  .history-evidence-grid {
    grid-template-columns: 1fr;
  }

  .history-evidence-image {
    min-height: 220px;
  }
}

/* CEDAPSA HISTORY BY PROCESS V1 */

.history-hub-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.history-hub-card {
  display: grid;
  grid-template-columns:
    auto minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.history-hub-card__icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-subtle);
  color: var(--accent);
  font-size: 1.45rem;
  font-weight: 700;
}

.history-hub-card__body {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.history-hub-card__body h2,
.history-hub-card__body p {
  margin: 0;
}

.history-hub-card__body > p:not(.eyebrow) {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.55;
}

.history-hub-card__count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.history-hub-card__count span {
  color: var(--muted);
  font-size: 0.8rem;
}

.history-hub-card__count strong {
  font-size: 1.25rem;
}

.history-hub-card .button {
  width: fit-content;
  margin-top: 4px;
}

.sidebar-history-group {
  display: grid;
  gap: 4px;
}

.sidebar-history-subnav {
  display: grid;
  gap: 4px;
  padding-left: 12px;
}

.sidebar-history-subnav a {
  min-height: 42px;
  font-size: 0.82rem;
}

.sidebar-history-subnav .menu-icon {
  width: 17px;
  height: 17px;
}

@media (min-width: 1121px) {
  body.sidebar-collapsed
    .sidebar-history-subnav {
    display: none;
  }
}

@media (
  min-width: 621px
) and (
  max-width: 1120px
) {
  .sidebar-history-subnav {
    display: none;
  }

  body.sidebar-open
    .sidebar-history-subnav {
    display: grid;
  }
}

@media (max-width: 820px) {
  .history-hub-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .history-hub-card {
    grid-template-columns: 1fr;
  }

  .history-hub-card__body
    > p:not(.eyebrow) {
    min-height: 0;
  }

  .history-hub-card .button {
    width: 100%;
    justify-content: center;
  }
}

/* CEDAPSA HISTORY HUB ICONS V2 */

.history-hub-icon-svg {
  display: block;
  width: 27px;
  height: 27px;
  color: var(--accent);
}

.history-hub-icon-svg use {
  pointer-events: none;
}

/* =========================================================
 * CEDAPSA B3B - PDF OFICIAL
 * ======================================================= */

.history-pdf-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid #dbe3ec;
  border-radius: 16px;
  background: #ffffff;
}

.history-pdf-actions__copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
}

.history-pdf-actions__copy strong {
  color: #172033;
  font-size: 14px;
  font-weight: 700;
}

.history-pdf-actions__copy span {
  color: #64748b;
  font-size: 12px;
  line-height: 1.4;
}

.history-pdf-actions__buttons {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .history-pdf-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .history-pdf-actions__buttons {
    width: 100%;
  }

  .history-pdf-actions__buttons .button {
    flex: 1 1 50%;
    justify-content: center;
    text-align: center;
  }
}

/* B4A DISTRIBUTION CONFIG START */

.distribution-config {
  display: grid;
  gap: 16px;
}

.distribution-config__notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.distribution-config__notice strong {
  font-size: 14px;
}

.distribution-config__notice p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.distribution-config__notice-tip {
  flex: 0 1 460px;
  margin: 0 !important;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.distribution-config__grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.distribution-config__card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    border-color .18s ease,
    box-shadow .18s ease;
}

.distribution-config__card.is-enabled {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 55%,
      var(--line)
    );
}

.distribution-config__card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.distribution-config__title {
  min-width: 0;
}

.distribution-config__title h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.distribution-switch {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.distribution-switch:hover {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 45%,
      var(--line)
    );
}

.distribution-switch__track {
  position: relative;
  display: block;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  background:
    color-mix(
      in srgb,
      var(--muted) 26%,
      var(--surface)
    );
  transition: background .18s ease;
}

.distribution-switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: white;
  box-shadow:
    0 1px 3px
    rgba(0,0,0,.28);
  transition:
    transform .18s ease;
}

.distribution-switch.is-on {
  border-color:
    color-mix(
      in srgb,
      var(--primary) 55%,
      var(--line)
    );
  color: var(--text);
}

.distribution-switch.is-on
.distribution-switch__track {
  background: var(--primary);
}

.distribution-switch.is-on
.distribution-switch__thumb {
  transform:
    translateX(15px);
}

.distribution-switch__text {
  font-size: 11px;
  font-weight: 800;
}

.distribution-config__active-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 13px;
  padding: 5px 9px;
  border-radius: 999px;
  background:
    color-mix(
      in srgb,
      var(--success) 12%,
      transparent
    );
  color: var(--success);
  font-size: 10px;
  font-weight: 800;
}

.distribution-config__active-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.distribution-config__fields {
  display: grid;
  gap: 13px;
  padding-top: 16px;
}

.distribution-email-field {
  display: grid;
  gap: 7px;
}

.distribution-email-field__label,
.distribution-config__field > span {
  font-size: 11px;
  font-weight: 800;
}

.distribution-email-field__control {
  min-height: 43px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  cursor: text;
}

.distribution-email-field__control:focus-within {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px
    color-mix(
      in srgb,
      var(--primary) 14%,
      transparent
    );
}

.distribution-email-field__control input {
  flex: 1 1 180px;
  min-width: 130px;
  height: 29px;
  padding: 2px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
}

.distribution-email-chip {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px 5px 9px;
  border: 1px solid
    color-mix(
      in srgb,
      var(--primary) 35%,
      var(--line)
    );
  border-radius: 999px;
  background:
    color-mix(
      in srgb,
      var(--primary) 9%,
      var(--surface)
    );
  color: var(--text);
  font-size: 11px;
}

.distribution-email-chip > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.distribution-email-chip button {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.distribution-email-chip button {
  outline: none;
  box-shadow: none;
}

.distribution-email-chip button:hover {
  background:
    color-mix(
      in srgb,
      var(--muted) 14%,
      transparent
    );
  color: var(--text);
}

.distribution-email-chip button:focus-visible {
  background:
    color-mix(
      in srgb,
      var(--primary) 14%,
      transparent
    );
  color: var(--text);
  box-shadow:
    0 0 0 2px
    color-mix(
      in srgb,
      var(--primary) 35%,
      transparent
    );
}

.distribution-config__optional-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -3px;
}

.distribution-config__optional-actions button,
.distribution-config__optional-heading button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.distribution-config__optional-actions button:hover,
.distribution-config__optional-heading button:hover {
  text-decoration: underline;
}

.distribution-config__optional-fields {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.distribution-config__optional-field {
  min-width: 0;
}

.distribution-config__optional-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.distribution-config__optional-heading > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.distribution-config__optional-heading
+ .distribution-email-field
> .distribution-email-field__label {
  display: none;
}

.distribution-config__field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.distribution-config__field small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.distribution-config__field small code {
  color: var(--text);
}

.distribution-config__field input,
.distribution-config__field textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.45;
}

.distribution-config__field textarea {
  resize: vertical;
  min-height: 76px;
}

.distribution-config__field input:focus,
.distribution-config__field textarea:focus {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px
    color-mix(
      in srgb,
      var(--primary) 14%,
      transparent
    );
}

.distribution-config__inline-error {
  padding: 8px 10px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 11px;
  font-weight: 700;
}

.distribution-config__flash {
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

.distribution-config__flash.is-success {
  border-color: var(--success);
  color: var(--success);
}

.distribution-config__flash.is-error {
  border-color: var(--danger);
  color: var(--danger);
}

.distribution-config__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.distribution-config__actions > span {
  max-width: 52%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.distribution-config__actions .button {
  flex: 0 0 auto;
  min-height: 38px;
  padding-block: 7px;
  font-size: 12px;
}

.distribution-config__actions .button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

@media (max-width: 1150px) {
  .distribution-config__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .distribution-config__notice {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .distribution-config__notice-tip {
    padding-top: 11px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .distribution-config__optional-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .distribution-config__card {
    padding: 16px;
  }

  .distribution-config__card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .distribution-switch {
    align-self: flex-start;
  }

  .distribution-config__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .distribution-config__actions > span {
    max-width: none;
  }

  .distribution-config__actions .button {
    width: 100%;
  }
}

/* B4A DISTRIBUTION CONFIG END */

/* EMAIL CHIP REMOVE STATE FIX START */

/*
 * El botón X es una acción secundaria, no una
 * acción destructiva. Mantiene apariencia neutra
 * independientemente de hover/focus/active para
 * evitar estados residuales del navegador.
 */

.distribution-email-field__control
.distribution-email-chip
> button {
  appearance: none !important;
  -webkit-appearance: none !important;

  background: transparent !important;
  color: var(--muted) !important;

  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;

  opacity: .72;
  cursor: pointer;

  transition:
    opacity .12s ease;
}

.distribution-email-field__control
.distribution-email-chip
> button:hover,
.distribution-email-field__control
.distribution-email-chip
> button:focus,
.distribution-email-field__control
.distribution-email-chip
> button:focus-visible,
.distribution-email-field__control
.distribution-email-chip
> button:active {
  background: transparent !important;
  color: var(--muted) !important;

  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

/*
 * Solo cuando el puntero está realmente encima
 * de la X se hace ligeramente más visible.
 * No cambia a rojo.
 */
@media (hover: hover) and (pointer: fine) {
  .distribution-email-field__control
  .distribution-email-chip
  > button:hover {
    opacity: 1;
  }
}

/* EMAIL CHIP REMOVE STATE FIX END */

/* =========================================================
   F001 Piece Image V1
   ========================================================= */

.f001-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.f001-piece-image-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding-inline: 0.7rem;
  cursor: pointer;
  overflow: hidden;
}

.f001-piece-image-button.is-busy {
  opacity: 0.65;
  cursor: wait;
}

.f001-piece-image-button input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.f001-upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  font-weight: 700;
}

.f001-piece-image-preview {
  display: flex;
  width: 2.5rem;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border-subtle, #d7e0ea);
  border-radius: 0.45rem;
  background: #ffffff;
}

.f001-piece-image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.f001-piece-image-remove {
  min-height: 2rem;
}

@media (max-width: 760px) {
  .f001-row-heading {
    align-items: flex-start;
    gap: 0.65rem;
  }

  .f001-row-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
