:root {
    --font-ui: "Sora", sans-serif;
    --font-display: "Cormorant Garamond", serif;
    --font-mono: "IBM Plex Mono", monospace;
    --sidebar-width: 240px;
    --header-height: 64px;
    --content-width: 1200px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 2.75rem;
    --radius-sm: 0.75rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    --accent: #c48a33;
    --accent-strong: #8a5920;
    --accent-soft: rgba(196, 138, 51, 0.14);
    --accent-border: rgba(196, 138, 51, 0.24);
    --success: #1f8d61;
    --warning: #c1811f;
    --danger: #c74e39;
    --info: #3c74c5;
    --bg-main: #f4efe7;
    --bg-alt: #efe5d7;
    --sidebar-bg: rgba(255, 251, 246, 0.84);
    --header-bg: rgba(255, 250, 244, 0.8);
    --card-bg: rgb(255, 255, 255);
    --surface: rgba(255, 255, 255, 0.48);
    --border: rgba(16, 32, 51, 0.1);
    --border-strong: rgba(16, 32, 51, 0.14);
    --text-main: #132033;
    --text-muted: #5f6f84;
    --text-soft: #7b8a9b;
    --shadow-sm: 0 12px 24px rgba(11, 19, 32, 0.08);
    --shadow-md: 0 24px 60px rgba(11, 19, 32, 0.14);
    --transition-fast: 0.18s ease;
    --transition-base: 0.28s ease;
    --transition-slow: 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

body.theme-dark {
    --bg-main: #0f1725;
    --bg-alt: #152136;
    --sidebar-bg: rgba(13, 21, 33, 0.92);
    --header-bg: rgba(11, 18, 30, 0.84);
    --card-bg: rgb(18, 27, 41);
    --surface: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text-main: #f5f1eb;
    --text-muted: #b4c0cf;
    --text-soft: #8d9bb1;
    --shadow-sm: 0 16px 36px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 28px 70px rgba(0, 0, 0, 0.32);
}

body.theme-dark .popover {
    --bs-popover-bg: var(--card-bg);
    --bs-popover-body-color: var(--text-muted);
    --bs-popover-color: var(--text-muted);
    --bs-popover-header-bg: var(--header-bg);
    --bs-popover-header-color: var(--text-main);
    --bs-popover-border-color: var(--border-strong);
}

body.theme-dark .popover .popover-header {
    background-color: var(--bs-popover-header-bg);
    color: var(--bs-popover-header-color);
}

body.theme-dark .popover .popover-body {
    color: var(--bs-popover-body-color);
}

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

.popover {
    max-width: 480px;
}

html {
    min-height: 100%;
    font-size: 13px;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-ui);
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, rgba(196, 138, 51, 0.12), transparent 30%),
        radial-gradient(circle at 85% 12%, rgba(60, 116, 197, 0.08), transparent 28%),
        linear-gradient(135deg, var(--bg-main), var(--bg-alt));
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(196, 138, 51, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(196, 138, 51, 0.05) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(circle at center, black 28%, transparent 88%);
}

a {
    color: inherit;
    text-decoration: none;
}

#page-loader {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: linear-gradient(135deg, rgba(19, 32, 51, 0.96), rgba(9, 14, 22, 0.98));
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

#page-loader::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84px;
    height: 84px;
    margin: -42px 0 0 -42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-top-color: rgba(196, 138, 51, 0.9);
    animation: sr-spin 1s linear infinite;
}

#page-loader.loaded {
    opacity: 0;
    visibility: hidden;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: rgba(10, 15, 24, 0.48);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

#sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1050;
    width: var(--sidebar-width);
    padding: var(--space-5);
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    transition: transform var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.sidebar-brand-panel,
.sidebar-profile-card,
.theme-switch-btn,
.page-hero,
.page-surface,
.data-table-card,
.form-shell,
.detail-card,
.metric-card,
.feature-card,
.confirm-card,
.empty-state,
.info-panel,
.timeline-card,
.card {
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.sidebar-brand-panel,
.sidebar-profile-card,
.theme-switch-btn,
.page-surface,
.data-table-card,
.form-shell,
.detail-card,
.info-panel,
.timeline-card,
.card {
    padding: clamp(1.1rem, 1.8vw, 1.6rem);
}

.sidebar-brand-panel {
    background: linear-gradient(145deg, rgba(196, 138, 51, 0.14), transparent), var(--card-bg);
}

.sidebar-brand-link,
.header-meta,
.header-tools,
.header-profile,
.sidebar-profile-card,
.page-actions,
.feature-card__actions,
.form-actions,
.table-user,
.quick-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-brand-mark,
.sidebar-profile-avatar,
.header-profile__avatar,
.avatar-circle,
.metric-card__icon,
.feature-card__icon,
.empty-state__icon,
.detail-hero__avatar,
.confirm-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff7ef;
    box-shadow: 0 12px 24px rgba(138, 89, 32, 0.22);
}

