:root {
  --text: #172b4d;
  --text-subtle: #44546f;
  --text-subtlest: #626f86;
  --list-bg: #f1f2f4;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 1px #091e4240, 0 0 1px #091e424f;
  --primary: #0c66e4;
  --primary-hover: #0055cc;
  --danger: #c9372c;
  --success: #1f845a;
  --warning-bg: #f5cd47;
  --overlay: #091e427a;
  --dialog-bg: #ffffff;
  --input-border: #8590a2;
  --chip-bg: #091e420f;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Ubuntu, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --text: #b6c2cf; --text-subtle: #9fadbc; --text-subtlest: #8c9bab;
    --list-bg: #101204; --card-bg: #22272b; --card-shadow: 0 1px 1px #03040480, 0 0 1px #03040480;
    --dialog-bg: #323940; --input-border: #738496; --chip-bg: #a1bdd914; --primary: #579dff; --primary-hover: #85b8ff;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .btn--primary { color: #1d2125; }
}
:root[data-theme="dark"] {
  --text: #b6c2cf; --text-subtle: #9fadbc; --text-subtlest: #8c9bab;
  --list-bg: #101204; --card-bg: #22272b; --card-shadow: 0 1px 1px #03040480, 0 0 1px #03040480;
  --dialog-bg: #323940; --input-border: #738496; --chip-bg: #a1bdd914; --primary: #579dff; --primary-hover: #85b8ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: 14px; line-height: 20px; color: var(--text);
  background: #0079bf; display: flex; flex-direction: column; overflow: hidden;
}
.bg { position: fixed; inset: 0; z-index: -1; background: linear-gradient(135deg, #0c66e4 0%, #6e5dc6 100%); background-size: cover; background-position: center; }
svg { width: 16px; height: 16px; fill: currentColor; flex: none; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: #0c1f3fb8; backdrop-filter: blur(6px); color: #fff;
}
.topbar__left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.board-name { font-size: 18px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.updated { font-size: 12px; opacity: .85; white-space: nowrap; }
.topbar__right { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 6px; background: #ffffff33; border-radius: 6px; padding: 0 8px; height: 32px; }
.search input { background: none; border: 0; color: #fff; outline: none; width: 160px; font: inherit; }
.search input::placeholder { color: #ffffffcc; }
.search:focus-within { background: #fff; color: var(--text); }
.search:focus-within input { color: #172b4d; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px;
  border: 0; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--primary:disabled { opacity: .6; cursor: progress; }
.btn--ghost { background: #ffffff33; color: #fff; }
.btn--ghost:hover { background: #ffffff4d; }
.btn--ghost-dark { background: var(--chip-bg); color: var(--text); }
.btn--ghost-dark:hover { filter: brightness(.95); }
.icon-btn { border: 0; background: none; font-size: 24px; line-height: 1; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--text-subtle); }
.icon-btn:hover { background: var(--chip-bg); }
.icon-btn--light { color: #fff; position: absolute; top: 12px; right: 12px; }

/* ---------- Tablero ---------- */
.board {
  flex: 1; display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px 16px;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scroll-padding-inline: 16px;
}
.list {
  flex: 0 0 272px; max-height: 100%; display: flex; flex-direction: column;
  background: var(--list-bg); border-radius: var(--radius); box-shadow: var(--card-shadow); scroll-snap-align: start;
}
.list__head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 14px; }
.list__title { font-weight: 600; margin: 0; font-size: 14px; }
.list__count { font-size: 12px; color: var(--text-subtlest); background: var(--chip-bg); border-radius: 10px; padding: 0 7px; }
.list__cards { display: flex; flex-direction: column; gap: 8px; padding: 2px 8px 8px; overflow-y: auto; min-height: 8px; }
.list--solicitudes:not([data-color]) { outline: 2px solid #f5cd47; outline-offset: -2px; }
/* Colores de columna de Trello */
.list[data-color="green"] { --list-bg: #baf3db; }
.list[data-color="yellow"] { --list-bg: #f8e6a0; }
.list[data-color="orange"] { --list-bg: #fedec8; }
.list[data-color="red"] { --list-bg: #ffd5d2; }
.list[data-color="purple"] { --list-bg: #dfd8fd; }
.list[data-color="blue"] { --list-bg: #cce0ff; }
.list[data-color="sky"] { --list-bg: #c6edfb; }
.list[data-color="lime"] { --list-bg: #d3f1a7; }
.list[data-color="pink"] { --list-bg: #fdd0ec; }
.list[data-color="black"] { --list-bg: #dcdfe4; }
.list[data-color] .list__count { background: #ffffff8c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .list[data-color="green"] { --list-bg: #164b35; }
  :root:not([data-theme="light"]) .list[data-color="yellow"] { --list-bg: #533f04; }
  :root:not([data-theme="light"]) .list[data-color="orange"] { --list-bg: #702e00; }
  :root:not([data-theme="light"]) .list[data-color="red"] { --list-bg: #5d1f1a; }
  :root:not([data-theme="light"]) .list[data-color="purple"] { --list-bg: #352c63; }
  :root:not([data-theme="light"]) .list[data-color="blue"] { --list-bg: #09326c; }
  :root:not([data-theme="light"]) .list[data-color="sky"] { --list-bg: #164555; }
  :root:not([data-theme="light"]) .list[data-color="lime"] { --list-bg: #37471f; }
  :root:not([data-theme="light"]) .list[data-color="pink"] { --list-bg: #50253f; }
  :root:not([data-theme="light"]) .list[data-color="black"] { --list-bg: #454f59; }
  :root:not([data-theme="light"]) .list[data-color] .list__count { background: #0000004d; }
}
.list__add {
  margin: 0 8px 8px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px;
  border: 0; background: none; color: var(--text-subtle); font: inherit; font-weight: 500; cursor: pointer; text-align: left;
}
.list__add:hover { background: var(--chip-bg); color: var(--text); }
.list__empty { color: var(--text-subtlest); font-size: 12px; text-align: center; padding: 8px; }

.card {
  background: var(--card-bg); border-radius: 8px; box-shadow: var(--card-shadow); cursor: pointer; overflow: hidden;
  border: 0; padding: 0; text-align: left; font: inherit; color: inherit; width: 100%; flex-shrink: 0;
}
.card:hover { outline: 2px solid var(--primary); }
.card:focus-visible { outline: 2px solid var(--primary); }
.card__cover { display: block; width: 100%; max-height: 260px; object-fit: cover; background: var(--chip-bg); }
.card__cover-color { height: 32px; }
.card__body { padding: 8px 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.card__labels { display: flex; flex-wrap: wrap; gap: 4px; }
.card__name { word-break: break-word; }
.card__badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--text-subtle); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 4px; }
.badge svg { width: 14px; height: 14px; }
.badge--due { padding: 0 4px; border-radius: 3px; }
.badge--done { background: #1f845a; color: #fff; }
.badge--late { background: #c9372c; color: #fff; }
.badge--soon { background: #f5cd47; color: #172b4d; }
.card__members { margin-left: auto; display: flex; }
.card.is-hidden { display: none; }

.label { display: inline-flex; align-items: center; min-width: 40px; height: 16px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; line-height: 16px; }
.label--big { height: 32px; line-height: 32px; padding: 0 12px; font-size: 14px; }

.avatar { width: 24px; height: 24px; border-radius: 50%; background: #dfe1e6; color: #172b4d; font-size: 11px; font-weight: 700; display: grid; place-items: center; overflow: hidden; margin-left: -4px; border: 2px solid var(--card-bg); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.skeleton-list { flex: 0 0 272px; height: 220px; border-radius: var(--radius); background: #ffffff40; animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- Diálogos ---------- */
.dialog { border: 0; border-radius: 12px; padding: 0; background: var(--dialog-bg); color: var(--text); box-shadow: 0 8px 24px #091e4240; }
.dialog::backdrop, .lightbox::backdrop { background: var(--overlay); }
.dialog--card { width: min(768px, calc(100vw - 32px)); max-height: calc(100vh - 64px); }
.dialog--form { width: min(560px, calc(100vw - 32px)); }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog__head h2 { margin: 0; font-size: 20px; line-height: 28px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.detail { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 20px; }
.detail__cover { width: 100%; max-height: 320px; object-fit: contain; background: #091e420f; display: block; cursor: zoom-in; }
.detail__cover-color { height: 96px; }
.detail__title { margin: 0; font-size: 20px; line-height: 28px; word-break: break-word; }
.detail__in { color: var(--text-subtle); font-size: 13px; margin-top: 2px; }
.detail__meta { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.meta h4, .section h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--text-subtle); text-transform: none; }
.section h3 { font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.meta__row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { background: var(--chip-bg); border-radius: 4px; padding: 6px 10px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }

.md { word-break: break-word; }
.md p { margin: 0 0 8px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md h1, .md h2, .md h3 { margin: 12px 0 6px; font-size: 16px; }
.md img { max-width: 100%; border-radius: 6px; cursor: zoom-in; display: block; margin: 6px 0; }
.md a { color: var(--primary); }
.md code { background: var(--chip-bg); padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.md pre { background: var(--chip-bg); padding: 10px; border-radius: 6px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--chip-bg); margin: 12px 0; }
.file-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip-bg); border-radius: 4px; padding: 1px 6px; font-size: 13px; }

.atts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-subtle); min-width: 0; }
.att img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; background: var(--chip-bg); cursor: zoom-in; }
.att__file { height: 100px; border-radius: 6px; background: var(--chip-bg); display: grid; place-items: center; font-weight: 700; color: var(--text-subtle); text-transform: uppercase; }
.att__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att a { color: var(--primary); }

.checklist { margin-bottom: 14px; }
.progress { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-subtle); margin-bottom: 6px; }
.progress__bar { flex: 1; height: 8px; border-radius: 4px; background: var(--chip-bg); overflow: hidden; }
.progress__fill { height: 100%; background: var(--primary); }
.progress__fill.is-full { background: var(--success); }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.check__box { width: 16px; height: 16px; border-radius: 3px; border: 2px solid var(--input-border); flex: none; margin-top: 2px; display: grid; place-items: center; }
.check.is-done .check__box { background: var(--primary); border-color: var(--primary); }
.check.is-done .check__box::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check.is-done .check__text { text-decoration: line-through; color: var(--text-subtle); }

.comment { display: flex; gap: 8px; margin-bottom: 12px; }
.comment .avatar { width: 32px; height: 32px; margin: 0; }
.comment__head { font-size: 12px; color: var(--text-subtle); }
.comment__head strong { color: var(--text); font-size: 14px; margin-right: 6px; }
.comment__body { background: var(--card-bg); box-shadow: var(--card-shadow); border-radius: 8px; padding: 8px 12px; margin-top: 4px; }

/* ---------- Formulario ---------- */
#request-form { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
#request-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-subtle); }
#request-form input, #request-form select, #request-form textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--card-bg);
  border: 1px solid var(--input-border); border-radius: 4px; padding: 8px 10px; width: 100%;
}
#request-form textarea { resize: vertical; }
#request-form :is(input, select, textarea):focus { outline: 2px solid var(--primary); border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.muted { color: var(--text-subtle); margin: 0; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-error { color: var(--danger); margin: 0; font-weight: 500; }
.turnstile:empty { display: none; }

/* ---------- Visor ---------- */
.lightbox { border: 0; background: transparent; padding: 0; max-width: 100vw; max-height: 100vh; }
.lightbox img { max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); display: block; border-radius: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f845a; color: #fff;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: 0 8px 24px #091e4240; z-index: 10; max-width: calc(100vw - 32px);
}
.toast.is-error { background: var(--danger); }

.error-box { margin: auto; background: var(--dialog-bg); color: var(--text); padding: 20px 24px; border-radius: 12px; max-width: 420px; }

@media (max-width: 640px) {
  .topbar { padding: 8px 16px; }
  .topbar__right { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
  .hide-sm { display: none; }
  .updated { display: none; }
  .board { padding: 12px 16px; }
  .list, .skeleton-list { flex-basis: min(85vw, 300px); }
  .grid2 { grid-template-columns: 1fr; }
  .detail { padding: 16px; }
}
