:root {
    /* Dark chrome */
    --c-navy-900: #0a1838;
    --c-navy-800: #102246;
    --c-navy-700: #1a3060;
    --c-navy-600: #25407a;

    /* Gold accents */
    --c-gold-500: #d4af5f;
    --c-gold-400: #e6c573;
    --c-gold-600: #b8964a;
    --c-gold-100: #f5e9c8;

    /* Action wine */
    --c-wine-600: #8a2741;
    --c-wine-700: #6f1e34;
    --c-wine-500: #a13452;

    /* Content */
    --c-cream-50: #faf7f0;
    --c-cream-100: #f3eee2;
    --c-cream-200: #e8e0cc;
    --c-cream-300: #d8cdb0;
    --c-paper: #ffffff;

    /* Text */
    --c-text-on-dark: #f5f1e4;
    --c-text-on-dark-muted: #a8b3c7;
    --c-text-on-light: #1a1a2e;
    --c-text-on-light-muted: #5a5d6e;
    --c-text-on-light-faint: #8a8fa3;
    --c-text-link: #8a2741;
    --c-text-link-hover: #b8964a;

    /* Functional */
    --c-success: #2f7d4f;
    --c-success-bg: #e6f0e8;
    --c-danger: #b03a3a;
    --c-danger-bg: #f7e6e6;
    --c-warning: #c98a1f;
    --c-warning-bg: #fbf2dd;
    --c-info: #2a5a8a;
    --c-info-bg: #e6eef5;
    --c-avatar-bg: #d8e4f0;
    --c-avatar-text: #4a6a8a;
    --c-skeleton-base: #f3eee2;
    --c-skeleton-highlight: #faf7f0;

    /* Typography */
    --font-serif: "Playfair Display", "Cormorant Garamond", Georgia, serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
    --fs-xs: 11px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 26px;
    --fs-2xl: 34px;
    --fs-3xl: 44px;
    --ls-tight: -0.01em;
    --ls-normal: 0;
    --ls-wide: 0.08em;
    --ls-widest: 0.18em;
    --lh-tight: 1.15;
    --lh-snug: 1.35;
    --lh-base: 1.55;
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* Spacing */
    --sp-0: 0;
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* Shape and motion */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --radius-xl: 12px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(10, 24, 56, 0.06);
    --shadow-md: 0 2px 8px rgba(10, 24, 56, 0.08);
    --shadow-lg: 0 8px 24px rgba(10, 24, 56, 0.12);
    --shadow-xl: 0 16px 48px rgba(10, 24, 56, 0.18);
    --shadow-focus: 0 0 0 3px rgba(212, 175, 95, 0.35);
    --t-fast: 120ms ease-out;
    --t-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Layout */
    --header-h: 56px;
    --header-h-mobile: 52px;
    --nav-h: 44px;
    --subnav-h: 36px;
    --sidebar-w: 220px;
    --sidebar-w-laptop: 200px;
    --content-max: 1280px;
    --drawer-w-nav: 280px;
    --drawer-w-filter: 320px;
    --z-content: 1;
    --z-sticky: 20;
    --z-topbar: 30;
    --z-fab: 50;
    --z-overlay: 80;
    --z-drawer: 90;
    --z-modal: 100;
    --z-toast: 110;
    --z-tooltip: 120;

    /* Compatibility with existing templates and admin settings. */
    --header-bg: var(--c-navy-900);
    --header-text: var(--c-text-on-dark);
    --accent: var(--c-navy-800);
    --accent-dark: var(--c-navy-700);
    --page-bg: var(--c-cream-50);
    --panel-border: var(--c-cream-200);
    --panel-heading: var(--c-cream-100);
    --text: var(--c-text-on-light);
    --muted: var(--c-text-on-light-muted);
    --input-border: var(--c-cream-200);
    --input-focus: var(--c-gold-500);
}

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

html,
body {
    margin: 0;
    padding: 0;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--c-text-on-light);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    background: var(--c-cream-50);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body,
button,
input,
select,
textarea {
    font-family: var(--font-sans);
}

h1,
h2,
h3,
h4,
.record-hero h1,
.sidebar-box h2,
.task-strip h2,
.activity-feed h2,
.placeholder-panel h1,
.admin-heading {
    margin: 0;
    color: var(--c-text-on-light);
    font-family: var(--font-serif);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-normal);
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p {
    margin: 0;
}

a {
    color: var(--c-text-link);
    text-decoration: none;
    transition: color var(--t-fast);
}

a:hover,
a:focus {
    color: var(--c-text-link-hover);
    text-decoration: none;
}

button {
    cursor: pointer;
}

img,
svg {
    max-width: 100%;
}

table {
    width: 100%;
}

:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

::selection {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
}

.app-shell {
    min-height: 100dvh;
    padding-bottom: 0;
    background: var(--c-cream-50);
    --header-bg: var(--c-navy-900);
    --accent: var(--c-navy-800);
    --accent-dark: var(--c-navy-700);
    --mobile-header-bg: var(--c-navy-900);
    --mobile-accent: var(--c-navy-800);
    --mobile-accent-dark: var(--c-navy-700);
}

.body--locked {
    overflow: hidden;
}

/* Topbar */
.app-header {
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
    border-bottom: 1px solid var(--c-navy-700);
    box-shadow: none;
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
}

.app-brand {
    order: 1;
    flex: 0 0 auto;
    width: auto;
    color: #ffffff;
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: var(--fw-bold);
    line-height: 1;
    letter-spacing: var(--ls-wide);
    text-shadow: none;
    white-space: nowrap;
}

.app-brand:hover,
.app-brand:focus {
    color: #ffffff;
}

.mobile-menu-toggle,
.mobile-menu-button,
.search-trigger {
    display: none;
}

.global-search {
    position: static;
    flex: 0 1 420px;
    width: auto;
    max-width: 420px;
    margin: 0 0 0 auto;
    order: 8;
    align-self: center;
}

.global-search label {
    position: relative;
    display: block;
}

.global-search span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.global-search label::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 13px;
    height: 13px;
    border: 2px solid var(--c-text-on-dark-muted);
    border-radius: 50%;
    transform: translateY(-56%);
    pointer-events: none;
}

.global-search label::after {
    content: "";
    position: absolute;
    left: 24px;
    top: calc(50% + 6px);
    width: 7px;
    height: 2px;
    background: var(--c-text-on-dark-muted);
    transform: rotate(45deg);
    transform-origin: left center;
    pointer-events: none;
}

.global-search input,
input[type="search"] {
    width: 100%;
    min-height: 34px;
    height: auto;
    padding: 8px 14px 8px 48px;
    color: var(--c-text-on-dark);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--c-navy-700);
    border-radius: var(--radius-md);
    box-shadow: none;
    font-size: var(--fs-sm);
    line-height: var(--lh-snug);
    transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}

.global-search input {
    padding-left: 64px;
}

.global-search input::placeholder,
input[type="search"]::placeholder {
    color: var(--c-text-on-dark-muted);
}

.global-search input:focus,
input[type="search"]:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--c-gold-500);
    box-shadow: var(--shadow-focus);
}

.search-trigger {
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--c-gold-500);
    background: transparent;
    border: 1px solid var(--c-navy-700);
    border-radius: var(--radius-md);
    font-size: 0;
    flex-shrink: 0;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.search-trigger::before {
    content: "";
    width: 13px;
    height: 13px;
    border: 2px solid currentColor;
    border-radius: 50%;
    transform: translate(-1px, -1px);
}

.search-trigger::after {
    content: "";
    width: 7px;
    height: 2px;
    margin-left: -3px;
    margin-top: 13px;
    background: currentColor;
    transform: rotate(45deg);
    transform-origin: left center;
}

.search-trigger:hover {
    background: var(--c-navy-800);
    border-color: var(--c-gold-500);
}

.logout-form,
.app-header > a[href$="login"] {
    position: static;
    order: 4;
}

.logout-form {
    order: 9;
    height: 24px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding-left: var(--sp-4);
    color: var(--c-text-on-dark);
    border-left: 1px solid var(--c-navy-700);
    font-size: var(--fs-sm);
}