.sidebar-brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
}

.sidebar-brand-text,
.page-title,
.sr-title,
.feature-card__title,
.detail-card__title,
.detail-hero__title,
.confirm-card__title,
.header-title {
    font-family: var(--font-display);
}

.sidebar-brand-text {
    display: block;
    font-size: 2rem;
    line-height: 1;
}

.sidebar-brand-sub,
.sidebar-section-label,
.page-kicker,
.header-kicker,
.detail-row__label,
.metric-label {
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.18em;
}

.sidebar-brand-sub {
    display: block;
    font-size: 0.78rem;
    margin-top: var(--space-2);
}

.sidebar-section-label,
.page-kicker,
.header-kicker,
.detail-row__label,
.metric-label {
    font-size: 0.74rem;
    font-weight: 700;
}

.sidebar-nav,
.metric-grid,
.page-grid,
.feature-grid,
.detail-grid,
.detail-stack,
.detail-list,
.form-shell,
.timeline,
.selection-grid,
.quick-links {
    display: grid;
    gap: var(--space-4);
}

.sidebar-nav {
    gap: var(--space-2);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: transform var(--transition-fast), background var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}

.sidebar-link:hover,
.sidebar-link.active {
    color: var(--text-main);
    transform: translateX(4px);
    background: linear-gradient(135deg, rgba(196, 138, 51, 0.16), transparent);
    border-color: var(--accent-border);
}

.metric-card__icon,
.feature-card__icon,
.empty-state__icon {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    background: rgba(196, 138, 51, 0.14);
    color: var(--accent);
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-link-icon {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.6rem;
    background: rgba(196, 138, 51, 0.14);
    color: var(--accent);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-profile-avatar,
.header-profile__avatar,
.avatar-circle {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 1rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
}

.theme-switch-btn {
    justify-content: center;
    transition: transform var(--transition-fast), border-color var(--transition-base), background var(--transition-base);
    color: var(--text-main);
}

.quick-link {
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    transition: transform var(--transition-fast), border-color var(--transition-base), background var(--transition-base);
}

.theme-switch-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
}

.quick-link:hover {
    transform: translateY(-2px);
    border-color: var(--accent-border);
    background: rgba(196, 138, 51, 0.08);
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

.app-layout.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%);
}

.app-layout.sidebar-collapsed .app-content {
    margin-left: 0;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 900;
    min-height: var(--header-height);
    padding: 0 var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    background: var(--header-bg);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--border);
}

.header-title {
    font-size: 1.5rem;
    line-height: 1;
}

.header-profile,
.header-chip {
    padding: 0.5rem 0.8rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.header-chip {
    display: grid;
    gap: 0.1rem;
}

.header-chip__label {
    color: var(--text-soft);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.header-chip__value,
.font-monospace,
.table-code,
.entity-code {
    font-family: var(--font-mono);
}

.header-chip__value {
    font-size: 0.82rem;
}

.header-profile__body {
    display: grid;
    gap: 0.12rem;
}

.header-profile__body span,
.sidebar-profile-meta,
.table-user__meta,
.metric-meta,
.page-subtitle,
.feature-card__text,
.detail-card__subtitle,
.detail-hero__meta,
.toolbar-meta,
.empty-state__text,
.confirm-card__text,
.timeline-item__text,
.dynamic-field-help,
.text-muted {
    color: var(--text-muted) !important;
}

.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
}

.main-container {
    flex: 1 1 auto;
    padding: var(--space-6);
}

.page-shell {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    animation: page-enter 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.footer {
    padding: 0 var(--space-6) var(--space-6);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    color: var(--text-soft);
    font-size: 0.8rem;
}

.footer-copy {
    color: var(--text-main);
    font-weight: 600;
}

.page-hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-5);
    padding: clamp(1.4rem, 2vw, 2rem);
    margin-bottom: var(--space-5);
    background: linear-gradient(135deg, rgba(196, 138, 51, 0.16), transparent), var(--card-bg);
    border-color: var(--accent-border);
    position: relative;
    overflow: hidden;
}

.page-hero__content,
.page-hero__aside {
    position: relative;
    z-index: 1;
}

.page-hero__aside {
    max-width: 360px;
}

.page-hero::after {
    content: "";
    position: absolute;
    right: -32px;
    bottom: -32px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(196, 138, 51, 0.22), transparent 70%);
}

