/*
 * TaxScope theme, on top of Bootstrap 5.3.
 *
 * "Cadastre" identity: a paper canvas, a sidebar drawn like a cadastral plan with the rooftops of a street at its
 * bottom (on phones, a top bar and an ink tab bar), navy ink as the action color, roof-tile terracotta as the highlight.
 * Headings use a geometric sans (Sora), the text Plus Jakarta Sans like every niouts application.
 * Colors are tokens redefined for each theme (data-bs-theme on <html>, set by the "theme" Stimulus controller): the
 * dark theme is the same street at night.
 */

:root,
[data-bs-theme="light"] {
    --ts-canvas: #f7f3ea;
    --ts-surface: #fff;
    --ts-surface-2: #f0ebdf;
    --ts-ink: #172a45;
    --ts-primary: #1f3a5f;
    --ts-primary-strong: #142844;
    --ts-primary-soft: #e1e9f3;
    --ts-on-primary: #fff;
    --ts-accent: #c2562f;
    --ts-accent-strong: #9c3f1e;
    --ts-accent-soft: #fbe5da;
    --ts-success: #15803d;
    --ts-success-soft: #dcf5e3;
    --ts-danger: #b42318;
    --ts-danger-soft: #fde4e1;
    --ts-plan: #f3eee2;
    --ts-plan-line: rgba(31, 58, 95, 0.07);
    --ts-plan-fg: #172a45;
    --ts-plan-muted: rgba(23, 42, 69, 0.66);
    --ts-plan-hover: rgba(23, 42, 69, 0.06);
    --ts-plan-active-bg: #fff;
    --ts-roof-back: #d9c8b4;
    --ts-roof-front: #1f3a5f;
    --ts-street: #1f3a5f;
    --ts-shadow: 0 1px 2px rgba(23, 42, 69, 0.05), 0 10px 28px -14px rgba(23, 42, 69, 0.22);

    --bs-body-bg: var(--ts-surface);
    --bs-body-color: #2b3a52;
    --bs-emphasis-color: #172a45;
    --bs-secondary-color: #687387;
    --bs-secondary-bg: #e6dfd0;
    --bs-tertiary-bg: #faf7f1;
    --bs-border-color: #e9e2d4;
    --bs-primary: #1f3a5f;
    --bs-primary-rgb: 31, 58, 95;
    --bs-primary-text-emphasis: #142844;
    --bs-primary-bg-subtle: #e1e9f3;
    --bs-primary-border-subtle: #a9bdd6;
    --bs-link-color: #1f3a5f;
    --bs-link-color-rgb: 31, 58, 95;
    --bs-link-hover-color: #c2562f;
    --bs-link-hover-color-rgb: 194, 86, 47;
    --bs-focus-ring-color: rgba(31, 58, 95, 0.25);
}

[data-bs-theme="dark"] {
    --ts-canvas: #0f1724;
    --ts-surface: #162133;
    --ts-surface-2: #1e2c42;
    --ts-ink: #f2ede3;
    --ts-primary: #8fb4e6;
    --ts-primary-strong: #bcd3f2;
    --ts-primary-soft: #1d3150;
    --ts-on-primary: #0d1a2c;
    --ts-accent: #f08a5d;
    --ts-accent-strong: #f6ab89;
    --ts-accent-soft: #43271d;
    --ts-success: #5ad88c;
    --ts-success-soft: #173d2a;
    --ts-danger: #ff8a7a;
    --ts-danger-soft: #45231f;
    --ts-plan: #121c2c;
    --ts-plan-line: rgba(143, 180, 230, 0.06);
    --ts-plan-fg: #f2ede3;
    --ts-plan-muted: rgba(242, 237, 227, 0.68);
    --ts-plan-hover: rgba(255, 255, 255, 0.07);
    --ts-plan-active-bg: rgba(255, 255, 255, 0.1);
    --ts-roof-back: #24344d;
    --ts-roof-front: #0b111c;
    --ts-street: #0b111c;
    --ts-shadow: none;

    --bs-body-color: #dcd8d0;
    --bs-emphasis-color: #fff;
    --bs-secondary-color: #a1abba;
    --bs-secondary-bg: #26354d;
    --bs-tertiary-bg: #1a2638;
    --bs-border-color: #26354b;
    --bs-primary: #8fb4e6;
    --bs-primary-rgb: 143, 180, 230;
    --bs-primary-text-emphasis: #cfe0f7;
    --bs-primary-bg-subtle: #1d3150;
    --bs-primary-border-subtle: #34507a;
    --bs-link-color: #bcd3f2;
    --bs-link-color-rgb: 188, 211, 242;
    --bs-link-hover-color: #f6ab89;
    --bs-link-hover-color-rgb: 246, 171, 137;
    --bs-focus-ring-color: rgba(143, 180, 230, 0.25);
}

