/* ===== Admin look & feel ===== */
:root { --tt-admin-build: "2026-11-09.2"; }   /* version check, see js/main.js */
.version-error { max-width: 560px; margin: 80px auto; padding: 28px; background: #fff; border: 1px solid #fecaca; border-radius: 10px; }
.version-error h2 { margin-top: 0; color: #991b1b; }
.version-error li { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 0;
       background: #f9fafb; color: #111827; font-size: 14px; }
.shell { display: flex; height: 100vh; }
/* Sidebar, header and nested folder navigation: see "App shell" at the end of this file */
nav .nav-section { padding: 16px 12px; }
nav .nav-title { font-size: 11px; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
nav .nav-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; color: #374151; }
nav .nav-item:hover, nav .nav-item.active { background: #eff6ff; color: #1d4ed8; }
.nav-logo { display: flex; align-items: center; gap: 8px; padding: 16px 16px 8px; }
.nav-logo .mark { width: 28px; height: 28px; border-radius: 7px; background: #2563eb; color: #fff;
                   display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.nav-logo .name { font-weight: 700; font-size: 14px; color: #111827; }
.nav-section-header { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 8px; cursor: pointer; }
.nav-section-header:hover .nav-title { color: #374151; }
.nav-collapse-icon { color: #9ca3af; font-size: 11px; transition: transform .15s ease; }
.nav-collapse-icon.collapsed { transform: rotate(-90deg); }
#folderListWrap.collapsed { display: none; }
.user-bar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #6b7280; }
.folder-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid #e5e7eb; }
.folder-tab { padding: 10px 4px; margin-right: 20px; cursor: pointer; color: #6b7280; font-size: 13.5px;
              font-weight: 600; border-bottom: 2px solid transparent; }
.folder-tab:hover { color: #374151; }
.folder-tab.active { color: #1d4ed8; border-bottom-color: #2563eb; }
main { flex: 1; min-width: 0; overflow-y: auto; container-type: inline-size; container-name: main; }

.breadcrumb { color: #6b7280; font-size: 13px; }
.breadcrumb b { color: #111827; }
.content { padding: 28px 32px 48px; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; }
h3 { font-size: 15px; font-weight: 600; color: #111827;
     margin: 32px 0 16px; padding-top: 24px; border-top: 1px solid #e5e7eb; }
/* Only a title that opens its box skips the divider. (first-of-type also
   matched titles further down a form, which then lost their spacing.) */
h3:first-child { margin-top: 0; padding-top: 0; border-top: none; }

button { border: 1px solid #d1d5db; background: #fff; border-radius: 6px; padding: 0 12px;
         cursor: pointer; font-size: 13px; color: #374151; box-sizing: border-box; height: 35px;
         display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
button:hover { background: #f3f4f6; }
button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
button.primary:hover { background: #1d4ed8; }
button.danger { color: #dc2626; border-color: #fecaca; }
button.small { padding: 0 8px; font-size: 12px; height: 28px; }
button svg { vertical-align: -2px; }
button.icon-btn { border: none; background: none; padding: 0 6px; color: #9ca3af; }
button.icon-btn:hover { color: #dc2626; background: none; }
button.text-danger { border: none; background: none; color: #9ca3af; padding: 0 6px; font-size: 13px; }
button.text-danger:hover { color: #dc2626; background: none; }

input, select, button { box-sizing: border-box; height: 35px; }
input, select, textarea { width: 100%; padding: 7px 9px; border: 1px solid #d1d5db; border-radius: 6px;
                           font-size: 13.5px; font-family: inherit; background: #fff; box-sizing: border-box; }
select { -webkit-appearance: none; appearance: none; cursor: pointer;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
         background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
input[type="color"] { padding: 3px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 4px; }
label { font-size: 12px; font-weight: 600; color: #4b5563; display: block; margin-bottom: 4px; }
.field { margin-bottom: 20px; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 20px; }
.field-row > div { flex: 1 1 160px; min-width: 0; }
.toggle-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.toggle-row label { margin: 0; }
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #d1d5db; border-radius: 999px;
                   cursor: pointer; transition: background-color .15s ease; }
.switch .slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
                           background: #fff; border-radius: 50%; transition: transform .15s ease;
                           box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: #2563eb; }
.switch input:checked + .slider::before { transform: translateX(16px); }
.hint { font-size: 12px; color: #6b7280; margin-top: 4px; line-height: 1.45; }

.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 28px; }
/* A card's own title + one-line description */
.card-head { margin-bottom: 22px; }
.card-head h3 { margin: 0 0 4px; padding: 0; border: none; }
.card-head.with-actions { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }
/* Save/Delete row above a stack of form cards */
.form-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 35px; }
.form-toolbar .form-title { font-weight: 600; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc { margin: 0; font-size: 13px; color: #6b7280; line-height: 1.45; }
/* Vertical stack of cards with even spacing */
.stack { display: flex; flex-direction: column; gap: 20px; }

.group-row { display: flex; align-items: center; justify-content: space-between; gap: 16px;
             padding: 16px 20px; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 12px; background: #fff; }
.badge { padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 700; }
.badge.live { background: #dcfce7; color: #166534; }
.badge.draft { background: #f3f4f6; color: #4b5563; }

.editor-grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.preview-canvas { background: #3f3f46; background-image: radial-gradient(#54545c 1px, transparent 1px);
                  background-size: 16px 16px; border-radius: 10px; min-height: 420px; position: relative;
                  overflow: hidden; display: flex; align-items: center; justify-content: center; padding: 24px; }
.preview-field { background: #fff; border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 12px;
                  font-size: 13px; color: #9ca3af; width: 180px; position: relative; }
/* tooltip widget classes, copied/adapted from widget/tooltip-widget.css so this preview matches
   production pixel-for-pixel. Theme colors are applied via inline CSS vars on #previewCanvas. */
.tt-beacon { width: 14px; height: 14px; border-radius: 50%; background: var(--tt-icon, #3b82f6);
             position: absolute; transform: translate(-50%, -50%); cursor: pointer;
             box-shadow: 0 0 0 4px rgba(59,130,246,0.25); }
.tt-beacon-info, .tt-beacon-question { width: 18px; height: 18px; display: flex; align-items: center;
             justify-content: center; font-size: 12px; font-weight: 700; font-family: Georgia, serif;
             color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.tt-tooltip { max-width: 260px; background: var(--tt-bg, #fff); color: var(--tt-text, #111827);
              border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); padding: 14px 16px;
              font-family: var(--tt-font, inherit); position: absolute; z-index: 5; }
.tt-tooltip-title { font-weight: 700; font-size: 14px; margin-bottom: 5px; }
.tt-tooltip-body { font-size: 12.5px; line-height: 1.4; }
.tt-tooltip-body a { color: var(--tt-link, #2563eb); }
.tt-tooltip-body img { max-width: 100%; height: auto; display: block; border-radius: 6px; margin: 6px 0; }
.tt-tooltip-arrow { position: absolute; width: 10px; height: 10px; background: var(--tt-bg, #fff);
                    transform: rotate(45deg); }
.tt-tooltip-close { position: absolute; top: 6px; right: 6px; border: none; background: none;
                    cursor: pointer; opacity: .5; font-size: 15px; color: var(--tt-text, #6b7280); }

/* Banner classes, copied/adapted from widget/tooltip-widget.css so this
   preview matches production. */
.tt-banner { background: var(--tt-bg, #ffffff); color: var(--tt-text, #111827); width: 100%; box-sizing: border-box;
             container-type: inline-size; container-name: tt-banner; }
.tt-banner-content { display: flex; align-items: center; gap: 14px; padding: 12px 20px; }
.tt-banner-align-right .tt-banner-content { justify-content: flex-end; }
@container tt-banner (max-width: 640px) {
  .tt-banner-content { flex-wrap: wrap; justify-content: center; text-align: center; padding: 14px 16px; }
  .tt-banner-image { margin: 0 auto; }
  .tt-banner-text { flex-basis: 100%; }
  .tt-banner-buttons { flex-basis: 100%; justify-content: center; margin-top: 4px; }
}
.tt-banner-image { flex-shrink: 0; height: auto; border-radius: 4px; }
.tt-banner-text { flex: 1; min-width: 0; }
.tt-banner-title { font-weight: 700; font-size: var(--tt-title-size, 15px); }
.tt-banner-body { font-size: var(--tt-body-size, 13.5px); line-height: 1.4; }
.tt-banner-body a { color: var(--tt-link, #2563eb); }
.tt-banner-buttons { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tt-banner-button { padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; border: none; }
.tt-banner-button-primary { background: var(--tt-icon, #2563eb); color: #fff; }
.tt-banner-button-secondary { background: transparent; color: var(--tt-text, #111827); border: 1px solid #d1d5db; }
.tt-banner-button-cross { background: none; font-size: 20px; line-height: 1; padding: 4px 8px; color: var(--tt-text, #6b7280); opacity: .6; }

/* Collapsible bar (same as the widget). Scoped to the preview so the
   panel's own button styles (white/grey, 35px high) don't apply. */
.tt-banner.tt-banner-collapsible .tt-banner-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.tt-banner.tt-banner-collapsible .tt-banner-toggle,
.tt-banner.tt-banner-collapsible .tt-banner-dismiss,
.tt-banner.tt-banner-collapsible .tt-banner-strip {
  height: auto; padding: 0; border: 0; border-radius: 0; box-shadow: none; cursor: pointer; font: inherit;
  background-color: transparent; background-image: none; color: var(--tt-text, #111827); gap: 8px;
}
.tt-banner.tt-banner-collapsible .tt-banner-toggle { width: 28px; height: 28px; border-radius: 6px; opacity: .7;
  display: flex; align-items: center; justify-content: center; }
.tt-banner.tt-banner-collapsible .tt-banner-toggle:hover { opacity: 1; background-color: rgba(0,0,0,.06); }
.tt-banner.tt-banner-collapsible .tt-banner-dismiss { font-size: 12px; white-space: nowrap; text-decoration: underline; opacity: .75; }
.tt-banner.tt-banner-collapsible .tt-banner-dismiss:hover { opacity: 1; background-color: transparent; }
.tt-banner.tt-banner-collapsible .tt-banner-strip { display: none; width: 100%; min-height: 28px; padding: 4px 16px;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 600; background-color: var(--tt-bg, #ffffff); }
.tt-banner.tt-banner-collapsible .tt-banner-strip:hover { background-color: var(--tt-bg, #ffffff); }
.tt-banner.tt-banner-collapsible .tt-banner-strip:hover .tt-banner-strip-title { text-decoration: underline; }
.tt-banner.tt-banner-collapsible .tt-banner-toggle svg,
.tt-banner.tt-banner-collapsible .tt-banner-strip svg { width: 16px; height: 16px; display: block; flex-shrink: 0; vertical-align: 0; }
.tt-banner-strip-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-banner.tt-banner-collapsible.tt-banner-collapsed .tt-banner-content { display: none; }
.tt-banner.tt-banner-collapsible.tt-banner-collapsed .tt-banner-strip { display: flex; }
@container tt-banner (max-width: 640px) { .tt-banner.tt-banner-collapsible .tt-banner-controls { flex-basis: 100%; justify-content: center; } }

.tip-list-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
                  display: flex; align-items: center; justify-content: space-between; }
.tip-list-item:hover, .tip-list-item.active { background: #eff6ff; }

.cond-node { border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 12px; background: #fafafa; }
.tip-row { border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; margin-bottom: 14px; background: #fafafa; }
.cond-node .cond-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12.5px; color: #4b5563; }
.cond-node select.op-select { width: auto; display: inline-block; padding: 5px 28px 5px 10px; }
.cond-leaf { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cond-leaf select { flex: 0 0 160px; }
.cond-leaf input { flex: 1; }
.cond-actions { display: flex; gap: 8px; margin-top: 6px; }
.cond-actions button { font-size: 12px; }

.rte-toolbar { display: flex; align-items: center; gap: 1px; border: 1px solid #d1d5db; border-bottom: none;
               border-radius: 6px 6px 0 0; padding: 4px; background: #f9fafb; flex-wrap: wrap; }
.rte-toolbar button { border: none; background: none; padding: 0 4px; min-width: 28px; height: 28px;
                       border-radius: 4px; font-size: 13px; font-weight: 600; color: #374151;
                       display: inline-flex; align-items: center; justify-content: center; }
.rte-toolbar button:hover { background: #e5e7eb; }
.rte-toolbar button svg { display: block; }
.rte-sep { width: 1px; height: 20px; background: #d1d5db; margin: 0 4px; }
.rte-body { border: 1px solid #d1d5db; border-radius: 0 0 6px 6px; padding: 10px; min-height: 90px;
            font-size: 13.5px; line-height: 1.5; }
.rte-body:focus { outline: 2px solid #93c5fd; outline-offset: -1px; }
.rte-body img { max-width: 100%; height: auto; display: block; border-radius: 6px; margin: 6px 0; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex;
                  align-items: flex-start; justify-content: center; padding: 40px 20px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 100%; padding: 28px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.login-screen { position: fixed; inset: 0; background: #f3f4f6; display: flex;
                 align-items: center; justify-content: center; z-index: 200; }
.login-card { background: #fff; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.1);
              padding: 32px; width: 340px; }
.login-card .mark { width: 40px; height: 40px; border-radius: 10px; background: #2563eb; color: #fff;
                     display: flex; align-items: center; justify-content: center; font-weight: 800;
                     font-size: 16px; margin: 0 auto 16px; }

.key-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0;
           border-bottom: 1px solid #f0f0f0; }
.key-row code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 12px; }
pre.snippet { background: #111827; color: #d1fae5; padding: 14px; border-radius: 8px; font-size: 12.5px;
              overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 8px 12px;
          border-radius: 6px; font-size: 12.5px; margin-bottom: 16px; }
.dropdown-menu { position: relative; display: inline-block; }
.dropdown-menu .menu { display: none; position: absolute; right: 0; top: 100%; background: #fff;
                       border: 1px solid #e5e7eb; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,.1);
                       z-index: 20; min-width: 130px; }
.dropdown-menu.open .menu { display: block; }
.dropdown-menu .menu button { display: block; width: 100%; text-align: left; border: none; border-radius: 0; }
/* ===== Added for the Supabase version ===== */

[hidden] { display: none !important; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* Environment badge - so demo and production can never be confused */
.env-badge { font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
             padding: 2px 7px; border-radius: 10px; margin-left: auto; }
.env-badge.demo { background: #fef3c7; color: #92400e; }
.env-badge.production { background: #fee2e2; color: #991b1b; }

/* Sign-in and Google Authenticator screens */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.06);
             padding: 32px; width: 380px; max-width: 100%; }
.auth-card .mark { width: 40px; height: 40px; border-radius: 10px; background: #2563eb; color: #fff; display: flex;
                   align-items: center; justify-content: center; font-weight: 800; font-size: 16px; margin: 0 auto 16px; }
.auth-card h2 { text-align: center; margin: 0 0 6px; }
.auth-card .sub { text-align: center; color: #6b7280; font-size: 13px; margin: 0 0 22px; line-height: 1.45; }
.auth-card button.primary { width: 100%; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; font-size: 12.5px; }
.link-btn { border: none; background: none; color: #2563eb; padding: 0; height: auto; cursor: pointer; font-size: 12.5px; }
.link-btn:hover { background: none; text-decoration: underline; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 6px;
              padding: 8px 10px; font-size: 12.5px; margin-bottom: 14px; }
.form-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; border-radius: 6px;
           padding: 8px 10px; font-size: 12.5px; margin-bottom: 14px; }
.qr-box { display: flex; justify-content: center; margin: 4px 0 14px; }
.qr-box img { width: 190px; height: 190px; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; background: #fff; }
.secret-box { background: #f3f4f6; border-radius: 6px; padding: 8px 10px; word-break: break-all; margin-bottom: 14px; }
.code-input { text-align: center; letter-spacing: .5em; font-size: 20px; height: 48px; font-variant-numeric: tabular-nums; }
.steps { color: #4b5563; font-size: 13px; line-height: 1.55; padding-left: 18px; margin: 0 0 16px; }

/* Status dots: grey = not live, green = live & working, blinking red = needs attention */
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.status-dot.off { background: #d1d5db; }
.status-dot.ok { background: #16a34a; }
.status-dot.problem { background: #dc2626; animation: tt-blink 1s ease-in-out infinite; }
@keyframes tt-blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .status-dot.problem { animation: none; box-shadow: 0 0 0 3px #fecaca; } }

/* Sidebar folders */
.folder-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; color: #374151; }
.folder-item:hover, .folder-item.active { background: #eff6ff; color: #1d4ed8; }
.folder-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item.deleted { color: #9ca3af; cursor: default; }
.folder-item.deleted:hover { background: none; color: #9ca3af; }
.folder-item.deleted .fname { text-decoration: line-through; }
.nav-bottom { margin-top: auto; border-top: 1px solid #e5e7eb; padding: 12px; }
.nav-bottom .who { font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }
.nav-bottom .row { display: flex; gap: 6px; }
.nav-bottom .row button { flex: 1; }

/* Page header, tabs, empty states */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.page-head .title { display: flex; align-items: center; gap: 8px; }
.tabs-row { display: flex; align-items: center; justify-content: space-between; }
.empty { text-align: center; color: #6b7280; padding: 40px 20px; }
.muted { color: #6b7280; }
.problem-note { color: #991b1b; font-size: 12px; margin-top: 4px; }

/* Keys and snippets */
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 12px;
           padding: 14px 18px; border: 1px solid #e5e7eb; border-radius: 8px; margin-bottom: 12px; background: #fff; }
.key-row .key-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: #374151; word-break: break-all; }
.key-row.revoked { opacity: .55; }
.badge.revoked { background: #fee2e2; color: #991b1b; }
pre.snippet { background: #111827; color: #e5e7eb; border-radius: 8px; padding: 14px; overflow-x: auto;
              font-size: 12.5px; line-height: 1.5; margin: 0 0 12px; white-space: pre-wrap; word-break: break-all; }

/* Modals and notifications */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start;
                  justify-content: center; padding: 60px 20px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 460px; max-width: 100%; padding: 28px; }
.modal h2 { margin-top: 0; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px;
         box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; }
.toast.error { background: #991b1b; }

/* Full-page error when the panel can't reach Supabase - never falls back to fake data */
.fatal { max-width: 520px; margin: 80px auto; text-align: center; padding: 0 20px; }
.fatal h2 { margin-bottom: 8px; }

/* Tip list, conditions, editor */
.tip-list-item .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond-leaf { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cond-leaf .cond-type { width: 230px; flex-shrink: 0; }
.cond-leaf .cond-input { flex: 1; }
.rte { border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; }
.rte .rte-toolbar { border: none; border-bottom: 1px solid #e5e7eb; border-radius: 0; }
.rte .rte-body { border: none; border-radius: 0; min-height: 110px; }
.rte-body img { max-width: 100%; height: auto; }

/* Simplified tip preview: tooltip placed around the field */
.pv-anchor { position: relative; display: inline-block; }
.pv-beacon { position: absolute; }
.pv-beacon-bottom { left: 50%; top: 100%; transform: translate(-50%, 6px); }
.pv-beacon-top    { left: 50%; bottom: 100%; transform: translate(-50%, -6px); }
.pv-beacon-left   { right: 100%; top: 50%; transform: translate(-6px, -50%); }
.pv-beacon-right  { left: 100%; top: 50%; transform: translate(6px, -50%); }
.pv-beacon.tt-beacon { width: var(--tt-beacon-size, 14px); height: var(--tt-beacon-size, 14px); }
.pv-tooltip { width: 260px; max-width: none; }
.theme-canvas { min-height: 300px; }
.pv-tooltip .tt-tooltip-body { font-size: var(--tt-body-size, 14px); }
.pv-top    { left: 50%; bottom: calc(100% + 26px); transform: translateX(-50%); }
.pv-bottom { left: 50%; top: calc(100% + 26px); transform: translateX(-50%); }
.pv-left   { right: calc(100% + 26px); top: 50%; transform: translateY(-50%); }
.pv-right  { left: calc(100% + 26px); top: 50%; transform: translateY(-50%); }

/* Themes */
.swatches { display: flex; gap: 4px; }
.swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); }
.color-field { display: flex; gap: 6px; }
.color-field input[type="color"] { width: 44px; flex-shrink: 0; }
.theme-grid { max-width: 860px; }

/* ===== Narrower screens =====
   Measured on the content area (not the window), so it also adapts when
   the sidebar is expanded or collapsed. The preview moves above the form
   (see TT.placePreview) when there's no room for its own column. */
@container main (max-width: 999px) {
  .editor-grid { grid-template-columns: 210px minmax(0, 1fr); }
}
@container main (max-width: 819px) {
  .content { padding: 20px 20px 40px; }
  .card { padding: 22px; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-wrap: wrap; }
  .page-head > div:last-child { flex-wrap: wrap; }
  .group-row { flex-wrap: wrap; }
  .group-row > div:last-child { flex-wrap: wrap; }
  .folder-tabs { overflow-x: auto; }
  .folder-tab { white-space: nowrap; }
  .card-head.with-actions { flex-wrap: wrap; }
}

/* Banner preview (desktop / mobile) */
.banner-preview-outer { background: #e5e7eb; border-radius: 10px; padding: 24px; display: flex; justify-content: center; overflow-x: auto; }
.banner-preview-frame { width: 100%; max-width: 900px; background: #fff; border-radius: 8px; overflow: hidden;
                        box-shadow: 0 4px 16px rgba(0,0,0,.08); transition: max-width .15s ease; }
.banner-preview-frame.mobile { max-width: 375px; }
.banner-preview-page { min-height: 220px; display: flex; flex-direction: column; background: #f9fafb; }
.banner-preview-filler { flex: 1; min-height: 90px; background-image: repeating-linear-gradient(0deg, transparent, transparent 18px, #eef0f3 18px, #eef0f3 19px); }
.banner-preview-target { margin: 12px 16px; padding: 14px; border: 1px dashed #9ca3af; border-radius: 6px; color: #6b7280; font-size: 12px; text-align: center; background: #fff; }
.tt-banner-clickable { cursor: pointer; }
.tt-banner-content { position: relative; }

/* Reports */
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { text-align: left; color: #6b7280; font-weight: 600; font-size: 12px; padding: 8px; border-bottom: 1px solid #e5e7eb; }
.report-table td { padding: 8px; border-bottom: 1px solid #f3f4f6; }
.noscript { padding: 24px; }

/* Installation check */
.install-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.install-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.install-pill.yes { background: #dcfce7; color: #166534; }
.install-pill.no { background: #fee2e2; color: #991b1b; }

/* Sidebar account menu (email + gear) */
.nav-bottom { position: relative; }
.user-row { display: flex; align-items: center; gap: 6px; }
.user-row .who { flex: 1; margin: 0; }
.gear-btn { color: #6b7280; height: 30px; padding: 0 6px; }
button.icon-btn.gear-btn:hover, button.icon-btn.gear-btn[aria-expanded="true"] { color: #1d4ed8; background: #eff6ff; border-radius: 6px; }
.user-menu { position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px); background: #fff; border: 1px solid #e5e7eb;
             border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 6px; display: flex; flex-direction: column; gap: 2px; z-index: 50; }
.user-menu[hidden] { display: none; }
.user-menu button { border: none; justify-content: flex-start; width: 100%; gap: 8px; height: 34px; }
.user-menu button.danger-item { color: #dc2626; }
.user-menu button.danger-item:hover { background: #fef2f2; }

/* Reports: mode switch, totals, line chart */
.segmented { display: inline-flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.segmented button { border: none; border-radius: 0; height: 33px; padding: 0 16px; background: #fff; color: #374151; }
/* Reports: filters row, then a separate "Show" row below a divider */
.report-filters { align-items: flex-end; }
.report-filters .report-update { flex: 0 0 auto; padding-bottom: 20px; }
.report-show { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 18px; border-top: 1px solid #e5e7eb; }
.report-show-label { font-size: 12px; font-weight: 600; color: #4b5563; }
select:disabled { background-color: #f3f4f6; color: #9ca3af; cursor: not-allowed; }
.segmented button + button { border-left: 1px solid #d1d5db; }
.segmented button.active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.stats-row { display: flex; gap: 48px; flex-wrap: wrap; margin-bottom: 8px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat-label { color: #6b7280; font-size: 13px; margin-top: 4px; }
.line-chart { display: block; }
.chart-legend { display: flex; justify-content: center; gap: 20px; font-size: 12.5px; color: #4b5563; margin-top: 6px; }
.chart-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }


/* =====================================================================
   App shell: header bar, sidebar with folders and their sections
   ===================================================================== */
.shell { display: flex; height: 100vh; overflow: hidden; }
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; min-height: 0; }

/* Header */
.topbar { display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 24px 0 16px;
          background: #fff; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.header-btn { width: 38px; height: 38px; padding: 0; border-radius: 8px; color: #4b5563; flex-shrink: 0; }
.header-btn:hover { background: #f3f4f6; color: #111827; }
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; color: #6b7280; white-space: nowrap; overflow: hidden; }
.breadcrumb span, .breadcrumb b { overflow: hidden; text-overflow: ellipsis; }
.breadcrumb b { color: #111827; font-weight: 600; }
.crumb-sep { color: #d1d5db; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar .env-badge { margin-left: 0; }
.user-wrap { position: relative; }
.avatar-btn { border: none; background: none; padding: 2px 6px 2px 2px; height: 40px; gap: 4px; border-radius: 999px; color: #6b7280; }
.avatar-btn:hover { background: #f3f4f6; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-weight: 700; font-size: 14px;
          display: inline-flex; align-items: center; justify-content: center; }
.user-wrap .user-menu { position: absolute; top: calc(100% + 8px); right: 0; left: auto; bottom: auto; width: 240px; z-index: 60; }
.user-menu-head { padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid #f3f4f6; display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: #6b7280; }
.user-menu-head b { color: #374151; font-weight: 600; }
.user-menu-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #111827; font-size: 13px; }

/* Page title under the header (the section you're in) */
.section-title { font-size: 20px; font-weight: 650; margin: 0 0 20px; }

/* Sidebar */
nav { width: 264px; flex-shrink: 0; display: flex; flex-direction: column; background: #fff; border-right: 1px solid #e5e7eb;
      transition: width .2s ease; z-index: 40; }
.nav-logo { height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #f3f4f6; flex-shrink: 0; }
.nav-logo .name { white-space: nowrap; }
.nav-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 18px 12px 24px; }
nav .nav-title { padding: 0 10px 10px; }
.nav-folders { display: flex; flex-direction: column; gap: 2px; }
.folder-row { position: relative; display: flex; align-items: center; border-radius: 8px; }
.folder-row:hover { background: #f9fafb; }
.folder-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px;
               border: none; background: none; border-radius: 8px; color: #374151; font-size: 14px; font-weight: 500; text-align: left; }
.folder-item:hover { background: none; }
.folder-row.current .folder-item { color: #1d4ed8; }
.folder-badge { position: relative; width: 28px; height: 28px; flex-shrink: 0; border-radius: 7px; background: #f3f4f6; color: #4b5563;
                display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.folder-row.current .folder-badge { background: #dbeafe; color: #1d4ed8; }
.folder-badge .status-dot { position: absolute; right: -3px; bottom: -3px; box-shadow: 0 0 0 2px #fff; }
.folder-item .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chevron { color: #9ca3af; display: inline-flex; transform: rotate(-90deg); transition: transform .15s ease; }
.folder-chevron.open { transform: none; }
.folder-more-wrap { position: relative; display: inline-flex; }
.folder-more { width: 30px; height: 30px; padding: 0; margin-right: 4px; border: none; background: none; color: #9ca3af; border-radius: 6px; opacity: 0; }
.folder-row:hover .folder-more, .folder-more:focus-visible, .folder-row.current .folder-more { opacity: 1; }
.folder-more:hover { background: #e5e7eb; color: #374151; }
.folder-menu { position: absolute; top: calc(100% + 4px); right: 0; width: 190px; z-index: 70; background: #fff; border: 1px solid #e5e7eb;
               border-radius: 10px; box-shadow: 0 10px 30px rgba(17,24,39,.14); padding: 6px; }
.folder-menu button, .user-menu button { border: none; justify-content: flex-start; width: 100%; gap: 8px; height: 34px; }
.folder-menu button.danger-item { color: #dc2626; }
.folder-menu button.danger-item:hover { background: #fef2f2; }
.folder-sub { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 8px 22px; margin-left: 13px; border-left: 1px solid #e5e7eb; }
.folder-sub[hidden] { display: none; }
.sub-item { justify-content: flex-start; gap: 10px; height: 36px; padding: 0 10px; border: none; background: none; border-radius: 7px;
            color: #4b5563; font-size: 13.5px; text-align: left; }
.sub-item svg { width: 16px; height: 16px; color: #9ca3af; flex-shrink: 0; }
.sub-item:hover { background: #f3f4f6; color: #111827; }
.sub-item.active { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.sub-item.active svg { color: #2563eb; }
.folder-row.deleted { opacity: .6; padding-right: 6px; }
.folder-row.deleted .fname { text-decoration: line-through; }
.nav-new { width: 100%; justify-content: flex-start; gap: 10px; height: 40px; margin-top: 10px; padding: 0 10px;
           border: 1px dashed #d1d5db; border-radius: 8px; background: none; color: #4b5563; }
.nav-new:hover { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; }
.nav-new-plus { width: 28px; text-align: center; font-size: 18px; line-height: 1; }

/* Collapsed to an icon rail: folder initials only; hovering opens it over the page */
nav.compact { width: 76px; }
nav.compact:not(.peek) .nav-label, nav.compact:not(.peek) .nav-logo .name, nav.compact:not(.peek) .folder-sub { display: none; }
nav.compact:not(.peek) .nav-logo { justify-content: center; padding: 0; }
nav.compact:not(.peek) .folder-item { justify-content: center; padding: 0; }
nav.compact:not(.peek) .nav-new { justify-content: center; padding: 0; }
nav.compact:not(.peek) .nav-new-plus { width: auto; }
nav.compact:not(.peek) .nav-title { visibility: hidden; height: 12px; padding: 0; }
nav.compact.peek { position: fixed; top: 0; bottom: 0; left: 0; width: 264px; box-shadow: 8px 0 30px rgba(17,24,39,.12); z-index: 80; }
nav.compact.peek + .nav-backdrop + .main-col { margin-left: 76px; }

/* Small screens: the sidebar slides over the page from the left */
.nav-backdrop { display: none; }
@media (max-width: 767px) {
  nav, nav.compact { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; transform: translateX(-100%);
        transition: transform .22s ease; box-shadow: none; z-index: 90; }
  nav.open { transform: none; box-shadow: 8px 0 30px rgba(17,24,39,.18); }
  nav.compact .nav-label, nav.compact .nav-logo .name { display: revert; }
  nav.compact .folder-sub:not([hidden]) { display: flex; }
  nav.compact .nav-title { visibility: visible; height: auto; padding: 0 10px 10px; }
  nav.compact .folder-item, nav.compact .nav-new { justify-content: flex-start; padding: 0 10px; }
  nav.compact .nav-logo { justify-content: flex-start; padding: 0 20px; }
  .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 85; }
  .topbar { padding: 0 14px 0 10px; }
  .topbar .env-badge { display: none; }
}
@media (prefers-reduced-motion: reduce) { nav, nav.compact { transition: none; } }

/* =====================================================================
   Row action buttons with icons, and hover tooltips (data-tip)
   ===================================================================== */
.action-btn { gap: 6px; }
.action-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.action-btn.icon-only { width: 36px; padding: 0; }
.action-btn.danger svg { color: #dc2626; }
.action-btn.primary svg { color: #fff; }
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translate(-50%, 4px);
  width: max-content; max-width: 240px; padding: 6px 9px; border-radius: 6px; background: #111827; color: #fff;
  font-size: 12px; font-weight: 500; line-height: 1.35; white-space: normal; text-align: center;
  pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s ease, transform .12s ease; z-index: 50;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: .25s; }
[data-tip-align="end"]::after { left: auto; right: 0; transform: translateY(4px); }
[data-tip-align="end"]:hover::after, [data-tip-align="end"]:focus-visible::after { transform: none; }
@media (hover: none) { [data-tip]::after { display: none; } }
@media (prefers-reduced-motion: reduce) { [data-tip]::after { transition: none; } }

/* Tooltips that open downward (header, top of the page) */
[data-tip-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
[data-tip-pos="bottom"]:hover::after, [data-tip-pos="bottom"]:focus-visible::after { transform: translate(-50%, 0); }
[data-tip-pos="bottom"][data-tip-align="end"]::after { transform: translateY(-4px); }
[data-tip-pos="bottom"][data-tip-align="end"]:hover::after, [data-tip-pos="bottom"][data-tip-align="end"]:focus-visible::after { transform: none; }
.action-btn.small { gap: 5px; }
.action-btn.small svg { width: 14px; height: 14px; }
.move-btn svg { width: 15px; height: 15px; }
button.icon-btn.move-btn:hover { color: #1d4ed8; }
.action-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Publish switch: green = published, grey = not published */
.action-btn.publish-on { background: #dcfce7; border-color: #86efac; }
.action-btn.publish-on svg { color: #15803d; }
.action-btn.publish-on:hover { background: #bbf7d0; }
.action-btn.publish-off { background: #fff; border-color: #d1d5db; }
.action-btn.publish-off svg { color: #9ca3af; }
.action-btn.publish-off:hover { background: #f3f4f6; }
.action-btn.publish-off:hover svg { color: #15803d; }

/* =====================================================================
   Preview panel (slides in from the right)
   ===================================================================== */
.banner-editor { display: flex; flex-direction: column; gap: 20px; max-width: 1100px; }
.preview-panel { position: fixed; top: 0; right: 0; bottom: 0; width: var(--pv-w, 480px); max-width: 100vw; z-index: 75;
                 display: flex; flex-direction: column; background: #fff; border-left: 1px solid #e5e7eb;
                 box-shadow: -12px 0 32px rgba(17,24,39,.12); transform: translateX(100%); visibility: hidden;
                 transition: transform .24s ease, visibility 0s linear .24s, width .2s ease; }
.preview-panel.open { transform: none; visibility: visible; transition: transform .24s ease, visibility 0s, width .2s ease; }
.pv-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 14px 22px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0; }
.pv-titles { flex: 1; min-width: 0; }
.pv-titles h3 { margin: 0 0 3px; padding: 0; border: none; }
.pv-tools { display: flex; gap: 6px; flex-shrink: 0; padding-top: 2px; }
.pv-close { width: 34px; height: 34px; padding: 0; color: #6b7280; }
button.icon-btn.pv-close:hover { color: #111827; background: #f3f4f6; border-radius: 6px; }
.pv-body { flex: 1; overflow: auto; padding: 20px; background: #f9fafb; }
.pv-body .preview-canvas { min-height: 380px; }
.pv-body .banner-preview-outer { padding: 16px; }
.pv-empty { color: #9ca3af; margin: 0; }
/* Wide screens: the page makes room so the panel never covers the form */
.main-col { transition: margin-right .24s ease; }
body.preview-docked .main-col { margin-right: var(--pv-w, 480px); }
/* The Preview button looks pressed while the panel is open */
.action-btn.pressed { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; }
@media (prefers-reduced-motion: reduce) { .preview-panel, .preview-panel.open, .main-col { transition: none; } }

/* Page title row: section name, and a text-only "Back to …" link */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; min-height: 30px; }
.section-head .section-title { margin: 0; }
button.link-back { height: auto; padding: 4px 2px; gap: 6px; border: none; background: none; border-radius: 4px;
                   color: #4b5563; font-size: 14px; font-weight: 500; }
button.link-back svg { width: 16px; height: 16px; }
button.link-back:hover { background: none; color: #1d4ed8; text-decoration: underline; text-underline-offset: 3px; }
button.link-back:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
