:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #151a23;
  --muted: #5b6474;
  --border: #e1e4ea;
  --accent: #d9481a;
  --accent-text: #ffffff;
  --accent-soft: #fdeee7;
  --blue: #2259b8;
  --green: #1d7f47;
  --green-soft: #e5f4eb;
  --amber: #a5650d;
  --violet: #7238b8;
  --violet-soft: #f3ecfc;
  --red: #c02c2c;
  --red-soft: #fdeceb;
  --gray: #6b7381;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --text: #e7eaf0;
    --muted: #9aa3b2;
    --border: #2a303b;
    --accent: #f06a35;
    --accent-text: #ffffff;
    --accent-soft: #3a2117;
    --blue: #7aa7f2;
    --green: #55c487;
    --green-soft: #15301f;
    --amber: #e3a94d;
    --violet: #b893f2;
    --violet-soft: #281d3a;
    --red: #f27f7f;
    --red-soft: #3a1c1c;
    --gray: #8d96a6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-underline-offset: 2px; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; letter-spacing: -0.01em; }
p { margin: 0 0 10px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { margin-bottom: 20px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pad { padding: 0 14px 14px; margin: 0; }

/* Cabecera */

.bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.bar-in {
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.brand em { font-style: normal; font-weight: 500; color: var(--muted); }

.nav { display: flex; flex-wrap: wrap; gap: 2px; }
.nav a { text-decoration: none; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a[aria-current] { background: var(--bg); color: var(--text); font-weight: 600; }

.me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

@media (max-width: 700px) {
  .nav { order: 3; width: 100%; margin: 0 -10px; }
}

.wrap { max-width: 920px; margin: 0 auto; padding: 24px 16px 72px; }

/* Botones y formularios */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); filter: none; }
.btn-danger { background: var(--red); }
.btn-danger-ghost { color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-block { width: 100%; }

button.link { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }

input[type=text], input[type=email], input[type=search], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
input[readonly] { color: var(--muted); }

label, .label { display: block; font-size: 14px; font-weight: 600; }
label > input, label > select, label > textarea { margin-top: 6px; font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }

.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; }
.check input { margin: 4px 0 0; width: 16px; height: 16px; accent-color: var(--accent); }

.stack > * + * { margin-top: 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-form input[type=text] { flex: 1 1 220px; width: auto; }
.row-form > span { flex: 1 1 auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.drop {
  position: relative;
  margin-top: 6px;
  padding: 18px 14px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-weight: 400;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.drop:hover, .drop:focus-within { border-color: var(--accent); color: var(--text); }
.drop input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }

/* Bloques comunes */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-title { font-size: 16px; margin: 0; }
.card + .card { margin-top: 12px; }
.empty, .empty-state { color: var(--muted); }
.empty-state { text-align: center; padding: 40px 16px; }

.flash {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 500;
}
.flash-err { background: var(--red-soft); color: var(--red); }

.notice {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
}

.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.head h1 { margin: 0; }
.head h1 small { margin-left: 6px; font-size: 14px; font-weight: 500; color: var(--muted); }

.back { display: inline-block; margin-bottom: 14px; color: var(--muted); font-size: 14px; text-decoration: none; }
.back:hover { color: var(--text); }

.chip {
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.badge {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  vertical-align: 2px;
}
.badge.urgent { background: var(--red-soft); color: var(--red); }

/* Colores por estado */

.st-recibido { --st: var(--gray); }
.st-estimado { --st: var(--amber); }
.st-aprobado { --st: var(--green); }
.st-planificado { --st: var(--blue); }
.st-esperando { --st: var(--violet); }
.st-hecho { --st: var(--green); }
.st-duplicada, .st-descartada { --st: var(--gray); }

/* Lista de solicitudes */

.search { margin: 14px 0 10px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; padding-bottom: 4px; overflow-x: auto; scrollbar-width: thin; }
.tabs a {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { background: var(--text); border-color: var(--text); color: var(--surface); }
.count { margin-left: 2px; font-size: 12px; font-weight: 700; opacity: .75; }

.tickets {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.tickets li + li { border-top: 1px solid var(--border); }
.tickets .empty { padding: 20px 16px; }
.ticket a { display: block; padding: 12px 16px 12px 14px; border-left: 4px solid var(--st, var(--gray)); text-decoration: none; }
.ticket a:hover { background: var(--bg); }
.row-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.row-top time { flex: none; color: var(--muted); }
.status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--st, var(--muted)); font-weight: 600; }
.row-title { margin: 2px 0 4px; font-size: 16px; }
.row-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.closed { margin-top: 18px; }
.closed > summary { margin-bottom: 10px; color: var(--muted); cursor: pointer; }

/* Ficha de una solicitud */

.t-head .status { font-size: 14px; white-space: normal; }
.t-head h1 { margin: 4px 0 8px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 6px; font-size: 14px; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 20px 0; padding: 0; list-style: none; }
.steps li { padding-top: 6px; border-top: 4px solid var(--border); font-size: 13px; color: var(--muted); }
.steps li.done { border-color: var(--green); }
.steps li.current { border-color: var(--accent); color: var(--text); font-weight: 600; }

.callout { margin: 16px 0; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.callout-wait { background: var(--violet-soft); border-color: var(--violet); }
.callout-title { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.estimate strong { display: block; margin-bottom: 8px; font-size: 30px; line-height: 1.2; }
.scope { margin-bottom: 10px; }

.sec { margin: 30px 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.byline { margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.byline strong { color: var(--text); }

.timeline { margin: 0 0 14px; padding: 0; list-style: none; }
.timeline .cm { margin-bottom: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.timeline .cm.mine { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.timeline .ev { margin: 0 0 10px 8px; padding: 2px 0 2px 14px; border-left: 2px solid var(--border); font-size: 13px; color: var(--muted); }
.timeline .ev time { white-space: nowrap; opacity: .8; }

.files { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.thumb img { display: block; max-width: min(260px, 100%); max-height: 180px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: 6px; }

.manage details, .upload {
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.manage summary, .upload > summary { padding: 12px 14px; font-weight: 600; cursor: pointer; }
.manage details > form, .upload > form { padding: 0 14px 14px; }
.manage > form { margin-bottom: 8px; }
.upload { margin-top: 24px; padding: 0; }

.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop[open] > form { margin-top: 10px; min-width: min(320px, 80vw); }

/* Descargas, documentos, proyectos y equipo */

.kicker { margin-bottom: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.release-main { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.release-info { min-width: 0; flex: 1 1 260px; }
.release-name { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.older { margin-top: 8px; font-size: 14px; }
.older > summary { color: var(--muted); cursor: pointer; }
.older form { margin-top: 10px; }

.plain { margin: 6px 0 0; padding-left: 18px; }

.list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.list > li { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.list > li + li { border-top: 1px solid var(--border); }
.list > li.archived .list-title { color: var(--muted); }
.list-main { min-width: 0; flex: 1; }
.list-title { font-size: 16px; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
a.list-title:hover { text-decoration: underline; }

/* Acceso */

.auth { max-width: 400px; margin: 9vh auto 0; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.auth-logo { display: block; margin-bottom: 14px; }
.auth h1 { font-size: 22px; }