:root {
    --ts-header-height: 4rem;
    --ts-tabbar-height: 3.75rem;
    --ts-sidebar-width: 16.5rem;
    --ts-font-display: "Sora Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-font-sans-serif: "Plus Jakarta Sans Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-font-size: 0.9375rem;
    --bs-border-radius: 0.85rem;
    --bs-border-radius-sm: 0.6rem;
    --bs-border-radius-lg: 1.25rem;
    --bs-border-radius-xl: 1.5rem;
}

body {
    background-color: var(--ts-canvas);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--ts-ink);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.min-w-0 {
    min-width: 0;
}

.num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

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

/* ---------- Bootstrap components bound to the theme colors ---------- */

.btn {
    --bs-btn-font-weight: 700;
    --bs-btn-padding-x: 1.15rem;
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-border-radius: 999px;
    --bs-btn-font-size: 0.9rem;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    --bs-btn-color: var(--ts-on-primary);
    --bs-btn-bg: var(--ts-primary);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--ts-on-primary);
    --bs-btn-hover-bg: var(--ts-primary-strong);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--ts-on-primary);
    --bs-btn-active-bg: var(--ts-primary-strong);
    --bs-btn-active-border-color: transparent;
    box-shadow: 0 6px 16px -6px rgba(var(--bs-primary-rgb), 0.55);
}

/* Secondary actions: a filled, quiet button. */
.btn-soft {
    --bs-btn-color: var(--ts-ink);
    --bs-btn-bg: var(--ts-surface-2);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--ts-ink);
    --bs-btn-hover-bg: var(--bs-secondary-bg);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--ts-ink);
    --bs-btn-active-bg: var(--bs-secondary-bg);
    --bs-btn-active-border-color: transparent;
}

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
}

/* Fields: filled, the border only shows on focus. */
.form-control,
.form-select {
    min-height: 3rem;
    border: 1.5px solid transparent;
    border-radius: 0.85rem;
    background-color: var(--ts-surface-2);
    color: var(--bs-body-color);
    font-weight: 500;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ts-primary);
    background-color: var(--ts-surface);
    box-shadow: 0 0 0 4px var(--bs-focus-ring-color);
}

.dropdown-menu {
    --bs-dropdown-bg: var(--ts-surface);
    --bs-dropdown-border-color: var(--bs-border-color);
    --bs-dropdown-border-radius: 1.1rem;
    --bs-dropdown-padding-y: 0.4rem;
    --bs-dropdown-item-padding-y: 0.55rem;
    --bs-dropdown-link-color: var(--bs-body-color);
    --bs-dropdown-link-hover-bg: var(--ts-surface-2);
    --bs-dropdown-link-active-color: var(--ts-primary-strong);
    --bs-dropdown-link-active-bg: var(--ts-primary-soft);
    min-width: 15rem;
    padding-inline: 0.4rem;
    box-shadow: 0 18px 40px -12px rgba(23, 42, 69, 0.3);
}

.dropdown-item {
    border-radius: 0.7rem;
    font-weight: 600;
}

.dropdown-item i {
    width: 1.25rem;
    margin-right: 0.5rem;
    opacity: 0.75;
}

.offcanvas {
    --bs-offcanvas-bg: var(--ts-surface);
    --bs-offcanvas-border-color: var(--bs-border-color);
}

/* ---------- Application shell ---------- */

.app-body {
    min-height: 100dvh;
}

/* Desktop: the sidebar on the left, the page on the right. Phones: a top bar and a tab bar around the page. */
.app-shell {
    display: flex;
    min-height: 100dvh;
}

.app-shell-main {
    flex: 1;
    min-width: 0;
}

.app-main {
    padding-bottom: calc(var(--ts-tabbar-height) + env(safe-area-inset-bottom, 0px) + 2.5rem);
}

@media (min-width: 992px) {
    .app-main {
        padding-bottom: 4rem;
    }
}

