:root {
    --brand: #0f4c81;
    --brand-dark: #0a355f;
    --surface: #ffffff;
    --soft: #f6f8fb;
    --text: #1f2937;
    --muted: #64748b;
    --border: rgba(15, 76, 129, 0.14);
}

/* Nested dropdown submenu (e.g. PPC > Production Order Report > ...).
   Bootstrap 5 has no built-in support for this; each nested toggle still
   auto-initializes as its own dropdown scoped to its .dropdown-submenu
   parent, this just positions the flyout and closes it via CSS/JS. */
.dropdown-submenu {
    position: relative;
}
.dropdown-submenu > .dropdown-menu {
    top: -0.5rem;
    left: 100%;
    margin-left: 0.35rem;
}
.dropdown-submenu > a.dropdown-toggle::after {
    transform: rotate(-90deg);
    margin-left: 0.5rem;
}

/* Top navbar: recolored to the app's own brand gradient instead of generic
   Bootstrap dark, matching the sidebar/page-shell brand elsewhere. */
.app-navbar {
    background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand) 100%);
}

/* Footer: same brand gradient as the navbar so the page is bookended by a
   consistent color, instead of generic Bootstrap dark. */
.app-footer {
    background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand) 100%);
}

.app-footer a {
    transition: color 0.15s ease;
}

.app-footer a:hover,
.app-footer a:focus {
    color: #ffffff !important;
}

.app-navbar .nav-link {
    border-radius: 8px;
    padding: 0.5rem 0.8rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .show > .nav-link {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
}

/* Dropdown/submenu open on click only (Bootstrap's default data-bs-toggle
   behavior, same on touch and pointer devices) — this just adds a fade/
   slide transition for the open, scoped to fine-pointer devices so touch
   doesn't get a stuck mid-transition state. */
@media (hover: hover) and (pointer: fine) {
    .app-navbar .dropdown-menu {
        display: block;
        opacity: 0;
        visibility: hidden;
        transform: translateY(6px);
        pointer-events: none;
        transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    }

    .app-navbar .dropdown-submenu > .dropdown-menu {
        transform: translateY(0) translateX(6px);
    }

    .app-navbar .dropdown-menu.show {
        opacity: 1;
        visibility: visible;
        transform: none;
        pointer-events: auto;
    }
}

/* Dropdown menu design: rounded, shadowed, spaced-out — consistent with
   the rest of the app's brand styling (card/page-shell radii and shadows)
   rather than Bootstrap's plain square default. */
.app-navbar .dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: 0 16px 32px rgba(10, 53, 95, 0.18);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.app-navbar .dropdown-submenu > .dropdown-menu {
    margin-top: 0;
}

.app-navbar .dropdown-item {
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    font-size: 0.92rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.app-navbar .dropdown-item:hover,
.app-navbar .dropdown-item:focus,
.app-navbar .dropdown-item.dropdown-toggle.show {
    background: var(--soft);
    color: var(--brand-dark);
}

.app-navbar .dropdown-item:active {
    background: var(--brand);
    color: #ffffff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f6f8fb 0%, #eef4fb 100%);
    color: var(--text);
    min-height: 100vh;
}

main {
    padding-top: 0.5rem;
}

.navbar-brand-logo {
    background: #fff;
    padding: 4px 12px;
    border-radius: 6px;
}

.app-shell {
    display: flex;
    flex: 1;
    min-height: 0;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar {
    width: 260px;
    min-width: 260px;
    background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand) 100%);
    color: #ffffff;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: calc(100vh - 56px);
    overflow-y: auto;
    box-shadow: 0 12px 30px rgba(10, 53, 95, 0.2);
}

.sidebar .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar .brand span {
    color: #d7e8fb;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    margin-bottom: 0.35rem;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar i {
    font-size: 1rem;
}

.page-shell {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 16px 40px rgba(15, 76, 129, 0.08);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-title {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--brand-dark);
    margin: 0;
}

.page-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.page-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(15, 76, 129, 0.12);
    color: var(--brand-dark);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.content-stack > * + * {
    margin-top: 1rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(15, 76, 129, 0.06);
}

.card-header {
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.btn {
    border-radius: 10px;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid #dbe4ef;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(15, 76, 129, 0.12);
}

.table th {
    color: #475569;
    font-weight: 600;
}

.table td {
    vertical-align: middle;
}

@media (max-width: 992px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: static;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.5rem;
    }

    .sidebar .brand {
        grid-column: 1 / -1;
        margin-bottom: 0.4rem;
    }

    .sidebar a {
        margin-bottom: 0;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
    }

    .page-shell {
        padding: 1rem;
    }
}
