:root {
    --bg-body: #f4f7fa;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --primary-blue: #3b82f6;
    /* Theme Colors for Gradients & Borders */
    --theme-green: #22c55e;
    --bg-green-light: #f0fdf4;
    --theme-purple: #6366f1;
    --bg-purple-light: #eef2ff;
    --theme-orange: #f59e0b;
    --bg-orange-light: #fffbeb;
    --theme-cyan: #06b6d4;
    --bg-cyan-light: #ecfeff;
}



/* --- Page Header --- */
.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    color: #111827;
}

.page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn-outline-custom {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

    .btn-outline-custom:hover {
        background: #f9fafb;
        color: var(--text-main);
    }

.btn-primary-custom {
    background: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    .btn-primary-custom:hover {
        background: #2563eb;
        color: #fff;
    }

/* --- KPI Cards --- */
.kpi-card-topranking {
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    border: 1px solid var(--border-color);
}

/* Gradients and Borders */
.kpi-green {
    border-left: 4px solid var(--theme-green);
    background: linear-gradient(90deg, var(--bg-green-light) 0%, #ffffff 80%);
}

.kpi-purple {
    border-left: 4px solid var(--theme-purple);
    background: linear-gradient(90deg, var(--bg-purple-light) 0%, #ffffff 80%);
}

.kpi-orange {
    border-left: 4px solid var(--theme-orange);
    background: linear-gradient(90deg, var(--bg-orange-light) 0%, #ffffff 80%);
}

.kpi-cyan {
    border-left: 4px solid var(--theme-cyan);
    background: linear-gradient(90deg, var(--bg-cyan-light) 0%, #ffffff 80%);
}

.kpi-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #111827;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.kpi-icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.kpi-green .kpi-icon-wrapper {
    color: var(--theme-green);
    border: 1px solid #bbf7d0;
}

.kpi-purple .kpi-icon-wrapper {
    color: var(--theme-purple);
    border: 1px solid #c7d2fe;
}

.kpi-orange .kpi-icon-wrapper {
    color: var(--theme-orange);
    border: 1px solid #fde68a;
}

.kpi-cyan .kpi-icon-wrapper {
    color: var(--theme-cyan);
    border: 1px solid #a5f3fc;
}

/* --- Dashboard Main Card --- */
.dashboard-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

/* --- Table Header & Search --- */
.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.search-container {
    position: relative;
    width: 260px;
}

    .search-container i {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
        font-size: 0.85rem;
    }

.search-input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
}

/* --- Table Styling --- */
.table-custom {
    margin-bottom: 0;
}

    .table-custom th {
        background-color: #f9fafb;
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 600;
        padding: 12px;
        border-bottom: 1px solid var(--border-color);
        text-align: center;
    }

    .table-custom td {
        font-size: 0.8rem;
        color: var(--text-main);
        padding: 14px 12px;
        vertical-align: middle;
        border-bottom: 1px solid var(--border-color);
        text-align: center;
    }

    .table-custom tr:last-child td {
        border-bottom: none;
    }

/* Trophy Icons */
.rank-icon {
    font-size: 1.2rem;
}

/* --- Pagination --- */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.page-item {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
}

    .page-item.active {
        background: #f3f4f6;
        color: var(--text-main);
        font-weight: 600;
    }

    .page-item.dots {
        border: none;
        background: transparent;
        cursor: default;
    }

/* ========================================================
   Top Ranking pages (District / Retailers / Wholesalers share this file).
   PageHeader adoption: keep the desktop title row exactly as the old
   inline-styled h1 / p looked (24px 600 #1e293b, 14px #64748b).
   ======================================================== */
.tr-page .shell-page-header.tr-header {
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin: 0 0 1.5rem;
}

    .tr-page .shell-page-header.tr-header .shell-page-title {
        font-size: 24px;
        font-weight: 600;
        line-height: 1.2;
        color: #1e293b;
        margin: 0 0 4px;
    }

    .tr-page .shell-page-header.tr-header .shell-page-subtitle {
        font-size: 14px;
        color: #64748b;
        margin: 0;
    }

    .tr-page .shell-page-header.tr-header .shell-page-actions {
        gap: 0.5rem;
        flex-wrap: wrap;
    }

/* KPI tiles (Districts / Wholesalers / Retailers): the title div has no
   min-width so a long value (e.g. "Monsoon Agro Ce...") wraps across
   multiple lines instead of truncating, stretching the card and shoving
   its icon toward/over the edge. Force a single truncated line. */
.tr-page .tr-kpi-row .d-flex.justify-content-between.align-items-start > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

    .tr-page .tr-kpi-row .d-flex.justify-content-between.align-items-start > div:first-child h2 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

/* Filter card (Districts / Wholesalers / Retailers), all sizes: the field row's
   mb-4 plus the action row's mt-4 pt-2 left ~56px of dead space above
   Clear All / Apply Filters. Keep one 20px gap instead. */
.tr-page .tr-filter-row {
    margin-bottom: 0 !important;
}

.tr-page .tr-filter-actions {
    margin-top: 20px !important;
    padding-top: 0 !important;
}

/* native: phone */
@media (max-width: 767.98px) {
    .tr-page {
        padding-top: 12px !important;
        padding-bottom: calc(16px + var(--safe-bottom, 0px)) !important;
    }

    .tr-page .shell-page-header.tr-header {
        gap: 8px;
        margin-bottom: 16px;
    }

        .tr-page .shell-page-header.tr-header .shell-page-title {
            font-size: 1.15rem;
            margin: 0;
        }

        .tr-page .shell-page-header.tr-header .shell-page-subtitle {
            font-size: 0.8rem;
        }

        .tr-page .shell-page-header.tr-header .shell-page-actions {
            flex-basis: 100%;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
        }

            .tr-page .shell-page-header.tr-header .shell-page-actions .btn {
                width: 100%;
                min-height: var(--tap-min, 44px);
                justify-content: center;
            }

    .tr-page .btn {
        min-height: var(--tap-min, 44px);
    }

    .tr-page .form-control,
    .tr-page .form-select {
        min-height: var(--tap-min, 44px);
        font-size: 16px !important;
    }

    /* KPI tiles: two per row */
    .tr-page .tr-kpi-row > [class*="col-"] {
        width: 50%;
    }

    .tr-page .tr-kpi-row > [class*="col-"] > div {
        padding: 14px !important;
    }

        .tr-page .tr-kpi-row > [class*="col-"] > div p {
            font-size: 12px !important;
        }

        .tr-page .tr-kpi-row > [class*="col-"] > div h2 {
            font-size: 18px !important;
        }

    /* Ranking table: one card per row, labels from data-label */
    .tr-page .table-responsive {
        overflow-x: hidden;
    }

    .tr-page table.table thead {
        display: none;
    }

    .tr-page table.table,
    .tr-page table.table tbody,
    .tr-page table.table tr,
    .tr-page table.table td {
        display: block;
        width: 100%;
    }

    .tr-page table.table tbody tr {
        padding: 6px 12px;
        margin-bottom: 10px;
        border: 1px solid #e2e8f0 !important;
        border-radius: 10px;
        background: #ffffff;
    }

    .tr-page table.table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
        text-align: right !important;
        white-space: normal;
    }

        .tr-page table.table td::before {
            content: attr(data-label);
            flex: 0 0 42%;
            color: #64748b;
            font-size: 13px;
            font-weight: 500;
            text-align: left;
        }

        .tr-page table.table td:last-child {
            border-bottom: 0 !important;
        }

    .tr-page .form-check-input {
        width: 22px;
        height: 22px;
    }

    /* Filter card: tighter header / body padding and field gaps (inline styles
       set 16px 20px / 24px 20px and g-4 = 24px gutters). */
    .tr-page .tr-filter-card {
        margin-bottom: 16px !important;
    }

        .tr-page .tr-filter-card > [role="button"] {
            padding: 12px 16px !important;
        }

    .tr-page .tr-filter-body {
        padding: 14px 16px 16px !important;
    }

    .tr-page .tr-filter-row {
        --bs-gutter-y: 12px;
    }

        .tr-page .tr-filter-row .form-label {
            margin-bottom: 6px !important;
        }

    .tr-page .tr-filter-actions {
        gap: 10px !important;
        margin-top: 16px !important;
    }

        .tr-page .tr-filter-actions .btn {
            flex: 1 1 0;
            justify-content: center;
        }

    /* Pagination: one row, "Items Per Page" left and the pager right, only
       prev / current / next - same as the other lists. The current page is the
       only pager button without .btn-outline-secondary. */
    .tr-page .tr-pagination {
        flex-direction: row !important;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        width: 100%;
        min-width: 0;
    }

    .tr-page .tr-pagesize {
        margin: 0 !important;
        gap: 6px !important;
        white-space: nowrap;
    }

        .tr-page .tr-pagesize span {
            font-size: 12px !important;
        }

        .tr-page .tr-pagesize .form-select {
            width: 58px !important;
            height: 30px;
            min-height: 30px;
            padding: 0 22px 0 8px;
            font-size: 12px !important;
            background-position: right 6px center;
        }

    .tr-page .tr-pager {
        flex-wrap: nowrap;
        gap: 4px !important;
    }

        .tr-page .tr-pager .btn-sm {
            flex: 0 0 auto;
            min-width: 28px;
            min-height: 28px;
            height: 28px;
            padding: 0 6px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            border-radius: 6px;
        }

        .tr-page .tr-pager > .btn-outline-secondary:not(:first-child):not(:last-child) {
            display: none;
        }
}

/* native: very small phones. Forcing two KPI tiles per row leaves too
   little width for the icon plus label/value - short values like
   "12.7 days" start ellipsis-truncating and longer labels wrap into a
   third line. Stack one tile per row instead. */
@media (max-width: 480px) {
    .tr-page .tr-kpi-row > [class*="col-"] {
        width: 100%;
    }
}

