/*
    TopNet Licensing — administration console design system
    =======================================================

    One stylesheet for the whole console. Pages compose the classes defined here and
    Bootstrap's grid and utilities; they do not carry style rules of their own, so a change
    to spacing, colour or a control shape happens once, here.

    Layered on top of Bootstrap 5 rather than replacing it: the form controls, grid and
    utility classes stay available, and what follows re-skins them and adds the shell,
    cards, tables and badges the console needs.
*/

/* ----------------------------------------------------------------- design tokens */

:root {
    /* Brand. One accent, used sparingly - a console that shouts everywhere says nothing. */
    --tn-primary: #4f46e5;
    --tn-primary-hover: #4338ca;
    --tn-primary-soft: #eef2ff;
    --tn-primary-border: #c7d2fe;

    /* Neutrals, warm-tinted so large white surfaces do not read as clinical. */
    --tn-bg: #f6f7fb;
    --tn-surface: #ffffff;
    --tn-surface-muted: #fafbfd;
    --tn-border: #e8eaf1;
    --tn-border-strong: #d8dbe6;

    --tn-text: #171a27;
    --tn-text-muted: #6b7185;
    --tn-text-subtle: #9aa0b1;

    /* States. Each is a text, background and border triple so badges stay legible. */
    --tn-success: #0f7a4d;
    --tn-success-bg: #e7f7ef;
    --tn-success-border: #b7e6ce;
    --tn-warning: #8a5a00;
    --tn-warning-bg: #fdf4e3;
    --tn-warning-border: #f0dcae;
    --tn-danger: #b3251e;
    --tn-danger-bg: #fdeceb;
    --tn-danger-border: #f5c6c3;
    --tn-info: #1d4ed8;
    --tn-info-bg: #eaf0ff;
    --tn-info-border: #c3d4fd;
    --tn-neutral: #525869;
    --tn-neutral-bg: #f1f2f6;
    --tn-neutral-border: #dfe1e9;

    --tn-radius-sm: 8px;
    --tn-radius: 12px;
    --tn-radius-lg: 16px;

    --tn-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --tn-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --tn-shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);

    --tn-sidebar-width: 260px;
    --tn-header-height: 68px;

    /* Content widths. A licensing table is not more readable for being 2500px wide. */
    --tn-container: 1280px;
    --tn-container-narrow: 880px;
    --tn-container-form: 640px;
}

/* ----------------------------------------------------------------- base */

html {
    font-size: 15px;
}

body {
    background: var(--tn-bg);
    color: var(--tn-text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Segoe UI Arabic",
        "Noto Sans Arabic", Tahoma, Roboto,
        "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--tn-text);
    font-weight: 600;
    letter-spacing: -.01em;
}

a {
    color: var(--tn-primary);
    text-decoration: none;
}

a:hover {
    color: var(--tn-primary-hover);
    text-decoration: underline;
}

code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .875em;
    color: var(--tn-text);
}

.text-muted {
    color: var(--tn-text-muted) !important;
}

/* Focus is never removed, only restyled - it is the only thing a keyboard user has. */
:focus-visible {
    outline: 2px solid var(--tn-primary);
    outline-offset: 2px;
}

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .18);
    border-color: var(--tn-primary-border);
}

/* ----------------------------------------------------------------- application shell */

.tn-shell {
    display: flex;
    min-height: 100vh;
}

.tn-sidebar {
    width: var(--tn-sidebar-width);
    flex: 0 0 var(--tn-sidebar-width);
    background: var(--tn-surface);
    border-inline-end: 1px solid var(--tn-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1040;
    transition: transform .2s ease;
}

.tn-sidebar__brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    height: var(--tn-header-height);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--tn-border);
    flex: 0 0 auto;
}

.tn-sidebar__brand:hover {
    text-decoration: none;
}

.tn-brand__mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tn-primary), #7c5cf5);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: var(--tn-shadow-sm);
}

.tn-brand__name {
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--tn-text);
    line-height: 1.15;
}

.tn-brand__sub {
    font-size: .75rem;
    color: var(--tn-text-muted);
    line-height: 1.15;
}

.tn-sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem .75rem 1.5rem;
}

.tn-nav__section {
    padding: 1.25rem .75rem .5rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--tn-text-subtle);
}

.tn-nav__link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem .75rem;
    margin-bottom: .125rem;
    border-radius: var(--tn-radius-sm);
    color: var(--tn-text-muted);
    font-weight: 500;
    font-size: .9375rem;
    transition: background .12s ease, color .12s ease;
}

.tn-nav__link:hover {
    background: var(--tn-surface-muted);
    color: var(--tn-text);
    text-decoration: none;
}

.tn-nav__link svg {
    flex: 0 0 auto;
    opacity: .75;
}

/* The active item is the one piece of strong colour in the sidebar, so position is obvious. */
.tn-nav__link.is-active {
    background: var(--tn-primary-soft);
    color: var(--tn-primary);
    font-weight: 600;
}

.tn-nav__link.is-active svg {
    opacity: 1;
}

.tn-sidebar__footer {
    flex: 0 0 auto;
    padding: 1rem;
    border-top: 1px solid var(--tn-border);
}

.tn-version {
    background: var(--tn-surface-muted);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    padding: .75rem;
    display: flex;
    align-items: center;
    gap: .625rem;
}

.tn-version__name {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--tn-text);
    line-height: 1.2;
}

.tn-version__meta {
    font-size: .75rem;
    color: var(--tn-text-muted);
}

/* ----------------------------------------------------------------- main column */

.tn-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-start: var(--tn-sidebar-width);
    display: flex;
    flex-direction: column;
}

