/* ==========================================================================
   Allurify Aura - application styles
   --------------------------------------------------------------------------
   1. Fonts
   2. Design tokens (spacing, radii, motion) + light / dark colour themes
   3. Base elements
   4. App shell: sidebar, mobile bar, main area, page header
   5. Components: buttons, pill tabs, cards, stat cards, badges, avatars
   6. Data lists / tables (become stacked cards on small screens)
   7. Forms
   8. Side panel, dialog, flash messages, empty states, pagination
   9. Feature blocks: auth pages, invoice document, QR, editor, charts
  10. Motion: transitions, native view transitions, reduced motion
  11. Utilities
   Colours are semantic tokens; components never use raw colours.
   Layout uses logical properties (inline/block) so RTL locales work.
   ========================================================================== */

/* 1. Fonts ------------------------------------------------------------------ */

/* One sans-serif family for everything (headings use heavier weights). */
@font-face {
    font-family: "Manrope";
    src: url("../fonts/Manrope-Variable.woff2") format("woff2");
    font-weight: 200 800;
    font-display: swap;
}

/* 2. Tokens ------------------------------------------------------------------ */

:root {
    /* Micro-interactions (section 10): press feedback, springy pop for small things. */
    --motion-press: 90ms;
    --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
    --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --radius-pill: 999px;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 0.9375rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;

    /* Motion: short, gentle ease-out. Feedback 120-180 ms, panels 180-240 ms. */
    --motion-fast: 140ms;
    --motion-panel: 220ms;
    --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);

    --sidebar-width: 264px;
    /* Content uses the full width of desktop screens (incl. 2560 px); only
       ultra-wide screens get side margins. */
    --content-max: 2240px;
    --shell-gap: var(--space-3);
    color-scheme: light;
}

/*
 * Colour themes: monochrome around Allurify violet (#5551fe). Neutrals carry a
 * slight violet cast and the tints are violet steps. No green: "success"
 * is a deep violet too (badges always carry text). Red/amber only mark status.
 * "accent" is for links/text, "accent-fill" for filled buttons (white text
 * keeps >= 4.5:1). "selected" is the active pill (tabs, segmented controls).
 * Everything is flat: solid fills, no gradients or glows. The dark theme
 * never uses white surfaces (only the QR code stays white).
 */
:root,
[data-theme="light"] {
    --canvas: #ecebf3;
    --frame: #f6f6fb;
    --dots: rgba(40, 36, 110, 0.08);
    --surface: #ffffff;
    --surface-2: #f3f2fa;
    --surface-3: #e9e8f4;
    --text: #0f0e1a;
    --muted: #565470;
    --subtle: #7d7b95;
    --border: #e4e3ee;
    --border-strong: #cfcde0;
    --accent: #5551fe;
    --accent-hover: #433ef0;
    --accent-fill: #5551fe;
    --accent-fill-hover: #433ef0;
    --accent-soft: #ebeaff;
    --accent-text: #3a33d1;
    /* Event colours: how strongly the colour tints the background, and what its text mixes with. */
    --ev-tint: 18%;
    --ev-ink: #000;
    --ev-ink-share: 55%;
    --on-accent: #ffffff;
    --focus: #5551fe;
    --ink: #0f0e1a;
    --on-ink: #ffffff;
    --selected: #0f0e1a;
    --on-selected: #ffffff;
    --chip: #0f0e1a;
    --on-chip: #ffffff;
    --stat-icon: rgba(255, 255, 255, 0.7);
    --sidebar: #100f1a;
    --sidebar-text: #c3c6cd;
    --sidebar-muted: #7d818b;
    --sidebar-hover: rgba(255, 255, 255, 0.07);
    --sidebar-active: #ffffff;
    --on-sidebar-active: #0f0e1a;
    --success: #322d9c;
    --success-soft: #e4e3f6;
    --warning: #845400;
    --warning-soft: #ffefc9;
    --danger: #b42318;
    --danger-soft: #fde5e2;
    --info: #1b5f8c;
    --info-soft: #e0eefa;
    --tint-lavender: #e6e5ff;
    --tint-sky: #f1f0ff;
    --tint-mint: #dcdaff;
    --tint-peach: #ebe8fb;
    --tint-rose: #e2dffa;
    --hero: #5551fe;
    /* Chart series: brand violet vs a violet-grey neutral (monochrome by design; the
       grey is below the chroma floor on purpose - legend, tooltips and a table view carry identity). */
    --series-invoiced: #5551fe;
    --series-received: #8b8aa3;
    --shadow: none;
    --shadow-panel: 0 24px 64px rgba(17, 19, 24, 0.18);
    --backdrop: rgba(17, 19, 24, 0.32);
    color-scheme: light;
}

/* Dark theme tokens, shared by data-theme="dark" and "system" + dark OS setting. */
[data-theme="dark"] {
    --canvas: #060609;
    --frame: #0b0b12;
    --dots: rgba(200, 198, 255, 0.06);
    --surface: #13131c;
    --surface-2: #1a1a26;
    --surface-3: #232332;
    --text: #f3f3f8;
    --muted: #a9a8bf;
    --subtle: #807f98;
    --border: #24243a;
    --border-strong: #34344e;
    --accent: #8a86ff;
    --accent-hover: #a3a0ff;
    --accent-fill: #5f5aff;
    --accent-fill-hover: #6f6aff;
    --accent-soft: #1f1d4a;
    --accent-text: #c9c7ff;
    --ev-tint: 26%;
    --ev-ink: #fff;
    --ev-ink-share: 38%;
    --on-accent: #ffffff;
    --focus: #a3a0ff;
    --ink: #2a2842;
    --on-ink: #ffffff;
    --selected: #5f5aff;
    --on-selected: #ffffff;
    --chip: rgba(255, 255, 255, 0.1);
    --on-chip: #f4f4f7;
    --stat-icon: rgba(201, 199, 255, 0.1);
    --sidebar: #0d0c16;
    --sidebar-text: #c3c6cd;
    --sidebar-muted: #7d818b;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: #5f5aff;
    --on-sidebar-active: #ffffff;
    --success: #bdbbff;
    --success-soft: #232140;
    --warning: #f5c04f;
    --warning-soft: #2b220e;
    --danger: #ff7b72;
    --danger-soft: #34161a;
    --info: #7cc4ff;
    --info-soft: #10263a;
    --tint-lavender: #211f47;
    --tint-sky: #191830;
    --tint-mint: #2a2766;
    --tint-peach: #1e1c3c;
    --tint-rose: #1c1a35;
    --hero: #5a55ff;
    /* Chart series (checked against dark surface #13131c; same monochrome rule). */
    --series-invoiced: #7c78ff;
    --series-received: #8f8ea8;
    --shadow: none;
    --shadow-panel: 0 24px 64px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    [data-theme="system"] {
        --canvas: #060609;
        --frame: #0b0b12;
        --dots: rgba(200, 198, 255, 0.06);
        --surface: #13131c;
        --surface-2: #1a1a26;
        --surface-3: #232332;
        --text: #f3f3f8;
        --muted: #a9a8bf;
        --subtle: #807f98;
        --border: #24243a;
        --border-strong: #34344e;
        --accent: #8a86ff;
        --accent-hover: #a3a0ff;
        --accent-fill: #5f5aff;
        --accent-fill-hover: #6f6aff;
        --accent-soft: #1f1d4a;
        --accent-text: #c9c7ff;
        --ev-tint: 26%;
        --ev-ink: #fff;
        --ev-ink-share: 38%;
        --on-accent: #ffffff;
        --focus: #a3a0ff;
        --ink: #2a2842;
        --on-ink: #ffffff;
        --selected: #5f5aff;
        --on-selected: #ffffff;
        --chip: rgba(255, 255, 255, 0.1);
        --on-chip: #f4f4f7;
        --stat-icon: rgba(201, 199, 255, 0.1);
        --sidebar: #0d0c16;
        --sidebar-text: #c3c6cd;
        --sidebar-muted: #7d818b;
        --sidebar-hover: rgba(255, 255, 255, 0.06);
        --sidebar-active: #5f5aff;
        --on-sidebar-active: #ffffff;
        --success: #bdbbff;
        --success-soft: #232140;
        --warning: #f5c04f;
        --warning-soft: #2b220e;
        --danger: #ff7b72;
        --danger-soft: #34161a;
        --info: #7cc4ff;
        --info-soft: #10263a;
        --tint-lavender: #211f47;
        --tint-sky: #191830;
        --tint-mint: #2a2766;
        --tint-peach: #1e1c3c;
        --tint-rose: #1c1a35;
        --hero: #5a55ff;
        /* Chart series (checked against dark surface #13131c; same monochrome rule). */
        --series-invoiced: #7c78ff;
        --series-received: #8f8ea8;
        --shadow: none;
        --shadow-panel: 0 24px 64px rgba(0, 0, 0, 0.6);
        --backdrop: rgba(0, 0, 0, 0.6);
        color-scheme: dark;
    }
}

/* 3. Base -------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* The root paints the canvas itself, so the page background is right from the
   very first frame and underneath view transitions (no light flash). */
html {
    background-color: var(--canvas);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Touch screens: no grey flash behind what was tapped. */
    -webkit-tap-highlight-color: transparent;
}

/* No double-tap zoom delay on controls. */
a,
button,
label,
summary,
input,
select,
textarea {
    touch-action: manipulation;
}

