:root {
    --bg-app: #f8f8f9;
    --bg-sidebar: #f3f3f4;
    --bg-card: #ffffff;
    --bg-muted: #f1f1f3;
    --text-main: #141414;
    --text-body: #515151;
    --text-soft: #8d8d8d;
    --border: #e3e3e6;
    --primary: #595d9a;
    --primary-soft: #ececff;
    --success: #3f8a55;
    --warning: #b07a2e;
    --danger: #aa4c4c;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-app);
    color: var(--text-main);
    font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
}

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

.layout-shell {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 100vh;
}

.app-sidebar {
    border-right: 1px solid var(--border);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 16px;
    gap: 24px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
}

.brand-mark {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: #000;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.86rem;
}

.brand-text {
    font-weight: 600;
    font-size: 1.04rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    text-decoration: none;
    color: var(--text-body);
    font-weight: 500;
    border-radius: 8px;
    padding: 10px 10px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.sidebar-link i {
    font-size: 1rem;
}

.sidebar-link:hover {
    background: #ececee;
    color: #262626;
}

.sidebar-link.active {
    background: #e9e9eb;
    color: #000;
    font-weight: 600;
}

.sidebar-user {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #d9d9dd;
    color: #333;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.sidebar-user-meta strong {
    font-size: 0.83rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-meta span {
    font-size: 0.72rem;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: 72px;
    border-bottom: 1px solid var(--border);
    background: #f6f6f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 14px;
}

.topbar-search {
    width: min(420px, 100%);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #cfcfd4;
    border-radius: 10px;
    height: 42px;
    padding: 0 12px;
    background: #f2f2f3;
    color: #8a8a8f;
}

.topbar-search input {
    border: 0;
    background: transparent;
    width: 100%;
    outline: none;
    color: #4f4f55;
    font-size: 0.93rem;
}

.topbar-right {
    display: inline-flex;
    align-items: center;
    gap: 16px;
}

.topbar-help {
    color: #5d5d63;
    font-size: 0.9rem;
}

.topbar-user {
    border: 1px solid #dadadd;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.86rem;
    background: #fff;
}

.app-content {
    padding: 24px;
}

.page-title {
    font-size: 2.05rem;
    line-height: 1.15;
    font-weight: 600;
    margin: 0;
}

.page-subtitle {
    color: var(--text-soft);
    font-size: 0.95rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: none !important;
}

.card-title {
    font-weight: 600;
}

.btn {
    border-radius: 9px;
    font-weight: 500;
}

.btn-primary {
    background: #000;
    border-color: #000;
}

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

.btn-success {
    background: #000;
    border-color: #000;
}

.btn-outline-primary {
    color: #000;
    border-color: #c9c9ce;
}

.btn-outline-primary:hover {
    color: #000;
    background: #ededf0;
    border-color: #bfc0c7;
}

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: 0.85rem 0.78rem;
    border-color: #ececef;
}

.table thead th {
    font-size: 0.77rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #8d8d92;
    font-weight: 600;
    border-bottom-width: 1px;
}

.table tbody td {
    color: #3f3f42;
}

.badge {
    border-radius: 8px;
    padding: 0.45rem 0.58rem;
    font-size: 0.74rem;
    font-weight: 600;
}

.bg-primary {
    background-color: #6468a1 !important;
}

.bg-secondary {
    background-color: #8e8e95 !important;
}

.bg-success {
    background-color: #628e67 !important;
}

.bg-warning {
    background-color: #cfaf6f !important;
}

.bg-danger {
    background-color: #ac5b5b !important;
}

.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: 6px;
}

.nav-tabs .nav-link {
    border: 0;
    border-radius: 10px 10px 0 0;
    color: #7f7f84;
    font-weight: 500;
    padding: 0.7rem 1rem;
}

.nav-tabs .nav-link.active {
    color: #1e1e1e;
    background: #efeff1;
}

.form-control,
.form-select {
    border-radius: 9px;
    border-color: #d8d8de;
    color: #3f3f45;
}

.form-control:focus,
.form-select:focus {
    border-color: #b7b8c5;
    box-shadow: 0 0 0 0.2rem rgba(89, 93, 154, 0.12);
}

.swal2-popup {
    border-radius: 14px;
}

.swal-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 1fr;
}

.swal-grid .full {
    grid-column: span 2;
}

.swal-grid input,
.swal-grid textarea,
.swal-grid select {
    width: 100%;
    border: 1px solid #d6d7e0;
    border-radius: 8px;
    padding: 0.56rem 0.68rem;
    font-size: 0.94rem;
    background: #fff;
}

.totals-grid {
    display: grid;
    gap: 0.38rem;
}

.totals-grid > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.93rem;
}

.totals-grid > div span {
    color: var(--text-soft);
}

.totals-grid .total-final {
    margin-top: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px dashed #d9d9de;
    font-weight: 600;
}

.totals-grid .total-final strong {
    color: #1f1f22;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
}

@media (max-width: 992px) {
    .layout-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding-bottom: 14px;
        gap: 12px;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-user {
        display: none;
    }

    .app-topbar {
        padding: 0 14px;
    }

    .topbar-help,
    .topbar-user {
        display: none;
    }

    .app-content {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .swal-grid {
        grid-template-columns: 1fr;
    }

    .swal-grid .full {
        grid-column: span 1;
    }

    .btn-group {
        flex-wrap: wrap;
    }

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