:root {
    --pm-primary: #157347;
    --pm-primary-dark: #10291d;
    --pm-teal: #28A966;
    --pm-light: #EAF8EF;
    --pm-bg: #F5FAF7;
    --pm-card: #FFFFFF;
    --pm-danger: #EF4444;
    --pm-warning: #FACC15;
    --pm-text: #17211B;
    --pm-muted: #647067;
    --pm-border: #DFE8E2;
    --pm-shadow: 0 18px 45px rgba(16, 41, 29, .10);
    --pm-soft-shadow: 0 10px 30px rgba(16, 41, 29, .06);
    --pm-radius: 22px;
    --pm-radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 8% 8%, rgba(87, 199, 133, .13), transparent 26%),
        linear-gradient(180deg, #F8FCFA 0%, var(--pm-bg) 42%, #EEF7F2 100%);
    color: var(--pm-text);
    font-family: "Segoe UI", "Aptos", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: .92rem;
}

[data-bs-theme="dark"] body {
    background: #0f172a;
    color: #E5E7EB;
}

[data-bs-theme="dark"] .app-shell,
[data-bs-theme="dark"] .app-content {
    background: #0f172a;
}

[data-bs-theme="dark"] .app-topbar,
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .pm-card,
[data-bs-theme="dark"] .dropdown-menu {
    background: #111827 !important;
    color: #E5E7EB;
    border-color: #243244;
}

[data-bs-theme="dark"] .table thead th {
    background: #172033;
    color: #CBD5E1;
    border-color: #243244;
}

[data-bs-theme="dark"] .table tbody tr:hover {
    background: #162235;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .btn-light {
    background-color: #0B1220;
    color: #E5E7EB;
    border-color: #334155;
}

[data-bs-theme="dark"] .text-secondary,
[data-bs-theme="dark"] .muted {
    color: #9CA3AF !important;
}

a {
    text-decoration: none;
}

img,
svg {
    max-width: 100%;
}

.app-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 8%, rgba(87, 199, 133, .12), transparent 28%),
        linear-gradient(180deg, #F8FCFA 0%, var(--pm-bg) 48%, #EEF7F2 100%);
}

.app-sidebar {
    width: 270px;
    height: 100vh;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 18% 8%, rgba(87,199,133,.22), transparent 25%),
        linear-gradient(180deg, #10291d 0%, #0b2118 100%);
    color: #D9F7EF;
    z-index: 1040;
    box-shadow: 8px 0 24px rgba(11, 47, 58, .14);
}

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

body.sidebar-collapsed .app-brand {
    justify-content: center;
    padding: 0 12px;
}

body.sidebar-collapsed .app-brand span:not(.app-brand-icon),
body.sidebar-collapsed .sidebar-link span,
body.sidebar-collapsed .sidebar-section,
body.sidebar-collapsed .sidebar-submenu,
body.sidebar-collapsed .sidebar-chevron {
    display: none;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
    margin-inline: 12px;
    padding: 12px;
}

body.sidebar-collapsed .app-main {
    margin-left: 84px;
}

.app-brand {
    height: 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    color: #fff;
}

.app-brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-teal));
    color: #fff;
    font-size: 20px;
    overflow: hidden;
    padding: 4px;
}

.app-brand-icon img,
.auth-logo img,
.dawa-loader-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.app-brand-name {
    display: block;
    color: #fff;
    font-weight: 800;
    letter-spacing: .2px;
}

.app-brand-sub {
    color: rgba(255, 255, 255, .62);
    font-size: 12px;
}

.sidebar-section {
    padding: 18px 22px 8px;
    color: rgba(255, 255, 255, .48);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 14px;
    padding: 11px 12px;
    border-radius: 16px;
    color: rgba(255, 255, 255, .78);
    font-weight: 650;
}

.sidebar-toggle-link {
    width: calc(100% - 28px);
    border: 0;
    background: transparent;
    text-align: left;
}

.sidebar-submenu {
    margin: 2px 14px 8px 48px;
}

.sidebar-sublink {
    display: block;
    color: rgba(255, 255, 255, .68);
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 650;
}

.sidebar-sublink:hover,
.sidebar-sublink.active {
    color: #fff;
    background: rgba(21, 154, 104, .18);
}

.sidebar-link:hover,
.sidebar-link.active {
    color: #fff;
    background: rgba(21, 154, 104, .22);
}

.sidebar-link.active {
    box-shadow: inset 4px 0 0 #57c785, 0 10px 22px rgba(0,0,0,.12);
}