body {
    margin: 0;
    background: var(--canvas);
    color: var(--text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.5;
    font-feature-settings: "tnum" 0;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: -0.01em;
}

p {
    margin: 0;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

@media (hover: hover) {
    a:hover {
        color: var(--accent-hover);
    }
}

img,
svg {
    display: block;
    max-inline-size: 100%;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.num,
td.num,
.amount {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.skip-link {
    position: absolute;
    inset-inline-start: var(--space-4);
    inset-block-start: -100px;
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background: var(--ink);
    color: var(--on-ink);
    border-radius: var(--radius-pill);
}

.skip-link:focus {
    inset-block-start: var(--space-4);
}

/* The hidden attribute always wins over component display rules (e.g. the
   closed side panel must never sit invisibly on top of the page). */
[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.icon {
    inline-size: 20px;
    block-size: 20px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm {
    inline-size: 16px;
    block-size: 16px;
}

/* 4. App shell ----------------------------------------------------------------- */

/*
 * Desktop: the shell fills exactly one viewport. The sidebar and the dotted
 * frame stay still; only the page content scrolls inside .main. The dots
 * belong to the frame, so they do not move while the content scrolls.
 * Phones (<= 860px) switch back to normal document scrolling (see the
 * responsive section) so mobile browser bars can collapse.
 */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--shell-gap);
    block-size: 100dvh;
    padding: var(--shell-gap);
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    min-block-size: 0;
    padding: var(--space-6) var(--space-4) var(--space-5);
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-radius: var(--radius-xl);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    view-transition-name: sidebar;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-inline: var(--space-2);
    color: #ffffff;
    text-decoration: none;
}

@media (hover: hover) {
    .brand:hover {
        color: #ffffff;
    }
}

/* Flat violet brand tile. */
.brand-mark {
    position: relative;
    display: grid;
    place-items: center;
    inline-size: 36px;
    block-size: 36px;
    border-radius: 12px;
    background: #5551fe;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 800;
}

/* Allurify logo letter inside the brand tile (filled glyph, not a stroke icon). */
.brand-mark-glyph {
    inline-size: 13px;
    block-size: 17px;
    fill: currentColor;
}


.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.org-switcher {
    display: block;
    padding: var(--space-3) var(--space-4);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.03);
    color: #ffffff;
}

.org-switcher summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    list-style: none;
}

.org-switcher summary::-webkit-details-marker {
    display: none;
}

.org-switcher .org-label {
    display: block;
    margin-block-end: 2px;
    color: var(--sidebar-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.org-switcher .org-name {
    display: block;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.org-switcher .org-chevron {
    margin-inline-start: auto;
    transition: transform var(--motion-fast) var(--ease-out);
}

.org-switcher[open] .org-chevron {
    transform: rotate(180deg);
}

.org-switcher ul {
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
}

.org-switcher li a {
    display: block;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
}

.org-switcher li a[aria-current="true"] {
    background: var(--sidebar-hover);
    color: #ffffff;
}

@media (hover: hover) {
    .org-switcher li a:hover {
        background: var(--sidebar-hover);
        color: #ffffff;
    }
}

/* Sidebar segments: the name links to the segment's main page, the chevron
   shows/hides its sub-pages. The segment of the current page starts open. */
.nav-segments {
    display: grid;
    gap: var(--space-2);
}

.nav-segment-head {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Segment name = link to the segment's main page. Clickable, so it uses the
   normal (not muted) sidebar text, bold - like the other menu items. */
.nav-segment-link {
    display: flex;
    flex: 1;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
    min-block-size: 44px;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    color: var(--sidebar-text);
    font-weight: 700;
    text-decoration: none;
    transition: color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}

.nav-segment.is-active .nav-segment-link {
    color: #ffffff;
}

@media (hover: hover) {
    .nav-segment-link:hover {
        color: #ffffff;
    }
}

@media (hover: hover) {
    .nav-segment-link:hover {
        background: var(--sidebar-hover);
    }
}

/* On the segment's main page the name itself is the active item. The
   selector repeats the segment classes so it always wins over "is-active"
   (else: white text on the white active pill in the light theme). */
.nav-segment .nav-segment-link.is-current,
.nav-segment.is-active .nav-segment-link.is-current {
    background: var(--sidebar-active);
    color: var(--on-sidebar-active);
}

/* Chevron = show / hide the sub-pages only. */
.nav-segment-toggle {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: 40px;
    block-size: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .nav-segment-toggle:hover {
        background: var(--sidebar-hover);
        color: #ffffff;
    }
}

.nav-segment-toggle .icon {
    transition: transform var(--motion-panel) var(--ease-out);
}

.nav-segment[data-open="true"] .nav-segment-toggle .icon {
    transform: rotate(180deg);
}

/* Height animation without measuring: a grid row from 0fr to 1fr. */
.nav-segment-body {
    display: grid;
    grid-template-rows: 0fr;
    visibility: hidden;
    transition: grid-template-rows var(--motion-panel) var(--ease-out), visibility var(--motion-panel);
}

/* "inherit" (not "visible"): inside the closed mobile drawer the links stay hidden. */
.nav-segment[data-open="true"] .nav-segment-body {
    grid-template-rows: 1fr;
    visibility: inherit;
}

.nav-segment-body > .nav {
    min-block-size: 0;
    padding-block: 0;
    overflow: hidden;
    transition: padding var(--motion-panel) var(--ease-out);
}

.nav-segment[data-open="true"] .nav-segment-body > .nav {
    padding-block: var(--space-1) var(--space-3);
}

.nav {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 46px;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    color: var(--sidebar-text);
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out),
        box-shadow var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .nav a:hover {
        background: var(--sidebar-hover);
        color: #ffffff;
    }
}

.nav a[aria-current="page"] {
    background: var(--sidebar-active);
    color: var(--on-sidebar-active);
}


.sidebar-footer {
    display: grid;
    gap: var(--space-4);
    margin-block-start: auto;
    padding-block-start: var(--space-4);
    border-block-start: 1px solid rgba(255, 255, 255, 0.07);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2);
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
}

@media (hover: hover) {
    .user-chip:hover {
        background: var(--sidebar-hover);
        color: #ffffff;
    }
}

.user-chip .user-name {
    display: block;
    color: #ffffff;
    font-weight: 700;
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

.user-chip .user-role {
    display: block;
    color: var(--sidebar-muted);
    font-size: var(--text-xs);
}

/* Theme segmented control (light / dark / system) in the sidebar. */
.theme-switch {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.06);
}

.theme-switch button {
    display: grid;
    place-items: center;
    min-block-size: 36px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.theme-switch button[aria-pressed="true"] {
    background: var(--sidebar-active);
    color: var(--on-sidebar-active);
}

.logout-form button {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    inline-size: 100%;
    min-block-size: 40px;
    padding: var(--space-2) var(--space-3);
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--sidebar-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

@media (hover: hover) {
    .logout-form button:hover {
        background: var(--sidebar-hover);
        color: #ffffff;
    }
}

/* The still frame with its dot grid. */
.main-frame {
    position: relative;
    min-inline-size: 0;
    min-block-size: 0;
    overflow: hidden;
    border-radius: var(--radius-xl);
    background-color: var(--frame);
    background-image: radial-gradient(var(--dots) 1px, transparent 1.2px);
    background-size: 22px 22px;
}

/* The scrolling content. Its edges fade softly under the frame's corners. */
.main {
    block-size: 100%;
    padding: var(--space-8) clamp(var(--space-5), 3vw, var(--space-12)) var(--space-12);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--space-6), #000 calc(100% - var(--space-6)), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0, #000 var(--space-6), #000 calc(100% - var(--space-6)), transparent 100%);
}

/* The main region is focused programmatically so arrow keys scroll it; no ring needed. */
.main:focus {
    outline: none;
}

.main-inner {
    max-inline-size: var(--content-max);
    margin-inline: auto;
}

.mobile-bar {
    display: none;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4) var(--space-6);
    margin-block-end: var(--space-8);
}

.page-eyebrow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-block-end: var(--space-2);
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
}

.page-eyebrow a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--muted);
    text-decoration: none;
}

@media (hover: hover) {
    .page-eyebrow a:hover {
        color: var(--text);
    }
}

.page-title {
    font-size: clamp(1.75rem, 2.6vw, 2.5rem);
    font-weight: 400;
    letter-spacing: -0.03em;
}

.page-title strong {
    font-weight: 800;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* 5. Components ------------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-block-size: 42px;
    padding: 0 var(--space-5);
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out),
        color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}

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

.btn[disabled],
.btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--accent-fill);
    color: var(--on-accent);
}

@media (hover: hover) {
    .btn-primary:hover {
        background: var(--accent-fill-hover);
        color: var(--on-accent);
    }
}

.btn-ink {
    background: var(--ink);
    color: var(--on-ink);
}

@media (hover: hover) {
    .btn-ink:hover {
        color: var(--on-ink);
        opacity: 0.9;
    }
}

.btn-ghost {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

@media (hover: hover) {
    .btn-ghost:hover {
        border-color: var(--text);
        color: var(--text);
    }
}

.btn-danger {
    border-color: var(--danger);
    background: transparent;
    color: var(--danger);
}

@media (hover: hover) {
    .btn-danger:hover {
        background: var(--danger-soft);
        color: var(--danger);
    }
}

.btn-sm {
    min-block-size: 34px;
    padding: 0 var(--space-4);
    font-size: var(--text-xs);
}

.btn-block {
    inline-size: 100%;
}

.btn-icon {
    inline-size: 42px;
    padding: 0;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Pill tabs / filters: active item is a solid pill (ink in light, violet in dark).
   On narrow screens the row scrolls sideways instead of wrapping. */
.pill-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
}

.pill-tabs a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-block-size: 38px;
    padding: 0 var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .pill-tabs a:hover {
        border-color: var(--border-strong);
    }
}

.pill-tabs a[aria-current="page"] {
    border-color: var(--selected);
    background: var(--selected);
    color: var(--on-selected);
}

.pill-tabs .count {
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--text-xs);
}

.pill-tabs a[aria-current="page"] .count {
    background: rgba(15, 14, 26, 0.3);
    color: inherit;
}

.card {
    padding: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

/* Stacked cards (outside grids) get vertical rhythm; grid children align by row. */
.card + .card {
    margin-block-start: var(--space-4);
}

.grid > .card + .card,
.grid > * + .card {
    margin-block-start: 0;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-end: var(--space-4);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.card-subtitle {
    color: var(--muted);
    font-size: var(--text-sm);
}

.card-flush {
    padding: 0;
    overflow: hidden;
}

.card-flush > .card-header {
    padding: var(--space-5) var(--space-6) 0;
}

/* A separated lower part of a flush card (e.g. a form below a table). */
.card-section {
    padding: var(--space-5) var(--space-6) var(--space-6);
    border-block-start: 1px solid var(--border);
}

/* Discount lines in the on-screen document. */
.discount-row td.primary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--accent-text);
}

.discount-row .num {
    color: var(--muted);
}

.discount-row .num.strong {
    color: var(--text);
}

.data-table tbody tr[aria-current="true"] {
    background: var(--accent-soft);
}

.grid {
    display: grid;
    gap: var(--space-4);
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-main-side {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    align-items: start;
}

/* Wide screens: more room for the side column and airier gaps. */
@media (min-width: 1500px) {
    .grid {
        gap: var(--space-5);
    }

    .grid-main-side {
        grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
    }
}

/* Pastel stat cards with big tabular numbers. */
.stat {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-block-size: 150px;
    padding: var(--space-5) var(--space-6);
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition: transform var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    a.stat:hover {
        color: var(--text);
        border-color: var(--border-strong);
        transform: translateY(-1px);
    }
}

.stat-head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.stat-icon {
    display: grid;
    place-items: center;
    inline-size: 38px;
    block-size: 38px;
    border-radius: 50%;
    background: var(--stat-icon);
    color: inherit;
}

.stat-label {
    font-weight: 700;
}

.stat-chip {
    /* Keeps visually hidden text inside the chip, so it cannot widen a carousel's page. */
    position: relative;
    margin-inline-start: auto;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--chip);
    color: var(--on-chip);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
}

