:root {
    --ypc-bg: #f5f7f6;
    --ypc-bg-rgb: 245, 247, 246;
    --ypc-surface: #ffffff;
    --ypc-surface-soft: #f8faf9;
    --ypc-surface-muted: #eef5f3;
    --ypc-border: #d9e4e1;
    --ypc-border-strong: #c6d4d0;
    --ypc-muted: #65747c;
    --ypc-text: #14232c;
    --ypc-heading: #0c1f28;
    --ypc-primary: #0f766e;
    --ypc-primary-dark: #0b5f5a;
    --ypc-primary-soft: #e5f3f0;
    --ypc-navy: #0b202b;
    --ypc-navy-soft: #102f3b;
    --ypc-blue: #2563eb;
    --ypc-green: #16825f;
    --ypc-red: #c2413d;
    --ypc-amber: #b7791f;
    --ypc-cyan: #0e7490;
    --ypc-shadow: 0 18px 48px rgba(12, 31, 40, .08);
    --ypc-shadow-soft: 0 10px 28px rgba(12, 31, 40, .06);
    --ypc-focus: 0 0 0 .22rem rgba(15, 118, 110, .14);
    --ypc-radius: 8px;
    --ypc-radius-sm: 6px;
}

html {
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, .08), transparent 28rem),
        linear-gradient(180deg, #fafcfb 0%, var(--ypc-bg) 48%, #f0f4f3 100%);
    color: var(--ypc-text);
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 15px;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--ypc-primary);
}

a:hover {
    color: var(--ypc-primary-dark);
}

::selection {
    background: rgba(15, 118, 110, .18);
}

.app-wrapper {
    background: transparent;
}

.app-main {
    padding: 22px;
}

.app-content-header {
    padding: 0;
}

.app-header {
    min-height: 64px;
    border-bottom: 1px solid rgba(217, 228, 225, .82);
    background: rgba(255, 255, 255, .88) !important;
    box-shadow: 0 10px 28px rgba(12, 31, 40, .045);
    backdrop-filter: blur(14px);
}

.app-header .nav-link {
    color: var(--ypc-muted);
    border-radius: var(--ypc-radius-sm);
    transition: background-color .18s ease, color .18s ease;
}

.app-header .nav-link:hover,
.app-header .nav-link:focus {
    color: var(--ypc-heading);
    background: var(--ypc-surface-muted);
}

.app-header .user-image {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 8px 18px rgba(12, 31, 40, .14);
}

.dropdown-menu {
    border: 1px solid var(--ypc-border);
    border-radius: var(--ypc-radius);
    box-shadow: var(--ypc-shadow);
}

.dropdown-item {
    border-radius: var(--ypc-radius-sm);
    font-weight: 700;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--ypc-primary-soft);
    color: var(--ypc-primary-dark);
}

.app-sidebar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 24%),
        linear-gradient(180deg, var(--ypc-navy), #0a2f35 58%, #09242e);
    border-left: 1px solid rgba(255, 255, 255, .06);
}

.app-sidebar.shadow {
    box-shadow: 14px 0 36px rgba(12, 31, 40, .12) !important;
}

.sidebar-brand {
    min-height: 76px;
}

.app-sidebar .brand-link {
    gap: 10px;
    min-height: 76px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
}

.app-sidebar .brand-image {
    width: 40px;
    height: 40px;
    object-fit: contain;
    padding: 6px;
    border-radius: var(--ypc-radius);
    background: rgba(255, 255, 255, .94);
    opacity: 1 !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
}

.app-sidebar .brand-text {
    color: #f8fbfb;
    font-size: 1rem;
    font-weight: 900 !important;
    letter-spacing: 0;
}

.sidebar-wrapper {
    padding: 10px 8px 18px;
}

.app-sidebar .nav-link {
    min-height: 44px;
    margin: 3px 6px;
    border-radius: var(--ypc-radius);
    color: rgba(255, 255, 255, .74);
    font-weight: 750;
    transition:
        background-color .18s ease,
        color .18s ease,
        transform .18s ease;
}

.app-sidebar .nav-link:hover,
.app-sidebar .nav-link:focus {
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.app-sidebar .nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(15, 118, 110, .95), rgba(12, 95, 90, .95));
    box-shadow: 0 12px 30px rgba(0, 0, 0, .20);
}

.app-sidebar .nav-icon {
    color: inherit;
    opacity: .92;
}

.app-sidebar .nav-treeview {
    margin: 4px 8px 8px;
    padding: 5px;
    border-radius: var(--ypc-radius);
    background: rgba(255, 255, 255, .045);
}