.app-container {
    max-width: 80rem;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--ts-plan-fg);
    font-family: var(--ts-font-display);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    text-decoration: none;
    line-height: 1;
}

.app-brand:hover {
    color: var(--ts-plan-fg);
}

.app-brand em {
    font-style: normal;
    color: var(--ts-accent);
}

.app-brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.7rem;
    background: var(--ts-primary);
    color: var(--ts-on-primary);
    font-size: 1.05rem;
    box-shadow: inset 0 -3px 0 var(--ts-accent);
}

/* ---------- Desktop sidebar: a cadastral plan, the rooftops of a street at its bottom ---------- */

.app-sidebar {
    position: sticky;
    top: 0;
    flex-direction: column;
    gap: 1.75rem;
    width: var(--ts-sidebar-width);
    height: 100dvh;
    flex: none;
    overflow: hidden;
    padding: 1.75rem 1rem 0;
    border-right: 1px solid var(--bs-border-color);
    background-color: var(--ts-plan);
    background-image:
        linear-gradient(var(--ts-plan-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--ts-plan-line) 1px, transparent 1px);
    background-size: 1.5rem 1.5rem;
    color: var(--ts-plan-fg);
}

.app-sidebar .app-brand {
    padding-inline: 0.5rem;
}

.app-side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.app-side-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.85rem 0.45rem 0.45rem;
    border-radius: 0.95rem;
    color: var(--ts-plan-muted);
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.app-side-icon,
.app-user-icon {
    display: inline-grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    flex: none;
    border-radius: 0.7rem;
    background: var(--ts-plan-hover);
    font-size: 1rem;
    transition: background 0.2s, color 0.2s;
}

.app-side-link:hover {
    color: var(--ts-plan-fg);
    background: var(--ts-plan-hover);
}

.app-side-link.active {
    color: var(--ts-plan-fg);
    background: var(--ts-plan-active-bg);
    box-shadow: var(--ts-shadow);
}

.app-side-link.active .app-side-icon {
    background: var(--ts-accent);
    color: #fff;
}

/* The settings, standing on the street at the bottom of the sidebar. */
.app-side-account {
    position: relative;
    z-index: 1;
    margin-top: auto;
    margin-bottom: 1rem;
}

.app-user-button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    border: 0;
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.9);
    color: #172a45;
    font-weight: 700;
    font-size: 0.85rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 20px -12px rgba(0, 0, 0, 0.5);
}

.app-user-button .app-user-icon {
    background: var(--ts-primary-soft);
    color: #1f3a5f;
}

.app-user-button:hover,
.app-user-button[aria-expanded="true"] {
    background: #fff;
}

.app-side-roofs {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 7rem;
}

.app-roof-back { fill: var(--ts-roof-back); }
.app-roof-front { fill: var(--ts-roof-front); }

/* ---------- Phones: a top bar ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    padding-top: env(safe-area-inset-top, 0px);
    border-bottom: 1px solid var(--bs-border-color);
    background: color-mix(in srgb, var(--ts-canvas) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-header-inner {
    display: flex;
    align-items: center;
    height: var(--ts-header-height);
}

/* ---------- Phones: the street at the bottom of the screen ---------- */

.app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    justify-content: space-around;
    height: calc(var(--ts-tabbar-height) + env(safe-area-inset-bottom, 0px));
    padding: 0 0.5rem env(safe-area-inset-bottom, 0px);
    background: var(--ts-street);
    box-shadow: inset 0 3px 0 var(--ts-accent);
}

.app-tab {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.4rem 0.25rem;
    border: 0;
    background: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.68rem;
    font-weight: 700;
    text-decoration: none;
}

.app-tab i {
    font-size: 1.3rem;
    line-height: 1;
}

.app-tab span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-tab:hover,
.app-tab.active {
    color: #fff;
}

/* The active tab: a lit window above its icon. */
.app-tab.active::before {
    content: "";
    width: 1.5rem;
    height: 0.2rem;
    margin-bottom: 0.15rem;
    border-radius: 0 0 0.2rem 0.2rem;
    background: #ffc58f;
    box-shadow: 0 0 10px 1px rgba(255, 197, 143, 0.6);
}

