:root {
    --color-navy: #0F2144;
    --color-navy-soft: #18325F;
    --color-teal: #0D7C6F;
    --color-teal-soft: #E7F6F4;
    --color-bg: #F7F9FC;
    --color-surface: #FFFFFF;
    --color-border: #E5EAF2;
    --color-muted: #64748B;
    --color-text: #172033;
    --font-heading: "Plus Jakarta Sans", sans-serif;
    --font-body: "DM Sans", sans-serif;
    --sidebar-expanded: 240px;
    --sidebar-collapsed: 64px;
    --topbar-height: 72px;
    --shadow-soft: 0 10px 30px rgba(15, 33, 68, 0.08);
    --shadow-card: 0 14px 40px rgba(15, 33, 68, 0.10);
}

* {
    box-sizing: border-box;
}

body.app-body {
    min-height: 100vh;
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
}

h1,
h2,
h3,
h4,
.font-heading {
    font-family: var(--font-heading);
}

.app-shell {
    min-height: 100vh;
    padding-left: var(--sidebar-expanded);
    transition: padding-left 220ms ease;
}

body.sidebar-collapsed .app-shell {
    padding-left: var(--sidebar-collapsed);
}

.app-shell.is-public {
    padding-left: 0;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-expanded);
    background: var(--color-navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 12px 0 30px rgba(15, 33, 68, 0.16);
    transition: width 220ms ease, transform 220ms ease;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.brand-mark {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
}

.brand-mark img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 10px;
    background: #fff;
    padding: 4px;
}

.brand-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.1;
    transition: opacity 160ms ease;
}

.brand-copy strong {
    font-family: var(--font-heading);
    font-size: 1rem;
}

.brand-copy small {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.75rem;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .sidebar-label {
    opacity: 0;
    pointer-events: none;
    width: 0;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-toggle {
    opacity: 1;
    pointer-events: auto;
    width: 36px;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.sidebar-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.78);
    border-radius: 12px;
    text-decoration: none;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.sidebar-link i {
    width: 20px;
    flex: 0 0 20px;
    text-align: center;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    color: #fff;
    background: rgba(13, 124, 111, 0.92);
    transform: translateX(2px);
}

.sidebar-link.is-disabled {
    cursor: not-allowed;
    color: rgba(255, 255, 255, 0.34);
}

.sidebar-link.is-disabled:hover {
    background: transparent;
    transform: none;
}

.icon-button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-navy);
    background: #fff;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.icon-button:hover {
    color: var(--color-teal);
    border-color: rgba(13, 124, 111, 0.35);
    transform: translateY(-1px);
}

.sidebar-toggle {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    color: #fff;
    background: rgba(255, 255, 255, 0.10);
    border-color: rgba(255, 255, 255, 0.14);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: rgba(247, 249, 252, 0.92);
    border-bottom: 1px solid rgba(229, 234, 242, 0.92);
    backdrop-filter: blur(16px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mobile-menu-button {
    display: none;
}

.breadcrumb-kicker {
    margin: 0 0 2px;
    color: var(--color-muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
}

.page-title {
    margin: 0;
    color: var(--color-navy);
    font-family: var(--font-heading);
    font-size: 1.35rem;
    line-height: 1.2;
}

.notif-button {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #E11D48;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 3px #fff;
}

.profile-menu {
    position: relative;
}

.profile-button {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: #fff;
    padding: 4px 10px 4px 5px;
    cursor: pointer;
}

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-teal);
    color: #fff;
    font-weight: 800;
}

.profile-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.profile-copy strong {
    max-width: 160px;
    color: var(--color-navy);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-copy small {
    color: var(--color-muted);
    font-size: 0.75rem;
}

.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 210px;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.profile-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    color: var(--color-text);
    text-decoration: none;
}

.profile-dropdown a:hover {
    background: var(--color-teal-soft);
    color: var(--color-teal);
}

.main-content {
    padding: 28px;
}

.page-section {
    animation: fadeInUp 360ms ease both;
}

.card,
.stat-card,
.content-card {
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: var(--shadow-soft);
}

.lift-card {
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.lift-card:hover {
    transform: translateY(-3px);
    border-color: rgba(13, 124, 111, 0.26);
    box-shadow: var(--shadow-card);
}

.stat-card {
    padding: 20px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-teal);
    background: var(--color-teal-soft);
}

.btn-modern {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--color-navy);
    color: #fff;
}

.btn-secondary {
    background: #64748B;
    color: #fff;
}

.btn-danger {
    background: #DC2626;
    color: #fff;
}

.btn-success {
    background: var(--color-teal);
    color: #fff;
}

.btn:hover {
    color: #fff;
    filter: brightness(0.96);
}

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

.btn-primary-modern {
    background: var(--color-navy);
    color: #fff;
    box-shadow: 0 10px 24px rgba(15, 33, 68, 0.18);
}

