:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #14171f;
  --muted: #687083;
  --line: #dce1ea;
  --accent: #db2727;
  --accent-dark: #ac1717;
  --ink: #232936;
  --chip: #eef1f6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 0 18px;
}

.brand-block {
  display: grid;
  gap: 14px;
}

.jobsoft-logo {
  width: 132px;
  height: auto;
  object-fit: contain;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.primary-button,
.secondary-button,
.icon-button,
.view-button,
input[type="search"],
select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

.primary-button {
  cursor: pointer;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  padding: 0 18px;
  font-weight: 700;
}

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

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.secondary-button,
.icon-button,
.view-button {
  cursor: pointer;
  padding: 0 14px;
  font-weight: 800;
}

.secondary-button:hover,
.icon-button:hover,
.view-button:hover,
.view-button.is-active {
  border-color: var(--ink);
}

.view-button.is-active {
  background: var(--ink);
  color: white;
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.controls,
.summary {
  display: grid;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.viewbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.segmented,
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-nav strong {
  min-width: 190px;
  text-align: center;
  text-transform: capitalize;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 1.45rem;
  line-height: 1;
}

.controls {
  grid-template-columns: auto minmax(150px, 1fr) auto minmax(180px, 1fr);
  padding: 16px;
}

.controls label {
  color: var(--muted);
  font-weight: 700;
}

input[type="search"],
select {
  width: 100%;
  padding: 0 12px;
}

.status {
  grid-column: 1 / -1;
  justify-self: end;
  color: var(--muted);
  font-size: 0.93rem;
  text-align: right;
}

.status[data-tone="ok"] {
  color: #236b3f;
}

.status[data-tone="error"] {
  color: #b42318;
}

.summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0 22px;
  padding: 16px;
}

.summary span {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
}

.summary small {
  color: var(--muted);
}

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

.event-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 24px rgb(20 23 31 / 7%);
  cursor: pointer;
}

.event-card.is-selected,
.history-card.is-selected,
.calendar-event.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(219 39 39 / 16%), 0 12px 24px rgb(20 23 31 / 7%);
}

.event-card.is-selected::after,
.history-card.is-selected::after {
  content: "Seleccionado";
  position: absolute;
  top: 10px;
  right: 10px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  padding: 5px 9px;
  font-size: 0.72rem;
  font-weight: 900;
}

.image-link {
  display: block;
  aspect-ratio: 16 / 9;
  background: #e9edf3;
}

.event-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.event-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.event-meta span {
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.history-badge {
  background: #fff2d8 !important;
  color: #8a5a00 !important;
}

h2 {
  margin: 0;
  min-height: 2.45em;
  font-size: 1.15rem;
  line-height: 1.22;
  letter-spacing: 0;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: grid;
  gap: 2px;
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 4px;
}

.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 12px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.download-link {
  border-color: var(--accent) !important;
  color: var(--accent);
}

.empty {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.calendar-view {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 134px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
}

.calendar-day.is-empty {
  background: transparent;
  border-color: transparent;
}

.calendar-day > strong {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.calendar-event {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin-top: 6px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--ink);
  padding: 4px;
  border: 1px solid transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.calendar-event img {
  width: 34px;
  height: 26px;
  border-radius: 4px;
  object-fit: cover;
}

.calendar-event span {
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-panel {
  display: grid;
  gap: 16px;
}

.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.history-toolbar strong,
.history-toolbar span {
  display: block;
}

.history-toolbar span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.history-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.history-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #e9edf3;
}

.history-card div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.history-card strong {
  font-size: 0.9rem;
}

.history-card a {
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 900;
  text-decoration: none;
}

@media (max-width: 900px) {
  .events-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .controls {
    grid-template-columns: 1fr;
  }

  .viewbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-view {
    grid-template-columns: 1fr;
  }

  .weekday,
  .calendar-day.is-empty {
    display: none;
  }

  .status {
    justify-self: start;
    text-align: left;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .topbar {
    display: grid;
  }

  .jobsoft-logo {
    width: 118px;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .events-grid,
  .history-grid,
  .summary {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

input[type="search"]:focus-visible, select:focus-visible, button:focus-visible {
  outline: 3px solid rgb(219 39 39 / 30%);
  outline-offset: 2px;
}
.view-notice { color: var(--muted); line-height: 1.5; }
.status[data-tone="warning"] { color: #8a5a00; }
.history-card .history-details { display: grid; gap: 5px; }
.history-details span { color: var(--muted); font-size: 0.85rem; }

#searchInput { min-width: 0; }
.source-badge { background: #e8efff !important; color: #174bb3 !important; }
#historyProgress { margin: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.event-meta span { max-width: 100%; overflow-wrap: anywhere; }
.history-toolbar button { flex-shrink: 0; }
.history-toolbar span { line-height: 1.5; }
@media (min-width: 901px) {
  #searchInput { grid-column: 2 / -1; }
}
.event-sessions { border-top: 1px solid var(--line); padding-top: 12px; font-size: 0.88rem; }
.event-sessions summary { cursor: pointer; color: var(--ink); font-weight: 700; }
.event-sessions ul { padding-left: 18px; margin: 12px 0 0; }
.event-sessions li { margin: 10px 0; line-height: 1.5; }
.event-sessions li span { display: block; }
.event-sessions a { color: var(--accent); font-weight: 700; }
.history-card > .event-sessions { margin: 0 10px 12px; }
.history-buttons { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; }
.history-toolbar { align-items: flex-start; }
.history-recognition { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 10px; }
.history-recognition summary { cursor: pointer; font-size: 0.85rem; font-weight: 700; }
.history-recognition button { font-size: 0.84rem; padding: 5px 10px; }
.recognition-note { margin: 0; color: #8a5a00; font-size: 0.82rem; }
.recognized-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.8rem; max-height: 180px; overflow: auto; }
.name-editor form { display: grid; gap: 8px; margin-top: 10px; }
.name-editor input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 6px; min-height: 40px; padding: 8px; font: inherit; }
#namesProgress { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
@media (max-width: 620px) { .history-buttons { flex-direction: column; } }