.stat-value {
    margin-block-start: auto;
    font-size: clamp(1.6rem, 2.4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.stat-note {
    color: var(--muted);
    font-size: var(--text-sm);
}

.tint-lavender {
    background: var(--tint-lavender);
    border-color: transparent;
}

.tint-sky {
    background: var(--tint-sky);
    border-color: transparent;
}

.tint-mint {
    background: var(--tint-mint);
    border-color: transparent;
}

.tint-peach {
    background: var(--tint-peach);
    border-color: transparent;
}

.tint-rose {
    background: var(--tint-rose);
    border-color: transparent;
}

/* Brand card: flat violet with white text (one per screen at most). */
.stat-hero {
    background: var(--hero);
    color: #ffffff;
    border-color: transparent;
}

@media (hover: hover) {
    a.stat-hero:hover {
        color: #ffffff;
    }
}

.stat-hero .stat-note {
    color: #ffffff;
}

.stat-hero .stat-icon {
    background: rgba(255, 255, 255, 0.16);
}

.stat-hero .stat-chip {
    background: rgba(15, 14, 26, 0.3);
    color: #ffffff;
}

/* Status badge: pill with a coloured dot AND text (colour is never the only signal). */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 700;
    white-space: nowrap;
}

.badge::before {
    content: "";
    inline-size: 7px;
    block-size: 7px;
    border-radius: 50%;
    background: currentColor;
}

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

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

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

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

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

.avatar {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: 40px;
    block-size: 40px;
    border-radius: 50%;
    font-size: var(--text-sm);
    font-weight: 800;
    color: var(--text);
}

.avatar-sm {
    inline-size: 32px;
    block-size: 32px;
    font-size: var(--text-xs);
}

.tone-1 { background: var(--tint-lavender); }
.tone-2 { background: var(--tint-sky); }
.tone-3 { background: var(--tint-mint); }
.tone-4 { background: var(--tint-peach); }
.tone-5 { background: var(--tint-rose); }

.sidebar .avatar {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.definition-list {
    display: grid;
    grid-template-columns: minmax(120px, 38%) minmax(0, 1fr);
    gap: var(--space-2) var(--space-4);
    margin: 0;
}

.definition-list dt {
    color: var(--muted);
    font-size: var(--text-sm);
}

.definition-list dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* References and IBANs stay on one line where they fit. */
.definition-list dd.ltr {
    overflow-wrap: normal;
    white-space: nowrap;
}

.timeline {
    display: grid;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    position: relative;
    padding-inline-start: var(--space-6);
}

.timeline li::before {
    content: "";
    position: absolute;
    inset-inline-start: 4px;
    inset-block-start: 7px;
    inline-size: 9px;
    block-size: 9px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline li::after {
    content: "";
    position: absolute;
    inset-inline-start: 8px;
    inset-block: 20px -12px;
    border-inline-start: 1px solid var(--border);
}

.timeline li:last-child::after {
    display: none;
}

.timeline time {
    display: block;
    color: var(--muted);
    font-size: var(--text-xs);
}

/* Icons on tinted cards use the violet text colour (monochrome palette). */
[class*="tint-"] .stat-icon {
    color: var(--accent-text);
}

/*
 * Disclosure card: secondary details stay folded until asked for.
 * Where the browser supports it, the body slides open (height + fade)
 * using ::details-content; elsewhere it simply opens.
 */
.disclosure {
    padding: 0;
    interpolate-size: allow-keywords;
}

.disclosure > summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 64px;
    padding: var(--space-4) var(--space-6);
    border-radius: inherit;
    cursor: pointer;
    list-style: none;
    transition: background-color var(--motion-fast) var(--ease-out);
}

.disclosure > summary::-webkit-details-marker {
    display: none;
}

@media (hover: hover) {
    .disclosure > summary:hover {
        background: var(--surface-2);
    }
}

.disclosure-title {
    font-weight: 700;
}

.disclosure-meta {
    margin-inline-start: auto;
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
}

.disclosure-chevron {
    flex: none;
    color: var(--muted);
    transition: transform var(--motion-panel) var(--ease-out);
}

.disclosure-meta + .disclosure-chevron {
    margin-inline-start: 0;
}

.disclosure-title + .disclosure-chevron {
    margin-inline-start: auto;
}

.disclosure[open] > summary .disclosure-chevron {
    transform: rotate(180deg);
}

.disclosure-body {
    padding: 0 var(--space-6) var(--space-6);
}

.disclosure::details-content {
    block-size: 0;
    opacity: 0;
    overflow: clip;
    transition: block-size var(--motion-panel) var(--ease-out), opacity var(--motion-panel) var(--ease-out),
        content-visibility var(--motion-panel) allow-discrete;
}

.disclosure[open]::details-content {
    block-size: auto;
    opacity: 1;
}

/* Plain inline disclosure (link-like summary) with the same gentle opening. */
.reveal {
    interpolate-size: allow-keywords;
}

.reveal > summary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--accent);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.reveal > summary::-webkit-details-marker {
    display: none;
}

.reveal > summary .icon {
    transition: transform var(--motion-panel) var(--ease-out);
}

.reveal[open] > summary .icon {
    transform: rotate(180deg);
}

.reveal::details-content {
    block-size: 0;
    opacity: 0;
    overflow: clip;
    transition: block-size var(--motion-panel) var(--ease-out), opacity var(--motion-panel) var(--ease-out),
        content-visibility var(--motion-panel) allow-discrete;
}

.reveal[open]::details-content {
    block-size: auto;
    opacity: 1;
}

/*
 * Carousel: a normal grid on wide screens; on phones the items become a
 * horizontal, snapping row (see the responsive section). JS marks it as a
 * keyboard-focusable region only while it actually scrolls.
 */
.carousel {
    scrollbar-width: none;
}

.carousel::-webkit-scrollbar {
    display: none;
}

/* 6. Data tables ---------------------------------------------------------------------- */

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

.data-table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table th {
    padding: var(--space-3) var(--space-4);
    border-block-end: 1px solid var(--border);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 700;
    text-align: start;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-4);
    border-block-end: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-block-end: 0;
}

.data-table tbody tr {
    transition: background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .data-table tbody tr:hover {
        background: var(--surface-2);
    }
}

.data-table .num,
.data-table th.num {
    text-align: end;
}

.row-link {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

@media (hover: hover) {
    .row-link:hover {
        color: var(--accent);
    }
}

.cell-main {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-inline-size: 0;
}

.cell-title {
    display: block;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.cell-sub {
    display: block;
    color: var(--muted);
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
}

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    margin-block-end: var(--space-4);
}

.list-toolbar > .input {
    inline-size: auto;
    flex: 0 1 180px;
}

.search-field {
    position: relative;
    flex: 1 1 260px;
    max-inline-size: 420px;
}

.search-field .icon {
    position: absolute;
    inset-inline-start: 14px;
    inset-block-start: 50%;
    translate: 0 -50%;
    color: var(--subtle);
}

.search-field input {
    padding-inline-start: 42px;
    border-radius: var(--radius-pill);
}

/* 7. Forms -------------------------------------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4) var(--space-5);
}

.form-grid .span-2 {
    grid-column: 1 / -1;
}

.form-section + .form-section {
    margin-block-start: var(--space-6);
    padding-block-start: var(--space-6);
    border-block-start: 1px solid var(--border);
}

.form-section-title {
    margin-block-end: var(--space-4);
    font-size: var(--text-md);
    font-weight: 700;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-inline-size: 0;
}

legend {
    padding: 0;
    font-weight: 700;
}

/* align-content: start keeps controls at their natural height, so fields side
   by side stay level even when only one of them has a hint or error below. */
.field {
    display: grid;
    align-content: start;
    gap: 6px;
    min-inline-size: 0;
}

.field > .segmented {
    justify-self: start;
}

.field label,
.label {
    font-size: var(--text-sm);
    font-weight: 700;
}

.field .optional {
    color: var(--muted);
    font-weight: 500;
}

.input,
.field input:not([type="checkbox"], [type="radio"], [type="hidden"]),
.field select,
.field textarea {
    inline-size: 100%;
    min-block-size: 44px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--text-base);
    transition: border-color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out);
}

.field textarea {
    min-block-size: 96px;
    resize: vertical;
}

/* Template source (HTML / CSS). */
.field textarea.code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: var(--text-sm);
    line-height: 1.5;
}

.placeholder-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.placeholder-list li {
    display: grid;
    gap: 2px;
}

.placeholder-list code {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--accent-text);
}

.field input[type="color"] {
    padding: 4px;
    inline-size: 88px;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.field [aria-invalid="true"] {
    border-color: var(--danger);
}

.field [readonly] {
    background: var(--surface-2);
}

.hint {
    color: var(--muted);
    font-size: var(--text-xs);
}

.field-error {
    display: flex;
    gap: 6px;
    color: var(--danger);
    font-size: var(--text-sm);
    font-weight: 600;
}

.field-error::before {
    content: "!";
    display: grid;
    place-items: center;
    flex: none;
    inline-size: 18px;
    block-size: 18px;
    border-radius: 50%;
    background: var(--danger);
    color: var(--surface);
    font-size: 12px;
    font-weight: 800;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: var(--text-sm);
}

.check input {
    flex-shrink: 0;
    inline-size: 20px;
    block-size: 20px;
    margin: 1px 0 0;
    accent-color: var(--accent);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-block-start: var(--space-6);
}

.form-actions-start {
    justify-content: flex-start;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
}

.segmented label {
    position: relative;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented span {
    display: inline-flex;
    align-items: center;
    min-block-size: 36px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out);
}

.segmented input:checked + span {
    background: var(--selected);
    color: var(--on-selected);
}

.segmented input:focus-visible + span {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* Business registry autocomplete */
.lookup {
    position: relative;
}

.lookup-results {
    position: absolute;
    inset-inline: 0;
    inset-block-start: calc(100% + 6px);
    z-index: 30;
    max-block-size: 360px;
    margin: 0;
    padding: var(--space-2);
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}

.lookup-results[data-open="true"] {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

.lookup-option {
    display: grid;
    gap: 2px;
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.lookup-option[aria-selected="true"] {
    background: var(--accent-soft);
}

@media (hover: hover) {
    .lookup-option:hover {
        background: var(--accent-soft);
    }
}

.lookup-option .name {
    font-weight: 700;
}

.lookup-option .meta {
    color: var(--muted);
    font-size: var(--text-xs);
}

.lookup-status {
    padding: var(--space-3);
    color: var(--muted);
    font-size: var(--text-sm);
}

.provenance {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--info-soft);
    color: var(--info);
    font-size: var(--text-sm);
}

/* 8. Panel, dialog, flashes, empty states, pagination ---------------------------------------- */

.panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--backdrop);
    opacity: 0;
    transition: opacity var(--motion-panel) var(--ease-out);
}

.panel {
    position: fixed;
    inset-block: var(--space-3);
    inset-inline-end: var(--space-3);
    z-index: 41;
    display: flex;
    flex-direction: column;
    inline-size: min(480px, calc(100vw - 2 * var(--space-3)));
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow-panel);
    opacity: 0;
    transform: translateX(16px);
    transition: opacity var(--motion-panel) var(--ease-out), transform var(--motion-panel) var(--ease-out);
}

[dir="rtl"] .panel {
    transform: translateX(-16px);
}

.panel[data-state="open"],
.panel-backdrop[data-state="open"] {
    opacity: 1;
    transform: none;
}

/* While closing (fading out) the panel must not catch clicks. */
.panel:not([data-state="open"]),
.panel-backdrop:not([data-state="open"]) {
    pointer-events: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-block-end: 1px solid var(--border);
}

.panel-header h2 {
    font-size: var(--text-lg);
}

.panel-close {
    margin-inline-start: auto;
}

.panel-body {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
}

.panel-body > * + * {
    margin-block-start: var(--space-5);
}

dialog.confirm {
    inline-size: min(440px, calc(100vw - 32px));
    padding: var(--space-6);
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-panel);
}

dialog.confirm::backdrop {
    background: var(--backdrop);
}

dialog.confirm h2 {
    margin-block-end: var(--space-3);
    font-size: var(--text-lg);
}

.flashes {
    display: grid;
    gap: var(--space-2);
    margin-block-end: var(--space-5);
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    font-weight: 600;
    animation: flash-in var(--motion-panel) var(--ease-out);
}

.flash-success {
    background: var(--success-soft);
    border-color: transparent;
    color: var(--success);
}

.flash-error {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}

.flash-warning {
    background: var(--warning-soft);
    border-color: transparent;
    color: var(--warning);
}

.flash-info {
    background: var(--info-soft);
    border-color: transparent;
    color: var(--info);
}

.flash-close {
    margin-inline-start: auto;
    padding: 0 var(--space-1);
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.callout {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius);
    background: var(--warning-soft);
    color: var(--warning);
    font-size: var(--text-sm);
    font-weight: 600;
}

.callout-info {
    background: var(--info-soft);
    color: var(--info);
}

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

.callout > .icon {
    margin-block-start: 1px;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state .empty-icon {
    display: grid;
    place-items: center;
    inline-size: 56px;
    block-size: 56px;
    border-radius: 50%;
    background: var(--tint-lavender);
    color: var(--accent);
}

.empty-state h2,
.empty-state h3 {
    font-size: var(--text-lg);
}

.empty-state p {
    max-inline-size: 42ch;
    color: var(--muted);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-block-start: 1px solid var(--border);
    color: var(--muted);
    font-size: var(--text-sm);
}

.pagination nav {
    display: flex;
    gap: var(--space-2);
}

/* 9. Feature blocks ---------------------------------------------------------------------- */

/* Auth pages: dark brand panel + form. */
.auth {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--space-3);
    min-block-size: 100dvh;
    padding: var(--space-3);
}

.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: var(--space-10);
    overflow: hidden;
    border-radius: var(--radius-xl);
    background: #0a0a0a;
    color: #f2f2f2;
}


