:root {
    --ui-font-family: "Source Sans 3", "Segoe UI", sans-serif;
    --ui-text-xs: 0.8rem;
    --ui-text-sm: 0.9rem;
    --ui-text-base: 1rem;
    --ui-text-md: 1.05rem;
    --ui-text-lg: 1.2rem;
    --ui-text-xl: clamp(1.55rem, 1.2rem + 1vw, 2.1rem);
    --ui-text-2xl: clamp(1.95rem, 1.45rem + 1.2vw, 2.8rem);
    --ui-line-base: 1.55;
    --ui-line-tight: 1.3;
    --ui-radius-sm: 0.7rem;
    --ui-radius-md: 0.95rem;
    --ui-radius-lg: 1.2rem;
    --ui-space-1: 0.5rem;
    --ui-space-2: 0.75rem;
    --ui-space-3: 1rem;
    --ui-space-4: 1.25rem;
    --ui-space-5: 1.5rem;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f7fafc;
    --ui-surface-muted: #f1f5f9;
    --ui-border: #dbe5ef;
    --ui-border-soft: #e8eef5;
    --ui-text: #24384d;
    --ui-text-strong: #17324a;
    --ui-text-soft: #6b7f93;
    --ui-primary: #1d4ed8;
    --ui-primary-soft: #e7efff;
    --ui-shadow-sm: 0 0.45rem 1rem rgba(15, 23, 42, 0.05);
    --ui-shadow-md: 0 0.75rem 1.65rem rgba(15, 23, 42, 0.06);
    --ui-shadow-lg: 0 1rem 2.2rem rgba(15, 23, 42, 0.08);
}

html {
    font-size: 15px;
}

