/* The Guide · back-office panels (web/console). Loaded after app.css, whose components (panel, button,
   field, chip, notice, dialog…) the modules use; this file only lays out the desktop-first shell. */

.console-shell {
  --cs-side: 272px;
  --cs-top: 60px;
  --cs-tone: #13303a;
  --cs-tone-soft: #dde7e9;
  --cs-tone-ink: #13303a;
  --header-h: var(--cs-top);
  background: var(--bg);
}
[data-surface="musei"] .console-shell, .console-shell[data-surface="musei"] { --cs-tone: #6d4f86; --cs-tone-soft: #ece4f2; --cs-tone-ink: #5b3f73; }
[data-surface="attivita"] .console-shell, .console-shell[data-surface="attivita"] { --cs-tone: #c2552f; --cs-tone-soft: #fbe5da; --cs-tone-ink: #a8472a; }
[data-surface="pa"] .console-shell, .console-shell[data-surface="pa"] { --cs-tone: #1f6f78; --cs-tone-soft: #dcecec; --cs-tone-ink: #175960; }
@media (prefers-color-scheme: dark) {
  .console-shell { --cs-tone: #8fb3bb; --cs-tone-soft: #1b3038; --cs-tone-ink: #b9d3d8; }
  [data-surface="musei"] .console-shell, .console-shell[data-surface="musei"] { --cs-tone: #b99ad0; --cs-tone-soft: #2c2236; --cs-tone-ink: #d4bfe4; }
  [data-surface="attivita"] .console-shell, .console-shell[data-surface="attivita"] { --cs-tone: #ec7a52; --cs-tone-soft: #3a2620; --cs-tone-ink: #f39a78; }
  [data-surface="pa"] .console-shell, .console-shell[data-surface="pa"] { --cs-tone: #5fb4ba; --cs-tone-soft: #173a3f; --cs-tone-ink: #8fd0d4; }
}

/* ---------- Layout ---------- */
.cs-layout { min-height: 100dvh; }
.cs-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60; width: var(--cs-side); display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px 14px; overflow-y: auto; overscroll-behavior: contain;
}
.cs-main { margin-left: var(--cs-side); min-width: 0; min-height: 100dvh; display: flex; flex-direction: column; }
.cs-topbar {
  position: sticky; top: 0; z-index: 40; height: var(--cs-top); display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.5) blur(14px); -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--line);
}
.cs-content { flex: 1; min-width: 0; }
.console-shell main { max-width: 1180px; margin: 0 auto; padding: 26px 32px 64px; overflow-x: clip; }
.console-shell .app-footer { display: none; }
.console-shell #toast { bottom: 24px; }
.cs-menu-button { display: none; }
.cs-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(8, 18, 22, .42); backdrop-filter: blur(1px); }

/* ---------- Sidebar ---------- */
.cs-brand { display: grid; gap: 14px; padding: 2px 6px 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.cs-logo { justify-self: start; }
.cs-logo img { height: 34px; width: auto; }
.cs-surface { position: relative; display: flex; flex-direction: column; min-width: 0; padding: 9px 12px 9px 16px; border-radius: var(--r-sm); background: var(--cs-tone-soft); }
.cs-surface::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--cs-tone); }
.cs-surface-kicker { font-size: 10px; font-weight: 800; letter-spacing: .09em; color: var(--muted); }
.cs-surface strong { font-size: 15.5px; line-height: 1.25; color: var(--cs-tone-ink); }
.cs-org { margin: 0 2px 14px; }
.cs-org-switch { display: flex; flex-direction: column; gap: 5px; }
.cs-org-label { font-size: 11px; font-weight: 750; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; padding-left: 4px; }
.cs-org-select { position: relative; display: block; }
.cs-org-select::after { content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.cs-org-select select {
  width: 100%; appearance: none; -webkit-appearance: none; height: 42px; padding: 0 34px 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--cs-tone-soft); color: var(--ink); font-weight: 700; font-size: 14px; text-overflow: ellipsis;
}
.cs-nav { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.cs-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cs-nav-title { margin: 0 0 4px; padding: 0 10px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-nav-link {
  display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 650; font-size: 14px; transition: background .15s, color .15s;
}
.cs-nav-link .tg-i { width: 19px; height: 19px; color: var(--muted); }
.cs-nav-link:hover { background: var(--surface-2); color: var(--ink); }
.cs-nav-link[aria-current="page"] { background: var(--cs-tone-soft); color: var(--cs-tone-ink); font-weight: 750; }
.cs-nav-link[aria-current="page"] .tg-i { color: var(--cs-tone); }
.cs-sidebar-foot { margin: 18px 8px 0; font-size: 11.5px; color: var(--muted); }

/* ---------- Top bar ---------- */
.cs-crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.cs-crumbs::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--cs-tone); box-shadow: 0 0 0 3px var(--cs-tone-soft); flex: none; }
.cs-crumbs > * { overflow: hidden; text-overflow: ellipsis; }
.cs-crumbs strong { color: var(--ink); font-weight: 750; }
.cs-crumb-surface { font-weight: 700; color: var(--cs-tone-ink); }
.cs-crumb-sep { color: var(--line-strong); flex: none; }
.cs-top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.cs-user-menu { position: relative; }
.cs-user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 4px; border-radius: var(--r-pill); cursor: pointer; }
.cs-user-menu summary::-webkit-details-marker { display: none; }
.cs-user-menu summary:hover, .cs-user-menu[open] summary { background: var(--surface-2); }
.cs-user-menu summary .tg-i { width: 16px; height: 16px; transform: rotate(90deg); color: var(--muted); }
.cs-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; background: var(--cs-tone); flex: none; }
.cs-user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; }
.cs-user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 280px; padding: 8px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-3); z-index: 80;
}
.cs-user-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.cs-user-head strong { display: block; }
.cs-user-head small { color: var(--muted); overflow-wrap: anywhere; }
.cs-user-title { margin: 8px 10px 4px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cs-user-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm); text-decoration: none; font-weight: 650; font-size: 14px; color: var(--ink-2); text-align: left; }
.cs-user-link:hover { background: var(--surface-2); color: var(--ink); }
.cs-user-link .tg-i { width: 18px; height: 18px; color: var(--muted); }
.cs-user-note { margin: 8px 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- States: 404, no access, errors ---------- */
.cs-state { max-width: 560px; margin: 8vh auto 0; text-align: center; padding: 36px 28px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.cs-state > .tg-i { width: 52px; height: 52px; padding: 13px; margin: 0 auto 14px; border-radius: 50%; background: var(--cs-tone-soft); color: var(--cs-tone); }
.cs-state h1 { font: 650 26px/1.15 var(--display); margin-bottom: 10px; }
.cs-state p { color: var(--ink-2); }
.cs-state .actions { justify-content: center; margin-top: 18px; }
.cs-state .tiny { margin-top: 16px; }
.cs-state-code { display: block; font: 700 54px/1 var(--display); color: var(--cs-tone); margin-bottom: 8px; }

/* ---------- Login ---------- */
.cs-auth .cs-sidebar, .cs-auth .cs-topbar { display: none; }
.cs-auth .cs-main { margin-left: 0; }
.cs-auth main { max-width: 1040px; padding-top: max(5vh, 24px); }
.cs-login { display: grid; grid-template-columns: 1.1fr .9fr; gap: 0; border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow-3); border: 1px solid var(--line); background: var(--surface); }
.cs-login-brand {
  position: relative; padding: 40px 40px 44px; color: #f3efe8; isolation: isolate;
  background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--cs-tone) 85%, #fff 0%) 0%, transparent 62%), linear-gradient(160deg, #173a45 0%, #0f2831 100%);
}
.cs-login-brand .brand-logo { height: 40px; padding: 6px 12px; border-radius: 14px; background: #fdf6e8; box-sizing: content-box; margin-bottom: 40px; }
.cs-login-kicker { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; color: rgba(243, 239, 232, .7); margin-bottom: 10px; }
.cs-login-brand h1 { font: 650 clamp(30px, 3.6vw, 42px)/1.06 var(--display); letter-spacing: -.02em; margin-bottom: 12px; }
.cs-login-brand > p { color: rgba(243, 239, 232, .84); max-width: 40ch; }
.cs-login-points { list-style: none; padding: 0; margin: 30px 0 0; display: grid; gap: 10px; font-size: 14px; color: rgba(243, 239, 232, .9); }
.cs-login-points li { display: flex; gap: 10px; align-items: center; }
.cs-login-points .tg-i { width: 18px; height: 18px; opacity: .85; }
.cs-login-card { padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.cs-login-card h2 { font-size: 22px; margin-bottom: 6px; }
.cs-login-card .auth-form .button { margin-top: 12px; }
.cs-login-foot { margin-top: 18px; }

/* ---------- Modules inside the panel ---------- */
/* Their own tab strips duplicate the sidebar on large screens. */
@media (min-width: 1024px) {
  .console-shell .biz-manage > .biz-tabs, .console-shell .pa-tabs { display: none; }
  .console-shell .pa-shell { grid-template-columns: minmax(0, 1fr); }
  .console-shell .biz-manage > .app-back { display: none; }
}
.console-shell .app-page-intro { margin-bottom: 18px; }
/* The community queue links back to the visitor feed (#social), which is not part of the panel. */
.console-shell[data-page="social-moderation"] .social-back[href="#social"] { display: none; }
.console-shell #detail-dialog { max-width: 720px; }

/* ---------- Tablet and phone ---------- */
@media (max-width: 1023px) {
  .cs-menu-button { display: inline-grid; margin-left: -8px; }
  .cs-sidebar { transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: none; }
  .cs-menu-open .cs-sidebar { transform: none; box-shadow: var(--shadow-3); }
  .cs-main { margin-left: 0; }
  .cs-topbar { padding: 0 16px; }
  .console-shell main { padding: 20px 18px 56px; }
  .cs-user-name { display: none; }
}
@media (max-width: 760px) {
  .cs-login { grid-template-columns: 1fr; }
  .cs-login-brand { padding: 28px 24px 30px; }
  .cs-login-brand .brand-logo { margin-bottom: 24px; }
  .cs-login-points { display: none; }
  .cs-login-card { padding: 26px 22px 28px; }
  .cs-auth main { padding: 16px 14px 40px; }
  #connection { display: none; }
  .cs-crumb-surface, .cs-crumb-surface + .cs-crumb-sep { display: none; }
  .cs-state { margin-top: 3vh; padding: 28px 20px; }
}
@media (prefers-reduced-motion: reduce) { .cs-sidebar { transition: none; } }

/* ---------- Admin pages (web/console/admin-core.js) ---------- */
.adm-page { display: grid; gap: 16px; }
.adm-page > .app-page-intro { margin-bottom: 2px; }
.adm-h2 { font-size: 17px; margin: 8px 0 -4px; }
.adm-h3 { font-size: 14px; margin: 18px 0 8px; letter-spacing: .01em; }
.adm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.adm-kpis-sm { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
.adm-kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); text-decoration: none; color: inherit; text-align: left; font: inherit; }
button.adm-kpi, a.adm-kpi { cursor: pointer; transition: border-color .15s, transform .15s; }
button.adm-kpi:hover, a.adm-kpi:hover { border-color: var(--cs-tone); }
.adm-kpi strong { font: 700 24px/1.15 var(--display); overflow-wrap: anywhere; }
.adm-kpi span { color: var(--muted); font-size: 13px; font-weight: 650; }
.adm-kpi.is-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.adm-kpi.is-warn strong { color: var(--warn); }
.adm-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.adm-card { margin: 0; }
.adm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.adm-card-head h2 { font-size: 17px; }
.adm-dl { display: grid; gap: 0; }
.adm-dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.adm-dl > div:last-child { border-bottom: 0; }
.adm-dl dt { color: var(--muted); font-size: 13.5px; font-weight: 650; }
.adm-dl dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.adm-note { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13.5px; }
.adm-note.is-ok { background: var(--ok-soft); color: var(--ok); }
.adm-note.is-bad { background: var(--danger-soft); color: var(--danger); }
.adm-audit { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.adm-audit li { display: flex; gap: 12px; }
.adm-audit small { display: block; color: var(--muted); font-size: 12.5px; }
.adm-audit-dot { width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--cs-tone); flex: none; box-shadow: 0 0 0 3px var(--cs-tone-soft); }
.adm-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.adm-panel-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow-1); }
.adm-panel-link:hover { border-color: var(--cs-tone); }
.adm-panel-link small { display: block; color: var(--muted); font-size: 12.5px; }
.adm-panel-link .tg-i { color: var(--muted); }
.adm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 0; padding: 12px 14px; }
.adm-search { display: flex; gap: 8px; flex: 1 1 280px; min-width: 0; }
.adm-search input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--bg-elev); }
.adm-search .button { flex: none; }
.adm-filters { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.adm-chips { margin: 0; padding: 0; flex-wrap: wrap; overflow: visible; }
.adm-tabs { margin: 0; padding: 0; }
.adm-tabs .chip { text-decoration: none; }
.adm-table-wrap { margin: 0; padding: 0; overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { text-align: left; font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.adm-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.adm-table tbody tr:last-child td { border-bottom: 0; }
.adm-table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.adm-table tr.is-disabled td { opacity: .72; }
.adm-sub { display: block; color: var(--muted); font-size: 12.5px; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user { display: flex; align-items: center; gap: 10px; text-align: left; min-width: 0; }
.adm-user span:last-child { min-width: 0; }
.adm-user strong { display: block; }
.adm-user small { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.adm-avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--cs-tone-soft); color: var(--cs-tone-ink); font-weight: 800; flex: none; }
.adm-org-tag { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); font-size: 12px; font-weight: 650; }
.adm-pill { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 750; white-space: nowrap; }
.adm-pill.is-ok { background: var(--ok-soft); color: var(--ok); }
.adm-pill.is-warn { background: var(--warn-soft); color: var(--warn); }
.adm-pill.is-danger { background: var(--danger-soft); color: var(--danger); }
.adm-pill.is-accent { background: var(--cs-tone-soft); color: var(--cs-tone-ink); }
.adm-actions-cell { text-align: right; white-space: nowrap; }
.adm-row-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.adm-row-actions .tg-i { width: 15px; height: 15px; }
.adm-danger { color: var(--danger) !important; }
.adm-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.adm-pager .actions { margin: 0; }
.adm-new summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; list-style: none; }
.adm-new summary::-webkit-details-marker { display: none; }
.adm-new summary strong::before { content: "+ "; color: var(--cs-tone); }
.adm-form { display: grid; gap: 4px; margin-top: 12px; max-width: 560px; }
.adm-form .button { justify-self: start; margin-top: 6px; }
.adm-mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.adm-mini-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); }
.adm-mini-list li span { color: var(--muted); font-size: 13px; flex: 1; }
.adm-services { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.adm-services li { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.adm-services small { grid-column: 2; color: var(--muted); font-size: 12px; }
.adm-services-all { grid-column: 1 / -1; }
.adm-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.adm-services .is-bad .adm-dot { background: var(--danger); }
@media (max-width: 1180px) { .adm-hide-md { display: none; } }
@media (max-width: 900px) { .adm-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .adm-hide-sm { display: none; }
  .adm-kpis-sm { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; }
  .adm-kpis-sm .adm-kpi { padding: 10px 12px; }
  .adm-kpi strong { font-size: 20px; }
  /* Phones: table rows become cards. */
  .adm-table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .adm-table, .adm-table tbody, .adm-table td { display: block; }
  .adm-table thead, .adm-table .adm-hide-sm, .adm-table .adm-hide-md { display: none; }
  .adm-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 12px 14px; margin-bottom: 8px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
  .adm-table tbody tr:hover { background: var(--surface); }
  .adm-table td { padding: 0; border: 0; }
  .adm-table td:first-child { flex: 1 1 100%; }
  .adm-table .adm-actions-cell { flex: 1 1 100%; text-align: left; }
  .adm-row-actions { justify-content: flex-start; }
  .adm-sub { max-width: none; white-space: normal; }
}

/* ---------- Full-screen module pages (zones editor) and printing ---------- */
@media (min-width: 960px) { .console-shell .zones-page { inset: var(--cs-top) 0 0 0; } }
@media (min-width: 1024px) { .console-shell .zones-page { left: var(--cs-side); } }
@media print {
  .console-shell .cs-sidebar, .console-shell .cs-topbar, .console-shell .cs-scrim, .console-shell #toast, .console-shell .skip-link { display: none !important; }
  .console-shell .cs-main { margin-left: 0; }
  .console-shell main { max-width: none; padding: 0; }
}
