/* GMB Tools platform — components. Design tokens live in tokens.css (linked first). */
:root {
  --topbar-h: var(--header-h, 56px);   /* height of the sticky app header (header.css) */
  --chipbar-h: 0px;            /* height of the sticky mobile section chip bar */
  --anchor-offset: calc(var(--topbar-h) + var(--chipbar-h) + 16px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.55; font-size: 15px; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.icon { width: 1.25em; height: 1.25em; vertical-align: -0.2em; flex: none; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 99; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .6rem 1.1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.lg { padding: .85rem 1.5rem; font-size: 1.05rem; }
.btn.sm { padding: .35rem .75rem; font-size: .85rem; border-radius: 8px; min-height: 36px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }

/* Cards, badges, alerts */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { margin-bottom: .35em; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--hover); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.alert { padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--card); margin-bottom: 1rem; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: var(--brand-soft); border-color: #c7d2fe; color: var(--brand-dark); }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* Forms */
label, .label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink); margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: .65rem .8rem; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; background: var(--card); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.hint { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .8rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* Public site */
.site-header { background: color-mix(in srgb, var(--card) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header .container { display: flex; align-items: center; gap: 1.5rem; height: 64px; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; color: var(--ink); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; color: #fff; font-size: .85rem; font-weight: 800; }
.site-nav { display: flex; gap: 1.25rem; margin-left: 1rem; }
.site-nav a { color: var(--text); font-weight: 500; }
.site-nav a:hover { color: var(--brand); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--brand-dark); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }
.site-nav .nav-login { display: none; }
.brand { min-width: 0; }
.site-actions { margin-left: auto; display: flex; gap: .6rem; align-items: center; }
.menu-toggle { display: none; }
.hero { padding: 88px 0 72px; background: radial-gradient(1200px 400px at 50% -10%, var(--brand-soft) 0%, transparent 70%), var(--bg); text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); max-width: 820px; margin: 0 auto .4em; }
.hero p.lead { font-size: 1.2rem; color: var(--muted); max-width: 640px; margin: 0 auto 1.8rem; }
.eyebrow { display: inline-block; font-weight: 700; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 1rem; }
.section { padding: 72px 0; }
.section.alt { background: var(--card); border-block: 1px solid var(--line); }
.section-head { max-width: 640px; margin: 0 auto 2.5rem; text-align: center; }
.section-head p { color: var(--muted); font-size: 1.05rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 24px; }
.grid-3.aside-right { grid-template-columns: 2fr 1fr; }
.grid-3.aside-left { grid-template-columns: 1fr 1.4fr; align-items: start; }
.tool-card { display: flex; flex-direction: column; gap: .5rem; height: 100%; }
.tool-card .tool-icon, .tool-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: .4rem; }
.tool-icon .icon { width: 24px; height: 24px; }
.tool-card .spacer { flex: 1; }
.steps { counter-reset: step; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.step { position: relative; padding-top: 44px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.feature-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.feature-list li { display: flex; gap: .6rem; padding: .3rem 0; }
.feature-list .icon { color: var(--ok); margin-top: .2rem; }
.plan-card { display: flex; flex-direction: column; }
.plan-card .price { font-size: 1.6rem; font-weight: 800; color: var(--ink); margin: .4rem 0 1rem; }
.plan-card.highlight { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.plan-card .spacer { flex: 1; }
.cta-band { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; text-align: center; padding: 56px 24px; border-radius: 20px; }
.cta-band h2 { color: #fff; }
.cta-band .btn { background: #fff; color: var(--brand-dark); border-color: #fff; }
.site-footer { border-top: 1px solid var(--line); padding: 32px 0; color: var(--muted); font-size: .9rem; background: var(--card); }
.site-footer .container { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Auth pages */
.auth-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.5rem; }

/* App shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand, .tool-side .brand { height: var(--header-h, 56px); margin: -20px -14px 10px; padding: 0 24px; border-bottom: 1px solid var(--line); }   /* same height as the header, so the two borders meet */
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 6px; font-weight: 700; }
.side-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px; color: var(--text); font-weight: 500; }
.side-link:hover { background: var(--hover); text-decoration: none; }
.side-link.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.side-link .lock { margin-left: auto; color: var(--muted); }
.topbar-title { font-size: 1rem; }
.topbar [data-toggle="sidebar"], .topbar-title { display: none; }
.scrim { display: none; }
.main { padding: 32px 40px 64px; max-width: 1200px; width: 100%; }   /* same width as the tool pages */
.page-head { margin-bottom: 1.75rem; }
.page-head p { color: var(--muted); margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; display: grid; place-items: center; flex: none; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab { padding: .6rem 1rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--brand-dark); border-color: var(--brand); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat .num { font-size: 1.8rem; font-weight: 800; color: var(--ink); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.token-box { display: flex; gap: .5rem; align-items: center; background: #0f172a; color: #e2e8f0; padding: .8rem 1rem; border-radius: 10px; }
.token-box code { flex: 1; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: .5rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.locked-tile { opacity: .92; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 40; transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility 0s linear .2s; box-shadow: var(--shadow); overflow-y: auto; }
  .sidebar.open { transform: none; visibility: visible; transition-delay: 0s; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .5); }
  .topbar { z-index: 30; }
  .topbar [data-toggle="sidebar"], .topbar-title { display: inline-flex; }
  .main { padding: 24px 16px 48px; }
  .site-nav { display: none; }
  .site-nav.open { display: flex; flex-direction: column; position: absolute; top: 64px; left: 0; right: 0; background: var(--card); padding: 16px 24px; border-bottom: 1px solid var(--line); margin: 0; }
  .menu-toggle { display: inline-flex; }
  .hero { padding: 56px 0 48px; }
  .section { padding: 48px 0; }
  dl.kv { grid-template-columns: 1fr; }
}

/* Legal pages */
.legal { max-width: 760px; }
.legal h2 { font-size: 1.15rem; margin: 1.8rem 0 .4rem; }
.legal p, .legal li { line-height: 1.65; }
.legal ul { padding-left: 1.2rem; }

/* ==========================================================================
   Reusable components (buttons, pills, chips, switch, dialog, toast, menu)
   ========================================================================== */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
a:focus-visible, button:focus-visible, summary:focus-visible, .btn:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.table-wrap:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* Button hierarchy: .primary  .secondary (default)  .danger  .ghost  (+ .ghost.danger = red text button) */
.btn { transition: background var(--ease), border-color var(--ease), box-shadow var(--ease); }
.btn.primary { box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.btn.ghost:hover { background: var(--hover); }
.btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.ghost.brand { color: var(--brand-dark); }
.btn[aria-busy="true"] { position: relative; opacity: .8; pointer-events: none; }
.btn[aria-busy="true"]::before, .spinner { content: ""; width: .95em; height: .95em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.spinner { display: inline-block; vertical-align: -.1em; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; padding: 0; transition: background var(--ease), color var(--ease); }
.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.icon-btn.danger:hover { background: var(--bad-soft); color: var(--bad); }
.icon-btn .icon { width: 18px; height: 18px; }
form.inline { display: inline-flex; margin: 0; }

/* Status pill */
.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .18rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--hover); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand-dark); }
.pill.plain::before { display: none; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); list-style: none; padding: 0; margin: 0; }
.chip { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .4rem .3rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; }
.chip .count { font-weight: 500; font-size: .78rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; }
.chip.off { background: var(--surface-2); color: var(--muted); border-style: dashed; }
.chip.off .name { text-decoration: line-through; text-decoration-color: rgba(90, 106, 127, .6); }
.chip-add { padding: .3rem .85rem .3rem .6rem; border-style: dashed; color: var(--brand-dark); background: var(--brand-soft); border-color: #c7d2fe; cursor: pointer; transition: background var(--ease), border-color var(--ease); }
.chip-add:hover { background: var(--brand-line); border-color: var(--brand); }
.chip-add .icon { width: 1em; height: 1em; }

/* Switch: <label class="switch"><input type="checkbox" role="switch"><span class="switch-track"></span><span class="switch-text">On</span></label> */
.switch { position: relative; display: inline-flex; align-items: center; gap: .5rem; margin: 0; cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--muted); }
.switch input { position: absolute; inset: 0 auto 0 0; width: 40px; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-track { position: relative; flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--control-off); transition: background var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .3); transition: transform var(--ease); }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch-text { min-width: 1.6rem; }
.switch[aria-busy="true"] .switch-track { opacity: .6; }

/* Row action menu: <details class="menu"> */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary { background: var(--hover); color: var(--ink); }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px; padding: var(--sp-1); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); display: grid; gap: 2px; }
.menu-list form { margin: 0; }
.menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .7rem; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; font-size: .9rem; font-weight: 500; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--hover); text-decoration: none; }
.menu-item.danger { color: var(--bad); }
.menu-item.danger:hover { background: var(--bad-soft); }
.menu-item .icon { width: 1.05em; height: 1.05em; }

/* Dialog: native <dialog class="dialog">. Without JS the #target fallback shows it as an overlay. */
.dialog { border: 0; padding: 0; border-radius: var(--radius-lg); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; color: var(--text); box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgba(15, 23, 42, .5); }
.dialog:target:not([open]) { display: block; position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 80; box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .5), var(--shadow-pop); }
.dialog[open] { animation: pop-in .16s ease; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) 0; }
.dialog-head h3 { margin: 0; font-size: 1.15rem; }
.dialog-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-4); }
.dialog .field:last-of-type { margin-bottom: 0; }