.auth-brand .auth-headline {
    position: relative;
    z-index: 1;
    max-inline-size: 16ch;
    font-size: clamp(2.2rem, 4vw, 3.6rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.auth-brand p {
    position: relative;
    z-index: 1;
    max-inline-size: 40ch;
    margin-block-start: var(--space-4);
    color: #b9bcc5;
}

.auth-main {
    display: grid;
    place-items: center;
    padding: var(--space-8) var(--space-4);
    border-radius: var(--radius-xl);
    background-color: var(--frame);
    background-image: radial-gradient(var(--dots) 1px, transparent 1.2px);
    background-size: 22px 22px;
}

.auth-card {
    inline-size: min(440px, 100%);
    padding: var(--space-8);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-card h2,
.auth-card .auth-title {
    margin-block-end: var(--space-2);
    font-size: var(--text-2xl);
}

.auth-card .lead {
    margin-block-end: var(--space-6);
    color: var(--muted);
}

.auth-card form {
    display: grid;
    gap: var(--space-4);
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-3);
    margin-block-start: var(--space-5);
    font-size: var(--text-sm);
}

.auth-card .brand {
    margin-block-end: var(--space-6);
    padding: 0;
    color: var(--text);
}

.locale-form {
    display: flex;
    gap: var(--space-2);
    margin-block-start: var(--space-5);
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-4);
    list-style: none;
    border-radius: var(--radius);
    background: var(--surface-2);
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: var(--text-md);
}

/* QR codes: the code itself is always black on white with its quiet zone,
   independent of the theme. Captions and payment details follow the theme. */
.qr-block {
    display: grid;
    justify-items: center;
    gap: var(--space-3);
    text-align: center;
}

/* Tight white tile: the SVG already contains the standard quiet zone. */
.qr-frame {
    inline-size: min(100%, 232px);
    overflow: hidden;
    border-radius: var(--radius-sm);
    background: #ffffff;
    line-height: 0;
}

.qr-frame .qr {
    inline-size: 100%;
    block-size: auto;
    image-rendering: pixelated;
}

/* Per-user module access (members page). */
.module-access summary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
}

.check-list {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    border: 0;
}

/* Read-only list of switched-on modules (settings). */
.module-list {
    display: grid;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.module-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

/* Fiscal operators: one row per member, form beside the name on wide screens. */
.operator-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.operator-list li {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-block-start: 1px solid var(--border);
}

.operator-who {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.operator-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    align-items: end;
}

/* Fiscal verification code (ZOI): small, still crisp; long ids wrap anywhere. */
.qr-frame-sm {
    inline-size: 132px;
}

.mono-id {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
}

.qr-caption {
    color: var(--muted);
    font-size: var(--text-xs);
}

.qr-caption strong {
    color: var(--text);
}

.qr-inline .qr {
    inline-size: 200px;
    block-size: 200px;
    padding: 8px;
    border-radius: var(--radius);
    background: #ffffff;
}

.payment-details {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-2) var(--space-4);
    margin: 0;
    padding: var(--space-4);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-size: var(--text-sm);
}

.payment-details dt {
    color: var(--muted);
}

.payment-details dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
    direction: ltr;
    unicode-bidi: isolate;
}

.draft-watermark {
    padding: var(--space-4);
    border: 2px dashed var(--warning);
    border-radius: var(--radius);
    background: var(--warning-soft);
    color: var(--warning);
    font-weight: 800;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Invoice document preview (on screen). */
.doc {
    padding: clamp(var(--space-5), 4vw, var(--space-10));
}

.doc-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-6);
    margin-block-end: var(--space-8);
}

.doc-number {
    font-size: var(--text-3xl);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.doc-parties {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6);
    margin-block-end: var(--space-8);
}

.doc-parties h2 {
    margin-block-end: var(--space-2);
    color: var(--muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.totals {
    display: grid;
    gap: var(--space-2);
    inline-size: min(100%, 360px);
    margin-inline-start: auto;
    margin-block-start: var(--space-5);
}

.totals div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    font-variant-numeric: tabular-nums;
}

.totals .grand {
    padding-block-start: var(--space-3);
    border-block-start: 1px solid var(--border);
    font-size: var(--text-lg);
    font-weight: 800;
}

/* Invoice editor: customer + dates in one row. */
.doc-fields {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(150px, 1fr) minmax(150px, 1fr);
    gap: var(--space-4) var(--space-5);
    align-items: start;
}

/*
 * Invoice editor lines. The layout follows the width of the LINES CARD
 * (container query), not of the screen - so it is right with or without
 * the sidebar, on a tablet in landscape or portrait:
 *   narrow (< 560 px)   two columns, labels above the fields;
 *   medium (560-899 px) four columns: service | description,
 *                       qty | unit | price | discount, VAT | amount | remove;
 *   wide (>= 900 px)    ONE row per line under a column header (labels
 *                       visually hidden but kept for screen readers):
 *   service | description | qty | unit | price | discount % | VAT | amount | remove
 * A discount row uses the same columns (label | description | value | %/€ |
 * - | - | applies to | amount | remove). Never a horizontally scrolling page.
 */
.lines-card {
    container: lines / inline-size;
}

.lines {
    display: grid;
    gap: var(--space-3);
}

.line {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    align-items: start;
    padding: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.line .line-service,
.line .line-desc {
    grid-column: 1 / -1;
}

.line .line-spacer,
.lines-head,
.line-service:not(:has(*)) {
    display: none;
}

.line .line-total {
    grid-column: 1 / 2;
    justify-content: flex-start;
}

.line .line-remove {
    justify-self: end;
}

.line .line-label {
    color: var(--muted);
    font-size: var(--text-xs);
}

@container lines (min-width: 560px) {
    .line {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .line .line-service {
        grid-column: 1 / 2;
    }

    /* Without a service picker the description takes the whole row. */
    .line:has(.line-service:not(:has(*))) .line-desc {
        grid-column: 1 / -1;
    }

    .line .line-desc {
        grid-column: 2 / -1;
    }

    .line .line-tax {
        grid-column: 1 / 3;
    }

    .line .line-total {
        grid-column: 3 / 4;
        justify-content: flex-end;
        align-self: end;
    }

    .line .line-remove {
        grid-column: 4 / 5;
        align-self: end;
    }
}

@container lines (min-width: 900px) {
    .line,
    .lines-head {
        display: grid;
        grid-template-columns: minmax(110px, 150px) minmax(140px, 1fr) 72px 60px 96px 68px minmax(100px, 128px) 92px 36px;
        gap: var(--space-2);
    }

    .line {
        padding: var(--space-2);
    }

    .line .line-service,
    .line .line-desc,
    .line .line-tax,
    .line .line-total,
    .line .line-remove {
        grid-column: auto;
    }

    .line .line-total {
        align-self: start;
    }

    .line .line-spacer,
    .line-service:not(:has(*)) {
        display: block;
    }

    .line:has(.line-service:not(:has(*))) .line-desc {
        grid-column: auto;
    }

    .lines-head {
        padding: 0 var(--space-2) var(--space-1);
        color: var(--muted);
        font-size: var(--text-xs);
        font-weight: 700;
    }

    .line .line-label {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
}

.line .field {
    gap: 4px;
}

.line input,
.line select,
.line textarea {
    min-block-size: 40px;
}

.line-service select {
    font-size: var(--text-sm);
}

/* One line tall by default; grows with the text where supported. */
.line-desc textarea {
    min-block-size: 40px;
    max-block-size: 180px;
    field-sizing: content;
    resize: vertical;
}

/* Label in the first column of a discount row. */
.line-kind {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-block-size: 40px;
    padding-inline: var(--space-2);
    color: var(--accent-text);
    font-size: var(--text-sm);
    font-weight: 700;
}

.line-discount {
    border-style: dashed;
    background: var(--accent-soft);
}

.line-total {
    display: flex;
    align-items: center;
    min-block-size: 40px;
    font-weight: 800;
    text-align: end;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.line-remove {
    inline-size: 36px;
    min-block-size: 36px;
    margin-block-start: 2px;
}

.lines-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-block-start: var(--space-3);
}

/* Mailbox: folders on the left, messages on the right. */
.mail-layout {
    display: grid;
    grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
    gap: var(--space-5);
    align-items: start;
}

.mail-folders {
    display: grid;
    gap: var(--space-3);
}

.mail-folders ul {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mail-folders a:not(.btn) {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 40px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-pill);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .mail-folders a:not(.btn):hover {
        background: var(--surface-2);
    }
}

.mail-folders a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.mail-folders .count {
    margin-inline-start: auto;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--accent-fill);
    color: var(--on-accent);
    font-size: var(--text-xs);
    font-weight: 700;
}

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

.mail-rows.selectable li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
}

.mail-select {
    display: grid;
    place-items: center;
    align-self: stretch;
    padding-inline: var(--space-4) 0;
    cursor: pointer;
}

.mail-select input,
.mail-bulk input[type="checkbox"] {
    inline-size: 18px;
    block-size: 18px;
    accent-color: var(--accent-fill);
}

.mail-bulk {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-block-end: 1px solid var(--border);
}

/* Search, filter and actions above the message list. */
.mail-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-block-end: 1px solid var(--border);
}

.mail-search input[type="search"] {
    flex: 1 1 14rem;
    min-inline-size: 0;
}

.mail-bulk-actions,
.mail-toolbar,
.mail-toolbar form,
.mail-move {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.mail-bulk {
    flex-wrap: wrap;
}

.mail-toolbar {
    gap: var(--space-3);
    margin-block-end: var(--space-4);
}

.input-sm {
    min-block-size: 36px;
    padding-block: var(--space-1);
    font-size: var(--text-sm);
}

.mail-move select {
    inline-size: auto;
    max-inline-size: 14rem;
}

.mail-star {
    color: var(--warning, #b7791f);
}

.mail-folder-tools {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

.mail-folder-tools summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--muted);
    cursor: pointer;
}

.mail-folder-tools form {
    margin-block-start: var(--space-3);
}

/* Drop-down menu (<details class="menu">): e.g. "Premakni ▾". */
.menu {
    position: relative;
}

.menu > summary {
    list-style: none;
}

.menu > summary::-webkit-details-marker {
    display: none;
}

.menu-chevron {
    transition: transform var(--motion-fast) var(--ease-out);
}

.menu[open] .menu-chevron {
    transform: rotate(180deg);
}

.menu-list {
    position: absolute;
    inset-block-start: calc(100% + 6px);
    inset-inline-end: 0;
    z-index: 30;
    display: grid;
    min-inline-size: 200px;
    max-block-size: 320px;
    overflow-y: auto;
    padding: var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(10, 10, 20, 0.14);
    animation: rise-in var(--motion-panel) var(--ease-out);
}

.menu-list button {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-block-size: 40px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    text-align: start;
    cursor: pointer;
    transition: background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .menu-list button:hover {
        background: var(--surface-2);
    }
}

.menu-list button:active {
    background: var(--accent-soft);
}

/* The folder menu may extend beyond the message list card. */
.mail-list {
    overflow: visible;
}

/* Actions for ticked messages: one quiet row after the selection. */
.mail-bulk-actions {
    gap: var(--space-1);
}

.mail-bulk-count {
    margin-inline-end: var(--space-2);
    color: var(--muted);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}

.mail-bulk-actions[hidden] {
    display: none;
}

.btn.is-on {
    color: var(--warning, #b7791f);
}

.btn.is-on .icon {
    fill: currentColor;
}

/* Storage use: a thin, quiet line under the folders. */
.mail-quota {
    display: grid;
    gap: 6px;
    margin-block-start: var(--space-2);
    padding: var(--space-3) var(--space-3) 0;
    border-block-start: 1px solid var(--border);
    color: var(--muted);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
}

.mail-quota meter {
    inline-size: 100%;
    block-size: 4px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-3);
    -webkit-appearance: none;
    appearance: none;
}

.mail-quota meter::-webkit-meter-bar {
    block-size: 4px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-3);
}

.mail-quota meter::-webkit-meter-optimum-value,
.mail-quota meter::-webkit-meter-suboptimum-value {
    border-radius: 999px;
    background: var(--accent-fill);
}

.mail-quota meter::-webkit-meter-even-less-good-value {
    border-radius: 999px;
    background: var(--danger);
}

.mail-quota meter::-moz-meter-bar {
    border-radius: 999px;
    background: var(--accent-fill);
}

.mail-rows li + li {
    border-block-start: 1px solid var(--border);
}

.mail-rows a {
    display: grid;
    grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) auto;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-3) var(--space-5);
    color: var(--muted);
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .mail-rows a:hover {
        background: var(--surface-2);
    }
}