.logout-form button,
.app-header > a[href$="login"] {
    min-height: 30px;
    padding: 6px 14px;
    color: var(--c-gold-500);
    background: transparent;
    border: 1px solid var(--c-gold-500);
    border-radius: var(--radius-md);
    box-shadow: none;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    line-height: 1;
    text-transform: uppercase;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.logout-form button:hover,
.app-header > a[href$="login"]:hover {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
    border-color: var(--c-gold-500);
}

.locale-switcher {
    order: 10;
    flex: 0 0 auto;
}

.locale-switcher label {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.locale-switcher label::before {
    content: "\25CE";
    position: absolute;
    left: 11px;
    color: var(--c-text-on-dark);
    font-size: 12px;
    pointer-events: none;
}

.locale-switcher label::after {
    content: "";
    position: absolute;
    right: 11px;
    width: 7px;
    height: 7px;
    border-right: 1px solid var(--c-text-on-dark);
    border-bottom: 1px solid var(--c-text-on-dark);
    transform: translateY(-2px) rotate(45deg);
    pointer-events: none;
}

.locale-switcher span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.locale-switcher select {
    min-width: 86px;
    min-height: 34px;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 30px 0 30px;
    color: var(--c-text-on-dark);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--c-gold-500);
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
}

.locale-switcher select:focus {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.locale-switcher select option {
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
}

/* Main navigation */
.app-nav {
    height: var(--nav-h);
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0 var(--sp-6);
    background: var(--c-navy-900);
    border-bottom: 1px solid var(--c-gold-500);
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--nav-h) * -1);
    z-index: var(--z-sticky);
    order: 2;
    margin: 0;
    align-self: flex-end;
}

.app-header .app-nav {
    position: absolute;
    top: auto;
    bottom: calc(var(--nav-h) * -1);
    left: 0;
    right: 0;
}

.app-nav a {
    min-height: var(--nav-h);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 var(--sp-5);
    color: var(--c-text-on-dark-muted);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    text-shadow: none;
    white-space: nowrap;
    position: relative;
    transition: background var(--t-fast), color var(--t-fast);
}

.app-nav a:hover {
    color: var(--c-text-on-dark);
    background: var(--c-navy-800);
}

.app-nav a.is-active {
    color: var(--c-gold-500);
    background: var(--c-navy-700);
    border: 0;
    box-shadow: none;
}

.app-nav a.is-active::before {
    content: "\2726";
    color: var(--c-gold-500);
    font-size: 8px;
}

.app-nav a.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--c-gold-500);
}

.app-main {
    width: min(calc(100% - 48px), var(--content-max));
    max-width: var(--content-max);
    margin: calc(var(--nav-h) + var(--sp-6)) auto var(--sp-8);
}

.sub-nav + .app-main {
    margin: var(--sp-6) auto var(--sp-8);
}

/* Sub-action bar */
.sub-nav {
    min-height: var(--subnav-h);
    display: flex;
    align-items: center;
    gap: var(--sp-6);
    margin-top: var(--nav-h);
    padding: 0 var(--sp-6);
    color: var(--c-text-on-dark);
    background: var(--c-navy-800);
    border-bottom: 1px solid var(--c-navy-700);
    box-shadow: none;
}

.sub-nav a,
.sub-nav label,
.assigned-filter,
.assigned-filter label {
    color: var(--c-gold-400);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    text-shadow: none;
}

.sub-nav a,
.sub-nav label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.sub-nav a:first-child::before {
    content: "+";
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-navy-900);
    background: var(--c-gold-500);
    border-radius: 50%;
    font-weight: var(--fw-bold);
}

.sub-nav a:not(:first-child)::before {
    content: "\2726";
    color: var(--c-gold-500);
    font-size: 9px;
}

.sub-nav a.sub-nav-link--plain::before {
    content: none;
}

.sub-nav a.sub-nav-link--star::before {
    content: "\2726";
    width: auto;
    height: auto;
    color: var(--c-gold-500);
    background: transparent;
    border-radius: 0;
    font-size: 9px;
}

.sub-nav a:hover,
.sub-nav a:focus,
.record-tabs a:hover,
.record-tabs a:focus {
    color: #ffffff;
}

.sub-nav a.is-active {
    color: #ffffff;
    text-decoration: none;
}

/* Panels and layout */
.directory-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: var(--sp-6);
    align-items: start;
}

.directory-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
}

.crm-panel,
.crm-form-panel,
.record-hero,
.record-history-panel,
.record-details,
.record-tags-panel,
.sidebar-box,
.placeholder-panel,
.task-item,
.admin-panel,
.admin-bottom-box,
.auth-form,
.image-upload-panel,
.contact-table,
.activity-row,
.detail-list-row {
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.crm-panel,
.placeholder-panel {
    padding: var(--sp-5);
}

.crm-form-panel,
.record-history-panel,
.record-details,
.record-tags-panel,
.image-upload-panel,
.admin-panel {
    overflow: hidden;
}

.crm-form-panel > header,
.record-details header,
.record-tags-panel header,
.admin-panel > header,
.image-upload-panel > header,
.contact-table th,
.auth-form::before {
    color: var(--c-text-on-light);
    background: var(--c-cream-100);
    border-bottom: 1px solid var(--c-cream-200);
}

.sidebar-box {
    padding: var(--sp-5);
}

.appearance-theme-picker {
    margin-bottom: var(--sp-4);
}

.appearance-custom-settings[hidden] {
    display: none;
}

.search-autocomplete {
    position: relative;
}

.search-suggestions {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 60;
    width: min(420px, 92vw);
    max-height: 380px;
    overflow: auto;
    padding: 6px;
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.search-suggestions[hidden] {
    display: none;
}

.search-suggestions a {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    color: var(--c-text-on-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.search-suggestions a:hover,
.search-suggestions a:focus-visible {
    color: var(--c-text-on-light);
    background: var(--c-cream-100);
    text-decoration: none;
}

.search-suggestion__type,
.search-result__type {
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
}

.search-suggestions span:not(.search-suggestion__type),
.search-result span:not(.search-result__type) {
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-sm);
}

.search-suggestions--overlay {
    top: calc(100% + 10px);
    left: 56px;
    right: 16px;
    width: auto;
}

.search-page {
    display: grid;
    gap: var(--sp-5);
}

.search-page__form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--sp-3);
    align-items: end;
    padding: var(--sp-4);
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius);
}

.search-page__form label {
    display: grid;
    gap: var(--sp-2);
    margin: 0;
}

.search-page__form label > span {
    color: var(--c-text-on-light-muted);
    font-weight: var(--fw-semibold);
}

.search-page__form input {
    min-height: 44px;
}

.search-page__summary {
    margin: 0;
    color: var(--c-text-on-light-muted);
    font-weight: var(--fw-semibold);
}

.search-results {
    display: grid;
    gap: var(--sp-5);
}

.search-results__group {
    display: grid;
    gap: var(--sp-3);
}

.search-results__group h2 {
    margin: 0;
    font-size: var(--fs-lg);
}

.search-results__list {
    display: grid;
    gap: 1px;
    overflow: hidden;
    background: var(--c-cream-200);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius);
}

.search-result {
    display: grid;
    gap: 3px;
    padding: 12px 14px;
    color: var(--c-text-on-light);
    background: var(--c-paper);
    text-decoration: none;
}

.search-result:hover,
.search-result:focus-visible {
    color: var(--c-text-on-light);
    background: var(--c-cream-100);
    text-decoration: none;
}

@media (max-width: 767px) {
    .search-page__form {
        grid-template-columns: 1fr;
    }
}

.sidebar-box h2::before,
.activity-feed h2::before,
.task-strip h2::before {
    content: "\2726";
    margin-right: var(--sp-2);
    color: var(--c-gold-500);
    font-family: var(--font-sans);
    font-size: var(--fs-xs);
}

.sidebar-box a.is-active {
    color: var(--c-danger);
    font-weight: var(--fw-semibold);
}

.directory-tags-list {
    display: contents;
}

.directory-tags-toggle {
    display: none;
}

.dashboard-intro,
.empty-state,
.task-item span,
.activity-meta,
.note-help,
.record-hero span,
.record-details dt,
.form-grid label > span:first-child,
.comments-row > span,
.admin-form-grid label > span:first-child,
.admin-two-column-grid label > span:first-child,
.placeholder-panel p {
    color: var(--c-text-on-light-muted);
}

