:root {
  --app-bg: #f6f5f2;
  --app-surface: rgba(255,255,255,.92);
  --app-surface-solid: #ffffff;
  --app-text: #171717;
  --app-muted: #686868;
  --app-line: #e4e1dd;
  --app-primary: #1d1d1d;
  --app-primary-2: #353535;
  --app-primary-soft: #fbeaf2;
  --app-accent: #df4b88;
  --app-success: #16855b;
  --app-warning: #b46a08;
  --app-danger: #c73b4d;
  --app-radius: 18px;
  --app-radius-sm: 11px;
  --app-shadow: 0 16px 48px rgba(31, 43, 72, .10);
  --app-shadow-sm: 0 8px 24px rgba(31, 43, 72, .08);
}

* { box-sizing: border-box; }
html { background: var(--app-bg); }
body {
  width: 100% !important;
  max-width: none !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 18px 28px !important;
  display: block !important;
  color: var(--app-text) !important;
  background:
    radial-gradient(circle at 8% 0%, rgba(223,75,136,.08), transparent 28rem),
    radial-gradient(circle at 92% 4%, rgba(29,29,29,.05), transparent 30rem),
    var(--app-bg) !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  line-height: 1.45;
}

body > section,
body > .container,
.gestion,
.app-page {
  width: min(100%, 1320px) !important;
  max-width: 1320px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* App header */
.app-header {
  position: sticky;
  top: 12px;
  z-index: 1000;
  width: min(100%, 1320px) !important;
  min-height: 0 !important;
  margin: 12px auto 18px !important;
  padding: 11px 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 18px;
  border: 1px solid rgba(222,228,239,.9) !important;
  border-radius: 18px !important;
  background: rgba(255,255,255,.86) !important;
  box-shadow: 0 10px 34px rgba(31,43,72,.09) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  color: var(--app-text) !important;
  text-decoration: none !important;
  font-weight: 800;
  letter-spacing: -.02em;
}
.app-brand img {
  width: 52px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  transform: none !important;
}
.app-brand small {
  display: block;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.app-brand-name { line-height: 1.05; }

.app-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}
.app-nav > a,
.app-nav summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #354056 !important;
  background: transparent;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.app-nav > a:hover,
.app-nav summary:hover,
.app-nav .is-active {
  color: var(--app-primary) !important;
  background: var(--app-primary-soft) !important;
  border-color: #dfe5ff !important;
  transform: translateY(-1px);
}
.app-nav details { position: relative; }
.app-nav details > summary { list-style: none; }
.app-nav details > summary::-webkit-details-marker { display: none; }
.app-nav details > summary::after {
  content: "⌄";
  margin-left: 7px;
  font-size: 12px;
  color: #8a94a6;
}
.app-nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 205px;
  padding: 7px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--app-line);
  border-radius: 14px;
  background: rgba(255,255,255,.98);
  box-shadow: var(--app-shadow-sm);
}
.app-nav-menu a {
  display: block;
  padding: 10px 11px;
  border-radius: 9px;
  color: #344054 !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 650;
}
.app-nav-menu a:hover,
.app-nav-menu a.is-active {
  color: var(--app-primary) !important;
  background: #f1f4ff;
}

/* Legacy header fallback */
header:not(.app-header) {
  width: min(100%, 1320px) !important;
  min-height: auto !important;
  margin: 14px auto !important;
  padding: 14px !important;
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 12px;
  align-items: stretch !important;
  border: 1px solid var(--app-line) !important;
  border-radius: var(--app-radius) !important;
  background: var(--app-surface) !important;
  box-shadow: var(--app-shadow-sm) !important;
}
.menu-column { width: auto !important; display: grid; gap: 7px; align-content: center; }
.image-column { width: auto !important; min-width: 120px; }
.image-column img { max-width: 150px !important; max-height: 94px !important; transform: none !important; }

