@import url('/css/theme.css');

/* ── AgenticFrontDesk Portal CSS ─────────────────────────────────────────────
   Shared across every website/portal/*.html page. Nav bar and footer markup
   itself is no longer duplicated per page — portal-nav.js injects both into
   `#portal-nav-root`/`#portal-footer-root` (2026-08-10) — but the classes
   here (.nav-*, .portal-footer, .btn-signout, etc.) still style them.
   ─────────────────────────────────────────────────────────────────────────── */

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Base ── */
body {
    font-family: 'Outfit', sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* This UI is always light regardless of OS/browser theme. Without this,
       a browser/OS set to dark mode can auto-darken native <select> dropdown
       popups while our text stays dark, making options invisible until the
       hover highlight lightens a row (same bug fixed in dashboard.css). */
    color-scheme: light;
}

/* ── Navigation ── */
nav {
    background: var(--portal-surface);
    border-bottom: 1px solid var(--portal-border);
    padding: 8px 24px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* The tab list has grown page over page (10+ top-level links/groups now) —
       wrap onto a second row instead of forcing the whole page wider than the
       viewport. `nav` is a flex item of `body` (flex column), and a flex
       item's default min-width:auto means it won't shrink below its content's
       natural width just because of the border-box's own bounds — without
       min-width:0 here, an overflowing nav drags the entire page into
       horizontal overflow, cutting off content well past the nav bar too
       (that's what was reported as "the analytics table is cut off" — it was
       actually the whole page being pushed wide by the nav, not the table's
       own scroll failing). */
    flex-wrap: wrap;
    row-gap: 8px;
    min-width: 0;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.nav-logo-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo-icon svg {
    width: 14px;
    height: 14px;
    color: var(--portal-surface);
}

.nav-brand {
    font-size: 1rem;
    font-weight: 700;
    color: var(--portal-text-primary);
}

.nav-brand span {
    color: var(--portal-accent);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    row-gap: 8px;
}

.nav-links {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    row-gap: 4px;
}

.nav-links a {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--portal-text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    background: #f3f4f6;
    color: var(--portal-text-primary);
}

.nav-links a.active {
    font-weight: 600;
}

/* ── Nav dropdown group (e.g. "Clinical" → Clinical Notes/Staff/Setup) ── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-trigger {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--portal-text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-family: inherit;
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}

.nav-dropdown-trigger:hover,
.nav-dropdown-trigger.active {
    background: #f3f4f6;
    color: var(--portal-text-primary);
}

.nav-dropdown-trigger.active {
    font-weight: 600;
}

.nav-dropdown-caret {
    font-size: 0.6rem;
    opacity: 0.6;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    box-shadow: var(--shadow-portal-card);
    min-width: 170px;
    padding: 6px;
    z-index: 50;
}

/* Invisible bridge across the 4px gap between the trigger and the menu — the
   menu is `position:absolute` so the parent `.nav-dropdown`'s hover box ends
   at the trigger; without this the cursor loses `:hover` crossing the gap and
   the menu closes before a child can be clicked. */
.nav-dropdown-menu::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -6px;
    height: 6px;
}

.nav-dropdown-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--portal-text-secondary);
    text-decoration: none;
    font-weight: 500;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
    background: #f3f4f6;
    color: var(--portal-text-primary);
}

