/* ============================================================
   Admin panel
   ============================================================

   The colour system is two variants of one hue, and they are not
   interchangeable:

     --admin-accent    saturated. FILLS only, plus text on the dark sidebar.
                       Never text on a light surface.
     --admin-primary   the same hue darkened until it clears 4.5:1 on white.
                       Links, focus rings, stat figures, sortable headers.

   Both are computed from the brand colour in includes/admin-ui.php and
   injected as custom properties, so this file holds no colour literal that
   belongs to a client. An unbranded install resolves to a neutral slate.

   If an accent fill ever appears with unreadable text on it, that is a bug —
   --admin-on-accent is chosen by contrast, not assumed.

   Working surfaces stay neutral on purpose. This is a tool people read lead
   details in all day, not a landing page.
   ============================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    line-height: 1.6;
    font-size: 14px;
}

a { color: var(--admin-primary); }

/* ---- layout ------------------------------------------------ */

.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--admin-sidebar-width);
    background: var(--admin-ink);
    color: #fff;
    padding: 24px 0;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    z-index: 100;
}

.admin-sidebar-logo {
    padding: 0 24px 24px;
    font-size: 22px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}
.admin-sidebar-logo span { color: var(--admin-accent); }

.admin-main {
    flex: 1;
    margin-left: var(--admin-sidebar-width);
    padding: 32px;
    min-width: 0;
}

/* ---- navigation -------------------------------------------- */

.admin-nav { list-style: none; }

.admin-nav a,
.admin-nav .admin-navgroup {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-family: inherit;
    text-align: left;
    background: none;
    border: 0;
    /* Reserved so the active state does not shift the item 3px right. */
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.admin-nav a:hover,
.admin-nav .admin-navgroup:hover,
.admin-nav a.active,
.admin-nav .admin-navgroup.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.admin-nav a.active,
.admin-nav .admin-navgroup.active { border-left-color: var(--admin-accent); }

.admin-nav svg { width: 20px; height: 20px; flex: none; }

/* An SVG rather than a text glyph: the small-triangle codepoint renders at
   different sizes across platform fonts. Sized on the class so it beats the
   20px rule above. */
.admin-navgroup-caret {
    margin-left: auto;
    width: 16px; height: 16px;
    opacity: .75;
    transition: transform .2s;
}
.admin-navgroup:hover .admin-navgroup-caret { opacity: 1; }
.admin-navgroup[aria-expanded="false"] .admin-navgroup-caret { transform: rotate(-90deg); }

.admin-subnav { list-style: none; margin: 0 0 4px; padding: 0; }

/* 24px base + 20px icon + 12px gap — children align with the parent's LABEL,
   not its icon. */
.admin-subnav a {
    padding: 8px 24px 8px 56px;
    font-size: 13px;
    color: rgba(255,255,255,0.55);
}
.admin-subnav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.admin-subnav a.active { background: rgba(255,255,255,0.08); color: #fff; font-weight: 600; }

/* Required: .admin-nav a is display:flex, which would otherwise beat the
   user-agent [hidden] rule and leave collapsed groups visible. */
.admin-subnav[hidden] { display: none; }

.admin-navtoggle { display: none; }

/* ---- page header ------------------------------------------- */

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 28px;
}
.admin-header h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.admin-header .subtitle { color: var(--admin-text-muted); font-size: 14px; margin-top: 4px; }
.admin-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- banners and alerts ------------------------------------ */

.admin-banner {
    padding: 11px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 20px;
}
.admin-banner--warn { background: #fff4e5; color: #8a4b00; border: 1px solid #ffe0b2; }
.admin-banner a { color: inherit; }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}
.alert--success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert--error   { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.alert--warn    { background: #fff8e1; color: #a65f00; border: 1px solid #ffecb3; }
.alert--info    { background: #e8f1fb; color: #1c4e80; border: 1px solid #cfe0f5; }

/* ---- cards ------------------------------------------------- */

.card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 22px;
    margin-bottom: 22px;
}
.card-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--admin-border);
}
.card-header h2 { font-size: 17px; font-weight: 600; }

/* Its own line, always.

   The margin-top here says this was written to sit UNDER the title, but the
   header is a flex row, so it landed to the RIGHT of it — squeezed against the
   card edge and, on any description longer than a few words, crowding the
   heading it was meant to explain. flex-basis 100% drops it to its own line
   while leaving the row free to do what it is for: title on the left, actions
   on the right. */
.card-desc {
    flex-basis: 100%;
    margin-top: 2px;
    color: var(--admin-text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.section-title {
    font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--admin-text-muted);
    padding-bottom: 8px; margin-bottom: 16px;
    border-bottom: 1px solid var(--admin-border);
}

/* ---- stats ------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}
.stat-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-value { font-size: 30px; font-weight: 700; color: var(--admin-primary); line-height: 1.15; }
.stat-label { font-size: 13px; color: var(--admin-text-muted); margin-top: 4px; }
.stat-sub   { font-size: 12px; color: var(--admin-text-muted); margin-top: 6px; }

/* ---- tables ------------------------------------------------ */

.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--admin-border);
}
.data-table th {
    font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--admin-text-muted);
    background: var(--admin-bg);
    white-space: nowrap;
}
.data-table th a { color: inherit; text-decoration: none; }
.data-table th a:hover { color: var(--admin-primary); }
.data-table td { font-size: 13.5px; vertical-align: middle; }
.data-table tbody tr:hover { background: var(--admin-bg); }
.data-table .actions { display: flex; gap: 8px; }
.data-table .nowrap { white-space: nowrap; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--admin-text-muted);
    font-size: 14px;
}