.empty-state {
    padding: var(--sp-8) var(--sp-4);
    font-family: var(--font-serif);
    font-style: italic;
    text-align: center;
}

.empty-state::before {
    content: "\2726";
    display: block;
    margin-bottom: var(--sp-2);
    color: var(--c-gold-500);
    font-family: var(--font-sans);
    font-size: var(--fs-lg);
    font-style: normal;
}

/* Tables */
.contact-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

.contact-table th {
    height: 38px;
    color: var(--c-text-link);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-snug);
    text-align: left;
}

.contact-table th,
.contact-table td {
    padding: 12px 14px;
    white-space: normal;
}

.contact-table td {
    min-height: 56px;
    color: var(--c-text-on-light);
    border-bottom: 1px solid var(--c-cream-200);
    font-size: var(--fs-base);
    vertical-align: middle;
}

.contact-table tbody tr {
    transition: background var(--t-fast), box-shadow var(--t-fast);
}

.contact-table tbody tr:nth-child(even) {
    background: var(--c-cream-50);
}

.contact-table tbody tr:hover,
.detail-list-row:hover,
.activity-row:hover {
    background: var(--c-cream-100);
    box-shadow: inset 2px 0 0 var(--c-gold-500);
}

.contact-table .crm-col {
    display: none;
}

@media (max-width: 767px) {
    .contact-table .crm-col--mobile {
        display: block;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .contact-table .crm-col--tablet {
        display: table-cell;
    }
}

@media (min-width: 1024px) {
    .contact-table .crm-col--desktop {
        display: table-cell;
    }
}

.contact-table td:empty::before,
.record-details dd:empty::before {
    content: "\2014";
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-sm);
    font-style: italic;
}

.clickable-row {
    cursor: pointer;
}

.sort-indicator,
[aria-sort="ascending"]::after,
[aria-sort="descending"]::after {
    margin-left: var(--sp-1);
    color: var(--c-gold-500);
    font-size: var(--fs-xs);
}

[aria-sort="ascending"]::after {
    content: "\25B2";
}

[aria-sort="descending"]::after {
    content: "\25BC";
}

/* Avatars */
.avatar-placeholder,
.company-avatar,
.record-avatar,
.record-avatar-image {
    display: inline-block;
    flex: 0 0 auto;
    background-color: var(--c-avatar-bg);
    border: 1px solid rgba(212, 175, 95, 0.45);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6);
}

.avatar-placeholder,
.company-avatar {
    width: 32px;
    height: 32px;
}

.avatar-placeholder,
.record-avatar {
    border-radius: 50%;
}

.company-avatar,
.company-record-avatar,
.record-avatar-image {
    border-radius: var(--radius-md);
}

.record-avatar,
.record-avatar-image {
    width: 56px;
    height: 56px;
}

.record-avatar--warning {
    background-color: var(--c-warning-bg);
    border-color: var(--c-warning);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.65), 0 0 0 2px rgba(201, 138, 31, 0.22);
}

/* Forms */
.contact-form {
    padding: var(--sp-5);
}

.form-panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5) 0;
}

.form-panel-actions--scope {
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-panel-action-buttons {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    margin-left: auto;
}

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

.scope-form-grid {
    display: grid;
    grid-template-columns: 12ch 20ch 10ch 25ch;
    gap: var(--sp-4);
    align-items: end;
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--c-cream-200);
}

.scope-form-grid label {
    display: grid;
    gap: var(--sp-1);
    min-width: 0;
}

.scope-form-grid label > span:first-child {
    font-weight: var(--fw-medium);
}

.scope-form-grid input,
.scope-form-grid select {
    width: 100%;
    min-width: 0;
}

.scope-form-grid input:disabled {
    color: var(--c-text-muted);
    background: var(--c-cream-100);
    cursor: not-allowed;
}

.scope-form-grid strong {
    color: var(--c-danger);
    font-weight: var(--fw-semibold);
}

.scope-form-grid--actions {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.form-grid label {
    display: grid;
    grid-template-columns: minmax(120px, 178px) minmax(150px, 1fr);
    align-items: center;
    gap: var(--sp-3);
}

.form-grid label > span:first-child,
.comments-row > span,
.admin-form-grid label > span:first-child,
.admin-two-column-grid label > span:first-child {
    padding-right: var(--sp-4);
    font-weight: var(--fw-medium);
    text-align: right;
}

.form-grid strong {
    color: var(--c-danger);
    font-weight: var(--fw-semibold);
}

input,
select,
textarea,
.form-grid input,
.form-grid select,
.comments-row textarea,
.admin-form-grid input[type="text"],
.admin-form-grid input[type="email"],
.admin-form-grid input[type="password"],
.admin-form-grid input[type="number"],
.admin-two-column-grid input,
.admin-two-column-grid textarea,
.auth-form input[type="email"],
.auth-form input[type="password"] {
    max-width: 100%;
    color: var(--c-text-on-light);
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-md);
    box-shadow: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

input:not([type="checkbox"]):not([type="radio"]),
select {
    min-height: 36px;
    padding: 7px 10px;
}

textarea,
.comments-row textarea {
    min-height: 128px;
    padding: 9px 10px;
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--c-gold-500);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus {
    border-color: var(--c-gold-500);
    outline: none;
    box-shadow: var(--shadow-focus);
}

input[type="checkbox"],
.form-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--c-wine-600);
}

.comments-row {
    display: grid;
    grid-template-columns: minmax(120px, 178px) 1fr;
    gap: var(--sp-3);
    align-items: start;
    margin-top: var(--sp-4);
}

.form-error {
    color: var(--c-danger);
    font-size: var(--fs-sm);
}

.tag-picker {
    min-width: 0;
}

.tag-picker-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--sp-2);
    min-width: 0;
}

.tag-picker-chips {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 36px;
    padding: 4px 0;
}

.tag-chip {
    min-height: 28px;
    padding: 4px 9px;
    color: var(--c-text-on-light);
    background: var(--c-cream-100);
    border: 1px solid var(--c-cream-300);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    line-height: 1.2;
}

.tag-chip-button {
    cursor: pointer;
}

.tag-chip-button:hover {
    color: var(--c-danger);
    border-color: var(--c-danger);
}

.tag-picker-menu {
    position: relative;
    flex: 0 0 min(300px, 100%);
    width: min(300px, 100%);
    display: flex;
    justify-content: flex-end;
}

.tag-picker-add {
    width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--c-wine-600);
    border: 1px solid var(--c-wine-600);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 21px;
    font-weight: var(--fw-semibold);
    line-height: 1;
    list-style: none;
}

.tag-picker-add::-webkit-details-marker {
    display: none;
}

.tag-picker-menu select {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    width: 100%;
    background: var(--c-paper);
    box-shadow: var(--shadow-md);
}

/* Buttons */
.primary-button,
.secondary-button,
.danger-button,
.compact-button,
.auth-form button[type="submit"],
.column-selector-actions button,
.link-button {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--sp-4);
    border-radius: var(--radius-md);
    font-weight: var(--fw-semibold);
    line-height: 1;
    text-decoration: none;
}

.primary-button,
.auth-form button[type="submit"],
.column-selector-actions button {
    color: #ffffff;
    background: var(--c-wine-600);
    border: 1px solid var(--c-wine-600);
    box-shadow: var(--shadow-sm);
    transition: background var(--t-base), border-color var(--t-base), transform var(--t-fast);
}

.primary-button:hover,
.auth-form button[type="submit"]:hover,
.column-selector-actions button:hover {
    color: #ffffff;
    background: var(--c-wine-700);
    border-color: var(--c-wine-700);
}

.primary-button:active,
.auth-form button[type="submit"]:active {
    transform: translateY(1px);
}

.secondary-button,
.link-button {
    color: var(--c-text-on-light);
    background: transparent;
    border: 1px solid var(--c-gold-500);
    box-shadow: none;
}

.secondary-button:hover,
.link-button:hover {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
}

.danger-button {
    color: #ffffff;
    background: var(--c-danger);
    border: 1px solid var(--c-danger);
}

.danger-button:hover {
    color: #ffffff;
    background: #922d2d;
}

/* Detail view */
.record-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 356px;
    gap: var(--sp-6);
    align-items: start;
}