/* Toasts (flash messages). Zero-height sticky host: no layout shift; works without JS (success fades out in CSS). */
.toasts { position: sticky; top: calc(var(--topbar-h) + 16px); height: 0; z-index: 70; }
.toast-list { display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-2); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: .7rem; width: min(440px, 100%); padding: .8rem .9rem .8rem 1rem; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--brand); box-shadow: var(--shadow-pop); color: var(--ink); animation: toast-in .2s ease; }
.toast .icon { margin-top: .12rem; color: var(--brand); }
.toast.success { border-left-color: var(--ok); } .toast.success .icon { color: var(--ok); }
.toast.error { border-left-color: var(--bad); background: #fff7f7; } .toast.error .icon { color: var(--bad); }
.toast.warn { border-left-color: var(--warn); } .toast.warn .icon { color: var(--warn); }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { margin: -.25rem -.35rem 0 0; width: 28px; height: 28px; }
.toast.success:not(.sticky) { animation: toast-in .2s ease, toast-out .2s ease 8s forwards; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

/* ==========================================================================
   Settings -> Connections
   ========================================================================== */
.conn-head { margin-bottom: var(--sp-5); }
.conn-head h2 { font-size: 1.6rem; margin-bottom: .15em; }
.conn-head .sub { color: var(--muted); margin: 0; }
.how { margin-top: var(--sp-3); max-width: 860px; }
.how > summary { display: inline-flex; align-items: center; min-height: 36px; gap: .4rem; cursor: pointer; color: var(--brand-dark); font-weight: 600; font-size: .9rem; list-style: none; }
.how > summary::-webkit-details-marker { display: none; }
.how > summary .icon { width: 1.1em; height: 1.1em; }
.how > summary .chev { transition: transform var(--ease); }
.how[open] > summary .chev { transform: rotate(90deg); }
.how-body { margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); background: var(--brand-soft); border: 1px solid #c7d2fe; border-radius: var(--radius); color: #312e81; font-size: .92rem; }
.how-body p { margin: 0; }

.conn-layout { display: grid; grid-template-columns: 200px minmax(0, 860px); gap: var(--sp-6); align-items: start; }
.conn-menu { position: sticky; top: 24px; }
.conn-menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.conn-menu a { display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: 10px; color: var(--text); font-weight: 500; font-size: .92rem; transition: background var(--ease), color var(--ease); }
.conn-menu a:hover { background: var(--hover); text-decoration: none; }
.conn-menu a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.dot.ok { background: #22a05b; }
.dot.todo { background: #e08a1b; }
.dot.optional { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); }
.conn-main { min-width: 0; }
.conn-main > * + * { margin-top: var(--sp-4); }
.conn-main [id] { scroll-margin-top: var(--anchor-offset); }

/* Setup card */
.setup { border: 1px solid var(--line); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--card) 55%, var(--brand-soft)); box-shadow: var(--shadow); }
.setup > summary { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); cursor: pointer; list-style: none; border-radius: var(--radius-lg); }
.setup > summary::-webkit-details-marker { display: none; }
.setup-ring { position: relative; flex: none; width: 52px; height: 52px; }
.setup-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.setup-ring circle { fill: none; stroke-width: 3.6; }
.setup-ring .track { stroke: var(--line); }
.setup-ring .bar { stroke: var(--brand); stroke-linecap: round; transition: stroke-dasharray .4s ease; }
.setup.done .setup-ring .bar { stroke: var(--ok); }
.setup-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; color: var(--ink); }
.setup-title { flex: 1; min-width: 0; }
.setup-title strong { display: block; color: var(--ink); font-size: 1.05rem; }
.setup-title span { color: var(--muted); font-size: .9rem; }
.setup > summary .chev { color: var(--muted); transition: transform var(--ease); }
.setup[open] > summary .chev { transform: rotate(90deg); }
.setup-list { list-style: none; margin: 0; padding: 0 var(--sp-3) var(--sp-3); display: grid; gap: 2px; }
.setup-list a { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: 10px; color: var(--text); }
.setup-list a:hover { background: color-mix(in srgb, var(--card) 80%, transparent); text-decoration: none; }
.setup-list .icon { width: 1.3em; height: 1.3em; color: var(--control-off); }
.setup-list .done .icon { color: var(--ok); }
.setup-list .label { flex: 1; font-weight: 500; }
.setup-list .done .label { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(90, 106, 127, .5); }
.setup-list .go { font-size: .85rem; font-weight: 600; color: var(--brand-dark); }
.setup-list .done .go { color: var(--muted); font-weight: 500; }

