:root {
  /* Presencia profesional ? navy / oro / crema */
  --navy: #13253A;
  --navy-deep: #0B1A2B;
  --navy-mid: #1B334D;
  --navy-light: #2A4A6B;
  --gold: #C4A35A;
  --gold-deep: #A8843F;
  --gold-soft: #E8D5A8;
  --gold-wash: #F7F0E0;
  --crimson: #C45C2A;
  --crimson-soft: #D97848;
  --ink: #13253A;
  --muted: #3F5163;
  --border: #E2D9C8;
  --border-strong: #C9B896;
  --surface: #F3EEE4;
  --ivory: #FFFEFA;
  --cream: #F7F4EE;
  --success: #1F7A4D;
  --warning: #9A6700;
  --danger: #B42318;
  --radius: 8px;
  --font-sans: "Plus Jakarta Sans", "Avenir Next", "Segoe UI", sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --shadow-sm: 0 6px 18px rgba(11, 26, 43, 0.06);
  --shadow-md: 0 14px 36px rgba(11, 26, 43, 0.12);
  --ease: 160ms ease;
  --text-xs: 0.78rem;
  --text-sm: 0.9rem;
  --text-base: 1.02rem;
  --text-md: 1.08rem;
  --text-lg: 1.2rem;
  --title-sm: clamp(1.35rem, 1.8vw, 1.65rem);
  --title-md: clamp(2rem, 2.8vw, 2.65rem);
  --title-lg: clamp(2.4rem, 4vw, 3.4rem);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 17px; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
  line-height: 1.5;
  font-size: var(--text-base);
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body:has(.portal-shell) {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.portal-shell {
  display: grid;
  grid-template-columns: minmax(240px, 17.5rem) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--cream);
}
.portal-shell .sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.portal-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--cream);
}
.portal-shell .content {
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  max-width: none;
  width: 100%;
  min-width: 0;
}

a { color: var(--navy); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--gold-deep); }

.topbar { display: none; }

.portal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--ivory);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.portal-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 0;
}
.crumb-sep { color: var(--border-strong); }
.crumb-here { color: var(--navy); }
.portal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.portal-user-chip {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.85;
}

.site-header {
  background: var(--navy-deep);
  color: #fff;
  padding: 0.55rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 3px solid var(--gold);
  min-width: 0;
  overflow: hidden;
}
.site-header .brand-lockup { min-width: 0; }
.site-header .actions { flex: 0 0 auto; }

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: #fff;
  text-decoration: none;
}
.brand-lockup:hover { color: #fff; opacity: 0.96; }
.brand-logo {
  display: block;
  height: 3.1rem;
  width: auto;
  max-width: min(14rem, 46vw);
  object-fit: contain;
}
.brand-logo-hero {
  height: auto;
  width: min(22rem, 88vw);
  max-width: 100%;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}
.sidebar-brand {
  flex: 0 0 auto;
  padding: 1.15rem 0.85rem 1.05rem;
  border-bottom: 1px solid rgba(196, 163, 90, 0.28);
}
.sidebar-brand .brand-lockup,
.brand-lockup-on-dark {
  background: transparent;
  border-radius: 0;
  padding: 0;
  width: 100%;
  justify-content: center;
  box-shadow: none;
}
.sidebar-brand .brand-logo {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  min-height: 4.75rem;
  max-height: 7.25rem;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35));
}
.site-header .brand-lockup {
  background: transparent;
  border-radius: 0;
  padding: 0.1rem 0;
  box-shadow: none;
}
.site-header .brand-logo { height: 2.85rem; }
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}
.auth-brand .brand-logo {
  height: 4.25rem;
  max-width: 16rem;
}
.invoice-logo {
  display: block;
  height: 4.5rem;
  width: auto;
  max-width: 14rem;
  object-fit: contain;
}
.brand-mark {
  width: 2.1rem;
  height: 2.6rem;
  color: #fff;
  flex: 0 0 auto;
}
.brand-mark img,
.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}
.brand-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
  text-transform: uppercase;
}
.brand-wordmark .brand-my {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(255, 255, 255, 0.92);
}
.brand-wordmark .brand-rule {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--gold);
  margin: 0.2rem 0 0.24rem;
}
.brand-wordmark .brand-team {
  font-size: clamp(1.2rem, 1.6vw, 1.55rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
}
.brand-wordmark .brand-sub {
  margin-top: 0.22rem;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--gold-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1.5px solid transparent;
  border-radius: 6px;
  padding: 0.6rem 1.05rem;
  min-height: 2.55rem;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), box-shadow var(--ease), color var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-gold {
  background: var(--gold);
  color: var(--navy-deep);
  box-shadow: 0 8px 16px rgba(168, 132, 63, 0.28);
}
.btn-gold:hover {
  background: var(--gold-deep);
  color: #fff;
}
.btn-primary,
.btn-navy {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 8px 16px rgba(11, 26, 43, 0.2);
}
.btn-primary:hover,
.btn-navy:hover {
  background: var(--navy-mid);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}
.btn-outline:hover {
  background: #fff;
  color: var(--navy);
  border-color: #fff;
}
.content .btn-outline,
.panel .btn-outline,
.portal-header .btn-outline {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--ivory);
}
.content .btn-outline:hover,
.panel .btn-outline:hover,
.portal-header .btn-outline:hover {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-outline-navy {
  background: transparent;
  border-color: var(--navy);
  color: var(--navy);
}
.btn-outline-navy:hover {
  background: var(--navy);
  color: #fff;
}
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  min-height: 2.1rem;
  font-size: 0.74rem;
}
.btn-block { width: 100%; }