.record-main {
    min-width: 0;
}

.record-sidebar {
    display: grid;
    gap: var(--sp-5);
    min-width: 0;
}

.record-tags-panel {
    overflow: visible;
}

.record-hero {
    min-height: 112px;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 14px;
    margin-bottom: var(--sp-5);
    border-left: 4px solid var(--c-gold-500);
}

.record-hero .record-avatar-image {
    width: 84px;
    height: 84px;
    object-fit: cover;
}

.record-hero-body {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 100%;
}

.record-hero-kicker {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
}

.record-hero-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-4);
    width: 100%;
}

.record-hero h1 {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
    width: 100%;
    min-width: 0;
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-normal);
    text-transform: none;
}

.record-hero-contact {
    display: grid;
    gap: var(--sp-1);
    margin-top: var(--sp-2);
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-sm);
}

.record-hero-phone {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.record-hero-contact .record-hero-icon-link {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-link);
    background: var(--c-paper);
    border: 1px solid var(--c-cream-300);
    border-radius: 50%;
    text-decoration: none;
}

.record-hero-contact .record-hero-icon-link svg {
    width: 14px;
    height: 14px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.record-hero-contact .record-hero-icon-link--whatsapp svg {
    fill: currentColor;
    stroke: none;
}

.record-hero-contact .record-hero-icon-link:hover,
.record-hero-contact .record-hero-icon-link:focus-visible {
    color: #ffffff;
    background: var(--c-text-link);
    text-decoration: none;
}

.record-hero-contact .record-hero-icon-link--whatsapp {
    color: #1f8f51;
}

.record-hero-contact .record-hero-icon-link--whatsapp:hover,
.record-hero-contact .record-hero-icon-link--whatsapp:focus-visible {
    background: #1f8f51;
}

.record-hero-contact a {
    color: var(--c-text-link);
    white-space: nowrap;
}

.mobile-name {
    display: none;
}

.lead-mobile-title-row {
    display: none;
}

@media (max-width: 767px) {
    .desktop-name {
        display: none;
    }

    .mobile-name {
        display: block;
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: bottom;
        white-space: nowrap;
    }

    .record-hero-title-row {
        display: grid;
        gap: var(--sp-1);
    }

    .record-hero h1 {
        overflow: hidden;
        white-space: nowrap;
    }

}

.record-tabs {
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4);
    overflow-x: auto;
    background: var(--c-navy-800);
    border-bottom: 1px solid var(--c-gold-500);
    border-radius: 8px 8px 0 0;
}

.record-tabs a {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--sp-3);
    color: var(--c-gold-400);
    background: transparent;
    border-radius: var(--radius-pill);
    font-weight: var(--fw-medium);
    white-space: nowrap;
}

.record-tabs .is-active {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
    box-shadow: none;
}

.record-actions {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-5);
    padding: var(--sp-5);
    border-bottom: 1px solid var(--c-cream-200);
}

.record-options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    color: var(--c-text-on-light-muted);
}

.inline-filter-form,
.inline-filter-form label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.record-feed,
.note-help,
.record-details dl,
.record-details footer,
.record-tags-body {
    padding: var(--sp-5);
}

.record-tags-panel header {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: 0 var(--sp-5);
    font-weight: var(--fw-semibold);
}

.record-tags-body {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.record-tag-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 3px 10px;
    background: var(--c-cream-100);
    border: 1px solid var(--c-cream-300);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
}

.record-tag-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.record-tag-menu summary {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--c-wine-600);
    border: 1px solid var(--c-wine-600);
    border-radius: 50%;
    cursor: pointer;
    font-weight: var(--fw-bold);
    line-height: 1;
}

.record-tag-menu {
    position: relative;
}

.record-tag-menu summary {
    list-style: none;
}

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

.record-tag-menu--remove summary {
    background: var(--c-danger);
    border-color: var(--c-danger);
}

.record-tag-menu form {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    right: 0;
    width: min(320px, calc(100vw - 32px));
    display: grid;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* Tags panel - Wenecja */
.record-tags-panel.tags-panel {
    width: 100%;
    max-width: 100%;
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 8px 24px rgba(10, 24, 56, 0.12), 0 0 0 1px rgba(212, 175, 95, 0.08);
}

.record-tags-panel .tags-head {
    min-height: 54px;
    padding: 0 12px;
    color: var(--c-gold-500);
    background: var(--c-navy-900);
    border-bottom: 1px solid var(--c-gold-500);
    border-radius: 8px 8px 0 0;
    position: relative;
}

.record-tags-panel .tags-head__scope,
.record-tags-panel .tags-head__right {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.record-tags-panel .tags-head__scope {
    flex: 1 1 auto;
    overflow: hidden;
}

.record-tags-panel .tags-head__right {
    flex: 0 0 auto;
}

.record-tags-panel .tags-scope-chip {
    min-height: 32px;
    min-width: 0;
    max-width: 104px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    overflow: hidden;
    color: var(--c-paper);
    border: 1px solid var(--c-gold-500);
    border-radius: 999px;
    font-size: 11px;
    font-weight: var(--fw-medium);
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-tags-panel .tags-head::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 12px;
    right: 12px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-gold-500), transparent);
}

.record-tags-panel .tags-head__title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--c-gold-500);
    font-size: 10px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.record-tags-panel .tags-head__title::before {
    content: "\2726";
    color: var(--c-gold-500);
    font-size: 9px;
}

.record-tags-panel .tags-head__actions {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.record-tags-panel .record-tag-menu {
    position: relative;
}

.record-tags-panel .record-tag-menu summary.tags-action {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    color: var(--c-gold-500);
    background: transparent;
    border: 1px solid var(--c-gold-500);
    border-radius: 50%;
    font-size: 13px;
    font-weight: var(--fw-bold);
    line-height: 1;
    transition: all 120ms ease-out;
}

.record-tags-panel .record-tag-menu summary.tags-action:hover,
.record-tags-panel .record-tag-menu[open] summary.tags-action__plus {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
    border-color: var(--c-gold-500);
    box-shadow: 0 0 0 2px rgba(212, 175, 95, 0.25);
}

.record-tags-panel .record-tag-menu[open] summary.tags-action__minus {
    color: var(--c-gold-500);
    background: var(--c-wine-600);
    border-color: var(--c-wine-600);
    box-shadow: 0 0 0 2px rgba(138, 39, 65, 0.3);
}

.record-tags-panel .tags-action__plus::before {
    content: "+";
}

.record-tags-panel .tags-action__minus::before {
    content: "\2212";
}

.record-tags-panel .tags-body {
    padding: 14px 16px 16px;
    background: var(--c-paper);
}

.record-tags-panel .tags-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 26px;
}

.record-tags-panel .record-tag-item.tag-chip {
    min-height: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    color: var(--c-text-on-light);
    background: rgba(212, 175, 95, 0.10);
    border: 1px solid var(--c-gold-500);
    border-radius: 999px;
    font-size: 12px;
    font-weight: var(--fw-medium);
    line-height: 1.5;
    letter-spacing: 0.01em;
}

.record-tags-panel .record-tag-item a {
    color: inherit;
    text-decoration: none;
}

.record-tags-panel .record-tag-item a:hover {
    color: var(--c-wine-600);
}

.record-tags-panel .record-tag-menu form.tags-form {
    width: min(320px, calc(100vw - 32px));
    padding: 0 16px 16px;
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(10, 24, 56, 0.16);
}

.record-tags-panel .tags-ornament {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0 10px;
}

.record-tags-panel .tags-ornament::before,
.record-tags-panel .tags-ornament::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-gold-500), transparent);
}

.record-tags-panel .tags-ornament__icon {
    color: var(--c-gold-500);
    font-size: 9px;
}

.record-tags-panel .tags-form__hint {
    margin-bottom: 8px;
    color: var(--c-text-on-light-muted);
    font-family: var(--font-serif);
    font-size: 11px;
    font-style: italic;
    text-align: center;
}

.record-tags-panel .tags-select {
    width: 100%;
    padding: 9px 32px 9px 12px;
    color: var(--c-text-on-light);
    background-color: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: var(--fw-medium);
    transition: all 120ms ease-out;
}

