:root {
  --navy: #16273e;
  --navy-2: #22385a;
  --ink: #1b2330;
  --muted: #6b7482;
  --line: #e4e7ec;
  --bg: #f5f6f8;
  --card: #fff;
  --accent: #2f6fed;
  --green: #1e8e4f; --green-bg: #e6f4ea;
  --amber: #a86300; --amber-bg: #fff3dc;
  --red: #c02929; --red-bg: #fde8e8;
  --radius: 10px;
  --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; height: 100%; }
body { font: 14px/1.45 Inter, system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); }
.hidden { display: none !important; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; color: var(--navy); letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); min-height: 1em; }

/* ---------- botones / inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8f9fb; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--ink); width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 111, 237, .25); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 12px; } .row > * { flex: 1; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--navy); }
.login-card { background: #fff; padding: 36px; border-radius: 14px; width: min(360px, 92vw); display: grid; gap: 12px; text-align: center; }
.login-logo { height: 46px; margin: 0 auto; }
.login-card h1 { letter-spacing: .3em; font-size: 16px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--navy); color: #cfd6e2; display: flex; flex-direction: column; padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; }
.brand img { height: 26px; }
.brand span { color: #fff; font-weight: 700; letter-spacing: .28em; font-size: 12px; border-left: 1px solid rgba(255,255,255,.25); padding-left: 10px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #cfd6e2; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.sidebar nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.sidebar nav a b { margin-left: auto; font-size: 11px; font-weight: 600; background: rgba(255,255,255,.14); padding: 1px 7px; border-radius: 10px; }
.sidebar nav a b:empty { display: none; }
.sidebar nav a b.alert { background: #e8a33a; color: var(--navy); }
.sync-box { margin-top: auto; background: rgba(255,255,255,.06); border-radius: 10px; padding: 12px; font-size: 12px; display: grid; gap: 8px; }
.sync-box .btn { justify-content: center; background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.sync-box .btn:hover { background: rgba(255,255,255,.18); }
.sync-box .err { color: #ffb4b4; }
.logout { color: #9fb0c8; margin-top: 12px; font-size: 12px; }
.view { flex: 1; min-width: 0; padding: 24px 28px 90px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 10px; cursor: pointer; color: var(--muted); font: inherit; }
.seg button.on { background: var(--navy); color: #fff; }
.seg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; display: block; }

/* ---------- grid de propiedades ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; position: relative; transition: box-shadow .15s, border-color .15s; }
.pcard:hover { box-shadow: 0 6px 18px rgba(16,24,40,.1); }
.pcard.sel { border-color: var(--navy); box-shadow: 0 0 0 2px var(--navy); }
.pcard.removed { opacity: .6; }
.pcard .img { aspect-ratio: 16/10; background: #dfe3e8 center/cover no-repeat; position: relative; }
.pcard .chk { position: absolute; top: 10px; left: 10px; background: #fff; border-radius: 6px; padding: 5px; display: flex; box-shadow: var(--shadow); }
.pcard .media { position: absolute; bottom: 8px; left: 8px; display: flex; gap: 4px; }
.pcard .media span { background: rgba(10,18,30,.72); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 10px; }
.pcard .body { padding: 12px 14px 14px; }
.pcard .ref { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.pcard .title { font-weight: 600; color: var(--navy); margin: 2px 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }
.pcard .price { font-weight: 700; font-size: 16px; }
.pcard .facts { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }
.pcard .foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: #eef1f5; color: var(--navy); white-space: nowrap; }
.chip.free { background: var(--green-bg); color: var(--green); }
.chip.limited { background: var(--amber-bg); color: var(--amber); }
.chip.block { background: var(--red-bg); color: var(--red); }
.chip.none { background: #f1f2f4; color: var(--muted); }
.chip.out { background: var(--red-bg); color: var(--red); }

/* ---------- tabla ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
tbody tr.click { cursor: pointer; }
td .thumb { width: 64px; height: 42px; border-radius: 6px; background: #dfe3e8 center/cover; }

/* ---------- barra de selección ---------- */
.selbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: #fff; border-radius: 12px; padding: 10px 12px 10px 18px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 30; }
.selbar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.selbar .btn:hover { background: rgba(255,255,255,.22); }
.selbar .btn.primary { background: #fff; color: var(--navy); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 20, 32, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: min(620px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; max-height: 90vh; }
.modal.wide { width: min(1100px, 100%); }
.modal header { padding: 18px 22px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; }
.modal header .x { margin-left: auto; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal .content { padding: 16px 22px; overflow: auto; }
.modal footer { padding: 12px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.modal footer .left { margin-right: auto; display: flex; align-items: center; gap: 6px; }

/* ventana compartir */
.pick-list { border: 1px solid var(--line); border-radius: 10px; max-height: 48vh; overflow: auto; }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: #fafbfc; }
.pick.changed { background: #f3f7ff; }
.pick .who { flex: 1; min-width: 0; }
.pick .who b { display: block; }
.pick .who span { font-size: 12px; color: var(--muted); }
.pick .state { font-size: 11px; font-weight: 600; }
.pick .state.add { color: var(--green); } .pick .state.del { color: var(--red); }
.pick .avatar { width: 32px; height: 32px; border-radius: 50%; background: #e8ecf2; color: var(--navy); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.pick.inactive { opacity: .55; }
.pick-tools { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.pick-tools input { flex: 1; }
.sel-summary { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }

/* restricciones */
.rgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.toggle-row .mixed { font-size: 11px; color: var(--amber); font-weight: 600; }
.switch { position: relative; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #cfd5de; border-radius: 22px; transition: .15s; cursor: pointer; }
.switch i::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::before { transform: translateX(16px); }
.switch.mixed input + i, .switch.mixed input:checked + i { background: repeating-linear-gradient(45deg, #e8c27a 0 5px, #f4dcae 5px 10px); }
.portal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.portal-chips label { border: 1px solid var(--line); border-radius: 16px; padding: 4px 10px; cursor: pointer; font-size: 12px; display: flex; gap: 5px; align-items: center; }
.portal-chips label:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.portal-chips input { display: none; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin: 16px 0 6px; }

/* ---------- ficha ---------- */
.detail-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head .price { font-size: 24px; font-weight: 700; color: var(--navy); }
.gallery { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 180px 180px; gap: 6px; border-radius: 12px; overflow: hidden; margin-bottom: 18px; }
.gallery div { background: #dfe3e8 center/cover; cursor: zoom-in; position: relative; }
.gallery div:first-child { grid-row: span 2; }
.gallery .more { position: absolute; inset: 0; background: rgba(10,18,30,.55); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 16px; }
.detail-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel h2 { margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .btn { margin-left: auto; }
.facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.facts-grid div span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts-grid div b { font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--navy); border-color: var(--navy); font-weight: 600; }
.desc { white-space: pre-wrap; }
.features { display: flex; flex-wrap: wrap; gap: 6px; }
.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.media-list img { width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #fff; }
.embed { aspect-ratio: 16/9; width: 100%; border: 0; border-radius: 8px; background: #000; }
.rlist { margin: 0; padding-left: 18px; }
.rlist li { margin-bottom: 4px; }
.collab-list { display: grid; gap: 6px; }
.collab-list div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.timeline { display: grid; gap: 8px; font-size: 13px; }
.timeline div { display: flex; gap: 10px; }
.timeline time { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 92px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(5,10,18,.94); z-index: 80; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 6px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.12); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.lightbox .prev { left: 20px; } .lightbox .next { right: 20px; } .lightbox .close { top: 20px; right: 20px; }
.lightbox .count { position: absolute; bottom: 20px; color: #fff; font-size: 13px; }

/* notificaciones */
.status { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.status.pending { background: var(--amber-bg); color: var(--amber); }
.status.sent { background: var(--green-bg); color: var(--green); }
.status.simulated { background: #e9eefb; color: #3a57a8; }
.status.failed { background: var(--red-bg); color: var(--red); }
.status.discarded { background: #f1f2f4; color: var(--muted); }
iframe.preview { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.notice { background: #fff8e6; border: 1px solid #f3d99b; color: #6b4a00; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.notice.info { background: #eef4ff; border-color: #c9dafc; color: #1f3f86; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 100; max-width: 420px; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--red); }

@media (max-width: 1000px) { .detail-cols { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 6px; }
  .brand { padding: 0 8px 0 0; }
  .sidebar nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .sidebar nav a { white-space: nowrap; }
  .sync-box, .logout { display: none; }
  .view { padding: 16px 16px 90px; }
  .gallery { grid-template-columns: 1fr 1fr; grid-template-rows: 200px 100px; }
  .gallery div:first-child { grid-column: span 2; grid-row: auto; }
  .gallery div:nth-child(n+4) { display: none; }
  .rgrid { grid-template-columns: 1fr; }
  .selbar { left: 16px; right: 16px; transform: none; flex-wrap: wrap; }
}
