/* ============================================================
   Survation Mailer — design system
   Token-first: light + dark content themes, permanently dark
   sidebar. Legacy class names from the pre-redesign templates
   are kept working and mapped onto the new tokens.
   ============================================================ */

/* ---------- fonts (self-hosted, variable) ---------- */

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-var.8e433c0592f7.woff2") format("woff2-variations");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-var.b058178d7f30.woff2") format("woff2-variations");
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

/* ---------- tokens ---------- */

:root {
    --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* light theme (default) */
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-2: #eef1f4;
    --ink: #17222d;
    --muted: #5d6c7b;
    --line: #e2e7ec;
    --line-strong: #cdd5dc;

    --accent: #007ec3;             /* Survation blue — the one accent hue */
    --accent-hover: #006aa6;
    --accent-soft: #e3f1f9;
    --accent-soft-ink: #005e8f;

    /* semantic status colors — separate from the accent */
    --success: #1e7a4c;
    --success-soft: #e2f2e9;
    --success-border: #c4e4d1;
    --warning: #96660a;
    --warning-soft: #faf0da;
    --warning-border: #eeddb0;
    --danger: #b03535;
    --danger-soft: #fae8e8;
    --danger-border: #f0caca;

    --shadow-1: 0 1px 2px rgba(23, 34, 45, 0.05);
    --shadow-2: 0 1px 2px rgba(23, 34, 45, 0.05), 0 4px 12px rgba(23, 34, 45, 0.06);
    --shadow-btn: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(0, 90, 140, 0.28);
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);

    /* sidebar — dark in both themes */
    --side-bg: #121b23;
    --side-line: #1f2b36;
    --side-ink: #93a3b2;
    --side-ink-bright: #eaf1f7;
    --side-label: #566a78;
    --side-active-bg: rgba(41, 157, 224, 0.13);
    --side-accent: #35aae4;
    --side-hover-bg: rgba(255, 255, 255, 0.045);

    /* spacing scale (kept from the previous system — templates
       reference these inline) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 20px;
    --sp-5: 32px;
    --sp-6: 48px;

    --radius: 8px;
    --radius-sm: 6px;

    /* form controls */
    --field-h: 34px;
    --field-bg: var(--surface);
    --field-border: var(--line-strong);
    --field-border-hover: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
    --placeholder: #93a0ac;
    /* chevron for custom-styled selects (stroke = --muted, light theme) */
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%235d6c7b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
    /* filter used to tint native date/time picker indicators toward --muted */
    --picker-filter: none;

    /* legacy aliases — pre-redesign templates reference these */
    --border: var(--line-strong);
    --sage: var(--surface-2);
    --brand-blue: var(--accent);
    --success-bg: var(--success-soft);
    --warning-bg: var(--warning-soft);
    --danger-bg: var(--danger-soft);
    --info-bg: var(--accent-soft);
    --info-border: color-mix(in srgb, var(--accent) 25%, var(--surface));
}

[data-theme="dark"] {
    --bg: #0e141a;
    --surface: #161e26;
    --surface-2: #1c252f;
    --ink: #e6edf3;
    --muted: #8b9aa9;
    --line: #232f3a;
    --line-strong: #32404d;

    --accent: #2ea3e0;
    --accent-hover: #4db4ea;
    --accent-soft: #12293a;
    --accent-soft-ink: #63bfef;

    --success: #4cc084;
    --success-soft: #12291d;
    --success-border: #1e4530;
    --warning: #e0a83e;
    --warning-soft: #2d2410;
    --warning-border: #4a3c1a;
    --danger: #e2716f;
    --danger-soft: #331717;
    --danger-border: #522525;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.35);
    --shadow-btn: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 1px 2px rgba(0, 0, 0, 0.5);

    /* form controls (dark) */
    --field-bg: #10181f;
    --field-border: #33414e;
    --field-border-hover: color-mix(in srgb, var(--accent) 55%, #33414e);
    --placeholder: #647585;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238b9aa9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
    /* invert + tune so native calendar/clock icons read on dark fields */
    --picker-filter: invert(0.85) brightness(1.1);
}

/* ---------- reset / base ---------- */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    display: flex;
    min-height: 100vh;
}