.app-sidebar .nav-treeview .nav-link {
    min-height: 38px;
    margin: 2px;
    font-size: .92rem;
}

.app-footer {
    border-top: 1px solid var(--ypc-border);
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(10px);
}

.page-shell {
    width: min(100%, 1440px);
    margin: 0 auto;
}

.page-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px;
    margin-bottom: 18px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .98), rgba(248, 250, 249, .98)),
        var(--ypc-surface);
    border: 1px solid var(--ypc-border);
    border-radius: var(--ypc-radius);
    box-shadow: var(--ypc-shadow-soft);
}

.page-title {
    margin: 0;
    color: var(--ypc-heading);
    font-size: clamp(1.16rem, 1vw + 1rem, 1.55rem);
    font-weight: 900;
    letter-spacing: 0;
}

.page-subtitle {
    max-width: 720px;
    margin: 7px 0 0;
    color: var(--ypc-muted);
    font-size: .92rem;
    line-height: 1.75;
}

.page-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ypc-radius);
    background: var(--ypc-primary-soft);
    color: var(--ypc-primary-dark);
    font-size: 1.38rem;
    flex: 0 0 auto;
    border: 1px solid rgba(15, 118, 110, .16);
}

.breadcrumb {
    --bs-breadcrumb-divider-color: var(--ypc-muted);
    font-weight: 750;
}

.breadcrumb a {
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--ypc-muted);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.section-card,
.card,
.modal-content {
    border: 1px solid var(--ypc-border);
    border-radius: var(--ypc-radius);
    box-shadow: var(--ypc-shadow-soft);
}

.section-card {
    background: var(--ypc-surface);
    overflow: hidden;
}

.section-card + .section-card {
    margin-top: 16px;
}

.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 19px;
    border-bottom: 1px solid var(--ypc-border);
    background: linear-gradient(180deg, #fff, var(--ypc-surface-soft));
}

.section-title {
    margin: 0;
    color: var(--ypc-heading);
    font-size: 1rem;
    font-weight: 900;
}

.section-note {
    margin: 5px 0 0;
    color: var(--ypc-muted);
    font-size: .86rem;
    line-height: 1.65;
}

.section-card-body {
    padding: 19px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.metric-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 104px;
    padding: 17px;
    background: var(--ypc-surface);
    border: 1px solid var(--ypc-border);
    border-radius: var(--ypc-radius);
    box-shadow: var(--ypc-shadow-soft);
    overflow: hidden;
    transition:
        border-color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--ypc-primary);
    opacity: .82;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--ypc-border-strong);
    box-shadow: var(--ypc-shadow);
}

.metric-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ypc-radius);
    color: #fff;
    font-size: 1.28rem;
    flex: 0 0 auto;
    box-shadow: 0 12px 28px rgba(12, 31, 40, .14);
}

.metric-label {
    margin: 0;
    color: var(--ypc-muted);
    font-size: .83rem;
    font-weight: 800;
}

.metric-value {
    margin-top: 5px;
    color: var(--ypc-heading);
    font-size: 1.62rem;
    font-weight: 950;
    line-height: 1;
}

.bg-ypc-primary { background: var(--ypc-primary); }
.bg-ypc-blue { background: var(--ypc-blue); }
.bg-ypc-green { background: var(--ypc-green); }
.bg-ypc-red { background: var(--ypc-red); }
.bg-ypc-amber { background: var(--ypc-amber); }

.table-responsive {
    scrollbar-width: thin;
    scrollbar-color: var(--ypc-border-strong) transparent;
}

.data-table {
    margin: 0;
    color: var(--ypc-text);
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 13px 14px;
    background: #f1f7f5;
    color: #173b38;
    border-bottom: 1px solid var(--ypc-border);
    font-size: .82rem;
    font-weight: 900;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 13px 14px;
    vertical-align: middle;
    border-color: #edf2f1;
}

.data-table tbody tr {
    transition: background-color .16s ease;
}

.data-table tbody tr:hover {
    background: #fbfdfc;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex-wrap: wrap;
}

.btn {
    border-radius: var(--ypc-radius-sm);
    font-weight: 850;
    letter-spacing: 0;
    box-shadow: none !important;
    transition:
        background-color .18s ease,
        border-color .18s ease,
        color .18s ease,
        transform .18s ease;
}

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

.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    box-shadow: var(--ypc-focus) !important;
}

