/* =========================================================
   NeuroPACS / AngioPACS
   CSS limpio desde cero
   ========================================================= */

:root {
  --navy-900: #0d1d2e;
  --navy-800: #142b42;
  --navy-700: #18364f;

  --blue-600: #5fa3bd;
  --blue-500: #76b4ca;
  --blue-100: #e7f2f5;

  --green-600: #4f6f3f;
  --green-100: #edf3e8;

  --amber-600: #d89510;
  --amber-100: #f7edcf;

  --red-600: #d9161c;
  --red-100: #f6dada;

  --cream-600: #d9cfaa;
  --cream-300: #eee7cf;
  --cream-100: #f7f3e5;

  --bg: #d9cfaa;
  --panel: #f7f3e5;
  --card: #fffaf0;
  --card-soft: #f4edd7;

  --text: #102033;
  --muted: #66706d;
  --border: rgba(16, 32, 51, 0.14);

  --shadow-sm: 0 8px 18px rgba(16, 32, 51, 0.08);
  --shadow-md: 0 18px 42px rgba(16, 32, 51, 0.14);
}



* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);

  background:
    linear-gradient(
      90deg,
      var(--green-600) 0%,
      var(--green-600) 25%,
      var(--blue-600) 25%,
      var(--blue-600) 50%,
      var(--amber-600) 50%,
      var(--amber-600) 75%,
      var(--red-600) 75%,
      var(--red-600) 100%
    ) top left / 100% 12px no-repeat,
    linear-gradient(135deg, #d9cfaa 0%, #eee7cf 45%, #f7f3e5 100%);
}

/* =========================================================
   Layout principal
   ========================================================= */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #ffffff;

  background:
    linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 52%, var(--navy-700) 100%);
  border-right: 5px solid var(--blue-600);
  box-shadow: 12px 0 32px rgba(16, 32, 51, 0.20);
}

.main-panel {
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 45% 0%, rgba(255,255,255,0.45) 0%, rgba(247,243,229,0.88) 42%, rgba(217,207,170,0.78) 100%);
}

/* =========================================================
   Marca lateral
   ========================================================= */

.side-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 30px;
}

.side-brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 4px;
  border: 3px solid var(--blue-500);
  box-shadow:
    0 0 0 3px rgba(111, 138, 91, 0.35),
    0 10px 26px rgba(0,0,0,0.32);
  flex-shrink: 0;
}

.side-brand-text h1,
.side-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0.04em;
  color: #ffffff;
}

.side-brand-text p,
.side-brand p {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.25;
  color: rgba(232, 244, 250, 0.82);
}

/* =========================================================
   Navegación lateral
   ========================================================= */

.side-section,
.nav-section {
  margin: 26px 0 10px;
  color: #abd2e2;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.side-link,
.nav-link {
  display: block;
  padding: 12px 13px;
  margin-bottom: 8px;
  border-radius: 13px;
  color: #edf8fc;
  font-weight: 800;
  text-decoration: none;
  border-left: 5px solid transparent;
  background: rgba(255,255,255,0.035);
  transition: 0.16s ease;
}

.side-link:hover,
.nav-link:hover {
  background: rgba(70, 169, 207, 0.24);
  color: #ffffff;
  border-left-color: var(--blue-500);
  transform: translateX(2px);
  text-decoration: none;
}

.side-link.active,
.side-link[aria-current="page"],
.nav-link.active {
  background: linear-gradient(90deg, rgba(47,145,183,0.38), rgba(111,138,91,0.22));
  border-left-color: var(--green-600);
}

/* =========================================================
   Barra superior
   ========================================================= */

.topbar {
  background:
    linear-gradient(90deg, #101819 0%, var(--navy-900) 45%, var(--navy-800) 100%);
  color: #ffffff;
  padding: 24px 32px 22px;
  border-bottom: 5px solid var(--blue-600);
  box-shadow: 0 12px 28px rgba(16, 32, 51, 0.18);
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.05em;
  color: #ffffff;
}

.brand span {
  color: rgba(232, 244, 250, 0.82);
  font-size: 13px;
}

/* =========================================================
   Contenido
   ========================================================= */

.container {
  max-width: 1240px;
  margin: 28px auto;
  padding: 0 24px 46px;
}

.card,
.metric,
.login-card {
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid rgba(79, 111, 63, 0.22);
  border-top: 6px solid var(--blue-600);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
  padding: 22px;
  margin-bottom: 24px;
}

.card-title {
  margin: 0 0 16px;
  font-size: 19px;
  color: var(--text);
}

.card h1,
.card h2 {
  color: var(--text);
}

.card.dark {
  background: var(--navy-800);
  color: #ffffff;
}

/* Tarjeta resumen */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric {
  border-top-color: var(--green-600);
}

.metric .number {
  font-size: 28px;
  font-weight: 900;
  color: var(--navy-900);
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

/* =========================================================
   Formularios
   ========================================================= */

label {
  display: block;
  font-weight: 900;
  font-size: 13px;
  margin-bottom: 7px;
  color: var(--text);
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 13px;
  border: 1px solid rgba(16, 32, 51, 0.16);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
}

textarea {
  min-height: 78px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 4px rgba(47,145,183,0.16);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  align-items: end;
}

.filters-wide {
  grid-column: span 2;
}

.filters-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-bottom: 13px;
}

/* =========================================================
   Botones
   ========================================================= */

.btn,
button {
  display: inline-block;
  padding: 11px 15px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 900;
  background: var(--blue-600);
  color: #ffffff;
  border: 1px solid #1f6f8d;
  box-shadow: 0 6px 14px rgba(47,145,183,0.22);
  cursor: pointer;
}

.btn:hover,
button:hover {
  background: var(--navy-800);
  text-decoration: none;
}

.btn-secondary {
  background: #536878;
  border-color: #3d4f5d;
}

.btn-danger {
  background: var(--red-600);
  border-color: #8d2424;
}

.btn-small {
  padding: 6px 9px;
  font-size: 12px;
  border-radius: 8px;
}

td form {
  margin: 0;
}

/* =========================================================
   Tablas
   ========================================================= */

.table-wrap {
  overflow-x: auto;
}

.table,
.card table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid rgba(47, 145, 183, 0.24);
  border-radius: 14px;
  overflow: hidden;
}

.card table {
  display: block;
  overflow-x: auto;
  white-space: nowrap;
  margin-top: 10px;
}

.table th,
.table td,
.card th,
.card td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(16, 32, 51, 0.09);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.table th,
.card th {
  background: var(--blue-100);
  color: var(--navy-900);
  font-weight: 900;
  border-bottom: 1px solid rgba(47, 145, 183, 0.28);
}

.table tr:nth-child(even),
.card tr:nth-child(even) {
  background: #f6fbfd;
}

.table tr:hover,
.card tr:hover {
  background: #eaf6fb;
}

.clinical-table th,
.clinical-table td {
  font-size: 13px;
}

.diagnosis-cell {
  max-width: 280px;
  white-space: normal;
}

/* =========================================================
   Badges, chips, auxiliares
   ========================================================= */

a {
  color: var(--navy-800);
  font-weight: 800;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: var(--blue-100);
  color: var(--navy-900);
  border: 1px solid rgba(47,145,183,0.25);
}

.badge-img {
  background: #dff2fa;
}

.badge-empty {
  background: var(--red-100);
  color: var(--red-600);
}

.small,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.operator-strip,
.summary-operators,
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.operator-chip,
.tag-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--green-100);
  border: 1px solid rgba(111,138,91,0.28);
  border-left: 6px solid var(--green-600);
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.operator-chip:nth-child(4n+1) { border-left-color: var(--green-600); }
.operator-chip:nth-child(4n+2) { border-left-color: var(--blue-600); }
.operator-chip:nth-child(4n+3) { border-left-color: var(--amber-600); }
.operator-chip:nth-child(4n+4) { border-left-color: var(--red-600); }