a {
    color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[x-cloak] {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- type scale ---------- */

h1 {
    font-size: 20px;
    font-weight: 650;
    letter-spacing: -0.015em;
    line-height: 1.3;
    margin: 0 0 var(--sp-4);
    text-wrap: balance;
}

/* section label — h2 keeps its established uppercase-label role */
h2 {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    margin: var(--sp-5) 0 var(--sp-3);
}

h1 + p,
h1 + .subtitle,
.page-sub {
    color: var(--muted);
    font-size: 13px;
    margin-top: -0.85rem;
    margin-bottom: var(--sp-4);
    max-width: 68ch;
}

small,
.help-text {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
    margin-top: var(--sp-1);
}

.muted {
    color: var(--muted);
}

.mono,
.num {
    font-variant-numeric: tabular-nums;
}

/* ---------- app shell: sidebar ---------- */

.sidebar {
    width: 228px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--side-bg);
    border-right: 1px solid var(--side-line);
    display: flex;
    flex-direction: column;
    padding: 14px 10px 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 8px 16px;
    color: var(--side-ink-bright);
    font-weight: 650;
    font-size: 14.5px;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    flex-shrink: 0;
    background: #e0e2da;
    display: grid;
    place-items: center;
    color: #14181c;
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.brand small {
    display: block;
    font-weight: 450;
    font-size: 10.5px;
    color: var(--side-ink);
    letter-spacing: 0.02em;
    margin: 0;
}

.side-collapse-btn {
    margin-left: auto;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--side-ink);
    padding: 0;
    box-shadow: none;
}

.side-collapse-btn:hover {
    color: var(--side-ink-bright);
    background: rgba(255, 255, 255, 0.07);
}

.side-collapse-btn svg {
    width: 14px;
    height: 14px;
}

.nav-group {
    margin-top: 14px;
}

.nav-group-label {
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--side-label);
    padding: 0 10px 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    margin: 1px 0;
    border-radius: 7px;
    cursor: pointer;
    color: var(--side-ink);
    font-size: 13px;
    font-weight: 480;
    text-decoration: none;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    position: relative;
    box-shadow: none;
}

.nav-item:hover {
    color: var(--side-ink-bright);
    background: var(--side-hover-bg);
}

.nav-item.active {
    color: var(--side-ink-bright);
    background: var(--side-active-bg);
    font-weight: 560;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--side-accent);
}

.nav-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active svg {
    opacity: 1;
    color: var(--side-accent);
}

.nav-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: #6b7f8e;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 5px;
    padding: 1px 6px;
}

.side-foot {
    margin-top: auto;
    border-top: 1px solid var(--side-line);
    padding-top: 10px;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    background: none;
    border: 0;
    color: var(--side-ink);
    font-family: inherit;
    font-size: 12.5px;
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    position: relative;
    box-shadow: none;
}

.theme-toggle:hover {
    color: var(--side-ink-bright);
    background: var(--side-hover-bg);
}

.theme-toggle svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}

.account {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px 6px;
    position: relative;
}

.avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #2b3b48;
    color: #a8bccb;
    display: grid;
    place-items: center;
    font-size: 10.5px;
    font-weight: 650;
}

.account .who {
    line-height: 1.25;
    min-width: 0;
}

.account .who b {
    display: block;
    color: var(--side-ink-bright);
    font-size: 12px;
    font-weight: 560;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account .who span {
    font-size: 10.5px;
    color: #677b8a;
}

.account-links {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 10px;
    padding: 0 10px 6px;
    font-size: 11px;
}

.account-links a {
    color: var(--side-ink);
    text-decoration: none;
}

.account-links a:hover {
    color: var(--side-ink-bright);
    text-decoration: underline;
}

/* --- collapsed (icon-only) sidebar --- */

[data-sidebar="collapsed"] .sidebar {
    width: 56px;
    padding: 14px 7px 10px;
}

[data-sidebar="collapsed"] .brand {
    padding: 6px 0 10px;
    flex-direction: column;
    gap: 8px;
}

[data-sidebar="collapsed"] .brand > *:not(.brand-mark):not(.side-collapse-btn) {
    display: none;
}

[data-sidebar="collapsed"] .side-collapse-btn {
    margin: 0 auto;
}

[data-sidebar="collapsed"] .nav-group-label {
    display: none;
}

[data-sidebar="collapsed"] .nav-group {
    border-top: 1px solid var(--side-line);
    padding-top: 6px;
    margin-top: 8px;
}

[data-sidebar="collapsed"] .nav-item {
    justify-content: center;
    padding: 8px 0;
}

[data-sidebar="collapsed"] .nav-item svg {
    width: 16px;
    height: 16px;
}

[data-sidebar="collapsed"] .nav-text,
[data-sidebar="collapsed"] .nav-count {
    display: none;
}

[data-sidebar="collapsed"] .nav-item.active::before {
    left: -7px;
}

[data-sidebar="collapsed"] .theme-toggle {
    justify-content: center;
    padding: 8px 0;
}

[data-sidebar="collapsed"] .account {
    justify-content: center;
    padding: 8px 0 4px;
}

[data-sidebar="collapsed"] .account .who,
[data-sidebar="collapsed"] .account-links {
    display: none;
}

/* custom tooltips — collapsed sidebar only */
[data-sidebar="collapsed"] .nav-item::after,
[data-sidebar="collapsed"] .theme-toggle::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1f2b38;
    color: #eaf1f7;
    font-size: 11.5px;
    font-weight: 520;
    letter-spacing: 0.01em;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease 0.1s;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    z-index: 60;
}