.btn-primary-modern:hover {
    background: var(--color-navy-soft);
    color: #fff;
}

.btn-teal-modern {
    background: var(--color-teal);
    color: #fff;
    box-shadow: 0 10px 24px rgba(13, 124, 111, 0.18);
}

.btn-teal-modern:hover {
    background: #09685E;
    color: #fff;
}

.btn-danger-modern {
    background: #DC2626;
    color: #fff;
}

.btn-ghost-modern {
    background: #fff;
    color: var(--color-navy);
    border-color: var(--color-border);
}

.alert-banner {
    border-radius: 16px;
    padding: 16px;
    border: 1px solid;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.alert-warning {
    background: #FFF7ED;
    border-color: #FED7AA;
    color: #9A3412;
}

.alert-info {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1E3A8A;
}

.alert-success {
    background: #ECFDF5;
    border-color: #A7F3D0;
    color: #065F46;
}

.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.modern-table th {
    background: #F8FAFC;
    color: var(--color-muted);
    font-size: 0.75rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0;
}

.modern-table th,
.modern-table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--color-border);
}

.modern-table tbody tr:nth-child(even) {
    background: #FBFCFE;
}

.modern-table tbody tr:hover {
    background: var(--color-teal-soft);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
}

.status-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    animation: pulse-dot 1.8s ease infinite;
}

.status-valid,
.status-ok {
    background: #DCFCE7;
    color: #166534;
}

.status-valid::before,
.status-ok::before {
    background: #16A34A;
}

.status-pending,
.status-no-signature,
.status-waiting {
    background: #FEF3C7;
    color: #92400E;
}

.status-pending::before,
.status-no-signature::before,
.status-waiting::before {
    background: #F59E0B;
}

.status-rejected,
.status-invalid,
.status-error {
    background: #FEE2E2;
    color: #991B1B;
}

.status-rejected::before,
.status-invalid::before,
.status-error::before {
    background: #DC2626;
}

.status-neutral {
    background: #E2E8F0;
    color: #334155;
}

.status-neutral::before {
    background: #64748B;
}

.flash-stack {
    position: fixed;
    top: 86px;
    right: 28px;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    background: #fff;
    box-shadow: var(--shadow-soft);
    animation: slideDown 220ms ease both;
}

.flash-message button {
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.flash-message.success {
    border-color: #A7F3D0;
    color: #065F46;
}

.flash-message.error,
.flash-message.danger {
    border-color: #FECACA;
    color: #991B1B;
}

.flash-message.info {
    border-color: #BFDBFE;
    color: #1E3A8A;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 33, 68, 0.52);
}

.modal-backdrop.is-open {
    display: flex;
}

.modal-panel {
    width: min(520px, 100%);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 70px rgba(15, 33, 68, 0.24);
    animation: fadeInUp 220ms ease both;
}

.modal-panel-wide {
    width: min(1100px, 100%);
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

.modal-scroll-area {
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.pdf-preview-frame {
    width: 100%;
    min-height: 520px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: #F8FAFC;
}

.sign-preview-layout,
.sign-page-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .sign-preview-layout {
        grid-template-columns: minmax(0, 1fr) 360px;
        align-items: start;
    }
}

@media (min-width: 1280px) {
    .sign-page-layout {
        grid-template-columns: minmax(0, 1fr) 420px;
        align-items: start;
    }
}

.form-control {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 11px 13px;
    color: var(--color-text);
    background: #fff;
    outline: none;
}

.form-control:focus {
    border-color: var(--color-teal);
    box-shadow: 0 0 0 4px rgba(13, 124, 111, 0.12);
}

.select2-container {
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    min-height: 44px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    padding-left: 13px;
    color: var(--color-text);
    line-height: 42px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px;
}

.expiry-date-input {
    max-width: 170px;
}

.toggle-track {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #CBD5E1;
    transition: background 160ms ease;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 33, 68, 0.18);
    transition: transform 160ms ease;
}

.peer:checked + .toggle-track {
    background: var(--color-teal);
}

.peer:checked + .toggle-track::after {
    transform: translateX(20px);
}

.hidden {
    display: none !important;
}

.sidebar-overlay {
    display: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.35);
        opacity: 0.62;
    }
}

@media (max-width: 900px) {
    .app-shell,
    body.sidebar-collapsed .app-shell {
        padding-left: 0;
    }

    .app-sidebar {
        transform: translateX(-104%);
        width: var(--sidebar-expanded);
    }

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

    body.sidebar-mobile-open .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(15, 33, 68, 0.46);
    }

    .mobile-menu-button {
        display: inline-flex;
    }

    .topbar {
        padding: 12px 16px;
    }

    .main-content {
        padding: 18px 14px;
    }

    .profile-copy {
        display: none;
    }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .page-title {
        font-size: 1.08rem;
    }

    .modern-table {
        min-width: 640px;
    }
}