img,
video {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #111;
}

/* =========================================================
   Grillas
   ========================================================= */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px,1fr));
  gap: 20px;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.three {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.2fr;
  gap: 14px;
}

.four {
  display: grid;
  grid-template-columns: 1.4fr 1fr .6fr 1.2fr;
  gap: 14px;
}

/* =========================================================
   Repositorios / auditoría / metadata
   ========================================================= */

.inline-form {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.repo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.repo-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(47,145,183,0.22);
  border-radius: 16px;
  background: #f6fbfd;
}

.repo-form,
.repo-merge-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.repo-form input,
.repo-merge-form select {
  margin-bottom: 0;
}

.repo-disabled {
  opacity: .55;
}

.tag-disabled {
  opacity: .45;
  text-decoration: line-through;
}

.audit-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.audit-form select,
.audit-form input {
  margin-bottom: 0;
}

.file-meta-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.file-meta-form textarea {
  min-height: 64px;
}

/* =========================================================
   Login
   ========================================================= */

.login-body {
  min-height: 100vh;
  background:
    linear-gradient(
      90deg,
      var(--green-600) 0%,
      var(--green-600) 25%,
      var(--blue-600) 25%,
      var(--blue-600) 50%,
      var(--amber-600) 50%,
      var(--amber-600) 75%,
      var(--red-600) 75%,
      var(--red-600) 100%
    ) top left / 100% 10px no-repeat,
    radial-gradient(circle at 50% 0%, #ffffff 0%, #f3f8fb 35%, #dbe8f0 100%);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  border-top: 8px solid var(--blue-600);
  padding: 30px;
}

.login-card::before {
  content: "";
  display: block;
  height: 6px;
  margin: -30px -30px 24px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(90deg, var(--green-600), var(--blue-600), var(--amber-600), var(--red-600));
}

.login-brand-with-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-brand-logo {
  width: 62px;
  height: 62px;
  object-fit: contain;
  border-radius: 50%;
  background: #ffffff;
  padding: 4px;
  border: 2px solid rgba(47,145,183,0.28);
  box-shadow: 0 10px 24px rgba(15, 32, 53, 0.16);
  flex-shrink: 0;
}

.login-brand {
  font-size: 32px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: .03em;
  color: var(--navy-900);
}

.login-subtitle {
  color: var(--muted);
  margin: 4px 0 0;
}

.login-button {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  background: var(--red-100);
  color: var(--red-600);
  border: 1px solid rgba(180,50,50,0.25);
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 800;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 700px) {
  .filters-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filters-wide {
    grid-column: span 2;
  }
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #ffffff;

  background:
    linear-gradient(180deg, #102033 0%, #18364f 55%, #203f55 100%);
  border-right: 5px solid var(--blue-600);
  box-shadow: 12px 0 32px rgba(16, 32, 51, 0.20);
}

@media (max-width: 900px) {
  .three,
  .four,
  .audit-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .two,
  .filters-grid,
  .repo-item,
  .repo-form,
  .repo-merge-form {
    grid-template-columns: 1fr;
  }

  .filters-wide {
    grid-column: span 1;
  }

  .filters-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .brand {
    display: block;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand span {
    display: block;
    margin-top: 6px;
  }

  .container {
    margin-top: 20px;
    padding: 0 12px 32px;
  }

  .card,
  .metric {
    padding: 16px;
    border-radius: 16px;
  }

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

  .clinical-table {
    min-width: 1050px;
  }

  .table th,
  .table td,
  .card th,
  .card td {
    padding: 10px 9px;
    font-size: 13px;
  }
}

/* Ajuste fino detalle de procedimiento */
.page-actions,
.container > .btn:first-child {
  margin-top: 10px;
}

.container > .btn {
  margin-bottom: 10px;
}

.case-summary-card {
  margin-top: 6px;
}


/* =========================================================
   NEUROPACS PASTEL THEME - capa final
   ========================================================= */

:root {
  --pastel-cream: #d9cfaa;
  --pastel-cream-light: #f4ecd2;
  --pastel-cream-card: #fff8e8;

  --pastel-green: #4f6f3f;
  --pastel-blue: #5fa3bd;
  --pastel-yellow: #d89510;
  --pastel-red: #d9161c;

  --pastel-navy: #102033;
  --pastel-navy-2: #18364f;

  --text: #102033;
  --muted: #66706d;
  --border: rgba(16, 32, 51, 0.14);
}

/* Fondo general pastel tipo referencia */
body,
.login-body {
  background:
    linear-gradient(
      90deg,
      var(--pastel-green) 0%,
      var(--pastel-green) 25%,
      var(--pastel-blue) 25%,
      var(--pastel-blue) 50%,
      var(--pastel-yellow) 50%,
      var(--pastel-yellow) 75%,
      var(--pastel-red) 75%,
      var(--pastel-red) 100%
    ) top left / 100% 12px no-repeat,
    linear-gradient(135deg, #d9cfaa 0%, #ece3c8 42%, #f7f0dc 100%) !important;
}

/* Panel principal cálido */
.main-panel {
  background:
    radial-gradient(circle at 42% 0%, rgba(255,255,255,0.50) 0%, rgba(247,240,220,0.88) 42%, rgba(217,207,170,0.72) 100%) !important;
}

/* Sidebar sobrio, pero no negro */
.sidebar {
  background:
    linear-gradient(180deg, #102033 0%, #18364f 55%, #203f55 100%) !important;
  border-right: 5px solid var(--pastel-blue) !important;
}

/* Barra superior */
.topbar {
  background:
    linear-gradient(90deg, #102033 0%, #18364f 70%, #203f55 100%) !important;
  border-bottom: 5px solid var(--pastel-blue) !important;
}

/* Tarjetas pastel */
.card,
.metric,
.login-card {
  background: rgba(255, 248, 232, 0.96) !important;
  border: 1px solid rgba(79, 111, 63, 0.24) !important;
  border-top: 6px solid var(--pastel-blue) !important;
  box-shadow: 0 18px 42px rgba(16, 32, 51, 0.13) !important;
}

/* Resumen con verde */
.metric {
  border-top-color: var(--pastel-green) !important;
}

/* Formularios */
input,
textarea,
select {
  background: #fffdf5 !important;
  border: 1px solid rgba(16, 32, 51, 0.18) !important;
}

input:focus,
textarea:focus,
select:focus {
  outline: none !important;
  border-color: var(--pastel-blue) !important;
  box-shadow: 0 0 0 4px rgba(95, 163, 189, 0.20) !important;
}

/* Tablas */
.table th,
.card th {
  background: #efe6c7 !important;
  color: #102033 !important;
  border-bottom: 1px solid rgba(95, 163, 189, 0.28) !important;
}

.table tr:nth-child(even),
.card tr:nth-child(even) {
  background: #fbf4df !important;
}

.table tr:hover,
.card tr:hover {
  background: #f2e9cf !important;
}

/* Botones */
.btn,
button {
  background: var(--pastel-blue) !important;
  color: #ffffff !important;
  border: 1px solid #3e829b !important;
}

.btn:hover,
button:hover {
  background: var(--pastel-navy) !important;
}

.btn-secondary {
  background: #526878 !important;
  border-color: #405564 !important;
}

.btn-danger {
  background: var(--pastel-red) !important;
  border-color: #9d1015 !important;
}

/* Links laterales */
.side-link {
  background: rgba(255,255,255,0.04) !important;
  border-left: 5px solid transparent !important;
}

.side-link:hover {
  background: rgba(95, 163, 189, 0.22) !important;
  border-left-color: var(--pastel-blue) !important;
}

.side-section {
  color: #d8d0aa !important;
}

/* Badges / chips */
.badge,
.badge-img {
  background: #efe6c7 !important;
  color: #102033 !important;
  border: 1px solid rgba(79,111,63,0.25) !important;
}

.operator-chip,
.tag-chip {
  background: #edf3e8 !important;
  border: 1px solid rgba(79,111,63,0.28) !important;
  border-left: 6px solid var(--pastel-green) !important;
}

/* Status flotante de guardado */
.save-status {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9999;
  padding: 10px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(16, 32, 51, 0.18);
  transition: 0.18s ease;
}

.save-status.saved {
  background: #edf3e8;
  color: #345328;
  border: 1px solid rgba(79,111,63,0.32);
}

.save-status.dirty {
  background: #f7edcf;
  color: #8a5b00;
  border: 1px solid rgba(216,149,16,0.40);
}

.save-status.saving {
  background: #e7f2f5;
  color: #245d70;
  border: 1px solid rgba(95,163,189,0.40);
}

.save-status.error {
  background: #f6dada;
  color: #9d1015;
  border: 1px solid rgba(217,22,28,0.35);
}



/* =========================================================
   ANGIO-014/016: estado de casos y repositorios colapsables
   ========================================================= */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--border);
  background: var(--card-soft);
  white-space: nowrap;
}

.status-abierto {
  background: var(--green-100);
  color: var(--green-600);
}

.status-hospitalizado {
  background: var(--amber-100);
  color: var(--amber-600);
}

.status-pendiente_control {
  background: var(--blue-100);
  color: var(--blue-600);
}

.status-de_alta {
  background: var(--cream-300);
  color: var(--muted);
}

.repo-group {
  padding: 0;
  overflow: hidden;
}

.repo-summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-weight: 900;
  color: var(--text);
}

.repo-summary::-webkit-details-marker {
  display: none;
}

.repo-summary::after {
  content: "Abrir";
  font-size: 12px;
  color: var(--muted);
}

.repo-group[open] .repo-summary::after {
  content: "Cerrar";
}

.repo-group .repo-list {
  padding: 0 22px 22px;
}


/* =========================================================
   ANGIO-026/028: panel diagnóstico DICOM / Orthanc
   ========================================================= */

.dicom-debug-panel {
  margin: 16px 0 22px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.dicom-debug-box {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  border-top: 5px solid var(--blue-600);
}

.dicom-debug-box .number {
  font-size: 28px;
  font-weight: 900;
}

.dicom-debug-box .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.dicom-error-details {
  margin-top: 16px;
}

.dicom-error-details summary {
  cursor: pointer;
  font-weight: 900;
  margin-bottom: 10px;
}

.dicom-error-item {
  background: var(--red-100);
  border-left: 5px solid var(--red-600);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

.dicom-error-item pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  background: rgba(255,255,255,0.7);
  border-radius: 10px;
  padding: 10px;
}

/* ANGIO-035: botones múltiples para DICOM */
.dicom-viewer-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.viewer-link-secondary {
  background: rgba(255, 250, 240, 0.92);
  color: var(--text);
  border: 1px solid var(--border);
}


/* =========================================================
   ANGIO-037: carga múltiple drag and drop
   ========================================================= */

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 140px;
  margin-bottom: 12px;
  padding: 22px;
  border: 2px dashed rgba(95, 163, 189, 0.75);
  border-radius: 18px;
  background: rgba(231, 242, 245, 0.42);
  cursor: pointer;
  text-align: center;
  transition: 0.18s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
  background: rgba(231, 242, 245, 0.82);
  border-color: var(--pastel-blue, #5fa3bd);
  box-shadow: 0 0 0 4px rgba(95, 163, 189, 0.16);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 6px;
}

.upload-file-list {
  white-space: pre-wrap;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 253, 245, 0.86);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}


/* =========================================================
   ANGIO-040: botones de caso, modal copiar datos y viewers
   ========================================================= */

.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 18px;
}

.case-actions .btn,
.dicom-viewer-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  line-height: 1.15;
  white-space: nowrap;
}

.dicom-viewer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.dicom-viewer-actions a {
  text-decoration: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 32, 51, 0.55);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(720px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 22px;
  background: var(--card, #fff8e8);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
}

#copy-data-textarea {
  width: 100%;
  min-height: 340px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}


/* =========================================================
   ANGIO-041: fix copiar datos, botones compactos y export
   ========================================================= */

.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 18px;
}