.btn-primary,
.page-item.active .page-link {
    background-color: var(--ypc-primary);
    border-color: var(--ypc-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--ypc-primary-dark);
    border-color: var(--ypc-primary-dark);
}

.btn-outline-primary {
    color: var(--ypc-primary);
    border-color: rgba(15, 118, 110, .32);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--ypc-primary);
    border-color: var(--ypc-primary);
}

.btn-light {
    background: var(--ypc-surface-soft);
    border-color: var(--ypc-border);
    color: var(--ypc-text);
}

.btn-light:hover {
    background: #eef5f3;
    border-color: var(--ypc-border-strong);
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.form-label {
    margin-bottom: 7px;
    color: #334650;
    font-weight: 900;
}

.form-control,
.form-select,
.input-group-text {
    border-radius: var(--ypc-radius-sm);
    border-color: var(--ypc-border);
    min-height: 43px;
}

.form-control,
.form-select {
    color: var(--ypc-text);
    background-color: #fff;
}

.form-control::placeholder {
    color: #94a3ad;
}

.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .input-group-text:not(:last-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group-text {
    color: var(--ypc-primary-dark);
    background: var(--ypc-surface-soft);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ypc-primary);
}

.form-text {
    color: var(--ypc-muted);
    font-size: .82rem;
}

.alert {
    border: 1px solid transparent;
    border-radius: var(--ypc-radius);
    box-shadow: 0 10px 28px rgba(12, 31, 40, .05);
    font-weight: 750;
}

.alert-success {
    color: #0d513b;
    background: #e9f7f1;
    border-color: #cdeadd;
}

.alert-danger {
    color: #842029;
    background: #fff0f0;
    border-color: #f4cccc;
}

.badge,
.status-pill {
    letter-spacing: 0;
}

.empty-state {
    padding: 40px 18px;
    text-align: center;
    color: var(--ypc-muted);
    font-weight: 750;
}

.empty-state i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 12px;
    color: var(--ypc-primary);
    background: var(--ypc-primary-soft);
    border: 1px solid rgba(15, 118, 110, .14);
    border-radius: var(--ypc-radius);
    font-size: 1.55rem;
}

.search-control {
    max-width: 300px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--ypc-primary-soft);
    color: var(--ypc-primary-dark);
    border: 1px solid rgba(15, 118, 110, .14);
    font-size: .78rem;
    font-weight: 900;
}

.user-avatar {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 8px 20px rgba(12, 31, 40, .14);
}

.workflow-chain {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 420px;
}

.workflow-node {
    flex: 1 1 0;
    min-width: 120px;
    padding: 9px 10px;
    border: 1px solid var(--ypc-border);
    border-radius: var(--ypc-radius-sm);
    background: #fff;
    font-size: .82rem;
    font-weight: 800;
}

.workflow-arrow {
    color: var(--ypc-muted);
}

.modal-content {
    background: var(--ypc-surface);
}

.modal-header {
    border-bottom: 1px solid var(--ypc-border);
    background: var(--ypc-surface-soft);
}

.modal-title {
    color: var(--ypc-heading);
    font-weight: 900;
}

.modal-footer {
    border-top: 1px solid var(--ypc-border);
    background: #fbfdfc;
}

.login-shell,
.reset-shell {
    border-radius: var(--ypc-radius) !important;
    border: 1px solid var(--ypc-border) !important;
    box-shadow: var(--ypc-shadow) !important;
}

.login-brand {
    background:
        linear-gradient(160deg, rgba(255, 255, 255, .05), transparent 32%),
        linear-gradient(160deg, var(--ypc-navy), var(--ypc-primary-dark)) !important;
}

.login-logo,
.reset-logo {
    border-radius: var(--ypc-radius) !important;
    border: 1px solid rgba(255, 255, 255, .18);
}

.account-chip {
    background: var(--ypc-primary-soft) !important;
    color: var(--ypc-primary-dark) !important;
}

@media (max-width: 991.98px) {
    .app-main {
        padding: 16px;
    }

    .page-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .breadcrumb {
        margin-top: 4px;
    }

    .section-card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .page-actions,
    .search-control {
        width: 100%;
        max-width: none;
    }

    .page-actions .btn,
    .page-actions .form-control {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    .app-main {
        padding: 12px;
    }

    .page-hero {
        padding: 16px;
    }

    .page-icon {
        width: 44px;
        height: 44px;
    }

    .section-card-body {
        padding: 15px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        min-height: 88px;
    }

    .login-brand,
    .login-form,
    .reset-shell {
        padding: 26px !important;
    }
}

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