.layout { display: contents; }
.sidebar {
  background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 100%);
  color: #fff;
  padding: 0 0 1rem;
}
.sidebar .user-box {
  margin-top: auto;
  padding: 0.95rem 1rem;
  border-top: 1px solid rgba(196, 163, 90, 0.28);
}
.sidebar .user-box strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
}
.sidebar .user-box span {
  font-size: var(--text-xs);
  color: var(--gold-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.nav-group {
  margin: 0.95rem 0 0.3rem;
  padding: 0 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}
.sidebar a.nav-link {
  display: block;
  color: rgba(255, 252, 245, 0.92);
  padding: 0.55rem 1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.01em;
  border-left: 3px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.sidebar a.nav-link:hover,
.sidebar a.nav-link.active {
  background: rgba(196, 163, 90, 0.14);
  color: #fff;
  border-left-color: var(--gold);
}

.content {
  padding: 1.1rem 1.35rem 1.5rem;
  min-width: 0;
  max-width: 100%;
  background: var(--cream);
}
.page-title {
  font-family: var(--font-sans);
  font-size: var(--title-md);
  font-weight: 800;
  margin: 0 0 0.3rem;
  color: var(--navy-deep);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-transform: none;
  text-wrap: balance;
  font-optical-sizing: auto;
}
.page-sub {
  color: var(--muted);
  margin: 0 0 1rem;
  font-size: var(--text-md);
  max-width: 56rem;
  font-weight: 500;
  line-height: 1.45;
}

.grid {
  display: grid;
  gap: 0.75rem;
  align-items: stretch;
}
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.stat {
  background: var(--ivory);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
  min-height: 4.8rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform var(--ease), box-shadow var(--ease);
}
.stat:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.stat .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 800;
}
.stat .value {
  font-family: var(--font-sans);
  font-size: clamp(1.55rem, 2.1vw, 2.05rem);
  color: var(--navy-deep);
  margin-top: 0.2rem;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.grid-4 > .stat:nth-child(4n + 1),
.stat.stat-navy {
  background: var(--navy);
  border-color: var(--navy);
}
.grid-4 > .stat:nth-child(4n + 1) .label,
.stat.stat-navy .label { color: rgba(255, 255, 255, 0.72); }
.grid-4 > .stat:nth-child(4n + 1) .value,
.stat.stat-navy .value { color: #fff; }
.grid-4 > .stat:nth-child(4n + 2),
.stat.stat-gold {
  background: var(--gold);
  border-color: var(--gold-deep);
}
.grid-4 > .stat:nth-child(4n + 2) .label,
.stat.stat-gold .label { color: rgba(19, 37, 58, 0.72); }
.grid-4 > .stat:nth-child(4n + 2) .value,
.stat.stat-gold .value { color: var(--navy-deep); }

/* Dentro de cards anidadas, KPIs compactos sin variantes navy/oro */
.mesa-card .grid-4 > .stat,
.mesa-card .stat {
  background: rgba(255, 254, 250, 0.92) !important;
  border-color: var(--border) !important;
}
.mesa-card .grid-4 > .stat .label,
.mesa-card .stat .label { color: var(--muted) !important; }
.mesa-card .grid-4 > .stat .value,
.mesa-card .stat .value {
  color: var(--navy) !important;
  font-size: 1.05rem !important;
  font-family: var(--font-sans) !important;
}

.panel {
  background: var(--ivory);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 0.85rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.panel h2, .panel h3 {
  font-family: var(--font-serif);
  color: var(--navy);
  margin: 0 0 0.8rem;
  font-size: var(--title-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: none;
}
.panel.panel-accent {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-wash) 0%, var(--ivory) 40%);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  border-radius: 4px;
  max-height: calc(100vh - 14rem);
  max-height: calc(100dvh - 14rem);
  -webkit-overflow-scrolling: touch;
}
table.data-table,
.table-wrap > table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
  min-width: 0;
}
th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;
}
th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 800;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr:hover { background: rgba(247, 240, 224, 0.55); }
td strong {
  font-size: 0.95rem;
  font-weight: 700;
}
td .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td .cell-stack {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  overflow: hidden;
}
.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-ok { background: #E5F6EC; color: var(--success); }
.badge-warn { background: #FFF3DC; color: #9A6700; }
.badge-danger { background: #FDE8EC; color: var(--crimson); }
.badge-info { background: #E8EEF7; color: var(--navy); }

/* Anchos de columnas t?picos de listados */
.col-name { width: 28%; }
.col-contact { width: 16%; }
.col-person { width: 20%; }
.col-mesa { width: 12%; }
.col-status { width: 16%; }
.col-actions { width: 12%; }
.col-num { width: 6%; }
.col-date { width: 14%; }
.col-actions,
td.col-actions {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  max-width: none;
}

form.inline { display: inline; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 0.85rem;
}
.form-grid .full { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  padding: 0.55rem 0.75rem;
  min-height: 2.5rem;
  font: inherit;
  font-size: var(--text-sm);
  background: #fff;
  color: var(--ink);
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(196, 163, 90, 0.28);
}
.actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
  align-items: center;
}
.flash-error,
.flash-ok {
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
}
.flash-error {
  background: #FDE8EC;
  color: var(--crimson);
  border: 1px solid #F5C2CB;
}
.flash-ok {
  background: #E5F6EC;
  color: var(--success);
  border: 1px solid #B7E4C7;
}
.temp-pass-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  background: rgba(11, 26, 43, 0.06);
  border: 1px dashed var(--border);
  border-radius: 6px;
}
.temp-pass-box code {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--navy-deep);
  user-select: all;
}

/* Landing hero ? tr?mites migratorios (pasaporte / visa) */
.hero {
  position: relative;
  min-height: min(86vh, 52rem);
  display: grid;
  align-items: end;
  color: #fff;
  overflow: hidden;
  background: var(--navy-deep);
}
.hero-media {
  position: absolute;
  inset: 0;
  background: url("/static/brand/banner-tramites-migratorios.png?v=1") right center / cover no-repeat;
  filter: none;
  transform: none;
  image-rendering: auto;
}
.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Velo a la izquierda para leer marca/CTA; documentos n?tidos a la derecha */
  background: linear-gradient(
    105deg,
    rgba(8, 20, 38, 0.88) 0%,
    rgba(8, 20, 38, 0.72) 28%,
    rgba(8, 20, 38, 0.28) 58%,
    rgba(8, 20, 38, 0.08) 100%
  );
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 64rem;
  margin: 0 auto;
  width: 100%;
  padding: clamp(3.5rem, 9vh, 6rem) 1.5rem;
}
.hero-brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.4rem;
}
.hero-brand .brand-mark {
  width: 3.6rem;
  height: 4.5rem;
  color: #fff;
}
.hero-kicker {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 0.45rem;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(3.6rem, 9vw, 6.2rem);
  margin: 0;
  line-height: 0.92;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hero h1 .thin {
  display: block;
  font-size: 0.38em;
  font-weight: 600;
  letter-spacing: 0.32em;
  margin-bottom: 0.35rem;
}
.hero h1 .rule {
  display: block;
  width: 5.5rem;
  height: 3px;
  background: var(--crimson);
  margin: 0.55rem 0 0.7rem;
}
.hero p {
  max-width: 34rem;
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  color: #fff;
  line-height: 1.55;
  margin: 0;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(8, 20, 38, 0.45);
}
.hero .cta {
  margin-top: 1.75rem;
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.hero .cta .btn,
.auth-card .btn {
  min-height: 2.85rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
}

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(160deg, rgba(11, 26, 43, 0.86), rgba(19, 37, 58, 0.68)),
    url("/static/brand/banner-tramites-migratorios.png?v=1") right center / cover no-repeat;
}
.auth-card {
  width: min(28rem, 100%);
  background: var(--ivory);
  border: 1px solid var(--border);
  border-top: 4px solid var(--gold);
  border-radius: 10px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-md);
}
.auth-wrap .auth-brand {
  margin-bottom: 0.35rem;
}
.muted { color: var(--muted); font-size: var(--text-sm); font-weight: 500; }
.stack > * + * { margin-top: 0.75rem; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
  min-width: 0;
  max-width: 100%;
}
.page-head > div { min-width: 0; flex: 1 1 12rem; }
.page-head .page-title { overflow-wrap: anywhere; }
.page-head .page-sub { margin-bottom: 0; }
.page-head .btn { flex: 0 0 auto; }

.desk-split {
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  min-width: 0;
  max-width: 100%;
}
.desk-split-side { margin-bottom: 0; min-width: 0; }
.desk-split-main { margin-bottom: 0; min-width: 0; overflow: hidden; }
.form-grid-compact { grid-template-columns: 1fr 1fr; }
.form-contacto {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.check-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  cursor: pointer;
}
.check-label input[type="checkbox"],
.check-label input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  margin-top: 0.15rem;
  flex: 0 0 auto;
  accent-color: var(--navy);
}
.flag-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.invoice-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-top: 0.35rem;
}
.mesa-card {
  transition: transform var(--ease), box-shadow var(--ease), border-color var(--ease);
  border: 1px solid var(--border);
}
.mesa-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--navy-light);
  color: inherit;
}

