:root {
    --app-bg: #f4f7fb;
    --app-surface: #ffffff;
    --app-surface-soft: #f8fafc;
    --app-border: #dce3ec;
    --app-text: #1f2937;
    --app-muted: #64748b;
    --app-primary: #2563eb;
    --app-primary-dark: #1d4ed8;
    --app-warning: #e1ac08;
    --app-success: #16a34a;
    --app-danger: #dc2626;
    --app-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    --app-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

a {
    color: var(--app-primary);
}

a:hover {
    color: var(--app-primary-dark);
}

.navbar.app-navbar {
    background: #172033 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.navbar-brand {
    letter-spacing: 0;
}

.app-brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    color: #fff;
}

.navbar-nav {
    gap: 4px;
}

.navbar-nav .nav-link {
    min-width: 38px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 10px !important;
    margin: 0;
    border: 1px solid transparent !important;
    border-radius: 6px !important;
    color: #cbd5e1 !important;
    background: transparent;
    font-size: 15px;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.navbar-nav .nav-link:hover {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.08);
}

.navbar-nav .nav-link.active {
    color: #fff !important;
    background: rgba(37, 99, 235, 0.26);
    border-color: rgba(96, 165, 250, 0.38) !important;
}

.nav-label {
    display: none;
    font-size: 13px;
    font-weight: 700;
}

.app-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 6px;
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.06);
}

.container-bg {
    background: transparent;
}

.min-height {
    min-height: calc(100vh - 112px);
}

main .container-fluid.min-height {
    padding-top: 14px;
    padding-bottom: 22px;
}

.card,
.admin-panel,
.message-wrapper,
.save-package-card {
    border: 1px solid var(--app-border) !important;
    border-radius: 6px !important;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-sm);
}

.card-header,
.card-header-custom,
.admin-nav,
.message-header {
    background: var(--app-surface-soft) !important;
    border-bottom: 1px solid var(--app-border) !important;
}

.admin-nav,
.message-header {
    min-height: 48px;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.admin-content,
.message-body {
    background: var(--app-surface);
}

.panel-title,
.header-title {
    color: var(--app-text) !important;
    font-weight: 800 !important;
    letter-spacing: 0;
}

.nav-pill-btn,
.btn-tab {
    min-height: 34px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 6px !important;
    border: 1px solid var(--app-border) !important;
    background: #fff !important;
    color: #334155 !important;
    font-weight: 700;
    text-decoration: none !important;
    box-shadow: none !important;
}

.nav-pill-btn:hover,
.btn-tab:hover {
    color: var(--app-primary) !important;
    border-color: #bfdbfe !important;
    background: #eff6ff !important;
}

.nav-pill-btn.active,
.btn-tab.active,
.nav-status-badge {
    background: var(--app-primary) !important;
    border-color: var(--app-primary) !important;
    color: #fff !important;
}

.close-link,
.btn-close-custom {
    min-width: 34px;
    min-height: 34px;
    border-radius: 6px !important;
    border: 1px solid #fecaca !important;
    background: #fff1f2 !important;
    color: var(--app-danger) !important;
}

.close-link:hover,
.btn-close-custom:hover {
    background: var(--app-danger) !important;
    color: #fff !important;
}

.table {
    margin-bottom: 0;
    color: var(--app-text);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 10px 9px;
    border-color: #e5eaf1;
}

.table thead,
.table-light {
    background: #f1f5f9 !important;
    color: #334155;
}

.table th {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.table-hover tbody tr:hover {
    background-color: #f8fbff;
}

.form-control,
.form-select,
.input-group-text {
    border-color: #cbd5e1;
    border-radius: 6px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.18rem rgba(37, 99, 235, 0.14);
}

.input-group .form-control,
.input-group .form-select,
.input-group .input-group-text,
.input-group .btn {
    border-radius: 0;
}

.input-group > :first-child {
    border-top-left-radius: 6px !important;
    border-bottom-left-radius: 6px !important;
}

.input-group > :last-child {
    border-top-right-radius: 6px !important;
    border-bottom-right-radius: 6px !important;
}

.btn {
    border-radius: 6px;
    font-weight: 700;
}

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

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

.btn-warning {
    background: var(--app-warning);
    border-color: var(--app-warning);
    color: #172033;
}

.btn-outline-secondary {
    border-color: #cbd5e1;
}

.badge {
    border-radius: 5px;
    font-weight: 800;
}

.alert {
    border-radius: 6px;
    border-width: 1px;
}

.menu-card {
    text-shadow: none !important;
    border-color: var(--app-border);
    border-radius: 6px;
    background: #fff;
    box-shadow: var(--app-shadow-sm);
}

.menu-body {
    background: #f8fafc;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.menu-icon {
    color: var(--app-primary);
}

.menu-footer {
    background: #172033 !important;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

.footer {
    padding: 10px 0 14px;
    background: transparent;
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        padding-top: 10px;
    }

    .navbar-nav .nav-link {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-label {
        display: inline;
    }

    .app-user-chip {
        width: 100%;
        margin: 8px 0;
        justify-content: center;
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 13px;
    }

    main .container-fluid.min-height {
        padding-left: 8px;
        padding-right: 8px;
    }

    .admin-content,
    .message-body {
        padding: 12px !important;
    }

    .table > :not(caption) > * > * {
        padding: 8px 7px;
    }
}

/* ── Mobile navbar: scrollable collapsed menu ── */
@media (max-width: 991.98px) {
    .navbar-collapse.show .navbar-nav {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.2) transparent;
    }
    .navbar-collapse.show .navbar-nav::-webkit-scrollbar { width: 4px; }
    .navbar-collapse.show .navbar-nav::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 2px;
    }
}

/* ── Responsive tables on mobile ── */
@media (max-width: 575px) {
    .table-responsive-stack tr { display: block; border-bottom: 2px solid #e5eaf4; }
    .table-responsive-stack td { display: flex; justify-content: space-between; padding: 6px 8px; border: none; }
    .table-responsive-stack td::before { content: attr(data-label); font-weight: 700; color: #64748b; flex-shrink: 0; margin-right: 8px; }
}

/* ── Better focus for accessibility ── */
:focus-visible {
    outline: 2px solid var(--app-primary);
    outline-offset: 2px;
}

/* ── Smooth scrolling ── */
html { scroll-behavior: smooth; }