.case-actions .btn,
.dicom-card .btn,
.dicom-viewer-actions .btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  line-height: 1.1;
  white-space: nowrap;
  width: auto;
  max-width: 100%;
  margin: 4px 4px 4px 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 32, 51, 0.55);
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-card {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 22px;
  background: var(--card, #fff8e8);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  width: 38px;
  height: 38px;
  padding: 0 !important;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
}

#copy-data-textarea {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}


/* =========================================================
   ANGIO-042: modal por CSS :target y botones corregidos
   ========================================================= */

.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 18px;
}

.case-actions .btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  line-height: 1.1;
  white-space: nowrap;
  width: auto;
  max-width: 100%;
}

.angio-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20000;
  place-items: center;
  padding: 20px;
  background: rgba(16, 32, 51, 0.58);
}

.angio-modal:target {
  display: grid;
}

.angio-modal-card {
  width: min(760px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  border-radius: 22px;
  background: var(--card, #fff8e8);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.angio-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.angio-modal-header h2 {
  margin: 0;
}

.angio-modal-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: rgba(0,0,0,0.08);
  color: inherit;
  font-size: 24px;
  font-weight: 900;
}

#angio-copy-textarea {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  font-size: 13px;
}

.angio-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}


/* =========================================================
   ANGIO-043: dialog copiar datos y borrado admin
   ========================================================= */