body {
    font-family: var(--ui-font-family);
    font-size: var(--ui-text-base);
    line-height: var(--ui-line-base);
    color: var(--ui-text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

p,
li,
td,
th,
label,
.form-text,
.small,
small,
.text-muted,
.dropdown-item,
.nav-link,
.btn,
.form-control,
.form-select,
.breadcrumb-item,
.table,
.card,
.panel,
.soft-card {
    font-size: var(--ui-text-sm);
    line-height: 1.55;
}

h1,
.content-header h1,
.app-content-header h3 {
    font-size: var(--ui-text-2xl);
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ui-text-strong);
}

h2,
.card-title,
.panel-title {
    font-size: var(--ui-text-xl);
    line-height: 1.2;
    font-weight: 600;
    color: var(--ui-text-strong);
}

h3,
h4,
.metric-card h4,
.quick-module h4,
.content-card h4 {
    font-size: var(--ui-text-lg);
    line-height: 1.25;
    font-weight: 600;
}

h5,
h6 {
    font-size: var(--ui-text-md);
    line-height: 1.3;
    font-weight: 600;
}

.app-content-header .text-muted,
.panel-kicker,
.profile-menu-role,
.breadcrumb-item,
.table thead th,
.form-text,
.small,
small {
    font-size: var(--ui-text-xs);
}

.sidebar-menu .nav-link {
    font-size: 1.02rem;
    line-height: 1.35;
    font-weight: 500;
}

.sidebar-menu .nav-link p {
    font-size: inherit;
}

.navbar-nav .nav-link,
.brand-link .brand-text {
    font-size: 1rem;
}

.table thead th {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: var(--ui-text-soft);
}

.table tbody td {
    font-size: var(--ui-text-sm);
    vertical-align: middle;
}

.form-label {
    font-size: var(--ui-text-sm);
    font-weight: 600;
    margin-bottom: 0.45rem;
    color: var(--ui-text);
}

.form-control,
.form-select {
    font-size: var(--ui-text-sm);
}

.btn {
    font-size: var(--ui-text-sm);
    font-weight: 600;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.82rem;
    text-decoration: none;
    white-space: normal;
    line-height: 1.35;
    min-height: 78px;
    padding-top: 0.95rem;
    padding-bottom: 0.95rem;
}

.brand-link .brand-image {
    float: none;
    max-height: 42px;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    opacity: 1;
}

.brand-link .brand-copy {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    flex-direction: column;
}

.brand-link .brand-eyebrow {
    display: block;
    margin-bottom: 0.12rem;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.brand-link .brand-text {
    display: block;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.28;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.brand-link .brand-meta {
    display: block;
    margin-top: 0.28rem;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
}

.app-main {
    background: linear-gradient(180deg, #f4f7fb 0%, #eef3f8 100%);
}

.app-content-header {
    padding: 0.65rem 0 0.3rem;
    background: linear-gradient(180deg, #eaf3ff 0%, #deebfb 100%);
    border-bottom: 1px solid #c8d8ef;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

.page-header-title {
    margin: 0;
    font-size: 1.84rem;
    line-height: 1.2;
    font-weight: 600;
    color: #1f4f82;
    letter-spacing: -0.01em;
}

.page-header-subtitle {
    margin-top: 0.12rem;
    font-size: 0.74rem;
    line-height: 1.4;
    color: #5f7797;
}

.page-breadcrumb {
    margin-bottom: 0;
    font-size: 0.74rem;
}

.page-breadcrumb .breadcrumb-item,
.page-breadcrumb .breadcrumb-item.active,
.page-breadcrumb .breadcrumb-item a {
    color: #6a84a7;
}

.page-breadcrumb .breadcrumb-item a:hover {
    color: #1f4f82;
}

.app-content {
    padding-bottom: 1rem;
}

.container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
}

.content-header h1 {
    font-weight: 500;
}

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

.stat-card-classic {
    color: #fff;
    border-radius: 0.5rem;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    min-height: 130px;
}

.stat-card-classic .stat-icon {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 3rem;
    opacity: 0.2;
}

.stat-card-classic .stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.stat-card-classic .stat-label {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.stat-card-classic .stat-note {
    font-size: 0.9rem;
    opacity: 0.9;
}

.bg-classic-green { background: linear-gradient(180deg, #28a745, #23903c); }
.bg-classic-yellow { background: linear-gradient(180deg, #ffc107, #eba900); color: #3b2c00; }
.bg-classic-orange { background: linear-gradient(180deg, #fd7e14, #ea6d04); }
.bg-classic-red { background: linear-gradient(180deg, #dc3545, #c62838); }

.metric-card {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    padding: var(--ui-space-3);
    box-shadow: var(--ui-shadow-sm);
}

.quick-module {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    padding: var(--ui-space-4);
    height: 100%;
    box-shadow: var(--ui-shadow-sm);
}

.quick-module .icon-box {
    width: 4.5rem;
    height: 4rem;
    border-radius: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: #fff;
    margin-bottom: 1rem;
}

.table-actions {
    display: flex;
    gap: var(--ui-space-1);
    flex-wrap: wrap;
}

.floating-preview {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 32px));
    height: min(82vh, 820px);
    display: none;
    grid-template-rows: auto 1fr;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.22);
    z-index: 1080;
}

.floating-preview.is-open { display: grid; }

.floating-preview.is-fullscreen {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-width: 1440px;
}

.floating-preview-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(0, 0, 0, 0.38);
    z-index: 1070;
}

.floating-preview-backdrop.is-open { display: block; }

.floating-preview-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #f8f9fa;
}

.content-card {
    border: 1px solid var(--ui-border);
    border-radius: 0.5rem;
    background: var(--ui-surface);
}

.navbar-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.navbar-avatar,
.user-avatar-photo,
.profile-preview-photo {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.navbar-avatar-fallback,
.user-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #0b5f92);
    color: #fff;
    font-weight: 700;
}

.navbar-avatar-fallback {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
}

.user-avatar-fallback {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 1rem;
}

.profile-menu {
    min-width: 280px;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-lg);
    padding: 0;
}

.profile-menu-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1rem 0.9rem;
    background: linear-gradient(135deg, #f8fbff, #eef4fb);
}

.profile-menu-body {
    padding: 0.85rem 1rem 0.35rem;
}

.profile-menu-role {
    color: var(--ui-text-soft);
    font-size: 0.88rem;
}

.profile-menu-name {
    font-weight: 700;
    color: var(--ui-text-strong);
    line-height: 1.35;
}

.page-grid,
.stack {
    display: grid;
    gap: var(--ui-space-3);
}

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

.grid-4,
.stats-hero {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--ui-space-3);
}

.panel {
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    box-shadow: var(--ui-shadow-md);
    padding: var(--ui-space-3);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--ui-space-3);
    margin-bottom: var(--ui-space-3);
}

.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: var(--ui-radius-sm);
    padding: 0.6rem 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
}

.button-primary {
    background: var(--ui-primary);
    color: #fff;
}

.button-secondary {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
}

.button-ghost {
    background: var(--ui-surface);
    color: var(--ui-text);
    border-color: var(--ui-border);
}

.button-danger {
    background: #dc3545;
    color: #fff;
}

.soft-card {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    padding: var(--ui-space-3);
    box-shadow: var(--ui-shadow-sm);
}

.card,
.content-card {
    border-radius: var(--ui-radius-md);
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-sm);
    overflow: hidden;
}

.card-header,
.content-card .card-header {
    padding: 0.95rem 1rem;
    background: linear-gradient(180deg, #fbfdff, #f5f8fb);
    border-bottom: 1px solid var(--ui-border-soft);
}

.card-body,
.content-card .card-body {
    padding: 1rem;
}

.table {
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.8rem 0.75rem;
    border-color: var(--ui-border-soft);
}

.form-control,
.form-select {
    min-height: 42px;
    border-radius: var(--ui-radius-sm);
    padding: 0.6rem 0.8rem;
    border-color: var(--ui-border);
    background: #fff;
    box-shadow: none;
}

textarea.form-control {
    min-height: 110px;
}

.form-control:focus,
.form-select:focus {
    border-color: #9ab9ff;
    box-shadow: 0 0 0 0.22rem rgba(29, 78, 216, 0.12);
}

.btn {
    border-radius: var(--ui-radius-sm);
    padding: 0.58rem 0.95rem;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-color: #1d4ed8;
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, #1f58db, #1847c6);
    border-color: #1847c6;
}

.btn-outline-secondary,
.btn-light {
    border-color: var(--ui-border);
}

.app-sidebar .nav-link {
    margin: 0.15rem 0.45rem;
    border-radius: 0.85rem;
    padding: 0.72rem 0.9rem;
}

.app-sidebar .nav-link.active {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    padding-bottom: 0.55rem;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0));
}

.brand-link {
    padding-left: 1rem;
    padding-right: 1rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    min-height: 84px;
    text-align: left;
}

.brand-link .brand-image-lg {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
}

.brand-link .brand-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.12rem;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}

.brand-link .brand-title {
    display: block;
    color: #ffffff;
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.01em;
}

.brand-link .brand-subtitle {
    display: block;
    max-width: none;
    width: 100%;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.62rem;
    line-height: 1.25;
    word-break: break-word;
    white-space: normal;
    overflow-wrap: anywhere;
}

.sidebar-collapse .brand-link {
    justify-content: center;
    min-height: 64px;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}

.sidebar-collapse .brand-link .brand-copy {
    display: none;
}

.sidebar-collapse .brand-link .brand-image {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
}

.breadcrumb {
    margin-bottom: 0;
}

.alert {
    border-radius: var(--ui-radius-md);
    padding: 0.85rem 1rem;
    border-width: 1px;
    box-shadow: var(--ui-shadow-sm);
}

@media (max-width: 991.98px) {
    .container-fluid {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .grid-2,
    .grid-4,
    .stats-hero {
        grid-template-columns: 1fr;
    }

    .card-header,
    .card-body,
    .panel,
    .soft-card,
    .quick-module,
    .metric-card {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }
}

.filters,
.footer-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.95rem 1.2rem;
    background: linear-gradient(135deg, #fbfdff, #f3f8fd);
    border-top: 1px solid #dbe7f2;
}

.app-footer > strong {
    display: inline-flex;
    align-items: center;
    margin: 0;
    padding: 0.45rem 0.8rem;
    border-radius: 0.9rem;
    background: linear-gradient(135deg, #eef4ff, #eefbf7);
    color: #163b63;
    border: 1px solid #d6e5f3;
    box-shadow: 0 0.35rem 0.8rem rgba(15, 23, 42, 0.05);
}

.app-footer > .text-muted:not(.app-footer-credit-legacy) {
    flex: 1 1 320px;
    min-width: 220px;
    color: #64788c !important;
    line-height: 1.45;
}

.app-footer .app-footer-credit-legacy strong {
    color: #0f4c81;
    font-weight: 800;
}

.app-footer .app-footer-credit-legacy {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.46rem 0.82rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #0f5fa8, #127c72);
    color: #f8fbff !important;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 0.6rem 1.3rem rgba(15, 95, 168, 0.18);
}

.app-footer .app-footer-credit-product {
    font-weight: 800;
    letter-spacing: -0.01em;
}

.app-footer .app-footer-credit-separator {
    opacity: 0.82;
    font-weight: 700;
}

.app-footer .app-footer-credit-legacy::before {
    content: "";
    width: 0.58rem;
    height: 0.58rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #f8c146, #fde68a);
    box-shadow: 0 0 0 0.16rem rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
}

@media (max-width: 767.98px) {
    .app-footer {
        align-items: flex-start;
    }

    .app-footer > strong,
    .app-footer > .text-muted:not(.app-footer-credit-legacy) {
        width: 100%;
    }

    .app-footer .app-footer-credit-legacy {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
}

.inline-field {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
}

.muted,
.help {
    color: #6c757d;
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: #6c757d;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
}

.badge-outgoing {
    background: #fff3cd;
    color: #856404;
}

.section-note {
    border: 1px dashed #cdd7e1;
    background: #f8fafc;
    border-radius: 0.5rem;
    padding: 1rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.empty {
    text-align: center;
    color: #6c757d;
    padding: 1.5rem;
}

.meter {
    height: 0.7rem;
    border-radius: 999px;
    background: #e9ecef;
    overflow: hidden;
}

.meter > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #0b5ed7);
}

.meter-secondary > span {
    background: linear-gradient(90deg, #ffc107, #f59f00);
}

.kpi-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: #adb5bd;
}

@media (max-width: 991.98px) {
    .grid-2,
    .grid-4,
    .stats-hero,
    .panel-header {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .page-actions,
    .table-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .inline-field {
        grid-template-columns: 1fr;
    }

    .floating-preview {
        width: calc(100vw - 12px);
        height: calc(100vh - 12px);
    }
}
