:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-border: #e2e5ec;
    --color-text: #1c2130;
    --color-text-muted: #626a7b;
    --color-primary: #1c4ed8;
    --color-primary-dark: #163eae;
    --color-success: #16794f;
    --color-success-bg: #e5f6ee;
    --color-warning: #92640a;
    --color-warning-bg: #fdf1da;
    --color-danger: #b3261e;
    --color-danger-bg: #fbe9e8;
    --color-info: #0f6fa8;
    --color-info-bg: #e4f2fa;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(20, 24, 38, 0.08), 0 1px 2px rgba(20, 24, 38, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.container-narrow { max-width: 440px; margin: 0 auto; padding: 24px 16px; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(120deg, var(--color-primary), var(--color-primary-dark));
    box-shadow: var(--shadow);
    position: sticky;
    top: env(safe-area-inset-top, 0px);
    z-index: 10;
}
.topbar h1 { font-size: 16px; margin: 0; color: #fff; }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-logo { height: 34px; width: auto; border-radius: 6px; background: #fff; padding: 2px; display: block; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.topbar .text-muted { color: rgba(255, 255, 255, 0.88); }
.topbar button.secondary { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.topbar button.secondary:hover { background: rgba(255, 255, 255, 0.26); }

.auth-logo { height: 56px; width: auto; border-radius: 8px; background: #fff; padding: 4px; margin-bottom: 10px; display: block; }

.site-footer {
    margin-top: 24px;
    padding: 18px 20px calc(18px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}
.site-footer .footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.site-footer .footer-logo { height: 32px; width: auto; border-radius: 6px; flex-shrink: 0; }
.site-footer .footer-text { font-size: 12px; color: var(--color-text-muted); line-height: 1.6; }
.site-footer .footer-text strong { color: var(--color-text); }
.site-footer .footer-copyright { margin-top: 2px; }
.topbar .notif-bell { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.topbar .notif-bell:hover { background: rgba(255, 255, 255, 0.26); }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 { margin-top: 0; font-size: 16px; }
.card h3 { font-size: 14px; margin: 0 0 12px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 12.5px; color: var(--color-text-muted); }
input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
    margin-bottom: 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }

button, .btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
button:hover, .btn:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
button.secondary { background: transparent; color: var(--color-primary); }
button.secondary:hover { background: #eef1fb; }
button.danger { background: var(--color-danger); border-color: var(--color-danger); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--color-border); }
th { color: var(--color-text-muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.badge-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-good { background: var(--color-success-bg); color: var(--color-success); }
.badge-bad { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-neutral { background: #eceef4; color: var(--color-text-muted); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }

/* Lead temperature / pipeline color language: hot=red, warm=amber, cold=blue, close=green */
.badge-hot { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-warm { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-cold { background: var(--color-info-bg); color: var(--color-info); }
.badge-close { background: var(--color-success-bg); color: var(--color-success); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 10px 14px; color: var(--color-text-muted); font-weight: 600; border-radius: 8px 8px 0 0; }
.tab-btn.active { color: var(--color-primary); border-bottom: 2px solid var(--color-primary); }
.tab-btn:hover { background: #eef1fb; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13.5px; }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }

.text-muted { color: var(--color-text-muted); }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }

.qr-box { text-align: center; }
.qr-box img { max-width: 220px; margin: 10px auto; display: block; }
.upi-link { word-break: break-all; font-size: 12px; background: #f1f3f9; padding: 8px; border-radius: 6px; display: block; margin-top: 8px; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 14px; align-items: center; }

.hero-banner {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.hero-banner h2 { margin: 0 0 8px; font-size: 20px; }
.hero-banner p { margin: 0; font-size: 13.5px; line-height: 1.6; color: rgba(255, 255, 255, 0.92); max-width: 720px; }
.hero-banner strong { color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 3px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.stat-tile .stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-tile .stat-label { font-size: 11.5px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.stat-tile.accent-good { border-top-color: var(--color-success); }
.stat-tile.accent-good .stat-value { color: var(--color-success); }
.stat-tile.accent-warn { border-top-color: var(--color-warning); }
.stat-tile.accent-warn .stat-value { color: var(--color-warning); }
.stat-tile.accent-bad { border-top-color: var(--color-danger); }
.stat-tile.accent-bad .stat-value { color: var(--color-danger); }
.stat-tile.accent-info { border-top-color: var(--color-info); }
.stat-tile.accent-info .stat-value { color: var(--color-info); }
.stat-tile.accent-primary { border-top-color: var(--color-primary); }
.stat-tile.accent-primary .stat-value { color: var(--color-primary); }

/* Admission form — numbered sections */
.adm-section { padding: 18px 0; border-bottom: 1px solid var(--color-border); }
.adm-section:last-of-type { border-bottom: none; }
.adm-section-title { background: var(--color-bg); padding: 6px 12px; border-radius: 6px; display: inline-block; margin: 0 0 14px; font-size: 13.5px; color: var(--color-primary); font-weight: 700; }
.qualification-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr) auto;
    gap: 8px;
    align-items: end;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--color-bg);
    border-radius: 8px;
}
.qualification-row label { font-size: 10.5px; }
.qualification-row input, .qualification-row select { margin-bottom: 0; }
@media (max-width: 760px) {
    .qualification-row { grid-template-columns: repeat(2, 1fr); }
}

/* Mini follow-up calendar */
.lead-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.lead-calendar .cal-dow { font-size: 10.5px; text-transform: uppercase; color: var(--color-text-muted); text-align: center; padding-bottom: 4px; }
.lead-calendar .cal-day {
    aspect-ratio: 1;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 6px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: default;
}
.lead-calendar .cal-day.empty { border-color: transparent; }
.lead-calendar .cal-day.has-followups { background: var(--color-info-bg); border-color: var(--color-info); cursor: pointer; }
.lead-calendar .cal-day.has-followups:hover { background: var(--color-info); }
.lead-calendar .cal-day.has-followups:hover .cal-daynum,
.lead-calendar .cal-day.has-followups:hover .cal-count { color: #fff; }
.lead-calendar .cal-day.is-today { box-shadow: 0 0 0 2px var(--color-primary) inset; }
.lead-calendar .cal-daynum { font-weight: 600; }
.lead-calendar .cal-count { font-size: 10.5px; color: var(--color-info); font-weight: 700; }

.notif-bell { position: relative; background: none; border: 1px solid var(--color-border); color: var(--color-text); border-radius: 8px; padding: 7px 10px; font-size: 14px; cursor: pointer; }
.notif-bell:hover { background: #eef1fb; }
.notif-count { position: absolute; top: -6px; right: -6px; background: var(--color-danger); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }
.notif-panel { position: absolute; top: calc(100% + 8px); right: 0; width: 320px; max-height: 380px; overflow-y: auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 40; }
.notif-panel .notif-item { padding: 10px 14px; border-bottom: 1px solid var(--color-border); font-size: 12.5px; cursor: pointer; }
.notif-panel .notif-item:last-child { border-bottom: none; }
.notif-panel .notif-item:hover { background: #f5f6fb; }
.notif-panel .notif-item.unread { background: #eef3ff; }
.notif-panel .notif-title { font-weight: 600; margin-bottom: 2px; }
.notif-panel .notif-empty { padding: 16px; text-align: center; }

.video-card { margin-bottom: 16px; }
.video-card h4 { margin: 0 0 6px; }
.video-embed { position: relative; width: 100%; padding-top: 56.25%; border-radius: 8px; overflow: hidden; background: #000; }
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.resource-list { display: flex; flex-direction: column; gap: 10px; }
.resource-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    flex-wrap: wrap;
}
.resource-item .resource-title { font-weight: 600; }
.resource-item .text-muted { font-size: 12.5px; }

.link-btn { background: none; border: none; color: var(--color-primary); font-weight: 600; padding: 0; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.auth-card {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    max-width: 860px;
    background: var(--color-surface);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.auth-side {
    flex: 1 1 260px;
    min-width: 240px;
    background: linear-gradient(150deg, var(--color-primary), var(--color-primary-dark));
    color: #fff;
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
}
.auth-side h1 { margin: 0 0 4px; font-size: 21px; }
.auth-tagline { margin: 0; font-size: 12.5px; color: rgba(255, 255, 255, 0.9); }
.auth-roles-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.75); margin-bottom: 8px; }
.role-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    padding: 8px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.role-chip:hover { background: rgba(255, 255, 255, 0.2); }
.role-chip.active { background: #fff; color: var(--color-primary); border-color: #fff; }
.auth-about { margin: 0; font-size: 12px; line-height: 1.5; color: rgba(255, 255, 255, 0.85); }
.auth-main { flex: 1 1 340px; min-width: 280px; padding: 26px 24px; }
.auth-main .tabs { margin-bottom: 14px; }
.auth-hint { margin: -4px 0 12px; font-size: 12.5px; color: var(--color-text-muted); }

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #14161d;
        --color-surface: #1d2029;
        --color-border: #2c303c;
        --color-text: #e7e9f0;
        --color-text-muted: #9aa0b2;
        --color-primary: #6f92ff;
        --color-primary-dark: #8aa5ff;
        --color-success: #4cc38a;
        --color-success-bg: #16281f;
        --color-warning: #e3b04b;
        --color-warning-bg: #2c2410;
        --color-danger: #ef6a63;
        --color-danger-bg: #2c1917;
        --color-info: #6ab6e0;
        --color-info-bg: #16283a;
    }
    .upi-link { background: #262a36; }
    .notif-bell:hover { background: #262a36; }
    .notif-panel .notif-item:hover { background: #262a36; }
    .notif-panel .notif-item.unread { background: #1c2740; }
}

/* Mobile — the lead-management workflow (calling, logging outcomes) is meant to run
   from a phone, so this gets real attention, not just a generic squeeze. */
@media (max-width: 600px) {
    body { font-size: 13.5px; }
    .container { padding: 16px 10px; }
    .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
    .topbar-logo { height: 26px; }
    .site-footer .footer-inner { flex-direction: column; text-align: center; }
    .topbar h1 { font-size: 14px; }
    .topbar .text-muted { display: none; }
    .topbar .actions { gap: 6px; }

    .tabs { gap: 2px; }
    .tab-btn { padding: 8px 10px; font-size: 12.5px; }

    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-tile { padding: 10px 12px; }
    .stat-tile .stat-value { font-size: 19px; }
    .stat-tile .stat-label { font-size: 10px; }

    .card { padding: 14px; }
    .grid-2 { grid-template-columns: 1fr; }

    table { font-size: 12px; }
    th, td { padding: 6px 7px; }
    button, .btn { padding: 8px 12px; font-size: 13px; }

    .lead-calendar { gap: 3px; }
    .lead-calendar .cal-day { padding: 3px; font-size: 10px; border-radius: 6px; }
    .lead-calendar .cal-count { font-size: 8.5px; }
    .lead-calendar .cal-dow { font-size: 9px; }

    .notif-panel { width: 88vw; right: -8px; }

    .auth-card { flex-direction: column; }
    .auth-side { padding: 20px; }
}