[data-sidebar="collapsed"] .nav-item:hover::after,
[data-sidebar="collapsed"] .theme-toggle:hover::after {
    opacity: 1;
}

/* narrow screens always get the icon rail */
@media (max-width: 880px) {
    .sidebar {
        width: 56px;
        padding: 14px 7px 10px;
    }

    .brand {
        padding: 6px 0 10px;
        flex-direction: column;
        gap: 8px;
    }

    .brand > *:not(.brand-mark):not(.side-collapse-btn) {
        display: none;
    }

    .side-collapse-btn {
        display: none;
    }

    .nav-group-label {
        display: none;
    }

    .nav-group {
        border-top: 1px solid var(--side-line);
        padding-top: 6px;
        margin-top: 8px;
    }

    .nav-item {
        justify-content: center;
        padding: 8px 0;
    }

    .nav-text,
    .nav-count {
        display: none;
    }

    .theme-toggle {
        justify-content: center;
        padding: 8px 0;
    }

    .account {
        justify-content: center;
        padding: 8px 0 4px;
    }

    .account .who,
    .account-links {
        display: none;
    }
}

/* ---------- app shell: content column ---------- */

.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.site-main {
    width: 100%;
    max-width: 1200px;
    padding: 24px 28px 96px;
}

.crumbs {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

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

.crumbs a:hover {
    color: var(--accent);
}

.crumbs .sep {
    margin: 0 6px;
    opacity: 0.5;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}

.page-head h1 {
    margin-bottom: 0;
}

.page-head .page-sub {
    margin: 3px 0 0;
}

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

/* secondary nav (dashboard tabs) */
.dashboard-nav {
    display: flex;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.dashboard-nav a {
    display: inline-block;
    padding: var(--sp-2) 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 570;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.dashboard-nav a:hover {
    color: var(--ink);
}

.dashboard-nav a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ---------- messages (toasts) / callouts ---------- */

.messages {
    list-style: none;
    margin: 0;
    padding: 0;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: min(420px, calc(100vw - 40px));
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 520;
    box-shadow: var(--shadow-2);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.message.is-leaving {
    opacity: 0;
    transform: translateY(8px);
}

.message::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
    background: var(--muted);
}

.message.success::before {
    background: var(--success);
}

.message.info::before,
.message.debug::before {
    background: var(--accent);
}

.message.warning::before {
    background: var(--warning);
}

.message.error::before,
.message.danger::before {
    background: var(--danger);
}

.message-close {
    margin-left: auto;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 0 0 6px;
    box-shadow: none;
}

.message-close:hover {
    background: none;
    color: var(--ink);
}

.callout {
    position: relative;
    padding: 11px 14px 11px 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
    margin-bottom: var(--sp-3);
    font-size: 13px;
    line-height: 1.55;
    /* neutral info glyph by default; each variant overrides it */
    --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.5'/%3E%3Cpath d='M8 7.4v3.5M8 5.1v.1'/%3E%3C/svg%3E");
}

/* leading icon — absolutely placed so it works with any inner markup
   (plain text, <p>, <ul>) without forcing a flex layout */
.callout::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 12px;
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: var(--callout-ico) center / contain no-repeat;
    mask: var(--callout-ico) center / contain no-repeat;
}

/* first/last child margins collapse so multi-paragraph callouts sit tidily */
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.callout-info {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--accent-soft-ink);
}

.callout-warning {
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning);
    font-weight: 560;
    --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round' stroke-linecap='round'%3E%3Cpath d='M8 2 14.5 13.5H1.5Z'/%3E%3Cpath d='M8 6.4v3.1M8 11.4v.1'/%3E%3C/svg%3E");
}

.callout-danger {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
    font-weight: 560;
    --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.5'/%3E%3Cpath d='M4.3 8h7.4'/%3E%3C/svg%3E");
}

.callout-success {
    background: var(--success-soft);
    border-color: var(--success-border);
    color: var(--success);
    font-weight: 560;
    --callout-ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.5'/%3E%3Cpath d='m5.1 8.2 2 2 3.8-4.2'/%3E%3C/svg%3E");
}

/* optional heading line inside a callout */
.callout-title {
    display: block;
    font-weight: 640;
    margin-bottom: 2px;
}