.tn-header {
    height: var(--tn-header-height);
    background: var(--tn-surface);
    border-bottom: 1px solid var(--tn-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.tn-header__toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-sm);
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    color: var(--tn-text-muted);
}

.tn-header__context {
    min-width: 0;
}

.tn-header__crumb {
    font-size: .75rem;
    color: var(--tn-text-subtle);
    line-height: 1.2;
}

.tn-header__title {
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tn-header__spacer {
    flex: 1 1 auto;
}

.tn-user {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .3125rem .5rem .3125rem .3125rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.tn-user:hover {
    background: var(--tn-surface-muted);
    border-color: var(--tn-border);
    text-decoration: none;
}

.tn-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tn-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8125rem;
    font-weight: 600;
    flex: 0 0 auto;
    text-transform: uppercase;
}

.tn-user__name {
    font-size: .875rem;
    font-weight: 600;
    color: var(--tn-text);
    line-height: 1.2;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tn-user__role {
    font-size: .75rem;
    color: var(--tn-text-muted);
    line-height: 1.2;
}

.tn-content {
    flex: 1 1 auto;
    padding: 1.75rem 1.5rem 3rem;
}

/* The container rule: content is centred and bounded, never stretched edge to edge. */
.tn-container {
    max-width: var(--tn-container);
    margin: 0 auto;
    width: 100%;
}

.tn-container--narrow {
    max-width: var(--tn-container-narrow);
}

.tn-container--form {
    max-width: var(--tn-container-form);
}

/* ----------------------------------------------------------------- page header */

.tn-page-head {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tn-page-head__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--tn-radius);
    background: linear-gradient(135deg, var(--tn-primary), #7c5cf5);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    box-shadow: var(--tn-shadow-sm);
}

.tn-page-head__text {
    flex: 1 1 auto;
    min-width: 0;
}

.tn-page-head__title {
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.tn-page-head__desc {
    max-width: 78ch;
    color: var(--tn-text-muted);
    font-size: .9375rem;
    margin: .25rem 0 0;
}

.tn-page-head__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ----------------------------------------------------------------- cards */

.tn-card {
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
    box-shadow: var(--tn-shadow);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.tn-card__head {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--tn-border);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.tn-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.tn-card__desc {
    max-width: 78ch;
    font-size: .8125rem;
    color: var(--tn-text-muted);
    margin: .125rem 0 0;
}

/*
 * The text block in a card head. Excluding the actions group matters: it is a div too, and
 * letting it grow cancels its own margin-inline-start:auto, which parked every card's button next to
 * the title instead of at the far edge.
 */
.tn-card__head > div:not(.tn-card__actions) {
    flex: 1 1 auto;
    min-width: 0;
}

.tn-card__actions {
    margin-inline-start: auto;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

.tn-card__body {
    padding: 1.5rem;
}

.tn-card__foot {
    padding: .875rem 1.5rem;
    border-top: 1px solid var(--tn-border);
    background: var(--tn-surface-muted);
    font-size: .8125rem;
    color: var(--tn-text-muted);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

/*
 * A card for an action that cannot be undone quietly - withdrawing a product, revoking a key.
 * The tint is deliberately restrained: a red border and heading are enough to make someone
 * pause, while a fully red panel would train people to ignore it.
 */
.tn-card--danger {
    border-color: var(--tn-danger-border);
}

.tn-card--danger .tn-card__head {
    background: var(--tn-danger-bg);
    border-bottom-color: var(--tn-danger-border);
    color: var(--tn-danger);
}

.tn-card--danger .tn-card__title {
    color: var(--tn-danger);
}

/* An alert whose content is more than one line needs its own column inside the flex row. */
.alert > div {
    min-width: 0;
}

.alert p:last-child, .alert ul:last-child {
    margin-bottom: 0;
}

.alert__title {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0 0 .375rem;
}

/* A footer carrying more than one line - a row of controls above a note explaining them. */
.tn-card__foot--stack {
    display: block;
}

.tn-card__foot--stack > * + * {
    margin-top: .75rem;
}

/* A card whose body is only a table: the table supplies its own edge padding. */
.tn-card--table .tn-card__body {
    padding: 0;
}

/* ----------------------------------------------------------------- layout grid */

/*
 * Two cards side by side, one under the other when there is no room. Grid rather than Bootstrap's
 * row/col because a card needs to stretch to its neighbour's height, which `h-100` only fakes.
 */
.tn-grid {
    display: grid;
    gap: 1.5rem;
    align-items: start;
}

.tn-grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}

/* Inside a grid the card's own bottom margin would double the gap. */
.tn-grid > .tn-card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* So that two cards side by side line their footers up rather than ending raggedly. */
.tn-grid > .tn-card > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.tn-grid > .tn-card > .tn-card__body,
.tn-grid > .tn-card > form > .tn-card__body {
    flex: 1 1 auto;
}

/* ----------------------------------------------------------------- statistics */

.tn-stats {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.5rem;

    /*
     * Explicit column counts rather than auto-fit. The dashboard shows six tiles, and auto-fit
     * sized them to fit five per row, leaving the sixth stranded alone underneath. Every count
     * below divides six exactly, so the grid is always full.
     */
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1399.98px) {
    .tn-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .tn-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.tn-stat {
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    box-shadow: var(--tn-shadow-sm);
    padding: 1.125rem 1.25rem;
}

.tn-stat__label {
    font-size: .8125rem;
    color: var(--tn-text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.tn-stat__value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
    margin-top: .375rem;
    letter-spacing: -.02em;
}

.tn-stat__hint {
    font-size: .75rem;
    color: var(--tn-text-subtle);
    margin-top: .125rem;
}

/* ----------------------------------------------------------------- tables */

/*
 * The scroll shadows are the affordance for a table wider than its card. Without them the audit
 * trail simply looked cut off at the edge, with nothing to say the rest was one swipe away.
 *
 * The trick is background-attachment: the two white covers scroll with the content (local) while
 * the two shadows stay pinned to the frame (scroll), so a shadow is only visible on a side that
 * actually has more table behind it. It is symmetric, so it works unchanged in Arabic.
 */
.tn-table-wrap {
    overflow-x: auto;
    background:
        linear-gradient(to right, var(--tn-surface) 30%, rgba(255, 255, 255, 0)) left center,
        linear-gradient(to left, var(--tn-surface) 30%, rgba(255, 255, 255, 0)) right center,
        radial-gradient(farthest-side at 0 50%, rgba(16, 24, 40, .10), rgba(16, 24, 40, 0)) left center,
        radial-gradient(farthest-side at 100% 50%, rgba(16, 24, 40, .10), rgba(16, 24, 40, 0)) right center;
    background-repeat: no-repeat;
    background-size: 44px 100%, 44px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}

.tn-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .9375rem;

    /* Opaque, so the scroll shadows above sit behind the rows rather than tinting them. */
    background: var(--tn-surface);
}

/*
 * A floor for a table that genuinely cannot fit, so its columns size to their content and the
 * wrapper scrolls rather than crushing them.
 *
 * Nothing uses it today. The audit trail did, and having to scroll sideways to reach a clipped
 * column read as broken rather than as scrollable - so that table was cut to the columns worth
 * scanning, with the whole record on a page of its own. Kept for a table with no such option.
 */
.tn-table--wide {
    min-width: 1180px;
}

/*
 * A cell of free text held to one line. The full value stays on the element's title, so nothing
 * is lost - only the row height, which is what made the trail hard to scan.
 */
.tn-cell-truncate {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Timestamps and identifiers read as one token; breaking them mid-value helps nobody. */
.tn-table .tn-col-when,
.tn-table .tn-col-nowrap {
    white-space: nowrap;
}

/* Free text needs a floor of its own, or it becomes a column one word wide. */
.tn-table .tn-col-text {
    min-width: 13rem;
}

.tn-table thead th {
    background: var(--tn-surface-muted);
    border-bottom: 1px solid var(--tn-border);
    padding: .75rem 1.5rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--tn-text-subtle);
    white-space: nowrap;
    text-align: start;
}

.tn-table tbody td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--tn-border);
    vertical-align: middle;
    color: var(--tn-text);
}

.tn-table tbody tr:last-child td {
    border-bottom: 0;
}

.tn-table tbody tr {
    transition: background .12s ease;
}

.tn-table tbody tr:hover {
    background: var(--tn-surface-muted);
}

.tn-table .tn-col-actions {
    text-align: end;
    white-space: nowrap;
}

.tn-table .tn-col-num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

/* A denser table for long logs, where row count matters more than air. */
.tn-table--compact thead th {
    padding: .625rem 1.25rem;
}

.tn-table--compact tbody td {
    padding: .625rem 1.25rem;
    font-size: .875rem;
}

.tn-cell-title {
    font-weight: 600;
    color: var(--tn-text);
}

.tn-cell-sub {
    font-size: .8125rem;
    color: var(--tn-text-muted);
    margin-top: .125rem;
}

/* A code that identifies a record: a product code, a client id, a licence mask. */
.tn-code {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .02em;
    background: var(--tn-surface-muted);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-sm);
    padding: .1875rem .5rem;
    color: var(--tn-text);
    white-space: nowrap;
}

.tn-code--plain {
    background: transparent;
    border-color: transparent;
    padding-inline-start: 0;
}

/* A small square glyph beside a record name, as in the reference. */
.tn-row-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--tn-primary-soft);
    color: var(--tn-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.tn-row-icon--muted {
    background: var(--tn-neutral-bg);
    color: var(--tn-neutral);
}

.tn-row-lead {
    display: flex;
    align-items: center;
    gap: .75rem;
    min-width: 0;
}

/* A count shown as a pill, so numbers read as data rather than as prose. */
.tn-count {
    display: inline-block;
    min-width: 2rem;
    text-align: center;

    /* "0 / 3" is one figure. Let it wrap and the pill breaks over two lines. */
    white-space: nowrap;
    background: var(--tn-primary-soft);
    color: var(--tn-primary);
    border-radius: var(--tn-radius-sm);
    padding: .1875rem .5rem;
    font-size: .8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tn-count--muted {
    background: var(--tn-neutral-bg);
    color: var(--tn-neutral);
}

.tn-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--tn-text-muted);
}

.tn-empty__icon {
    width: 52px;
    height: 52px;
    border-radius: var(--tn-radius);
    background: var(--tn-surface-muted);
    border: 1px solid var(--tn-border);
    color: var(--tn-text-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .875rem;
}

.tn-empty__title {
    font-weight: 600;
    color: var(--tn-text);
}

/* ----------------------------------------------------------------- badges */

.tn-badge {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .25rem .625rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
}

.tn-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.tn-badge--plain::before {
    display: none;
}

.tn-badge--success { color: var(--tn-success); background: var(--tn-success-bg); border-color: var(--tn-success-border); }
.tn-badge--warning { color: var(--tn-warning); background: var(--tn-warning-bg); border-color: var(--tn-warning-border); }
.tn-badge--danger  { color: var(--tn-danger);  background: var(--tn-danger-bg);  border-color: var(--tn-danger-border); }
.tn-badge--info    { color: var(--tn-info);    background: var(--tn-info-bg);    border-color: var(--tn-info-border); }
.tn-badge--neutral { color: var(--tn-neutral); background: var(--tn-neutral-bg); border-color: var(--tn-neutral-border); }

/* ----------------------------------------------------------------- buttons */

.btn {
    border-radius: var(--tn-radius-sm);
    font-weight: 500;
    font-size: .9375rem;
    padding: .5rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.btn-sm {
    font-size: .8125rem;
    padding: .375rem .75rem;
    border-radius: var(--tn-radius-sm);
}

.btn-primary {
    background: var(--tn-primary);
    border-color: var(--tn-primary);
    color: #fff;
    box-shadow: var(--tn-shadow-sm);
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background: var(--tn-primary-hover) !important;
    border-color: var(--tn-primary-hover) !important;
    color: #fff;
}

/* The secondary button carries most of the console: Manage, Cancel, Filter. */
.btn-secondary, .btn-outline-secondary {
    background: var(--tn-surface);
    border-color: var(--tn-border-strong);
    color: var(--tn-text);
}

.btn-secondary:hover, .btn-outline-secondary:hover,
.btn-secondary:focus, .btn-outline-secondary:focus,
.btn-secondary:active, .btn-outline-secondary:active {
    background: var(--tn-surface-muted) !important;
    border-color: var(--tn-text-subtle) !important;
    color: var(--tn-text) !important;
}

/* Destructive actions are outlined, not filled: a wall of red buttons stops being a warning. */
.btn-danger, .btn-outline-danger {
    background: var(--tn-surface);
    border-color: var(--tn-danger-border);
    color: var(--tn-danger);
}

.btn-danger:hover, .btn-outline-danger:hover,
.btn-danger:focus, .btn-outline-danger:focus,
.btn-danger:active, .btn-outline-danger:active {
    background: var(--tn-danger) !important;
    border-color: var(--tn-danger) !important;
    color: #fff !important;
}

.btn-link {
    color: var(--tn-primary);
    text-decoration: none;
    padding: 0;
}

.tn-btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--tn-radius-sm);
    border: 1px solid var(--tn-border-strong);
    background: var(--tn-surface);
    color: var(--tn-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tn-btn-icon:hover {
    background: var(--tn-surface-muted);
    color: var(--tn-text);
}

.tn-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .375rem;
    flex-wrap: wrap;
}

/* ----------------------------------------------------------------- row menu */

/*
 * The three-dot menu on a table row.
 *
 * Built on <details>/<summary> rather than on a script: it opens, closes and takes keyboard focus
 * natively, so the menu works before any JavaScript runs and keeps working if none ever does. The
 * script only adds the two conveniences the element has no opinion about - closing when you click
 * elsewhere, and closing on Escape.
 */
.tn-menu {
    position: relative;
    display: inline-block;
}

.tn-menu__trigger {
    width: 34px;
    height: 34px;
    border-radius: var(--tn-radius-sm);
    border: 1px solid var(--tn-border-strong);
    background: var(--tn-surface);
    color: var(--tn-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    list-style: none;
}

/* Safari draws its own disclosure triangle unless both of these say otherwise. */
.tn-menu__trigger::-webkit-details-marker {
    display: none;
}

.tn-menu__trigger::marker {
    content: "";
}

.tn-menu__trigger:hover,
.tn-menu[open] .tn-menu__trigger {
    background: var(--tn-surface-muted);
    color: var(--tn-text);
    border-color: var(--tn-text-subtle);
}

.tn-menu__list {
    position: absolute;
    z-index: 1050;
    top: calc(100% + .375rem);

    /* Anchored to the end edge so the panel opens inward, whichever direction the page reads. */
    inset-inline-end: 0;
    min-width: 12rem;
    padding: .375rem;
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    box-shadow: var(--tn-shadow-lg);
    text-align: start;
}

.tn-menu__item {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .5rem .625rem;
    border: 0;
    border-radius: var(--tn-radius-sm);
    background: transparent;
    color: var(--tn-text);
    font-size: .875rem;
    font-weight: 500;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.tn-menu__item:hover {
    background: var(--tn-surface-muted);
    color: var(--tn-text);
}

.tn-menu__item svg {
    color: var(--tn-text-subtle);
    flex: 0 0 auto;
}

.tn-menu__item:hover svg {
    color: var(--tn-text-muted);
}

/* The destructive entry, separated so it is never the one clicked by accident. */
.tn-menu__item--danger {
    color: var(--tn-danger);
}

.tn-menu__item--danger svg,
.tn-menu__item--danger:hover svg {
    color: var(--tn-danger);
}

.tn-menu__item--danger:hover {
    background: var(--tn-danger-bg);
    color: var(--tn-danger);
}

.tn-menu__separator {
    height: 1px;
    margin: .375rem .25rem;
    background: var(--tn-border);
}

/*
 * An open menu has to escape everything that clips it.
 *
 * A card hides its own overflow so its corners stay rounded, and the table wrapper scrolls
 * horizontally - so a menu on the last row was cut off at the card's bottom edge and the entries
 * below the fold simply could not be reached. Both containers open up while a menu is open.
 *
 * Stated twice on purpose: :has() covers the case where scripting never runs, and the class is
 * what the script sets, so the fix holds in a browser that supports neither one of them.
 */
.tn-table-wrap:has(.tn-menu[open]),
.tn-card:has(.tn-menu[open]),
.tn-card:has(.tn-menu[open]) .tn-card__body,
.tn-table-wrap.is-menu-open,
.tn-card.is-menu-open,
.tn-card.is-menu-open .tn-card__body {
    overflow: visible;
}

/*
 * Near the foot of a table the menu would hang off the bottom of the page. This flips it above
 * the button instead, and the script decides which rows need it from their real position.
 */
.tn-menu.is-above .tn-menu__list {
    top: auto;
    bottom: calc(100% + .375rem);
}

/* ----------------------------------------------------------------- forms */

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--tn-text);
    margin-bottom: .375rem;
}

.form-control, .form-select {
    border-radius: var(--tn-radius-sm);
    border-color: var(--tn-border-strong);
    padding: .5rem .75rem;
    font-size: .9375rem;
    color: var(--tn-text);
    min-height: 40px;
}

/*
 * A select draws its own chevron as a background image, so it needs room for it that a plain
 * padding shorthand takes away. padding-inline states start and end separately, so the clearance
 * follows the chevron to whichever edge the direction puts it on.
 */
.form-select {
    padding-inline: .75rem 2.25rem;
    background-position: right .75rem center;
}

/* Bootstrap's stylesheet is the left-to-right build, so the chevron needs moving by hand. */
[dir="rtl"] .form-select {
    background-position: left .75rem center;
}

.form-control-sm, .form-select-sm {
    font-size: .875rem;
    padding: .375rem .625rem;
    min-height: 36px;
    border-radius: var(--tn-radius-sm);
}

.form-select-sm {
    padding-inline: .625rem 2rem;
}

.form-control::placeholder {
    color: var(--tn-text-subtle);
}

.form-text, .tn-hint {
    font-size: .8125rem;
    color: var(--tn-text-muted);
}

.text-danger {
    color: var(--tn-danger) !important;
    font-size: .8125rem;
}

/* A labelled group of related fields inside a card. */
.tn-field {
    margin-bottom: 1.125rem;
}

.tn-field:last-child {
    margin-bottom: 0;
}

.tn-form-section {
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--tn-border);
}

.tn-form-section:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: 0;
}

.tn-form-section__title {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0 0 .25rem;
}

.tn-form-section__desc {
    font-size: .8125rem;
    color: var(--tn-text-muted);
    margin: 0 0 1rem;
}

.tn-form-actions {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--tn-border);
    flex-wrap: wrap;
}

