:root {
  --brand-red: #a31619;
  --brand-red-dark: #741014;
  --brand-navy: #10184a;
  --brand-navy-soft: #182468;
  --brand-green: #18864f;
  --brand-orange: #d9791e;
  --bg: #eef1f8;
  --surface: #ffffff;
  --line: #e2e6f0;
  --muted: #65708a;
  --text: #151a2d;
  --danger: #b42318;
  --warning: #b54708;
  --success: #067647;
  --shadow: 0 18px 50px rgba(17, 27, 79, 0.09);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(16, 24, 74, 0.08), transparent 240px),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; overflow-wrap: anywhere; }
img, video { max-width: 100%; height: auto; }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 14% 16%, rgba(163, 22, 25, 0.22), transparent 28%),
    radial-gradient(circle at 86% 82%, rgba(16, 24, 74, 0.26), transparent 30%),
    linear-gradient(135deg, #ffffff 0%, #eef1f8 48%, #f8ecec 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(163, 22, 25, 0.18);
  border-top: 6px solid var(--brand-red);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-block { text-align: center; margin-bottom: 24px; }
.brand-logo { width: 132px; height: auto; object-fit: contain; }
.brand-title { margin: 14px 0 5px; color: var(--brand-navy); font-size: 24px; }
.brand-subtitle { margin: 0; color: var(--muted); font-size: 14px; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  border-right: 0;
  background:
    linear-gradient(180deg, var(--brand-navy) 0%, #0b1138 100%);
  box-shadow: 12px 0 34px rgba(16, 24, 74, 0.18);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}
.sidebar-logo {
  width: 62px;
  height: 62px;
  padding: 5px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}
.sidebar-title { color: #fff; font-weight: 800; line-height: 1.12; }
.sidebar-title small { display: block; margin-top: 3px; color: #cbd2f2; font-size: 12px; font-weight: 400; }

.nav { display: grid; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 7px;
  color: #e8ecff;
  font-weight: 700;
  font-size: 14px;
}
.nav a.active, .nav a:hover {
  background: var(--brand-red);
  color: #fff;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
}

.content { min-width: 0; padding: 24px 28px 44px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 20px;
  border: 1px solid rgba(16, 24, 74, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.82)),
    linear-gradient(120deg, rgba(163, 22, 25, 0.18), rgba(16, 24, 74, 0.16));
  box-shadow: 0 12px 30px rgba(16, 24, 74, 0.07);
}

.page-title { margin: 0; color: var(--brand-navy); font-size: 26px; }
.page-kicker { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.user-chip { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(150px, 1fr)); margin-bottom: 18px; }
.two-col { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.panel, .metric, .table-wrap {
  border: 1px solid #d7ddeb;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(17, 27, 79, 0.05);
}

.panel { padding: 18px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-title { margin: 0; color: var(--brand-navy); font-size: 18px; }
.metric {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border-top: 5px solid var(--brand-red);
}
.metric::after {
  position: absolute;
  right: -24px;
  top: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(163, 22, 25, 0.08);
  content: "";
}
.metric:nth-child(2) { border-top-color: var(--brand-orange); }
.metric:nth-child(2)::after { background: rgba(217, 121, 30, 0.1); }
.metric:nth-child(3) { border-top-color: var(--brand-green); }
.metric:nth-child(3)::after { background: rgba(24, 134, 79, 0.1); }
.metric:nth-child(4) { border-top-color: var(--brand-navy); }
.metric:nth-child(4)::after { background: rgba(16, 24, 74, 0.1); }
.metric-label { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-value { position: relative; z-index: 1; color: var(--brand-navy); font-size: 32px; font-weight: 800; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--brand-navy);
  cursor: pointer;
  touch-action: manipulation;
  font-weight: 700;
  font-size: 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.btn.primary {
  border-color: var(--brand-red);
  background: linear-gradient(180deg, #b51b1f, var(--brand-red));
  color: #fff;
  box-shadow: 0 8px 18px rgba(163, 22, 25, 0.18);
}
.btn.primary:hover { background: var(--brand-red-dark); }
.btn.danger { border-color: #f4c7c1; color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--brand-navy); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px 11px;
  border: 1px solid #cfd6e6;
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  font: inherit;
  max-width: 100%;
}
textarea { min-height: 118px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(157, 21, 24, 0.16); border-color: var(--brand-red); }

.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; overflow-wrap: anywhere; }
th:last-child,
td:last-child {
  width: 120px;
}
td:last-child .btn,
.actions .btn {
  white-space: nowrap;
}
th {
  color: #fff;
  background: var(--brand-navy-soft);
  font-size: 12px;
  text-transform: uppercase;
}
tbody tr:nth-child(even) { background: #fbfcff; }
tbody tr:hover { background: #fff7f7; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  min-width: max-content;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef1f7;
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.open { background: #fff0dd; color: var(--warning); border: 1px solid #ffd9a8; }
.badge.follow { background: #e7f6ee; color: var(--success); border: 1px solid #bfe3cd; }
.badge.closed { background: #eef1f7; color: var(--muted); border: 1px solid #dce2ee; }
.badge.category { background: #e9edff; color: var(--brand-navy); border: 1px solid #cbd4ff; }
.badge.high { background: #fde8e7; color: var(--danger); border: 1px solid #f7c6c2; }

.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--brand-navy); }
.notice.error { border-color: #f4c7c1; background: #fff4f2; color: var(--danger); }
.notice.success { border-color: #bfe3cd; background: #f0fbf4; color: var(--success); }

.case-summary { display: grid; gap: 10px; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 1.2fr repeat(3, 1fr) auto; gap: 10px; align-items: end; margin-bottom: 14px; }

.print-sheet {
  max-width: 840px;
  margin: 0 auto;
  padding: 34px 42px;
  border: 1px solid #cfd6e6;
  border-top: 8px solid var(--brand-red);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(16, 24, 74, 0.08);
}

.print-doc-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 3px double var(--brand-navy);
}

.print-doc-header img {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.print-doc-header h2 {
  margin: 0;
  color: var(--brand-navy);
  font-size: 22px;
}

.print-doc-header p {
  margin: 4px 0 0;
  color: var(--brand-red);
  font-weight: 700;
}

.print-sheet h1 {
  margin: 24px 0 18px;
  color: var(--brand-red);
  text-align: center;
  font-size: 22px;
}

.resolution-doc {
  color: #111827;
  font-family: "Times New Roman", Times, serif;
  font-size: 13.5pt;
  line-height: 1.48;
}

.resolution-doc .print-doc-header {
  align-items: flex-start;
  border-bottom: 1px solid #111827;
}

.resolution-doc .print-doc-header img {
  width: 82px;
  height: 82px;
}

.resolution-doc .print-doc-header h2 {
  color: #111827;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15pt;
  letter-spacing: 0;
}

.resolution-doc .print-doc-header p {
  color: #111827;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12pt;
  font-weight: 700;
}

.resolution-doc p {
  margin: 10px 0;
  text-align: justify;
}

.resolution-subject {
  margin: 20px 0;
  text-align: left !important;
}

.print-sheet h3 {
  margin: 22px 0 10px;
  padding: 0;
  background: transparent;
  color: #111827;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13pt;
  text-transform: uppercase;
}

.resolve-word {
  font-weight: 700;
  text-align: center !important;
}

.resolution-box {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--brand-red);
  background: #fafafa;
}

.facts-box {
  margin: 12px 0 16px;
  padding: 14px 18px;
  border: 0;
  border-left: 4px solid var(--brand-red);
  background: #fafafa;
}

.facts-box strong {
  display: block;
  margin-bottom: 6px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11.5pt;
  text-transform: uppercase;
}

.facts-box p {
  margin-bottom: 0;
}

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

.print-grid > div,
.print-box {
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid #cfd6e6;
  background: #fbfcff;
}

.print-box {
  margin-bottom: 10px;
}

.print-box p {
  margin-bottom: 0;
  line-height: 1.55;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 64px;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10.5pt;
}

.signature-grid span {
  display: block;
  height: 1px;
  margin-bottom: 8px;
  background: #1f2937;
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  .panel, .table-wrap, .metric, .print-sheet { box-shadow: none; }
  .print-sheet { max-width: none; padding: 0; border: 0; border-top: 0; }
  body { background: #fff; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 12px;
  }
  .sidebar-brand {
    margin-bottom: 10px;
    padding: 8px;
  }
  .sidebar-logo {
    width: 48px;
    height: 48px;
  }
  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }
  .nav a {
    justify-content: center;
    min-height: 40px;
    padding: 0 8px;
    font-size: 13px;
    text-align: center;
  }
  .content { padding: 16px 14px 34px; }
  .metrics, .two-col, .form-grid, .filters { grid-template-columns: 1fr; }
  .print-grid, .signature-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar {
    gap: 12px;
    padding: 14px;
  }
  .user-chip {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
  }
  .user-chip .btn-row,
  .btn-row {
    width: 100%;
  }
  .btn {
    min-height: 44px;
  }
  table { min-width: 0; }
  th, td {
    padding: 11px 12px;
  }
}

@media (max-width: 980px) {
  .app-shell,
  .sidebar,
  .content,
  .topbar,
  .panel,
  .table-wrap,
  .print-sheet {
    max-width: 100%;
  }
  .app-shell {
    overflow-x: hidden;
  }
  .content {
    width: 100%;
    overflow-x: hidden;
  }
  body {
    background: var(--bg);
  }
  .login-page {
    padding: 16px;
    place-items: stretch;
  }
  .login-card {
    align-self: center;
    padding: 24px 18px;
  }
  .brand-logo {
    width: 112px;
  }
  .brand-title {
    font-size: 21px;
  }
  .sidebar-title {
    font-size: 16px;
  }
  .sidebar-brand {
    align-items: center;
  }
  .sidebar-title small {
    display: none;
  }
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nav a {
    min-height: 46px;
    padding: 7px 8px;
    line-height: 1.15;
  }
  .content {
    padding: 12px 10px 28px;
  }
  .topbar {
    margin-bottom: 14px;
  }
  .page-title {
    font-size: 22px;
    line-height: 1.18;
  }
  .page-kicker {
    font-size: 13px;
  }
  .metrics {
    gap: 10px;
  }
  .metric {
    padding: 14px;
  }
  .metric-value {
    font-size: 28px;
  }
  .panel {
    padding: 14px;
  }
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }
  label {
    font-size: 13px;
  }
  input, select, textarea {
    min-height: 44px;
    font-size: 16px;
  }
  input[type="file"] {
    min-height: 0;
    padding: 12px 10px;
  }
  textarea {
    min-height: 140px;
  }
  .btn {
    width: 100%;
    min-height: 46px;
    padding: 0 12px;
    white-space: normal;
    text-align: center;
  }
  .btn-row .btn,
  .user-chip .btn {
    flex: 1 1 100%;
    width: 100%;
  }
  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .actions .btn {
    width: 100%;
  }
  .table-wrap {
    width: 100%;
    overflow-x: hidden;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }
  table {
    width: 100%;
    min-width: 0;
    background: transparent;
    table-layout: fixed;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  tbody {
    display: grid;
    gap: 12px;
  }
  tr {
    width: 100%;
    overflow: hidden;
    border: 1px solid #d7ddeb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(17, 27, 79, 0.05);
  }
  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #fff;
  }
  td {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  td > * {
    min-width: 0;
    max-width: 100%;
  }
  tr:last-child td,
  td:last-child {
    border-bottom: 0;
  }
  td::before {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    content: attr(data-label);
  }
  td[colspan] {
    grid-template-columns: 1fr;
  }
  td[colspan]::before {
    content: "";
    display: none;
  }
  td.actions,
  td[data-label="Acciones"] {
    grid-template-columns: 1fr;
  }
  td.actions::before,
  td[data-label="Acciones"]::before {
    margin-bottom: 2px;
  }
  .badge {
    justify-self: start;
    white-space: normal;
  }
  .case-summary p,
  .case-summary h3 {
    overflow-wrap: anywhere;
  }
  .print-sheet {
    padding: 14px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }
  .print-doc-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .print-doc-header img,
  .resolution-doc .print-doc-header img {
    width: 68px;
    height: 68px;
  }
  .print-doc-header h2,
  .resolution-doc .print-doc-header h2 {
    font-size: 15pt;
  }
  .resolution-doc {
    font-size: 12.5pt;
  }
  .resolution-doc p {
    text-align: left;
  }
}