/* ---------- contextual help link ---------- */

.help-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    color: var(--muted);
    text-decoration: none;
}

.help-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

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

form p,
.field {
    margin: 0 0 var(--sp-3);
}

label {
    display: block;
    font-size: 12px;
    font-weight: 570;
    margin-bottom: var(--sp-1);
}

.required {
    color: var(--danger);
    font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="datetime-local"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
    font-family: inherit;
    font-size: 13px;
    min-height: var(--field-h);
    padding: 7px 11px;
    border: 1px solid var(--field-border);
    border-radius: var(--radius-sm);
    background: var(--field-bg);
    color: var(--ink);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-1);
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
    -webkit-appearance: none;
    appearance: none;
}

/* hover cue on the whole family (not while disabled) */
input:hover:not(:disabled):not(:focus),
select:hover:not(:disabled):not(:focus),
textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--field-border-hover);
}

::placeholder {
    color: var(--placeholder);
    opacity: 1;
}

textarea {
    max-width: 100%;
    resize: vertical;
    min-height: 68px;
    line-height: 1.5;
}

/* native select: custom chevron, room on the right for it */
select {
    padding-right: 32px;
    background-image: var(--select-chevron);
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 16px 16px;
    cursor: pointer;
}

/* a multi-select is a list, not a dropdown — no chevron, taller box */
select[multiple] {
    background-image: none;
    padding: 4px;
    min-height: 92px;
    cursor: default;
}

select[multiple] option {
    padding: 4px 7px;
    border-radius: 4px;
}

/* tint native date/time picker glyphs so they read in dark mode */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
    filter: var(--picker-filter);
    cursor: pointer;
    opacity: 0.75;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* search: keep the native clear affordance visible on dark */
input[type="search"]::-webkit-search-cancel-button {
    filter: var(--picker-filter);
    cursor: pointer;
}

/* file input: turn the whole control into a designed field with a real button */
input[type="file"] {
    font-family: inherit;
    font-size: 13px;
    width: 100%;
    max-width: 420px;
    color: var(--muted);
    background: var(--field-bg);
    border: 1px dashed var(--field-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 0.12s ease, background 0.12s ease;
}

input[type="file"]:hover:not(:disabled) {
    border-color: var(--field-border-hover);
}

input[type="file"]::file-selector-button {
    font-family: inherit;
    font-weight: 560;
    font-size: 12px;
    margin-right: 12px;
    padding: 5px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease;
}

input[type="file"]:hover::file-selector-button {
    border-color: var(--accent);
    color: var(--accent);
}

input:focus,
select:focus,
textarea:focus,
input[type="file"]:focus {
    outline: none;
    border-color: var(--accent);
    border-style: solid;
    box-shadow: var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--surface-2);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.75;
}

/* browser autofill paints its own (light) background that ignores our fill,
   which reads badly on dark fields — pin it back to the field tokens */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--ink);
    -webkit-box-shadow: 0 0 0 100px var(--field-bg) inset;
    caret-color: var(--ink);
    transition: background-color 9999s ease 0s;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
    width: auto;
    min-height: 0;
    height: 15px;
    box-shadow: none;
    -webkit-appearance: auto;
    appearance: auto;
    cursor: pointer;
}

/* inline field: a label sitting beside its checkbox/radio */
label.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 480;
    margin-bottom: 0;
    cursor: pointer;
}

tr.dim {
    color: var(--muted);
}

.field-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
}

.field-row > .field {
    flex: 1 1 220px;
}

fieldset.criteria {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: var(--sp-2) var(--sp-4) var(--sp-4);
    margin: 0 0 var(--sp-4);
    min-width: 0;
}

fieldset.criteria legend {
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 6px;
}

ul.errorlist {
    list-style: none;
    margin: var(--sp-1) 0 0;
    padding: 0;
    color: var(--danger);
    font-size: 12px;
    font-weight: 570;
}

/* ---------- filter bar (list filters + applied chips) ---------- */

.filter-bar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 14px 16px;
    margin-bottom: var(--sp-4);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.filter-field > label {
    margin: 0;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.filter-field input,
.filter-field select {
    width: 100%;
    min-width: 180px;
    max-width: 220px;
}

.filter-field.grow {
    flex: 1 1 200px;
}

.filter-field.grow input {
    max-width: none;
}

/* actions hug the right edge and bottom-align with the fields */
.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-left: auto;
}

/* applied-filter chips, shown once a filter is active */
.applied-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.applied-filters .lbl {
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 540;
    padding: 3px 5px 3px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
    white-space: nowrap;
    max-width: 320px;
}

