:root {
  --bg: #1f2326;
  --bg-soft: #2d3436;
  --surface: #ffffff;
  --text: #111827;
  --text-soft: #4b5563;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e5e7eb;
  --ok: #22c55e;
  --muted: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Roboto", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top right, #3a4446, var(--bg));
  color: var(--text);
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  padding: 1rem;
}

.auth-card {
  max-width: 520px;
  margin: 4rem auto;
  text-align: center;
}

.logo {
  width: min(170px, 60vw);
  height: auto;
}

h1, h2, h3 { margin: .2rem 0 .8rem; }

input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem .9rem;
  font-size: 1rem;
}

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

.form-stack { display: grid; gap: .75rem; }

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .4rem;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover { background: var(--primary-dark); }

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: white;
}

.user-chip img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

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

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

.table-wrap {
  overflow: visible;
}

.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

.table-expedientes {
  min-width: 1180px;
}

.table th, .table td {
  border-bottom: 1px solid var(--border);
  padding: .55rem;
  text-align: left;
  vertical-align: middle;
}

.table th {
  background: #111827;
  color: white;
  position: sticky;
  top: 0;
}

.table tr:hover td { background: #eff6ff; }

.badge { padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-muted { background: #e2e8f0; color: #334155; }
.badge-sesion {
  background: #dbeafe;
  color: #1e3a8a;
  border: 1px solid #93c5fd;
  font-weight: 700;
  padding: .28rem .62rem;
}

.fojas-chip {
  display: inline-flex;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

.session-btn {
  width: auto;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: .28rem .62rem;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.1;
}
.session-btn:hover {
  background: #dbeafe;
}

.btn-ver-expediente {
  width: auto;
  padding: .35rem .78rem;
  border-radius: 999px;
  font-size: .82rem;
}

.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.actions form, .actions a { margin: 0; }
.actions input[type="submit"],
.actions input[type="image"],
.actions button,
.actions a { width: auto; }

.notice { color: var(--text-soft); font-size: .92rem; }
.error { color: #b91c1c; font-weight: 600; }

.welcome-page {
  background:
    radial-gradient(circle at top right, rgba(125, 211, 252, 0.2), transparent 35%),
    linear-gradient(150deg, #eff6ff 0%, #dbeafe 35%, #bfdbfe 100%);
}
.welcome-hero {
  background: linear-gradient(145deg, #ffffff 0%, #eff6ff 65%, #e0f2fe 100%);
  color: #0f172a;
  border: 1px solid #bfdbfe;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
}
.welcome-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: .9rem;
}
.user-chip-on-hero { color: #0f172a; }
.notice-on-hero { color: #475569; display: block; }
.welcome-hero-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.welcome-hero-logo {
  width: 106px;
  height: 106px;
  object-fit: contain;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #dbeafe;
  padding: .6rem;
}
.hero-counter {
  display: inline-flex;
  margin-top: .3rem;
  background: #dbeafe;
  color: #1e3a8a;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  padding: .25rem .65rem;
}
.btn-light {
  background: #ffffff;
  color: #1e40af;
  border: 1px solid #c7ddff;
}
.btn-light:hover { background: #dbeafe; }
.card-clean { box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08); }
.comision-card { border: 0; }
.comision-card__form { margin: 0; }
.comision-image-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transition: transform .22s ease, box-shadow .22s ease;
}
.comision-image-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.15);
}
.comision-image-button img {
  width: 100%;
  height: clamp(150px, 18vw, 235px);
  object-fit: cover;
  display: block;
  border: 1px solid #dbeafe;
}

@media (max-width: 900px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .welcome-hero-content { flex-direction: column; align-items: flex-start; }
}



/* Buscador inteligente en comisiones */
.welcome-hero-main {
  flex: 1;
  min-width: min(100%, 340px);
}

.search-panel {
  margin-top: .95rem;
  padding: .72rem;
  border-radius: 14px;
  background: linear-gradient(140deg, #1d4ed8, #2563eb);
  border: 1px solid rgba(255,255,255,.3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}

.search-label {
  color: #e0ecff;
  font-size: .86rem;
  font-weight: 700;
  margin-bottom: .42rem;
  display: block;
}

.search-row {
  display: flex;
  gap: .55rem;
  align-items: center;
}

.search-row input[type="text"] {
  flex: 1;
  width: auto;
  border: 1px solid #a5c6ff;
  background: #fff;
  color: #0f172a;
}

.search-exact-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: #e0ecff;
  font-size: .84rem;
  font-weight: 600;
  white-space: nowrap;
  padding: .45rem .6rem;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 12px;
  background: rgba(255,255,255,.08);
}

.search-exact-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #22c55e;
}

.search-btn {
  width: auto;
  min-width: 112px;
  border-radius: 12px;
  background: #0ea5e9;
}

.search-btn:hover {
  background: #0284c7;
}

.search-results {
  border-color: #bae6fd;
}

.search-results__header {
  display: flex;
  gap: .8rem;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.search-context {
  margin: .15rem 0 .2rem;
  color: #0f172a;
  font-size: .93rem;
}

.btn-close-search {
  white-space: nowrap;
}

.search-empty {
  margin-top: .8rem;
  border: 1px dashed #93c5fd;
  border-radius: 12px;
  background: #f0f9ff;
  color: #0c4a6e;
  padding: .9rem;
  font-weight: 600;
}

.search-error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #9f1239;
}

.search-single-card {
  margin-top: .5rem;
  border: 1px solid #c7e4ff;
  border-radius: 14px;
  padding: .9rem;
  background: linear-gradient(180deg, #f8fdff, #eef8ff);
}

.search-ficha {
  margin: .5rem 0 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem .85rem;
}

.search-ficha dt {
  font-size: .78rem;
  color: #334155;
  margin-bottom: .1rem;
}

.search-ficha dd {
  margin: 0;
  font-weight: 600;
  color: #0f172a;
}

.search-count {
  margin: .2rem 0 .65rem;
  color: #0f172a;
  font-weight: 600;
}

.search-table th {
  position: static;
}

@media (max-width: 900px) {
  .search-row {
    flex-direction: column;
  }

  .search-exact-toggle,
  .search-btn {
    width: 100%;
    justify-content: center;
  }

  .search-ficha {
    grid-template-columns: 1fr;
  }
}


/* Acciones superiores de consulta de expedientes */
.topbar-action {
  width: auto;
  min-height: 44px;
  padding: .68rem 1rem;
  border-radius: 999px;
  font-size: .92rem;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .16);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
  white-space: nowrap;
}

.topbar-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, .22);
}

.topbar-action--back {
  background: #ffffff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.topbar-action--back:hover {
  background: #eff6ff;
  color: #1d4ed8;
}

.topbar-action--clean {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: 1px solid #1d4ed8;
}

.topbar-action--clean:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

@media (max-width: 680px) {
  .topbar {
    align-items: stretch;
  }

  .topbar > h2 {
    width: 100%;
    text-align: center;
    order: -1;
  }

  .topbar-action,
  .topbar > form,
  .topbar > form .topbar-action {
    width: 100%;
  }
}

/* Seguridad de acceso y contraseñas */
.alert-box {
  margin: 0 0 1rem;
  padding: .85rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  text-align: left;
  font-weight: 650;
  line-height: 1.4;
}

.alert-box--warning {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.alert-box--error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.alert-box--success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.panel-kicker {
  display: inline-block;
  margin-bottom: .55rem;
  color: #1d4ed8;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .08em;
}

.form-stack label {
  display: grid;
  gap: .35rem;
  text-align: left;
  font-weight: 700;
}

.secondary-form {
  margin-top: .8rem;
}
