/* =====================================================================
   portal.css — Orbit · portal de hubs (misma base visual de los hubs)
   ===================================================================== */
:root {
  --bg: #f6f5f2; --surface: #fcfcfb; --surface-2: #f3f2ee; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --line: #e6e5df; --hairline: rgba(11, 11, 11, 0.08); --baseline: #c3c2b7;
  --accent: #a8475f; --accent-ink: #8d3650; --accent-soft: #f7e9ee;
  --good: #006300; --good-soft: #e6f4e6; --bad: #b02f2f; --bad-soft: #fbe9e9; --warn: #8a5a00; --warn-soft: #fff3d6; --info: #1c5cab; --info-soft: #e4eefb;
  --radius: 14px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 8px 24px -16px rgba(11, 11, 11, 0.12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; line-height: 1.45; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; } h2 { font-size: 15px; } h3 { font-size: 13px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
b { font-weight: 600; } p { margin: 0; }
small { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Header ---------- */
.portal-head { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 32px; background: rgba(246, 245, 242, 0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--hairline); }
.brandmark { display: flex; align-items: center; gap: 12px; }
.mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent) 0%, #e28aa3 100%); flex: none; position: relative; }
.mark::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); opacity: 0.9; }
.mark.hub { background: linear-gradient(135deg, var(--c) 0%, color-mix(in oklab, var(--c) 55%, white) 100%); }
.mark.lg { width: 48px; height: 48px; border-radius: 14px; }
.mark.lg::after { inset: 13px; }
.brand-app { font-weight: 600; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.head-right { display: flex; align-items: center; gap: 10px; }
.tabs { display: inline-flex; background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs a, .tabs button { text-decoration: none; }
.tabs a, .tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 500; color: var(--ink-2); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.tabs a.on, .tabs button.on { background: var(--ink); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--hairline); padding: 5px 12px 5px 6px; border-radius: 999px; }
.user-chip span:last-child { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-chip b { font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 11px; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ---------- Layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 36px 32px 64px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card.note { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); box-shadow: none; }
.card.tight { padding: 14px 16px; }

/* ---------- Botones / chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--hairline); background: var(--surface); font-weight: 500; font-size: 13px; transition: background .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #262626; }
.btn.primary:disabled { opacity: .35; cursor: default; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.chip.sm { padding: 1px 7px; font-size: 11px; }
.chip.admin { background: var(--accent-soft); color: var(--accent-ink); }
.chip.manager { background: var(--info-soft); color: var(--info); }
.chip.editor { background: var(--surface-2); color: var(--ink-2); }
.chip.off { background: var(--bad-soft); color: var(--bad); }
.chip.good { background: var(--good-soft); color: var(--good); }

/* ---------- Tarjetas de hubs ---------- */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.hub-card { --c: var(--accent); display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.hub-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.hub-card.enabled:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(11,11,11,.04), 0 16px 32px -18px rgba(11,11,11,.22); }
.hub-card.locked { opacity: .75; }
.hub-card .hc-head { display: flex; align-items: center; gap: 12px; }
.hub-card .hc-head > div { display: flex; flex-direction: column; line-height: 1.25; }
.hub-card .hc-head b { font-size: 16px; }
.hub-card p { color: var(--ink-2); font-size: 13px; line-height: 1.5; flex: 1; }
.hub-card .hc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hub-card.soon { border-style: dashed; box-shadow: none; background: transparent; }

/* ---------- Tabla ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .c { text-align: center; }
.table tbody tr:hover td { background: var(--surface-2); }
.who { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.who > div { display: flex; flex-direction: column; line-height: 1.25; }
.inline-select { font: inherit; font-size: 12px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); }
.inline-select.admin { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.inline-select.manager { border-color: #9dbdea; color: var(--info); background: var(--info-soft); }
.inline-select.editor { color: var(--ink-2); }
.inline-select.none { color: var(--muted); }
.switch { position: relative; width: 34px; height: 20px; border-radius: 999px; background: var(--baseline); border: 0; padding: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: #2f9e44; }
.switch.on::after { left: 16px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
tr:hover .actions { opacity: 1; }

/* ---------- Login ---------- */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #f5e3e9 0%, transparent 60%), radial-gradient(900px 500px at 100% 100%, #e9eef7 0%, transparent 55%), var(--bg); }
.login-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--hairline); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin-top: 10px; }
.user-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; max-height: 300px; overflow-y: auto; }
.user-opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--hairline); background: var(--surface); transition: border-color .15s, background .15s; }
.user-opt:hover { background: var(--surface-2); }
.user-opt.active { border-color: var(--ink); background: var(--surface-2); }
.user-opt > span:nth-child(2) { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.user-opt .hubs { display: flex; gap: 4px; flex-wrap: nowrap; }
.pbadge { --c: #888; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 9px; font-weight: 700; color: color-mix(in oklab, var(--c) 65%, black); background: color-mix(in oklab, var(--c) 18%, white); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field input, .field select { font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); width: 100%; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field.full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); }
.hint.center { text-align: center; }
.error { color: var(--bad); font-size: 13px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 11, 11, .35); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; box-shadow: 0 24px 64px -24px rgba(0,0,0,.4); }
.modal-head { padding: 18px 22px 12px; display: flex; align-items: center; gap: 12px; }
.modal-head h2 { font-size: 17px; flex: 1; }
.modal-body { padding: 4px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 12px 22px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; justify-content: flex-end; }
.close-x { border: 0; background: var(--surface-2); width: 30px; height: 30px; border-radius: 8px; font-size: 16px; line-height: 1; color: var(--ink-2); }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 100; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
pre.code { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 12px; overflow-x: auto; margin: 0; }

@media (max-width: 700px) { main, .portal-head { padding-left: 16px; padding-right: 16px; } .form-grid { grid-template-columns: 1fr; } .user-chip span:last-child { display: none; } }

/* ---------- Usuarios y permisos ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink-2); }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips button .cnt { font-size: 11px; opacity: .7; }
.select { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.select select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface); color: var(--ink); }
.search { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--hairline); background: var(--surface); border-radius: 9px; padding: 0 10px; color: var(--muted); }
.search input { border: 0; background: none; padding: 8px 0; font: inherit; outline: none; width: 240px; color: var(--ink); }
.pbadge.sm { width: 26px; height: 26px; font-size: 10px; border-radius: 7px; position: relative; }
.pbadge.xs { width: 20px; height: 20px; font-size: 8px; border-radius: 5px; }
.pbadge.off { opacity: .28; filter: grayscale(1); }
.pbadge i { position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 8px; font-style: normal; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.people { display: flex; flex-direction: column; }
.person-row { display: grid; grid-template-columns: auto minmax(180px, 1.4fr) auto 1fr auto; align-items: center; gap: 14px; padding: 12px 6px; border-top: 1px solid var(--hairline); cursor: pointer; border-radius: 10px; transition: background .12s; }
.person-row:first-child { border-top: 0; }
.person-row:hover, .person-row:focus-visible { background: var(--surface-2); outline: none; }
.person-row.inactive { opacity: .55; }
.person-main { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.person-main b, .person-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.person-hubs { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.person-go { color: var(--baseline); font-size: 20px; line-height: 1; padding: 0 4px; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.access-row:first-of-type { border-top: 0; }
.access-row > div:first-child { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.access-row > div.row { flex-direction: row; align-items: center; }
.access-row small { line-height: 1.3; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-weight: 500; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.seg button.on { background: var(--ink); color: #fff; }
.seg.sm button { padding: 4px 10px; font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.fieldset-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.swatch { position: relative; width: 28px; height: 28px; border-radius: 50%; background: var(--c); cursor: pointer; display: inline-block; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch i { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent; }
.swatch input:checked + i { border-color: var(--ink); }
.drawer-bg { position: fixed; inset: 0; background: rgba(11, 11, 11, .32); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: -8px 0 32px -12px rgba(0,0,0,.25); z-index: 51; display: flex; flex-direction: column; animation: slideIn .22s ease; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 12px; }
.drawer-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.drawer-head h2 { font-size: 17px; }
.drawer-body { padding: 20px 22px 32px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 22px; }
.drawer-foot { padding: 12px 22px; border-top: 1px solid var(--hairline); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 700px) { .person-row { grid-template-columns: auto 1fr auto; } .person-tags, .person-go { display: none; } .person-hubs { grid-column: 1 / -1; justify-content: flex-start; } .search input { width: 160px; } .access-row .seg { width: 100%; } .seg.sm button { flex: 1; padding: 6px 4px; } }