.invoice-doc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  max-width: 52rem;
  color: #1a1a1a;
}
.invoice-doc-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 3px solid var(--gold);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}
.invoice-brand {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
}
.invoice-meta { text-align: right; font-size: 0.92rem; }
.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.invoice-doc h4 {
  margin: 0 0 0.35rem;
  font-size: 0.84rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.invoice-doc p { margin: 0; line-height: 1.45; }
.invoice-matter { margin-bottom: 1rem; }
.invoice-matter .matter-folio-link {
  font-weight: 700;
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}
.invoice-matter .matter-folio-link:hover { color: var(--crimson); }
.invoice-lines {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-bottom: 1rem;
  table-layout: auto;
}
.invoice-lines th {
  background: var(--navy);
  color: #fff;
  text-align: left;
  padding: 0.45rem 0.55rem;
  font-weight: 600;
  overflow: visible;
  text-overflow: unset;
  white-space: nowrap;
  max-width: none;
}
.invoice-lines td {
  padding: 0.45rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  max-width: none;
  word-break: break-word;
}
.invoice-lines td.desc {
  min-width: 14rem;
  width: 42%;
}
.invoice-lines .num,
.data-table .num,
table .num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.invoice-totals {
  margin-left: auto;
  width: min(18rem, 100%);
}
.invoice-totals .row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.25rem 0;
  font-size: 0.95rem;
}
.invoice-totals .row.total {
  border-top: 2px solid var(--navy);
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  font-size: 1.05rem;
  color: var(--navy);
}
.invoice-apps { margin-top: 1.25rem; }