/* Bottom sheets (offcanvas) */
.app-sheet.offcanvas-bottom {
    height: auto;
    max-height: 85vh;
    border: 0;
    border-radius: 1.75rem 1.75rem 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.app-sheet .offcanvas-header {
    padding-top: 1.5rem;
    padding-bottom: 0.5rem;
}

.app-sheet .offcanvas-header::before {
    content: "";
    position: absolute;
    top: 0.6rem;
    left: 50%;
    width: 2.75rem;
    height: 0.3rem;
    margin-left: -1.375rem;
    border-radius: 1rem;
    background: var(--bs-border-color);
}

.app-sheet-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 0.5rem;
    border-radius: 1rem;
    color: var(--bs-body-color);
    font-weight: 700;
    text-decoration: none;
}

.app-sheet-link > i {
    display: inline-grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.8rem;
    background: var(--ts-surface-2);
    font-size: 1.1rem;
}

.app-sheet-link:hover {
    background: var(--ts-surface-2);
    color: var(--ts-ink);
}

/* Theme switcher, and any other segmented control */
.app-theme-switch,
.app-segmented {
    display: flex;
    gap: 0.2rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: var(--ts-surface-2);
}

.app-theme-switch .btn,
.app-segmented .btn {
    flex: 1;
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-padding-x: 0.5rem;
    --bs-btn-font-size: 0.78rem;
    --bs-btn-color: var(--bs-secondary-color);
    --bs-btn-hover-color: var(--ts-ink);
    --bs-btn-active-color: var(--ts-ink);
    --bs-btn-active-bg: var(--ts-surface);
    border: 0;
}

.app-theme-switch .btn.active,
.app-segmented .btn.active {
    background: var(--ts-surface);
    color: var(--ts-ink);
    box-shadow: 0 1px 4px rgba(23, 42, 69, 0.15);
}

/* ---------- Page structure ---------- */

.app-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin: 0.5rem 0 1.75rem;
}

.app-page-header h1 {
    margin: 0;
    font-family: var(--ts-font-display);
    font-size: clamp(1.75rem, 6vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.app-page-header .app-subtitle {
    margin: 0.45rem 0 0;
    color: var(--bs-secondary-color);
}

.app-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.4rem;
    color: var(--ts-accent);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 2.25rem 0 0.9rem;
    font-family: var(--ts-font-display);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.app-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--bs-border-color);
}

/* ---------- Cards, lists, pills ---------- */

.app-card {
    --bs-card-bg: var(--ts-surface);
    --bs-card-border-width: 1px;
    --bs-card-border-color: var(--bs-border-color);
    --bs-card-cap-bg: transparent;
    --bs-card-border-radius: 1.25rem;
    --bs-card-inner-border-radius: calc(1.25rem - 1px);
    box-shadow: var(--ts-shadow);
    overflow: hidden;
}

.app-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.app-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    vertical-align: middle;
}

.app-pill-primary { background: var(--ts-primary-soft); color: var(--ts-primary-strong); }
.app-pill-accent { background: var(--ts-accent-soft); color: var(--ts-accent-strong); }
.app-pill-success { background: var(--ts-success-soft); color: var(--ts-success); }
.app-pill-danger { background: var(--ts-danger-soft); color: var(--ts-danger); }
.app-pill-muted { background: var(--ts-surface-2); color: var(--bs-secondary-color); }

.app-feature {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.25rem;
}

.app-feature-icon {
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    flex: none;
    margin-bottom: 0.35rem;
    border-radius: 0.85rem;
    background: var(--ts-primary-soft);
    color: var(--ts-primary);
    font-size: 1.25rem;
}

.app-feature h3 {
    margin: 0;
    font-size: 1rem;
}

