/* ── Design tokens ────────────────────────────────────────────────────────
   The colours of the Rodly client (rodly.css / login.css), promoted to custom properties. */
:root {
    --rd-blue: #1986f2;
    --rd-blue-soft: #60a5fa;
    --rd-blue-deep: #2563eb;
    --rd-navy: #1e3a8a;
    --rd-ink: #0f172a;
    --rd-ink-2: #111a2e;
    --rd-ink-deep: #0b1220;
    --rd-text: #0f172a;
    --rd-text-2: #1e293b;
    --rd-muted: #64748b;
    --rd-muted-2: #475569;
    --rd-text-on-dark: #e2e8f0;
    --rd-muted-on-dark: #94a3b8;
    --rd-surface: #ffffff;
    --rd-surface-2: #f8fafc;
    --rd-surface-3: #f1f5f9;
    --rd-line: rgba(37, 99, 235, 0.12);
    --rd-line-strong: rgba(37, 99, 235, 0.2);
    --rd-tint: rgba(37, 99, 235, 0.07);
    --rd-success: #16a34a;
    --rd-warning: #f59e0b;
    --rd-error: #dc2626;
    --rd-error-deep: #b32121;
    --rd-radius: 10px;
    --rd-radius-lg: 16px;
    --rd-shadow: 0 8px 22px rgba(37, 99, 235, 0.12);
    --rd-ease: cubic-bezier(0.2, 0.75, 0.15, 1);
}

/* ── Page scaffold ─────────────────────────────────────────────────────── */
.page {
    padding: 1.5rem 2.5rem 3rem;
    animation: rd-rise 0.45s var(--rd-ease) backwards;
}

.page--narrow {
    max-width: 60rem;
}

/* Every block of a page is separated from the one before it (stat rows, cards, tables, sections): */
.page > * + * {
    margin-top: 1.25rem;
}

.page > * + .page__section {
    margin-top: 1.75rem;
}

.page__section-title {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--rd-muted);
}

@media (max-width: 860px) {
    .page {
        padding: 1.25rem 1.25rem 3rem;
    }
}

/* ── Grid & cards ──────────────────────────────────────────────────────── */
.rd-grid {
    display: grid;
    gap: 1rem;
}

.rd-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rd-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rd-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) {
    .rd-grid--3, .rd-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .rd-grid--2, .rd-grid--3, .rd-grid--4 { grid-template-columns: 1fr; }
}

.rd-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--rd-line);
    border-radius: var(--rd-radius-lg);
    background: var(--rd-surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}

.rd-card--hover:hover {
    border-color: var(--rd-line-strong);
    box-shadow: var(--rd-shadow);
    transform: translateY(-1px);
}

.rd-card--flush {
    padding: 0;
    overflow: hidden;
}

.rd-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--rd-ink);
}

.rd-card__text {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--rd-muted-2);
}

.rd-card__link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rd-blue-deep);
}

    .rd-card__link:hover {
        text-decoration: underline;
    }

/* ── Stat tiles ────────────────────────────────────────────────────────── */
.stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 1.2rem;
    border: 1px solid var(--rd-line);
    border-radius: var(--rd-radius-lg);
    background: var(--rd-surface);
}

.stat__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--rd-muted);
}

.stat__value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--rd-ink);
    line-height: 1.1;
}

.stat__sub {
    font-size: 0.78rem;
    color: var(--rd-muted);
}

/* ── Buttons (additions to .hbtn of rodly.css) ─────────────────────────── */
.hbtn--danger {
    background: var(--rd-error);
    color: white;
    box-shadow: 0 8px 22px rgba(220, 38, 38, 0.2);
}

    .hbtn--danger:hover {
        opacity: 0.88;
    }

.hbtn--ghost {
    background: transparent;
    color: var(--rd-navy);
    box-shadow: none;
}

    .hbtn--ghost:hover {
        background: var(--rd-tint);
    }