/* Content shell */
.gestion {
  min-height: 0 !important;
  height: auto !important;
  padding: 18px !important;
  border: 1px solid var(--app-line) !important;
  border-radius: var(--app-radius) !important;
  background: var(--app-surface-solid) !important;
  box-shadow: var(--app-shadow) !important;
  overflow: visible !important;
}
.gestion > .container,
.gestion .container,
.container {
  width: 100% !important;
  max-width: 100% !important;
}

h1, h2, h3, h4, h5, h6 { color: var(--app-text); letter-spacing: -.025em; }
h1 { font-weight: 820; }
h2, h3 { font-weight: 760; }
.text-center { text-wrap: balance; }

/* Controls */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.form-control,
.form-select {
  min-height: 42px;
  border: 1px solid #d8deea !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: var(--app-text) !important;
  box-shadow: none !important;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
textarea { min-height: 92px; resize: vertical; }
input:focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-select:focus {
  border-color: #7f95ed !important;
  box-shadow: 0 0 0 4px rgba(49,87,213,.10) !important;
}
label { color: #475467; font-weight: 680; margin-bottom: 5px; }

button,
.btn,
input[type="submit"] {
  min-height: 40px;
  width: auto !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  font-weight: 740 !important;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease !important;
}
button:hover,
.btn:hover,
input[type="submit"]:hover { transform: translateY(-1px); }
.btn-primary,
button[type="submit"],
input[type="submit"] {
  border-color: transparent !important;
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-2)) !important;
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(49,87,213,.20) !important;
}
.btn-outline-primary {
  width: 100% !important;
  min-height: 38px;
  border: 1px solid #d8e0ff !important;
  background: #f8f9ff !important;
  color: var(--app-primary) !important;
  text-shadow: none !important;
}
.btn-outline-primary:hover {
  border-color: #cbd6ff !important;
  background: #edf1ff !important;
  color: #2449c5 !important;
  text-shadow: none !important;
}