.page-hero__content,
.page-hero__aside {
    position: relative;
    z-index: 1;
}

.page-title,
.sr-title {
    margin: 0;
    font-size: clamp(2.25rem, 4vw, 3.6rem);
    line-height: 0.95;
}

.sr-title.small,
.page-title--sm,
.detail-card__title,
.feature-card__title {
    font-size: 1.65rem;
    line-height: 1.02;
}

.page-subtitle {
    max-width: 760px;
    margin-top: 0.85rem;
    line-height: 1.75;
}

.page-grid--sidebar {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.9fr);
}

.toolbar-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(196, 138, 51, 0.12);
    color: var(--accent-strong);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.theme-dark .toolbar-chip {
    color: #efc16f;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: var(--space-5);
}

.metric-card,
.feature-card {
    padding: 1.25rem;
    display: grid;
    gap: var(--space-3);
}

.metric-card__head,
.detail-card__header,
.table-toolbar,
.filter-toolbar,
.form-section__header,
.info-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
}

.metric-value {
    font-family: var(--font-display);
    font-size: clamp(2rem, 3vw, 2.8rem);
    line-height: 0.95;
}

.metric-bar {
    height: 0.45rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
}

.metric-bar>span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #efc16f);
}

.metric-bar--78>span {
    width: 78%;
}

.metric-bar--64>span {
    width: 64%;
}

.metric-bar--72>span {
    width: 72%;
}

.metric-bar--58>span {
    width: 58%;
}

.table-toolbar,
.filter-toolbar,
.page-actions,
.form-actions {
    flex-wrap: wrap;
}

.form-section {
    padding: clamp(1.1rem, 1.7vw, 1.55rem);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);
}

.form-section__title,
.detail-card__title {
    margin: 0;
}

.form-section__text,
.detail-card__subtitle {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    line-height: 1.7;
}

.form-label,
label {
    color: var(--text-main);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.65rem;
}