.hbtn--on-dark {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.hbtn:disabled {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

.hbtn--icon {
    padding: 0.5rem;
    border-radius: 999px;
}

.hbtn--sm {
    padding: 0.55rem 1.1rem;
    font-size: 0.85rem;
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--rd-muted-2);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

    .icon-button:hover:not(:disabled) {
        background: var(--rd-tint);
        color: var(--rd-navy);
    }

    .icon-button:disabled {
        opacity: 0.4;
        cursor: default;
    }

    .icon-button--danger:hover:not(:disabled) {
        background: rgba(220, 38, 38, 0.08);
        color: var(--rd-error);
    }

/* ── Chips ─────────────────────────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--rd-surface-3);
    color: var(--rd-muted-2);
}

.chip__dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.chip--info { background: rgba(37, 99, 235, 0.1); color: var(--rd-navy); }
.chip--success { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.chip--warning { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.chip--danger { background: rgba(220, 38, 38, 0.1); color: var(--rd-error-deep); }

/* ── Filter chips (toggle buttons with a count) ────────────────────────── */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.filters__label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--rd-muted);
    margin-right: 0.25rem;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--rd-line-strong);
    border-radius: 999px;
    background: white;
    color: var(--rd-text-2);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

    .filter-chip:hover {
        background: var(--rd-tint);
    }

    .filter-chip.is-active {
        background: var(--rd-ink);
        border-color: var(--rd-ink);
        color: white;
    }

.filter-chip__count {
    min-width: 1.2rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--rd-surface-3);
    color: var(--rd-muted-2);
    font-size: 0.7rem;
    text-align: center;
}

.filter-chip.is-active .filter-chip__count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.filter-chip__dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
}

/* ── Tables ────────────────────────────────────────────────────────────── */
.rd-table-wrap {
    overflow: auto;
    border: 1px solid var(--rd-line);
    border-radius: var(--rd-radius-lg);
    background: white;
}

.rd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

    .rd-table th {
        padding: 0.7rem 1rem;
        text-align: left;
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--rd-muted);
        background: var(--rd-surface-2);
        border-bottom: 1px solid var(--rd-line);
        white-space: nowrap;
    }

    .rd-table td {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--rd-line);
        vertical-align: middle;
    }

    .rd-table tbody tr:last-child td {
        border-bottom: none;
    }

    .rd-table tbody tr {
        transition: background 0.15s;
    }

    .rd-table--clickable tbody tr {
        cursor: pointer;
    }

    .rd-table tbody tr:hover {
        background: var(--rd-surface-2);
    }

    .rd-table tbody tr.is-selected {
        background: rgba(37, 99, 235, 0.06);
    }

    .rd-table .is-num {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }

    .rd-table .is-muted {
        color: var(--rd-muted);
    }

    .rd-table .is-actions {
        text-align: right;
        white-space: nowrap;
    }

.rd-table__primary {
    display: block;
    font-weight: 600;
    color: var(--rd-ink);
}

.rd-table__secondary {
    display: block;
    font-size: 0.75rem;
    color: var(--rd-muted);
}

.sort-header {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: none;
    background: transparent;
    padding: 0;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    cursor: pointer;
}

    .sort-header:hover {
        color: var(--rd-ink);
    }