.sidebar-link i {
    width: 22px;
    font-size: 18px;
    text-align: center;
}

.app-main {
    margin-left: 270px;
    min-height: 100vh;
}

.app-topbar {
    min-height: 72px;
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--pm-border);
    padding: 14px 28px;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--pm-text);
    font-weight: 800;
    white-space: nowrap;
}

.topbar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--pm-primary), var(--pm-teal));
    padding: 3px;
    flex: 0 0 auto;
}

.topbar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.topbar-brand-text {
    line-height: 1.1;
}

.topbar-brand-text small {
    display: block;
    color: var(--pm-muted);
    font-weight: 650;
    letter-spacing: .02em;
}

.app-content {
    padding: 28px;
}

.top-search {
    max-width: 460px;
}

.top-search .form-control {
    border-radius: 999px;
    padding-left: 42px;
}

.top-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--pm-muted);
    z-index: 2;
}

.global-search-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 1060;
    background: #fff;
    border: 1px solid var(--pm-border);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .12);
    border-radius: 20px;
    max-height: 360px;
    overflow-y: auto;
}

.global-search-panel.open {
    display: block;
}

.global-search-item {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    color: var(--pm-text);
    border-bottom: 1px solid #EEF2F0;
    text-decoration: none;
}

.global-search-item:last-child {
    border-bottom: 0;
}

.global-search-item:hover,
.global-search-item.active {
    background: #EAF7F0;
    color: var(--pm-text);
}

.global-search-item-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    background: #E8F4EE;
    color: var(--pm-primary);
    border: 1px solid #B9D7C8;
    border-radius: 14px;
}

.global-search-item-title {
    font-weight: 750;
    line-height: 1.2;
}

.global-search-item-desc {
    color: var(--pm-muted);
    font-size: 12px;
    margin-top: 2px;
}

.global-search-empty {
    padding: 16px;
    color: var(--pm-muted);
    font-size: 13px;
}

[data-bs-theme="dark"] .global-search-panel {
    background: #111827;
    border-color: #243244;
}

[data-bs-theme="dark"] .global-search-item {
    color: #E5E7EB;
    border-bottom-color: #243244;
}

[data-bs-theme="dark"] .global-search-item:hover,
[data-bs-theme="dark"] .global-search-item.active {
    background: #162235;
    color: #F8FAFC;
}

[data-bs-theme="dark"] .global-search-item-icon {
    background: #0B1220;
    border-color: #334155;
}

.card,
.pm-card {
    background: var(--pm-card);
    border: 1px solid var(--pm-border);
    border-radius: var(--pm-radius);
    box-shadow: var(--pm-soft-shadow);
}

.card-header {
    border-bottom-color: var(--pm-border);
    background: rgba(255,255,255,.78);
    border-radius: var(--pm-radius) var(--pm-radius) 0 0 !important;
}

.btn {
    border-radius: 999px;
    font-weight: 750;
}

.btn-primary,
.primary {
    --bs-btn-bg: #1A7F4E;
    --bs-btn-border-color: #1A7F4E;
    --bs-btn-hover-bg: #146A41;
    --bs-btn-hover-border-color: #146A41;
    --bs-btn-focus-shadow-rgb: 21, 115, 71;
    color: #fff !important;
    box-shadow: 0 12px 24px rgba(21, 115, 71, .22);
}

.btn-outline-primary {
    --bs-btn-color: var(--pm-primary);
    --bs-btn-border-color: var(--pm-primary);
    --bs-btn-hover-bg: var(--pm-primary);
    --bs-btn-hover-border-color: var(--pm-primary);
}

.text-primary {
    color: var(--pm-primary) !important;
}

.bg-primary {
    background-color: var(--pm-primary) !important;
}

.border-primary {
    border-color: var(--pm-primary) !important;
}

.text-secondary,
.muted {
    color: var(--pm-muted) !important;
}

.form-label {
    color: var(--pm-text);
    font-weight: 700;
    margin-bottom: 7px;
}

.form-control,
.form-select {
    border: 1px solid #D7DEE8;
    border-radius: var(--pm-radius-sm);
    min-height: 44px;
    color: var(--pm-text);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--pm-primary);
    box-shadow: 0 0 0 .22rem rgba(21, 154, 104, .14);
}

.form-check-input:checked {
    background-color: var(--pm-primary);
    border-color: var(--pm-primary);
}