/* Section card */
.sec { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: box-shadow var(--ease), border-color var(--ease); }
.sec:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.sec-head { display: flex; align-items: flex-start; gap: var(--sp-4); padding: var(--sp-5) var(--sp-5) 0; }
.sec-tile { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.sec-tile .icon { width: 22px; height: 22px; }
.sec-title { flex: 1; min-width: 0; }
.sec-title h3 { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .7rem; margin: 0 0 .15rem; font-size: 1.1rem; }
.sec-title p { margin: 0; color: var(--muted); font-size: .92rem; }
.sec-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sec-body { padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.sec-body > * + * { margin-top: var(--sp-4); }
.sec.attention { border-color: #fcd9a0; }
.sec.attention .sec-tile { background: var(--warn-soft); color: var(--warn); }

/* Google connection card */
.gcard { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); flex-wrap: wrap; }
.gcard.warn { background: #fffbeb; border-color: #fde68a; }
.gcard .avatar { width: 44px; height: 44px; font-size: 1.1rem; }
.gcard .who { flex: 1; min-width: 200px; }
.gcard .who strong { overflow-wrap: anywhere; }
.perks { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.perks li { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; }
.perks .icon { color: var(--ok); margin-top: .15rem; }
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem .9rem; border-radius: var(--radius); background: var(--warn-soft); color: #7c3a06; border: 1px solid #fde68a; font-size: .92rem; }
.notice .icon { margin-top: .15rem; flex: none; }
.notice.info { background: var(--brand-soft); border-color: #c7d2fe; color: #312e81; }

/* Lists of rows (projects, sheets) */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.panel + .panel { margin-top: var(--sp-3); }
.panel > summary { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); cursor: pointer; list-style: none; border-radius: var(--radius); transition: background var(--ease); }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary:hover { background: var(--surface-2); }
.panel > summary .chev { color: var(--muted); transition: transform var(--ease); }
.panel[open] > summary .chev { transform: rotate(90deg); }
.panel[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 1px solid var(--line); }
.panel-name { flex: 1; min-width: 0; }
.panel-name strong { display: block; overflow-wrap: anywhere; color: var(--ink); }
.panel-name span { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.panel-tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.panel-tools .grow { flex: 1; }
.rows { list-style: none; margin: 0; padding: 0; }
.rowi { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); transition: background var(--ease); }
.rowi:last-child { border-bottom: 0; }
.rowi:hover { background: var(--surface-2); }
.rowi-main { flex: 1; min-width: 0; }
.rowi-main strong { color: var(--ink); overflow-wrap: anywhere; }
.rowi-meta { display: flex; flex-wrap: wrap; gap: .1rem 1rem; color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.rowi-meta .mono { color: var(--text); }
.rowi-tools { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.rowi.off .rowi-main strong { color: var(--muted); }
.panel-empty { padding: var(--sp-4); color: var(--muted); font-size: .92rem; }
/* SignalWire tree: Account > Space > Project (Settings -> Connections) */
.account-tile { flex: none; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.account-tile svg { width: 18px; height: 18px; }
.account-none .account-tile { background: var(--surface-2); color: var(--muted); }
.tree-children { padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-6, 2rem); border-left: 2px solid var(--line-soft, var(--line)); margin-left: calc(var(--sp-4) + 15px); }
.tree-children > .panel-empty { padding: var(--sp-2) 0; }
@media (max-width: 640px) { .tree-children { margin-left: var(--sp-2); padding-left: var(--sp-3); } }
.tag { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 600; background: var(--warn-soft); color: var(--warn); vertical-align: .1em; margin-left: .35rem; }

/* Empty state */
.empty-state { text-align: center; padding: var(--sp-5) var(--sp-4); }
.empty-state svg.art { width: 150px; height: auto; margin-bottom: var(--sp-3); }
.empty-state h4 { font-size: 1.1rem; margin-bottom: .25em; }
.empty-state p { color: var(--muted); max-width: 420px; margin: 0 auto var(--sp-4); }
.empty-inline { padding: var(--sp-4); border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); text-align: center; font-size: .92rem; }

/* Compact inline add row */
.addrow { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: var(--sp-3); align-items: end; }
.addrow .field { margin: 0; }
.addrow-simple { grid-template-columns: minmax(0, 1fr) auto; }

/* Timezone */
.tz-preview { display: flex; align-items: center; gap: .5rem; min-height: 1.6rem; margin-top: .5rem; font-weight: 600; color: var(--ink); }
.tz-preview .icon { color: var(--brand); }
.tz-preview.bad { color: var(--bad); }

/* Backup */
.advanced > summary { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; color: var(--ink); list-style: none; padding: .5rem 0; }
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary .chev { transition: transform var(--ease); color: var(--muted); }
.advanced[open] > summary .chev { transform: rotate(90deg); }
.advanced-body { margin-top: var(--sp-3); }
.advanced-body > * + * { margin-top: var(--sp-4); }
.dropzone { display: grid; justify-items: center; gap: .35rem; padding: var(--sp-5) var(--sp-4); border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); text-align: center; cursor: pointer; margin: 0; transition: border-color var(--ease), background var(--ease); }
.dropzone:hover, .dropzone.drag, .dropzone:focus-within { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .icon { width: 28px; height: 28px; color: var(--brand); }
.dropzone input[type=file] { max-width: 100%; font: inherit; font-size: .88rem; }
.dropzone .fname { font-weight: 600; color: var(--ink); }

@media (max-width: 1100px) {
  .conn-layout { grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); }
  :root { --chipbar-h: 52px; }
  .conn-menu { position: sticky; top: var(--topbar-h); z-index: 25; margin: 0 -40px; padding: 8px 40px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); height: var(--chipbar-h); }
  /* right-edge fade says "more chips"; the padding keeps the last chip clear of it at the end of the scroll */
  .conn-menu ul { display: flex; gap: var(--sp-2); overflow-x: auto; scrollbar-width: none; padding-right: 28px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .conn-menu ul::-webkit-scrollbar { display: none; }
  .conn-menu a { flex: none; white-space: nowrap; border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: .3rem .8rem; }
  .conn-menu a.active { border-color: var(--brand); }
}
@media (max-width: 860px) { .conn-menu { margin: 0 -16px; padding: 8px 0 8px 16px; } }
@media (max-width: 640px) {
  .sec-head { flex-wrap: wrap; padding: var(--sp-4) var(--sp-4) 0; }
  .sec-title { flex-basis: calc(100% - 64px); }
  .sec-actions { width: 100%; justify-content: flex-start; }
  .sec-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); }
  .rowi { flex-wrap: wrap; }
  .rowi-tools { width: 100%; justify-content: flex-end; }
  .addrow { grid-template-columns: 1fr; }
  .toast-list { align-items: stretch; }
  .toasts { margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .btn[aria-busy="true"]::before, .spinner { animation: none; border-right-color: currentColor; opacity: .6; }
}

/* ==========================================================================
   UX pass: field errors, first-run dashboard, install steps, filters
   ========================================================================== */
.field-error { color: var(--bad); font-size: .85rem; font-weight: 600; margin: .3rem 0 0; }
.field.has-error input:not([type=checkbox]) { border-color: var(--bad); }
input[aria-invalid="true"]:not([type=checkbox]) { border-color: var(--bad); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.2rem; }
.pw-toggle { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); border: 0; background: transparent; color: var(--brand-dark); font: inherit; font-size: .85rem; font-weight: 600; padding: .35rem .55rem; border-radius: var(--radius-sm); cursor: pointer; }
.pw-toggle:hover { background: var(--brand-soft); }
.pw-icon { display: inline-flex; align-items: center; padding: .35rem; }
.pw-icon .icon { width: 20px; height: 20px; }
.pw-icon .pw-off, .pw-icon[data-shown="true"] .pw-on { display: none; }
.pw-icon[data-shown="true"] .pw-off { display: inline-flex; }
.pw-wrap:has(.pw-icon) input { padding-right: 3rem; }
.pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.next-steps { margin: 0 0 1.2rem; padding-left: 1.25rem; }
.next-steps li { margin: .15rem 0; }

.get-started { padding: 28px; border-color: var(--brand-line); background: linear-gradient(135deg, var(--card) 60%, var(--brand-soft)); }
.get-started h2 { margin-bottom: .3em; }
.gs-steps { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; gap: 1.1rem; }
.gs-step { display: grid; grid-template-columns: 36px 1fr; gap: .9rem; align-items: start; }
.gs-step h3 { margin: 0 0 .15em; font-size: 1.05rem; }
.gs-step p { margin: 0 0 .6rem; }
.gs-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--line); color: var(--ink); }
.gs-step.current .gs-num { background: var(--brand); color: #fff; }
.gs-hint { margin-left: .6rem; }

.setup-nudge { margin-bottom: 24px; }
.check-list { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .15rem; }
.check-list a { display: flex; align-items: center; gap: .6rem; padding: .45rem .5rem; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.check-list a:hover { background: var(--surface-2); text-decoration: none; }
.check-list .done .icon { color: var(--ok); }
.check-list .todo .icon { color: var(--muted); }

.ext-install h3 { font-size: 1.05rem; }
.ext-install .ext-actions { margin: .4rem 0 1rem; }
.ext-steps { margin: 0; padding-left: 1.25rem; }
.ext-steps li { margin: .35rem 0; }
.ext-install code, .ext-steps code { background: var(--brand-soft); padding: .1rem .4rem; border-radius: 6px; }

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.error-actions { margin-top: 1.4rem; }
.filter-form select { width: auto; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .get-started { padding: 20px; }
}
/* Standalone text links used as actions (not links inside a sentence) */
.row.between > a, .setup-nudge a.small, nav.small > a { display: inline-flex; align-items: center; min-height: 36px; }
@media (max-width: 640px) {
  .btn, .btn.sm, .icon-btn, .side-link, .pw-toggle, .chip-add, .conn-menu a, .how > summary { min-height: 40px; }
  /* Plain text links used as actions ("All tools", "Open Connections") */
  .icon-btn { min-width: 40px; }
  .filter-form { width: 100%; }
  .filter-form input[type=search], .filter-form select, .filter-form .btn { width: 100% !important; }
  .pager { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .gs-hint { display: block; margin: .5rem 0 0; }
}

/* ==========================================================================
   Mobile pass: no sideways scroll, readable type, comfortable tap targets
   ========================================================================== */
html, body { overflow-x: clip; }
img, svg, video { max-width: 100%; }
.main, .container, .card, .sec, .panel { min-width: 0; }
.token-box { flex-wrap: wrap; }
.site-nav .nav-login { padding: .35rem 0; }

@media (max-width: 860px) {
  .grid-3.aside-right, .grid-3.aside-left { grid-template-columns: 1fr; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .site-nav a { display: block; padding: .7rem 0; }
  .sidebar { width: min(268px, 86vw); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .site-footer .container { flex-direction: column; }
  .cta-band { padding: 40px 20px; border-radius: 16px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; }
  .container { padding: 0 16px; }
  .card { padding: 18px; }
  .hero { padding: 40px 0 36px; }
  .hero p.lead { font-size: 1.05rem; }
  .hero .row { flex-direction: column; align-items: stretch; }
  .hero .row .btn { width: 100%; }
  .section { padding: 36px 0; }
  .section-head { margin-bottom: 1.5rem; }
  /* 16px inputs: iOS Safari zooms the page when a smaller field gets focus */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea { font-size: 16px; min-height: 44px; }
  .pw-wrap input { padding-right: 4.6rem; }
  .row.between > .btn, .page-head.row > .btn { width: 100%; }
  .dialog { width: calc(100vw - 24px); }
  .dialog-foot { flex-direction: column-reverse; }
  .dialog-foot .btn { width: 100%; }
  .site-header .container { gap: .5rem; padding: 0 12px; }
  .site-actions { gap: .3rem; }
  .site-actions .btn.sm { padding: .35rem .6rem; }
  .brand { font-size: 1rem; gap: .45rem; }
  .toasts { left: 12px; right: 12px; }
    .stat .num { font-size: 1.5rem; }
  td, th { padding-inline: .65rem; }
  .menu-list { min-width: min(190px, calc(100vw - 32px)); }
}
@media (max-width: 400px) {
  .site-actions .btn.ghost:not(.menu-toggle) { display: none; }
  .site-nav .nav-login { display: block; border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .9rem; }
}

/* ---- Replaces inline styles in the workspace templates ---- */
.stat .num.num-sm { font-size: 1.2rem; }
.num-unit { font-size: 1rem; }
.stat-value-wrap { margin-top: .4rem; overflow-wrap: anywhere; }
.card-title-sm { margin: 0; font-size: 1.1rem; }
.section-head { margin-bottom: 1rem; }
.section-head h2, .section-title { margin: 0; }
.section-title { margin: 1.5rem 0 1rem; }
.page-head-tool { margin-top: .8rem; flex-wrap: nowrap; align-items: flex-start; }
.h1-tight { margin-bottom: .1em; }
.mb-card { margin-bottom: 1.25rem; }
.mt-form { margin-top: 1rem; }
.check-progress { width: 100%; height: 8px; margin: 10px 0 4px; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); accent-color: var(--brand); }
.check-progress::-webkit-progress-bar { background: var(--line); }
.check-progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.check-progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.recent-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
#recent-runs { margin-bottom: 24px; }
.btn-block { width: 100%; }
.mt-lg { margin-top: 1.2rem; }
.m-0 { margin: 0; }
.mb-sm { margin-bottom: .4rem; }

/* Admin: customer detail page */
.inline-form { display: inline; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }
.ud-head { display: flex; gap: 1rem; align-items: center; }
.ud-id { min-width: 0; overflow-wrap: anywhere; }
.ud-id h2 { margin: 0 0 .1em; font-size: 1.25rem; }
.ud-badges { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.ud-more { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.ud-more summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; font-size: .9rem; margin-bottom: .6rem; }
.ud-more input[type=email] { flex: 1 1 12rem; min-width: 0; }
.ud-danger { border-color: #fecaca; }
.form-grid .span-all { grid-column: 1 / -1; }


/* ==========================================================================
   Utilities (replace one-off inline styles in the templates)
   ========================================================================== */
.u-center { justify-content: center; } .u-fs-lg { font-size: 1.6rem; } .u-w-auto { width: auto; } .u-w-full { width: 100%; } .u-w-260 { width: 260px; max-width: 100%; }
.u-p0 { padding: 0; } .u-p-3 { padding: 12px; } .u-pt-0 { padding-top: 0; } .u-m-0 { margin: 0; } .u-ml-0 { margin-left: 0; }
.u-mt-0 { margin-top: 0; } .u-mt-1 { margin-top: .4rem; } .u-mt-3 { margin-top: var(--sp-3); } .u-mt-4 { margin-top: 1rem; } .u-mt-5 { margin-top: 1.5rem; } .u-mt-6 { margin-top: 2rem; }
.u-mb-1 { margin-bottom: .4rem; } .u-mb-02 { margin-bottom: .2em; } .u-mb-3 { margin-bottom: 12px; } .u-mb-4 { margin-bottom: 1rem; }
.u-mw-560 { max-width: 560px; } .u-mw-680 { max-width: 680px; } .u-mw-720 { max-width: 720px; } .u-mw-860 { max-width: 860px; }
.u-inline { display: inline; } .u-text-left { text-align: left; } .u-self-start { align-self: flex-start; } .u-gap-1 { gap: .4rem; }
.u-top-nowrap { align-items: flex-start; flex-wrap: nowrap; }

/* Admin → Google access: the "List an address" form (fields and button share one baseline) */
.list-address { align-items: end; margin-top: var(--sp-3); }
.list-address .list-address-btn { margin-bottom: 1rem; }
@media (max-width: 640px) { .list-address .list-address-btn .btn { width: 100%; } }

/* Team page and member notices */
.temp-pw { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.temp-pw code { font-size: 1.05rem; padding: .25rem .6rem; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--line-strong); user-select: all; }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; }
.row-actions form { margin: 0; }
.notice-card { text-align: left; }
.tools-row td { padding-top: 0; border-top: 0; }
.tools-form { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin: 0; }
.tools-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.tools-form legend { padding: 0; margin-bottom: .3rem; }
.check-inline { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }

/* Admin lists: keep them usable on a phone */
@media (max-width: 640px) {
  .filter-form { flex-wrap: wrap; width: 100%; }
  .filter-form input, .filter-form select { width: 100%; max-width: 100%; }
  .hide-sm { display: none; }
  /* .table-stack: each row becomes a small card; the last cell (the action) sits beside the first */
  .table-stack thead { display: none; }
  .table-stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: .75rem 0; border-bottom: 1px solid var(--line); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { display: block; padding: 0; border: 0; grid-column: 1; }
  .table-stack td:last-child { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .table-stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  th, td { padding-left: .6rem; padding-right: .6rem; }
  .menu-toggle { min-width: 44px; min-height: 44px; }
}

/* Prompt lists (AI prompts tool and portal pages share these states) */
.loading-hint { color: var(--muted); font-style: italic; }

/* ==========================================================================
   Dark mode (portal pages only: the hosted tools keep their light theme)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :where(:root:not([data-theme="light"])) a { color: #a5b4fc; }
  :where(:root:not([data-theme="light"])) .btn.primary, :where(:root:not([data-theme="light"])) .btn.primary:hover { color: #fff; }
  :where(:root:not([data-theme="light"])) .badge.brand { color: #c7d2fe; }
  :where(:root:not([data-theme="light"])) .alert.success { background: #052e16; border-color: #166534; color: #bbf7d0; }
  :where(:root:not([data-theme="light"])) .alert.error { background: #3b0d0d; border-color: #7f1d1d; color: #fecaca; }
  :where(:root:not([data-theme="light"])) .alert.info { background: var(--brand-soft); border-color: var(--brand-line); color: #c7d2fe; }
  :where(:root:not([data-theme="light"])) .alert.warn { background: #3b2a05; border-color: #78350f; color: #fde68a; }
  :where(:root:not([data-theme="light"])) .section.alt, :where(:root:not([data-theme="light"])) .site-footer, :where(:root:not([data-theme="light"])) .sidebar { background: var(--card); }
  :where(:root:not([data-theme="light"])) .gcard.warn { background: #3b2a05; border-color: #78350f; }
  :where(:root:not([data-theme="light"])) .notice { color: #fde68a; border-color: #78350f; }
  :where(:root:not([data-theme="light"])) .notice.info { color: #c7d2fe; border-color: var(--brand-line); }
  :where(:root:not([data-theme="light"])) .how-body { color: #c7d2fe; border-color: var(--brand-line); }
  :where(:root:not([data-theme="light"])) .btn.danger { border-color: #7f1d1d; }
  :where(:root:not([data-theme="light"])) .chip-add { border-color: var(--brand-line); }
  :where(:root:not([data-theme="light"])) .sec.attention { border-color: #78350f; }
  :where(:root:not([data-theme="light"])) .ud-danger { border-color: #7f1d1d; }
  :where(:root:not([data-theme="light"])) .toast.error { background: #3b0d0d; }
}
:where(:root[data-theme="dark"]) a { color: #a5b4fc; }
:where(:root[data-theme="dark"]) .btn.primary, :root[data-theme="dark"] .btn.primary:hover { color: #fff; }
:where(:root[data-theme="dark"]) .badge.brand { color: #c7d2fe; }
:where(:root[data-theme="dark"]) .alert.success { background: #052e16; border-color: #166534; color: #bbf7d0; }
:where(:root[data-theme="dark"]) .alert.error { background: #3b0d0d; border-color: #7f1d1d; color: #fecaca; }
:where(:root[data-theme="dark"]) .alert.info { background: var(--brand-soft); border-color: var(--brand-line); color: #c7d2fe; }
:where(:root[data-theme="dark"]) .alert.warn { background: #3b2a05; border-color: #78350f; color: #fde68a; }
:where(:root[data-theme="dark"]) .section.alt, :root[data-theme="dark"] .site-footer, :root[data-theme="dark"] .sidebar { background: var(--card); }

/* Theme switch (static/js/theme.js): Auto / Light / Dark */
.theme-switch { display: inline-flex; align-items: center; gap: .45rem; width: 100%; }
.theme-switch .theme-label { font-weight: 600; }
.site-actions .theme-switch { width: auto; }
:where(:root[data-theme="dark"]) .gcard.warn { background: #3b2a05; border-color: #78350f; }
:where(:root[data-theme="dark"]) .notice { color: #fde68a; border-color: #78350f; }
:where(:root[data-theme="dark"]) .notice.info { color: #c7d2fe; border-color: var(--brand-line); }
:where(:root[data-theme="dark"]) .how-body { color: #c7d2fe; border-color: var(--brand-line); }
:where(:root[data-theme="dark"]) .btn.danger { border-color: #7f1d1d; }
:where(:root[data-theme="dark"]) .chip-add { border-color: var(--brand-line); }
:where(:root[data-theme="dark"]) .sec.attention { border-color: #78350f; }
:where(:root[data-theme="dark"]) .ud-danger { border-color: #7f1d1d; }
:where(:root[data-theme="dark"]) .toast.error { background: #3b0d0d; }
.plan-line { margin: 1.5rem 0 0; }
.more-settings { margin-top: var(--sp-4, 1.5rem); }
.more-settings > summary { display: flex; align-items: center; gap: .5rem; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--brand-dark); list-style: none; }
.more-settings > summary::-webkit-details-marker { display: none; }
.more-settings > summary .chev { transition: transform var(--ease); display: inline-flex; }
.more-settings[open] > summary .chev { transform: rotate(90deg); }
.more-settings > .sec { margin-top: var(--sp-4, 1.5rem); }
.team-links { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; }
.verify-resend { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin: 0; }
.rec-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 12px; }
.rec-list { margin: 0; padding-left: 1.1rem; line-height: 1.7; }
tr.row-dup { background: var(--bad-soft); } tr.row-warn { background: var(--warn-soft); }
.sec-tile.sec-tile-warn { background: var(--warn-soft); color: var(--warn); }

/* Touch targets: checkbox rows and summaries get a 40px hit area on phones (the .btn/.side-link rules above already do). */
@media (max-width: 640px) {
  .check, .check-inline, .ud-more summary, .team-links a { min-height: 40px; align-items: center; }
  .ud-more summary { display: flex; }
  .team-links a { display: inline-flex; }
  .check input, .check-inline input { width: 20px; height: 20px; margin-top: 0; flex: none; }
}