.mail-who,
.mail-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-who {
    color: var(--text);
    font-weight: 600;
}

.mail-rows .unseen .mail-who,
.mail-rows .unseen .mail-subject {
    color: var(--text);
    font-weight: 800;
}

.mail-rows .unseen .mail-who::before {
    content: "";
    display: inline-block;
    inline-size: 8px;
    block-size: 8px;
    margin-inline-end: var(--space-2);
    border-radius: 50%;
    background: var(--accent);
}

.mail-meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    white-space: nowrap;
}

.mail-title {
    overflow-wrap: anywhere;
}

.mail-headers {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-1) var(--space-4);
    margin: 0 0 var(--space-5);
    padding-block-end: var(--space-4);
    border-block-end: 1px solid var(--border);
    font-size: var(--text-sm);
}

.mail-headers dt {
    color: var(--muted);
}

.mail-headers dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.mail-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-5);
    padding: 0;
    list-style: none;
}

/* Lock screen: only the card, centred (no brand panel). */
.auth-compact {
    grid-template-columns: minmax(0, 1fr);
}

.auth-compact .auth-brand {
    display: none;
}

.unlock {
    text-align: center;
}

.unlock-icon {
    display: inline-grid;
    place-items: center;
    inline-size: 56px;
    block-size: 56px;
    margin-block-end: var(--space-4);
    border-radius: 18px;
    background: var(--accent-soft);
    color: var(--accent-text);
    animation: rise-in var(--motion-panel) var(--ease-out);
}

.unlock .lead {
    margin-inline: auto;
}

/* "Nastavi to napravo" dialog. */
.setup-items {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-4) 0;
    padding: 0;
    list-style: none;
}

.setup-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--surface-2);
    animation: rise-in var(--motion-panel) var(--ease-out);
}

.setup-item[hidden] {
    display: none;
}

.setup-icon {
    display: grid;
    place-items: center;
    inline-size: 40px;
    block-size: 40px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent-text);
}

.setup-text {
    display: grid;
    gap: 2px;
}

.setup-item.is-done .setup-icon {
    background: var(--accent-fill);
    color: var(--on-accent);
}

/* Customer form: company or private person. */
.customer-kind {
    margin: 0 0 var(--space-4);
    padding: 0;
    border: 0;
}

[data-customer-form][data-kind="person"] [data-business],
[data-customer-form][data-kind="business"] [data-person] {
    display: none !important;
}

/* Invoice buyer: the picker, or "Kupec brez imena" below it. */
.buyer-choice {
    display: grid;
    gap: var(--space-2);
    align-content: start;
}