/* ---- forms ------------------------------------------------- */

.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 13.5px; font-weight: 600;
    color: var(--admin-text); margin-bottom: 6px;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=url],
.form-group input[type=tel],
.form-group input[type=number],
.form-group input[type=password],
.form-group input[type=date],
.form-group input[type=search],
.form-group select,
.form-group textarea,
.form-control {
    width: 100%;
    padding: 10px 13px;
    font: inherit; font-size: 14px;
    color: var(--admin-text);
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px var(--admin-focus-ring);
}
.form-group textarea, textarea.form-control { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.help-text, .form-text {
    display: block;
    font-size: 12.5px; font-weight: 400;
    color: var(--admin-text-muted);
    margin-top: 5px;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.checkbox-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.checkbox-row input { margin-top: 3px; flex: none; width: 16px; height: 16px; }
.checkbox-row label { font-weight: 400; font-size: 13.5px; margin: 0; }

/* ---- buttons ----------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    font: inherit; font-size: 13.5px; font-weight: 600;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--admin-accent); color: var(--admin-on-accent); }
.btn-primary:hover { background: var(--admin-accent-dark); color: var(--admin-on-accent); }
.btn-secondary {
    background: var(--admin-card); color: var(--admin-text); border-color: var(--admin-border);
}
.btn-secondary:hover { background: var(--admin-bg); }
.btn-danger { background: var(--admin-error); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---- pills -------------------------------------------------
   ONE pill system. Four grew in the original — a stage select, a connection
   pill, a dark translucent one and a variant badge — which is four sets of
   colours to keep aligned and four places to fix a contrast problem. */

.pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
    white-space: nowrap;
}
.pill--ok      { background: #e7f7f0; color: #0f6b48; border: 1px solid #bde5d3; }
.pill--warn    { background: #fff4e0; color: #8a5409; border: 1px solid #ffe0b2; }
.pill--fail    { background: #fdecec; color: #a12020; border: 1px solid #f7c9c9; }
.pill--info    { background: #e8f1fb; color: #1c4e80; border: 1px solid #cfe0f5; }
.pill--neutral { background: #f1f3f6; color: #5c6672; border: 1px solid var(--admin-border); }

/* ---- stage select (a pill you can change in place) ---------- */

.stage-select {
    padding: 5px 26px 5px 11px;
    font: inherit; font-size: 12px; font-weight: 600;
    border: 1px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
}
.stage-select:focus { outline: none; box-shadow: 0 0 0 3px var(--admin-focus-ring); }

.stage-new                  { background-color: #dbeafe; color: #1e40af; }
.stage-contacted            { background-color: #fef3c7; color: #92400e; }
.stage-able_to_connect      { background-color: #d1fae5; color: #065f46; }
.stage-no_answer            { background-color: #fee2e2; color: #991b1b; }
.stage-left_message         { background-color: #ede9fe; color: #5b21b6; }
/* Borders declared on every stage, not just two, so the pills stay the same
   height as each other. */
.stage-booked               { background-color: #d1fae5; color: #047857; border-color: #10b981; }
.stage-quoted               { background-color: #e0e7ff; color: #3730a3; border-color: #818cf8; }
.stage-closed_won           { background-color: #a7f3d0; color: #065f46; border-color: #059669; }
.stage-no_longer_interested { background-color: #f3f4f6; color: #6b7280; border-color: #d1d5db; }

/* ---- filters and pagination -------------------------------- */

.filters-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    margin-bottom: 20px;
}
.filters-bar .search-input { flex: 1 1 240px; min-width: 200px; }
.filters-bar input, .filters-bar select {
    padding: 9px 12px;
    font: inherit; font-size: 13.5px;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: var(--admin-card);
    color: var(--admin-text);
}
.filters-bar input:focus, .filters-bar select:focus {
    outline: none; border-color: var(--admin-primary);
    box-shadow: 0 0 0 3px var(--admin-focus-ring);
}
.date-filter { display: flex; gap: 8px; align-items: center; color: var(--admin-text-muted); }

.pagination { display: flex; justify-content: center; gap: 7px; margin-top: 22px; flex-wrap: wrap; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 10px;
    border-radius: 8px; font-size: 13.5px; text-decoration: none;
    color: var(--admin-text); background: var(--admin-card);
    border: 1px solid var(--admin-border);
}
.pagination a:hover { border-color: var(--admin-primary); color: var(--admin-primary); }
.pagination .active {
    background: var(--admin-accent); color: var(--admin-on-accent); border-color: var(--admin-accent);
    font-weight: 600;
}
.pagination-note { text-align: center; color: var(--admin-text-muted); font-size: 12.5px; margin-top: 10px; }

/* ---- bulk actions ------------------------------------------ */

.bulk-bar {
    display: none;
    align-items: center; gap: 12px;
    padding: 11px 15px; margin-bottom: 14px;
    background: #fdecec; border: 1px solid #f7c9c9; border-radius: 8px;
}
.bulk-bar.on { display: flex; }
.bulk-bar strong { color: #a12020; }

/* ---- modal -------------------------------------------------
   Everything here is scoped to .has-js, which the shell sets on <html> from
   an inline script in the head. The unscoped rules are therefore what a
   browser WITHOUT scripting renders: the dialog becomes an ordinary card in
   the page flow, and the controls that would only work under script -- the
   trigger buttons, the close cross, the cancel button -- are hidden.

   The alternative is a modal that is display:none with no way to open it,
   which on users.php would mean no way to add, edit or delete an account at
   all. Same reasoning as the lead form's two-step and the expandable row
   panels: the page has to work before the script does, not because of it. */

.modal {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    padding: 26px;
    margin-bottom: 18px;
}
[data-modal-open], .modal-close, .modal-cancel { display: none; }

.has-js [data-modal-open] { display: inline-flex; }
.has-js .modal-close { display: block; }
.has-js .modal-cancel { display: inline-flex; }

.has-js .modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    border: 0; border-radius: 0; padding: 20px; margin: 0;
    z-index: 1000;
    align-items: center; justify-content: center;
}
.has-js .modal.on { display: flex; }

.modal-content {
    background: var(--admin-card);
    border-radius: 14px;
    max-width: 460px; width: 100%;
}
.has-js .modal-content {
    padding: 26px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}

/* The roles matrix is a three-column table, and 460px makes it unreadable. */
.modal-content--wide { max-width: 720px; }

.modal-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 14px; margin-bottom: 14px;
}
.modal-title { font-size: 18px; font-weight: 600; margin: 0; }
.modal-close {
    background: none; border: 0; padding: 0; line-height: 1;
    font-size: 26px; color: var(--admin-text-muted); cursor: pointer;
}
.modal-close:hover { color: var(--admin-text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* A dialog reached only from a control that itself needs script -- the bulk
   bar on the leads page appears on checkbox selection -- has nothing to
   degrade INTO. Rendering it as a card would leave "Delete 0 lead(s)?" sitting
   in the page for a visitor who cannot select a lead in the first place. */
.modal--script-only { display: none; }

/* The global reset zeroes every margin, which leaves a confirmation sentence
   sitting directly on the label of the field below it. */
.modal-content > p { margin-bottom: 16px; }

/* The delete form inside an account's own dialog is the fallback for a browser
   with no scripting, where the shared confirm dialog above cannot open. Once
   script is running there are two routes to the same delete -- the row button
   and this -- so the duplicate goes away. */
.has-js .modal .danger-zone { display: none; }

/* ---- login ------------------------------------------------- */

.login-page {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--admin-ink) 0%, var(--admin-ink-2) 100%);
    padding: 20px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--admin-card);
    border-radius: 14px;
    padding: 34px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    /* Decoration, so the text-contrast floor does not apply and this can be the
       saturated accent rather than the darkened working variant. Clipped by the
       card's own radius. */
    border-top: 5px solid var(--admin-accent);
    overflow: hidden;
}
.login-header { text-align: center; margin-bottom: 26px; }
.login-logo { font-size: 27px; font-weight: 700; color: var(--admin-text); }
.login-logo span { color: var(--admin-primary); }
.login-subtitle { color: var(--admin-text-muted); font-size: 13.5px; margin-top: 6px; }

/* ---- responsive -------------------------------------------- */

/* Tabular figures, so a column of timestamps or counts aligns on the digit
   rather than drifting with the glyph widths. */
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* A user agent is one long unbroken token. It has to be allowed to break, and
   bounded, or one row sets the width of the whole table. */
.ua {
    display: inline-block;
    max-width: 320px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--admin-text-muted);
    word-break: break-all;
}

/* One-time recovery codes. Wide enough to select cleanly, and monospaced so a
   1 cannot be read as an l on the one screen where that matters. */
.codes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.code-chip {
    display: inline-block;
    padding: 8px 10px;
    background: var(--admin-bg);
    border: 1px solid var(--admin-border);
    border-radius: 7px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: .04em;
    user-select: all;
}
.setup-steps { margin: 0 0 14px 18px; }
.setup-steps li { margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.inline-form .form-control { max-width: 140px; }

/* The arm cards. Layout only — every colour is the derived palette, so a
   client's brand hue cannot clash with a hardcoded accent. */
.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.variant-card {
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 11px;
    padding: 16px 18px;
}
.variant-card--winner { border-color: var(--admin-success); border-width: 2px; }
.variant-card--paused { opacity: .72; border-style: dashed; }
.variant-card__head { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-bottom: 6px; }
.variant-card__head h3 { font-size: 15px; margin: 0; }
.variant-card__actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.variant-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin: 12px 0 0;
}
.variant-stats dt {
    font-size: 11.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: var(--admin-text-muted); margin-bottom: 2px;
}
.variant-stats dd { margin: 0; font-size: 18px; font-weight: 600; }

/* -------------------------------------------------------------------------
   Form field states

   .field-error replaces the inline style="color:var(--admin-error);font-weight:600"
   that the brand page repeated on all eight of its error slots. One class, so
   the ninth field cannot be styled differently by accident.
   ---------------------------------------------------------------------- */
.field-error {
    display: block;
    margin: 5px 0 0;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--admin-error);
}
.form-control.is-invalid {
    border-color: var(--admin-error);
    background: color-mix(in srgb, var(--admin-error) 4%, var(--admin-card));
}
.form-control.is-invalid:focus {
    outline-color: var(--admin-error);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--admin-error) 18%, transparent);
}

/* The required marker. An abbr so it explains itself on hover and to a screen
   reader, rather than being an asterisk whose meaning lives in a legend. */
abbr.req {
    color: var(--admin-error);
    text-decoration: none;
    font-weight: 700;
    cursor: help;
}

/* A value the system computes and the operator cannot type. Styled to read as
   output rather than as an input somebody has failed to fill in. */
.derived-value {
    margin: 0;
    padding: 9px 12px;
    background: var(--admin-bg);
    border: 1px dashed var(--admin-border);
    border-radius: 8px;
    font-size: 13.5px;
    color: var(--admin-text);
}

/* -------------------------------------------------------------------------
   Colour picking and the shades derived from it
   ---------------------------------------------------------------------- */
.color-field { display: flex; align-items: center; gap: 10px; }
.color-hex-input {
    flex: 1 1 auto;
    max-width: 190px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    text-transform: lowercase;
}
.color-input {
    width: 58px; height: 38px; padding: 3px;
    border: 1px solid var(--admin-border); border-radius: 8px;
    background: var(--admin-card); cursor: pointer;
}
.color-input.is-invalid { border-color: var(--admin-error); }
.color-hex {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px; color: var(--admin-text-muted);
}

.swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
    display: flex; flex-direction: column; gap: 3px;
    min-width: 74px;
}
.swatch i {
    display: block; height: 30px; border-radius: 7px;
    border: 1px solid var(--admin-border);
    /* A chequerboard behind the chip, so the translucent focus-ring value reads
       as translucent instead of as a slightly different solid colour. */
    background-image:
        linear-gradient(45deg, #e6e8ec 25%, transparent 25%, transparent 75%, #e6e8ec 75%),
        linear-gradient(45deg, #e6e8ec 25%, transparent 25%, transparent 75%, #e6e8ec 75%);
    background-size: 10px 10px;
    background-position: 0 0, 5px 5px;
}
.swatch-label { font-size: 11.5px; font-weight: 600; color: var(--admin-text); }
.swatch-hex {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10.5px; color: var(--admin-text-muted);
}

/* What the colour looks like doing its actual job. The contrast table says
   whether it passes; this says what passing looks like. */
.brand-preview {
    margin-top: 16px; padding: 14px 16px;
    background: var(--admin-bg);
    border: 1px solid var(--admin-border); border-radius: 10px;
}
.brand-preview__label {
    display: block; margin-bottom: 10px;
    font-size: 11.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .05em; color: var(--admin-text-muted);
}
.brand-preview__row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.brand-cta {
    padding: 11px 20px; border: 0; border-radius: 8px;
    font-size: 14.5px; font-weight: 700; cursor: default;
}
.brand-text { font-size: 14.5px; font-weight: 600; }

/* A third column, for the proof-point numbers. */
.form-row--three { grid-template-columns: repeat(3, 1fr); }

/* The exported intake document. */
.code-block {
    max-height: 420px; overflow: auto;
    margin: 10px 0 0; padding: 13px 15px;
    background: var(--admin-ink); color: #e6e8ec;
    border-radius: 9px;
    font-size: 12px; line-height: 1.55;
}

/* The save bar stays reachable on a form this long.

   Opaque, with a top edge. A gradient fading to transparent was the first
   attempt and it let the content underneath show through the bar — which on a
   form full of inputs reads as a rendering fault rather than as a nice touch. */
.form-actions--sticky {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; align-items: center; gap: 14px;
    margin-top: 4px;
    padding: 14px 16px;
    background: var(--admin-card);
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    box-shadow: 0 -2px 10px rgba(16, 24, 40, .06);
}

@media (max-width: 1024px) {
    .admin-sidebar { transform: translateX(-100%); transition: transform .25s; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; padding: 20px; }

    /* The original slid the sidebar off screen and nothing ever brought it
       back — there was no toggle anywhere in the codebase, so the nav was
       simply unreachable on a phone. */
    .admin-navtoggle {
        display: inline-flex; align-items: center; gap: 8px;
        margin-bottom: 16px;
        padding: 9px 14px;
        font: inherit; font-size: 13.5px; font-weight: 600;
        background: var(--admin-card); color: var(--admin-text);
        border: 1px solid var(--admin-border); border-radius: 8px;
        cursor: pointer;
    }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .form-row--three { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .admin-header { flex-direction: column; align-items: stretch; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---- settings cards (collapsed by default) -------------------
   The page is a list of integrations and their state until you ask to change
   one. No new pill system and no new card: this reuses .card and .pill, and
   only adds the actions cluster and the collapse. */

.settings-card-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}
.settings-card-body[hidden] { display: none; }

/* A closed card is a row, so it does not need the header rule or the padding a
   full card carries. */
.settings-card:not(.is-open) { padding-bottom: 18px; }
.settings-card:not(.is-open) .card-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}
.settings-card.is-open .card-header { margin-bottom: 18px; }

/* ---- disclosure summaries that look like buttons -------------------------
   A <summary> is the control, so it should read as one. Without this it
   renders as a muted line of text with a disclosure triangle, full width of
   its container — which is why "Edit user@example.com" looked like a row
   rather than a button. */
summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ""; }

/* ---- an expandable panel row inside a data table -------------------------
   The panel is rendered OPEN and hidden by script on load, so with scripting
   unavailable every form is still reachable. */
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 6px; }

/* ---- a destructive action that needs a password --------------------------
   Inline rather than stacked: in a table cell the stacked version pushed the
   button out of the column and it was clipped. */
.danger-zone {
    margin-top: 22px; padding-top: 18px;
    border-top: 1px solid var(--admin-border);
}
.danger-zone h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; color: var(--admin-error); }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.inline-form .form-control { width: auto; min-width: 200px; }
.access-exceptions { margin: 6px 0 18px; }
.access-exceptions[open] > summary { margin-bottom: 12px; }