/* Tables */
.table-container {
  max-height: none !important;
  margin: 12px 0 16px;
  overflow: auto !important;
  border: 1px solid var(--app-line);
  border-radius: 13px;
  background: #fff;
}
table,
.tbl {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background: #fff;
}
th,
td {
  padding: 10px 9px !important;
  border: 0 !important;
  border-bottom: 1px solid #e9edf4 !important;
  text-align: left;
  vertical-align: middle;
  background: transparent !important;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #475467;
  background: #f7f9fc !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .025em;
  text-transform: uppercase;
}
tr:nth-child(even), tr:nth-child(odd) { background: #fff !important; }
tbody tr:hover { background: #fafbff !important; }

/* Status buttons become compact chips */
[class*="btn-estado-"],
.btn-pendiente,.btn-impreso,.btn-finalizado,.btn-comunicado,.btn-entregado,.btn-SinSena,
.btn-entregad {
  width: auto !important;
  min-width: 86px;
  min-height: 31px;
  padding: 5px 9px !important;
  border: 0 !important;
  border-radius: 999px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  text-shadow: none !important;
}
.btn-pendiente, .btn-estado-pendiente { background: #fff0f2 !important; color: var(--app-danger) !important; }
.btn-impreso { background: #fff6df !important; color: var(--app-warning) !important; }
.btn-finalizado, .btn-estado-resuelto, .btn-entregad { background: #eaf8f2 !important; color: var(--app-success) !important; }
.btn-comunicado, .btn-estado-comunicado { background: #edf3ff !important; color: #3157d5 !important; }
.btn-SinSena { background: #f1f3f6 !important; color: #667085 !important; }

/* Tabs / cards */
.nav-tabs {
  gap: 6px;
  padding: 5px !important;
  border: 1px solid var(--app-line) !important;
  border-radius: 13px;
  background: #f6f8fb;
}
.nav-tabs .nav-link {
  border: 0 !important;
  border-radius: 9px !important;
  color: #667085;
  font-weight: 720;
}
.nav-tabs .nav-link.active { background: #fff !important; color: var(--app-primary) !important; box-shadow: 0 4px 12px rgba(31,43,72,.08); }
.tab-content { padding-top: 14px; }
.item {
  padding: 14px;
  border: 1px solid var(--app-line);
  border-radius: 13px;
  background: #fbfcfe;
}

/* Dashboard */
.dashboard-shell { width: min(100%, 1320px); margin: 0 auto; }
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px,.7fr);
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--app-line);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(24,24,24,.98), rgba(58,58,58,.96)),
    #1d1d1d;
  color: #fff;
  box-shadow: var(--app-shadow);
  overflow: hidden;
}
.dashboard-hero h1 { margin: 0 0 7px; color: #fff; font-size: clamp(29px,4vw,46px); }
.dashboard-hero p { max-width: 680px; margin: 0; color: rgba(255,255,255,.82); font-size: 16px; }
.dashboard-hero-side {
  align-self: stretch;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.10);
  backdrop-filter: blur(10px);
}
.dashboard-hero-side strong { display:block; margin-bottom: 4px; font-size: 14px; }
.dashboard-hero-side span { color: rgba(255,255,255,.75); font-size: 13px; }
.dashboard-search {
  width: min(100%, 520px);
  margin-top: 18px;
  position: relative;
}
.dashboard-search input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px 0 43px !important;
  border: 1px solid rgba(255,255,255,.20) !important;
  background: rgba(255,255,255,.96) !important;
}
.dashboard-search::before { content: "⌕"; position:absolute; left:15px; top:10px; z-index:2; color:#667085; font-size:22px; }
.dashboard-section-title { display:flex; align-items:end; justify-content:space-between; gap:16px; margin:28px 0 12px; }
.dashboard-section-title h2 { margin:0; font-size:20px; }
.dashboard-section-title p { margin:0; color:var(--app-muted); font-size:13px; }
.dashboard-grid { display:grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap:14px; }
.dashboard-card {
  min-height: 188px;
  padding: 18px;
  display:flex;
  flex-direction:column;
  border:1px solid var(--app-line);
  border-radius:18px;
  background:#fff;
  box-shadow: var(--app-shadow-sm);
  text-decoration:none !important;
  color:var(--app-text) !important;
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.dashboard-card:hover { transform:translateY(-3px); border-color:#cfd8ff; box-shadow:0 18px 38px rgba(31,43,72,.12); }
.dashboard-card .icon {
  width:44px; height:44px; display:grid; place-items:center; margin-bottom:18px;
  border-radius:13px; background:var(--app-primary-soft); color:var(--app-primary); font-size:21px; font-weight:800;
}
.dashboard-card h3 { margin:0 0 6px; font-size:17px; }
.dashboard-card p { margin:0; color:var(--app-muted); font-size:13px; }
.dashboard-card .go { margin-top:auto; padding-top:15px; color:var(--app-primary); font-size:13px; font-weight:780; }
.dashboard-card[hidden] { display:none !important; }
.dashboard-quick { display:flex; gap:9px; flex-wrap:wrap; }
.dashboard-quick a {
  display:inline-flex; align-items:center; min-height:39px; padding:0 13px;
  border:1px solid var(--app-line); border-radius:10px; background:#fff;
  color:#475467 !important; text-decoration:none !important; font-size:13px; font-weight:700;
}
.dashboard-quick a:hover { border-color:#cdd6f7; color:var(--app-primary) !important; }

/* Footer */
.app-footer,
footer {
  width: min(100%, 1320px) !important;
  height: auto !important;
  min-height: 48px;
  margin: 18px auto 0 !important;
  padding: 11px 15px !important;
  display:flex !important;
  justify-content:space-between !important;
  align-items:center !important;
  gap:14px;
  border:1px solid var(--app-line) !important;
  border-radius:14px !important;
  background:rgba(255,255,255,.82) !important;
  color:var(--app-muted);
  box-shadow:none !important;
}
.app-footer a,
.social-icons a { color:var(--app-primary) !important; text-decoration:none; }
.app-footer small { color:var(--app-muted); }

/* Do not show known dead legacy placeholders */
a[href="#"] { display:none !important; }

@media (max-width: 1000px) {
  .app-header { position: static; align-items:flex-start !important; flex-direction:column; }
  .app-nav { width:100%; justify-content:flex-start; }
  .app-nav-menu { left:0; right:auto; }
  .dashboard-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-hero { grid-template-columns:1fr; }
  header:not(.app-header) { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .image-column { grid-column:1/-1; grid-row:1; }
}

@media (max-width: 640px) {
  body { padding: 0 9px 18px !important; }
  .app-header { margin-top:8px !important; padding:10px !important; border-radius:14px !important; }
  .app-brand img { width:45px; height:36px; }
  .app-nav { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .app-nav > a, .app-nav summary { width:100%; justify-content:center; }
  .app-nav details { width:100%; }
  .app-nav-menu { position:static; width:100%; margin-top:5px; box-shadow:none; }
  .gestion { padding:11px !important; border-radius:14px !important; }
  .dashboard-hero { padding:20px; border-radius:18px; }
  .dashboard-grid { grid-template-columns:1fr; }
  .dashboard-card { min-height:160px; }
  header:not(.app-header) { grid-template-columns:1fr; }
  .menu-column { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .form-row { display:grid !important; grid-template-columns:1fr !important; gap:9px; }
  #LabelUs,#LabelNo,#LabelCo { width:100% !important; margin:0 !important; }
  .table-container { width:100%; }
  table { min-width:680px; }
  footer,.app-footer { align-items:flex-start !important; flex-direction:column; }
}

@media print {
  .app-header,.app-footer,.dashboard-search { display:none !important; }
  body { padding:0 !important; background:#fff !important; }
  .gestion { border:0 !important; box-shadow:none !important; padding:0 !important; }
}

/* v1.02 · shell global: 80% real del viewport en escritorio */
html {
  width: 100%;
  min-height: 100%;
  background: var(--app-bg);
}

body {
  width: 80vw !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: 0 18px 28px !important;
}

/* Todo el contenido ocupa el 100% del shell de 80vw. */
body > .app-header,
body > .dashboard-shell,
body > .app-footer,
body > section,
body > .gestion,
body > footer {
  width: 100% !important;
  max-width: none !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

body > section > .app-header,
body > section > .gestion,
body > section > footer,
body .gestion,
body .container {
  width: 100% !important;
  max-width: none !important;
}

.app-brand img {
  width: 58px;
  height: 46px;
  object-fit: contain;
  border-radius: 0;
}

.app-nav > a:hover,
.app-nav summary:hover,
.app-nav .is-active,
.dashboard-card .icon {
  color: var(--app-accent) !important;
}

.dashboard-card:hover {
  border-color: rgba(223,75,136,.32);
}

.dashboard-card .go,
.app-footer a,
.social-icons a {
  color: var(--app-accent) !important;
}

@media (max-width: 1000px) {
  body {
    width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* v1.03 · acceso con Google */
.app-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 12px;
  border-left: 1px solid var(--app-line);
  font-size: 12px;
  white-space: nowrap;
}
.app-user span { color: var(--app-muted); font-weight: 650; }
.app-user a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--app-line);
  border-radius: 10px;
  color: var(--app-text) !important;
  text-decoration: none !important;
  font-weight: 750;
  background: #fff;
}
.login-body {
  width: 100% !important;
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 24px !important;
  display: grid !important;
  place-items: center;
}
.login-shell { width: min(100%, 460px); }
.login-card {
  width: 100%;
  padding: 34px;
  border: 1px solid var(--app-line);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--app-shadow);
  text-align: center;
}
.login-logo { width: 118px; height: auto; object-fit: contain; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 7px; font-size: 27px; letter-spacing: -.03em; }
.login-card p { margin: 0 0 24px; color: var(--app-muted); }
#google-signin { min-height: 44px; display: grid; place-items: center; }
.login-alert {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #ead7a2;
  border-radius: 11px;
  background: #fff9e8;
  color: #6f5611;
  font-size: 13px;
}
.login-alert-error { border-color: #efc8ce; background: #fff1f3; color: #9e293c; }
@media (max-width: 1180px) {
  .app-user { width: 100%; justify-content: flex-end; border-left: 0; padding-left: 0; }
}
