/*
 * Portal redesign: shared tokens and app shell.
 * Pages opt in by using includes/portal-shell.php instead of css/landing.css.
 * Source of truth for the look: the "Newsie Agreements Portal Redesign" canvas.
 */
:root {
    color-scheme: light;

    /* Brand */
    --brand-orange: #F1552C;
    --brand-orange-ink: #A8361A;
    --brand-orange-tint: #FDE3DA;
    --primary: #0B57E3;
    --primary-hover: #0841A8;
    --primary-tint: #E8F0FF;
    --footer: #C9401A;

    /* Neutrals */
    --bg: #F4F7FC;
    --surface: #FFFFFF;
    --text: #1B1D2A;
    --text-muted: #5B6275;
    --border: #E3E7F0;
    --border-strong: #C9CEDB;
    --rule: #EDF0F6;

    /* Signals */
    --alert: #D0281C;
    --danger-ink: #B42318;
    --ok-ink: #0B6B47;
    --ok-tint: #DDF5EA;
    --warn-ink: #8A4B00;
    --warn-tint: #FFF0D6;
    --info-ink: #1D4F7C;
    --info-tint: #E6F0FB;
    --neutral-ink: #5B6275;
    --neutral-tint: #EDF0F6;

    /* Type */
    --font-ui: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-agreement: "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-signature: "Caveat", "Segoe Script", cursive;

    --radius-card: 14px;
    --radius-control: 8px;
    --shadow-card: 0 2px 10px rgba(27, 29, 42, 0.06);
    --shadow-menu: 0 8px 28px rgba(27, 29, 42, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
.portal [hidden] { display: none !important; }

body.portal {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--bg);
}
.portal a { color: var(--primary); }
.portal a:hover { color: var(--primary-hover); }

.agreement-text { font-family: var(--font-agreement); }
.signature-text { font-family: var(--font-signature); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

/* ---------- Shell ---------- */
.portal-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal-header {
    background: var(--surface);
    box-shadow: 0 1px 0 var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 32px;
    flex-wrap: wrap;
}
.portal-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
}
.portal-brand img { width: 120px; height: auto; display: block; }
/* Text stand-in until the logo files are added to the repo. */
.portal-wordmark {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand-orange);
}
.portal-brand-product {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-left: 1px solid var(--border);
    padding-left: 16px;
}
.portal-header-tools {
    display: flex;
    align-items: center;
    gap: 16px;
}

.portal-bell {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
}
.portal .portal-bell { color: var(--text-muted); }
.portal-bell:hover { background: var(--bg); }
.portal-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--alert);
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.portal-bell .portal-count { position: absolute; top: 6px; right: 6px; }

/* Account menu */
.account-menu { position: relative; }
.account-menu > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 4px 10px 4px 4px;
    border-radius: 26px;
    cursor: pointer;
    background: var(--bg);
}
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.account-avatar {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: var(--brand-orange-tint);
    color: var(--brand-orange-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex: none;
}
.account-who { display: flex; flex-direction: column; }
.account-name { font-size: 15px; font-weight: 600; }
.account-role { font-size: 12px; color: var(--text-muted); }
.account-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 20;
    min-width: 220px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-menu);
    padding: 8px;
    display: flex;
    flex-direction: column;
}
.portal .account-menu-panel a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
}
.portal .account-menu-panel a:hover,
.portal .account-menu-panel a:focus-visible { background: var(--bg); }
.portal .account-menu-panel a.account-signout { color: var(--danger-ink); font-weight: 600; }
.account-menu-sep { height: 1px; background: var(--rule); margin: 6px 0; }

.portal-body {
    display: flex;
    flex-wrap: wrap;
    flex: 1;
}