/* An inline form inside a table row - a reason box plus a button. */
.tn-inline-form {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    flex-wrap: nowrap;
}

.tn-inline-form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tn-inline-form .form-control {
    min-width: 11rem;
}

.tn-col-actions .tn-inline-form .form-control {
    max-width: 14rem;
}

/*
 * The "add a row" form that lives in a card's footer. It carries several inputs, so unlike the
 * single reason box inside a table row it is allowed to wrap rather than force the card wide.
 */
.tn-card__foot .tn-inline-form {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.tn-card__foot .tn-inline-form .form-control,
.tn-card__foot .tn-inline-form .form-select {
    flex: 0 1 14rem;
    min-width: 7rem;
    width: auto;
}

.tn-card__foot .tn-inline-form .btn {
    flex: 0 0 auto;
}

.tn-card__foot--stack .tn-op__form > .tn-inline-form {
    flex: 1 1 22rem;
    width: auto;
}

/*
 * A filter or search bar sitting above a table. It is a card with a single row of controls, so
 * the filters read as part of the table's frame rather than as loose inputs on the background.
 */
.tn-toolbar {
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    box-shadow: var(--tn-shadow-sm);
    padding: .875rem 1rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.tn-toolbar .form-control,
.tn-toolbar .form-select {
    flex: 0 1 18rem;
    min-width: 9rem;
    max-width: 22rem;
    width: auto;
}

/* The one control that should take the leftover room: a search box with nothing beside it. */
.tn-toolbar .tn-toolbar__wide {
    flex: 1 1 20rem;
    max-width: 40rem;
}

.tn-toolbar .btn {
    flex: 0 0 auto;
}

/*
 * A form laid out in columns inside a card body. Fields size themselves to their content
 * hint rather than to a twelve-column grid, which kept producing a one-character currency box
 * next to a full-width name.
 */
.tn-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

.tn-form-grid > .tn-field {
    flex: 1 1 12rem;
    min-width: 8rem;
    margin-bottom: 0;
}

/* Occupies its own line: a reason box, a checkbox row, the submit button. */
.tn-form-grid > .tn-field--full {
    flex: 1 1 100%;
}

.tn-form-grid > .tn-field--narrow {
    flex: 0 1 8rem;
}

.form-check-label {
    font-size: .875rem;
    color: var(--tn-text);
}

/*
 * An operations panel: one labelled row per action, each with its own form. Used where a page
 * offers several small commands over the same record - suspend, cancel, renew, change plan.
 *
 * Deliberately not Bootstrap's input-group. The joined-corner treatment fights the rounded
 * controls this design system uses, and a row of fused boxes hides where one command ends and
 * the next begins - on a page where every button does something consequential, that matters.
 */
.tn-op {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .75rem 0;
    border-bottom: 1px solid var(--tn-border);
}

.tn-op:first-child {
    padding-top: 0;
}

.tn-op:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.tn-op__label {
    flex: 0 0 7.5rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--tn-text);
}

.tn-op__form {
    flex: 1 1 20rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.tn-op__form .form-control,
.tn-op__form .form-select {
    flex: 1 1 8rem;
    min-width: 6rem;
    max-width: 26rem;
    width: auto;
}

.tn-op__form .btn {
    flex: 0 0 auto;
}

/* A checkbox travelling with an action - "cancel, and do it now". */
.tn-op__check {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: .8125rem;
    color: var(--tn-text-muted);
    white-space: nowrap;
}

.tn-op__check .form-check-input {
    margin: 0;
}

/* ----------------------------------------------------------------- validation */

/*
 * What a rejected form looks like.
 *
 * These class names are ASP.NET's, not this design system's: the framework stamps
 * input-validation-error on the control and field-validation-error on its message when the server
 * refuses a value. Styling them here means every form in the console gets the same treatment
 * without a single page having to ask for it.
 */
.form-control.input-validation-error,
.form-select.input-validation-error,
.form-control.input-validation-error:focus,
.form-select.input-validation-error:focus {
    border-color: var(--tn-danger-border);
    background-color: var(--tn-danger-bg);
}

.form-control.input-validation-error:focus,
.form-select.input-validation-error:focus {
    box-shadow: 0 0 0 3px rgba(179, 37, 30, .14);
}

/*
 * The message sits on its own line under the field. Colour alone would not carry it - a reader
 * who cannot separate red from grey would see only another line of hint text - so it is also
 * marked by weight and by the warning glyph.
 */
.field-validation-error {
    display: block;
    margin-top: .375rem;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--tn-danger);
}

.field-validation-error::before {
    content: "⚠";
    margin-inline-end: .3125rem;
    font-weight: 400;
}

/* A field that was rejected and then corrected leaves an empty span; it must not take up room. */
.field-validation-valid:empty {
    display: none;
}

/*
 * The summary at the top of a form, for errors that belong to no single field. Deliberately
 * styled as an alert rather than as a bare list: it is the first thing to read after a refused
 * submit, and it has to look like a message rather than like part of the form.
 */
.validation-summary-errors {
    background: var(--tn-danger-bg);
    border: 1px solid var(--tn-danger-border);
    border-radius: var(--tn-radius);
    padding: .875rem 1.125rem;
    margin-bottom: 1.25rem;
    color: var(--tn-danger);
    font-size: .9375rem;
}

.validation-summary-errors ul {
    margin: 0;
    padding-inline-start: 1.125rem;
}

.validation-summary-errors ul:only-child li:only-child {
    list-style: none;
    margin-inline-start: -1.125rem;
}

/* Nothing to say, so nothing to show - and no empty red box above the fields. */
.validation-summary-valid {
    display: none;
}

/* ----------------------------------------------------------------- busy state */

/*
 * A submit that is on its way.
 *
 * Every mutation in this console is a full page POST, and on a slow round trip the only feedback
 * was the browser's own progress bar - which is easy to miss, and which led to the same reason
 * being submitted twice. The button now says it is working and stops accepting a second click.
 *
 * Applied by script after the browser has already accepted the submit, so a visitor without
 * JavaScript loses the spinner and nothing else.
 */
.btn.is-busy {
    pointer-events: none;
    opacity: .8;
}

.btn.is-busy::before {
    content: "";
    width: .875em;
    height: .875em;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tn-spin .6s linear infinite;
}

@keyframes tn-spin {
    to { transform: rotate(360deg); }
}

/* A spinner is decoration; for a reader who asked for less motion it can simply hold still. */
@media (prefers-reduced-motion: reduce) {
    .btn.is-busy::before {
        animation: none;
        border-top-color: currentColor;
        opacity: .5;
    }
}

/* ----------------------------------------------------------------- section headings */

/*
 * A heading for a run of cards that belongs together - the licence keys under the issue form.
 * Without it the cards simply started, and there was nothing to say where one concern ended and
 * the next began.
 */
.tn-section {
    display: flex;
    align-items: baseline;
    gap: .625rem;
    flex-wrap: wrap;
    margin: 2rem 0 1rem;
}

.tn-section__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--tn-text);
}

