:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e3e6ec;
  --brand: #2f6fde; --brand-ink: #fff; --ok: #14804a; --ok-bg: #e5f6ec; --warn: #a15c00; --warn-bg: #fff3dc;
  --bad: #b42318; --bad-bg: #fde8e7; --info: #2f6fde; --info-bg: #e7efff; --gray-bg: #eef0f3;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* Barra superior */
.top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 18px; margin-right: 8px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { padding: 8px 14px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.nav a.on { background: var(--info-bg); color: var(--brand); }
.top-right { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.top-right select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid2, .grid-detail { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--gray-bg); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(.95); }
.btn.big { padding: 14px 24px; font-size: 17px; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 4px 6px; }
.btn.link.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd4dc; border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info-bg); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 12px; }

/* Etiquetas de estado */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.b-pending { background: var(--warn-bg); color: var(--warn); }
.b-in_progress { background: var(--info-bg); color: var(--info); }
.b-clarification { background: var(--bad-bg); color: var(--bad); }
.b-quoted { background: var(--ok-bg); color: var(--ok); }
.b-expired, .b-cancelled { background: var(--gray-bg); color: var(--muted); }
.b-stage { background: var(--gray-bg); color: var(--ink); }

/* Tarjetas de resumen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow); }
.stat:hover { border-color: var(--brand); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 14px; }

/* Pestañas */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 500; }
.tabs a.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Lista de items */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.it { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); box-shadow: var(--shadow); }
.it:hover { border-color: var(--brand); }
.it .ph { aspect-ratio: 4/3; background: #fafafa; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); }
.it .ph img { max-width: 100%; max-height: 100%; object-fit: contain; }
.it .bd { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.it .ref { font-size: 12px; color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.it .tt { font-weight: 700; }
.times { line-height: 1.4; margin-top: 2px; }
.times .ago { color: var(--warn); }
.prices { font-size: 13px; color: var(--ok); font-weight: 600; }

/* Detalle */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.gallery a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fafafa; aspect-ratio: 1; }
.gallery img { width: 100%; height: 100%; object-fit: contain; }
.hero { display: block; border: 1px solid var(--line); border-radius: 10px; background: #fafafa; text-align: center; margin-bottom: 8px; }
.hero img { max-width: 100%; max-height: 420px; object-fit: contain; display: block; margin: 0 auto; }
dl.specs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.specs dt { color: var(--muted); font-size: 14px; }
dl.specs dd { margin: 0; font-weight: 500; white-space: pre-wrap; }
.private { border-left: 4px solid var(--warn); }

table.t { width: 100%; border-collapse: collapse; font-size: 15px; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
table.t th { font-size: 13px; color: var(--muted); font-weight: 600; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.qsec { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 4px; margin-bottom: 14px; background: #fcfcfd; }
.qsec h3 { font-size: 16px; margin-bottom: 10px; }
.qsec textarea { margin-bottom: 10px; text-align: left; }
.qform input { text-align: right; font-variant-numeric: tabular-nums; }
.qform td.qtycell input { width: 110px; }
.up { color: var(--bad); font-size: 12px; } .down { color: var(--ok); font-size: 12px; }
.version { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.version.latest { border-color: var(--ok); }
.lock { font-size: 13px; color: var(--muted); }
.hash { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); }

/* Mensajes */
.msgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; max-height: 520px; overflow: auto; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--gray-bg); max-width: 85%; }
.msg.me { align-self: flex-end; background: var(--info-bg); }
.msg.q { border: 2px solid var(--bad); }
.msg .who { font-size: 12px; color: var(--muted); }
.msg .gallery { margin-top: 6px; }

/* Zona de fotos */
.drop { border: 2px dashed #c3cad5; border-radius: 10px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; background: #fbfcfd; }
.drop.active, .drop:focus { border-color: var(--brand); background: var(--info-bg); outline: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbs .th { position: relative; width: 90px; height: 90px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.thumbs .th img { width: 100%; height: 100%; object-fit: contain; }
.thumbs .th button { position: absolute; top: 2px; right: 2px; border: 0; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.itemform { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fcfcfd; }
.itemform.focus { border-color: var(--brand); }

/* Seguimiento */
.track { display: grid; grid-template-columns: 70px 1fr 220px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.track img { width: 70px; height: 70px; object-fit: contain; background: #fafafa; border-radius: 8px; border: 1px solid var(--line); }
.bar { height: 10px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.bar.late > i { background: var(--bad); }
@media (max-width: 640px) { .track { grid-template-columns: 56px 1fr; } .track .tb { grid-column: 1 / -1; } }
.steps { display: flex; gap: 4px; margin: 8px 0 4px; }
.steps span { flex: 1; height: 6px; border-radius: 3px; background: var(--gray-bg); }
.steps span.done { background: var(--ok); }

.events { list-style: none; padding: 0; margin: 0; }
.events li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.events li .when { color: var(--muted); min-width: 120px; }

.login { max-width: 380px; margin: 10vh auto; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }
.toast.bad { background: var(--bad); }
