html, body {
    font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Bridge Bootstrap's CSS variables to the Dashtxtastic design tokens so every
   button, link, focus ring, and form-control accent uses the brand palette
   instead of Bootstrap blue. RGB triplets mirror --navy (#1f2a5e) and --blue
   (#2a6fb5); update them here if the palette in design-tokens.css changes. */
:root {
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: 31, 42, 94;
    --bs-link-color: var(--brand-primary);
    --bs-link-color-rgb: 31, 42, 94;
    --bs-link-hover-color: var(--brand-accent);
    --bs-link-hover-color-rgb: 42, 111, 181;
    --bs-nav-pills-link-active-bg: var(--brand-primary);
    --bs-nav-link-color: var(--brand-primary);
    --bs-nav-link-hover-color: var(--brand-accent);
}

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background-color: var(--brand-primary);
    color: #fff;
}

/* Brand color for plain content anchors. The :where() wrapper drops the
   specificity contribution of the :not() list to 0, so any class-based rule
   (.navbar-brand, .nav-link, .btn-primary, .account-tab.active, ...) wins
   automatically without us having to extend an exclusion list every time a
   new component-styled anchor shows up. */
a:where(:not(.btn, .btn-link, .nav-link, .navbar-brand, .dropdown-item, .dropdown-toggle, .account-tab)),
.btn-link {
    color: var(--brand-primary);
}

a:where(:not(.btn, .btn-link, .nav-link, .navbar-brand, .dropdown-item, .dropdown-toggle, .account-tab)):hover,
.btn-link:hover {
    color: var(--brand-accent);
}

a:where(:not(.btn, .btn-link, .nav-link, .navbar-brand, .dropdown-item, .dropdown-toggle, .account-tab)):visited {
    color: var(--brand-primary);
}

.btn-primary,
.btn-primary:visited,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    color: #fff;
}

.btn-primary {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--brand-accent);
    border-color: var(--brand-accent);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--brand-accent);
}

.form-check-input:checked {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Sidebar nav rules now live in NavMenu.razor.css (editorial chrome). The
 * legacy collapsible nav-section / nav-submenu CSS that lived here was for
 * the dark gradient sidebar and has been removed alongside that design. */

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Sidebar collapse: the × inside the NavMenu brand bar sets html.sidebar-collapsed;
   the floating hamburger handle clears it. Lives in non-scoped app.css so the body
   class selector isn't rewritten by Blazor's scoped-CSS pipeline. */
html.sidebar-collapsed .sidebar {
    display: none;
}

.sidebar-expand-handle {
    display: none;
    position: fixed;
    top: 0.6rem;
    left: 0.6rem;
    z-index: 100;
    background: var(--ld-ink, #16181c);
    color: var(--ld-paper, #f7f4ec);
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(22, 24, 28, 0.18);
    transition: background 0.18s ease;
}

.sidebar-expand-handle:hover {
    background: var(--ld-navy, #1f2a5e);
}

html.sidebar-collapsed .sidebar-expand-handle {
    display: inline-block;
}

/* When the sidebar is hidden, the floating expand handle sits at top-left
 * (fixed positioning). Shift the main canvas right so the handle doesn't
 * crash into the first piece of page content (Back button, page header,
 * etc.). The offset matches the handle's left position + width + breathing
 * room. */
html.sidebar-collapsed main {
    padding-left: 56px;
}

/* .sidebar-collapse-btn is rendered inside NavMenu and styled in its scoped CSS. */

/* ---------- /account/* Blazor pages (Profile, Email, Password) ---------- */

.account-shell {
    max-width: 880px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.account-title {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
}

.account-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2rem;
    align-items: start;
}

.account-content {
    min-width: 0;
}

.account-heading {
    margin: 0 0 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.account-alert {
    border-radius: 6px;
    padding: 0.625rem 0.875rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    list-style: none;
}

.account-alert li {
    margin-left: 0;
}

.account-alert-success {
    background-color: var(--green-soft);
    color: var(--green);
    border: 1px solid var(--green);
}

.account-alert-error {
    background-color: var(--red-soft);
    color: var(--red);
    border: 1px solid var(--red);
}

.account-actions {
    margin-top: 1rem;
}

.account-help {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 1rem;
}

.account-shell .field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.account-shell .field label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
}

.account-shell .field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.account-shell .field-row > .field {
    margin-bottom: 0;
}

.account-shell .field-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin: 0.25rem 0 0;
}

.account-shell .text-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.95rem;
    background-color: #fff;
}

.account-shell .text-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(31, 42, 94, 0.15);
}

.account-shell .text-input:disabled {
    background-color: var(--gray-100);
    color: var(--gray-500);
}

/* Owner-only Admin zone at the bottom of Account -> Profile (AccountProfile.razor).
   Deliberately not a sidebar entry — see NavMenu.razor's comment. */
.admin-zone {
    margin-top: 2.5rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--gray-300);
}

.admin-eyebrow {
    font-family: var(--ld-mono, monospace);
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-3, var(--gray-500));
    margin: 0 0 4px;
}

.admin-zone-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 1rem;
}

.admin-links {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.admin-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gray-300);
    color: var(--ink);
    text-decoration: none;
    transition: background 0.15s ease;
}

.admin-link:last-child {
    border-bottom: 0;
}

.admin-link:hover {
    background: var(--gray-100);
    color: var(--ink);
}

.admin-link-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-link-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
}