.nav-dropdown-menu a.active {
    font-weight: 600;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

.btn-signout {
    font-size: 0.8rem;
    color: var(--portal-text-muted);
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
}

.btn-signout:hover {
    color: var(--portal-text-secondary);
    background: #f3f4f6;
}

.nav-tenant {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Footer ── */
.portal-footer {
    margin-top: auto;
    padding: 20px 24px;
    border-top: 1px solid var(--portal-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    row-gap: 6px;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--portal-text-muted);
}

.portal-footer a {
    color: var(--portal-text-muted);
    text-decoration: none;
}

.portal-footer a:hover {
    color: var(--portal-text-secondary);
}

.portal-footer-sep {
    opacity: 0.5;
}

/* ── Layout ── */
main {
    max-width: 780px;
    margin: 0 auto;
    padding: 40px 24px;
    width: 100%;
    /* Same flex-item min-width:auto issue as nav above — without this, a wide
       child (e.g. analytics.html's summary table) stretches main past its own
       max-width instead of scrolling inside .table-scroll. */
    min-width: 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 28px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: opacity 0.15s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary {
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    color: var(--portal-surface);
}

.btn-outline {
    background: var(--portal-surface);
    color: var(--portal-text-secondary);
    border: 1.5px solid #d1d5db;
}

.btn-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ── Alerts ── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    margin-top: 14px;
    display: none;
}

.alert.err {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

.alert.ok {
    background: #f0fdf4;
    color: #065f46;
    border: 1px solid #bbf7d0;
    display: block;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

/* ── Chips ── */
.chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 99px;
    white-space: nowrap;
}

.chip-ok      { background: #d1fae5; color: #065f46; }
.chip-wait    { background: #dbeafe; color: #1e40af; }
.chip-warn    { background: #fef3c7; color: #92400e; }
.chip-err     { background: #fee2e2; color: #991b1b; }
.chip-revoked { background: #f3f4f6; color: #6b7280; }
.chip-owner   { background: #ede9fe; color: #5b21b6; }

/* ── Status badges (home page) ── */
.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
}

.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err  { background: #fee2e2; color: #991b1b; }
.badge-wait { background: #dbeafe; color: #1e40af; }

/* ── Actions row ── */
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Loading skeleton ── */
.skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, var(--portal-border) 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
    height: 16px;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-rows {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.skeleton-row {
    height: 14px;
    border-radius: 4px;
}

.skeleton-row.sk-w-70 { width: 70%; }
.skeleton-row.sk-w-65 { width: 65%; }
.skeleton-row.sk-w-55 { width: 55%; }
.skeleton-row.sk-w-50 { width: 50%; }

/* ── Utilities ── */
.portal-hidden {
    display: none !important;
}

.text-muted {
    font-weight: 400;
    color: var(--portal-text-muted);
}

.link-blue {
    color: var(--portal-accent);
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--portal-accent);
    cursor: pointer;
    text-align: left;
}
.btn-link:hover {
    text-decoration: underline;
}

.error-text {
    color: #991b1b;
    font-size: 0.85rem;
}


/* ── Shared Components ── */

.page-subtitle {
    color: var(--portal-text-secondary);
    font-size: 0.85rem;
    margin-bottom: 20px;
}

.card-intro {
    color: var(--portal-text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.stat-card-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.stat-card {
    flex: 1;
    min-width: 140px;
    padding: 14px 18px;
}

.stat-card-label {
    font-size: 0.75rem;
    color: var(--portal-text-secondary);
}

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 600;
}

.pagination-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
}

.details-view {
    font-size: 0.85rem;
    color: var(--portal-text-secondary);
    white-space: pre-wrap;
}

.optional-hint {
    font-weight: 400;
    color: #6b7280;
}

.btn-full-width { width: 100%; }
.btn-list-item { width: 100%; margin-bottom: 8px; text-align: left; }

.field-tight { margin-bottom: 12px; }
.field-narrow { max-width: 280px; }
.input-followup { margin-top: 8px; }
.page-header-tight { margin-bottom: 14px; }
.card-section { margin-top: 24px; }
.table-card { margin-top: 16px; }

.settings-category { margin-bottom: 20px; }
.settings-category-title { margin: 0 0 12px 0; font-size: 1rem; }
.settings-category-title.title-compact { margin: 0 0 4px 0; }

/* Settings renders one <table> per category (General / AI & Call Behavior /
   Automation & Scheduling) instead of one shared table. Left to auto layout,
   each table sizes its own columns independently from just its own rows, so
   a category with only short rows (e.g. "Safe Mode: Off") ends up with wildly
   different column widths than one with a long value (the Welcome Message
   text) — the Value column visually starts at a different x-position in
   every section. Fixed proportional widths make every category's columns
   line up consistently regardless of that table's own content. */
.settings-category table {
    table-layout: fixed;
}
.settings-category th:first-child,
.settings-category td:first-child {
    width: 25%;
}
.settings-category th:last-child,
.settings-category td:last-child {
    width: 90px;
}


/* ════════════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════════════════════ */
body.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-page .card {
    background: var(--portal-surface);
    border-radius: 20px;
    padding: 48px 44px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.login-page .logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    margin-bottom: 32px;
}

.login-page .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-page .logo-icon svg {
    width: 18px;
    height: 18px;
    color: var(--portal-surface);
}

.login-page .logo-icon.logo-icon-image {
    background: none;
    width: 44px;
    height: 44px;
}

.login-page .logo-icon-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-page .logo-text {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--portal-text-primary);
}

.login-page .logo-text span {
    color: var(--portal-accent);
}

.login-page .logo-sub {
    font-size: 0.65rem;
    color: var(--portal-text-muted);
    font-weight: 400;
}

.logo-text-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: left;
}

.login-page h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--portal-text-primary);
    margin-bottom: 8px;
}

.login-page .subtitle {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 36px;
    line-height: 1.5;
}

.login-page .subtitle-tight {
    margin-bottom: 12px;
}

.alert-error-link {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
}

.login-page .divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    color: var(--portal-text-muted);
    font-size: 0.8rem;
}

.login-page .divider::before,
.login-page .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--portal-border);
}

.g-signin-btn {
    display: flex;
    justify-content: center;
}

.login-page .footer {
    margin-top: 32px;
    font-size: 0.78rem;
    color: var(--portal-text-muted);
}

.login-page .footer a {
    color: var(--portal-accent);
    text-decoration: none;
}

.login-page .footer-mt {
    margin-top: 8px;
}


/* ════════════════════════════════════════════════════════════════════════════
   HOME PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.page-home .page-header {
    margin-bottom: 28px;
}

.page-home .page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
}

.page-home .page-header .sub {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 4px;
}

.status-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}

.status-card h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--portal-text-secondary);
}

.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

.status-row:last-child {
    border-bottom: none;
}

.page-home .status-icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.page-home .status-label {
    flex: 1;
    color: var(--portal-text-secondary);
}

.page-home .actions {
    gap: 12px;
    margin-top: 8px;
}

.info-strip {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 16px 20px;
    font-size: 0.85rem;
    color: #0369a1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
}

.info-strip svg {
    flex-shrink: 0;
    margin-top: 1px;
}


/* ════════════════════════════════════════════════════════════════════════════
   COMPLIANCE PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.section {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 20px;
}

.section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
    margin-bottom: 16px;
}

.row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.page-compliance .status-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.page-compliance .status-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--portal-text-primary);
    margin-bottom: 4px;
}

.status-desc {
    font-size: 0.83rem;
    color: #6b7280;
    line-height: 1.5;
}

.page-compliance .chip {
    margin-top: 6px;
}

.phone-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phone-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--portal-text-primary);
    letter-spacing: 0.5px;
}

.phone-sub {
    font-size: 0.82rem;
    color: var(--portal-text-muted);
}

.support-note {
    margin-top: 20px;
    padding: 14px 18px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    font-size: 0.83rem;
    color: #6b7280;
}

.support-note a {
    color: var(--portal-accent);
    text-decoration: none;
}


/* ════════════════════════════════════════════════════════════════════════════
   ADD-ONS PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.addon-card {
    background: var(--portal-surface);
    border: 1.5px solid var(--portal-border);
    border-radius: 18px;
    padding: 28px;
    display: flex;
    gap: 22px;
    align-items: flex-start;
}

.addon-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #ede9fe, #dbeafe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.addon-body {
    flex: 1;
}

.addon-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--portal-text-primary);
    margin-bottom: 4px;
}

.addon-price {
    font-size: 0.82rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.addon-desc {
    font-size: 0.875rem;
    color: var(--portal-text-secondary);
    line-height: 1.6;
    margin-bottom: 18px;
}

.addon-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.status-text {
    font-size: 0.82rem;
    color: var(--portal-text-muted);
}

.status-text.on  { color: #059669; font-weight: 600; }
.status-text.off { color: var(--portal-text-muted); }

.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
}

.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 99px;
    transition: background 0.2s;
}

.toggle input:checked + .toggle-track {
    background: var(--portal-accent);
}

.toggle-thumb {
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--portal-surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.toggle input:checked ~ .toggle-thumb {
    transform: translateX(22px);
}

.toggle.disabled {
    opacity: 0.45;
    pointer-events: none;
}

.plan-gate {
    background: #fafafa;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.82rem;
    color: #6b7280;
    margin-top: 12px;
}

.plan-gate strong {
    color: var(--portal-text-secondary);
}


/* ════════════════════════════════════════════════════════════════════════════
   STAFF PAGE
   ════════════════════════════════════════════════════════════════════════════ */
.page-staff .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-staff .page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
}

.btn-invite {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    color: var(--portal-surface);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.btn-invite:hover {
    opacity: 0.88;
}

.btn-invite:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-invite:disabled:hover {
    opacity: 0.5;
}

.page-staff .card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    overflow: hidden;
}

.user-row {
    display: flex;
    align-items: center;
    padding: 16px 22px;
    border-bottom: 1px solid #f3f4f6;
    gap: 14px;
}

.user-row:last-child {
    border-bottom: none;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--portal-surface);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--portal-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.78rem;
    color: var(--portal-text-muted);
}

.page-staff .chip {
    font-size: 0.72rem;
    padding: 2px 8px;
}

.user-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-revoke,
.btn-restore {
    font-size: 0.78rem;
    padding: 5px 10px;
    border-radius: 7px;
    border: 1.5px solid #d1d5db;
    background: var(--portal-surface);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: 0.15s;
}

.btn-revoke:hover  { border-color: #f87171; color: #b91c1c; background: #fef2f2; }
.btn-restore:hover { border-color: var(--portal-accent); color: var(--portal-accent); background: #eff6ff; }

.resend-link {
    font-size: 0.75rem;
    color: var(--portal-accent);
    cursor: pointer;
    text-decoration: underline;
    white-space: nowrap;
}

.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--portal-text-muted);
    font-size: 0.88rem;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.overlay.open {
    display: flex;
}

.modal {
    background: var(--portal-surface);
    border-radius: 18px;
    padding: 32px 30px;
    max-width: 420px;
    width: 100%;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* Opt-in modifier for forms with many fields (Business Setup, CRM) — lays
   fields out two-up instead of one long single-column scroll. */
.modal-wide {
    max-width: 720px;
}

.modal-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.modal-fields-grid .field {
    min-width: 0;
}

/* Fields that read better spanning the full width (addresses, free-text notes). */
.field-wide {
    grid-column: 1 / -1;
}

@media (max-width: 640px) {
    .modal-fields-grid {
        grid-template-columns: 1fr;
    }
}

.modal h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
    margin-bottom: 5px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--portal-accent);
}

.field .hint {
    font-size: 0.75rem;
    color: var(--portal-text-muted);
    margin-top: 4px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-cancel {
    padding: 9px 18px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    background: var(--portal-surface);
    font-family: inherit;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-send {
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--portal-accent), #7c3aed);
    color: var(--portal-surface);
    font-family: inherit;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
}

.btn-send:disabled {
    opacity: 0.6;
    pointer-events: none;
}


.sa-box {
    margin: 14px 0;
    padding: 10px 14px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--portal-text-secondary);
    font-family: monospace;
    word-break: break-all;
}

/* ════════════════════════════════════════════════════════════════════════════
   DATA CRUD PAGES (§0.75.2) — settings, business-setup, business-knowledge,
   blacklist-waitlist, crm. Shared across all five via .page-data-crud.
   ════════════════════════════════════════════════════════════════════════════ */

.page-data-crud main {
    /* Fluid, not a fixed cap — 2026-08-13, user request: these pages are
       mostly wide data tables (analytics.html's 12-column summary/call-log
       being the worst case), and a fixed 1100px cap forced every one of them
       into .table-scroll's horizontal scroll well before the actual browser
       window ran out of room. Now fills whatever width is actually
       available; .table-scroll's overflow-x:auto (below) still kicks in as
       the fallback once a table is wider than even the full viewport (e.g.
       a narrow laptop screen), so nothing is ever hard-clipped either way. */
    max-width: 100%;
}

.page-data-crud .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-data-crud .page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0;
}