.record-tags-panel .tags-select:hover,
.record-tags-panel .tags-select:focus {
    border-color: var(--c-gold-500);
    outline: none;
    box-shadow: 0 0 0 3px rgba(212, 175, 95, 0.35);
}

.record-tags-panel .tags-confirm {
    min-height: 36px;
    width: 100%;
    margin-top: 8px;
    padding: 9px 16px;
    color: var(--c-text-on-light);
    background: transparent;
    border: 1px solid var(--c-gold-500);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transition: all 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.record-tags-panel .tags-confirm:hover {
    color: var(--c-navy-900);
    background: var(--c-gold-500);
}

.record-tags-panel .tags-confirm--remove:hover {
    color: var(--c-paper);
    background: var(--c-wine-600);
    border-color: var(--c-wine-600);
}

.admin-user-side-panels {
    display: grid;
    gap: 16px;
}

.admin-user-show-layout {
    display: grid;
    grid-template-columns: minmax(320px, 395px) minmax(320px, 380px);
    gap: 16px;
    align-items: start;
}

.admin-scope-panel.record-tags-panel.tags-panel {
    width: 100%;
}

.admin-scope-panel .record-tag-menu form.tags-form {
    right: 0;
}

@media (max-width: 760px) {
    .admin-user-show-layout {
        grid-template-columns: 1fr;
    }
}

.muted-text {
    color: var(--c-text-on-light-muted);
}

.record-details dl {
    display: grid;
    grid-template-columns: 108px 1fr;
    gap: var(--sp-3) var(--sp-4);
    margin: 0;
}

.record-details dt {
    padding-right: var(--sp-4);
    font-weight: var(--fw-medium);
    text-align: right;
}

.record-details dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.record-empty-fields {
    border-top: 1px solid var(--c-cream-200);
}

.record-empty-fields summary {
    min-height: 40px;
    display: flex;
    align-items: center;
    padding: 0 var(--sp-5);
    color: var(--c-text-link);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    list-style: none;
}

.record-empty-fields summary::-webkit-details-marker {
    display: none;
}

.record-empty-fields-hide,
.record-empty-fields[open] .record-empty-fields-show {
    display: none;
}

.record-empty-fields[open] .record-empty-fields-hide {
    display: inline;
}

.record-empty-fields dl {
    padding-top: 0;
}

.quality-warning-list {
    margin: var(--sp-2) 0 0;
    padding-left: var(--sp-4);
    color: var(--c-warning);
    font-size: var(--fs-sm);
    line-height: var(--lh-snug);
}

.quality-status {
    font-weight: var(--fw-semibold);
    text-transform: lowercase;
}

.quality-status--warning {
    color: var(--c-danger);
}

.quality-status--ok {
    color: var(--c-success);
}

.settings-columns-grid {
    display: grid;
    gap: var(--sp-5);
    padding: var(--sp-5);
}

.settings-columns-module {
    display: grid;
    gap: var(--sp-3);
    padding-bottom: var(--sp-5);
    border-bottom: 1px solid var(--c-cream-200);
}

.settings-columns-module:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.settings-columns-module h3 {
    margin: 0;
    color: var(--c-text-link);
    font-size: var(--fs-lg);
}

.settings-columns-breakpoints {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-4);
}

.settings-columns-fieldset {
    min-width: 0;
    margin: 0;
    padding: var(--sp-3);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-md);
}

.settings-columns-fieldset legend {
    padding: 0 var(--sp-1);
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
}

.settings-column-list {
    display: grid;
    gap: var(--sp-2);
}

.settings-column-list label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.admin-action-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    padding: var(--sp-5);
}

.admin-general-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5);
    border-bottom: 1px solid var(--c-cream-200);
}

.admin-general-form label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
}

.admin-general-language select {
    min-width: 84px;
}

.admin-entity-picker {
    border-bottom: 0;
}

.admin-tags-form {
    padding: 0 var(--sp-5) var(--sp-5);
}

.admin-tags-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.admin-tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-2);
}

.admin-tag-option {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-height: 38px;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-md);
    background: rgba(212, 175, 95, 0.06);
}

.admin-tag-option small {
    margin-left: auto;
    color: var(--c-text-on-light-muted);
    font-size: 11px;
}

.detail-list-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px 140px;
    gap: var(--sp-4);
    align-items: center;
    min-height: 42px;
    padding: var(--sp-2) var(--sp-3);
    border-radius: 0;
    border-right: 0;
    border-left: 0;
    border-top: 0;
}

/* Dashboard activity */
.task-list,
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-3);
}

.task-item {
    padding: var(--sp-3) var(--sp-4);
    display: block;
    color: var(--c-text-on-light);
    text-decoration: none;
}

.task-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--c-text-link);
}

.task-item strong a {
    color: inherit;
    text-decoration: none;
}

.task-item strong a:hover,
.task-item strong a:focus {
    color: var(--c-text-link-hover);
    text-decoration: underline;
}

.task-item:hover {
    background: var(--c-cream-100);
    box-shadow: inset 2px 0 0 var(--c-gold-500), var(--shadow-sm);
}

.dashboard-task-strip {
    margin-bottom: var(--sp-5);
}

.dashboard-task-strip h2 {
    margin: 0 0 var(--sp-3);
    color: var(--c-text-link);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
}

.activity-row {
    min-height: 48px;
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 150px;
    gap: var(--sp-4);
    align-items: center;
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
}

.activity-badge {
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--sp-3);
    color: var(--c-text-on-dark);
    background: var(--c-navy-700);
    border-radius: var(--radius-pill);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
}

.activity-badge-system {
    color: var(--c-text-on-light-muted);
    background: var(--c-cream-200);
    font-style: italic;
}

.activity-copy strong,
.activity-copy span,
.activity-meta span,
.activity-meta time {
    display: block;
}

.activity-copy strong a {
    color: var(--c-text-link);
    text-decoration: none;
}

.activity-copy strong a:hover,
.activity-copy strong a:focus {
    color: var(--c-text-link-hover);
    text-decoration: underline;
}

.activity-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* Admin and auth */
.auth-panel {
    width: min(100%, 360px);
    margin: var(--sp-8) auto 0;
}

.auth-panel h1 {
    margin-bottom: var(--sp-5);
    font-size: var(--fs-lg);
    text-align: center;
}

.auth-form {
    position: relative;
    display: grid;
    gap: var(--sp-4);
    padding: var(--sp-12) var(--sp-6) var(--sp-6);
}

.auth-form::before {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.auth-form label:not(.checkbox-row) {
    display: grid;
    gap: var(--sp-2);
    color: var(--c-text-on-light-muted);
}

.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form button[type="submit"] {
    width: 100%;
    margin: 0;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: 0;
    color: var(--c-text-on-light-muted);
}

.admin-heading {
    color: var(--c-text-link);
}

/* Pagination */
.pagination-wrap {
    margin-top: var(--sp-4);
}

.pagination-wrap nav {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    color: var(--c-text-on-light-muted);
    font-size: var(--fs-xs);
}

.pagination-wrap nav > div:first-child,
.pagination-wrap nav > div:last-child > div:first-child {
    display: none;
}

.pagination-wrap nav > div:last-child,
.pagination-wrap nav > div:last-child > div:last-child,
.pagination-wrap nav > div:last-child > div:last-child > span {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}

.pagination-wrap nav > div:last-child > div:last-child > span > a,
.pagination-wrap nav > div:last-child > div:last-child > span > span {
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--sp-2);
    color: var(--c-text-on-light);
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
    line-height: 1;
}

.pagination-wrap nav > div:last-child > div:last-child > span > [aria-current="page"] {
    color: #ffffff;
    background: var(--c-wine-600);
    border-color: var(--c-wine-600);
}

.pagination-wrap nav > div:last-child > div:last-child > span > span[aria-disabled="true"] {
    color: var(--c-text-on-light-muted);
    background: var(--c-cream-100);
}

.pagination-wrap svg {
    width: 12px;
    height: 12px;
    display: block;
}

/* Component hooks for the final spec */
.bulk-bar {
    position: fixed;
    left: 50%;
    bottom: var(--sp-5);
    z-index: var(--z-fab);
    display: none;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-5);
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
    border: 1px solid var(--c-gold-500);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}

.bulk-bar.is-visible {
    display: flex;
}