/* ── Toolbar / search ──────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.toolbar__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.search {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 16rem;
}

    .search svg {
        position: absolute;
        left: 0.8rem;
        color: var(--rd-muted);
        pointer-events: none;
    }

    .search input {
        width: 100%;
        padding: 0.55rem 0.9rem 0.55rem 2.4rem;
        border: 1px solid var(--rd-line-strong);
        border-radius: 999px;
        background: white;
        font: inherit;
        font-size: 0.85rem;
        transition: border-color 0.15s, box-shadow 0.15s;
    }

        .search input:focus {
            outline: none;
            border-color: var(--rd-blue);
            box-shadow: 0 0 0 4px rgba(25, 134, 242, 0.15);
        }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.rd-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rd-form__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
}

.rd-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.rd-field__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rd-muted);
}

.rd-field__hint {
    font-size: 0.75rem;
    color: var(--rd-muted);
}

.rd-input,
.rd-field input[type=text],
.rd-field input[type=email],
.rd-field input[type=number],
.rd-field input[type=date],
.rd-field select,
.rd-field textarea {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--rd-line-strong);
    border-radius: var(--rd-radius);
    background: white;
    color: var(--rd-text);
    font: inherit;
    font-size: 0.88rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

    .rd-input:focus,
    .rd-field input:focus,
    .rd-field select:focus,
    .rd-field textarea:focus {
        outline: none;
        border-color: var(--rd-blue);
        box-shadow: 0 0 0 4px rgba(25, 134, 242, 0.15);
    }

    .rd-field input:disabled,
    .rd-field select:disabled,
    .rd-field textarea:disabled {
        background: var(--rd-surface-3);
        color: var(--rd-muted);
    }

.rd-input--sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
}

.rd-field input.invalid,
.rd-field select.invalid {
    border-color: var(--rd-error);
}

.rd-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    cursor: pointer;
}

    .rd-check input {
        width: 1rem;
        height: 1rem;
        accent-color: var(--rd-blue-deep);
    }

.rd-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.88rem;
    cursor: pointer;
}

    .rd-switch input {
        appearance: none;
        width: 2.3rem;
        height: 1.3rem;
        border-radius: 999px;
        background: #cbd5e1;
        position: relative;
        transition: background 0.2s;
        cursor: pointer;
    }

        .rd-switch input::after {
            content: "";
            position: absolute;
            top: 0.15rem;
            left: 0.15rem;
            width: 1rem;
            height: 1rem;
            border-radius: 50%;
            background: white;
            box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
            transition: transform 0.2s var(--rd-ease);
        }

        .rd-switch input:checked {
            background: var(--rd-blue-deep);
        }

            .rd-switch input:checked::after {
                transform: translateX(1rem);
            }

.rd-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.validation-message {
    font-size: 0.75rem;
    color: var(--rd-error);
}

/* ── Messages ──────────────────────────────────────────────────────────── */
.message {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-radius: var(--rd-radius);
    font-size: 0.85rem;
}

.message--info { background: rgba(37, 99, 235, 0.08); color: var(--rd-navy); }
.message--success { background: rgba(22, 163, 74, 0.1); color: #15803d; }
.message--warning { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.message--error { background: rgba(220, 38, 38, 0.08); color: var(--rd-error-deep); }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--rd-line);
    margin-bottom: 1.25rem;
}

.tab {
    padding: 0.6rem 0.9rem;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--rd-muted-2);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

    .tab:hover {
        color: var(--rd-ink);
    }

    .tab.is-active {
        color: var(--rd-blue-deep);
        border-bottom-color: var(--rd-blue-deep);
        font-weight: 600;
    }

/* Tabs can be links (deep-linkable tabs such as the notch review): */
a.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
}

.tab__count {
    display: inline-grid;
    place-items: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--rd-surface-3);
    color: var(--rd-muted-2);
    font-size: 0.7rem;
    font-weight: 700;
}

.tab__count--attention {
    background: rgba(245, 158, 11, 0.18);
    color: #b45309;
}

/* ── Segmented control (list / tiles) ──────────────────────────────────── */
.segmented {
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 999px;
    background: var(--rd-surface-3);
}

    .segmented button {
        display: inline-flex;
        align-items: center;
        gap: 0.35rem;
        padding: 0.35rem 0.8rem;
        border: none;
        border-radius: 999px;
        background: transparent;
        color: var(--rd-muted-2);
        font: inherit;
        font-size: 0.8rem;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }

        .segmented button.is-active {
            background: var(--rd-ink);
            color: white;
        }