.table-card {
    overflow: hidden;
    border-radius: var(--pm-radius);
}

.table {
    margin-bottom: 0;
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #F8FCFA;
    color: var(--pm-muted);
    border-bottom: 1px solid var(--pm-border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 800;
}

.table tbody tr:hover {
    background: #F8FFFC;
}

.alert,
.dropdown-menu,
.modal-content,
.input-group-text,
.page-link,
.list-group-item {
    border-radius: var(--pm-radius-sm);
}

.modal-content {
    border: 1px solid var(--pm-border);
    box-shadow: 0 26px 80px rgba(16, 41, 29, .22);
}

.badge {
    border-radius: 999px;
}

.status,
.pill-soft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--pm-light);
    color: var(--pm-primary);
    font-size: 12px;
    font-weight: 750;
}

.notice {
    background: var(--pm-light);
    border: 1px solid rgba(21, 154, 104, .2);
    color: #0F5132;
    padding: 13px 15px;
    border-radius: 14px;
    margin-bottom: 16px;
}

.simple-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.dashboard-focus {
    border-left: 4px solid var(--pm-primary);
}

.field-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--pm-primary);
    font-size: 13px;
    vertical-align: middle;
    cursor: help;
}

.field-help-icon:focus {
    outline: 2px solid rgba(21, 154, 104, .35);
    outline-offset: 2px;
}

.metric-card {
    border-left: 4px solid var(--pm-primary);
}

.metric-card.warning {
    border-left-color: var(--pm-warning);
}

.metric-card.info {
    border-left-color: var(--pm-teal);
}

.metric-card.danger {
    border-left-color: var(--pm-danger);
}

.icon-shape,
.metric-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-md,
.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
}

.metric-icon {
    background: var(--pm-light);
    color: var(--pm-primary);
    font-size: 20px;
}

.product-card,
.medicine-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-card:hover,
.medicine-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 42px rgba(15, 23, 42, .10);
}

.product-avatar,
.medicine-avatar {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, rgba(21,154,104,.16), rgba(14,165,164,.14));
    color: var(--pm-primary);
    font-weight: 800;
}

.price-line {
    font-size: 22px;
    font-weight: 850;
    color: var(--pm-primary);
}

.empty-state {
    padding: 44px 20px;
    text-align: center;
    color: var(--pm-muted);
}

.empty-state i {
    font-size: 42px;
    color: var(--pm-primary);
    margin-bottom: 12px;
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 80% 16%, rgba(87, 199, 133, .15), transparent 24%),
        linear-gradient(135deg, #F8FCFA 0%, #EFF8F3 100%);
}

.auth-panel {
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 18%, rgba(87,199,133,.30), transparent 26%),
        radial-gradient(circle at 86% 75%, rgba(255,255,255,.14), transparent 24%),
        linear-gradient(145deg, #10291D, #157347);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.auth-panel::after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    right: -90px;
    top: -70px;
    border-radius: 50%;
    border: 36px solid rgba(255,255,255,.10);
}

.auth-logo {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.16);
    font-size: 28px;
    overflow: hidden;
    padding: 6px;
}

.auth-card {
    width: min(100%, 520px);
    border-radius: 30px;
    border: 1px solid var(--pm-border);
    box-shadow: 0 24px 70px rgba(16, 41, 29, .14);
}

.auth-card .btn-primary {
    padding-block: .8rem;
}

.navbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--pm-light);
    color: var(--pm-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.sidebar-backdrop {
    display: none;
}

.public {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
    }

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

    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .48);
        z-index: 1035;
    }

    .app-main {
        margin-left: 0;
    }

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

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

    body.sidebar-collapsed .app-brand span:not(.app-brand-icon),
    body.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-section,
    body.sidebar-collapsed .sidebar-submenu,
    body.sidebar-collapsed .sidebar-chevron {
        display: initial;
    }

    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start;
        margin: 4px 14px;
        padding: 11px 12px;
    }

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

    .app-content {
        padding: 18px;
    }

    .simple-page-header {
        display: block;
    }

    .simple-page-header .btn {
        margin-top: 8px;
    }

    .top-search {
        display: none;
    }

    .auth-panel {
        min-height: 300px;
    }
}

@media (max-width: 767.98px) {
    .btn,
    .form-control,
    .form-select {
        min-height: 44px;
    }

    .table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-card > .table {
        min-width: 720px;
    }

    .modal-dialog {
        margin: .75rem;
    }

    .public {
        padding: 22px 14px;
    }
}