.filter-chip {
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-3);
    color: var(--c-text-on-light);
    background: var(--c-cream-100);
    border: 1px solid var(--c-cream-200);
    border-radius: var(--radius-pill);
    font-size: var(--fs-sm);
}

.skeleton {
    min-height: 14px;
    overflow: hidden;
    background: linear-gradient(90deg, var(--c-skeleton-base), var(--c-skeleton-highlight), var(--c-skeleton-base));
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.fab {
    position: fixed;
    right: var(--sp-5);
    bottom: var(--sp-5);
    z-index: var(--z-fab);
    width: 56px;
    height: 56px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: var(--c-wine-600);
    border: 1px solid var(--c-wine-700);
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
    font-size: 28px;
}

.bulk-active .fab {
    display: none;
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    display: none;
    background: rgba(10, 24, 56, 0.55);
}

.drawer-overlay.is-visible {
    display: block;
}

.nav-drawer,
.filter-drawer {
    position: fixed;
    top: 0;
    z-index: var(--z-drawer);
    height: 100dvh;
    overflow-y: auto;
    transition: transform var(--t-base);
}

.nav-drawer {
    left: 0;
    width: var(--drawer-w-nav);
    max-width: 85vw;
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
    transform: translateX(-100%);
}

.nav-drawer.is-open {
    transform: translateX(0);
}

.filter-drawer {
    right: 0;
    width: var(--drawer-w-filter);
    max-width: 85vw;
    padding: var(--sp-12) var(--sp-4) var(--sp-4);
    background: var(--c-cream-50);
    box-shadow: -4px 0 16px rgba(10, 24, 56, 0.15);
    transform: translateX(100%);
}

.filter-drawer.is-open {
    transform: translateX(0);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    background: rgba(10, 24, 56, 0.6);
    opacity: 0;
    transition: opacity var(--t-base);
}

.modal.is-open {
    display: flex;
    opacity: 1;
}

.modal__dialog {
    width: 100%;
    max-width: 480px;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--c-paper);
    border: 1px solid var(--c-gold-500);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal__header,
.modal__footer {
    padding: var(--sp-4) var(--sp-5);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    border-bottom: 1px solid var(--c-gold-500);
}

.modal__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-5);
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-3);
    background: var(--c-cream-50);
    border-top: 1px solid var(--c-cream-200);
}

.modal--danger .modal__header {
    border-bottom-color: var(--c-danger);
}

.modal--danger .modal__title::before {
    content: "\26A0 ";
    color: var(--c-danger);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 60;
    min-width: 200px;
    display: none;
    padding: 6px 0;
    background: var(--c-paper);
    border: 1px solid var(--c-gold-500);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.dropdown.is-open .dropdown__menu {
    display: block;
}

.dropdown__item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 8px 14px;
    color: var(--c-text-on-light);
    background: none;
    border: 0;
    font-size: var(--fs-sm);
    text-align: left;
}

.dropdown__item:hover {
    color: var(--c-text-link);
    background: var(--c-cream-100);
}

.dropdown__item--danger {
    color: var(--c-danger);
}

.dropdown__item--danger:hover {
    background: var(--c-danger-bg);
}

.toast-stack {
    position: fixed;
    right: var(--sp-5);
    bottom: var(--sp-5);
    z-index: var(--z-toast);
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    pointer-events: auto;
    background: var(--c-paper);
    border: 1px solid var(--c-cream-200);
    border-left: 4px solid var(--c-gold-500);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: toast-in var(--t-base) ease-out;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast--success { border-left-color: var(--c-success); }
.toast--danger { border-left-color: var(--c-danger); }
.toast--warning { border-left-color: var(--c-warning); }
.toast--info { border-left-color: var(--c-info); }

[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: var(--z-tooltip);
    padding: 4px 10px;
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: var(--fs-xs);
    white-space: nowrap;
    pointer-events: none;
    transform: translateX(-50%);
}

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: none;
    flex-direction: column;
    background: var(--c-navy-900);
}

.search-overlay.is-open {
    display: flex;
}

.search-overlay__header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--c-gold-500);
}

.search-overlay__back {
    width: 36px;
    height: 36px;
    padding: 0;
    overflow: hidden;
    color: var(--c-gold-500);
    background: transparent;
    border: 0;
    font-size: 0;
}

.search-overlay__back::before {
    content: "<";
    font-size: 22px;
    line-height: 1;
}

.search-overlay__input {
    flex: 1;
    color: var(--c-text-on-dark);
    background: transparent;
    border: 0;
    font-size: 18px;
}

.search-overlay__body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    color: var(--c-text-on-light);
    background: var(--c-cream-50);
}

.search-overlay__section-title {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin: var(--sp-4) 0 var(--sp-2);
    color: var(--c-text-on-light-muted);
    font-family: var(--font-serif);
    font-size: var(--fs-sm);
    font-style: italic;
}

.search-overlay__section-title::before {
    content: "\2726";
    color: var(--c-gold-500);
    font-family: var(--font-sans);
    font-size: 10px;
}

/* Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: 1000;
    padding: 8px 16px;
    color: var(--c-navy-900);
    background: var(--c-gold-500);
    font-weight: var(--fw-semibold);
}

.skip-link:focus {
    top: 0;
}

@media (max-width: 1279px) and (min-width: 1024px) {
    .app-header {
        padding: 0 var(--sp-5);
    }

    .global-search {
        max-width: 360px;
    }

    .directory-layout {
        grid-template-columns: var(--sidebar-w-laptop) minmax(0, 1fr);
        gap: var(--sp-5);
    }
}

@media (max-width: 1023px) {
    .app-header {
        padding: 0 var(--sp-4);
        gap: var(--sp-3);
    }

    .global-search {
        max-width: 280px;
    }

    .logout-form > span {
        display: none;
    }

    .directory-layout,
    .record-layout,
    .scope-form-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .directory-sidebar {
        display: grid;
        gap: var(--sp-3);
        order: -1;
    }

    .directory-sidebar .sidebar-box {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--sp-2);
        padding: var(--sp-3);
    }

    .directory-sidebar .sidebar-box h2 {
        flex: 0 0 auto;
        font-size: var(--fs-base);
    }

    .directory-sidebar .sidebar-box h2::before {
        content: none;
    }

    .directory-sidebar .sidebar-box a,
    .directory-sidebar .sidebar-box span {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
        padding: 6px 10px;
        background: var(--c-cream-50);
        border: 1px solid var(--c-cream-200);
        border-radius: var(--radius-sm);
    }

    .directory-tags-box {
        display: block;
    }

    .directory-tags-box h2 {
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        margin-right: var(--sp-2);
    }

    .directory-tags-box .directory-tags-list {
        display: block;
        flex-wrap: wrap;
        gap: var(--sp-2);
        max-height: 136px;
        overflow: hidden;
    }

    .directory-tags-box .directory-tags-list h2,
    .directory-tags-box .directory-tags-list a,
    .directory-tags-box .directory-tags-list span {
        margin: 0 var(--sp-2) var(--sp-2) 0;
        vertical-align: top;
    }

    .directory-tags-box.is-expanded .directory-tags-list {
        max-height: none;
        overflow: visible;
    }

    .directory-tags-toggle {
        width: 100%;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        margin-top: var(--sp-2);
        padding: 6px 10px;
        color: #8f6823;
        background: rgba(245, 236, 215, 0.28);
        border: 1px dashed rgba(200, 164, 93, 0.7);
        border-radius: var(--radius-sm);
        font-size: var(--fs-sm);
        font-weight: var(--fw-bold);
    }

    .directory-tags-toggle:hover,
    .directory-tags-toggle:focus {
        background: rgba(245, 236, 215, 0.55);
    }

    .record-main {
        order: -1;
    }

    .record-details {
        order: 0;
    }

    .activity-row {
        grid-template-columns: 1fr;
        gap: var(--sp-2);
    }

    .activity-meta {
        align-items: flex-start;
    }
}

@media (max-width: 1023px) and (min-width: 768px) {
    .app-header {
        min-height: var(--header-h);
        display: grid;
        grid-template-columns: 36px auto minmax(220px, 1fr) auto auto;
        align-items: center;
    }

    .mobile-menu-toggle {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        pointer-events: none;
    }

    .mobile-menu-button {
        width: 36px;
        height: 36px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        grid-column: 1;
        background: transparent;
        border: 1px solid var(--c-navy-700);
        border-radius: var(--radius-md);
    }

    .mobile-menu-button span {
        width: 18px;
        height: 2px;
        display: block;
        background: var(--c-gold-500);
        border-radius: var(--radius-pill);
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .app-brand {
        grid-column: 2;
    }

    .global-search {
        grid-column: 3;
        justify-self: end;
        width: min(340px, 100%);
        max-width: 340px;
        margin-left: auto;
    }

    .logout-form {
        grid-column: 4;
        height: auto;
        padding-left: 0;
        border-left: 0;
    }

    .locale-switcher {
        grid-column: 5;
    }

    .search-trigger {
        display: none;
    }

    .app-header .app-nav {
        position: absolute;
        top: 100%;
        bottom: auto;
        left: var(--sp-4);
        right: auto;
        width: 240px;
        height: auto;
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: var(--sp-2);
        background: var(--c-navy-900);
        border: 1px solid var(--c-gold-500);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
    }

    .mobile-menu-toggle:checked ~ .app-nav {
        display: flex;
    }

    .app-nav a {
        min-height: 44px;
        justify-content: flex-start;
        padding: 0 var(--sp-3);
        border-radius: var(--radius-sm);
    }

    .app-nav a.is-active::after {
        left: 0;
        top: 0;
        right: auto;
        bottom: 0;
        width: 3px;
        height: auto;
    }

    .activity-row {
        grid-template-columns: 110px minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        align-items: start;
    }

    .activity-badge {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    .activity-meta {
        grid-column: 3;
        grid-row: 1;
        flex-direction: row;
        gap: var(--sp-2);
        align-items: center;
        justify-self: end;
        white-space: nowrap;
    }

    .activity-copy {
        grid-column: 1 / -1;
        grid-row: 2;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--sp-4);
    }

    .activity-copy span {
        text-align: right;
    }
}

@media (max-width: 767px) {
    body {
        font-size: var(--fs-base);
    }

    .app-shell {
        padding-bottom: 0;
    }

    .app-header {
        min-height: var(--header-h-mobile);
        display: grid;
        grid-template-columns: 36px minmax(0, 1fr) 36px 86px;
        gap: var(--sp-2);
        padding: 0 var(--sp-3);
    }

    .mobile-menu-toggle {
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        pointer-events: none;
    }

    .mobile-menu-button {
        width: 36px;
        height: 36px;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        grid-column: 1;
        grid-row: 1;
        background: transparent;
        border: 1px solid var(--c-navy-700);
        border-radius: var(--radius-md);
        box-shadow: none;
    }

    .mobile-menu-button span {
        width: 18px;
        height: 2px;
        display: block;
        background: var(--c-gold-500);
        border-radius: var(--radius-pill);
        box-shadow: none;
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-toggle:checked + .mobile-menu-button span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .app-brand {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 18px;
        text-overflow: ellipsis;
    }

    .global-search {
        display: none;
    }

    .search-trigger {
        grid-column: 3;
        grid-row: 1;
        display: inline-flex;
    }

    .logout-form {
        display: none;
    }

    .locale-switcher {
        grid-column: 4;
        grid-row: 1;
        display: block;
        justify-self: end;
    }

    .logout-form button,
    .app-header > a[href$="login"] {
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        overflow: hidden;
        font-size: 0;
    }

    .logout-form button::before,
    .app-header > a[href$="login"]::before {
        content: "Log";
        font-size: 11px;
    }

    .app-header .app-nav {
        position: absolute;
        top: 100%;
        left: var(--sp-3);
        right: auto;
        grid-column: 1 / -1;
        display: none;
        width: min(240px, calc(100vw - 24px));
        height: auto;
        margin: 0;
        padding: var(--sp-2);
        background: var(--c-navy-900);
        border: 1px solid var(--c-gold-500);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
    }

    .mobile-menu-toggle:checked ~ .app-nav {
        display: flex;
        flex-direction: column;
        gap: var(--sp-2);
    }

    .app-nav a {
        min-height: 44px;
        justify-content: flex-start;
        padding: 0 var(--sp-3);
        color: var(--c-text-on-dark);
        background: rgba(10, 24, 56, 0.35);
        border: 1px solid var(--c-navy-700);
        border-radius: var(--radius-md);
        font-size: var(--fs-xs);
    }

    .app-nav a::before {
        content: "\2726";
        color: var(--c-gold-500);
        font-size: 9px;
    }

    .app-nav a.is-active {
        color: var(--c-gold-500);
        background: var(--c-navy-700);
    }

    .app-nav a.is-active::after {
        left: 0;
        top: 0;
        right: auto;
        bottom: 0;
        width: 3px;
        height: auto;
    }

    .sub-nav {
        min-height: 40px;
        gap: var(--sp-4);
        margin-top: 0;
        overflow-x: auto;
        padding: 0 var(--sp-4);
        -webkit-overflow-scrolling: touch;
    }

    .sub-nav::-webkit-scrollbar {
        display: none;
    }

    .app-main {
        width: calc(100% - 32px);
        margin: var(--sp-4) auto 96px;
    }

    .crm-panel,
    .placeholder-panel,
    .contact-form,
    .record-hero,
    .record-actions,
    .record-feed,
    .note-help,
    .record-details dl,
    .record-details footer {
        padding: var(--sp-4);
    }

    .contact-table,
    .contact-table thead,
    .contact-table tbody,
    .contact-table tr,
    .contact-table th,
    .contact-table td {
        display: block;
    }

    .contact-table {
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    .contact-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
    }

    .contact-table tbody {
        display: grid;
        gap: var(--sp-3);
    }

    .contact-table tbody tr {
        position: relative;
        display: grid;
        gap: var(--sp-2);
        padding: var(--sp-4);
        background: var(--c-paper);
        border: 1px solid var(--c-cream-200);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }

    .contact-table tbody tr:hover {
        box-shadow: inset 2px 0 0 var(--c-gold-500), var(--shadow-sm);
    }

    .contact-table td {
        min-height: 0;
        padding: 0;
        border-bottom: 0;
        font-size: var(--fs-sm);
        white-space: normal;
    }

    .contact-table td:first-child {
        display: flex;
        align-items: center;
        gap: var(--sp-3);
        padding-bottom: var(--sp-2);
        border-bottom: 1px solid var(--c-cream-200);
        font-size: var(--fs-base);
        font-weight: var(--fw-semibold);
    }

    .contact-table--mobile-smart-title tbody tr {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: var(--sp-4);
        row-gap: var(--sp-2);
    }

    .contact-table--mobile-smart-title .lead-avatar-cell,
    .contact-table--mobile-smart-title .crm-col {
        display: none;
    }

    .contact-table--mobile-smart-title .lead-mobile-col {
        display: block;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .contact-table--mobile-smart-title .lead-mobile-title-row {
        grid-column: 1 / -1;
        order: 1;
        display: flex;
        align-items: baseline;
        gap: var(--sp-3);
        min-width: 0;
        padding-bottom: var(--sp-1);
    }

    .lead-mobile-title-row a {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .lead-mobile-title-name {
        flex: 0 1 auto;
        font-size: var(--fs-base);
        font-weight: var(--fw-semibold);
    }

    .lead-mobile-title-company {
        flex: 0 1 auto;
        margin-left: auto;
        text-align: right;
    }

    .lead-mobile-title-row--balanced .lead-mobile-title-name,
    .lead-mobile-title-row--balanced .lead-mobile-title-company {
        flex: 1 1 0;
        max-width: 50%;
    }

    .lead-mobile-title-row--name-only .lead-mobile-title-name {
        flex: 1 1 auto;
        max-width: 100%;
    }

    .search-results-table.lead-table td:first-child:not(.lead-mobile-title-row) {
        display: block;
        padding-bottom: 0;
        border-bottom: 0;
    }

    .contact-table--mobile-smart-title .lead-mobile-name {
        order: 1;
        display: none;
        min-width: 0;
        font-size: var(--fs-base);
        font-weight: var(--fw-semibold);
    }

    .contact-table--mobile-smart-title .lead-mobile-name a {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .contact-table--mobile-smart-title .lead-mobile-company {
        order: 2;
        display: none;
        text-align: right;
    }

    .contact-table--mobile-smart-title .lead-mobile-phone {
        order: 3;
    }

    .contact-table--mobile-smart-title .lead-mobile-email {
        order: 4;
        text-align: right;
    }

    .contact-table--mobile-smart-title .lead-mobile-lead_status {
        order: 5;
    }

    .contact-table--mobile-smart-title .lead-mobile-assignee {
        order: 6;
        text-align: right;
    }

    .form-grid label,
    .comments-row,
    .admin-form-grid label,
    .admin-two-column-grid label {
        display: grid;
        grid-template-columns: 1fr;
        gap: var(--sp-1);
    }

    .form-grid label > span:first-child,
    .comments-row > span,
    .admin-form-grid label > span:first-child,
    .admin-two-column-grid label > span:first-child,
    .record-details dt {
        padding-right: 0;
        text-align: left;
    }

    .settings-columns-breakpoints {
        grid-template-columns: 1fr;
    }

    .record-details dl {
        grid-template-columns: 1fr;
        gap: var(--sp-1);
    }

    .record-actions {
        display: grid;
        gap: var(--sp-3);
    }

    .dashboard-task-strip .task-list {
        grid-template-columns: 1fr;
    }

    .dashboard-task-strip .task-item {
        padding: var(--sp-3);
    }

    .dashboard-task-strip .task-item strong {
        margin-bottom: 0;
    }

    .dashboard-task-strip .task-item span {
        display: none;
    }

    .activity-feed .activity-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        gap: var(--sp-2) var(--sp-3);
        align-items: start;
        padding: var(--sp-3);
    }

    .activity-feed .activity-badge {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
        min-height: 24px;
        padding: 0 var(--sp-2);
        font-size: var(--fs-xs);
    }

    .activity-feed .activity-meta {
        grid-column: 2 / 4;
        grid-row: 1;
        display: flex;
        flex-direction: row;
        gap: var(--sp-2);
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
        font-size: var(--fs-xs);
        white-space: nowrap;
    }

    .activity-feed .activity-meta span {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .activity-feed .activity-copy {
        grid-column: 1 / 4;
        grid-row: 2;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: var(--sp-3);
        align-items: center;
        min-width: 0;
    }

    .activity-feed .activity-copy strong {
        min-width: 0;
        overflow: hidden;
        color: var(--c-text-on-light);
        font-size: var(--fs-sm);
        font-weight: var(--fw-semibold);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .activity-feed .activity-copy span {
        min-width: 0;
        overflow: hidden;
        color: var(--c-text-link);
        font-size: var(--fs-sm);
        text-align: right;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .primary-button,
    .auth-form button[type="submit"] {
        width: 100%;
        min-height: 48px;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .toast-stack {
        left: var(--sp-4);
        right: var(--sp-4);
        bottom: 80px;
        max-width: none;
    }

    .modal {
        align-items: flex-end;
        padding: 0;
    }

    .modal__dialog {
        max-width: 100%;
        max-height: 90dvh;
        border-bottom: 0;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    }

    .fab {
        right: var(--sp-4);
        bottom: var(--sp-4);
    }

    .mobile-nav {
        display: none;
    }
}

.app-header .global-search label > input[type="search"] {
    padding-left: 76px !important;
}

.app-header .locale-switcher select {
    width: 72px;
    min-width: 72px;
    min-height: 34px;
    padding: 0 24px 0 26px;
    color: var(--c-text-on-dark);
    background: var(--c-navy-900);
    border-color: var(--c-gold-500);
}

.app-header .locale-switcher label::before {
    left: 9px;
    font-size: 11px;
}

.app-header .locale-switcher label::after {
    right: 9px;
}

@media (min-width: 768px) and (max-width: 1024px) {
    .app-header .global-search {
        display: block;
        min-width: 220px;
    }

    .app-header .search-trigger {
        display: none;
    }
}

@media (pointer: coarse) {
    [data-tooltip]:hover::after,
    [data-tooltip]:hover::before {
        display: none;
    }
}

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

/* Hamburger nav drawer */
.topbar__hamburger {
    width: 36px;
    height: 36px;
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    order: 0;
    color: var(--c-gold-500);
    background: transparent;
    border: 1px solid var(--c-navy-700);
    border-radius: var(--radius-md);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.topbar__hamburger:hover {
    background: var(--c-navy-800);
    border-color: var(--c-gold-500);
}

.topbar__hamburger:active {
    background: var(--c-navy-700);
}

.topbar__hamburger:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.drawer-overlay {
    display: block;
    background: rgba(10, 24, 56, 0.6);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--t-base), visibility var(--t-base);
}