.field-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.form-control,
.form-select {
    min-height: 3.1rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    border: 1px solid var(--border-strong);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

textarea.form-control {
    min-height: 7rem;
    resize: vertical;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.25rem rgba(196, 138, 51, 0.14);
}

.form-check-input {
    width: 2.8rem;
    height: 1.5rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background-color: rgba(255, 255, 255, 0.1);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn {
    position: relative;
    overflow: hidden;
    border-radius: 999px;
    padding: 0.78rem 1.15rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1;
    transform: translateZ(0);
    transition: transform var(--transition-fast), box-shadow var(--transition-base), background var(--transition-base), border-color var(--transition-base);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary,
.btn-gold,
.bg-gold {
    color: #fffaf2;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 12px 24px rgba(138, 89, 32, 0.2);
}

.btn-primary:hover,
.btn-gold:hover {
    color: #fffaf2;
}

.btn-outline-gold,
.text-gold {
    color: var(--accent-strong);
    border-color: rgba(196, 138, 51, 0.28);
    background: rgba(196, 138, 51, 0.08);
}

.theme-dark .btn-outline-gold,
.theme-dark .text-gold {
    color: #efc16f;
}

.btn-outline-gold:hover {
    color: #fffaf2;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.btn-outline-secondary {
    color: var(--text-main);
    border-color: var(--border-strong);
    background: rgba(255, 255, 255, 0.03);
}

.btn-outline-secondary:hover {
    color: var(--text-main);
    border-color: var(--accent-border);
    background: rgba(196, 138, 51, 0.08);
}

.btn-danger {
    border-color: transparent;
    background: linear-gradient(135deg, var(--danger), #9a3728);
}

.btn-sm {
    padding: 0.55rem 0.9rem;
    font-size: 0.82rem;
}

.table-actions-col {
    width: 1%;
    white-space: nowrap;
}

.table-actions-inline {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: nowrap;
    white-space: nowrap;
}

.table-actions-inline .btn {
    flex: 0 0 auto;
}

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

.detail-hero__avatar {
    width: 5rem;
    height: 5rem;
    border-radius: 1.6rem;
    font-size: 1.8rem;
}

.detail-row {
    display: grid;
    gap: 0.3rem;
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.detail-row__value,
.table-user__title {
    font-weight: 600;
}

.table thead th {
    padding: 1rem;
    color: var(--text-soft);
    border-bottom-color: var(--border);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    font-weight: 700;
}

.table tbody td {
    padding: 1rem;
    color: var(--text-main);
    border-bottom-color: var(--border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition-base);
}

.table tbody tr:hover {
    background: rgba(196, 138, 51, 0.08);
}

.table-code,
.entity-code {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    background: rgba(196, 138, 51, 0.14);
    color: var(--accent-strong);
    border: 1px solid rgba(196, 138, 51, 0.2);
    font-size: 0.78rem;
}

.theme-dark .table-code,
.theme-dark .entity-code {
    color: #efc16f;
}

.status-pill,
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: 999px;
    padding: 0.45rem 0.72rem;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.status-pill--accent {
    background: rgba(196, 138, 51, 0.14);
    color: var(--accent-strong);
}

.status-pill--success {
    background: rgba(31, 141, 97, 0.14);
    color: var(--success);
}

.status-pill--warning {
    background: rgba(193, 129, 31, 0.14);
    color: var(--warning);
}

.status-pill--danger {
    background: rgba(199, 78, 57, 0.14);
    color: var(--danger);
}

.status-pill--neutral {
    background: rgba(95, 111, 132, 0.15);
    color: var(--text-muted);
}

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

.selection-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.empty-state,
.confirm-card {
    text-align: center;
    padding: clamp(2rem, 4vw, 3rem);
}

.empty-state__title,
.confirm-card__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.85rem, 3vw, 2.5rem);
    line-height: 1;
}

.empty-state__text,
.confirm-card__text {
    margin: 1rem auto 0;
    max-width: 560px;
    color: var(--text-muted);
    line-height: 1.8;
}

.confirm-shell {
    display: flex;
    justify-content: center;
}

.empty-state__icon,
.confirm-card__icon {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 1.5rem;
    margin-inline: auto;
    font-size: 1.8rem;
}

.timeline-item {
    padding: 1rem 1rem 1rem 1.35rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 1rem;
    left: 0.75rem;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-item__meta {
    color: var(--text-soft);
    font-size: 0.78rem;
}

.alert,
.dynamic-structure-alert {
    border-radius: var(--radius-md);
    padding: 1rem 1.1rem;
    border: 1px solid transparent;
}

.alert-warning,
.alert-soft-warning {
    color: var(--warning);
    background: rgba(193, 129, 31, 0.12);
    border-color: rgba(193, 129, 31, 0.16);
}

.alert-danger,
.alert-soft-danger {
    color: var(--danger);
    background: rgba(199, 78, 57, 0.12);
    border-color: rgba(199, 78, 57, 0.16);
}

.text-danger {
    color: var(--danger) !important;
}

.text-success {
    color: var(--success) !important;
}

.text-warning {
    color: var(--warning) !important;
}

.text-navy {
    color: #12233a !important;
}

.sr-gold,
.sr-gold-light {
    color: var(--accent) !important;
}

.font-cinzel {
    font-family: var(--font-display);
}

.letter-spacing-1 {
    letter-spacing: 0.1em;
}

.letter-spacing-2 {
    letter-spacing: 0.2em;
}

.border-gold,
.border-gold-dim {
    border-color: rgba(196, 138, 51, 0.22) !important;
}

.dynamic-field-shell,
.dynamic-structure-header,
.field-help-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}

.dynamic-field-shell--emphasis {
    border-color: rgba(196, 138, 51, 0.28);
    background: linear-gradient(135deg, rgba(196, 138, 51, 0.12), rgba(255, 255, 255, 0.02));
}

.dynamic-structure-header {
    border-left: 3px solid rgba(196, 138, 51, 0.5);
}

.dynamic-structure-divider {
    border-color: rgba(196, 138, 51, 0.22);
    opacity: 1;
    margin: 0.75rem 0;
}

.admin-field-help {
    background: linear-gradient(135deg, rgba(196, 138, 51, 0.16), transparent), var(--card-bg);
}

.field-help-list {
    margin: 0;
    padding-left: 1rem;
    display: grid;
    gap: 0.6rem;
}

.field-help-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.field-help-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(196, 138, 51, 0.12);
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 600;
}

.field-help-trigger {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 999px;
    border: 1px solid rgba(196, 138, 51, 0.24);
    background: rgba(196, 138, 51, 0.1);
    color: var(--accent-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Allow field-help-trigger to grow when it's also a standard button with text */
.btn.field-help-trigger {
    width: auto;
    height: auto;
    padding: 0.75rem 1.25rem;
}

.popover.sr-help-popover {
    border-radius: 1rem;
    border: 1px solid var(--accent-border);
    background: var(--card-bg);
    box-shadow: var(--shadow-md);
}

.popover.sr-help-popover .popover-header {
    background: transparent;
    border-bottom-color: var(--border);
}

.text-preline {
    white-space: pre-line;
}

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

.page-link {
    border-radius: 999px !important;
    border-color: var(--border-strong);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.page-item.active .page-link {
    color: #fffaf2;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.page-item.disabled .page-link {
    color: var(--text-soft);
}

.validation-summary-errors ul {
    margin-bottom: 0;
    padding-left: 1rem;
}

#sr-toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 2200;
    display: grid;
    gap: var(--space-3);
}

.sr-toast {
    min-width: 280px;
    max-width: 360px;
    padding: 0.95rem 1rem;
    border-radius: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sr-toast--out {
    animation: toast-out 0.3s ease forwards;
}

.header-theme-toggle {
    width: 2.4rem;
    height: 2.4rem;
}

.stagger-item {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.46s ease, transform 0.46s ease;
    transition-delay: calc(var(--stagger-i, 0) * 60ms);
}

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

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes sr-ripple-anim {
    to {
        transform: scale(1);
        opacity: 0;
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-12px);
    }
}

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

    .page-grid--sidebar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1199.98px) {

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

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-content {
        margin-left: 0;
    }

    .hamburger-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .app-header {
        padding: 0 var(--space-4);
    }

    .main-container,
    .footer {
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }

    .page-hero,
    .table-toolbar,
    .filter-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-chip,
    .header-profile {
        display: none;
    }
}

@media (max-width: 767.98px) {

    .metric-grid,
    .feature-grid,
    .selection-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .page-title,
    .sr-title {
        font-size: clamp(2rem, 9vw, 2.85rem);
    }

    .page-hero {
        padding: 1.15rem;
    }
}

/* ── Validation Summary ───────────────────────────────────────────────── */
/* Hide when there are no validation errors (ASP.NET adds this class) */
.validation-summary-valid {
    display: none !important;
}

/* Show with danger styling only when there are actual errors */
.validation-summary-errors {
    display: block !important;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    background: rgba(199, 78, 57, 0.12);
    border: 1px solid rgba(199, 78, 57, 0.32);
    color: var(--danger);
    font-size: 0.87rem;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ── Mobile Navigation Bar ───────────────────────────────────────────────── */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: var(--header-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 var(--space-2);
    z-index: 1100;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}

.mobile-nav-item {
    flex: 1;
    text-align: center;
}

.mobile-nav-item a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-soft);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color var(--transition-base);
}

.mobile-nav-item i {
    font-size: 1.35rem;
    transition: transform var(--transition-fast);
}

.mobile-nav-item.active a,
.mobile-nav-item.active i {
    color: var(--accent);
}

.mobile-nav-item.active i {
    transform: translateY(-2px);
}

.mobile-nav-primary {
    position: relative;
    top: -24px;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.btn-mobile-primary {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    border: 4px solid var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 12px 24px rgba(138, 89, 32, 0.4);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-mobile-primary:active {
    transform: scale(0.9) rotate(45deg);
}

/* ── Desktop Footer ─────────────────────────────────────────────────────── */
.app-footer {
    margin-top: auto;
    background: var(--header-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    padding: var(--space-7) 0 var(--space-6);
    position: relative;
    overflow: hidden;
}

/* Filo d'oro superiore */
.app-footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

.footer-container {
    width: min(100%, var(--content-width));
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
    gap: var(--space-6);
    margin-bottom: var(--space-7);
}

.footer-brand-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.footer-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
}

.footer-brand-name {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--text-main);
    line-height: 1;
}

.footer-brand-tag {
    font-size: 0.7rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.footer-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 320px;
}

.footer-heading {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--text-main);
    margin-bottom: var(--space-4);
}

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

.footer-list a {
    color: var(--text-soft);
    font-size: 0.92rem;
    transition: color var(--transition-base), transform var(--transition-fast);
    display: inline-block;
}

.footer-list a:hover {
    color: var(--accent);
    transform: translateX(4px);
}

.footer-status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.6rem 1rem;
    border-radius: 999px;
    background: rgba(31, 141, 97, 0.1);
    color: var(--success);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-4);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.footer-meta {
    display: grid;
    gap: var(--space-1);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer-bottom-bar {
    border-top: 1px solid var(--border);
    padding-top: var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-soft);
    font-size: 0.85rem;
}

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

.dot-separator {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--border-strong);
}

.footer-signature {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-main);
}

/* ── Mobile Layout Fixes ───────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    /* Aggiunge spazio extra in fondo a tutto il contenuto per superare la barra mobile */
    .app-content {
        padding-bottom: 120px !important; 
    }

    /* Assicura che anche i contenitori interni permettano lo scroll extra */
    .main-container {
        padding-bottom: 40px;
    }
}