@media print {
  .no-print,
  .portal-nav,
  .portal-sidebar,
  .sidebar,
  .topbar,
  nav,
  aside {
    display: none !important;
  }
  body {
    background: #fff !important;
  }
  .portal-shell,
  .portal-main,
  main {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  .invoice-doc {
    border: none;
    box-shadow: none;
    max-width: none;
    padding: 0;
  }
  .invoice-lines,
  .invoice-lines th,
  .invoice-lines td {
    overflow: visible !important;
    text-overflow: unset !important;
    white-space: normal !important;
    max-width: none !important;
  }
  .invoice-lines td.desc {
    white-space: normal !important;
    word-break: break-word;
  }
  .matter-folio-link {
    color: #000 !important;
    text-decoration: none !important;
  }
}

@media (max-width: 1100px) {
  .form-contacto { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .form-contacto { grid-template-columns: 1fr; }
}

.table-wrap-fill {
  max-height: calc(100dvh - 12.5rem);
}
.portal-shell .panel .table-wrap {
  max-height: calc(100dvh - 13.5rem);
}

.cita-section {
  max-width: 960px;
  margin: -2.2rem auto 3rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 2;
}

/* Pantallas anchas de PC: m?s columnas y menos scroll */
@media (min-width: 1400px) {
  .portal-shell {
    grid-template-columns: minmax(260px, 18.5rem) minmax(0, 1fr);
  }
  .sidebar-brand {
    padding: 1.25rem 1rem 1.15rem;
  }
  .sidebar-brand .brand-logo {
    min-height: 5.25rem;
    max-height: 8rem;
  }
  .portal-shell .form-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .portal-shell .content {
    padding: 1.1rem 1.55rem 1.45rem;
  }
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .desk-split { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .portal-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .portal-shell .sidebar { display: none; }
  .portal-shell .content {
    overflow: visible;
    max-height: none;
  }
  .portal-header {
    flex-wrap: wrap;
  }
  .table-wrap {
    max-height: none;
  }
  .grid-3, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  html { font-size: 16px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 0.85rem; }
  .site-header { padding: 0.65rem 0.85rem; }
  th, td { white-space: normal; max-width: none; }
  .table-wrap > table { table-layout: auto; min-width: 36rem; }
  .brand-wordmark .brand-team { font-size: 1.2rem; }
  .hero-media {
    background-position: 72% center;
  }
  .hero-media::after {
    background: linear-gradient(
      180deg,
      rgba(8, 20, 38, 0.42) 0%,
      rgba(8, 20, 38, 0.78) 52%,
      rgba(8, 20, 38, 0.92) 100%
    );
  }
}

/* Admin ? privilegios */
.admin-table {
  table-layout: auto !important;
}
.admin-table th,
.admin-table td,
.admin-table .cell-wrap,
.priv-matrix td,
.priv-matrix th {
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  max-width: none !important;
  vertical-align: top;
}
.priv-roles {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.priv-role-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ivory);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.priv-role-item input {
  width: auto;
  min-height: auto;
  margin-top: 0.2rem;
}
.priv-role-item strong {
  display: block;
  font-size: 0.92rem;
}
.priv-role-item small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}
.priv-help {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}
.priv-help li { margin-bottom: 0.45rem; }
.priv-group-row td {
  background: var(--gold-wash) !important;
  color: var(--navy);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border-strong);
}
.priv-select {
  width: 100%;
  min-width: 11rem;
  max-width: 16rem;
}

/* Factura multil?nea */
.invoice-form .panel h3 {
  margin-top: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
}
.invoice-form .stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.invoice-form .stack > div label,
.invoice-form .form-grid label {
  display: block;
  margin-bottom: 0.28rem;
}
.inv-lines {
  table-layout: auto !important;
  min-width: 56rem;
}
.inv-lines th,
.inv-lines td {
  white-space: normal !important;
  vertical-align: middle;
  overflow: visible !important;
}
.inv-lines input,
.inv-lines select {
  width: 100%;
  min-height: 2.4rem;
  margin: 0;
  font: inherit;
  font-size: 0.9rem;
}
.inv-lines .num-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.inv-lines .sub-usd {
  background: var(--ivory);
  color: var(--muted);
}
.inv-totals {
  margin-top: 1rem;
  margin-left: auto;
  max-width: 18rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.inv-totals .row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
}
.inv-totals .row.total {
  margin-top: 0.25rem;
  padding-top: 0.45rem;
  border-top: 2px solid var(--navy);
  font-size: 1.05rem;
}
.inv-totals .row.total strong {
  color: var(--navy);
  font-family: var(--font-serif);
}

/* Documentos por caso */
.caso-docs {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--ivory);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
}
.caso-docs-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}
.doc-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0 0 0.55rem;
}
.doc-upload select,
.doc-upload input[type="file"] {
  width: auto;
  min-height: 2.35rem;
  margin: 0;
  max-width: 100%;
}
.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.doc-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.doc-meta {
  min-width: 12rem;
  flex: 1;
}
.doc-modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(96vw, 980px);
  height: min(92vh, 860px);
  max-width: 980px;
  background: var(--ivory);
  box-shadow: var(--shadow-md);
}
.doc-modal::backdrop {
  background: rgba(11, 26, 43, 0.55);
}
.doc-modal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.doc-modal-body {
  height: calc(100% - 3.6rem);
  overflow: auto;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.doc-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