.admin-link-desc {
    font-size: 0.82rem;
    color: var(--ink-3, var(--gray-500));
}

.admin-chevron {
    color: var(--ink-3, var(--gray-500));
    flex-shrink: 0;
}

/* ---------- Owner-only admin pages (/admin/users, /admin/usage, /admin/referrals) ----------
   None of these have a sidebar entry (see NavMenu.razor); this breadcrumb is their only
   way back to where they're linked from (Account -> Profile). */
.admin-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--ink-3, var(--gray-500));
    text-decoration: none;
    margin: 0 0 0.75rem;
}

.admin-back-link:hover {
    color: var(--brand-primary);
}

/* Card-table treatment shared by every plain admin list (/admin/users,
   /admin/referrals) — same look as .usage-table below, minus the numeric-column
   specifics that page needs and this one doesn't. This class previously had no
   rules at all, so these tables just sat unstyled on the page background. */
.account-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    overflow: hidden;
}

.account-table th {
    text-align: left;
    font-family: var(--ld-mono, monospace);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3, var(--gray-500));
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-100);
}

.account-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule-soft, var(--gray-200));
    font-size: 0.88rem;
    color: var(--ink);
    vertical-align: top;
}

.account-table tr:last-child td {
    border-bottom: 0;
}

/* Sortable column headers, shared by .account-table and .usage-table. The label and the
   ▲/▼ indicator are both inside the <th>'s onclick target, so the whole header cell is the
   hit area, not just the text. */
.account-table th.sortable,
.usage-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.account-table th.sortable:hover,
.usage-table th.sortable:hover {
    color: var(--ink);
}

/* ---------- /admin/usage: summary stat strip + consolidated table ----------
   Wider than .account-shell (880px) — the redesigned table stacks two numbers
   per cell (e.g. AI spend month + all-time), which needs breathing room or it
   wraps into tall, cramped rows. */
.usage-shell {
    max-width: 1360px;
    margin: 0 auto;
    padding: 1rem 0 3rem;
}

.usage-stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 2rem;
}

.usage-stat-tile {
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 16px 18px;
}

.usage-stat-label {
    font-family: var(--ld-mono, monospace);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-3, var(--gray-500));
    margin: 0 0 6px;
}

.usage-stat-value {
    font-family: var(--ld-mono, monospace);
    font-size: 26px;
    font-weight: 500;
    color: var(--brand-primary);
    line-height: 1;
    margin: 0;
}

.usage-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    overflow: hidden;
}

.usage-table th {
    text-align: left;
    font-family: var(--ld-mono, monospace);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-3, var(--gray-500));
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-300);
    background: var(--gray-100);
}

.usage-table th.num {
    text-align: right;
}

.usage-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule-soft, var(--gray-200));
    font-size: 0.88rem;
    color: var(--ink);
    vertical-align: top;
}

.usage-table tr:last-child td {
    border-bottom: 0;
}

.usage-table td.num {
    text-align: right;
    font-family: var(--ld-mono, monospace);
    font-size: 0.85rem;
    white-space: nowrap;
}

.usage-cell-user {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.usage-cell-email {
    font-weight: 500;
}

.usage-cell-name {
    font-size: 0.78rem;
    color: var(--ink-3, var(--gray-500));
}

.usage-cell-stacked {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
}

.usage-cell-secondary {
    font-size: 0.78rem;
    color: var(--ink-3, var(--gray-500));
}

.usage-muted {
    color: var(--ink-3, var(--gray-500));
}

/* ---------- Shared: search box + pager above/below an admin table ---------- */
.admin-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.admin-table-search {
    max-width: 320px;
    width: 100%;
}

.admin-table-count {
    font-size: 0.82rem;
    color: var(--ink-3, var(--gray-500));
    white-space: nowrap;
}

.table-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.table-pager-status {
    font-size: 0.82rem;
    color: var(--ink-3, var(--gray-500));
    font-family: var(--ld-mono, monospace);
}

.table-pager .btn-link:disabled {
    color: var(--gray-300);
    cursor: default;
    pointer-events: none;
}

/* ---------- /admin/users: status + actions ---------- */
.user-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
}

.user-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
}

.user-status.is-disabled {
    color: var(--ink-3, var(--gray-500));
}

.user-status.is-disabled::before {
    background: var(--red);
}

@media (max-width: 640px) {
    .account-shell {
        padding: 0.5rem 0 2rem;
    }

    .account-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .account-layout .account-tabs {
        display: none;
    }

    .account-shell .field-row {
        grid-template-columns: 1fr;
    }
}

/* === Agent pop-out window === */

/* `html.popout-mode` is set synchronously by PopoutLayout.razor so the chrome-free shell
   applies during SSR without a flash of the sidebar. The pop-out window holds exactly one
   conversation, so the transcript takes the full viewport height. */
html.popout-mode,
html.popout-mode body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--surface);
}

html.popout-mode .sidebar,
html.popout-mode .sidebar-expand-handle {
  display: none !important;
}

.popout-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

.popout-empty {
  padding: var(--space-5) var(--space-4);
  text-align: center;
  color: var(--ink-3, var(--gray-500));
}

/* Native controls (selects, scrollbars, date pickers) follow color-scheme, not our tokens.
   Without this the shell's pinned-light palette still drew a dark <select> on the projects
   filter bar, which is what made that page look half-themed. */
html[data-theme="light"] {
  color-scheme: light;
}
