:root {
  --bg: #f1f5f9;
  --card: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --ok: #166534;
  --err: #991b1b;
  --radius: 8px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; }
a { color: var(--primary); }
.wrap { max-width: 960px; margin: 0 auto; padding: 1rem; }
.wrap-wide { max-width: 1100px; margin: 0 auto; padding: 1rem; }
body.bg-light .wrap-wide { max-width: 1140px; }
body.bg-light .topbar { background: #fff; }
body.bg-light .topbar-menu a { text-decoration: none; }
body.bg-light .topbar-menu a.active { font-weight: 600; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
}
.topbar-menu a { position: relative; z-index: 1001; }
.topbar-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.85rem;
  flex: 1 1 auto;
  min-width: 0;
}
.topbar-meta {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.3;
  max-width: 28rem;
}
.topbar-brand { font-weight: 700; }
.topbar nav a { margin-right: 0.75rem; text-decoration: none; color: var(--muted); }
.topbar nav a:hover, .topbar nav a.active { color: var(--primary); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.card h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.65rem; }
label { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
input:not(.quantity):not(.unit-price), select, textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
input.quantity,
input.unit-price {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.btn { display: inline-block; padding: 0.45rem 0.85rem; border-radius: 6px; border: 1px solid var(--border); background: var(--card); cursor: pointer; font: inherit; text-decoration: none; color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.alert { padding: 0.6rem 0.85rem; border-radius: 6px; margin-bottom: 0.75rem; }
.alert-ok { background: #dcfce7; color: var(--ok); }
.alert-err { background: #fee2e2; color: var(--err); }
.edit-policy-check { display: flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; white-space: nowrap; }
.edit-policy-check input { width: auto; }
.dept-checks .dept-checks-list { margin: 0; padding: 0; }
.dept-checks .dept-check { margin: 0 0 0.35rem 0; }
.dept-checks .dept-check:last-child { margin-bottom: 0; }
.dept-checks .dept-check > label { margin: 0 !important; font-size: 0.95rem; line-height: 1.25; color: var(--text); font-weight: 400; display: block; }
.dept-checks .dept-check input[type="checkbox"] { margin-top: 2px; }
.edit-policy-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.form-inline label { margin-bottom: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { border: 1px solid var(--border); padding: 0.4rem 0.5rem; text-align: left; }
table.data th { background: #f8fafc; }
.num { text-align: right; }
.badge { font-size: 0.72rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: #e2e8f0; }
.badge-sa { background: #fef3c7; color: #92400e; font-weight: 600; }
.login-box { max-width: 22rem; margin: 3rem auto; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 0.65rem;
  width: 100%; padding: 0.65rem 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; color: #3c4043; text-decoration: none; font-weight: 500; font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn-google:hover { background: #f8f9fa; color: #202124; }
.btn-google::before {
  content: ""; width: 1.15rem; height: 1.15rem; flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.56 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59a14.5 14.5 0 0 1 0-9.18l-7.98-6.19a24 24 0 0 0 0 21.56l7.98-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E") center/contain no-repeat;
}
.login-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--muted); font-size: 0.85rem; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-divider span { white-space: nowrap; }
.portal-links { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin-top: 2rem; }
.portal-links a,
.portal-link-form .portal-link-btn { padding: 1rem 1.25rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); min-width: 10rem; text-align: center; cursor: pointer; font: inherit; }
.portal-links a strong,
.portal-link-form .portal-link-btn strong { display: block; margin-bottom: 0.25rem; }
.portal-link-form { margin: 0; display: inline; }
.topbar-inline-form { display: inline; margin: 0; }
.topbar-link-btn { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; text-decoration: none; }
.topbar-link-btn:hover { text-decoration: underline; }
.btn-link { background: none; border: none; color: var(--link, #2563eb); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
a.topbar-brand { text-decoration: none; color: var(--text); }
a.topbar-brand:hover { color: var(--primary); }
.topbar-menu { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: center; }
.page-nav { margin-bottom: 1rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }
.page-nav-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.page-heading { margin: 0.5rem 0 0; font-size: 1.2rem; font-weight: 600; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }
.breadcrumb-current { color: var(--text); font-weight: 500; }
.breadcrumb-sep { color: var(--muted); margin: 0 0.2rem; user-select: none; }
.btn-back { white-space: nowrap; font-size: 0.88rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; padding: 0; list-style: none; }
p.page-actions { border: 0; }
.catalog-tenant-meta { margin-bottom: 0.75rem; }
.catalog-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.catalog-subnav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.catalog-subnav a:hover { color: var(--primary); background: #f8fafc; }
.catalog-subnav a.active { color: var(--primary); font-weight: 600; background: #eff6ff; }
.catalog-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.85rem;
}
.catalog-hub-card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.catalog-hub-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.12);
}
.catalog-hub-card h2 { font-size: 0.95rem; margin: 0 0 0.35rem; }
.catalog-hub-count { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.65rem; }
.catalog-list {
  max-height: 28rem;
  overflow-y: auto;
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  columns: 2;
  column-gap: 1.5rem;
}
@media (max-width: 640px) { .catalog-list { columns: 1; } }
.catalog-list li { break-inside: avoid; margin-bottom: 0.2rem; }
.catalog-list--editable {
  columns: 1;
  list-style: none;
  padding-left: 0;
}
.catalog-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.45rem;
}
.catalog-rename-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  flex: 1 1 16rem;
}
.catalog-rename-form__current {
  min-width: 8rem;
  font-weight: 600;
}
.catalog-rename-form input[name="new_name"] {
  flex: 1 1 10rem;
  max-width: 18rem;
}
.catalog-delete-form {
  flex: 0 0 auto;
}
.catalog-add-form { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.catalog-add-form label { margin-top: 0.35rem; }
.catalog-add-form--grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}
.catalog-add-form__actions { padding-bottom: 0.15rem; }
@media (max-width: 720px) {
  .catalog-add-form--grid { grid-template-columns: 1fr; }
}
.dash-title { margin: 0 0 0.5rem; font-size: 1.35rem; font-weight: 700; }
.dash-activity-top { margin-bottom: 1rem; }
.dash-activity-top__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.dash-activity-top__actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.dash-activity-top .btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.85rem;
}
.dash-muted { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
.dash-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 1rem; }
.dash-pill { display: inline-block; padding: 0.35rem 0.75rem; font-size: 0.85rem; border-radius: 6px; border: 1px solid var(--border); background: var(--card); text-decoration: none; color: var(--text); }
.dash-pill:hover { background: #f8fafc; }
.dash-pill.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.dash-pill.dim:not(.active) { opacity: 0.55; }
.dash-months { display: flex; flex-wrap: nowrap; gap: 0.25rem; overflow-x: auto; margin-bottom: 1rem; padding-bottom: 0.25rem; }
.dash-months .dash-pill { white-space: nowrap; }
.dash-grid { display: grid; gap: 1.25rem; margin-bottom: 1rem; }
.dash-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.dash-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.dash-grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.dash-section h2 { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.5rem; }
.dash-dept-btn { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.75rem; font-size: 0.85rem; font-weight: 500; border-radius: 6px; background: var(--primary); color: #fff; text-decoration: none; border: none; }
.dash-dept-btn:hover { background: var(--primary-hover); color: #fff; }
.dash-dept-btn.selected { background: #1e293b; }
table.data tr.row-selected { background: #eff6ff; }

/* Detalle presupuesto (nueva / editar actividad) */
[data-budget-detail] table.table-budget-detail {
  table-layout: fixed;
  width: 100%;
}
[data-budget-detail] table.table-budget-detail col.col-qty {
  width: 7rem;
}
[data-budget-detail] table.table-budget-detail col.col-unit {
  width: 9rem;
}
[data-budget-detail] table.table-budget-detail col.col-total {
  width: 6.5rem;
}
[data-budget-detail] table.table-budget-detail col.col-actions {
  width: 5.5rem;
}
[data-budget-detail] th.col-qty,
[data-budget-detail] td.col-qty {
  width: 7rem !important;
  min-width: 7rem !important;
  max-width: 7rem !important;
  white-space: nowrap;
  vertical-align: middle;
  text-align: center;
}
[data-budget-detail] input.quantity {
  display: block;
  width: 6.5rem !important;
  min-width: 6.5rem !important;
  max-width: 6.5rem !important;
  margin: 0 auto;
  box-sizing: border-box;
  text-align: right;
}
[data-budget-detail] th.col-unit,
[data-budget-detail] td.col-unit {
  width: 9rem !important;
}
[data-budget-detail] input.unit-price {
  width: 8.5rem !important;
  min-width: 8.5rem !important;
  max-width: 8.5rem !important;
  box-sizing: border-box;
  text-align: right;
}
.dash-view-toggle { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.btn-success { background: #15803d; color: #fff; border-color: #15803d; }
.btn-success:hover { background: #166534; }
.alert-warn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

body.export-modal-open { overflow: hidden; }
.export-modal {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.export-modal[hidden] { display: none !important; }
.export-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.export-modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 22rem);
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.1rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  text-align: center;
}
.export-modal__visual {
  display: flex;
  justify-content: center;
  margin-bottom: 0.85rem;
}
.export-modal__doc {
  position: relative;
  width: 4.5rem;
  height: 5rem;
}
.export-modal__doc-sheet {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}
.export-modal__doc-sheet--back {
  transform: rotate(-8deg) translate(-6px, 4px);
  opacity: 0.65;
}
.export-modal__doc-sheet--front {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #ecfdf5, #fff);
  animation: export-doc-pulse 1.4s ease-in-out infinite;
}
.export-modal__doc-icon {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #047857;
}
@keyframes export-doc-pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.export-modal__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.export-modal__subtitle {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
.export-modal__progress-wrap {
  margin-bottom: 0.55rem;
}
.export-modal__progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.export-modal__progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #059669, #34d399);
  transition: width 0.25s ease;
}
.export-modal__progress-text {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #047857;
}
.export-modal__detail {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text, #0f172a);
  min-height: 1.2rem;
}
.export-modal__hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted, #64748b);
  line-height: 1.35;
}

/* OC nueva: modales AJAX flotantes (como oc_create.php legado) */
body.page-oc-new .modal { z-index: 10050 !important; }
body.page-oc-new .modal-backdrop { z-index: 10040 !important; }
body.page-oc-new .modal-body { max-height: min(70vh, 520px); overflow-y: auto; }
body.page-oc-new .ui-autocomplete {
  z-index: 10060 !important;
  max-height: 280px;
  overflow-y: auto;
}
body.page-oc-new .oc-modal-loader { font-size: 0.85rem; color: var(--muted); min-height: 1.25rem; }
body.page-oc-new .oc-form-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; margin: 0.75rem 0 1rem; }