.angio-copy-dialog {
  width: min(760px, 96vw);
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: transparent;
}

.angio-copy-dialog::backdrop {
  background: rgba(16, 32, 51, 0.62);
}

.angio-copy-dialog-card {
  padding: 22px;
  border-radius: 22px;
  background: var(--card, #fff8e8);
  border: 1px solid var(--border);
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
}

.angio-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.angio-dialog-header h2 {
  margin: 0;
}

.angio-dialog-close {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 1;
  padding: 0 !important;
}

#angio-copy-textarea {
  width: 100%;
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  font-size: 13px;
}

.angio-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.btn-danger {
  background: #b94a48 !important;
  color: white !important;
  border-color: #9f3735 !important;
}

.danger-card {
  border-color: rgba(185, 74, 72, 0.55) !important;
  background: rgba(255, 235, 230, 0.92) !important;
}

.delete-details summary {
  cursor: pointer;
  list-style: none;
}

.delete-details summary::-webkit-details-marker {
  display: none;
}

.delete-form {
  min-width: 260px;
  margin-top: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--border);
}

.inline-check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}


/* =========================================================
   ANGIO-044: galería, copy textarea alto y tabla limpia
   ========================================================= */

#angio-copy-textarea {
  min-height: 22em !important;
  height: 22em !important;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 14px;
  background: #111;
}

.gallery-caption {
  margin-top: 10px;
}


/* =========================================================
   ANGIO-045: sidebar único consistente
   ========================================================= */

.sidebar {
  overflow-y: auto;
}

.side-link.active {
  background: rgba(95, 163, 189, 0.28);
  border-left: 4px solid var(--pastel-blue, #5fa3bd);
}

.repo-group {
  scroll-margin-top: 24px;
}


.case-activity {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.case-activity li {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.04);
    line-height: 1.45;
}

.case-log {
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.4;
    max-height: 360px;
    overflow: auto;
}


.upload-status {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.05);
}

.upload-status.ok {
    background: rgba(22, 163, 74, 0.12);
}

.upload-status.error {
    background: rgba(220, 38, 38, 0.12);
}

.upload-status.saving,
.upload-status.info {
    background: rgba(14, 165, 233, 0.12);
}

.upload-progress-wrap {
    width: 100%;
    height: 8px;
    margin-top: 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: rgba(14, 165, 233, 0.85);
    transition: width 0.2s ease;
}


/* NeuroPACS - usuario / perfil */
.side-user-box {
    margin: 8px 12px 12px 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.10);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.side-user-box span {
    opacity: 0.85;
}

.side-warning {
    color: #ffe082;
    font-weight: 700;
}

.inline-reset-form {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
}

.inline-reset-form input {
    min-width: 140px;
}

.actions-cell {
    min-width: 260px;
}

.warning-card {
    border-left: 5px solid #f5a623;
}

.success-card {
    border-left: 5px solid #31a354;
}


/* ANGIO - filtros activos y ordenamiento */
.active-filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 18px;
  padding: 12px 14px;
  border: 1px solid rgba(16, 32, 51, 0.14);
  border-left: 5px solid var(--amber-600);
  border-radius: 16px;
  background: rgba(255, 250, 240, 0.86);
  box-shadow: var(--shadow-sm);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--blue-100);
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 800;
}

.table-sort-link {
  color: inherit;
  text-decoration: none;
  font-weight: 900;
}

.table-sort-link:hover {
  text-decoration: underline;
}

.table-sort-link.active {
  color: var(--blue-600);
}

.btn-small {
  padding: 7px 10px;
  font-size: 12px;
}

/* =========================================================
   ANGIO-MOBILE-CLEAN-V5
   Capa móvil limpia y estable.
   - Desktop: sidebar clásico + contenido.
   - Mobile: sidebar plegable + cards compactas.
   ========================================================= */

/* Base: botón móvil oculto fuera de celular */
.mobile-menu-toggle {
  display: none !important;
}

.mobile-filters summary {
  display: none;
}

/* -------------------- Desktop / tablet grande -------------------- */
@media (min-width: 701px) {

  html,
  body {
    overflow-x: auto;
  }

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

  .app-shell > .sidebar {
    grid-column: 1 !important;
    display: block !important;
    position: sticky !important;
    top: 0 !important;
    width: 280px !important;
    height: 100vh !important;
    min-height: 100vh !important;
    padding: 24px 18px !important;
    border-right: 5px solid var(--blue-600) !important;
    border-bottom: 0 !important;
  }

  .app-shell > .main-panel {
    grid-column: 2 !important;
    display: block !important;
    min-width: 0 !important;
    width: auto !important;
  }

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

  .mobile-filters summary {
    display: none !important;
  }

  .container {
    max-width: 1240px !important;
    margin: 28px auto !important;
    padding: 0 24px 46px !important;
  }

  .topbar {
    padding: 24px 32px 22px !important;
  }

  .brand {
    display: flex !important;
    align-items: baseline !important;
    justify-content: space-between !important;
    gap: 16px !important;
  }

  .filters-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(160px, 1fr)) !important;
    gap: 14px !important;
    align-items: end !important;
  }

  .filters-wide {
    grid-column: span 2 !important;
  }

  button,
  .btn {
    width: auto !important;
  }

  table.procedimientos-table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse !important;
    overflow: visible !important;
  }

  table.procedimientos-table thead {
    display: table-header-group !important;
  }

  table.procedimientos-table tbody {
    display: table-row-group !important;
  }

  table.procedimientos-table tr {
    display: table-row !important;
  }

  table.procedimientos-table th,
  table.procedimientos-table td {
    display: table-cell !important;
    white-space: normal !important;
  }

  table.procedimientos-table td::before {
    display: none !important;
    content: none !important;
  }
}