.chip .k {
    opacity: 0.75;
    font-weight: 600;
}

.chip .v {
    font-weight: 640;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chip-remove {
    display: inline-grid;
    place-items: center;
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    border-radius: 50%;
    background: none;
    border: 0;
    box-shadow: none;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease;
}

.chip-remove:hover {
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    color: var(--accent-soft-ink);
    text-decoration: none;
}

.chip-clear {
    font-size: 12px;
    font-weight: 560;
    color: var(--muted);
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 999px;
}

.chip-clear:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

/* toolbar row above lists (search + view switches) */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    display: inline-block;
}

.search-box svg {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    width: 13px;
    height: 13px;
    color: var(--muted);
    pointer-events: none;
}

.search-box input {
    padding-left: 28px;
    width: 240px;
}

.seg-control {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 2px;
    box-shadow: var(--shadow-1);
}

.seg-control button,
.seg-control a {
    font-family: inherit;
    font-size: 12px;
    font-weight: 550;
    color: var(--muted);
    border: 0;
    background: none;
    box-shadow: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transform: none;
}

.seg-control button.on,
.seg-control a.on {
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
}

.seg-control button:hover:not(.on),
.seg-control a:hover:not(.on) {
    color: var(--ink);
    background: none;
}

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

button,
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: inherit;
    font-weight: 560;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 7px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
    color: #fff;
    box-shadow: var(--shadow-btn);
    transition: background 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.05s ease;
}

button svg,
.btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

button:hover,
.btn:hover {
    background: var(--accent-hover);
}

button:active,
.btn:active {
    transform: translateY(1px);
}

button:disabled,
.btn:disabled {
    background: var(--surface-2);
    color: var(--muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
    box-shadow: var(--shadow-1);
}

.btn-secondary:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: linear-gradient(180deg, #c74a4a, #b03535);
    color: #fff;
}

.btn-danger:hover {
    background: #9c2e2e;
}

.btn-ghost {
    background: none;
    color: var(--muted);
    box-shadow: none;
}

.btn-ghost:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-link {
    background: none;
    border: 0;
    box-shadow: none;
    color: var(--accent);
    padding: 0;
    font-weight: 550;
    text-decoration: underline;
}

.btn-link:hover {
    background: none;
    color: var(--accent-hover);
}

.btn-sm {
    padding: 4px 11px;
    font-size: 12px;
}

.actions {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    margin-top: var(--sp-3);
    flex-wrap: wrap;
}

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

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    color: inherit;
    font-family: inherit;
}

.table-scroll {
    overflow-x: auto;
}

/* contained table card */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    margin-bottom: var(--sp-4);
}

table th,
table td {
    text-align: left;
    padding: 9px 14px;
    border-bottom: 1px solid var(--line);
}

table thead th {
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

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

table tbody tr {
    transition: background 0.1s ease;
}

table tbody tr:hover {
    background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

td.num,
th.num {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

td a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 520;
}

td a:hover {
    text-decoration: underline;
}

td.nowrap,
th.nowrap {
    white-space: nowrap;
}

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    font-size: 12px;
    color: var(--muted);
    background: var(--surface);
    flex-wrap: wrap;
}

/* key/value tables don't want hover or heavy headers */
table.kv tbody tr:hover {
    background: transparent;
}

table.kv th {
    background: transparent;
    text-transform: none;
    letter-spacing: normal;
    font-size: 12.5px;
    font-weight: 570;
    color: var(--ink);
    width: 1%;
    white-space: nowrap;
}

dl.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--sp-2) var(--sp-4);
    margin: 0 0 var(--sp-4);
}

dl.meta dt {
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 570;
}

dl.meta dd {
    margin: 0;
}

/* sortable headers */
th.sortable {
    white-space: nowrap;
}

th.sortable a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    text-decoration: none;
}

th.sortable a:hover {
    color: var(--ink);
}

th.sortable a.active {
    color: var(--ink);
    font-weight: 700;
}

th.sortable .caret {
    font-size: 0.7em;
}

/* ---------- badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 2px 8px 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    background: var(--surface-2);
    color: var(--muted);
}

.badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
    opacity: 0.85;
}

.badge-tool {
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
}

.badge-native,
.badge-neutral {
    background: var(--surface-2);
    color: var(--muted);
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 18px 20px;
    margin-bottom: var(--sp-4);
}

.card > h2:first-child {
    margin-top: 0;
}

/* a numbered step header inside a card (builder flows) */
.card-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: var(--sp-4);
}

.card-step b {
    font-size: 14px;
    font-weight: 620;
    display: block;
}

.card-step p {
    margin: 1px 0 0;
    font-size: 12.5px;
}