.portal-nav {
    flex: 1 1 264px;
    max-width: 280px;
    background: var(--surface);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.portal .portal-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.portal-nav a svg { color: var(--primary); flex: none; }
.portal .portal-nav a:hover { background: var(--bg); }
.portal .portal-nav a[aria-current="page"] {
    background: var(--primary-tint);
    color: var(--primary);
    font-weight: 600;
    box-shadow: inset 4px 0 0 var(--primary);
}
.portal-nav .portal-count {
    margin-left: auto;
    min-width: 24px;
    height: 22px;
    border-radius: 11px;
    font-size: 12px;
}

.portal-main {
    flex: 999 1 560px;
    min-width: 0;
    padding: 40px 48px 64px;
}
.portal-content {
    max-width: 1080px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.portal-footer {
    background: var(--footer);
    color: #FFFFFF;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.portal-footer img { width: 160px; height: auto; }
.portal-footer .portal-wordmark { color: #FFFFFF; font-size: 32px; }
.portal-footer p {
    margin: 0;
    font-size: 13px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.portal .portal-footer a { color: #FFFFFF; }

/* Admin viewing a member's pages */
.preview-bar {
    background: var(--text);
    color: #FFFFFF;
    padding: 10px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 14px;
}
.portal .preview-bar a { color: #FFFFFF; font-weight: 600; }

/* ---------- Building blocks ---------- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.page-head-who { display: flex; align-items: center; gap: 16px; }
.page-head h1 { margin: 0; font-size: 32px; font-weight: 600; }
.page-head p { margin: 4px 0 0; font-size: 15px; color: var(--text-muted); }
.page-head .account-avatar { width: 56px; height: 56px; border-radius: 28px; font-size: 20px; }

.card {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.card h2 { margin: 0; font-size: 20px; font-weight: 600; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.card-note { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 28px;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.portal .btn-primary { background: var(--primary); color: #FFFFFF; }
.portal .btn-primary:hover { background: var(--primary-hover); color: #FFFFFF; }
.portal .btn-secondary {
    min-height: 44px;
    padding: 0 18px;
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
    font-size: 14px;
}
.portal .btn-secondary:hover { background: var(--bg); color: var(--text); }
.btn-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}
.btn-link:hover { color: var(--primary-hover); }

/* Action-needed banner */
.action-card {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border-top: 6px solid var(--brand-orange);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
    padding: 28px 32px;
}
.action-card.is-info { border-top-color: var(--primary); }
.action-card-body { flex: 1 1 420px; display: flex; flex-direction: column; gap: 8px; }
.action-eyebrow {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brand-orange-ink);
}
.action-card.is-info .action-eyebrow { color: var(--primary); }
.action-card h2 { margin: 0; font-size: 22px; font-weight: 600; }
.action-card p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--text-muted); }
.action-card .action-warning { color: var(--danger-ink); font-size: 14px; }
.action-card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.action-card-actions form { margin: 0; }
.action-fineprint { font-size: 12px; color: var(--text-muted); max-width: 280px; text-align: right; }

.reject-disclosure { width: 100%; font-size: 14px; }
.reject-disclosure summary { cursor: pointer; color: var(--text-muted); }
.reject-disclosure form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.reject-disclosure label { flex: 1 1 260px; display: flex; flex-direction: column; gap: 4px; }
.reject-disclosure input {
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    font: inherit;
}
.reject-disclosure button { align-self: flex-end; }

/* Notices */
.notice {
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.5;
    background: var(--info-tint);
    color: var(--info-ink);
}
.notice-error { background: #FDECEA; color: var(--danger-ink); }
.notice-success { background: var(--ok-tint); color: var(--ok-ink); }

/* Stat tiles */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}
.stat {
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.stat p { margin: 0; }
.stat-label { font-size: 15px; color: var(--text-muted); }
.stat-value { font-size: 26px; font-weight: 600; }
.stat-value small { font-size: 15px; font-weight: 500; color: var(--text-muted); }
.stat-sub { font-size: 14px; color: var(--text-muted); }
.stat-sub form { display: inline; margin: 0; }

/* Status chips */
.chip {
    display: inline-block;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    padding: 4px 10px;
    white-space: nowrap;
}
.chip-ok { color: var(--ok-ink); background: var(--ok-tint); }
.chip-warn { color: var(--warn-ink); background: var(--warn-tint); }
.chip-neutral { color: var(--neutral-ink); background: var(--neutral-tint); }
.chip-info { color: var(--info-ink); background: var(--info-tint); }

/* Tables */
.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 520px;
}
.data-table thead tr { background: var(--bg); text-align: left; }
.data-table th {
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.data-table td { padding: 14px; }
.data-table tbody tr { border-bottom: 1px solid var(--rule); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table .cell-strong { font-weight: 600; }
.empty-state { margin: 0; font-size: 14px; color: var(--text-muted); }

/* Document list */
.doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.doc-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--rule);
}
.doc-list li:last-child { border-bottom: 0; }
.doc-date { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.split {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    align-items: flex-start;
}
.split > .split-main { flex: 2 1 520px; }
.split > .split-side { flex: 1 1 300px; }

/* ---------- Admin chrome ---------- */
.portal-search input {
    font: inherit;
    font-size: 14px;
    width: 280px;
    max-width: 60vw;
    min-height: 44px;
    border: none;
    border-radius: 22px;
    background: var(--bg);
    padding: 0 18px;
    color: var(--text);
}
.portal-nav-total { margin-left: auto; font-size: 13px; color: var(--text-muted); font-weight: 400; }
.portal-nav .portal-nav-total + .portal-count { margin-left: 8px; }

/* ---------- Admin dashboard (board 6) ---------- */
.page-title { margin: 0; font-size: 32px; font-weight: 600; }
.portal a.stat-link { color: inherit; text-decoration: none; }
.portal a.stat-link:hover { box-shadow: 0 0 0 2px var(--primary-tint), var(--shadow-card); color: inherit; }
.attention-list, .tool-list { list-style: none; margin: 0; padding: 0; }
.attention-list li { border-bottom: 1px solid var(--rule); }
.attention-list li:last-child { border-bottom: 0; }
.attention-list li > a, .attention-list li > div {
    display: flex; justify-content: space-between; gap: 16px; align-items: center;
    min-height: 56px; padding: 0 4px; color: var(--text); text-decoration: none; font-size: 15px;
}
.portal .attention-list li > a { color: var(--text); }
.portal .attention-action { color: var(--primary); font-weight: 600; white-space: nowrap; text-decoration: none; }
.tool-list li { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.tool-list li:last-child { border-bottom: 0; }
.tool-list a { font-weight: 600; }
.tool-list span { color: var(--text-muted); }

/* ---------- Admin lists (boards 7, 18) ---------- */
.head-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.list-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.list-search {
    font: inherit; font-size: 14px; flex: 1 1 260px; max-width: 360px; min-height: 44px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-control); padding: 0 14px; background: var(--surface);
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
    font: inherit; font-size: 14px; min-height: 44px; padding: 0 16px; border-radius: 22px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer;
}
.filter-chip[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-tint); color: #0B4FC9; font-weight: 600; }
.table-card { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow-x: auto; }
.table-card .data-table { min-width: 900px; }
@media (min-width: 1240px) { .table-card { overflow: visible; } }
.table-card .data-table th, .table-card .data-table td { padding: 14px 16px; }
.table-card .list-empty { padding: 20px 16px; }
.cell-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.cell-alert { color: var(--brand-orange-ink); }
.inline-action { display: inline; margin: 0; }
.row-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.portal .link-action { font: inherit; font-size: 14px; background: none; border: 0; padding: 0; color: var(--primary); text-decoration: underline; cursor: pointer; }
.row-more { position: relative; }
.row-more summary { list-style: none; cursor: pointer; font-size: 14px; color: var(--text-muted); padding: 4px 8px; border-radius: 6px; }
.row-more summary::-webkit-details-marker { display: none; }
.row-more[open] summary { background: var(--bg); }
.row-more-panel {
    position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 220px;
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-menu); padding: 6px;
    display: flex; flex-direction: column;
}
.portal .menu-action {
    display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px;
    background: none; font: inherit; font-size: 14px; color: var(--text); text-align: left; text-decoration: none; cursor: pointer;
}
.portal .menu-action:hover { background: var(--bg); color: var(--text); }
.row-more-panel .inline-action { display: block; }

/* ---------- Tycoon detail (board 8) ---------- */
.breadcrumb-small { font-size: 18px; }
.detail-avatar { width: 64px; height: 64px; border-radius: 32px; font-size: 22px; }
.detail-title { display: flex; flex-direction: column; gap: 6px; }
.detail-title h1 { margin: 0; font-size: 30px; font-weight: 600; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.detail-side { flex: 1 1 320px; max-width: 400px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.detail-card { padding: 24px; gap: 14px; font-size: 14px; }
.detail-card h2 { font-size: 18px; }
.facts { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; margin: 0; }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.portal .strong-link { font-weight: 600; }
.detail-main { flex: 999 1 560px; padding: 24px 28px 28px; gap: 18px; }
.detail-tabs { padding: 0; }
.detail-tabs .portal-count { position: static; display: inline-flex; vertical-align: middle; }
.detail-panel { display: flex; flex-direction: column; gap: 18px; }
.panel-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.callout { background: var(--bg); border-radius: 10px; padding: 16px; font-size: 14px; line-height: 1.5; }
.callout-link { display: block; margin-top: 6px; }
.row-more summary.btn { color: var(--text); }

/* ---------- Territories (board 9) ---------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-row .list-search { width: 240px; flex: none; }
.field-select {
    font: inherit; font-size: 14px; min-height: 44px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-control); padding: 0 12px; background: var(--surface); color: var(--text);
}
.bulk-bar {
    background: var(--text); color: #FFFFFF; border-radius: 12px; padding: 16px 20px;
    display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center;
}
.bulk-count { font-weight: 600; min-width: 200px; }
.bulk-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
.bulk-group select, .bulk-group input {
    font: inherit; font-size: 14px; min-height: 44px; border: none; border-radius: var(--radius-control); padding: 0 12px; max-width: 260px;
}
.bulk-group input { width: 150px; }
.portal .btn-light { background: #FFFFFF; color: var(--text); min-height: 44px; padding: 0 18px; }
.portal .btn-light:hover { background: var(--primary-tint); color: var(--text); }
.portal .btn-light:disabled { opacity: 0.6; cursor: progress; }
.bulk-hint { flex-basis: 100%; margin: 0; font-size: 12px; color: #C9CEDB; }
.territory-card .data-table { min-width: 980px; }
.territory-card tr.is-selected { background: #F7FAFF; }
.territory-card input[type="checkbox"] { width: 20px; height: 20px; }
.cell-none { color: var(--text-muted); }
.cell-instance { font-size: 12px; color: var(--text-muted); }
.zip-details summary { cursor: pointer; color: var(--primary); }
.zip-details div { margin-top: 6px; font-size: 13px; max-width: 280px; }
.fee-input { font: inherit; font-size: 14px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; }
.territory-card .dataTables_info, .territory-card .dataTables_paginate { padding: 12px 16px; font-size: 13px; color: var(--text-muted); }
.territory-card .dataTables_paginate { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.territory-card .dataTables_paginate .paginate_button {
    min-width: 36px; min-height: 36px; padding: 0 10px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--primary); text-decoration: none;
}
.territory-card .dataTables_paginate .paginate_button.current { background: var(--primary-tint); font-weight: 600; }
.territory-card .dataTables_paginate .paginate_button.disabled { color: var(--border-strong); cursor: default; }
.territory-card .dataTables_wrapper { display: flex; flex-wrap: wrap; justify-content: space-between; }
.territory-card .dataTables_wrapper table { flex-basis: 100%; }
.territory-card th.sorting, .territory-card th.sorting_asc, .territory-card th.sorting_desc { cursor: pointer; }
.territory-card th.sorting_asc::after { content: ' ▲'; font-size: 10px; }
.territory-card th.sorting_desc::after { content: ' ▼'; font-size: 10px; }
/* Row action icons and the remove-assignment menu (ported from landing.css). */
.action-menu { display: inline-flex; align-items: center; gap: 12px; position: relative; }
.portal .action-link { color: var(--primary); text-decoration: none; font-size: 15px; background: none; border: 0; padding: 4px; cursor: pointer; }
.action-menu-dropdown {
    position: absolute; top: 32px; right: 0; min-width: 180px; background: var(--surface); border-radius: 12px;
    box-shadow: var(--shadow-menu); padding: 6px; display: none; z-index: 20;
}
.action-menu.is-open .action-menu-dropdown { display: block; }
.portal .action-menu-dropdown a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14px; }
.portal .action-menu-dropdown a:hover { background: var(--bg); }
.portal [data-tooltip] { position: relative; }
.portal [data-tooltip]:hover::before {
    content: attr(data-tooltip); position: absolute; bottom: 100%; right: 0; margin-bottom: 8px; padding: 6px 10px;
    background: var(--text); color: #FFFFFF; font-size: 12px; font-weight: 400; border-radius: 6px; pointer-events: none;
    z-index: 1000; min-width: 140px; max-width: 200px; line-height: 1.4; text-align: left; white-space: normal;
}

/* ---------- Build an addendum (board 10) ---------- */
.inline-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.big-check { width: 20px; height: 20px; }
.addendum-row { flex-wrap: wrap; }

/* ---------- Operator detail (board 11) ---------- */
.avatar-operator { background: #E3ECFF; color: #0B4FC9; }
.exhibit-editor { border: 1px solid var(--border-strong); border-radius: var(--radius-control); overflow: hidden; }
.exhibit-editor .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border-strong); background: var(--bg); padding: 6px; }
.exhibit-editor .ql-container.ql-snow { border: 0; font-family: var(--font-agreement); font-size: 16px; }
.exhibit-editor .ql-editor { min-height: 360px; padding: 24px 28px; line-height: 1.7; }
.exhibit-readonly { border: 1px solid var(--border); border-radius: var(--radius-control); max-height: none; }
.exhibit-fallback { width: 100%; font: inherit; }

/* ---------- Master templates (board 12) ---------- */
.portal a.filter-chip { display: inline-flex; align-items: center; text-decoration: none; }
.field-chip { min-height: 36px; font-size: 13px; }
.template-editor .ql-editor { min-height: 520px; }
.template-source { width: 100%; min-height: 560px; border: 0; padding: 16px; font: 13px/1.5 ui-monospace, Menlo, monospace; }
.template-card { padding: 28px; }

/* ---------- Forms (boards 13, 16) ---------- */
.form-card { margin: 0; border: 0; gap: 18px; }
.form-card legend { float: left; padding: 0; font-size: 18px; font-weight: 600; }
.form-card legend + * { clear: both; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.choice-row { display: flex; gap: 12px; flex-wrap: wrap; }
.choice {
    display: flex; gap: 10px; align-items: center; min-height: 52px; padding: 0 16px;
    border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; background: var(--surface);
}
.choice input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; }
.choice.is-checked { border: 2px solid var(--primary); background: var(--primary-tint); font-weight: 600; }
.choice-small { min-width: 72px; justify-content: center; min-height: 48px; }
.choice-block { align-items: flex-start; padding: 14px; font-size: 14px; line-height: 1.5; font-weight: 400; }
.choice-block.is-checked { font-weight: 400; }
.choice-block input { margin-top: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.span-all { grid-column: 1 / -1; }
.form-field label { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.form-field input, .form-field select {
    font: inherit; font-size: 16px; border: none; border-bottom: 1px solid var(--border-strong);
    padding: 8px 0; background: transparent; color: var(--text); min-height: 44px; border-radius: 0;
}
.form-field input:focus, .form-field select:focus { outline: none; border-bottom: 2px solid var(--primary); }
.form-field input:read-only { color: var(--text-muted); }

/* ---------- Security (board 14) ---------- */
.security-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.qr-box { align-self: center; width: 220px; height: 220px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #FFFFFF; }
.qr-box svg { width: 100%; height: 100%; display: block; }
.mono-box { font-family: ui-monospace, Menlo, monospace; font-size: 16px; letter-spacing: 0.08em; background: var(--bg); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; }
.code-input { font-family: ui-monospace, Menlo, monospace; font-size: 24px; letter-spacing: 0.4em; border: 1px solid var(--border-strong); border-radius: 8px; padding: 10px 14px; max-width: 260px; }
.code-input:focus { outline: none; border: 2px solid var(--primary); }

/* ---------- Weekly digest (board 15) ---------- */
.next-run { flex-direction: row; flex-wrap: wrap; gap: 24px; align-items: center; justify-content: space-between; }
.next-run-text { display: flex; flex-direction: column; gap: 6px; max-width: 640px; }
.next-run-text h2 { font-size: 22px; }
.portal .btn-outline-primary { border-color: var(--primary); color: var(--primary); }

/* ---------- My territories (board 17) ---------- */
.territory-list { padding: 8px 28px; gap: 0; }
.territory-row { border-bottom: 1px solid var(--rule); padding: 16px 0; }
.territory-row:last-of-type { border-bottom: 0; }
.territory-row summary { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; min-height: 44px; list-style: none; cursor: pointer; }
.territory-row summary::-webkit-details-marker { display: none; }
.territory-name { flex: 1 1 260px; font-size: 16px; }
.zip-chips { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.portal .zip-chip { font-size: 14px; background: var(--bg); border-radius: 6px; padding: 6px 10px; color: var(--text); text-decoration: none; }
.portal .zip-chip:hover { background: var(--primary-tint); }

/* ---------- Emails (board 19) ---------- */
.facts-wide { grid-template-columns: 220px 1fr; }
.email-nav { flex: 1 1 260px; max-width: 320px; padding: 16px; gap: 4px; }
.portal .email-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.portal .email-nav a[aria-current="page"] { background: var(--primary-tint); color: var(--primary); font-weight: 600; }
.email-preview { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: 8px; background: #FFFFFF; }

/* ---------- Sign in (board 1) ---------- */
.signin { min-height: 100vh; display: flex; flex-wrap: wrap; background: var(--bg); }
.signin-art { flex: 1 1 480px; min-height: 320px; background: var(--brand-orange); display: flex; align-items: center; justify-content: center; padding: 48px; }
.signin-art img { width: 100%; max-width: 760px; height: auto; }
.signin-main { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 64px 24px; }
.signin-box { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 32px; }
.signin-brand { display: flex; flex-direction: column; gap: 12px; }
.signin-brand img, .signin-logo { width: 220px; height: auto; }
.signin-brand .portal-wordmark { font-size: 44px; }
.signin-box h1 { margin: 0; font-size: 40px; font-weight: 600; line-height: 1.1; }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--text-muted); }
.pw-rules li { display: flex; align-items: center; gap: 8px; }
.pw-rules li svg { opacity: 0.25; }
.pw-rules li.is-met { color: var(--text); }
.pw-rules li.is-met svg { opacity: 1; color: var(--ok-ink); }
.signin-lede { margin: -16px 0 0; font-size: 16px; line-height: 1.6; color: var(--text-muted); }
.signin-form { display: flex; flex-direction: column; gap: 28px; }
.signin-field { display: flex; flex-direction: column; gap: 8px; }
.signin-field label { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.signin-field input:not(.code-input) {
    font: inherit; font-size: 17px; border: none; border-bottom: 1px solid var(--border-strong);
    background: transparent; padding: 8px 0; color: var(--text); outline: none; width: 100%;
}
.signin-field input:not(.code-input):focus { border-bottom: 2px solid var(--primary); }
.signin-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.portal .signin-actions .btn-primary { padding: 0 32px; }
.signin-remember { align-items: center; font-size: 15px; }
.signin-remember input { margin: 0; }
.signin-note { padding: 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; line-height: 1.5; }
.signin-note p { margin: 0; color: var(--text-muted); }
.signin-note p:first-child { color: var(--text); margin-bottom: 4px; }
.signin-links { margin: 0; font-size: 15px; color: var(--text-muted); display: flex; gap: 12px; flex-wrap: wrap; }
.signin-legal { margin: 0; font-size: 13px; color: var(--text-muted); }
@media (max-width: 720px) {
    .signin-art { min-height: 200px; padding: 24px; }
    .signin-main { padding: 40px 16px; }
    .signin-box h1 { font-size: 32px; }
}

/* ---------- Review and sign (board 3) ---------- */
.portal-content-wide { max-width: 1320px; margin: 0 auto; width: 100%; gap: 24px; }

.breadcrumb {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: baseline;
    font-size: 24px;
}
.portal .breadcrumb a { text-decoration: none; }
.breadcrumb h1 { margin: 0; font-size: 28px; font-weight: 600; }

.review-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    align-items: flex-start;
}
.review-docs {
    flex: 999 1 560px;
    min-width: 0;
    background: var(--surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
}
.review-side {
    flex: 1 1 360px;
    max-width: 440px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.review-side .card { padding: 28px; gap: 22px; }

.doc-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.doc-tabs button {
    font: inherit;
    font-size: 15px;
    min-height: 48px;
    padding: 0 18px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: #3A4052;
    cursor: pointer;
}
.doc-tabs button[aria-selected="true"] { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.doc-tabs button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.doc-meta {
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--rule);
}
.doc-article {
    max-height: 760px;
    overflow-y: auto;
    padding: 32px 48px;
    font-family: var(--font-agreement);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
}
.doc-article > h2 { margin: 0 0 6px; font-family: var(--font-ui); font-size: 20px; font-weight: 600; }
.doc-article > .doc-subtitle { margin: 0 0 24px; font-family: var(--font-ui); font-size: 14px; color: var(--text-muted); }
.doc-article table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-article th, .doc-article td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc-article table.agreement-signature-table, .doc-article table.agreement-signature-table td { border: none; }
.doc-article img { max-width: 100%; height: auto; }

.sign-head { display: flex; flex-direction: column; gap: 6px; }
.sign-head p { margin: 0; font-size: 14px; color: var(--text-muted); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist svg { flex-shrink: 0; margin-top: 1px; }
.checklist .is-ok svg { color: var(--ok-ink); }
.checklist .is-missing svg { color: var(--warn-ink); }
.field-label { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.signature-box {
    height: 88px;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 14px;
    color: var(--text-muted);
}
.signature-box img { max-height: 100%; max-width: 100%; }
.signature-box-lg { height: 180px; }
.signature-pad { border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface, #fff); }
.signature-pad canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.disclosure {
    background: var(--bg);
    border-radius: 10px;
    padding: 16px;
    font-size: 13px;
    line-height: 1.55;
    color: #3A4052;
}
.disclosure strong { color: var(--text); }
.disclosure a { color: var(--primary); }
.disclosure-more { margin-top: 8px; }
.disclosure-more summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.disclosure-more ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; cursor: pointer; }
.consent input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; }
.typed-name {
    font: inherit;
    font-size: 16px;
    border: none;
    border-bottom: 2px solid var(--primary);
    padding: 8px 0;
    background: transparent;
    color: var(--text);
    outline: none;
    width: 100%;
}
.field-hint { font-size: 12px; color: var(--text-muted); }
.field-stack { display: flex; flex-direction: column; gap: 8px; }
.field-stack > .list-search { flex: none; }
.portal .btn-sign { min-height: 52px; font-size: 16px; width: 100%; }
.portal .btn-sign:disabled { background: #8C93A6; cursor: not-allowed; }
.fineprint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }

/* ---------- Sign an addendum (board 4) ---------- */
.review-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.review-main > .review-docs { flex: none; }
.card-lead { margin: 0; font-size: 15px; line-height: 1.6; color: #3A4052; }
.link-row { margin: 0; font-size: 14px; display: flex; gap: 16px; flex-wrap: wrap; }
.reject-block { border-top: 1px solid var(--rule); padding-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.reject-label { font-size: 14px; font-weight: 600; }
.reject-block textarea {
    font: inherit;
    font-size: 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    padding: 10px 12px;
    resize: vertical;
}
.portal .btn-danger-outline { background: var(--surface); border-color: var(--danger-ink); color: var(--danger-ink); }
.portal .btn-danger-outline:hover { background: #FDECEA; color: var(--danger-ink); }

/* ---------- Payouts (boards 5a-5d) ---------- */
.narrow-stack { max-width: 1080px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.payout-card { padding: 32px; gap: 28px; }
.payout-intro { display: flex; flex-direction: column; gap: 6px; max-width: 600px; }
.payout-intro h2 { font-size: 22px; }
.payout-intro p { margin: 0; font-size: 15px; line-height: 1.6; color: #3A4052; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.step { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: 10px; background: var(--bg); }
.step.is-current, .step.is-pending { background: #FFF7EA; box-shadow: inset 0 0 0 2px #E59A2B; }
.step.is-ready { background: #EEF9F3; box-shadow: inset 0 0 0 2px var(--ok-ink); }
.step-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.step-dot {
    width: 28px; height: 28px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-muted);
}
.step.is-done .step-dot, .step.is-ready .step-dot { background: var(--ok-ink); border-color: var(--ok-ink); color: #FFFFFF; }
.step.is-current .step-dot, .step.is-pending .step-dot { background: var(--warn-ink); border-color: var(--warn-ink); color: #FFFFFF; }
.step-dot svg { stroke-width: 3; }
.step-title { font-size: 15px; font-weight: 600; }
.step-desc { font-size: 13px; color: var(--text-muted); }
.payout-panel { border: 1px solid var(--border); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.payout-panel h3 { margin: 0; font-size: 16px; font-weight: 600; }
.payout-panel p { margin: 0; font-size: 15px; line-height: 1.6; color: #3A4052; }
.payout-actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.portal .payout-actions .btn-primary { min-height: 52px; }
.faq-list { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.8; color: #3A4052; }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
    .breadcrumb { font-size: 18px; }
    .breadcrumb h1 { font-size: 22px; }
    .doc-meta { padding: 16px 20px; }
    .doc-article { max-height: none; padding: 24px 20px; }
    .review-side { max-width: none; }
    .portal-header { padding: 12px 16px; }
    .portal-brand-product { display: none; }
    .account-who { display: none; }
    .portal-nav {
        max-width: none;
        flex: 1 1 100%;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px 16px;
        gap: 4px;
    }
    .portal .portal-nav a { white-space: nowrap; min-height: 44px; }
    .portal .portal-nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--primary); }
    .portal-main { padding: 24px 16px 48px; }
    .card, .action-card { padding: 22px 20px; }
    .action-card-actions { align-items: stretch; width: 100%; }
    .action-fineprint { text-align: left; max-width: none; }
    .page-head h1 { font-size: 26px; }
}

/* ---------- Legacy page content inside the portal shell ----------
   Admin pages that predate the redesign (Territory import / edit / assign) keep their
   markup inside .legacy-content; these rules give it the portal look. */
.legacy-content { display: flex; flex-direction: column; gap: 20px; }
.legacy-content .form-section,
.legacy-content.ter2 > .section {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(27, 29, 42, 0.06);
    padding: 24px;
    margin: 0;
}
.legacy-content h2, .legacy-content h3 { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.legacy-content .section-hint, .legacy-content .helper, .legacy-content .message { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--text-muted); }
.legacy-content .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.legacy-content .form-grid > div { display: flex; flex-direction: column; gap: 6px; }
.legacy-content label { font-size: 13px; font-weight: 600; }
.legacy-content input[type="text"], .legacy-content input[type="number"], .legacy-content input[type="search"],
.legacy-content input[type="email"], .legacy-content input:not([type]), .legacy-content select, .legacy-content textarea {
    font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
.legacy-content input[type="file"] { font: inherit; font-size: 14px; }
.legacy-content .modal-actions, .legacy-content .export-format-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.legacy-content .export-options { display: grid; gap: 16px; }
.legacy-content .modal-status { padding: 12px 16px; border-radius: 10px; background: var(--ok-tint); color: var(--ok-ink); font-size: 14px; margin: 0 0 12px; }
.legacy-content .modal-status.error { background: #FDECEA; color: var(--danger-ink); }
.legacy-content .link-button, .legacy-content button[type="submit"]:not(.action-link-button), .ter2-modal .link-button,
#ter2-confirm .link-button {
    display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 999px;
    border: 1px solid transparent; background: var(--primary); color: #FFFFFF; font: inherit; font-size: 14px; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.legacy-content .link-button.secondary, #ter2-confirm .link-button.secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.legacy-content .link-button:disabled { opacity: 0.5; cursor: default; }
.legacy-content .list-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.legacy-content .list-table th { text-align: left; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.legacy-content .list-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.legacy-content.ter2 .field-row { border-bottom-color: var(--border); }
.legacy-content.ter2 .save-bar { background: var(--surface); border-radius: 14px; padding: 16px 24px; box-shadow: 0 -2px 10px rgba(27, 29, 42, 0.06); border-top: 0; }

/* ---------- Emails editor ---------- */
.form-field textarea {
    font: inherit; font-size: 15px; line-height: 1.55; padding: 12px; min-height: 200px; resize: vertical;
    border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
}
.form-field textarea:focus { outline: none; border-color: var(--primary); }
.token-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.portal .token-chip {
    font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
.portal .token-chip:hover { border-color: var(--primary); color: var(--primary); }