/* -------------------- Mobile real -------------------- */
@media (max-width: 700px) {

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 15px;
    background:
      linear-gradient(
        90deg,
        var(--green-600) 0%,
        var(--green-600) 25%,
        var(--blue-600) 25%,
        var(--blue-600) 50%,
        var(--amber-600) 50%,
        var(--amber-600) 75%,
        var(--red-600) 75%,
        var(--red-600) 100%
      ) top left / 100% 8px no-repeat,
      var(--cream-100);
  }

  .app-shell {
    display: block !important;
    min-height: 100vh !important;
  }

  .main-panel {
    width: 100% !important;
    min-width: 0 !important;
    min-height: auto !important;
  }

  .sidebar {
    display: block !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 9999 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-right: 0 !important;
    border-bottom: 5px solid var(--blue-600) !important;
    box-shadow: 0 8px 22px rgba(16, 32, 51, 0.25) !important;
  }

  .sidebar > .mobile-menu-toggle {
    display: block !important;
    width: 100% !important;
    min-height: 50px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: linear-gradient(90deg, var(--navy-900), var(--navy-800)) !important;
    color: #fff !important;
    text-align: left !important;
    font-size: 18px !important;
    font-weight: 900 !important;
    box-shadow: none !important;
  }

  .sidebar:not(.mobile-open) > :not(.mobile-menu-toggle):not(script) {
    display: none !important;
  }

  .sidebar.mobile-open {
    padding: 14px 12px !important;
  }

  .sidebar.mobile-open > .mobile-menu-toggle {
    margin: -14px -12px 12px !important;
    width: calc(100% + 24px) !important;
  }

  .side-brand {
    margin-bottom: 12px !important;
  }

  .side-brand-logo {
    width: 44px !important;
    height: 44px !important;
  }

  .side-brand-text h1,
  .side-brand h1 {
    font-size: 20px !important;
  }

  .side-brand-text p,
  .side-brand p {
    font-size: 10px !important;
  }

  .side-section,
  .nav-section {
    margin: 16px 0 8px !important;
  }

  .side-link,
  .nav-link {
    padding: 10px 11px !important;
    margin-bottom: 6px !important;
    border-radius: 11px !important;
    font-size: 13px !important;
  }

  .side-user-box {
    font-size: 13px !important;
  }

  .topbar {
    padding: 16px 14px !important;
    border-bottom-width: 4px !important;
  }

  .brand {
    display: block !important;
  }

  .brand h1 {
    font-size: 21px !important;
    line-height: 1.15 !important;
    margin-bottom: 5px !important;
  }

  .brand span {
    display: block !important;
    font-size: 12px !important;
    line-height: 1.3 !important;
  }

  .container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 14px auto !important;
    padding: 0 10px 28px !important;
  }

  .card,
  .metric,
  .login-card {
    width: 100% !important;
    padding: 14px !important;
    margin-bottom: 14px !important;
    border-radius: 16px !important;
    border-top-width: 5px !important;
  }

  .card-title,
  .card h1,
  .card h2 {
    font-size: 18px !important;
    line-height: 1.2 !important;
    margin-bottom: 12px !important;
  }

  .summary {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .metric .number {
    font-size: 24px !important;
  }

  .metric .label {
    font-size: 12px !important;
  }

  .two,
  .three,
  .grid,
  .form-grid,
  .filters-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .filters-wide {
    grid-column: auto !important;
  }

  label {
    font-size: 12px !important;
    margin-bottom: 5px !important;
  }

  input,
  textarea,
  select {
    font-size: 16px !important;
    padding: 10px 11px !important;
    margin-bottom: 9px !important;
    border-radius: 11px !important;
  }

  textarea {
    min-height: 72px !important;
  }

  .filters-actions,
  .actions,
  .actions-cell,
  .button-row,
  .case-actions,
  .inline-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    width: 100% !important;
  }

  button,
  .btn {
    width: 100% !important;
    min-height: 42px !important;
    padding: 10px 12px !important;
    font-size: 14px !important;
    text-align: center !important;
    margin-bottom: 7px !important;
  }

  .mobile-filters {
    display: block !important;
    background: rgba(255, 250, 240, 0.96) !important;
    border: 1px solid rgba(79, 111, 63, 0.22) !important;
    border-top: 6px solid var(--blue-600) !important;
    border-radius: 18px !important;
    box-shadow: var(--shadow-md) !important;
    padding: 0 !important;
    margin-bottom: 18px !important;
    overflow: hidden !important;
  }

  .mobile-filters summary {
    display: block !important;
    padding: 16px !important;
    cursor: pointer !important;
    font-size: 20px !important;
    font-weight: 900 !important;
    color: var(--text) !important;
    list-style: none !important;
  }

  .mobile-filters summary::-webkit-details-marker {
    display: none !important;
  }

  .mobile-filters summary::after {
    content: "Mostrar";
    float: right;
    color: var(--blue-600);
    font-size: 13px;
    margin-top: 4px;
  }

  .mobile-filters[open] summary::after {
    content: "Ocultar";
  }

  .mobile-filters > .card {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding-top: 0 !important;
  }

  .mobile-filters > .card > h2,
  .mobile-filters > .card > .card-title {
    display: none !important;
  }

  table {
    width: 100% !important;
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    font-size: 13px !important;
  }

  th,
  td {
    padding: 8px !important;
    white-space: nowrap !important;
  }

  table.procedimientos-table {
    border-collapse: separate !important;
    border-spacing: 0 8px !important;
    overflow: visible !important;
  }

  table.procedimientos-table thead {
    display: none !important;
  }

  table.procedimientos-table tbody,
  table.procedimientos-table tr,
  table.procedimientos-table td {
    display: block !important;
    width: 100% !important;
  }

  table.procedimientos-table tr {
    background: rgba(255, 250, 240, 0.98) !important;
    border: 1px solid rgba(16, 32, 51, 0.14) !important;
    border-left: 4px solid var(--blue-600) !important;
    border-radius: 14px !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 9px 10px !important;
    margin-bottom: 8px !important;
  }

  table.procedimientos-table td {
    border: 0 !important;
    padding: 3px 0 !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  table.procedimientos-table td::before {
    display: none !important;
  }

  table.procedimientos-table td:nth-child(1) {
    display: inline-block !important;
    width: auto !important;
    font-size: 15px !important;
    font-weight: 900 !important;
    color: var(--blue-600) !important;
    margin: 0 8px 2px 0 !important;
  }

  table.procedimientos-table td:nth-child(3) {
    display: inline-block !important;
    width: auto !important;
    margin: 0 0 2px 0 !important;
  }

  table.procedimientos-table td:nth-child(4) {
    display: block !important;
    font-size: 16px !important;
    font-weight: 900 !important;
    color: var(--navy-900) !important;
    margin-top: 2px !important;
  }

  table.procedimientos-table td:nth-child(2),
  table.procedimientos-table td:nth-child(5),
  table.procedimientos-table td:nth-child(6),
  table.procedimientos-table td:nth-child(7) {
    color: var(--muted) !important;
    font-size: 12px !important;
  }

  table.procedimientos-table td:nth-child(8) {
    display: none !important;
  }

  table.procedimientos-table td:nth-child(9),
  table.procedimientos-table td:nth-child(10),
  table.procedimientos-table td:last-child {
    display: inline-block !important;
    width: auto !important;
    margin-top: 6px !important;
    margin-right: 6px !important;
    vertical-align: top !important;
  }

  table.procedimientos-table td:nth-child(9) a,
  table.procedimientos-table td:nth-child(10) a,
  table.procedimientos-table td:last-child a,
  table.procedimientos-table td:nth-child(9) button,
  table.procedimientos-table td:nth-child(10) button,
  table.procedimientos-table td:last-child button {
    width: auto !important;
    min-height: 34px !important;
    padding: 8px 10px !important;
    margin: 0 4px 6px 0 !important;
    font-size: 12px !important;
    border-radius: 999px !important;
  }

  img,
  video,
  iframe {
    max-width: 100% !important;
    height: auto !important;
  }

  .gallery,
  .files-grid,
  .imagenes-grid,
  .cards-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .muted,
  .small {
    font-size: 12px !important;
    line-height: 1.35 !important;
  }

  .badge,
  .estado-badge {
    display: inline-block !important;
    font-size: 12px !important;
    padding: 4px 9px !important;
    border-radius: 999px !important;
    margin: 2px 3px 2px 0 !important;
  }

  .dropzone,
  .upload-dropzone,
  #dropzone,
  #global-dropzone,
  .drag-drop-zone,
  .file-drop-zone {
    position: relative !important;
    z-index: 1 !important;
    max-width: 100% !important;
  }
}