.step-badge {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 650;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

.card-danger {
    border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

.usage-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 16px 20px;
    margin-bottom: var(--sp-4);
}

.usage-panel h2 {
    margin-top: 0;
}

.usage-panel .muted {
    color: var(--muted);
    font-size: 12.5px;
}

.usage-panel .warning {
    color: var(--danger);
    font-weight: 600;
}

/* usage meter */
.meter {
    height: 6px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
    margin: 8px 0 6px;
}

.meter > i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--side-accent));
}

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

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: var(--sp-4);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 14px 16px 12px;
    position: relative;
    overflow: hidden;
}

.stat-card .num {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.stat-card .lbl {
    font-size: 11.5px;
    font-weight: 550;
    color: var(--muted);
    letter-spacing: 0.01em;
}

.stat-card.hero {
    grid-column: 1 / -1;
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.stat-card.hero .num {
    color: var(--accent);
    font-size: 26px;
}

.stat-card.bad {
    border-color: var(--danger-border);
}

.stat-card.bad .num {
    color: var(--danger);
}

.delta {
    font-size: 11px;
    font-weight: 600;
    border-radius: 5px;
    padding: 1px 6px;
    margin-left: 6px;
    vertical-align: 3px;
    font-family: var(--font-ui);
    background: var(--surface-2);
    color: var(--muted);
}

.delta.up {
    color: var(--success);
    background: var(--success-soft);
}

.delta.down {
    color: var(--danger);
    background: var(--danger-soft);
}

.stat-row-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin: 0 0 var(--sp-4);
}

.mini-stat {
    font-size: 12px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
}

.mini-stat b {
    color: var(--ink);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* sparkline in a stat card */
.stat-card .spark {
    position: absolute;
    right: 10px;
    bottom: 10px;
    opacity: 0.9;
}

/* ---------- quick-action tiles ---------- */

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: var(--sp-4);
}

.quick {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 14px 16px;
    color: var(--ink);
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.quick:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-2);
    transform: translateY(-1px);
}

.quick-ic {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    display: grid;
    place-items: center;
}

.quick-ic svg {
    width: 15px;
    height: 15px;
}

.quick b {
    font-size: 13px;
    font-weight: 590;
    display: block;
}

.quick span {
    font-size: 12px;
    color: var(--muted);
}

/* ---------- activity feed ---------- */

.activity {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity li {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
}

.activity li:last-child {
    border-bottom: 0;
}

.activity .t {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
    width: 62px;
    padding-top: 1px;
}

.activity b {
    font-weight: 580;
}

/* ---------- two-column layout ---------- */

.two-col {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 1000px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* ---------- stepper ---------- */

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0 0 var(--sp-4);
    flex-wrap: wrap;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--muted);
}

.step .n {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    border: 1.5px solid var(--line-strong);
    color: var(--muted);
    background: var(--surface);
    flex-shrink: 0;
}

.step.done .n {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.step.cur {
    color: var(--ink);
}

.step.cur .n {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--focus-ring);
}

.step-line {
    flex: 0 0 34px;
    height: 1.5px;
    background: var(--line-strong);
    margin: 0 10px;
}

.step-line.done {
    background: var(--accent);
}

/* ---------- pre-flight checklist ---------- */

.check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}

.check-row:last-child {
    border-bottom: 0;
}

.check-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    margin-top: 1px;
    font-size: 12px;
    font-weight: 700;
}

.check-icon svg {
    width: 12px;
    height: 12px;
}

.check-pass {
    background: var(--success-soft);
    color: var(--success);
}

.check-warn {
    background: var(--warning-soft);
    color: var(--warning);
}

.check-block {
    background: var(--danger-soft);
    color: var(--danger);
}

.check-info {
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
}

.check-row b {
    font-size: 13px;
    font-weight: 590;
    display: block;
}

.check-row p {
    margin: 1px 0 0;
    font-size: 12.5px;
    color: var(--muted);
    max-width: 68ch;
}

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

.project-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    margin-bottom: var(--sp-3);
}

.proj-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

.proj-head b {
    font-size: 14px;
    font-weight: 620;
}

.proj-head b a {
    color: inherit;
    text-decoration: none;
}

.proj-head b a:hover {
    color: var(--accent);
}

.proj-ref {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    background: var(--surface-2);
    border-radius: 5px;
    padding: 1px 7px;
}