/* ── Timeline (audit trail) ────────────────────────────────────────────── */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline__item {
    position: relative;
    display: grid;
    grid-template-columns: 1.6rem 1fr;
    gap: 0.6rem;
    padding-bottom: 1rem;
}

    .timeline__item::before {
        content: "";
        position: absolute;
        left: 0.75rem;
        top: 1.5rem;
        bottom: 0;
        width: 2px;
        background: var(--rd-line-strong);
    }

    .timeline__item:last-child::before {
        display: none;
    }

.timeline__dot {
    display: grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--rd-surface-3);
    color: var(--rd-muted-2);
    z-index: 1;
}

.timeline__dot--success { background: rgba(22, 163, 74, 0.15); color: #15803d; }
.timeline__dot--warning { background: rgba(245, 158, 11, 0.18); color: #b45309; }
.timeline__dot--danger { background: rgba(220, 38, 38, 0.12); color: var(--rd-error-deep); }
.timeline__dot--info { background: rgba(37, 99, 235, 0.12); color: var(--rd-navy); }

.timeline__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--rd-ink);
}

.timeline__meta {
    font-size: 0.75rem;
    color: var(--rd-muted);
}

.timeline__comment {
    margin-top: 0.3rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    background: var(--rd-surface-2);
    font-size: 0.8rem;
    color: var(--rd-text-2);
}

/* ── Pager ─────────────────────────────────────────────────────────────── */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    font-size: 0.8rem;
    color: var(--rd-muted);
}

.pager__buttons {
    display: flex;
    gap: 0.3rem;
}

/* ── Skeleton ──────────────────────────────────────────────────────────── */
.skeleton {
    border-radius: 8px;
    background: linear-gradient(90deg, var(--rd-surface-3) 25%, #e8eef8 50%, var(--rd-surface-3) 75%);
    background-size: 200% 100%;
    animation: rd-shimmer 1.4s linear infinite;
}

/* ── Misc ──────────────────────────────────────────────────────────────── */
.muted {
    color: var(--rd-muted);
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

.spin {
    animation: rd-spin 0.9s linear infinite;
}

.rodly-login-links {
    display: flex;
    justify-content: center;
    gap: 0.6rem;
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted, #94a3b8);
}

    .rodly-login-links a:hover {
        color: white;
    }

.rodly-login-company.is-current {
    border-color: rgba(25, 134, 242, 0.6);
}

.rodly-login-companies form {
    margin: 0;
}

/* The list scrolls (overflow: auto) and the hovered button lifts by 1px: without room around the buttons the lift clips their border
   and briefly shows a scrollbar. The negative margin keeps the list aligned with the card. */
.rodly-login-companies {
    margin: -4px;
    padding: 4px;
}

/* ── Animations ────────────────────────────────────────────────────────── */
@keyframes rd-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
}

@keyframes rd-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

@keyframes rd-spin {
    to { transform: rotate(360deg); }
}

/* The bend figure (BendFigure.razor) switches these on per row with var(--fig-{row}-off, name). They live here because CSS isolation
   renames a component's keyframes, but not the names in a var() fallback. */
@keyframes bf-swing {
    0%, 100% { --bf-theta: 90deg; }
    50% { --bf-theta: 35deg; }
}

@keyframes bf-turn {
    0%, 100% { --bf-phi: 0deg; }
    25% { --bf-phi: 35deg; }
    75% { --bf-phi: -35deg; }
}

@keyframes bf-grow {
    0%, 100% { --bf-leg: 60px; }
    25% { --bf-leg: 76px; }
    75% { --bf-leg: 40px; }
}

@keyframes bf-gap {
    0%, 100% { --bf-clearance: 24px; }
    25% { --bf-clearance: 36px; }
    75% { --bf-clearance: 14px; }
}

/* The same for the overlap figure (OverlapFigure.razor): */
@keyframes of-gap {
    0%, 100% { --of-clearance: 26px; }
    25% { --of-clearance: 38px; }
    75% { --of-clearance: 16px; }
}

@keyframes of-overhang {
    0%, 100% { --of-overhang: 40px; }
    25% { --of-overhang: 62px; }
    75% { --of-overhang: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
