:root {
    --pink: #d92772;
    --pink2: #f25387;
    --yellow: #f5c44b;
    --peach: #ffd9b5;
    --ink: #302332;
    --muted: #776b77;
    --bg: #fff8f5;
    --green: #18a558;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a {
    text-decoration: none;
    color: inherit;
}

/* =========================================================
   TOP HEADER
   ========================================================= */

.top {
    min-height: 72px;
    background: #fff;
    border-bottom: 1px solid #f2d9df;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px max(16px, calc((100% - 1180px) / 2));
    position: sticky;
    top: 0;
    z-index: 5;
}

    .top > a {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .top img {
        width: 50px;
        height: 50px;
        object-fit: contain;
    }

    .top b {
        display: block;
        color: var(--pink);
        font-size: 18px;
    }

    .top small {
        color: var(--muted);
    }

nav {
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 14px;
}

    nav a:hover {
        color: var(--pink);
    }

/* =========================================================
   MAIN
   ========================================================= */

.container {
    max-width: 1180px;
    margin: auto;
    padding: 20px;
}

/* =========================================================
   LOGIN
   ========================================================= */

.login-card {
    max-width: 420px;
    margin: 8vh auto;
    background: #fff;
    padding: 28px;
    border-radius: 22px;
    box-shadow: 0 14px 40px #8f52651c;
    text-align: center;
}

.login-logo {
    width: 130px;
}

.login-card form {
    text-align: left;
}

/* =========================================================
   FORM ELEMENTS
   ========================================================= */

label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    margin: 12px 0 6px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #e4cfd6;
    border-radius: 12px;
    background: #fff;
    font: inherit;
    color: var(--ink);
    outline: none;
}

    input:focus,
    select:focus,
    textarea:focus {
        border-color: var(--pink2);
        box-shadow: 0 0 0 3px rgba(217, 39, 114, .08);
    }

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 800;
    cursor: pointer;
}

.primary {
    background: linear-gradient(135deg, var(--pink), var(--pink2));
    color: #fff;
}

.wide {
    width: 100%;
    margin-top: 14px;
}

.call {
    background: #e8fff1;
    color: #087d3c;
}

.whatsapp {
    background: #21c063;
    color: #fff;
}

.view {
    background: #fff0f5;
    color: var(--pink);
}

/* =========================================================
   ALERTS
   ========================================================= */

.alert {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.ok {
    background: #e8fff1;
    color: #087d3c;
}

.err {
    background: #ffe9e9;
    color: #a11;
}

/* =========================================================
   PAGE HEADER
   ========================================================= */

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 15px;
}

    .page-head h1 {
        margin-bottom: 3px;
    }

    .page-head p {
        margin-top: 0;
        color: var(--muted);
    }

/* =========================================================
   STUDENT FILTER
   ========================================================= */

.filters {
    display: flex;
    gap: 10px;
    background: #fff;
    padding: 12px;
    border-radius: 16px;
    margin: 14px 0;
}

    .filters input {
        flex: 1;
    }

    .filters select {
        max-width: 190px;
    }

/* =========================================================
   STUDENT LIST
   ========================================================= */

.student-list {
    display: grid;
    gap: 10px;
}