@media (max-width: 520px) {

  .container {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .card,
  .metric,
  .login-card {
    padding: 12px !important;
    border-radius: 14px !important;
  }

  .summary {
    grid-template-columns: 1fr !important;
  }

  .brand h1 {
    font-size: 20px !important;
  }

  .card-title,
  .card h1,
  .card h2 {
    font-size: 17px !important;
  }
}

/* =========================================================
   ANGIO-CASE-COLLAPSIBLE-SECTIONS-V1
   Ficha de caso: estado arriba derecha + secciones colapsables
   ========================================================= */

.case-summary-card {
  position: relative;
  padding-right: 170px;
}

.case-status-corner {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
}

.case-status-badge {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--blue-100);
  color: var(--navy-900);
  border: 1px solid rgba(16, 32, 51, 0.15);
}

.case-status-abierto {
  background: var(--green-100);
  color: var(--green-600);
}

.case-status-hospitalizado {
  background: var(--amber-100);
  color: var(--amber-600);
}

.case-status-pendiente_control {
  background: var(--blue-100);
  color: var(--blue-600);
}

.case-status-de_alta {
  background: rgba(255,255,255,0.86);
  color: var(--muted);
}

.case-section-ready {
  padding-top: 0;
  overflow: hidden;
}

.case-section-toggle {
  width: calc(100% + 44px) !important;
  margin: 0 -22px 18px !important;
  padding: 16px 22px !important;
  border: 0 !important;
  border-radius: 0 !important;
  border-bottom: 1px solid rgba(16, 32, 51, 0.10) !important;
  background: rgba(255,255,255,0.36) !important;
  color: var(--text) !important;
  box-shadow: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  text-align: left !important;
  cursor: pointer !important;
}

.case-section-toggle:hover {
  background: rgba(231, 242, 245, 0.85) !important;
}

.case-section-title {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.2;
}

.case-section-chevron {
  font-size: 20px;
  font-weight: 900;
  transition: transform 0.16s ease;
}

.case-section-collapsed .case-section-body {
  display: none !important;
}

.case-section-collapsed .case-section-chevron {
  transform: rotate(-90deg);
}

@media (max-width: 700px) {

  .case-summary-card {
    padding-right: 14px !important;
    padding-top: 54px !important;
  }

  .case-status-corner {
    top: 12px;
    right: 12px;
  }

  .case-status-badge {
    font-size: 11px;
    padding: 6px 10px;
  }

  .case-section-toggle {
    width: calc(100% + 28px) !important;
    margin: 0 -14px 12px !important;
    padding: 13px 14px !important;
  }

  .case-section-title {
    font-size: 17px;
  }
}

/* =========================================================
   ANGIO-CASE-COLLAPSE-FIX-V2
   Colapso robusto de ficha de caso
   ========================================================= */

.case-section-body[hidden] {
  display: none !important;
}

.case-section-ready-v2 {
  padding-top: 0;
  overflow: hidden;
}

.case-section-ready-v2 .case-section-toggle {
  width: calc(100% + 44px) !important;
  margin: 0 -22px 18px !important;
  padding: 16px 22px !important;
  border: 0 !important;
  border-radius: 0 !important;
  border-bottom: 1px solid rgba(16, 32, 51, 0.10) !important;
  background: rgba(95, 163, 189, 0.96) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(47,145,183,0.20) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  text-align: left !important;
  cursor: pointer !important;
}

.case-section-ready-v2 .case-section-toggle:hover {
  background: var(--navy-800) !important;
}

.case-section-ready-v2 .case-section-title {
  font-size: 16px;
  font-weight: 900;
  line-height: 1.2;
}

.case-section-ready-v2 .case-section-chevron {
  font-size: 17px;
  font-weight: 900;
}

@media (max-width: 700px) {

  .case-section-ready-v2 .case-section-toggle {
    width: calc(100% + 28px) !important;
    margin: 0 -14px 12px !important;
    padding: 13px 14px !important;
  }

  .case-section-ready-v2 .case-section-title {
    font-size: 15px;
  }
}

/* =========================================================
   ANGIO-ESTADO-CASO-V2
   Estados de caso actualizados
   ========================================================= */