.proj-head .spacer {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.proj-meta {
    font-size: 12px;
    color: var(--muted);
}

.project-card table {
    font-size: 12.5px;
}

.project-card thead th {
    background: var(--surface);
}

.project-card tbody tr:last-child td {
    border-bottom: 0;
}

/* compact projects view */
.projects-compact .project-card table,
.projects-compact .project-card .proj-body {
    display: none;
}

.projects-compact .proj-head {
    border-bottom: 0;
}

.projects-compact .proj-head .spacer {
    display: none;
}

.projects-compact .project-card {
    margin-bottom: 8px;
}

/* legacy foldable project list (kept until conversion) */
.project-fold {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: var(--sp-2);
}

.project-fold > summary {
    cursor: pointer;
    padding: 0.7rem 1rem;
    font-weight: 570;
    list-style-position: inside;
}

.project-fold-name {
    font-weight: 650;
}

.project-fold-body {
    padding: 0 1rem 1rem;
}

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

.tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: var(--sp-4);
}

.tpl-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    overflow: hidden;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

a.tpl-card {
    text-decoration: none;
    color: inherit;
    display: block;
}

.tpl-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-2);
    transform: translateY(-1px);
}

.tpl-thumb {
    height: 104px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tpl-thumb i {
    display: block;
    border-radius: 3px;
    background: var(--line-strong);
    opacity: 0.6;
    height: 7px;
}

.tpl-thumb .hd {
    height: 14px;
    width: 55%;
    background: var(--accent);
    opacity: 0.35;
}

.tpl-thumb .cta {
    height: 16px;
    width: 34%;
    background: var(--accent);
    opacity: 0.5;
    border-radius: 5px;
}

.tpl-body {
    padding: 11px 14px 13px;
}

.tpl-body b {
    font-size: 13px;
    font-weight: 600;
    display: block;
    margin-bottom: 5px;
}

.tpl-meta {
    font-size: 11.5px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- live / htmx-driven panels ---------- */

.live-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
}

.live-panel .count-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 0 var(--sp-2);
}

.live-panel .count-line strong {
    font-size: 1.3rem;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

.htmx-indicator {
    opacity: 0;
    transition: opacity 150ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

.updating-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--accent-soft-ink);
    background: var(--accent-soft);
    padding: 3px 9px;
    border-radius: 999px;
    margin-bottom: var(--sp-2);
}

.updating-chip .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}

/* ---------- progress bars ---------- */

.progress-track {
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
    margin: var(--sp-3) 0 0.4rem;
}

.progress-fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--side-accent));
    transition: width 0.4s ease;
}

.progress-indeterminate {
    height: 100%;
    width: 40%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--side-accent));
    animation: slide 1.2s ease-in-out infinite alternate;
}

@keyframes slide {
    0% {
        margin-left: 0;
    }

    100% {
        margin-left: 60%;
    }
}

/* ---------- empty states ---------- */

.empty-state {
    text-align: center;
    padding: var(--sp-5) var(--sp-3);
    color: var(--muted);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
}

.empty-state p {
    margin: 0 0 var(--sp-3);
}

.empty-state p:last-child {
    margin-bottom: 0;
}

/* ---------- pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
    font-size: 12.5px;
    color: var(--muted);
}

.pagination a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 570;
}

.pagination a:hover {
    text-decoration: underline;
}

.table-foot .pagination {
    margin-top: 0;
}

/* ---------- in-app template editor ---------- */

.editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
}

.editor-tabs {
    display: inline-flex;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tab-btn {
    padding: var(--sp-1) var(--sp-3);
    border: 0;
    border-radius: 0;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    box-shadow: none;
}

.tab-btn + .tab-btn {
    border-left: 1px solid var(--line-strong);
}

.tab-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.tab-btn.is-active {
    background: var(--accent);
    color: #fff;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
    padding: var(--sp-2);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: var(--surface-2);
}

.tag-btn {
    padding: 2px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 12px;
    line-height: 1.6;
    box-shadow: none;
}

.tag-btn:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
}

.code-area {
    width: 100%;
    max-width: 100%;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.5;
    border: 1px solid var(--line);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    padding: var(--sp-2);
    resize: vertical;
    tab-size: 2;
}

.merge-fields {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1);
    margin-top: var(--sp-2);
}

.merge-chip {
    padding: 2px 8px;
    border: 1px dashed var(--line-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11.5px;
    box-shadow: none;
}

.merge-chip:hover {
    background: var(--surface);
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
}

.template-preview-frame {
    width: 100%;
    height: 480px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
}

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

.radio-cards {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.radio-card {
    flex: 1 1 220px;
    display: flex;
    gap: var(--sp-2);
    align-items: flex-start;
    padding: var(--sp-3);
    border: 1.5px solid var(--line-strong);
    border-radius: 9px;
    cursor: pointer;
    background: var(--surface);
    transition: border-color 0.12s ease, background 0.12s ease;
}

.radio-card:hover {
    border-color: var(--accent);
}

.radio-card.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.radio-card small {
    display: block;
    color: var(--muted);
}

/* ============================================================
   Inline hint tooltip — an (i) icon that reveals a short note on
   hover, keyboard focus, or tap. Use for secondary field help;
   keep anything actionable (links, warnings) inline instead.
   Markup: templates/components/_hint.html
   ============================================================ */

.label-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--sp-1);
}

