/* El portal de informes. Paleta neutra; el azul marino de garden.json
   (visualization/themes/) solo marca lo activo, y el dorado, el favorito. */
:root {
  --ink: #252423; --muted: #6B6862; --line: #E6E4E0; --bg: #F4F4F2;
  --brand: #003850; --accent: #10739F; --gold: #D0A060; --error: #C0392B;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.4 "Segoe UI", system-ui, sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
form { margin: 0; }
[hidden] { display: none !important; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); }
.icon-button:hover { background: var(--bg); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: #DCE7EE; color: var(--brand); font-size: 12px; font-weight: 600; flex: none; }
.button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px; text-align: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--brand); font-weight: 600; }
.button.primary { border: 0; background: var(--brand); color: #fff; }
.button:hover { filter: brightness(.96); }
.error { background: #FBEAE8; color: var(--error); border-radius: 8px; padding: 10px 12px; text-align: left; }

/* Login */
.login { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 40px 36px; text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .06); }
.login-logo { width: 96px; }
.login-card h1 { font-size: 20px; font-weight: 600; margin: 16px 0 4px; color: var(--brand); }
.login-card > .muted { margin: 0 0 28px; }
.ms-logo { display: grid; grid-template-columns: 8px 8px; gap: 2px; }
.ms-logo i { width: 8px; height: 8px; }
.ms-logo i:nth-child(1) { background: #F25022; } .ms-logo i:nth-child(2) { background: #7FBA00; }
.ms-logo i:nth-child(3) { background: #00A4EF; } .ms-logo i:nth-child(4) { background: #FFB900; }
.separator { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: 12px; }
.separator::before, .separator::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.field { display: block; margin-bottom: 14px; text-align: left; }
.field span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.field input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: #FAFAF9; }
.login p.small { margin-top: 18px; }

/* Marco: menú lateral y barra superior */
.app { display: flex; height: 100%; }
.side { width: 232px; flex: none; display: flex; flex-direction: column; padding: 12px 10px;
  background: #fff; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; margin-bottom: 14px; }
.brand img { width: 32px; }
.brand .label { flex: 1; font-weight: 600; color: var(--brand); }
nav a { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; margin-bottom: 4px;
  border-radius: 8px; color: var(--muted); }
nav a:hover { background: var(--bg); }
nav a.active { background: var(--brand); color: #fff; }
.side-foot { margin-top: auto; padding: 8px 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.folded .side { width: 64px; }
.folded .side .label { display: none; }
.folded .brand { justify-content: center; padding: 0; }
.folded nav a { justify-content: center; padding: 0; }
.folded .fold svg { transform: rotate(180deg); }
.folded .brand { flex-direction: column; height: auto; gap: 8px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { flex: none; display: flex; align-items: center; gap: 10px; height: 60px; padding: 0 20px;
  background: #fff; border-bottom: 1px solid var(--line); }
.top .menu, .backdrop { display: none; }
.search { display: flex; align-items: center; gap: 8px; width: 340px; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
.search:focus-within, .select:focus-within { border-color: var(--accent); }
.select { position: relative; display: flex; flex-direction: column; justify-content: center; width: 200px; height: 40px;
  padding: 0 32px 0 12px; border: 1px solid var(--line); border-radius: 8px; }
.select span { color: var(--muted); font-size: 10px; line-height: 1; }
.select select { appearance: none; border: 0; outline: 0; background: none; padding: 0; }
.select .i { position: absolute; right: 10px; top: 11px; color: var(--muted); pointer-events: none; }
.content { flex: 1; overflow: auto; padding: 16px 20px 24px; }

/* Portada */
.tools { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.views { display: flex; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.views button { display: grid; place-items: center; width: 34px; height: 30px; border-radius: 6px; color: var(--muted); }
.views button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.panel { background: #fff; border-radius: 12px; padding: 20px 22px 26px; box-shadow: 0 1px 2px rgba(0, 0, 0, .03); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding-bottom: 12px; border-bottom: 1px solid #D5D9DE; }
.panel-head h1 { margin: 0; font-size: 15px; font-weight: 600; }
.count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.group h2 { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; color: var(--muted); font-size: 12px; font-weight: 600; }
.group h2::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.section-name { margin: 24px 0 0; color: var(--brand); font-size: 14px; font-weight: 600; }
.technical { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.empty { color: var(--muted); margin: 18px 0 0; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.item { position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "chip name" "star open";
  align-items: center; row-gap: 12px; column-gap: 10px; padding: 14px 16px; border-radius: 10px; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08); transition: box-shadow .15s; }
.item:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.chip { grid-area: chip; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: #EEF0F2; color: #6B7785; }
.chip .i { width: 16px; height: 16px; }
.item .name { grid-area: name; font-weight: 600; }
/* Toda la tarjeta abre el informe; la estrella queda por encima. */
.item .name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.item .area { display: none; }
.item .favorite { grid-area: star; justify-self: center; position: relative; }
.open { grid-area: open; justify-self: end; display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 12px; }
.open .i { width: 14px; height: 14px; }
.item:hover .open { color: var(--accent); }
.star { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; color: #9A968F; }
.star:hover { background: var(--bg); }
.star.on { color: var(--gold); }
[data-layout="list"] .items { display: flex; flex-direction: column; gap: 0; }
[data-layout="list"] .item { display: flex; gap: 12px; height: 48px; padding: 0 10px; border-radius: 8px; box-shadow: none; }
[data-layout="list"] .item:hover { background: var(--bg); box-shadow: none; }
[data-layout="list"] .item .name { flex: 1; }
[data-layout="list"] .item .area { display: block; width: 160px; color: var(--muted); font-size: 12px; }
.notice p { max-width: 640px; }
.notice .button { width: auto; display: inline-flex; padding: 0 18px; }

/* Visor: el informe ocupa todo menos una barra fina */
.viewer { height: 100%; display: flex; flex-direction: column; background: #EDECEA; }
.viewer-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px;
  background: #fff; border-bottom: 1px solid var(--line); }
.viewer-bar .avatar { width: 28px; height: 28px; font-size: 11px; }
.back { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.back:hover { color: var(--accent); }
.divider { width: 1px; height: 20px; background: var(--line); }
.viewer-bar h1 { margin: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report { flex: 1; min-height: 0; }
.fullscreen .i-exit-fullscreen, :fullscreen .fullscreen .i-fullscreen { display: none; }
:fullscreen .fullscreen .i-exit-fullscreen { display: block; }
.report iframe { display: block; border: 0; }

@media (max-width: 760px) {
  .login-card { padding: 32px 22px; }
  .side { position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .folded .side { width: 232px; }
  .folded .side .label { display: inline; }
  .side .fold { display: none; }
  .nav-open .side { transform: none; }
  .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .3); }
  .top { flex-wrap: wrap; height: auto; padding: 10px 12px; row-gap: 10px; }
  .top .menu { display: grid; }
  .search { order: 5; width: 100%; }
  .select { order: 6; width: 100%; }
  .content { padding: 12px; }
  .panel { padding: 14px; }
  .items { grid-template-columns: 1fr; }
  [data-layout="list"] .item .area { display: none; }
  .back span, .fullscreen { display: none; }
}

/* Administración: tabla, cabecera de página, etiquetas y panel lateral. */
nav .nav-title { margin: 14px 12px 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.page-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: #fff; }
.page-head h1 { margin: 0; font-size: 17px; font-weight: 600; color: var(--brand); }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.button.inline { width: auto; min-height: 38px; padding: 0 14px; }
.filters { display: flex; gap: 10px; margin-bottom: 12px; }
.filters .search { width: 360px; background: #fff; }
.filters .select { background: #fff; }
table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.grid th { text-align: left; padding: 12px 14px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.grid td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr:hover td { background: #FAFAF9; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .actions form { display: inline; }
.icon-slot { display: inline-block; width: 30px; }
.grid .actions .icon-button { display: inline-grid; width: 30px; height: 30px; vertical-align: middle; }
.grid .actions .danger:hover { color: var(--error); }
.tag { display: inline-block; padding: 2px 8px; margin: 2px 4px 2px 0; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; background: #fff; }
.state { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.state.on { background: #E6F4EA; color: #1E7B34; }
.state.off { background: #FBEAE8; color: var(--error); }
.state.wait { background: #FFF4E0; color: #8A5A00; }
.section-title { margin: 22px 0 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.section-title + .hint { margin: 0 0 10px; }
/* El árbol de Entra: grupos desplegables, y su nivel en la concesión. */
.tree-box { background: #fff; border-radius: 12px; padding: 8px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.tree-node > summary { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; cursor: pointer; }
.tree-name { font-weight: 600; }
.tree-body { padding-left: 22px; border-left: 1px solid var(--line); margin-left: 5px; }
.people { margin: 0 0 6px; padding: 0 0 0 4px; list-style: none; }
.people li { padding: 3px 0; }
.check.tree { padding-left: calc(var(--depth) * 18px); }
.check.inherited { color: var(--muted); }
.table-foot { display: flex; justify-content: flex-end; padding: 10px 4px; color: var(--muted); font-size: 12px; }
/* Panel lateral para alta y edición, sobre la tabla. */
.drawer-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.25); }
.drawer { position: fixed; z-index: 31; max-width: 100%; top: 0; right: 0; bottom: 0; width: 440px; background: #fff; padding: 22px 24px; overflow: auto; box-shadow: -8px 0 28px rgba(0,0,0,.12); }
.drawer h2 { margin: 0 0 4px; font-size: 16px; color: var(--brand); }
.drawer > p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }
.drawer .field select, .drawer .field input { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #FAFAF9; }
.drawer fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.drawer legend { padding: 0 4px; color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.drawer.wide { width: 760px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 12px; }
.box h3, .box summary { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink); }
.box summary { cursor: pointer; margin: 0; }
.box[open] summary { margin-bottom: 10px; }
.box h4 { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.box .field p { margin: 6px 0 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 6px 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: relative; width: 34px; height: 20px; flex: none; border-radius: 10px; background: #D5D3CF; transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { margin: -8px 0 14px; color: var(--muted); font-size: 12px; }
.note { padding: 10px 12px; border-radius: 8px; background: #EEF5F9; color: var(--brand); font-size: 12px; margin-bottom: 14px; }
.warn { padding: 10px 12px; border-radius: 8px; background: #FFF4E0; color: #8A5A00; font-size: 13px; }
/* Capacidad */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card h2 { margin: 0 0 12px; font-size: 14px; }
.big-state { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 22px; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #1E7B34; }
.dot.off { background: var(--error); }
.dot.wait { background: #D08A00; }
.schedule { display: grid; grid-template-columns: 140px 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.schedule input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #FAFAF9; }
.log { margin: 0; padding: 0; list-style: none; font-size: 13px; }
.log li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.log li span:first-child { width: 130px; color: var(--muted); }
.done { background: #E6F4EA; color: #1E7B34; border-radius: 8px; padding: 10px 12px; }
.error, .done { margin: 0 0 12px; }
.card .warn { margin: 0 0 14px; }
@media (max-width: 760px) {
  .filters { flex-wrap: wrap; }
  .filters .search, .filters .select { width: 100%; }
  table.grid { display: block; overflow-x: auto; }
  .cards { grid-template-columns: 1fr; }
  .schedule, .two, .checks { grid-template-columns: 1fr; }
}
.card .hint { margin: 8px 0 14px; }

/* «View as»: el aviso de que se ve el portal como otra persona */
.view-as { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; border-radius: 10px;
  background: var(--gold); color: var(--ink); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.view-as .button { width: auto; min-height: 34px; }

/* Marcadores del visor */
.bookmarks { position: relative; }
.bookmarks-panel { position: absolute; right: 0; top: 40px; z-index: 40; width: 320px; padding: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .12); }
.bookmarks-panel form { display: flex; gap: 8px; }
.bookmarks-panel input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.bookmarks-panel .button { width: auto; min-height: 36px; }
.bookmarks-panel .hint, .bookmarks-panel .error { margin: 8px 0 0; font-size: 12px; }
.bookmarks-panel ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 320px; overflow: auto; }
.bookmarks-panel li { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--line); }
.bookmark-apply { flex: 1; min-width: 0; padding: 8px 4px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bookmark-apply:hover { color: var(--accent); }