.app-feature p {
    margin: 0 0 0.75rem;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

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

.app-list > li {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.app-list > li:last-child {
    border-bottom: 0;
}

.app-list .app-feature-icon {
    margin: 0;
}

/* ---------- Calculator ---------- */

/* Commune suggestions, under the field. */
.app-combobox {
    position: relative;
}

.app-combobox .dropdown-menu {
    width: 100%;
    max-height: 18rem;
    overflow-y: auto;
}

.app-combobox .dropdown-menu:not([hidden]) {
    display: block;
}

.app-combobox .dropdown-item,
.app-candidates a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
}

.app-candidates {
    max-height: 16rem;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
}

.app-candidates a {
    padding: 0.55rem 0.85rem;
    color: inherit;
    text-decoration: none;
}

.app-candidates li + li {
    border-top: 1px solid var(--bs-border-color);
}

.app-candidates a:hover {
    background: var(--ts-surface-2);
}

.app-result {
    padding: 1.25rem 1.25rem 1rem;
    background: var(--ts-surface-2);
    border-bottom: 1px solid var(--bs-border-color);
}

.app-result-amount {
    margin: 0.15rem 0 0.35rem;
    color: var(--ts-accent-strong);
    font-family: var(--ts-font-display);
    font-size: clamp(2rem, 9vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.app-table {
    --bs-table-bg: transparent;
    font-size: 0.9rem;
}

.app-table > :not(caption) > * > * {
    padding: 0.7rem 1.25rem;
    white-space: nowrap;
}

.app-table thead th {
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.app-table tfoot tr:first-child > * {
    border-top: 2px solid var(--bs-border-color);
}

.app-table-aside > * {
    background: var(--ts-surface-2);
    border-bottom: 0;
}

/* Row headers may be long labels: they wrap, the figures stay on one line. */
.app-table th[scope="row"]:not(.num) {
    min-width: 9rem;
    white-space: normal;
}

@media (max-width: 575.98px) {
    .app-table > :not(caption) > * > * {
        padding: 0.65rem 0.6rem;
    }

    .app-table thead th {
        white-space: normal;
    }

    .app-table th[scope="row"]:not(.num) {
        min-width: 7rem;
    }
}

/* A table scrolling sideways (one column per compared commune) keeps its row headers in view. */
.app-table-sticky > :not(caption) > tr > :first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--ts-surface);
    box-shadow: inset -1px 0 0 var(--bs-border-color);
}

.app-table-sticky .app-table-aside > :first-child {
    background: var(--ts-surface-2);
}

/* The last row border of a ranking overflows by a pixel, which would show a vertical scrollbar. */
.table-responsive:has(> .app-ranking) {
    overflow-y: hidden;
}

/* Rankings shown side by side: one line per row, so that the rows of both tables line up. */
@media (min-width: 1200px) {
    .app-ranking {
        table-layout: fixed;
    }

    .app-ranking tbody tr {
        height: 3.1rem;
    }

    .app-ranking > :not(caption) > * > * {
        padding-inline: 0.6rem;
    }

    .app-ranking th[scope="row"]:not(.num) {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-ranking th[scope="row"].app-ranking-message {
        overflow: visible;
        text-overflow: clip;
    }

    .app-ranking .app-ranking-rank { width: 2.5rem; }
    .app-ranking .app-ranking-department { width: 3.75rem; }
    .app-ranking .app-ranking-rate { width: 5.75rem; }
    .app-ranking .app-ranking-change { width: 6.75rem; }
}

/* Column chart: a bar per year on a value axis fitted to the amounts; hovering (or tapping) a column shows its figures beside it. */
.app-chart {
    --ts-chart-axis-width: 3.75rem;
    margin: 0;
    padding: 1.5rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.app-chart-plot {
    position: relative;
    height: 13rem;
    margin-left: var(--ts-chart-axis-width);
}

.app-chart-tick {
    position: absolute;
    inset-inline: 0;
    bottom: var(--ts-chart-position);
    border-top: 1px solid var(--bs-border-color);
}

.app-chart-tick:first-child {
    border-top-color: var(--bs-secondary-color);
}

.app-chart-tick span {
    position: absolute;
    right: calc(100% + 0.5rem);
    transform: translateY(-50%);
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

.app-chart-columns,
.app-chart-years {
    display: flex;
}

.app-chart-columns {
    position: absolute;
    inset: 0;
}

.app-chart-column {
    position: relative;
    display: flex;
    flex: 1 1 0;
    align-items: flex-end;
    justify-content: center;
    min-width: 0;
    padding-inline: 1px;
}

.app-chart-bar {
    width: 100%;
    max-width: 2.25rem;
    height: var(--ts-chart-height);
    min-height: 2px;
    border-radius: 4px 4px 0 0;
    background: var(--ts-primary);
    transition: opacity 0.15s ease;
}

.app-chart-column.is-latest .app-chart-bar {
    background: var(--ts-accent);
}

.app-chart-columns:hover .app-chart-bar {
    opacity: 0.45;
}

.app-chart-columns .app-chart-column:hover .app-chart-bar {
    opacity: 1;
}

.app-chart-column:hover {
    background: var(--ts-plan-hover);
}

.app-chart-tip {
    position: absolute;
    top: 0;
    left: calc(100% + 0.35rem);
    z-index: 2;
    display: none;
    min-width: 8.5rem;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius-sm);
    background: var(--ts-surface);
    box-shadow: var(--ts-shadow);
    color: var(--ts-ink);
    font-size: 0.78rem;
    line-height: 1.35;
    pointer-events: none;
}

.app-chart-column:hover .app-chart-tip {
    display: block;
}

/* The tip sits beside its column: on its right, or on its left in the second half of the chart. */
.app-chart-column.is-right-half .app-chart-tip {
    right: calc(100% + 0.35rem);
    left: auto;
}

.app-chart-tip-year {
    display: block;
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
}

.app-chart-tip-amount {
    display: block;
    font-size: 1rem;
}

.app-chart-years {
    margin: 0.35rem 0 0 var(--ts-chart-axis-width);
}

.app-chart-years span {
    display: flex;
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    color: var(--bs-secondary-color);
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .app-chart {
        --ts-chart-axis-width: 3.25rem;
        padding-inline: 0.75rem;
    }

    .app-chart-plot {
        height: 11rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-chart-bar {
        transition: none;
    }
}

/*
 * Rate map: the map fills the card, the base map picker sits over its top-left corner and the legend over its
 * bottom-left one. The base maps are light in both themes, so the points keep one terracotta ramp, the highest rates
 * the darkest, with a white ring.
 */
:root {
    --ts-map-1: #e8925f;
    --ts-map-2: #db7a48;
    --ts-map-3: #c96536;
    --ts-map-4: #b0522a;
    --ts-map-5: #924220;
    --ts-map-6: #733316;
    --ts-map-7: #55240e;
    --ts-map-ring: rgba(255, 255, 255, 0.85);
}

.app-map {
    position: relative;
    height: min(70vh, 40rem);
    min-height: 22rem;
    overflow: hidden;
    border-radius: inherit;
}

.app-map-canvas {
    height: 100%;
}

.app-map-legend {
    position: absolute;
    bottom: 0.75rem;
    left: 0.75rem;
    z-index: 1;
    margin: 0;
    padding: 0.5rem 0.75rem;
    list-style: none;
    background: var(--ts-surface);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    box-shadow: var(--ts-shadow);
    color: var(--bs-body-color);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.app-map-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    line-height: 1.5;
}

.app-map-layers {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1;
    box-shadow: var(--ts-shadow);
}

.app-map-layers .btn {
    --bs-btn-padding-y: 0.3rem;
    --bs-btn-padding-x: 0.65rem;
    --bs-btn-font-size: 0.8rem;
    --bs-btn-bg: var(--ts-surface);
    --bs-btn-color: var(--bs-body-color);
    --bs-btn-border-color: var(--bs-border-color);
    --bs-btn-hover-bg: var(--ts-surface-2);
    --bs-btn-hover-color: var(--bs-emphasis-color);
    --bs-btn-hover-border-color: var(--bs-border-color);
    --bs-btn-active-bg: var(--ts-primary);
    --bs-btn-active-color: var(--ts-on-primary);
    --bs-btn-active-border-color: var(--ts-primary);
    font-weight: 600;
}

.app-map-swatch {
    width: 0.7rem;
    height: 0.7rem;
    flex: none;
    border-radius: 50%;
    background: var(--ts-map-swatch);
}

.app-map-status {
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

.app-map-popup .maplibregl-popup-content {
    padding: 0.6rem 0.8rem;
    background: var(--ts-surface);
    color: var(--bs-body-color);
    border-radius: 0.5rem;
    box-shadow: var(--ts-shadow);
    font-family: inherit;
}

.app-map-popup .maplibregl-popup-tip {
    display: none;
}

.app-map-popup .maplibregl-popup-close-button {
    color: var(--bs-secondary-color);
    font-size: 1.1rem;
}

.app-map-popup-title {
    padding-right: 1rem;
    color: var(--bs-emphasis-color);
    font-weight: 700;
}

.app-map-popup-rate {
    margin-top: 0.15rem;
}

.app-map-popup-link {
    display: inline-block;
    margin-top: 0.4rem;
    font-weight: 600;
}

@media (max-width: 575.98px) {
    .app-map {
        height: 65vh;
    }

    .app-map-layers {
        top: 0.5rem;
        left: 0.5rem;
    }

    .app-map-legend {
        bottom: 0.5rem;
        left: 0.5rem;
        padding: 0.35rem 0.55rem;
        font-size: 0.7rem;
    }
}