.page-data-crud .tab-strip {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--portal-border);
}

.page-data-crud .tab-strip button {
    padding: 10px 16px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--portal-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.page-data-crud .tab-strip button.active {
    color: var(--portal-accent);
    border-bottom-color: var(--portal-accent);
}

.page-data-crud .card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
}

.page-data-crud .table-scroll {
    overflow-x: auto;
}

.page-data-crud table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.page-data-crud th {
    text-align: left;
    padding: 12px 16px;
    background: #f9fafb;
    color: var(--portal-text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 1px solid var(--portal-border);
}

.page-data-crud td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--portal-border);
    vertical-align: middle;
}

.page-data-crud tr:last-child td {
    border-bottom: none;
}

.page-data-crud td:has(.btn-icon) {
    text-align: right;
}

.page-data-crud .row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    white-space: nowrap;
}

.page-data-crud .btn-icon {
    padding: 5px 10px;
    border-radius: 7px;
    border: 1.5px solid #d1d5db;
    background: var(--portal-surface);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--portal-text-secondary);
}

.page-data-crud .btn-icon:hover {
    border-color: var(--portal-accent);
    color: var(--portal-accent);
    background: #eff6ff;
}

.page-data-crud .btn-icon.danger:hover {
    border-color: #f87171;
    color: #b91c1c;
    background: #fef2f2;
}

.page-data-crud .empty-state {
    padding: 40px 24px;
    text-align: center;
    color: var(--portal-text-muted);
    font-size: 0.875rem;
}

.page-data-crud .inline-editable {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
}

.page-data-crud .inline-editable:hover {
    border-bottom-color: var(--portal-accent);
}

.page-data-crud .search-bar {
    margin-bottom: 16px;
    max-width: 320px;
}

.page-data-crud .search-bar input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
}

/* Copy that depends on an optional price (currency.js toggles .is-available) */
[data-needs]:not(.is-available) { display: none; }

/* Products page — "Set up the AI Front Desk" form */
#front-desk-form { margin-top: 16px; display: grid; gap: 8px; max-width: 520px; }
#front-desk-form.portal-hidden { display: none; }
#front-desk-form input:not([type=checkbox]), #front-desk-form select {
    width: 100%; padding: 8px 10px; border: 1px solid var(--portal-border, #e5e7eb);
    border-radius: 8px; font: inherit; box-sizing: border-box;
}