/* Customer notes: plain text keeps its line breaks. */
.pre-line {
    margin: var(--space-1) 0 0;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.note-general {
    margin-block-end: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.note-list li.is-pinned::before {
    background: var(--warning, #b7791f);
}

.note-edit summary {
    margin-block-start: var(--space-1);
    color: var(--muted);
    font-size: var(--text-xs);
    cursor: pointer;
}

.row-between {
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Members: names and e-mail addresses keep a readable width on desktop. */
.members-table td.primary {
    min-inline-size: 12rem;
}

/* Account -> notifications: this device's switch. */
.push-device {
    display: grid;
    gap: var(--space-2);
    justify-items: start;
    margin-block-end: var(--space-5);
}

.members-table .cell-sub {
    overflow-wrap: anywhere;
}

/* Received HTML mail: its own white page (mails are designed for white),
   full card width, height set by mail-frame.js. */
.mail-frame {
    display: block;
    inline-size: 100%;
    block-size: 480px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    color-scheme: light;
    /* Hidden until the message is parsed: no white empty frame flashes in dark mode. */
    opacity: 0;
    transition: opacity var(--motion-fast) var(--ease-out);
}

.mail-frame.is-ready {
    opacity: 1;
}

/* Received mail content: readable, never wider than the card. */
.mail-body {
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.mail-body table {
    max-inline-size: 100%;
    border-collapse: collapse;
}

.mail-body blockquote {
    margin: var(--space-3) 0;
    padding-inline-start: var(--space-4);
    border-inline-start: 3px solid var(--border-strong);
    color: var(--muted);
}

.mail-quote {
    max-block-size: 320px;
    overflow: auto;
    padding: var(--space-4);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-family: inherit;
    font-size: var(--text-sm);
    white-space: pre-wrap;
}

.mail-compose textarea#body {
    min-block-size: 280px;
}


/* Calendar ------------------------------------------------------------------
 * Week grid rendered by the server: one row per 15 minutes (--cal-row high),
 * positions come from classes (gr-N start row, gs-N row span, rows-N rows,
 * lane-X-of-Y side-by-side lanes); no inline styles, so the CSP stays strict.
 * Day columns are 12 sub-columns wide so 1-4 lanes divide evenly. */
.card.cal {
    --cal-row: 16px;
    padding: 0;
    overflow: hidden;
}

.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-block-end: var(--space-4);
}

.cal-toolbar .pill-tabs {
    margin-block: 0;
}

.cal-toolbar .cal-range {
    font-weight: 700;
}

/* Previous / today / next always stay together on one line. */
.cal-nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.cal-toolbar form {
    margin-inline-start: auto;
}

.cal-grid {
    display: grid;
    grid-template-columns: 56px repeat(7, minmax(0, 1fr));
}

.cal-col {
    min-inline-size: 0;
    border-inline-start: 1px solid var(--border);
}

.cal-col.cal-times {
    border-inline-start: 0;
}

.cal-day-head {
    display: grid;
    align-content: center;
    min-block-size: 52px;
    padding: var(--space-2);
    border-block-end: 1px solid var(--border);
    font-size: var(--text-sm);
    font-weight: 700;
    text-align: center;
    color: var(--muted);
}

.cal-day-head a {
    color: inherit;
    text-decoration: none;
}

.cal-col[aria-current="date"] .cal-day-head {
    color: var(--accent-text);
}

.cal-col[aria-current="date"] .cal-day-head span {
    display: inline-block;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
}

.cal-body {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: 2px;
    padding-inline: 2px;
    /* Hour lines every 4 rows, half-hour lines fainter. */
    background-image:
        linear-gradient(to bottom, var(--border) 1px, transparent 1px),
        linear-gradient(to bottom, color-mix(in srgb, var(--border) 45%, transparent) 1px, transparent 1px);
    background-size: 100% calc(var(--cal-row) * 4), 100% calc(var(--cal-row) * 2);
}

.cal-body[data-clickable] {
    cursor: cell;
}

.cal-hour {
    grid-column: 1 / -1;
    padding-inline-end: var(--space-2);
    color: var(--muted);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    text-align: end;
    transform: translateY(-0.6em);
}

.cal-open {
    grid-column: 1 / -1;
    background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
    pointer-events: none;
}

/* Appointment blocks: flat tinted tiles, no borders (flat design). */
.cal-event {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-block-size: 0;
    margin-block: 1px;
    padding: 3px 7px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--text);
    font-size: var(--text-xs);
    line-height: 1.3;
    text-decoration: none;
    transition: filter var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .cal-event:hover {
        color: var(--text);
        filter: brightness(1.08);
    }
}

.cal-event strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event .cal-event-time,
.cal-event .cal-event-meta {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cal-event.kind-booking {
    background: var(--accent-fill);
    color: var(--on-accent);
}

.cal-event.kind-booking .cal-event-time,
.cal-event.kind-booking .cal-event-meta {
    color: var(--on-accent);
}

.cal-event.kind-meeting {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.cal-event.kind-block {
    background: var(--surface-2);
    color: var(--muted);
}

.cal-event.status-tentative {
    opacity: 0.65;
}

/* Short appointments (30 minutes or less): time and title on one line. */
.cal-event.is-short {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    padding-block: 2px;
}

.cal-event.is-short .cal-event-meta {
    display: none;
}

/* A short event sharing its row: the title matters more; the time stays in the tooltip. */
.cal-event.is-short:not([class$="-of-1"]) .cal-event-time {
    display: none;
}

/*
 * Appointment colours: one palette for the week grid, the day list and the
 * colour picker. Flat like the rest of the interface: a soft tint of the
 * colour (text keeps full contrast in both themes), a dot in lists.
 */
.ev-violet { --ev: #6d5dfc; }
.ev-blue { --ev: #3b82f6; }
.ev-teal { --ev: #14b8a6; }
.ev-green { --ev: #22a06b; }
.ev-amber { --ev: #e3a008; }
.ev-orange { --ev: #f97316; }
.ev-red { --ev: #e5484d; }
.ev-pink { --ev: #e0529c; }
.ev-slate { --ev: #64748b; }
.ev-kind-booking { --ev: var(--accent); }
.ev-kind-meeting { --ev: #3b82f6; }
.ev-kind-block { --ev: #94a3b8; }
.ev-kind-task { --ev: #22a06b; }

.cal-event[class*=" ev-"] {
    background: color-mix(in srgb, var(--ev) var(--ev-tint), var(--surface));
    color: color-mix(in srgb, var(--ev) var(--ev-ink-share), var(--ev-ink));
}

.cal-event[class*=" ev-"] .cal-event-time,
.cal-event[class*=" ev-"] .cal-event-meta {
    color: inherit;
    opacity: 0.8;
}

/* Colour picker: round swatches (radio buttons). */
.swatches {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-block-start: var(--space-3);
}

.swatch {
    position: relative;
    cursor: pointer;
}

.swatch input {
    position: absolute;
    opacity: 0;
}

.swatch > span {
    display: block;
    inline-size: 30px;
    block-size: 30px;
    border-radius: 50%;
    background: var(--ev);
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px transparent;
    transition: box-shadow var(--motion-fast) var(--ease-out), transform var(--motion-panel) var(--ease-spring);
}

.swatch-none > span {
    background: var(--surface-2);
    border: 2px dashed var(--border-strong);
}

.swatch input:checked + span {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
    transform: scale(1.08);
}

.swatch input:focus-visible + span {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

/* Day overview: the overview's agenda rows, with the event's colour as a dot. */
.day-agenda .agenda-time {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-inline-size: 118px;
    color: var(--text);
}

.day-agenda .agenda-title,
.day-agenda .agenda-meta {
    white-space: normal;
    overflow-wrap: anywhere;
}

.day-agenda .status-tentative {
    opacity: 0.65;
}

.ev-dot {
    flex: none;
    inline-size: 10px;
    block-size: 10px;
    border-radius: 50%;
    background: var(--ev);
}

.day-tasks-title {
    margin-block: var(--space-5) var(--space-2);
    padding-inline: var(--space-3);
}

.card > .day-tasks-title:first-child {
    margin-block-start: 0;
}

.day-agenda .agenda-task > span:empty {
    display: none;
}

.day-agenda + .day-tasks-title {
    padding-block-start: var(--space-5);
    border-block-start: 1px solid var(--border);
}

@media (max-width: 560px) {
    .day-agenda .agenda-item {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .day-agenda .agenda-item:not(.agenda-task) .agenda-time {
        grid-column: 1 / -1;
        min-inline-size: 0;
    }

    .day-agenda .agenda-task {
        grid-template-columns: auto minmax(0, 1fr);
    }
}

/* Grid positions of the week view (generated: rows of 15 minutes). */
.gr-1 { grid-row-start: 1; }
.gr-2 { grid-row-start: 2; }
.gr-3 { grid-row-start: 3; }
.gr-4 { grid-row-start: 4; }
.gr-5 { grid-row-start: 5; }
.gr-6 { grid-row-start: 6; }
.gr-7 { grid-row-start: 7; }
.gr-8 { grid-row-start: 8; }
.gr-9 { grid-row-start: 9; }
.gr-10 { grid-row-start: 10; }
.gr-11 { grid-row-start: 11; }
.gr-12 { grid-row-start: 12; }
.gr-13 { grid-row-start: 13; }
.gr-14 { grid-row-start: 14; }
.gr-15 { grid-row-start: 15; }
.gr-16 { grid-row-start: 16; }
.gr-17 { grid-row-start: 17; }
.gr-18 { grid-row-start: 18; }
.gr-19 { grid-row-start: 19; }
.gr-20 { grid-row-start: 20; }
.gr-21 { grid-row-start: 21; }
.gr-22 { grid-row-start: 22; }
.gr-23 { grid-row-start: 23; }
.gr-24 { grid-row-start: 24; }
.gr-25 { grid-row-start: 25; }
.gr-26 { grid-row-start: 26; }
.gr-27 { grid-row-start: 27; }
.gr-28 { grid-row-start: 28; }
.gr-29 { grid-row-start: 29; }
.gr-30 { grid-row-start: 30; }
.gr-31 { grid-row-start: 31; }
.gr-32 { grid-row-start: 32; }
.gr-33 { grid-row-start: 33; }
.gr-34 { grid-row-start: 34; }
.gr-35 { grid-row-start: 35; }
.gr-36 { grid-row-start: 36; }
.gr-37 { grid-row-start: 37; }
.gr-38 { grid-row-start: 38; }
.gr-39 { grid-row-start: 39; }
.gr-40 { grid-row-start: 40; }
.gr-41 { grid-row-start: 41; }
.gr-42 { grid-row-start: 42; }
.gr-43 { grid-row-start: 43; }
.gr-44 { grid-row-start: 44; }
.gr-45 { grid-row-start: 45; }
.gr-46 { grid-row-start: 46; }
.gr-47 { grid-row-start: 47; }
.gr-48 { grid-row-start: 48; }
.gr-49 { grid-row-start: 49; }
.gr-50 { grid-row-start: 50; }
.gr-51 { grid-row-start: 51; }
.gr-52 { grid-row-start: 52; }
.gr-53 { grid-row-start: 53; }
.gr-54 { grid-row-start: 54; }
.gr-55 { grid-row-start: 55; }
.gr-56 { grid-row-start: 56; }
.gr-57 { grid-row-start: 57; }
.gr-58 { grid-row-start: 58; }
.gr-59 { grid-row-start: 59; }
.gr-60 { grid-row-start: 60; }
.gr-61 { grid-row-start: 61; }
.gr-62 { grid-row-start: 62; }
.gr-63 { grid-row-start: 63; }
.gr-64 { grid-row-start: 64; }
.gr-65 { grid-row-start: 65; }
.gr-66 { grid-row-start: 66; }
.gr-67 { grid-row-start: 67; }
.gr-68 { grid-row-start: 68; }
.gr-69 { grid-row-start: 69; }
.gr-70 { grid-row-start: 70; }
.gr-71 { grid-row-start: 71; }
.gr-72 { grid-row-start: 72; }
.gr-73 { grid-row-start: 73; }
.gr-74 { grid-row-start: 74; }
.gr-75 { grid-row-start: 75; }
.gr-76 { grid-row-start: 76; }
.gr-77 { grid-row-start: 77; }
.gr-78 { grid-row-start: 78; }
.gr-79 { grid-row-start: 79; }
.gr-80 { grid-row-start: 80; }
.gr-81 { grid-row-start: 81; }
.gr-82 { grid-row-start: 82; }
.gr-83 { grid-row-start: 83; }
.gr-84 { grid-row-start: 84; }
.gr-85 { grid-row-start: 85; }
.gr-86 { grid-row-start: 86; }
.gr-87 { grid-row-start: 87; }
.gr-88 { grid-row-start: 88; }
.gr-89 { grid-row-start: 89; }
.gr-90 { grid-row-start: 90; }
.gr-91 { grid-row-start: 91; }
.gr-92 { grid-row-start: 92; }
.gr-93 { grid-row-start: 93; }
.gr-94 { grid-row-start: 94; }
.gr-95 { grid-row-start: 95; }
.gr-96 { grid-row-start: 96; }
.gs-1 { grid-row-end: span 1; }
.gs-2 { grid-row-end: span 2; }
.gs-3 { grid-row-end: span 3; }
.gs-4 { grid-row-end: span 4; }
.gs-5 { grid-row-end: span 5; }
.gs-6 { grid-row-end: span 6; }
.gs-7 { grid-row-end: span 7; }
.gs-8 { grid-row-end: span 8; }
.gs-9 { grid-row-end: span 9; }
.gs-10 { grid-row-end: span 10; }
.gs-11 { grid-row-end: span 11; }
.gs-12 { grid-row-end: span 12; }
.gs-13 { grid-row-end: span 13; }
.gs-14 { grid-row-end: span 14; }
.gs-15 { grid-row-end: span 15; }
.gs-16 { grid-row-end: span 16; }
.gs-17 { grid-row-end: span 17; }
.gs-18 { grid-row-end: span 18; }
.gs-19 { grid-row-end: span 19; }
.gs-20 { grid-row-end: span 20; }
.gs-21 { grid-row-end: span 21; }
.gs-22 { grid-row-end: span 22; }
.gs-23 { grid-row-end: span 23; }
.gs-24 { grid-row-end: span 24; }
.gs-25 { grid-row-end: span 25; }
.gs-26 { grid-row-end: span 26; }
.gs-27 { grid-row-end: span 27; }
.gs-28 { grid-row-end: span 28; }
.gs-29 { grid-row-end: span 29; }
.gs-30 { grid-row-end: span 30; }
.gs-31 { grid-row-end: span 31; }
.gs-32 { grid-row-end: span 32; }
.gs-33 { grid-row-end: span 33; }
.gs-34 { grid-row-end: span 34; }
.gs-35 { grid-row-end: span 35; }
.gs-36 { grid-row-end: span 36; }
.gs-37 { grid-row-end: span 37; }
.gs-38 { grid-row-end: span 38; }
.gs-39 { grid-row-end: span 39; }
.gs-40 { grid-row-end: span 40; }
.gs-41 { grid-row-end: span 41; }
.gs-42 { grid-row-end: span 42; }
.gs-43 { grid-row-end: span 43; }
.gs-44 { grid-row-end: span 44; }
.gs-45 { grid-row-end: span 45; }
.gs-46 { grid-row-end: span 46; }
.gs-47 { grid-row-end: span 47; }
.gs-48 { grid-row-end: span 48; }
.gs-49 { grid-row-end: span 49; }
.gs-50 { grid-row-end: span 50; }
.gs-51 { grid-row-end: span 51; }
.gs-52 { grid-row-end: span 52; }
.gs-53 { grid-row-end: span 53; }
.gs-54 { grid-row-end: span 54; }
.gs-55 { grid-row-end: span 55; }
.gs-56 { grid-row-end: span 56; }
.gs-57 { grid-row-end: span 57; }
.gs-58 { grid-row-end: span 58; }
.gs-59 { grid-row-end: span 59; }
.gs-60 { grid-row-end: span 60; }
.gs-61 { grid-row-end: span 61; }
.gs-62 { grid-row-end: span 62; }
.gs-63 { grid-row-end: span 63; }
.gs-64 { grid-row-end: span 64; }
.gs-65 { grid-row-end: span 65; }
.gs-66 { grid-row-end: span 66; }
.gs-67 { grid-row-end: span 67; }
.gs-68 { grid-row-end: span 68; }
.gs-69 { grid-row-end: span 69; }
.gs-70 { grid-row-end: span 70; }
.gs-71 { grid-row-end: span 71; }
.gs-72 { grid-row-end: span 72; }
.gs-73 { grid-row-end: span 73; }
.gs-74 { grid-row-end: span 74; }
.gs-75 { grid-row-end: span 75; }
.gs-76 { grid-row-end: span 76; }
.gs-77 { grid-row-end: span 77; }
.gs-78 { grid-row-end: span 78; }
.gs-79 { grid-row-end: span 79; }
.gs-80 { grid-row-end: span 80; }
.gs-81 { grid-row-end: span 81; }
.gs-82 { grid-row-end: span 82; }
.gs-83 { grid-row-end: span 83; }
.gs-84 { grid-row-end: span 84; }
.gs-85 { grid-row-end: span 85; }
.gs-86 { grid-row-end: span 86; }
.gs-87 { grid-row-end: span 87; }
.gs-88 { grid-row-end: span 88; }
.gs-89 { grid-row-end: span 89; }
.gs-90 { grid-row-end: span 90; }
.gs-91 { grid-row-end: span 91; }
.gs-92 { grid-row-end: span 92; }
.gs-93 { grid-row-end: span 93; }
.gs-94 { grid-row-end: span 94; }
.gs-95 { grid-row-end: span 95; }
.gs-96 { grid-row-end: span 96; }
.rows-4 { grid-template-rows: repeat(4, var(--cal-row)); }
.rows-8 { grid-template-rows: repeat(8, var(--cal-row)); }
.rows-12 { grid-template-rows: repeat(12, var(--cal-row)); }
.rows-16 { grid-template-rows: repeat(16, var(--cal-row)); }
.rows-20 { grid-template-rows: repeat(20, var(--cal-row)); }
.rows-24 { grid-template-rows: repeat(24, var(--cal-row)); }
.rows-28 { grid-template-rows: repeat(28, var(--cal-row)); }
.rows-32 { grid-template-rows: repeat(32, var(--cal-row)); }
.rows-36 { grid-template-rows: repeat(36, var(--cal-row)); }
.rows-40 { grid-template-rows: repeat(40, var(--cal-row)); }
.rows-44 { grid-template-rows: repeat(44, var(--cal-row)); }
.rows-48 { grid-template-rows: repeat(48, var(--cal-row)); }
.rows-52 { grid-template-rows: repeat(52, var(--cal-row)); }
.rows-56 { grid-template-rows: repeat(56, var(--cal-row)); }
.rows-60 { grid-template-rows: repeat(60, var(--cal-row)); }
.rows-64 { grid-template-rows: repeat(64, var(--cal-row)); }
.rows-68 { grid-template-rows: repeat(68, var(--cal-row)); }
.rows-72 { grid-template-rows: repeat(72, var(--cal-row)); }
.rows-76 { grid-template-rows: repeat(76, var(--cal-row)); }
.rows-80 { grid-template-rows: repeat(80, var(--cal-row)); }
.rows-84 { grid-template-rows: repeat(84, var(--cal-row)); }
.rows-88 { grid-template-rows: repeat(88, var(--cal-row)); }
.rows-92 { grid-template-rows: repeat(92, var(--cal-row)); }
.rows-96 { grid-template-rows: repeat(96, var(--cal-row)); }
.lane-0-of-1 { grid-column: 1 / span 12; }
.lane-0-of-2 { grid-column: 1 / span 6; }
.lane-1-of-2 { grid-column: 7 / span 6; }
.lane-0-of-3 { grid-column: 1 / span 4; }
.lane-1-of-3 { grid-column: 5 / span 4; }
.lane-2-of-3 { grid-column: 9 / span 4; }
.lane-0-of-4 { grid-column: 1 / span 3; }
.lane-1-of-4 { grid-column: 4 / span 3; }
.lane-2-of-4 { grid-column: 7 / span 3; }
.lane-3-of-4 { grid-column: 10 / span 3; }

/* Month view: one cell per day with small dots per appointment/task. */
.cal-month {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-month-head {
    padding: var(--space-3) var(--space-2);
    border-block-end: 1px solid var(--border);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cal-month-day {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-block-size: 96px;
    padding: var(--space-2) var(--space-3);
    border-block-end: 1px solid var(--border);
    border-inline-start: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition: background-color var(--motion-fast) var(--ease-out);
}

.cal-month-day:nth-child(7n + 8) {
    border-inline-start: 0;
}

@media (hover: hover) {
    .cal-month-day:hover {
        background: var(--surface-2);
        color: var(--text);
    }
}

.cal-month-day.outside {
    color: var(--subtle);
}

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

.cal-month-day[aria-current="date"] .cal-month-num {
    display: inline-grid;
    place-items: center;
    inline-size: 28px;
    block-size: 28px;
    border-radius: 50%;
    background: var(--accent-fill);
    color: var(--on-accent);
}

.cal-dots {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.cal-dot {
    inline-size: 8px;
    block-size: 8px;
    border-radius: 50%;
    background: var(--accent-fill);
}

.cal-dot.kind-meeting {
    background: var(--accent);
}

.cal-dot.kind-block {
    background: var(--border-strong);
}

.cal-dot.task {
    background: transparent;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.cal-dots .more {
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 700;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin-block-start: var(--space-3);
    color: var(--muted);
    font-size: var(--text-xs);
}

.cal-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Appointment form: fields for bookings only appear for bookings (with JS). */
.event-form[data-kind="meeting"] [data-only="booking"],
.event-form[data-kind="block"] [data-only="booking"],
.event-form[data-kind="block"] [data-hide="block"] {
    display: none;
}

.slot-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.slot-list button {
    min-block-size: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.slot-list button[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

@media (hover: hover) {
    .slot-list button:hover {
        border-color: var(--accent);
        background: var(--accent-soft);
        color: var(--accent-text);
    }
}

/* Agenda (overview) and tasks. */
.agenda,
.task-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.agenda-item,
.task-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    min-block-size: 48px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
}

@media (hover: hover) {
    .agenda-item:hover,
    .task-row:hover {
        background: var(--surface-2);
    }
}

.agenda-time {
    min-inline-size: 92px;
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.agenda-item.kind-booking .agenda-time {
    color: var(--accent-text);
}

.agenda-title {
    overflow: hidden;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agenda-body {
    display: grid;
    min-inline-size: 0;
}

.agenda-meta {
    overflow: hidden;
    color: var(--muted);
    font-size: var(--text-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agenda-meta.overdue,
.task-row .overdue {
    color: var(--danger);
    font-weight: 700;
}

.agenda-task form,
.task-row form.task-toggle {
    display: contents;
}

/* Round check button for tasks (the whole button is the target). */
.task-check {
    display: grid;
    place-items: center;
    inline-size: 24px;
    block-size: 24px;
    padding: 0;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--on-accent);
    cursor: pointer;
    transition: border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .task-check:hover {
        border-color: var(--accent);
    }
}

.task-check[aria-pressed="true"] {
    border-color: var(--accent-fill);
    background: var(--accent-fill);
}

.task-row.done .task-title {
    color: var(--muted);
    text-decoration: line-through;
}

.task-title {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    color: var(--muted);
    font-size: var(--text-sm);
}

.hours-grid {
    display: grid;
    grid-template-columns: minmax(84px, auto) repeat(2, minmax(0, 1fr));
    gap: var(--space-2) var(--space-3);
    align-items: center;
}

.hours-grid .interval {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.hours-grid .interval input {
    inline-size: 100%;
    min-inline-size: 92px;
    padding-inline: 10px 6px;
}

.hours-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
}

/* Working hours: the weekly table gets the wide column, closed days the side. */
@media (min-width: 1101px) {
    .hours-layout {
        grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    }
}

.overview-tiles {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Charts are inline SVG with real data only (no decorative graphs). */
/* The SVG stretches in width at a fixed height; month labels are HTML in
   equal columns that match the bar groups (BarChart pads 8/640 each side,
   the label band is the bottom 26/220 of the drawing). */
.chart-box {
    position: relative;
}

.chart {
    display: block;
    inline-size: 100%;
    block-size: clamp(200px, 17vw, 300px);
}

.chart-labels {
    position: absolute;
    inset-inline: 1.25%;
    inset-block-end: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: center;
    block-size: 11.8%;
    color: var(--muted);
    font-size: var(--text-xs);
    text-align: center;
    white-space: nowrap;
}

.chart .bar-invoiced {
    fill: var(--series-invoiced);
}

.chart .bar-received {
    fill: var(--series-received);
}

@media (hover: hover) {
    .chart .bar:hover {
        opacity: 0.8;
    }
}

.chart .baseline {
    stroke: var(--border-strong);
    stroke-width: 1;
}

.chart .axis-label {
    fill: var(--muted);
    font-size: 11px;
    font-family: var(--font-body);
}

.chart .grid-line {
    stroke: var(--border);
    stroke-width: 1;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    color: var(--muted);
    font-size: var(--text-xs);
    font-weight: 600;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--surface-2);
}

.legend i {
    inline-size: 10px;
    block-size: 10px;
    border-radius: 3px;
}

.legend .sw-invoiced {
    background: var(--series-invoiced);
}

.legend .sw-received {
    background: var(--series-received);
}

.mini-list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mini-list li a,
.mini-list li > div {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

@media (hover: hover) {
    .mini-list li a:hover {
        background: var(--surface-2);
    }
}

.mini-list .amount {
    margin-inline-start: auto;
    font-weight: 800;
}

/* Client panel ("Allurify" menu of a client, and Allurify's support desk). */

/* Package modules and hand-entered services: icon, name + hint, badge at the end. */
.service-tiles {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.service-tiles li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.service-tiles li > span:nth-child(2) {
    flex: 1;
    min-inline-size: 0;
}

.service-tiles li.is-ended {
    background: transparent;
    border: 1px dashed var(--border);
}

.service-tiles li.is-ended .cell-title {
    color: var(--muted);
}

.service-tile-icon {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: 36px;
    block-size: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.mini-list li a > .badge {
    margin-inline-start: auto;
    flex: none;
}

.operator-list.is-plain li {
    padding-inline: 0;
}

/* A small accent dot before unread tickets (text alternative is visually hidden). */
.unread-dot {
    display: inline-block;
    inline-size: 8px;
    block-size: 8px;
    margin-inline-end: var(--space-2);
    border-radius: 50%;
    background: var(--accent);
    vertical-align: middle;
}

.panel-note {
    align-items: flex-start;
}

/* Support conversation: own messages at the end, the other side at the start. */
.thread {
    display: grid;
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.thread-message {
    justify-self: start;
    max-inline-size: min(760px, 92%);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border-end-start-radius: var(--radius-sm);
    background: var(--surface-2);
}

.thread-message.is-own {
    justify-self: end;
    border-end-start-radius: var(--radius-lg);
    border-end-end-radius: var(--radius-sm);
    background: var(--accent-soft);
}

.thread-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block-end: var(--space-2);
    font-size: var(--text-sm);
}

.thread-meta time {
    color: var(--muted);
}

.thread-body {
    overflow-wrap: anywhere;
}

.thread-reply {
    margin-block-start: var(--space-6);
    padding-block-start: var(--space-6);
    border-block-start: 1px solid var(--border);
}

/* Extras: cards that wrap to as many columns as fit. */
.offer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.offer-grid > .card + .card {
    margin: 0;
}

.offer-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.offer-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.offer-price {
    margin-block-start: auto;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* 10. Motion ---------------------------------------------------------------------------- */

@keyframes flash-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

@keyframes vt-fade-out {
    to {
        opacity: 0;
    }
}

@keyframes vt-fade-in {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
}

/*
 * Micro-interactions - one vocabulary for the whole interface:
 *  - press: whatever is clicked or tapped gives in slightly (scale .97, 90 ms)
 *    and springs back; no background flash on touch (hover styles are for
 *    mice only, see @media (hover: hover));
 *  - lift: clickable cards rise 2 px under a mouse;
 *  - enter: dialogs and menus fade in with a 6 px rise;
 *  - busy: the button that sent a form shows a small spinner (forms.js).
 * Only transform / opacity animate; values and text appear at once.
 * Switched off by the user (html[data-motion="off"]) or the system setting.
 */
.btn,
.nav a,
.nav-segment-link,
.nav-segment-toggle,
.mini-list li a,
.mail-rows a,
.mail-folders a,
.pill-tabs a,
.segmented span,
.slot-list button,
.theme-switch button,
.user-chip,
.org-switcher summary,
.check input,
.menu-toggle {
    transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out),
        color var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out),
        opacity var(--motion-fast) var(--ease-out), transform var(--motion-panel) var(--ease-spring);
}

.btn:active:not([disabled]):not([aria-disabled="true"]),
.nav a:active,
.nav-segment-link:active,
.nav-segment-toggle:active,
.mini-list li a:active,
.mail-rows a:active,
.mail-folders a:active,
.pill-tabs a:active,
.segmented label:active span,
.slot-list button:active,
.theme-switch button:active,
.user-chip:active,
.org-switcher summary:active,
.menu-toggle:active {
    transform: scale(0.97);
    transition-duration: var(--motion-press);
}

.check input:active {
    transform: scale(0.88);
    transition-duration: var(--motion-press);
}

/* Clickable cards and tiles lift a little under a mouse. */
.overview-tiles > a,
a.stat,
a.card {
    transition: transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out),
        border-color var(--motion-fast) var(--ease-out);
}

@media (hover: hover) {
    .overview-tiles > a:hover,
    a.stat:hover,
    a.card:hover {
        transform: translateY(-2px);
    }
}

/* Dialogs, menus and the organization list fade in with a small rise. */
dialog.confirm[open],
.org-switcher[open] ul,
.lookup-results:not(:empty),
.module-access[open] > form,
.mail-folder-tools[open] > form,
.note-edit[open] > form {
    animation: rise-in var(--motion-panel) var(--ease-out);
}

dialog.confirm[open]::backdrop {
    animation: fade-in var(--motion-panel) var(--ease-out);
}

/* The button that sent a form: a small spinner while the next page loads. */
.btn[data-busy] {
    position: relative;
    color: transparent !important;
}

.btn[data-busy] > * {
    visibility: hidden;
}

.btn[data-busy]::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    inline-size: 16px;
    block-size: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-color: var(--spinner, var(--muted)) transparent var(--spinner, var(--muted)) var(--spinner, var(--muted));
    animation: spin 700ms linear infinite;
}

.btn-primary[data-busy],
.btn-ink[data-busy],
.btn-danger[data-busy] {
    --spinner: var(--on-accent);
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* The user switched animations off (Moj račun): same as the system setting. */
html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
}

html[data-motion="off"]::view-transition-group(*),
html[data-motion="off"]::view-transition-old(*),
html[data-motion="off"]::view-transition-new(*) {
    animation: none !important;
}

/*
 * Native cross-document view transitions (progressive enhancement).
 * Only enabled when the user has not asked for reduced motion. The sidebar
 * has its own name so it stays still while the page content cross-fades.
 */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }

    ::view-transition {
        background-color: var(--canvas);
    }

    ::view-transition-old(root) {
        animation: 120ms var(--ease-out) both vt-fade-out;
    }

    ::view-transition-new(root) {
        animation: 200ms var(--ease-out) both vt-fade-in;
    }

    ::view-transition-group(sidebar) {
        animation: none;
    }

    ::view-transition-old(sidebar),
    ::view-transition-new(sidebar) {
        animation: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }

    .panel,
    [dir="rtl"] .panel {
        transform: none;
    }
}

/* 11. Utilities & responsive ----------------------------------------------------------------- */

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

.small {
    font-size: var(--text-sm);
}

.xsmall {
    font-size: var(--text-xs);
}

.strong {
    font-weight: 700;
}

.stack > * + * {
    margin-block-start: var(--space-4);
}

/* Page columns (document + side column): clearly separated segments. */
.grid-main-side > .stack > * + * {
    margin-block-start: var(--space-5);
}

/* Hidden form inputs (CSRF, flags) must not push the first visible field down. */
.stack > input[type="hidden"] + *,
.stack > input[type="hidden"]:first-child {
    margin-block-start: 0;
}

.stack-sm > * + * {
    margin-block-start: var(--space-2);
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

.row-between {
    justify-content: space-between;
}

.mt-4 {
    margin-block-start: var(--space-4);
}

.mt-6 {
    margin-block-start: var(--space-6);
}

.mb-4 {
    margin-block-end: var(--space-4);
}

.text-end {
    text-align: end;
}

.nowrap {
    white-space: nowrap;
}

.ltr {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Tablets in landscape and small laptops: a slimmer sidebar leaves the
   content room to breathe. */
@media (min-width: 861px) and (max-width: 1279px) {
    :root {
        --sidebar-width: 228px;
    }

    .main {
        padding-inline: var(--space-6);
    }
}

/* Tables: a document number or a name stays on one line; the other
   columns wrap first. */
.data-table td.primary .cell-title {
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-main-side {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-fields {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .mail-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .mail-folders ul {
        display: flex;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .mail-folders li {
        flex: none;
    }

    .doc-fields > :first-child {
        grid-column: 1 / -1;
    }
}

/* Phones and small tablets: normal document scrolling, drawer navigation. */
@media (max-width: 860px) {
    .shell {
        display: block;
        block-size: auto;
        min-block-size: 100dvh;
        padding: 0;
        overflow: visible;
    }

    .mobile-bar {
        position: sticky;
        inset-block-start: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: calc(var(--space-3) + env(safe-area-inset-top)) calc(var(--space-4) + env(safe-area-inset-right)) var(--space-3) calc(var(--space-4) + env(safe-area-inset-left));
        background: var(--sidebar);
        color: #ffffff;
    }

    .mobile-bar .brand {
        padding: 0;
    }

    .mobile-bar .menu-toggle {
        margin-inline-start: auto;
        border-color: rgba(255, 255, 255, 0.2);
        background: transparent;
        color: #ffffff;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 45;
        inline-size: min(320px, 86vw);
        block-size: 100dvh;
        padding-block-start: calc(var(--space-6) + env(safe-area-inset-top));
        border-radius: 0;
        transform: translateX(-100%);
        transition: transform var(--motion-panel) var(--ease-out);
        visibility: hidden;
    }

    [dir="rtl"] .sidebar {
        inset: 0 0 0 auto;
        transform: translateX(100%);
    }

    .sidebar[data-open="true"] {
        transform: none;
        visibility: visible;
    }

    .sidebar .brand-desktop {
        display: none;
    }

    .main-frame {
        overflow: visible;
        border-radius: 0;
        min-block-size: calc(100dvh - 60px);
    }

    .main {
        block-size: auto;
        padding: var(--space-6) calc(var(--space-4) + env(safe-area-inset-right)) calc(var(--space-10) + env(safe-area-inset-bottom)) calc(var(--space-4) + env(safe-area-inset-left));
        overflow: visible;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .page-header {
        margin-block-end: var(--space-6);
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .auth {
        grid-template-columns: minmax(0, 1fr);
        padding: 0;
        gap: 0;
    }

    .auth-brand {
        min-block-size: 180px;
        padding: var(--space-6);
        border-radius: 0;
    }

    .auth-main {
        border-radius: 0;
    }

    .doc-parties {
        grid-template-columns: minmax(0, 1fr);
    }

    .panel {
        inset: 0;
        inline-size: 100vw;
        border-radius: 0;
    }

    /* Rows of pills and actions scroll sideways instead of wrapping into piles. */
    .pill-tabs,
    .page-actions {
        flex-wrap: nowrap;
        margin-inline: calc(-1 * var(--space-4));
        padding-inline: var(--space-4);
        overflow-x: auto;
        scrollbar-width: none;
    }

    .pill-tabs::-webkit-scrollbar,
    .page-actions::-webkit-scrollbar {
        display: none;
    }

    .pill-tabs > li,
    .page-actions > * {
        flex: none;
    }

    .page-actions {
        inline-size: calc(100% + 2 * var(--space-4));
        padding-block: 2px;
    }

    /* Card groups become a snapping carousel; the next card peeks in. */
    .carousel.grid {
        display: flex;
        gap: var(--space-3);
        margin-inline: calc(-1 * var(--space-4));
        padding: 2px var(--space-4);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--space-4);
    }

    .carousel.grid > * {
        flex: 0 0 min(82%, 340px);
        scroll-snap-align: start;
    }

    .carousel-wide.grid > * {
        flex-basis: min(88%, 420px);
    }
}

/* Tables become stacked cards on phones; labels come from data-label. */
@media (max-width: 720px) {
    .grid-4 {
        grid-template-columns: minmax(0, 1fr);
    }

    .data-table.responsive thead {
        display: none;
    }

    .data-table.responsive,
    .data-table.responsive tbody,
    .data-table.responsive tr,
    .data-table.responsive td {
        display: block;
        inline-size: 100%;
    }

    .data-table.responsive tr {
        padding: var(--space-4) var(--space-5);
        border-block-end: 1px solid var(--border);
    }

    .data-table.responsive td {
        display: flex;
        justify-content: space-between;
        gap: var(--space-4);
        padding: var(--space-1) 0;
        border: 0;
        text-align: end;
    }

    .data-table.responsive td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: var(--text-xs);
        font-weight: 700;
        text-align: start;
    }

    .data-table.responsive td.primary {
        display: block;
        margin-block-end: var(--space-2);
        text-align: start;
    }

    .data-table.responsive td.primary::before {
        content: none;
    }

    .mail-rows a {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--space-1) var(--space-3);
    }

    .mail-rows .mail-subject {
        grid-row: 2;
        grid-column: 1 / -1;
    }

    /* Calendar on phones: one day per screen, swipe sideways; hours stay visible. */
    .cal-scroll {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        overscroll-behavior-x: contain;
        /* Days snap to the right of the sticky hours column. */
        scroll-padding-inline-start: 44px;
    }

    /* A flex row (not a grid): a sticky grid item could not leave its own
       column, a sticky flex item stays visible while the days scroll. */
    .cal-month-day {
        min-block-size: 64px;
        padding: var(--space-2);
    }

    .cal-dot {
        inline-size: 6px;
        block-size: 6px;
    }

    .cal-grid {
        display: flex;
        /* As wide as all days together, so the sticky hours stay inside it. */
        inline-size: max-content;
    }

    .cal-col {
        flex: 0 0 calc(100vw - 44px - 2 * var(--space-4) - 2px);
        scroll-snap-align: start;
    }

    .cal-col.cal-times {
        position: sticky;
        inset-inline-start: 0;
        z-index: 2;
        flex-basis: 44px;
        background: var(--surface);
    }

    .hours-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .doc-fields {
        grid-template-columns: minmax(0, 1fr);
    }

    .card {
        padding: var(--space-5);
    }

    .disclosure {
        padding: 0;
    }

    .disclosure > summary {
        padding-inline: var(--space-5);
    }

    .disclosure-body {
        padding: 0 var(--space-5) var(--space-5);
    }

    .recovery-codes {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat {
        min-block-size: 132px;
    }
}

/* --- Website statistics (Google Analytics) ------------------------------- */

.analytics-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-4);
}

.analytics-period {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    margin: 0;
    margin-inline-start: auto;
    font-size: var(--text-sm);
}

/* A table column that takes the free width and shortens long text with an
   ellipsis instead of pushing the number columns out of the card. */
.data-table td.cell-fill {
    inline-size: 100%;
    max-inline-size: 0;
}

/* Secondary table columns give way to the page name on phones. */
/* Phones: message actions as icons (the text stays for screen readers). */
@media (max-width: 560px) {
    .mail-bulk-actions .btn-label {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .mail-bulk-actions .btn {
        min-inline-size: 42px;
        padding-inline: var(--space-3);
    }

    .mail-search,
    .mail-bulk {
        padding-inline: var(--space-4);
    }
}

/* Tablets in portrait: more air at the sides than on phones. */
@media (min-width: 561px) and (max-width: 860px) {
    .main {
        padding-inline: calc(var(--space-6) + env(safe-area-inset-left));
    }

    .mobile-bar {
        padding-inline: var(--space-6);
    }
}

@media (max-width: 560px) {
    .data-table .col-secondary {
        display: none;
    }
}

.card-pad {
    padding: var(--space-4) var(--space-6) var(--space-6);
}

.clamp-1 {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Change against the previous period: arrow + text, never colour alone. */
.trend-chip.is-down {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--border-strong);
    color: var(--muted);
}

/* Daily trend: the SVG stretches in width; the dot, guide and tooltip are
   HTML placed in percentages by analytics.js (CSSOM, allowed by the CSP).
   The chart's time axis runs left to right in every language. */
.trend-plot {
    position: relative;
    direction: ltr;
    touch-action: pan-y;
}

.trend-labels {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    margin-block-start: var(--space-2);
    color: var(--muted);
    font-size: var(--text-xs);
    text-align: center;
    white-space: nowrap;
}

.trend-labels span {
    overflow: visible;
}

.chart .trend-current {
    fill: none;
    stroke: var(--series-invoiced);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart .trend-area {
    fill: var(--series-invoiced);
    opacity: 0.1;
}

.chart .trend-previous {
    fill: none;
    stroke: var(--series-received);
    stroke-width: 1.5;
    stroke-dasharray: 4 4;
}

.legend .sw-current {
    background: var(--series-invoiced);
}

.legend .sw-previous {
    background: var(--series-received);
}

.trend-axis {
    position: absolute;
    inset-inline-start: 0;
    padding-inline: 4px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--muted);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    transform: translateY(-50%);
}

.trend-axis-top {
    inset-block-start: 5%;
}

.trend-axis-mid {
    inset-block-start: 52%;
}

.trend-guide {
    position: absolute;
    inset-block: 0;
    left: var(--x, 0); /* physical: SVG coordinates do not mirror in RTL */
    inline-size: 1px;
    background: var(--border-strong);
    pointer-events: none;
}

.trend-dot {
    position: absolute;
    inset-block-start: var(--y, 0);
    left: var(--x, 0); /* physical: SVG coordinates do not mirror in RTL */
    inline-size: 10px;
    block-size: 10px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--series-invoiced);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.trend-tip {
    position: absolute;
    inset-block-start: 0;
    left: var(--x, 0); /* physical: SVG coordinates do not mirror in RTL */
    z-index: 2;
    display: grid;
    gap: 2px;
    min-inline-size: 150px;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    box-shadow: var(--shadow);
    transform: translateX(12px);
    pointer-events: none;
}

.trend-tip.is-flipped {
    transform: translateX(calc(-100% - 12px));
}

.trend-tip strong {
    font-size: var(--text-sm);
}

.trend-tip span {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    color: var(--muted);
}

.trend-tip b {
    color: var(--text);
}

/* Ranked share lists (channels, countries, devices). */
.share-list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.share-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px var(--space-3);
    align-items: baseline;
    font-size: var(--text-sm);
}

.share-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.share-bar {
    grid-column: 1 / -1;
    inline-size: 100%;
    block-size: 6px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--chip);
    overflow: hidden;
    appearance: none;
}

.share-bar::-webkit-progress-bar {
    background: var(--chip);
    border-radius: var(--radius-pill);
}

.share-bar::-webkit-progress-value {
    background: var(--series-invoiced);
    border-radius: var(--radius-pill);
}

.share-bar::-moz-progress-bar {
    background: var(--series-invoiced);
    border-radius: var(--radius-pill);
}

.key-steps {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding-inline-start: 1.25rem;
    color: var(--muted);
    font-size: var(--text-sm);
}

.connected-as {
    display: grid;
    gap: var(--space-1);
    padding: var(--space-4);
    border-radius: var(--radius);
    background: var(--chip);
}

.connected-as code {
    font-size: var(--text-sm);
    overflow-wrap: anywhere;
}

@media print {
    .sidebar,
    .mobile-bar,
    .page-actions,
    .no-print {
        display: none !important;
    }

    .shell {
        display: block;
        block-size: auto;
        padding: 0;
        overflow: visible;
    }

    .main-frame,
    .main {
        padding: 0;
        overflow: visible;
        background: #ffffff;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .qr-frame .qr {
        inline-size: 35.98mm;
    }
}
