:root {
    --bs-font-sans-serif: "Noto Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, -apple-system, sans-serif;
    --bs-body-bg: #eef1f4;
    --bs-body-color: #16212b;
    --bs-border-radius: .625rem;
    --bs-border-radius-sm: .5rem;
    --bs-border-radius-lg: .875rem;
    --bs-border-color: #dce3e8;

    --bs-primary: #2f5fe6;
    --bs-primary-rgb: 47, 95, 230;
    --bs-secondary: #5b6b7a;
    --bs-secondary-rgb: 91, 107, 122;
    --bs-success: #1e8f5c;
    --bs-success-rgb: 30, 143, 92;
    --bs-warning: #c99a2e;
    --bs-warning-rgb: 201, 154, 46;
    --bs-danger: #c0392e;
    --bs-danger-rgb: 192, 57, 46;
    --bs-info: #5b8def;
    --bs-info-rgb: 91, 141, 239;

    --bs-link-color: #2f5fe6;
    --bs-link-color-rgb: 47, 95, 230;
    --bs-link-hover-color: #1f45b8;
    --bs-link-hover-color-rgb: 31, 69, 184;

    --app-ink: #0d0f17;
    --app-accent: #2f5fe6;
    --app-accent-light: #5b8def;
    --app-line: #dce3e8;
    --app-text-muted: #5b6b7a;
}

body {
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   App shell layout (sidebar + main), replaces Bootstrap grid
   ============================================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

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

.app-content {
    padding: 22px 26px 40px;
    flex: 1;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--app-ink);
    display: flex;
    flex-direction: column;
    padding: 18px 14px 16px;
    gap: 4px;
}

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

.brand-mark {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.brand-mark svg {
    width: 26px;
    height: 26px;
}

.brand-text {
    font-size: 16.5px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -.01em;
}

.brand-text .accent {
    color: var(--app-accent-light);
}

.brand-tagline {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .18em;
    color: #5f7386;
    margin-top: 1px;
}

/* Standalone brand lockup used on auth pages (login/signup/suspended) */
.auth-brand-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--app-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.auth-brand-icon svg {
    width: 30px;
    height: 30px;
}

.auth-brand-text {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    letter-spacing: -.01em;
    color: var(--app-ink);
}

.auth-brand-text .accent {
    color: var(--app-accent);
}

.auth-brand-tagline {
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .2em;
    color: var(--app-text-muted);
    margin-bottom: 18px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-group-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #5f7386;
    font-weight: 700;
    padding: 12px 10px 4px;
}

.nav-group-label:first-child {
    padding-top: 2px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .75rem;
    border-radius: .5rem;
    color: #aebdca !important;
    font-size: .92rem;
    border-left: 3px solid transparent;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.app-nav-link:hover {
    background: rgba(255, 255, 255, .06);
    color: #e7ecf0 !important;
}

.app-nav-link.active {
    background: rgba(47, 95, 230, .2);
    color: #fff !important;
    font-weight: 600;
    border-left-color: var(--app-accent);
}

.app-nav-link svg {
    width: 17px;
    height: 17px;
    flex: none;
    opacity: .9;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
}

.user-chip .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #22344a;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex: none;
}

.user-chip .who {
    line-height: 1.25;
    min-width: 0;
}

.user-chip .who b {
    display: block;
    font-size: 12.6px;
    color: #e7ecf0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-chip .who span {
    font-size: 11px;
    color: #8ea2b3;
}

/* ---------- Topbar ---------- */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 26px;
    background: #fff;
    border-bottom: 1px solid var(--app-line);
}

.topbar-crumb {
    font-size: 11.5px;
    color: var(--app-text-muted);
    letter-spacing: .02em;
    margin-bottom: 1px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid var(--app-line);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--app-text-muted);
    cursor: pointer;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
}

/* ---------- Cards & surfaces ---------- */
.card {
    border-color: rgba(16, 28, 43, .06);
    box-shadow: 0 1px 2px rgba(16, 28, 43, .04), 0 8px 20px -14px rgba(16, 28, 43, .25);
}

.card-header {
    font-weight: 700;
    font-size: .92rem;
}

/* ---------- Tables ---------- */
.table thead th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    color: #5b6b7a;
    font-weight: 700;
    border-bottom-width: 1px;
}

.table td, .table th {
    vertical-align: middle;
}

/* ---------- Badges (status pills) ---------- */
.badge {
    border-radius: 999px;
    font-weight: 600;
    padding: .42em .75em;
    font-size: .76rem;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: .5rem;
    font-weight: 600;
}

.btn-sm {
    border-radius: .45rem;
}

/* ---------- Banners (payable/receivable style alerts) ---------- */
.alert {
    border-radius: .625rem;
    font-size: .87rem;
}

.alert-warning {
    background-color: #faf1dd;
    border-color: rgba(201, 154, 46, .35);
    color: #16212b;
}

.alert-success {
    background-color: #e2f5ec;
    border-color: rgba(30, 143, 92, .35);
    color: #16212b;
}

/* ---------- Stat tiles ---------- */
.stat-tile-icon {
    width: 34px;
    height: 34px;
    border-radius: .55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.stat-tile-icon svg {
    width: 17px;
    height: 17px;
}

/* ---------- Process stepper ---------- */
.process-stepper > div {
    min-width: 140px;
    border-radius: .5rem;
}

/* ---------- Mobile sidebar drawer ---------- */
@media (max-width: 767.98px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1045;
        width: 260px;
        max-width: 82vw;
        transform: translateX(-100%);
        transition: transform .2s ease-in-out;
        overflow-y: auto;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    }

    .app-sidebar.show {
        transform: translateX(0);
        box-shadow: 12px 0 30px rgba(0, 0, 0, .25);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(16, 28, 43, .45);
        z-index: 1040;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .app-topbar {
        padding: 12px 16px;
    }

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