.case-status-pendiente_control_ambulatorio,
.estado-pendiente_control_ambulatorio,
.badge-pendiente_control_ambulatorio {
  background: var(--blue-100) !important;
  color: var(--blue-600) !important;
}

.case-status-cerrado,
.estado-cerrado,
.badge-cerrado {
  background: rgba(255,255,255,0.88) !important;
  color: var(--muted) !important;
}

.case-status-hospitalizado,
.estado-hospitalizado,
.badge-hospitalizado {
  background: var(--amber-100) !important;
  color: var(--amber-600) !important;
}

/* =========================================================
   ANGIO-STROKE-DATOS-CLINICOS-V2
   Botones rápidos de fechas y Stroke V2
   ========================================================= */

.quick-date-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.quick-date-row .btn,
.quick-date-row button {
  width: auto !important;
  min-height: 30px !important;
  padding: 6px 9px !important;
  font-size: 12px !important;
  border-radius: 999px !important;
  margin-bottom: 0 !important;
}

.inline-checks input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
}

@media (max-width: 700px) {
  .quick-date-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quick-date-row .btn,
  .quick-date-row button {
    width: 100% !important;
  }
}

/* =========================================================
   ANGIO-FIELD-HELP-V3
   Ayudas breves bajo campos clínicos
   ========================================================= */

.field-help {
  margin: -3px 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 700px) {
  .field-help {
    font-size: 12px;
    margin-bottom: 8px;
  }
}

/* =========================================================
   ANGIO-OCLUSIONES-MULTIPLES-LIMPIO-V1
   Sitios múltiples de oclusión
   ========================================================= */

.four {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.occlusion-sites-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(16, 32, 51, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.28);
}

.occlusion-sites-box h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.occlusion-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
}

.occlusion-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(16, 32, 51, 0.10);
}

.btn-danger {
  background: var(--red-600) !important;
  color: #fff !important;
}

@media (max-width: 900px) {
  .four {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 700px) {
  .four {
    grid-template-columns: 1fr;
  }

  .occlusion-item {
    grid-template-columns: 1fr;
  }

  .occlusion-item form button {
    width: 100% !important;
  }
}

/* =========================================================
   ANGIO-STROKE-FORM-FIX-V4
   Stroke: TICI solo por sitio + imágenes diagnósticas claras
   ========================================================= */

.diagnostic-images-box {
  margin: 14px 0 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid rgba(16, 32, 51, 0.10);
}

.diagnostic-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 10px;
}

.diagnostic-check {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(16, 32, 51, 0.14);
  cursor: pointer;
  font-weight: 800;
}

.diagnostic-check input[type="checkbox"] {
  width: auto !important;
  margin: 0 !important;
}

.diagnostic-images-current {
  margin: 6px 0 0;
}

@media (max-width: 700px) {
  .diagnostic-checks {
    display: grid;
    grid-template-columns: 1fr;
  }

  .diagnostic-check {
    width: 100%;
  }
}

/* =========================================================
   ANGIO-PARTICIPANTES-MATERIALES-FORCE-V3
   Participantes y materiales nuevos
   ========================================================= */

.structured-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
}

.structured-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(16, 32, 51, 0.10);
}

.five {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .five {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 700px) {
  .structured-item {
    grid-template-columns: 1fr;
  }

  .structured-item form button {
    width: 100% !important;
  }

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

/* =========================================================
   ANGIO-MATERIALES-DEDICADOS-V4
   Materiales dedicados del procedimiento
   ========================================================= */

.structured-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
}

.structured-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.92);
  border: 1px solid rgba(16, 32, 51, 0.10);
}

.five {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 14px;
}

@media (max-width: 1100px) {
  .five {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 700px) {
  .structured-item {
    grid-template-columns: 1fr;
  }

  .structured-item form button {
    width: 100% !important;
  }

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

/* =========================================================
   ANGIO-STROKE-TIEMPO-JS-V8
   Campo calculado punción-recanalización
   ========================================================= */

#acvTiempoPuncionRecanalizacion[readonly] {
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

/* =========================================================
   ANGIO-TABLAS-COMPACTAS-FICHA-V15
   Tablas compactas para elementos agregables de la ficha
   ========================================================= */

.compact-structured-wrap {
  margin: 10px 0 14px;
  overflow-x: auto;
}

.compact-structured-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(16, 32, 51, 0.14);
  background: rgba(255, 255, 255, 0.58);
}

.compact-structured-table th,
.compact-structured-table td {
  padding: 9px 11px;
  border-bottom: 1px solid rgba(16, 32, 51, 0.10);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

.compact-structured-table th {
  background: rgba(207, 234, 243, 0.80);
  font-weight: 900;
}

.compact-structured-table tr:last-child td {
  border-bottom: 0;
}

.compact-structured-table form {
  margin: 0;
}

.compact-structured-table .btn-small,
.compact-structured-table button.btn-small {
  padding: 6px 10px !important;
  min-height: auto !important;
  line-height: 1.1;
}

@media (max-width: 760px) {
  .compact-structured-table {
    min-width: 640px;
  }
}

/* =========================================================
   ANGIO-CARD-HIERARCHY-FIX-V18
   Tarjetas independientes dentro de ficha clínica
   ========================================================= */

#sitios-oclusion,
#participantes,
#materiales {
  clear: both;
}

.compact-structured-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0 14px;
}

.compact-structured-table {
  width: 100%;
  min-width: 640px;
}

.compact-structured-table th,
.compact-structured-table td {
  vertical-align: top;
}

@media (max-width: 760px) {
  .compact-structured-table {
    min-width: 620px;
  }
}

/* =========================================================
   ANGIO-CARDS-DIRECTAS-V19
   Cards independientes para Stroke, oclusiones, participantes y materiales
   ========================================================= */

#sitios-oclusion,
#participantes,
#materiales {
  clear: both;
}

.compact-structured-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 10px 0 14px;
}

.compact-structured-table {
  width: 100%;
  min-width: 640px;
}

.compact-structured-table th,
.compact-structured-table td {
  vertical-align: top;
}

/* =========================================================
   ANGIO-SITIOS-DENTRO-STROKE-V20
   Sitios de oclusión como subsección interna de Stroke
   ========================================================= */

.stroke-subsection {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(16, 32, 51, 0.14);
}

.stroke-subsection .section-subtitle {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ink, #102033);
}

.stroke-subsection .compact-structured-wrap {
  margin-top: 12px;
}

.stroke-subsection form.structured-add-form {
  margin-top: 10px;
}

/* =========================================================
   ANGIO-LISTADO-TABLA-V21
   Listado principal: columnas, paciente y grupo procedimiento
   ========================================================= */