.student-card {
    background: #fff;
    border: 1px solid #f1dfe4;
    border-radius: 16px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.student-main h3 {
    margin: 0 0 5px;
}

.student-main small {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

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

.icon {
    padding: 10px 12px;
    border-radius: 11px;
    font-weight: 800;
}

.pager {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 20px;
}

/* =========================================================
   PROFILE / FOLLOW-UP / HISTORY
   ========================================================= */

.profile,
.follow-form,
.history,
.panel {
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    margin: 14px 0;
    border: 1px solid #f1dfe4;
}

.profile {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

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

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

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

    .check input {
        width: auto;
    }

.history article {
    border-left: 4px solid var(--yellow);
    padding: 10px 14px;
    margin: 12px 0;
    background: #fffaf0;
    border-radius: 8px;
}

/* =========================================================
   DASHBOARD
   ========================================================= */

.stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

    .stats div {
        background: #fff;
        padding: 16px;
        border-radius: 16px;
        border-top: 4px solid var(--pink);
    }

    .stats b {
        font-size: 24px;
        display: block;
    }

    .stats span {
        font-size: 12px;
        color: var(--muted);
    }

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.panel form {
    display: grid;
    gap: 9px;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 11px;
    border-bottom: 1px solid #eee;
}

.back {
    color: var(--pink);
    font-weight: 800;
}

/* =========================================================
   CALLER DISTRICT ALLOCATION
   ========================================================= */

.allocation-top {
    margin-top: 16px;
}

.allocation-select {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 1.5fr;
    gap: 25px;
    align-items: end;
}

    .allocation-select > div:first-child label {
        margin-top: 0;
    }

.allocation-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

    .allocation-summary div {
        background: var(--bg);
        border: 1px solid #f1dfe4;
        border-radius: 14px;
        padding: 12px 14px;
    }

    .allocation-summary small {
        display: block;
        font-size: 11px;
        font-weight: 800;
        color: var(--muted);
        margin-bottom: 4px;
    }

    .allocation-summary b {
        display: block;
        font-size: 18px;
    }

.assigned-number {
    color: var(--green);
}

/* =========================================================
   DISTRICT HEADER + SEARCH
   ========================================================= */

.district-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 20px;
    margin-bottom: 14px;
}

    .district-head h2 {
        margin: 0 0 4px;
    }

    .district-head p {
        margin: 0;
        color: var(--muted);
        font-size: 13px;
    }

.district-search {
    width: 300px;
}

/* =========================================================
   DISTRICT FILTER BUTTONS
   ========================================================= */

.district-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.district-filter {
    appearance: none;
    border: 1px solid #ead4dc;
    background: #fff;
    color: var(--ink);
    border-radius: 20px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

    .district-filter:hover {
        border-color: var(--pink2);
        color: var(--pink);
    }

    .district-filter.active {
        background: var(--pink);
        border-color: var(--pink);
        color: #fff;
    }

/* =========================================================
   DISTRICT GRID
   ========================================================= */

.district-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.district-card {
    min-height: 74px;
    border: 1px solid #f0dfe4;
    border-radius: 14px;
    padding: 11px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}

    .district-card:hover {
        border-color: #e4afc0;
        box-shadow: 0 5px 14px #8f526510;
    }

    .district-card.selected {
        background: #f0fff6;
        border-color: #bfe8cf;
    }

.district-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    font-size: 13px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.district-check {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--green);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
}

.district-card form {
    margin: 0;
    display: block;
    flex: 0 0 auto;
}

.district-btn {
    appearance: none;
    border: 0;
    border-radius: 10px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

    .district-btn.assign {
        background: #fff0f5;
        color: var(--pink);
    }

        .district-btn.assign:hover {
            background: #ffe2ec;
        }

    .district-btn.remove {
        background: #dff8e9;
        color: #087d3c;
    }

        .district-btn.remove:hover {
            background: #c9f1d9;
        }

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {

    .district-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .allocation-select {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .container {
        padding: 12px;
    }

    .top {
        height: auto;
        align-items: flex-start;
    }

        .top nav span {
            display: none;
        }

        .top nav {
            gap: 8px;
            font-size: 12px;
            flex-wrap: wrap;
            justify-content: flex-end;
        }

        .top small {
            display: none;
        }

    .filters {
        flex-wrap: wrap;
    }

        .filters select {
            max-width: none;
        }

    .student-card {
        align-items: center;
    }

    .actions {
        flex-direction: column;
    }

    .profile {
        display: block;
    }

    .quick {
        margin-top: 12px;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        margin: 4vh auto;
    }

    .student-main {
        min-width: 0;
    }

        .student-main h3 {
            font-size: 16px;
        }

    /* District Allocation Mobile */

    .page-head {
        align-items: flex-start;
    }

    .district-head {
        display: block;
    }

    .district-search {
        width: 100%;
        margin-top: 12px;
    }

    .district-grid {
        grid-template-columns: 1fr 1fr;
    }

    .allocation-summary {
        grid-template-columns: repeat(3, 1fr);
    }

    .district-card {
        display: block;
    }

        .district-card form {
            margin-top: 9px;
        }

    .district-btn {
        width: 100%;
    }
}

/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 430px) {

    .district-grid {
        grid-template-columns: 1fr;
    }

    .allocation-summary {
        grid-template-columns: 1fr;
    }

    .page-head {
        display: block;
    }

        .page-head .back {
            display: inline-block;
            margin-top: 6px;
        }
}


/* =========================================================
   ADMIN TOP NAV - POLISHED HEADER
   ========================================================= */
.admin-top {
    min-height: 92px;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--pink);
    box-shadow: 0 8px 24px rgba(217, 39, 114, .10);
}

    .admin-top .brand {
        flex: 0 0 auto;
    }

        .admin-top .brand img {
            width: 58px;
            height: 58px;
        }

        .admin-top .brand b {
            font-size: 20px;
        }

.admin-nav {
    gap: 9px;
}

    .admin-nav .nav-card {
        min-height: 60px;
        padding: 8px 15px;
        border: 1px solid #f5dce5;
        border-radius: 13px;
        background: linear-gradient(180deg, #fff7fa 0%, #fff 100%);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-width: 92px;
        font-weight: 700;
        color: var(--ink);
        transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    }

        .admin-nav .nav-card:hover {
            color: var(--pink);
            border-color: #efabc5;
            box-shadow: 0 7px 18px rgba(217, 39, 114, .12);
            transform: translateY(-2px);
        }

    .admin-nav .nav-icon {
        color: var(--pink);
        font-size: 20px;
        line-height: 1;
    }

    .admin-nav .logout-card {
        background: linear-gradient(135deg, var(--pink), var(--pink2));
        border-color: transparent;
        color: #fff;
    }

        .admin-nav .logout-card .nav-icon,
        .admin-nav .logout-card:hover {
            color: #fff;
        }

/* Dashboard starts directly with summary cards */
.stats {
    margin-top: 8px;
}

    .stats > div {
        box-shadow: 0 7px 20px rgba(83, 49, 62, .06);
        transition: transform .15s ease, box-shadow .15s ease;
    }

        .stats > div:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 24px rgba(83, 49, 62, .10);
        }

.panel .page-head h2 {
    margin: 0;
}

@media (max-width: 900px) {
    .admin-top {
        align-items: center;
        flex-wrap: wrap;
    }

    .admin-nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
}

@media (max-width: 700px) {
    .admin-top .brand img {
        width: 46px;
        height: 46px;
    }

    .admin-top .brand b {
        font-size: 16px;
    }

    .admin-nav .nav-card {
        min-width: 0;
        min-height: 48px;
        padding: 7px 9px;
        font-size: 11px;
    }

    .admin-nav .nav-icon {
        font-size: 16px;
    }
}

/* =========================================================
   ADMIN DASHBOARD + CALLER DETAIL - FINAL FIX
   ========================================================= */

/* ---------- Dashboard summary cards ---------- */
.stats.admin-click-stats {
    margin-top: 6px;
    margin-bottom: 14px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
}

    .stats.admin-click-stats > .stat-link {
        position: relative;
        display: block;
        min-height: 94px;
        padding: 17px 14px 13px;
        overflow: hidden;
        background: #fff;
        border: 1px solid #f1e5e9;
        border-top: 4px solid var(--pink);
        border-radius: 16px;
        box-shadow: 0 7px 20px rgba(65,42,52,.06);
        color: inherit;
        text-decoration: none;
        transition: transform .16s ease, box-shadow .16s ease;
    }

        .stats.admin-click-stats > .stat-link:hover {
            transform: translateY(-2px);
            box-shadow: 0 11px 26px rgba(65,42,52,.11);
        }

        .stats.admin-click-stats > .stat-link:nth-child(1) {
            border-top-color: #e82b72;
            background: linear-gradient(180deg,#fff 0%,#fff7fa 100%);
        }

        .stats.admin-click-stats > .stat-link:nth-child(2) {
            border-top-color: #19ad68;
            background: linear-gradient(180deg,#fff 0%,#f4fff9 100%);
        }

        .stats.admin-click-stats > .stat-link:nth-child(3) {
            border-top-color: #3689ef;
            background: linear-gradient(180deg,#fff 0%,#f4f9ff 100%);
        }

        .stats.admin-click-stats > .stat-link:nth-child(4) {
            border-top-color: #f47b20;
            background: linear-gradient(180deg,#fff 0%,#fff9f3 100%);
        }

        .stats.admin-click-stats > .stat-link:nth-child(5) {
            border-top-color: #914be8;
            background: linear-gradient(180deg,#fff 0%,#faf6ff 100%);
        }

        .stats.admin-click-stats > .stat-link:nth-child(6) {
            border-top-color: #16ad9b;
            background: linear-gradient(180deg,#fff 0%,#f3fffd 100%);
        }

        .stats.admin-click-stats > .stat-link::after {
            content: "";
            position: absolute;
            width: 72px;
            height: 72px;
            right: -26px;
            bottom: -38px;
            border-radius: 50%;
            background: rgba(217,39,114,.045);
        }

        .stats.admin-click-stats > .stat-link b {
            display: block;
            margin-bottom: 6px;
            color: #17213d;
            font-size: 23px;
            line-height: 1;
            font-weight: 850;
        }

        .stats.admin-click-stats > .stat-link span {
            display: block;
            color: #706775;
            font-size: 11px;
            line-height: 1.3;
        }

/* ---------- Dashboard / detail panel ---------- */
.panel {
    margin: 12px 0 20px;
    padding: 20px 24px 22px;
    background: #fff;
    border: 1px solid #efdce3;
    border-radius: 18px;
    box-shadow: 0 8px 25px rgba(65,42,52,.045);
}

    .panel .page-head {
        margin: 0 0 13px;
        align-items: center;
    }

        .panel .page-head h2 {
            position: relative;
            margin: 0;
            padding-left: 14px;
            color: #17213d;
            font-size: 22px;
            line-height: 1.25;
        }

            .panel .page-head h2::before {
                content: "";
                position: absolute;
                left: 0;
                top: 3px;
                bottom: 3px;
                width: 5px;
                border-radius: 5px;
                background: linear-gradient(180deg,var(--pink),var(--pink2));
            }

    /* ---------- Date range ---------- */
    .panel > form.filters {
        display: grid;
        grid-template-columns: minmax(180px,1fr) minmax(180px,1fr) auto;
        align-items: end;
        gap: 14px;
        margin: 0 0 18px;
        padding: 14px;
        background: #fff9fb;
        border: 1px solid #f5e2e9;
        border-radius: 15px;
    }

        .panel > form.filters > div {
            min-width: 0;
        }

        .panel > form.filters label {
            margin: 0 0 6px;
            color: #302332;
            font-size: 12px;
            font-weight: 800;
        }

        .panel > form.filters input[type="date"] {
            height: 42px;
            padding: 8px 12px;
            border: 1px solid #ead3dc;
            border-radius: 11px;
            background: #fff;
        }

        .panel > form.filters .btn {
            min-width: 94px;
            height: 42px;
            padding: 0 18px;
            border-radius: 11px;
        }

/* ---------- Caller detail performance cards ---------- */
.caller-detail-stats {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin: 4px 0 18px !important;
}

    .caller-detail-stats > div {
        display: block !important;
        min-height: 88px !important;
        padding: 15px 14px !important;
        background: #fff7fa !important;
        border: 1px solid #f0dfe5 !important;
        border-top: 4px solid #e82b72 !important;
        border-radius: 14px !important;
        box-shadow: 0 6px 18px rgba(65,42,52,.055) !important;
    }

        .caller-detail-stats > div:nth-child(2) {
            border-top-color: #19ad68 !important;
            background: #f4fff9 !important;
        }

        .caller-detail-stats > div:nth-child(3) {
            border-top-color: #3689ef !important;
            background: #f4f9ff !important;
        }

        .caller-detail-stats > div:nth-child(4) {
            border-top-color: #914be8 !important;
            background: #faf6ff !important;
        }

        .caller-detail-stats > div:nth-child(5) {
            border-top-color: #16ad9b !important;
            background: #f3fffd !important;
        }

        .caller-detail-stats > div > b {
            display: block !important;
            margin: 0 0 6px !important;
            color: #17213d !important;
            font-size: 23px !important;
            line-height: 1 !important;
            font-weight: 850 !important;
        }

        .caller-detail-stats > div > span {
            display: block !important;
            color: #706775 !important;
            font-size: 11px !important;
            line-height: 1.3 !important;
        }

/* ---------- Clickable caller/student names ---------- */
.caller-detail-link {
    color: var(--pink) !important;
    font-weight: 800;
    text-decoration: none;
}

    .caller-detail-link:hover {
        text-decoration: underline;
    }

/* ---------- Tables ---------- */
.panel .table-wrap {
    overflow-x: auto;
    border: 1px solid #f0e4e8;
    border-radius: 14px;
}

.panel table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

.panel thead th {
    padding: 12px 14px;
    background: #fff6f9;
    color: #4b3a45;
    border-bottom: 1px solid #ecdce2;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.panel tbody td {
    padding: 12px 14px;
    color: #302332;
    border-bottom: 1px solid #f1eaed;
    font-size: 13px;
}

.panel tbody tr:last-child td {
    border-bottom: 0;
}

.panel tbody tr:hover {
    background: #fffafb;
}

/* ---------- Desktop width ---------- */
@media (min-width: 1200px) {
    .container {
        max-width: 1220px;
    }
}

/* ---------- Tablet ---------- */
@media (max-width: 950px) {
    .stats.admin-click-stats {
        grid-template-columns: repeat(3, minmax(0,1fr));
    }

    .caller-detail-stats {
        grid-template-columns: repeat(3, minmax(0,1fr)) !important;
    }

    .panel > form.filters {
        grid-template-columns: 1fr 1fr auto;
    }
}

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
    .stats.admin-click-stats {
        grid-template-columns: repeat(2, minmax(0,1fr));
        gap: 8px;
    }

        .stats.admin-click-stats > .stat-link {
            min-height: 88px;
            padding: 14px 12px;
        }

            .stats.admin-click-stats > .stat-link b {
                font-size: 20px;
            }

    .caller-detail-stats {
        grid-template-columns: repeat(2, minmax(0,1fr)) !important;
    }

    .panel {
        padding: 15px 12px 18px;
        border-radius: 16px;
    }

        .panel > form.filters {
            grid-template-columns: 1fr;
            gap: 9px;
            padding: 12px;
        }

            .panel > form.filters .btn {
                width: 100%;
            }
}