.drawer-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.nav-drawer {
    width: var(--drawer-w-nav);
    max-width: 85vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--c-navy-900);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform var(--t-base);
}

.nav-drawer.is-open {
    transform: translateX(0);
}

@supports (padding: env(safe-area-inset-top)) {
    .nav-drawer {
        padding-top: env(safe-area-inset-top);
    }
}

.nav-drawer__header {
    flex: 0 0 auto;
    padding: 20px;
    border-bottom: 1px solid var(--c-gold-500);
}

.nav-drawer__brand {
    display: block;
    color: #ffffff;
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: var(--fw-bold);
    letter-spacing: var(--ls-wide);
    line-height: 1;
    text-decoration: none;
}

.nav-drawer__brand .accent {
    margin-left: 6px;
    color: var(--c-gold-500);
}

.nav-drawer__user {
    margin-top: 14px;
    color: var(--c-text-on-dark);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
}

.nav-drawer__user-meta {
    margin-top: 2px;
    color: var(--c-text-on-dark-muted);
    font-size: var(--fs-xs);
    letter-spacing: 0.04em;
}

.nav-drawer__items {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
}

.nav-drawer__item {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 20px;
    color: var(--c-text-on-dark);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--c-navy-700);
    border-radius: 0;
    box-shadow: none;
    font-family: var(--font-sans);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    letter-spacing: var(--ls-wide);
    line-height: 1.2;
    text-align: left;
    text-decoration: none;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

.nav-drawer__item-icon {
    flex: 0 0 auto;
    opacity: 0.65;
    transition: opacity var(--t-fast), color var(--t-fast);
}

.nav-drawer__item:hover {
    color: var(--c-text-on-dark);
    background: var(--c-navy-800);
    text-decoration: none;
}

.nav-drawer__item:hover .nav-drawer__item-icon {
    opacity: 0.85;
}

.nav-drawer__item:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px rgba(212, 175, 95, 0.4);
}

.nav-drawer__item.is-active {
    padding-left: 17px;
    color: var(--c-gold-500);
    background: var(--c-navy-700);
    border-left: 3px solid var(--c-gold-500);
}

.nav-drawer__item.is-active .nav-drawer__item-icon {
    opacity: 1;
}

.nav-drawer__logout {
    margin: auto 0 0;
}

.nav-drawer__item--logout {
    border-top: 1px solid var(--c-navy-700);
    border-bottom: 0;
}

.nav-drawer__item--logout .nav-drawer__item-icon {
    color: var(--c-wine-600);
    opacity: 0.85;
}

.nav-drawer__item--logout:hover {
    color: var(--c-wine-600);
    background: rgba(138, 39, 65, 0.15);
}

.nav-drawer__item--logout:hover .nav-drawer__item-icon {
    opacity: 1;
}

body.body--locked {
    overflow: hidden;
}

@supports (-webkit-touch-callout: none) {
    body.body--locked {
        position: fixed;
        width: 100%;
    }
}

@media (max-width: 1023px) {
    .topbar__hamburger {
        display: inline-flex;
    }

    .app-header .app-nav {
        display: none !important;
    }

    .sub-nav {
        margin-top: 0 !important;
    }
}

@media (max-width: 1023px) and (min-width: 768px) {
    .topbar__hamburger {
        grid-column: 1;
    }
}

@media (max-width: 767px) {
    .topbar__hamburger {
        grid-column: 1;
        grid-row: 1;
    }
}

/* Zadania: tytul bywa dlugi - na mobile ma sie zawijac, nie ucinac.
   Nadpisuje mobilna regule .record-hero h1 { white-space: nowrap }. */
.task-detail-layout .record-hero h1 {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
}

.task-table td strong {
    overflow-wrap: anywhere;
}
