:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #eef2f7;
  --navy: #172a4a;
  --blue: #2f63d7;
  --line: #dce3ec;
  --muted: #68758a;
  --surface: #fff;
  --shadow: 0 12px 34px rgba(23, 42, 74, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #eef2f7; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(73, 115, 200, .11), transparent 32rem),
    linear-gradient(180deg, #f4f7fb 0%, #edf1f6 100%);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }

.dashboard-shell {
  width: min(1160px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.dashboard-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  overflow: hidden;
  padding: 34px 36px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 20%, rgba(100, 149, 255, .27), transparent 18rem),
    linear-gradient(135deg, #142641 0%, #203c68 58%, #274d88 100%);
  box-shadow: 0 18px 46px rgba(20, 38, 65, .2);
  color: #fff;
}
.dashboard-header::after {
  content: "";
  position: absolute;
  right: -65px;
  bottom: -105px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 50%;
  box-shadow: 0 0 0 38px rgba(255,255,255,.035), 0 0 0 78px rgba(255,255,255,.025);
  pointer-events: none;
}
.dashboard-header > * { position: relative; z-index: 1; }
.brand-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 18px; }
.brand-mark { font-size: 13px; font-weight: 900; letter-spacing: .2em; }
.version-badge { padding: 5px 8px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.1); color: #dce8ff; font-size: 10px; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
h1 { max-width: 720px; margin: 0; font-size: clamp(36px, 6vw, 58px); line-height: .98; letter-spacing: -.052em; }
.intro { max-width: 680px; margin: 16px 0 0; color: #cfdbef; font-size: clamp(15px, 2vw, 18px); line-height: 1.55; }

.access-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 5px 6px 5px 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  color: #fff0cc;
  font-size: 12px;
  font-weight: 800;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.access-status.editing { color: #c8f7d7; }
.access-status form { margin: 0; }
.access-status a, .access-status button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: #20385e;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(6, 18, 37, .18);
}
.access-status.viewing a { background: #4c7ff1; color: #fff; }

.dashboard-overview {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 12px;
  margin: 16px 0 38px;
}
.overview-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 84px;
  padding: 17px 19px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,.88);
  box-shadow: 0 7px 20px rgba(23, 42, 74, .05);
}
.overview-card:not(.primary) { align-items: flex-start; flex-direction: column; justify-content: center; gap: 5px; }
.overview-card.primary { background: linear-gradient(135deg, #f3f7ff, #fff); }
.overview-icon { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: #e5edff; color: #2f63d7; font-size: 18px; font-weight: 900; }
.overview-card span:not(.overview-icon) { display: grid; gap: 4px; }
.overview-card strong { color: #24324a; font-size: 16px; }
.overview-card small, .overview-label { color: #788397; font-size: 12px; line-height: 1.35; }

.program-section-heading, .section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.eyebrow { margin: 0 0 6px; color: #597098; font-size: 11px; font-weight: 900; letter-spacing: .15em; }
.program-section-heading h2, .section-heading h2 { margin: 0; color: #172033; font-size: clamp(25px, 3vw, 32px); letter-spacing: -.03em; }
.responsive-note { padding: 7px 10px; border-radius: 999px; background: #e5ecf8; color: #536783; font-size: 11px; font-weight: 750; }

.program-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.program-card {
  --accent: #466ca8;
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  grid-template-areas:
    "number state arrow"
    "number copy arrow";
  align-items: center;
  gap: 7px 16px;
  overflow: hidden;
  min-height: 164px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.program-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--accent); }
.program-card::after { content: ""; position: absolute; right: -45px; bottom: -65px; width: 150px; height: 150px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 8%, transparent); pointer-events: none; }
.program-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 35%, #dce3ec); box-shadow: 0 17px 38px rgba(23,42,74,.13); }
.program-card:focus-visible { outline: 3px solid rgba(47, 99, 215, .28); outline-offset: 3px; }
.program-card.vida { --accent: #7d5cab; }
.program-card.asignaciones { --accent: #287d86; }
.program-card.publica { --accent: #c86a35; }
.program-card.discursos { --accent: #3868ac; }
.program-card.territorios { --accent: #347b50; grid-column: 1 / -1; }
.card-number { grid-area: number; display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent); font-size: 12px; font-weight: 900; }
.program-state { grid-area: state; display: inline-flex; align-items: center; gap: 6px; justify-self: start; color: #66748a; font-size: 10px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.program-state i { width: 7px; height: 7px; border-radius: 50%; background: #39a564; box-shadow: 0 0 0 3px #e6f6ec; }
.program-state.busy { color: #9a5d08; }
.program-state.busy i { background: #df9a23; box-shadow: 0 0 0 3px #fff1d5; }
.card-copy { grid-area: copy; display: flex; min-width: 0; flex-direction: column; gap: 5px; }
.card-copy strong { color: #202d43; font-size: 21px; letter-spacing: -.015em; }
.card-copy > small { color: #68758a; font-size: 13px; }
.program-meta { display: grid; gap: 2px; margin-top: 6px; color: #8791a2; font-size: 11px; line-height: 1.35; }
.program-meta span:last-child { color: #58667c; font-weight: 700; }
.card-arrow { grid-area: arrow; position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 11px; font-weight: 850; text-transform: uppercase; }
.card-arrow b { font-size: 22px; transition: transform .18s ease; }
.program-card:hover .card-arrow b { transform: translateX(3px); }

.history-section { margin-top: 42px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.section-heading { align-items: flex-start; }
.section-heading p:not(.eyebrow) { max-width: 620px; margin: 7px 0 0; color: #6d788b; font-size: 14px; line-height: 1.5; }
.history-tools { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.history-tools label { color: #718096; font-size: 11px; font-weight: 750; }
.history-tools select { min-height: 36px; padding: 0 28px 0 10px; border: 1px solid #ccd5e1; border-radius: 9px; background: #fff; color: #3d4a60; font-size: 12px; }
.history-total { flex: none; padding: 7px 10px; border-radius: 999px; background: #eaf0f8; color: #526077; font-size: 11px; font-weight: 800; }
.history-create { display: grid; grid-template-columns: 220px minmax(220px, 1fr) auto; align-items: end; gap: 12px; margin-top: 22px; padding: 16px; border: 1px solid #dce3ed; border-radius: 14px; background: #f6f8fb; }
.history-create label { display: grid; gap: 6px; }
.history-create label > span { color: #4c596d; font-size: 11px; font-weight: 800; }
.history-create input, .history-create select { width: 100%; min-height: 43px; padding: 0 11px; border: 1px solid #bcc6d5; border-radius: 9px; background: #fff; color: #172033; font-size: 14px; }
.history-create input:focus, .history-create select:focus, .history-tools select:focus { outline: 3px solid rgba(40,85,197,.16); border-color: #2855c5; }
.history-create button, .history-actions button, .history-actions a { display: inline-flex; align-items: center; justify-content: center; min-height: 39px; padding: 0 13px; border: 1px solid #cbd3df; border-radius: 9px; background: #fff; color: #344056; font-size: 12px; font-weight: 800; text-decoration: none; cursor: pointer; }
.history-create > button { min-height: 43px; border-color: #2855c5; background: #2855c5; color: #fff; }
.history-create button:disabled, .history-actions button:disabled { opacity: .65; cursor: wait; }
.history-view-note { margin: 19px 0 0; padding: 11px 13px; border-radius: 10px; background: #f1f4f8; color: #657187; font-size: 12px; }
.dashboard-notice { margin-top: 15px; padding: 11px 13px; border: 1px solid #a9dfbd; border-radius: 10px; background: #effbf3; color: #17633a; font-size: 12px; font-weight: 700; }
.dashboard-notice.error { border-color: #efbcbc; background: #fff2f2; color: #982f2f; }
.history-list { display: grid; gap: 9px; margin-top: 18px; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px; border: 1px solid #e1e5eb; border-radius: 12px; transition: border-color .15s ease, background .15s ease; }
.history-item:hover { border-color: #cbd6e5; background: #fafcff; }
.history-copy { display: grid; justify-items: start; gap: 5px; min-width: 0; }
.history-copy strong { overflow: hidden; max-width: 100%; color: #263247; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.history-copy small { color: #758095; font-size: 11px; }
.history-program { padding: 4px 7px; border-radius: 6px; background: #eef2f7; color: #536177; font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.history-vida { background: #f1ebfa; color: #67468f; }.history-asignaciones { background: #e6f4f5; color: #256a72; }.history-publica { background: #faeee7; color: #a35125; }.history-discursos { background: #eaf0f9; color: #315b96; }.history-territorios { background: #e8f4ec; color: #2d6945; }
.history-actions { display: flex; flex: none; gap: 7px; }.history-actions button { border-color: #efc1c1; color: #a43d3d; }
.history-empty { padding: 26px; border: 1px dashed #cdd4de; border-radius: 12px; color: #758095; font-size: 12px; line-height: 1.5; text-align: center; }.history-empty.error { border-color: #efc1c1; color: #a43d3d; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-top: 26px; padding: 0 4px; color: #788397; font-size: 11px; } footer strong { color: #536178; }

.dashboard-confirm-modal { position: fixed; z-index: 2147483600; inset: 0; display: grid; place-items: center; padding: 18px; }
.dashboard-confirm-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(15, 26, 45, .62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dashboard-confirm-card { position: relative; width: min(100%, 420px); padding: 25px; border: 1px solid rgba(255,255,255,.5); border-radius: 18px; background: #fff; box-shadow: 0 25px 80px rgba(8, 20, 40, .35); }
.dashboard-confirm-icon { display: grid; width: 46px; height: 46px; place-items: center; margin-bottom: 15px; border-radius: 13px; background: #fff0ed; color: #bc4d3c; font-size: 25px; font-weight: 800; }
.dashboard-confirm-card h3 { margin: 0; color: #202d43; font-size: 23px; letter-spacing: -.025em; }
.dashboard-confirm-card p { margin: 9px 0 21px; color: #68758a; font-size: 14px; line-height: 1.5; }
.dashboard-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dashboard-confirm-actions button { min-height: 43px; border: 1px solid #cdd5e0; border-radius: 10px; background: #fff; color: #425066; font-size: 13px; font-weight: 800; cursor: pointer; }
.dashboard-confirm-actions .confirm { border-color: #b94d40; background: #b94d40; color: #fff; }

@media (max-width: 820px) {
  .dashboard-shell { width: min(100% - 22px, 1160px); padding-top: 12px; }
  .dashboard-header { flex-direction: column; padding: 27px 24px; border-radius: 20px; }
  .access-status { align-self: stretch; justify-content: space-between; }
  .dashboard-overview { grid-template-columns: 1fr 1fr; margin-bottom: 31px; }
  .overview-card.primary { grid-column: 1 / -1; }
  .program-section-heading { align-items: flex-start; flex-direction: column; gap: 9px; }
  .program-grid { grid-template-columns: 1fr; }
  .program-card.territorios { grid-column: auto; }
  .section-heading { flex-direction: column; }
  .history-tools { width: 100%; justify-content: flex-start; }
  .history-create { grid-template-columns: 1fr; padding: 13px; }
}

@media (max-width: 560px) {
  .dashboard-header { padding: 24px 20px; }
  h1 { font-size: 38px; }
  .intro { font-size: 14px; }
  .dashboard-overview { grid-template-columns: 1fr; gap: 9px; }
  .overview-card.primary { grid-column: auto; }
  .overview-card { min-height: 72px; padding: 14px; }
  .responsive-note { font-size: 10px; }
  .program-card { grid-template-columns: 42px minmax(0, 1fr) auto; min-height: 151px; gap: 6px 12px; padding: 18px 15px; border-radius: 16px; }
  .card-number { width: 42px; height: 42px; }
  .card-copy strong { font-size: 19px; }
  .card-arrow { font-size: 0; gap: 0; }
  .card-arrow b { font-size: 22px; }
  .history-section { margin-top: 30px; padding: 21px 14px; border-radius: 17px; }
  .history-tools { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
  .history-tools select { width: 100%; min-width: 0; }
  .history-item { align-items: stretch; flex-direction: column; gap: 12px; }
  .history-copy strong { white-space: normal; }
  .history-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .history-actions > :only-child { grid-column: 1 / -1; }
  .history-actions button { grid-column: 1 / -1; }
  .history-actions button, .history-actions a { min-height: 43px; }
  footer { align-items: flex-start; flex-direction: column; padding: 0 5px; }
}

@media (max-width: 350px) {
  .version-badge { display: none; }
  .history-tools { grid-template-columns: 1fr auto; }
  .history-tools label { display: none; }
}

/* Historial compacto y accesible (v6) */
.history-section {
  overflow: hidden;
  padding: 0;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.history-section.is-open {
  border-color: #cbd7e8;
  box-shadow: 0 18px 42px rgba(23, 42, 74, .1);
}
.history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 112px;
  padding: 22px 24px;
}
.history-summary-copy {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.history-summary-icon {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: #e9f0fb;
  color: #315f9f;
  font-size: 24px;
  font-weight: 850;
}
.history-summary .eyebrow { margin-bottom: 3px; font-size: 9px; }
.history-summary h2 { margin: 0; color: #172033; font-size: 24px; letter-spacing: -.025em; }
.history-summary-copy p:not(.eyebrow) { margin: 4px 0 0; color: #758095; font-size: 12px; line-height: 1.45; }
.history-summary-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
}
.history-summary-total {
  padding: 7px 10px;
  border-radius: 999px;
  background: #eef3f9;
  color: #65748a;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.history-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid #cbd8ea;
  border-radius: 11px;
  background: #f8fbff;
  color: #31557f;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.history-toggle:hover { border-color: #aebfda; background: #eef4fd; color: #234b7d; }
.history-toggle:focus-visible { outline: 3px solid rgba(47, 99, 215, .2); outline-offset: 2px; }
.history-toggle i { font-size: 16px; font-style: normal; transition: transform .18s ease; }
.history-toggle[aria-expanded="true"] i { transform: rotate(180deg); }
.history-content {
  padding: 0 24px 24px;
  border-top: 1px solid #e6ebf2;
}
.history-content[hidden] { display: none; }
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0 13px;
}
.history-toolbar > p { margin: 0; color: #788397; font-size: 11px; line-height: 1.45; }
.history-list {
  max-height: min(520px, 62vh);
  margin-top: 4px;
  padding-right: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #bdc9d9 transparent;
  scrollbar-width: thin;
}
.history-list::-webkit-scrollbar { width: 7px; }
.history-list::-webkit-scrollbar-thumb { border-radius: 999px; background: #bdc9d9; }

@media (max-width: 720px) {
  .history-summary { align-items: stretch; flex-direction: column; gap: 16px; padding: 19px 17px; }
  .history-summary-actions { justify-content: space-between; }
  .history-toggle { flex: 1; max-width: 190px; }
  .history-content { padding: 0 14px 16px; }
  .history-toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .history-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .history-tools label { grid-column: 1 / -1; }
  .history-list { max-height: 66vh; padding-right: 1px; }
}

@media (max-width: 390px) {
  .history-summary-copy { align-items: flex-start; gap: 12px; }
  .history-summary-icon { flex-basis: 42px; width: 42px; height: 42px; border-radius: 12px; font-size: 21px; }
  .history-summary h2 { font-size: 22px; }
  .history-summary-copy p:not(.eyebrow) { font-size: 11px; }
  .history-summary-total { padding-inline: 8px; }
  .history-toggle { min-height: 40px; padding-inline: 11px; }
}