.label-row label {
    margin-bottom: 0;
}

.hint {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    line-height: 0;
}

.hint-btn {
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: help;
    box-shadow: none;
}

.hint-btn svg {
    width: 15px;
    height: 15px;
}

.hint-btn:hover,
.hint-btn:focus-visible {
    color: var(--accent);
    background: none;
}

.hint-pop {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    z-index: 70;
    width: max-content;
    max-width: 250px;
    padding: 8px 11px;
    background: #1f2b38;
    color: #eaf1f7;
    font-size: 12px;
    font-weight: 460;
    line-height: 1.5;
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    white-space: normal;
}

.hint-pop::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2b38;
}

.hint-pop a {
    color: var(--side-accent);
}

/* ============================================================
   Help page — PM-focused topic cards, steps, and button chips.
   Also used by the "Launch a send" card on Home.
   ============================================================ */

.help-hero {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: stretch;
    margin-bottom: var(--sp-5);
}

.help-hero-step {
    flex: 1 1 150px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
}

.help-hero-step .step-badge {
    margin-bottom: 2px;
}

/* clickable variant (Home "Launch a send" card) */
a.help-hero-step {
    text-decoration: none;
    color: var(--ink);
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

a.help-hero-step:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

.launch-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}

.launch-head h2 {
    margin: 0;
}

.help-hero-step b {
    font-size: 13px;
    font-weight: 620;
}

.help-hero-step p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

/* grid of topic cards */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.topic-tile {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    text-decoration: none;
    color: var(--ink);
    transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.topic-tile:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

.topic-tile .topic-ico {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
}

.topic-tile .topic-ico svg {
    width: 18px;
    height: 18px;
}

.topic-tile b {
    font-size: 13.5px;
    font-weight: 620;
}

.topic-tile p {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

/* a single topic article */
.topic {
    scroll-margin-top: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.topic-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--sp-2);
}

.topic-head .topic-ico {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    flex-shrink: 0;
}

.topic-head .topic-ico svg {
    width: 16px;
    height: 16px;
}

.topic-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 640;
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--ink);
}

.topic-meta {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 var(--sp-3);
}

/* numbered steps within a topic */
.steps {
    list-style: none;
    margin: 0 0 var(--sp-4);
    padding: 0;
    counter-reset: step;
}

.steps > li {
    position: relative;
    padding: 0 0 var(--sp-4) 38px;
    counter-increment: step;
}

.steps > li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 650;
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

/* vertical connector line between step badges */
.steps > li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: 13px;
    top: 30px;
    bottom: 4px;
    width: 1px;
    background: var(--line);
}

.steps > li > .step-title {
    font-size: 13.5px;
    font-weight: 600;
    display: block;
    margin-bottom: 3px;
    padding-top: 3px;
}

.steps > li p {
    margin: 0 0 6px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--muted);
}

/* a chip that shows a button/control the user should click */
.ui-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 560;
    line-height: 1.7;
    white-space: nowrap;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    vertical-align: baseline;
}

.ui-chip svg {
    width: 12px;
    height: 12px;
}

.ui-chip.is-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.ui-chip.is-danger {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

/* a keyboard-key / menu-path style token */
.ui-path {
    font-family: var(--font-mono);
    font-size: 11.5px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* --- Explore: searchable / tickable high-cardinality breakdown --- */
.explore-breakdown .breakdown-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}
.explore-breakdown .breakdown-search {
    flex: 1 1 240px;
    min-width: 200px;
}
.explore-breakdown .breakdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    color: var(--muted);
    font-size: 0.92em;
}
.explore-breakdown .breakdown-selection {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 8px 12px;
    margin-bottom: var(--sp-3);
    background: var(--accent-soft);
    color: var(--accent-soft-ink);
    border: 1px solid var(--info-border);
    border-radius: var(--radius);
}
.explore-breakdown .breakdown-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}
.explore-breakdown .table-scroll {
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.explore-breakdown thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
}
.explore-breakdown th.breakdown-tick,
.explore-breakdown td.breakdown-tick {
    width: 1%;
    text-align: center;
    padding-right: 4px;
    padding-left: 12px;
}
.explore-breakdown tr.is-ticked td {
    background: var(--accent-soft);
}