.tn-section__meta {
    font-size: .8125rem;
    color: var(--tn-text-muted);
}

.tn-section__note {
    /* width, not just a 100% basis: the basis alone left it sharing the heading's line. */
    width: 100%;
    flex: 0 0 100%;
    font-size: .8125rem;
    color: var(--tn-text-muted);
    margin: .125rem 0 0;
    max-width: 78ch;
}

/* ----------------------------------------------------------------- alerts */

.alert {
    border-radius: var(--tn-radius);
    border-width: 1px;
    padding: .875rem 1.125rem;
    font-size: .9375rem;
    display: flex;
    align-items: flex-start;
    gap: .625rem;
}

.alert-success {
    background: var(--tn-success-bg);
    border-color: var(--tn-success-border);
    color: var(--tn-success);
}

.alert-danger {
    background: var(--tn-danger-bg);
    border-color: var(--tn-danger-border);
    color: var(--tn-danger);
}

.alert-warning {
    background: var(--tn-warning-bg);
    border-color: var(--tn-warning-border);
    color: var(--tn-warning);
}

.alert-info {
    background: var(--tn-info-bg);
    border-color: var(--tn-info-border);
    color: var(--tn-info);
}

/* A panel for a value shown once and never again - an issued key or secret. */
.tn-reveal {
    background: linear-gradient(180deg, var(--tn-primary-soft), var(--tn-surface));
    border: 1px solid var(--tn-primary-border);
    border-radius: var(--tn-radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

/* The value and its copy button, side by side. */
.tn-reveal__row {
    display: flex;
    align-items: stretch;
    gap: .5rem;
    flex-wrap: wrap;
}

.tn-reveal__row .tn-reveal__value {
    flex: 1 1 18rem;
    margin: 0;
}

/*
 * Copying is the whole purpose of this panel: the value is shown once and never again, so a
 * failure to copy it means reissuing the key. The button is therefore as prominent as the value.
 */
.tn-copy {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .75rem 1rem;
    border-radius: var(--tn-radius-sm);
    border: 1px solid var(--tn-primary-border);
    background: var(--tn-surface);
    color: var(--tn-primary);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.tn-copy:hover {
    background: var(--tn-primary-soft);
}

/* Confirmation, because a copy that silently failed is the worst outcome on this panel. */
.tn-copy.is-copied {
    background: var(--tn-success-bg);
    border-color: var(--tn-success-border);
    color: var(--tn-success);
}

.tn-copy__done {
    display: none;
}

.tn-copy.is-copied .tn-copy__idle {
    display: none;
}

.tn-copy.is-copied .tn-copy__done {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
}

.tn-reveal__value {
    display: block;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: .04em;
    background: var(--tn-surface);
    border: 1px solid var(--tn-primary-border);
    border-radius: var(--tn-radius-sm);
    padding: .75rem 1rem;
    color: var(--tn-text);
    word-break: break-all;
}

/* ----------------------------------------------------------------- description lists */

.tn-detail {
    display: grid;
    grid-template-columns: minmax(9rem, 15rem) 1fr;
    gap: .625rem 1.25rem;
    margin: 0;
    font-size: .9375rem;
}

.tn-detail dt {
    color: var(--tn-text-muted);
    font-weight: 500;
}

.tn-detail dd {
    margin: 0;
    color: var(--tn-text);
    font-weight: 500;
    min-width: 0;
    word-break: break-word;
}

/* ----------------------------------------------------------------- auth screens */

.tn-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1100px 520px at 50% -12%, #e9ecff 0%, rgba(233, 236, 255, 0) 62%),
        var(--tn-bg);
}

.tn-auth__panel {
    width: 100%;
    max-width: 27rem;
}

.tn-auth__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.tn-auth__card {
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-lg);
    box-shadow: var(--tn-shadow-lg);
    padding: 2rem;
}

.tn-auth__title {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 .25rem;
}

.tn-auth__desc {
    color: var(--tn-text-muted);
    font-size: .9375rem;
    margin: 0 0 1.5rem;
}

.tn-auth__foot {
    text-align: center;
    font-size: .8125rem;
    color: var(--tn-text-muted);
    margin-top: 1.25rem;
}

/* ----------------------------------------------------------------- page themes */

/*
 * A theme scoped to one page.
 *
 * Licence keys are the part of this console that reaches a customer's machine rather than a row in
 * a table, and they were asked to look like their own area. This does that by re-pointing the
 * accent tokens on a single wrapper - no component is forked, no rule is duplicated, and every
 * card, badge, button and table inside simply inherits the new accent.
 *
 * Deliberately only the accent. The surfaces, borders, radii, shadows and type scale stay exactly
 * the platform's, so the page reads as a room in the same building rather than a different one.
 * The sidebar and header sit outside this wrapper and keep the platform accent, which is what
 * stops the navigation from appearing to change under the reader.
 */
.tn-theme-keys {
    --tn-primary: #0d7d72;
    --tn-primary-hover: #0a625a;
    --tn-primary-soft: #e6f7f4;
    --tn-primary-border: #9ddcd4;
}

/* The page's own icon tile, so the theme is stated once at the top rather than only in the buttons. */
.tn-theme-keys .tn-page-head__icon {
    background: linear-gradient(135deg, #0d7d72, #14a89a);
}

.tn-theme-keys .tn-row-icon {
    background: var(--tn-primary-soft);
    border-color: var(--tn-primary-border);
    color: var(--tn-primary);
}

/*
 * A licence key is a value to be copied, so it is set larger and looser here than the same class
 * carries elsewhere - this is the one screen where reading it off correctly is the whole point.
 */
.tn-theme-keys .tn-table .tn-code {
    font-size: .875rem;
    letter-spacing: .06em;
}

/* ----------------------------------------------------------------- responsive */

@media (max-width: 1199.98px) {
    :root {
        --tn-container: 100%;
    }
}

/* Tablet and below: the sidebar leaves the flow and slides over the content. */
@media (max-width: 991.98px) {
    .tn-sidebar {
        transform: translateX(-100%);
        box-shadow: var(--tn-shadow-lg);
    }

    .tn-shell.is-open .tn-sidebar {
        transform: translateX(0);
    }

    .tn-main {
        margin-inline-start: 0;
    }

    .tn-header__toggle {
        display: inline-flex;
    }

    .tn-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(16, 24, 40, .45);
        z-index: 1035;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .tn-shell.is-open .tn-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (max-width: 767.98px) {
    .tn-grid--2 {
        grid-template-columns: 1fr;
    }

    .tn-content {
        padding: 1.25rem 1rem 2.5rem;
    }

    .tn-page-head {
        flex-wrap: wrap;
    }

    .tn-page-head__actions {
        width: 100%;
    }

    .tn-page-head__actions .btn {
        flex: 1 1 auto;
    }

    .tn-page-head__title {
        font-size: 1.375rem;
    }

    .tn-card__body, .tn-card__head, .tn-card__foot {
        padding-inline: 1.125rem;
    }

    .tn-table thead th, .tn-table tbody td {
        padding-inline: 1.125rem;
    }

    /* Stacked, so a label is never orphaned from its value on a phone. */
    .tn-detail {
        grid-template-columns: 1fr;
        gap: .25rem;
    }

    .tn-detail dd {
        margin-bottom: .625rem;
    }

    .tn-inline-form {
        flex-wrap: wrap;
    }

    .tn-inline-form .form-control {
        min-width: 0;
        flex: 1 1 8rem;
    }

    .tn-user__name, .tn-user__role {
        display: none;
    }
}

/* =================================================================
   Arabic and right-to-left
   =================================================================

   The layout above is written in logical properties - inline-start, inline-end, padding-inline -
   so it mirrors on its own when the document direction flips. Only the things logical properties
   cannot express need saying twice, and they are all below.
*/

/*
 * Letter-spacing and uppercase are Latin typographic devices and both are actively wrong for
 * Arabic. Arabic is cursive: spacing the letters breaks the joins between them and turns a word
 * into disconnected shapes. Uppercase does not exist in the script at all, so text-transform is
 * merely inert - but it is removed alongside so the rules read as one decision.
 *
 * The small-caps look of column headers and the sidebar section label is therefore an
 * English-only treatment. In Arabic those labels are distinguished by weight and colour, which
 * they already carry.
 */
[dir="rtl"] .tn-nav__section,
[dir="rtl"] .tn-table thead th,
[dir="rtl"] .tn-stat__label,
[dir="rtl"] .tn-badge,
[dir="rtl"] body {
    letter-spacing: normal;
    text-transform: none;
}

/* Arabic ascenders and descenders need more room than the Latin face was set for. */
[dir="rtl"] body {
    line-height: 1.7;
}

[dir="rtl"] .tn-page-head__title,
[dir="rtl"] .tn-stat__value {
    letter-spacing: normal;
}

/*
 * Identifiers stay left-to-right inside right-to-left text.
 *
 * This is the one bidirectional bug that would actually mislead someone. A licence mask like
 * TN-ABA0E-*****-*****-N2XWQ or a date like 2026-09-11 is a neutral-and-Latin run; dropped into an
 * Arabic paragraph the bidi algorithm reorders the leading and trailing punctuation around it, and
 * the value is displayed in an order it was never issued in. Isolating each one means what the
 * reader sees is what they can type back into a support ticket.
 */
[dir="rtl"] .tn-code,
[dir="rtl"] .tn-reveal__value,
[dir="rtl"] .tn-avatar,
[dir="rtl"] .tn-count,
[dir="rtl"] .tn-table .tn-col-num {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Isolated runs still belong on the end side of their cell, not dragged to the left of it. */
[dir="rtl"] .tn-table .tn-col-num {
    text-align: end;
}

/*
 * .tn-cell-sub is deliberately NOT in the list above, though it carries most of the dates.
 *
 * It carries Arabic prose as well - a hint under a table cell, a reason from the audit trail - and
 * forcing the whole class left-to-right moved the full stop of every such sentence to the wrong
 * end. A date needs no help anyway: its digits are strong left-to-right runs to the bidi
 * algorithm, and the hyphens and colons between them are common separators that join the run, so
 * 2026-09-11 14:53 already renders correctly inside an Arabic paragraph.
 */

/*
 * Arrows point at a direction, so they mirror with the layout. Everything else - the shield, the
 * key, the box - means the same thing either way and is deliberately left alone. Mirroring an
 * icon that is not directional is the commonest RTL mistake and produces a key that unlocks
 * backwards.
 */
[dir="rtl"] .tn-icon--flip {
    transform: scaleX(-1);
}

/* The off-canvas sidebar hides past the start edge, which in Arabic is the right one. */
@media (max-width: 991.98px) {
    [dir="rtl"] .tn-sidebar {
        transform: translateX(100%);
    }

    [dir="rtl"] .tn-shell.is-open .tn-sidebar {
        transform: translateX(0);
    }
}

/*
 * Check and radio controls. Bootstrap's non-RTL build floats the input left and reserves the space
 * with padding-left, which in Arabic put every checkbox on top of the text it labels.
 */
[dir="rtl"] .form-check {
    padding-left: 0;
    padding-right: 1.5em;
}

[dir="rtl"] .form-check .form-check-input {
    float: right;
    margin-left: 0;
    margin-right: -1.5em;
}

[dir="rtl"] .form-check-inline {
    margin-right: 0;
    margin-left: 1rem;
}

/* The language switcher in the header. */
.tn-lang {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    background: var(--tn-surface-muted);
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius-sm);
    padding: .1875rem;
}

.tn-lang__option {
    border: 0;
    background: transparent;
    color: var(--tn-text-muted);
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1;
    padding: .375rem .625rem;
    border-radius: calc(var(--tn-radius-sm) - 3px);
    cursor: pointer;
}

.tn-lang__option:hover {
    color: var(--tn-text);
}

/*
 * The language you are already reading. Marked so the control shows state rather than merely
 * offering a swap, and disabled so it cannot be re-submitted - but styled back to full contrast,
 * because the browser's default dimming of a disabled control would make the current language look
 * like the unavailable one.
 */
.tn-lang__option.is-current,
.tn-lang__option:disabled {
    background: var(--tn-surface);
    color: var(--tn-text);
    box-shadow: var(--tn-shadow-sm);
    opacity: 1;
    cursor: default;
}

/* Each label is written in its own script, so each needs its own direction. */
.tn-lang__option[lang="ar"] {
    direction: rtl;
    font-family: "Segoe UI Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
}

@media (max-width: 575.98px) {
    .tn-lang__option {
        padding: .375rem .5rem;
    }
}

@media print {
    .tn-sidebar, .tn-header, .tn-page-head__actions, .tn-actions {
        display: none !important;
    }

    .tn-main {
        margin-inline-start: 0;
    }

    .tn-card {
        box-shadow: none;
    }
}