.clinical-table th,
.clinical-table td {
  vertical-align: top;
}

.clinical-table th:nth-child(2),
.clinical-table td:nth-child(2) {
  width: 92px;
  min-width: 92px;
  white-space: nowrap;
}

.clinical-table th:nth-child(3),
.clinical-table td:nth-child(3) {
  width: 150px;
  min-width: 150px;
}

.clinical-table th:nth-child(4),
.clinical-table td:nth-child(4),
.patient-cell {
  width: 150px;
  min-width: 150px;
}

.patient-two-line {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.12;
}

.patient-lastname {
  font-weight: 900;
  text-transform: uppercase;
}

.patient-firstname {
  font-weight: 700;
  text-transform: none;
}

.clinical-table .col-procedure-group,
.clinical-table .procedure-group-cell,
.procedure-group-cell {
  width: 150px;
  min-width: 130px;
  max-width: 170px;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
}

.clinical-table th:nth-child(6),
.clinical-table td:nth-child(6) {
  min-width: 150px;
}

.clinical-table th:nth-child(8),
.clinical-table td:nth-child(8) {
  min-width: 130px;
}

@media (max-width: 760px) {
  .clinical-table .procedure-group-cell,
  .procedure-group-cell {
    max-width: none;
  }

  .patient-two-line {
    min-width: 110px;
  }
}

/* =========================================================
   ANGIO-LISTADO-OPERADORES-V22
   Optimización columnas listado principal
   ========================================================= */

.clinical-table th,
.clinical-table td {
  vertical-align: top;
}

.clinical-table th {
  white-space: normal;
  line-height: 1.15;
}

.clinical-table th:nth-child(2),
.clinical-table td:nth-child(2) {
  width: 86px;
  min-width: 86px;
  white-space: nowrap;
}

.clinical-table th:nth-child(3),
.clinical-table td:nth-child(3) {
  width: 126px;
  min-width: 126px;
  max-width: 138px;
  white-space: normal !important;
  overflow-wrap: normal;
  line-height: 1.2;
}

.clinical-table th:nth-child(4),
.clinical-table td:nth-child(4) {
  width: 145px;
  min-width: 145px;
  max-width: 155px;
}

.patient-two-line {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
}

.patient-lastname {
  display: block;
  font-weight: 900;
  text-transform: uppercase;
}

.patient-firstname {
  display: block;
  font-weight: 700;
  text-transform: none;
}

.operators-cell {
  width: 128px;
  min-width: 128px;
  max-width: 145px;
  white-space: normal !important;
}

.operator-name-only {
  display: block;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 3px;
}

.clinical-table .col-procedure-group,
.clinical-table .procedure-group-cell,
.procedure-group-cell {
  width: 138px;
  min-width: 120px;
  max-width: 145px;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.18;
}

.clinical-table th:nth-child(8),
.clinical-table td:nth-child(8) {
  min-width: 130px;
}

@media (max-width: 760px) {
  .clinical-table th:nth-child(3),
  .clinical-table td:nth-child(3),
  .clinical-table .procedure-group-cell,
  .procedure-group-cell,
  .operators-cell {
    max-width: none;
  }
}

/* =========================================================
   ANGIO-FIX-LISTADO-VISIBLE-V23
   Forzar visual de listado: paciente, estado, operadores y grupo
   ========================================================= */

.clinical-table th,
.clinical-table td {
  vertical-align: top !important;
}

.clinical-table th {
  white-space: normal !important;
  line-height: 1.12 !important;
}

.clinical-table th:nth-child(2),
.clinical-table td:nth-child(2) {
  width: 84px !important;
  min-width: 84px !important;
  white-space: nowrap !important;
}

.clinical-table th:nth-child(3),
.clinical-table td:nth-child(3) {
  width: 128px !important;
  min-width: 118px !important;
  max-width: 138px !important;
  white-space: normal !important;
  overflow-wrap: normal !important;
  line-height: 1.18 !important;
}

.patient-two-line {
  display: block !important;
  line-height: 1.08 !important;
}

.patient-two-line span {
  display: block !important;
}

.patient-lastname {
  display: block !important;
  font-weight: 900 !important;
  text-transform: uppercase !important;
}

.patient-firstname {
  display: block !important;
  font-weight: 700 !important;
  text-transform: none !important;
}

.operators-cell {
  width: 130px !important;
  min-width: 120px !important;
  max-width: 145px !important;
  white-space: normal !important;
}

.operator-name-only {
  display: block !important;
  font-weight: 700 !important;
  line-height: 1.12 !important;
  margin-bottom: 3px !important;
}

.col-procedure-group,
.procedure-group-cell {
  width: 135px !important;
  min-width: 118px !important;
  max-width: 145px !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
  line-height: 1.15 !important;
}

/* =========================================================
   ANGIO-FIX-OPERADORES-LISTADO-V24
   Operadores visibles como nombres simples en listado principal
   ========================================================= */

.clinical-table .operators-cell {
  width: 130px !important;
  min-width: 120px !important;
  max-width: 150px !important;
  white-space: normal !important;
  line-height: 1.15 !important;
}

.clinical-table .operator-name-only {
  display: block !important;
  font-weight: 800 !important;
  line-height: 1.12 !important;
  margin-bottom: 4px !important;
}

.clinical-table .procedure-group-cell,
.clinical-table .col-procedure-group {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  line-height: 1.15 !important;
}

.clinical-table .patient-two-line span {
  display: block !important;
}

.clinical-table td:nth-child(3) {
  white-space: normal !important;
  overflow-wrap: normal !important;
  line-height: 1.18 !important;
}

/* =========================================================
   ANGIO-ESTADO-PACIENTE-V25
   Salto de línea en Estado y Paciente del listado
   ========================================================= */

.clinical-table .status-cell {
  width: 122px !important;
  min-width: 112px !important;
  max-width: 132px !important;
  white-space: normal !important;
  line-height: 1.1 !important;
}

.clinical-table .status-multiline {
  display: inline-flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 1px !important;
  white-space: normal !important;
  line-height: 1.05 !important;
  max-width: 118px !important;
}

.clinical-table .status-multiline span {
  display: block !important;
  white-space: normal !important;
}

.clinical-table .patient-two-line {
  display: inline-flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 1px !important;
  line-height: 1.05 !important;
  white-space: normal !important;
}

.clinical-table .patient-two-line span {
  display: block !important;
}

.clinical-table .patient-lastname {
  font-weight: 900 !important;
  text-transform: uppercase !important;
}

.clinical-table .patient-firstname {
  font-weight: 700 !important;
}
