:root {
    --surface: #ffffff;
    --surface-2: #f7fbf9;
    --border-soft: #dbe8e2;
    --text-main: #101828;
    --text-muted: #667085;
    --brand: #0f9d7a;
    --brand-2: #22b07d;
    --shadow-soft: 0 10px 30px rgba(16, 24, 40, .06);
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top right, #e5f0eb 0, #f5faf7 28%, #f2f8f5 100%);
    color: var(--text-main);
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    width: 280px;
    background: linear-gradient(170deg, #0f3c33 0%, #135145 55%, #196455 100%);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1060;
    border-right: 1px solid rgba(255, 255, 255, .08);
    transition: width .2s ease, transform .2s ease;
    overflow-x: hidden;
    overflow-y: auto;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.brand-box {
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .18);
    border-radius: 0;
    margin: 0 -1rem 1.1rem;
    padding: 1.1rem 1rem 1rem;
}

.brand-avatar {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-avatar-fallback {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: linear-gradient(120deg, #0f9d7a, #22b07d);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.brand-greeting {
    font-size: 17px;
    font-weight: 400;
    color: rgba(255, 255, 255, .92);
    line-height: 1.15;
}

.brand-username {
    font-size: .85rem;
    font-weight: 400;
    color: rgba(255, 255, 255, .88);
    line-height: 1.2;
    margin-top: 2px;
}

.app-nav .nav-link {
    color: rgba(255, 255, 255, .78);
    border-radius: 12px;
    padding: .75rem .85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .90rem;
    position: relative;
    overflow: visible;
}

.nav-text {
    white-space: nowrap;
    transition: opacity .15s ease;
}

.nav-text-wrap {
    min-width: 0;
    transition: opacity .15s ease;
}

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

.app-nav .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(15, 157, 122, .88), rgba(34, 176, 125, .92));
    box-shadow: 0 8px 24px rgba(15, 157, 122, .24);
}

.sidebar-footer {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 14px;
}

.app-main {
    margin-left: 280px;
    width: calc(100% - 280px);
    transition: margin-left .2s ease, width .2s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: 68px;
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-main > .container-fluid {
    flex: 1 0 auto;
}

.app-main > footer {
    margin-top: auto;
}

.app-topbar-left {
    display: inline-flex;
    align-items: center;
    gap: .9rem;
}

.topbar-mobile-brand,
.topbar-mobile-divider {
    display: none;
}

.topbar-mobile-brand {
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
}

.topbar-mobile-brand .brand-avatar-fallback {
    width: 26px;
    height: 26px;
    font-size: .8rem;
}

.topbar-mobile-divider {
    width: 1px;
    height: 28px;
    background: #e4ebe7;
}

.app-topbar-right {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    color: #667085;
}

.topbar-toggle-btn {
    border: 1px solid #d7e7e1;
    background: #f8fcfa;
    color: #36594f;
    min-width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.topbar-toggle-btn:hover,
.topbar-toggle-btn:focus,
.topbar-toggle-btn:focus-visible,
.topbar-toggle-btn:active {
    border-color: #d7e7e1;
    background: #f8fcfa;
    color: #36594f;
    opacity: .78;
    box-shadow: none;
}

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

.metric-card {
    background: linear-gradient(145deg, #ffffff 0%, #f3f9f6 100%);
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.table-modern {
    border-collapse: separate;
    border-spacing: 0 10px;
    margin-top: -10px;
}

.table-modern thead th {
    border: 0;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: transparent;
    padding: .75rem 1rem;
}

.table-modern tbody tr {
    background: var(--surface-2);
}

.table-modern tbody td {
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    padding: .9rem 1rem;
    vertical-align: middle;
}

.table-modern tbody td:first-child {
    border-left: 1px solid var(--border-soft);
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

.table-modern tbody td:last-child {
    border-right: 1px solid var(--border-soft);
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.content-card .table-responsive {
    overflow-x: clip;
    overflow-y: visible;
    padding-bottom: .95rem;
}

.content-card .dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

.content-card .dataTables_wrapper .row > [class*='col-'] {
    padding-left: 0;
    padding-right: 0;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border-color: #d5e4de;
    border-radius: 10px;
    box-shadow: none;
}

.dataTables_wrapper .dataTables_length select {
    padding-right: 2rem;
    background-position: right .7rem center;
}

.dataTables_wrapper .dataTables_paginate {
    margin-top: .9rem;
    margin-bottom: .2rem;
}

.dataTables_wrapper .dataTables_info {
    padding-top: .45rem;
    padding-bottom: .45rem;
}

.content-card .table-modern {
    width: 100% !important;
}

.dataTables_wrapper .dataTables_paginate .pagination {
    gap: .38rem;
    margin: 0;
}

.dataTables_wrapper .dataTables_paginate .page-item .page-link {
    border: 1px solid #d7e7e1;
    background: #f4f8f6;
    color: #2f554a;
    border-radius: 11px;
    min-width: 2.35rem;
    height: 2.35rem;
    padding: 0 .7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1;
    box-shadow: none;
    transition: all .18s ease;
}

.dataTables_wrapper .dataTables_paginate .page-item .page-link:hover {
    background: #eaf4ef;
    border-color: #c7ddd5;
    color: #24483e;
}

.dataTables_wrapper .dataTables_paginate .page-item.active .page-link {
    color: #fff;
    background: linear-gradient(100deg, var(--brand), var(--brand-2));
    border-color: transparent;
    box-shadow: 0 8px 16px rgba(15, 157, 122, .2);
}

.dataTables_wrapper .dataTables_paginate .page-item.disabled .page-link {
    background: #f6f8f7;
    border-color: #e2ece8;
    color: #99aba4;
    opacity: 1;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: 11px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: linear-gradient(100deg, var(--brand), var(--brand-2)) !important;
    color: #fff !important;
    border-color: transparent !important;
}

.form-control, .form-select {
    border-color: #d5e4de;
    border-radius: 12px;
    padding: .65rem .85rem;
}

.form-control:focus, .form-select:focus {
    border-color: #7ec8af;
    box-shadow: none;
}

.textarea-auto-height {
    min-height: 80px;
    max-height: 180px;
    resize: none;
    overflow: hidden;
}

form.form-submitting-lock {
    pointer-events: none;
}

.btn {
    border-radius: 12px;
    font-weight: 600;
    padding-top: .65rem;
    padding-bottom: .65rem;
}

.btn-header-action {
    padding-top: .45rem;
    padding-bottom: .45rem;
    min-height: 38px;
}

.action-trash-btn {
    border: 0;
    background: transparent;
    padding: 0;
    color: #e11d48;
    line-height: 1;
}

.action-trash-btn:hover,
.action-trash-btn:focus,
.action-trash-btn:focus-visible {
    color: #be123c;
    background: rgba(225, 29, 72, .08);
    box-shadow: none;
    outline: none;
    border-radius: 8px;
}

.action-edit-btn {
    border: 0;
    background: transparent;
    padding: 0;
    color: #0f9d7a;
    line-height: 1;
}

.action-edit-btn:hover,
.action-edit-btn:focus,
.action-edit-btn:focus-visible {
    color: #0d8a6c;
    background: rgba(15, 157, 122, .1);
    box-shadow: none;
    outline: none;
    border-radius: 8px;
}

.letter-type-badge {
    display: inline-flex;
    align-items: center;
    padding: .28rem .62rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .01em;
}

.desc-toggle-btn {
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    vertical-align: baseline;
}

.desc-toggle-btn:hover,
.desc-toggle-btn:focus {
    text-decoration: underline;
}

.badge-letter-outgoing {
    background: #e8f8f2;
    color: #0f8b6f;
    border: 1px solid #bfe7d8;
}

.badge-letter-incoming {
    background: #eef5ff;
    color: #2f66b8;
    border: 1px solid #cfe0ff;
}

.btn-primary {
    background: linear-gradient(100deg, var(--brand), var(--brand-2));
    border: none;
    box-shadow: 0 10px 18px rgba(15, 157, 122, .22);
}

.btn-soft {
    background: #f2f7f5;
    color: #36594f;
    border: 1px solid #d7e7e1;
}

.btn-soft:hover,
.btn-soft:focus,
.btn-soft:focus-visible,
.btn-soft:active {
    background: #e8f2ee;
    color: #2a4a41;
    border-color: #c8ddd5;
}

.sidebar-actions .btn-soft {
    background: rgba(255, 255, 255, .14);
    color: #f8fafc;
    border-color: rgba(255, 255, 255, .2);
    border-radius: 12px;
}

.sidebar-actions .btn-soft:hover,
.sidebar-actions .btn-soft:focus,
.sidebar-actions .btn-soft:focus-visible,
.sidebar-actions .btn-soft:active,
.sidebar-actions .btn-soft.active,
.sidebar-actions .btn-soft.show,
.sidebar-actions .show > .btn-soft.dropdown-toggle,
.sidebar-actions .btn-check:checked + .btn-soft,
.sidebar-actions .btn-check:active + .btn-soft {
    background: rgba(255, 255, 255, .2) !important;
    color: #fff !important;
    border-color: rgba(255, 255, 255, .26) !important;
    box-shadow: none !important;
}

.sidebar-actions {
    border-top: 1px solid rgba(255, 255, 255, .18);
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 1rem 1rem 0;
}

.sidebar-logout-btn {
    border-radius: 12px;
    background: #f1f3f8;
    border: 1px solid #e2e5ee;
}

.sidebar-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: .90rem;
}

body.sidebar-collapsed .app-sidebar {
    width: 86px;
}

body.sidebar-collapsed .app-main {
    margin-left: 86px;
    width: calc(100% - 86px);
}

body.sidebar-collapsed .app-sidebar .nav-text,
body.sidebar-collapsed .app-sidebar .nav-text-wrap {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

body.sidebar-collapsed .app-sidebar .app-nav .nav-link,
body.sidebar-collapsed .app-sidebar .sidebar-actions .btn {
    justify-content: center;
    gap: 0;
}

body.sidebar-collapsed .app-sidebar .brand-box .d-flex {
    justify-content: center;
}

body.sidebar-collapsed .app-sidebar .app-nav .nav-link {
    width: 52px;
    height: 52px;
    margin: 0 auto;
    padding: 0;
    border-radius: 14px;
}

body.sidebar-collapsed .app-sidebar .app-nav .nav-link > i {
    margin: 0;
    line-height: 1;
    font-size: 1.05rem;
}

body.sidebar-collapsed .app-sidebar .app-nav .nav-link:hover .nav-text {
    position: absolute;
    left: 64px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 1;
    width: max-content;
    overflow: visible;
    background: #ffffff;
    color: #334155;
    padding: .55rem .8rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .12);
    z-index: 1200;
}

body.sidebar-collapsed .app-sidebar .app-nav .nav-link:hover .nav-text::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: translateY(-50%) rotate(45deg);
}

body.sidebar-collapsed .app-sidebar .sidebar-actions .btn {
    position: relative;
    width: 52px !important;
    min-width: 52px;
    height: 52px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
    border-radius: 14px;
}

body.sidebar-collapsed .app-sidebar .sidebar-actions .btn i {
    margin: 0;
}

body.sidebar-collapsed .app-sidebar .sidebar-actions .btn .nav-text {
    position: absolute;
    left: 64px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    width: max-content;
    overflow: visible;
    background: #ffffff;
    color: #334155;
    padding: .55rem .8rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .12);
    z-index: 1200;
    pointer-events: none;
}

body.sidebar-collapsed .app-sidebar .sidebar-actions .btn:hover .nav-text {
    opacity: 1;
}

body.sidebar-collapsed .app-sidebar .sidebar-actions .btn .nav-text::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-left: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    transform: translateY(-50%) rotate(45deg);
}

@media (min-width: 992px) {
    body.sidebar-collapsed .app-sidebar {
        overflow: visible;
    }
}

.sidebar-logout-btn:hover,
.sidebar-logout-btn:focus,
.sidebar-logout-btn:active {
    background: #e8ebf3;
    border-color: #d8dce7;
}

.btn-soft.show,
.btn-check:checked + .btn-soft,
.btn-check:active + .btn-soft,
.btn-soft:active:focus,
.btn-soft.active,
.show > .btn-soft.dropdown-toggle {
    background: #e8f2ee;
    color: #2a4a41;
    border-color: #c8ddd5;
    box-shadow: none;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

h2 {
    margin-bottom: .9rem;
    padding-bottom: .1rem;
}

.card-header-line {
    border-bottom: 1px solid var(--border-soft);
    padding: .8rem 1rem .8rem;
    margin: -1rem -1rem 1rem;
}

.card-header-line h2 {
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-header-line {
    border-bottom: 1px solid var(--border-soft);
    padding: 1rem 1.25rem;
}

.modal .btn-close,
.modal .btn-close:focus,
.modal .btn-close:active {
    box-shadow: none !important;
    outline: none;
}

.muted {
    color: var(--text-muted);
}

.login-page {
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    background: radial-gradient(circle at top left, #e7f2ee 0%, #edf6f2 35%, #f7fbf9 100%);
}

.login-page .login-panel {
    border: 1px solid #dbe8e2;
    border-radius: 24px;
    box-shadow: 0 18px 45px rgba(17, 24, 39, .09);
    overflow: hidden;
    background: #fff;
}

.login-page .login-panel-compact {
    max-width: 450px;
}

.login-page .login-form {
    background: #fff;
}

.login-page .form-control {
    border-color: #d5e4de;
    border-radius: 12px;
    padding: .65rem .85rem;
}

.login-page .form-control:focus {
    border-color: #7ec8af;
    box-shadow: none;
}

.login-page .btn-primary {
    border: none;
    border-radius: 12px;
    background: linear-gradient(100deg, #0f9d7a, #22b07d);
    box-shadow: 0 10px 18px rgba(15, 157, 122, .22);
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .app-main {
        margin-left: 0;
        width: 100%;
    }

    .app-sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

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

    body.sidebar-mobile-open .app-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    body.sidebar-collapsed .app-main {
        margin-left: 0;
        width: 100%;
    }

    .topbar-mobile-brand,
    .topbar-mobile-divider {
        display: inline-flex;
    }

    .content-card .table-responsive {
        overflow-x: auto;
    }
}

@media (min-width: 768px) {
    .card-header-line {
        padding-top: 1rem;
        padding-bottom: 1rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
        margin-left: -1.5rem;
        margin-right: -1.5rem;
    }
}
