:root {
    --tn-dark: #252525;
    --tn-dark-soft: #303030;
    --tn-yellow: #ffeb00;
    --tn-yellow-soft: #fff7a8;
    --tn-bg: #f4f6f9;
    --tn-text: #1f2937;
    --tn-sidebar-width: 280px;
    --tn-sidebar-collapsed-width: 84px;
    --tn-topbar-height: 72px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
}

.body-bg {
    background: var(--tn-bg);
    color: var(--tn-text);
    overflow-x: hidden;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--tn-sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #222 0%, #2b2b2b 55%, #1d1d1d 100%);
    color: #fff;
    z-index: 1040;
    transition: width .24s ease, transform .24s ease;
    box-shadow: 10px 0 28px rgba(0, 0, 0, .08);
}

.sidebar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.brand-box {
    flex: 0 0 auto;
    min-height: 104px;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
}

.brand-logo {
    width: 68px;
    height: 68px;
    flex: 0 0 68px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--tn-yellow);
    background: var(--tn-dark);
}

.brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    white-space: nowrap;
}

.brand-text strong {
    color: var(--tn-yellow);
    font-size: 17px;
    letter-spacing: .04em;
}

.brand-text small {
    color: rgba(255, 255, 255, .62);
    margin-top: 5px;
    font-size: 11px;
}

.sidebar-close {
    color: #fff;
    margin-left: auto;
    padding: 8px;
    border: 0;
}

.sidebar-close:hover,
.sidebar-close:focus {
    color: var(--tn-yellow);
}

.sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 235, 0, .45) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 235, 0, .42);
    border-radius: 10px;
}

.sidebar .menu-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .42);
    padding: 18px 25px 7px;
    white-space: nowrap;
}

.sidebar .nav-link {
    min-height: 46px;
    color: rgba(255, 255, 255, .78);
    border-radius: 11px;
    margin: 3px 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 13px;
    white-space: nowrap;
    overflow: hidden;
    transition: background .18s ease, color .18s ease, padding .22s ease;
}

.sidebar .nav-link i {
    width: 22px;
    flex: 0 0 22px;
    text-align: center;
    font-size: 18px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 235, 0, .13);
    color: #fff;
}

.sidebar .nav-link.active {
    color: var(--tn-yellow);
    box-shadow: inset 3px 0 0 var(--tn-yellow);
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .52);
    z-index: 1035;
    opacity: 0;
    transition: opacity .2s ease;
}

.main-wrap {
    margin-left: var(--tn-sidebar-width);
    min-height: 100vh;
    transition: margin-left .24s ease;
}

.topbar {
    min-height: var(--tn-topbar-height);
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 10px 26px;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
}

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

.topbar-left {
    min-width: 0;
    gap: 14px;
}

.topbar-title {
    min-width: 0;
}

.topbar-title h6,
.topbar-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    flex: 0 0 auto;
    gap: 14px;
}

.user-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.sidebar-toggle {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    color: var(--tn-dark);
    font-size: 23px;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
    color: var(--tn-dark);
    background: var(--tn-yellow-soft);
    border-color: #eadb39;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.content-wrap {
    padding: 26px;
}

.card-soft {
    border: 0;
    border-radius: 16px;
    box-shadow: 0 6px 22px rgba(15, 23, 42, .06);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: #fffbd1;
    color: #5a5100;
    font-size: 22px;
}

.btn-primary {
    background: var(--tn-dark);
    border-color: var(--tn-dark);
}

.btn-primary:hover,
.btn-primary:focus {
    background: #111;
    border-color: #111;
}

.text-primary {
    color: #252525 !important;
}

.badge-soft-success {
    background: #dcfce7;
    color: #166534;
}

.badge-soft-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-soft-danger {
    background: #fee2e2;
    color: #991b1b;
}

.login-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(255, 235, 0, .2), transparent 30%),
        linear-gradient(135deg, #f8f8f8, #ececec);
    display: grid;
    place-items: center;
    padding: 22px;
}

.login-card {
    width: min(440px, 100%);
    border: 0;
    border-radius: 24px;
    box-shadow: 0 22px 65px rgba(0, 0, 0, .14);
    overflow: hidden;
}

.login-card::before {
    content: '';
    display: block;
    height: 5px;
    background: var(--tn-yellow);
}

.login-logo {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid var(--tn-yellow);
    background: var(--tn-dark);
}

.doc-logo {
    width: 104px;
    height: 104px;
    object-fit: cover;
    border-radius: 50%;
}

.doc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    border-bottom: 3px solid var(--tn-dark);
    padding-bottom: 14px;
    margin-bottom: 22px;
}

.doc-title {
    text-align: right;
}

.table thead th {
    white-space: nowrap;
}

.item-row .form-control,
.item-row .form-select {
    min-width: 120px;
}

@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: var(--tn-sidebar-collapsed-width);
    }

    body.sidebar-collapsed .main-wrap {
        margin-left: var(--tn-sidebar-collapsed-width);
    }

    body.sidebar-collapsed .brand-box {
        padding-left: 12px;
        padding-right: 12px;
        justify-content: center;
    }

    body.sidebar-collapsed .brand-link {
        justify-content: center;
    }

    body.sidebar-collapsed .brand-logo {
        width: 56px;
        height: 56px;
        flex-basis: 56px;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .menu-title,
    body.sidebar-collapsed .nav-label {
        display: none;
    }

    body.sidebar-collapsed .sidebar .nav-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
        margin-left: 10px;
        margin-right: 10px;
    }

    body.sidebar-collapsed .sidebar .nav-link i {
        width: auto;
        flex-basis: auto;
        font-size: 20px;
    }
}

@media (max-width: 991.98px) {
    .sidebar {
        width: min(86vw, 300px);
        transform: translateX(-102%);
    }

    body.sidebar-open {
        overflow: hidden;
    }

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

    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    .main-wrap {
        margin-left: 0;
    }

    .topbar {
        padding-left: 16px;
        padding-right: 16px;
    }

    .content-wrap {
        padding: 18px;
    }
}

@media (max-width: 575.98px) {
    .topbar {
        min-height: 64px;
        gap: 10px;
        padding: 9px 12px;
    }

    .topbar-left {
        gap: 9px;
    }

    .sidebar-toggle {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .topbar-subtitle,
    .user-name,
    .logout-label {
        display: none;
    }

    .topbar-actions {
        gap: 8px;
    }

    .user-label i {
        font-size: 20px;
    }

    .logout-btn {
        width: 38px;
        height: 38px;
        justify-content: center;
        padding: 0;
    }

    .content-wrap {
        padding: 14px 12px 20px;
    }

    .login-page {
        padding: 14px;
    }

    .login-card .card-body {
        padding: 30px 22px !important;
    }

    .login-logo {
        width: 126px;
        height: 126px;
    }

    .doc-header {
        gap: 12px;
    }

    .doc-logo {
        width: 84px;
        height: 84px;
    }
}

@media print {
    .no-print {
        display: none !important;
    }

    .main-wrap {
        margin: 0 !important;
    }

    .content-wrap {
        padding: 0;
    }

    .card-soft {
        box-shadow: none;
    }

    .print-page {
        font-size: 12px;
    }

    .doc-header {
        margin-top: 0;
    }

    .doc-logo {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}
