:root {
    --brand: #0e7c86;
    --brand-2: #12a3ad;
    --brand-dark: #0a5c64;
    --brand-light: #e6f5f6;
    --ink: #14232b;
    --muted: #6b7c85;
    --bg: #f4f8f9;
    --card-border: #e7eef0;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(20,35,43,.04);
    --shadow-md: 0 8px 24px rgba(20,35,43,.07);
    --shadow-lg: 0 20px 48px rgba(10,40,45,.14);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--ink);
    margin: 0;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 268px;
    background: linear-gradient(165deg, #0a3d44 0%, #0a5c64 55%, #0e7c86 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 14px 14px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
    transition: transform .25s ease;
    /* Contain the column so only the nav list scrolls internally —
       brand header and footer stay pinned in place. */
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 20px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.brand-icon {
    width: 42px; height: 42px;
    background: rgba(255,255,255,.15);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.brand-title { font-weight: 800; font-size: 17px; line-height: 1.1; letter-spacing: .2px; }
.brand-sub { font-size: 12px; opacity: .75; }

/* Scrollable nav list — this is the fix: fills remaining sidebar height and
   scrolls on its own, so items below the fold (Renewals, Settings, Developer
   Mode, etc.) are always reachable instead of being cut off with no scrollbar. */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 0;           /* required for overflow to work inside a flex column */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 6px 2px 2px;
    margin-right: -6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.28) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); border-radius: 10px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.45); }

/* Soft fade hint at the bottom of the sidebar so it's visually obvious the
   list keeps going / is scrollable, not just visually truncated. */
.sidebar-nav-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.sidebar-nav-wrap::after {
    content: '';
    position: absolute; left: 0; right: 6px; bottom: 0; height: 22px;
    background: linear-gradient(180deg, transparent, rgba(9,57,63,.55));
    pointer-events: none; border-radius: 0 0 10px 10px;
}

.sidebar-nav .nav-link {
    color: rgba(255,255,255,.82);
    padding: 10.5px 14px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}

.sidebar-nav .nav-link i { font-size: 17px; width: 20px; text-align: center; }

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
    transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
    background: #fff;
    color: var(--brand-dark);
    font-weight: 700;
    box-shadow: 0 6px 16px -6px rgba(0,0,0,.35);
}
.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
    width: 4px; height: 20px; border-radius: 0 4px 4px 0;
    background: #fff;
}

.sidebar-footer {
    font-size: 12px;
    opacity: .65;
    padding: 12px 8px 4px;
    flex-shrink: 0;
    border-top: 1px solid rgba(255,255,255,.1);
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== Main area ===== */
.main-area {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: rgba(255,255,255,.9);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--card-border);
    padding: 15px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-title { font-weight: 800; font-size: 20px; flex: 1; letter-spacing: .1px; }
.topbar-date {
    font-size: 13px; font-weight: 600; color: var(--brand-dark);
    background: var(--brand-light);
    display: flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: 999px;
}
.topbar-date i { font-size: 13px; }

.content-area {
    padding: 26px 28px 60px;
    animation: none !important;
}

/* ===== Cards ===== */
.stat-card, .panel {
    background: #fff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card { padding: 20px 22px; display: flex; align-items: center; gap: 16px; position: relative; overflow: hidden; }
.stat-card::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--brand-2), var(--brand-dark));
    opacity: 0; transition: opacity .18s ease;
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
    width: 50px; height: 50px;
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-value { font-size: 25px; font-weight: 800; line-height: 1.1; letter-spacing: -.3px; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; font-weight: 600; }

.panel { padding: 22px 24px; margin-bottom: 24px; transition: box-shadow .18s ease; }
.panel-title { font-weight: 800; font-size: 16px; margin-bottom: 4px; letter-spacing: .1px; }
.panel-title i { color: var(--brand); margin-right: 6px; }
.panel-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

/* ===== Tables ===== */
.table > :not(caption) > * > * { padding: 13px 14px; vertical-align: middle; }
.table thead th {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    border-bottom: 2px solid var(--card-border);
    font-weight: 800;
    background: #fbfefe;
}
.table tbody tr { border-bottom: 1px solid var(--card-border); transition: background .12s ease; }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: var(--brand-light); }
.table-responsive { border-radius: 10px; }

/* ===== Buttons ===== */
.btn { border-radius: 10px; font-weight: 600; letter-spacing: .1px; }
.btn-sm { border-radius: 8px; }
.btn-brand {
    background: linear-gradient(135deg, var(--brand-2), var(--brand-dark));
    border-color: var(--brand-dark); color: #fff;
    box-shadow: 0 6px 16px -6px rgba(10,92,100,.55);
}
.btn-brand:hover {
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    border-color: var(--brand-dark); color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 10px 20px -6px rgba(10,92,100,.6);
}
.btn-outline-secondary { border-color: var(--card-border); color: var(--ink); }
.btn-outline-secondary:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand-dark); }

/* ===== Badges ===== */
.badge.rounded-pill { font-weight: 700; letter-spacing: .1px; padding: 5px 11px; }

/* ===== Circular progress ring (pure CSS, no JS) ===== */
.ring {
    --pct: 0;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: conic-gradient(var(--ring-color, var(--brand)) calc(var(--pct) * 1%), #e9eef0 0);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ring-inner {
    width: 34px; height: 34px;
    background: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 10.5px;
    font-weight: 800;
    color: var(--ink);
}

.ring-lg { width: 130px; height: 130px; }
.ring-lg .ring-inner { width: 100px; height: 100px; font-size: 22px; }
.ring-lg .ring-inner small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

/* ===== Dashboard hero banner ===== */
.dash-hero {
    background: linear-gradient(120deg, #0a3d44 0%, #0a5c64 45%, #0e7c86 100%);
    border-radius: var(--radius);
    padding: 26px 28px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}
.dash-hero::before {
    content: '';
    position: absolute; right: -60px; top: -60px;
    width: 220px; height: 220px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.10), transparent 70%);
}
.dash-hero::after {
    content: '';
    position: absolute; right: 90px; bottom: -80px;
    width: 160px; height: 160px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,.07), transparent 70%);
}
.dash-hero-greet { font-size: 21px; font-weight: 800; letter-spacing: -.2px; position: relative; z-index: 1; }
.dash-hero-sub { font-size: 13.5px; opacity: .85; margin-top: 4px; position: relative; z-index: 1; }
.dash-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.dash-hero-actions .btn {
    background: rgba(255,255,255,.14);
    border: 1px solid rgba(255,255,255,.28);
    color: #fff;
    font-weight: 600;
    backdrop-filter: blur(4px);
}
.dash-hero-actions .btn:hover { background: rgba(255,255,255,.24); color: #fff; }
.dash-hero-actions .btn-light-solid {
    background: #fff; color: var(--brand-dark); border-color: #fff;
}
.dash-hero-actions .btn-light-solid:hover { background: #f0fbfb; }

/* ===== Misc ===== */
.avatar-circle {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state i { font-size: 42px; opacity: .3; display: block; margin-bottom: 12px; }

.kanban-col { background: #f7fafb; border-radius: var(--radius); padding: 14px; min-height: 200px; }
.kanban-col h6 { font-weight: 700; font-size: 13px; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.lead-card { background: #fff; border: 1px solid var(--card-border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.lead-card .lead-name { font-weight: 700; font-size: 14px; }
.lead-card .lead-meta { font-size: 12px; color: var(--muted); }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
}

/* ===== Attendance Calendar — premium/animated version ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes ringPulse {
    0%   { box-shadow: 0 0 0 0 rgba(14,124,134,.45); }
    70%  { box-shadow: 0 0 0 8px rgba(14,124,134,0); }
    100% { box-shadow: 0 0 0 0 rgba(14,124,134,0); }
}
@keyframes popIn {
    0%   { transform: scale(.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.panel {
    animation: none;
}
/* ===== Calendar card shell ===== */
.cal-card {
    background: linear-gradient(180deg, #fff 0%, #fbfefe 100%);
    border: 1px solid var(--card-border);
    border-radius: 18px;
    padding: 20px 22px 22px;
    box-shadow: 0 1px 2px rgba(20,35,43,.03);
}

.cal-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-bottom: 16px;
}
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav-btn {
    width: 34px; height: 34px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-light); color: var(--brand-dark);
    transition: background .15s ease, transform .15s ease;
}
.cal-nav-btn:hover { background: var(--brand); color: #fff; transform: translateY(-1px); }
.cal-month-label { font-weight: 800; font-size: 17px; min-width: 168px; text-align: center; }
.cal-today-btn {
    font-size: 12.5px; font-weight: 700; color: var(--brand-dark);
    background: var(--brand-light); border-radius: 999px; padding: 7px 14px;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background .15s ease;
}
.cal-today-btn:hover { background: var(--brand); color: #fff; }

/* ===== Weekday-aligned month grid — compact, fits without page scroll ===== */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-width: 430px;
    margin: 0 auto;
}
.cal-weekday {
    text-align: center; font-size: 10.5px; font-weight: 800; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em; padding-bottom: 2px;
}
.cal-cell-blank { background: transparent; }

.cal-cell {
    width: 100%;
    height: 44px;
    border: none; border-radius: 10px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    color: #fff; cursor: pointer;
    position: relative; overflow: visible;
    transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease, filter .18s ease;
    animation: popIn .3s ease both;
}
.cal-cell::before {
    content: ''; position: absolute; inset: 0; border-radius: 10px;
    background: linear-gradient(160deg, rgba(255,255,255,.35), rgba(255,255,255,0) 60%);
    pointer-events: none;
}
.cal-daynum { position: relative; z-index: 1; font-size: 10px; font-weight: 700; opacity: .9; line-height: 1; }
.cal-status-letter { position: relative; z-index: 1; font-size: 12.5px; font-weight: 800; line-height: 1; }
.cal-daynum.is-today { text-decoration: underline; text-underline-offset: 2px; }

/* Custom instant hover-tooltip — reason/note turant dikhta hai, browser ke
   default (slow) title-tooltip ki jagah */
.cal-cell[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    background: #1f2937; color: #fff; padding: 6px 11px; border-radius: 8px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    box-shadow: 0 10px 20px -6px rgba(0,0,0,.35);
    z-index: 60; pointer-events: none;
    animation: fadeInUp .12s ease both;
}
.cal-cell[data-tip]:hover::before {
    content: ''; position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #1f2937; z-index: 60; pointer-events: none;
}
.cal-cell:hover:not(.is-na) {
    transform: translateY(-3px) scale(1.06);
    filter: brightness(1.06);
    box-shadow: 0 10px 18px -6px rgba(0,0,0,.28);
    z-index: 2;
}
.cal-cell:active:not(.is-na) { transform: translateY(-1px) scale(1.01); }

.att-status-present      { background: linear-gradient(135deg,#10d488,#0e9f6e); }
.att-status-absent       { background: linear-gradient(135deg,#ff6b6b,#e53e3e); }
.att-status-leave_paid   { background: linear-gradient(135deg,#60a5fa,#3b82f6); }
.att-status-leave_unpaid { background: linear-gradient(135deg,#fbbf24,#f59e0b); }
.att-status-holiday      { background: linear-gradient(135deg,#fde047,#eab308); color:#3f2d00; }
.cal-cell.is-na           { background: #eef1f3 !important; color: #b6c0c6; cursor: default; box-shadow: none; }
.cal-cell.is-na::after    { display: none; }
.cal-cell.is-na .cal-status-letter { opacity: .5; }

.cal-cell.is-today-cell { animation: popIn .3s ease both, ringPulse 2s ease-in-out infinite; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }

@media (max-width: 767px) {
    .cal-grid { max-width: 100%; gap: 4px; }
    .cal-cell { height: 38px; }
    .cal-daynum { font-size: 9px; }
    .cal-status-letter { font-size: 11px; }
    .cal-month-label { font-size: 14.5px; min-width: 0; }
}

.att-legend { display: flex; flex-wrap: wrap; gap: 10px; }
.att-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
    background: #fff; border: 1px solid var(--card-border); border-radius: 999px; padding: 5px 12px;
}
.att-legend .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 3px rgba(0,0,0,.03); }

/* ===== Stat pills — animated gradient cards ===== */
.stat-pill {
    background: linear-gradient(145deg, #ffffff, var(--brand-light));
    border: 1px solid var(--card-border);
    color: var(--brand-dark); border-radius: 14px;
    padding: 14px 12px; text-align: center;
    transition: transform .2s ease, box-shadow .2s ease;
    animation: fadeInUp .4s ease both;
}
.stat-pill:hover { transform: translateY(-3px); box-shadow: 0 10px 20px -10px rgba(14,124,134,.35); }
.stat-pill .num { font-size: 24px; font-weight: 800; line-height: 1.1; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-pill .lbl { font-size: 11.5px; color: var(--muted); margin-top: 3px; font-weight: 600; letter-spacing: .2px; }

/* ===== Status-picker chips inside the mark modal ===== */
.att-modal { border-radius: 18px; border: none; box-shadow: 0 24px 48px -12px rgba(10,40,45,.35); max-height: 88vh; }
.att-modal .modal-body { overflow-y: auto; }
.status-chip-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.status-chip {
    border: 2px solid var(--card-border); background: #fff; border-radius: 12px;
    padding: 10px 12px; font-weight: 700; font-size: 13px; color: var(--ink);
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    transition: all .15s ease;
}
.status-chip i { font-size: 15px; opacity: .75; }
.status-chip:hover { border-color: var(--brand); transform: translateY(-1px); }
.status-chip.is-active { color: #fff; border-color: transparent; box-shadow: 0 6px 14px -6px rgba(0,0,0,.35); transform: translateY(-1px); }
.status-chip.is-active i { opacity: 1; }
.status-chip.sc-present.is-active      { background: linear-gradient(135deg,#10d488,#0e9f6e); }
.status-chip.sc-absent.is-active       { background: linear-gradient(135deg,#ff6b6b,#e53e3e); }
.status-chip.sc-leave_paid.is-active   { background: linear-gradient(135deg,#60a5fa,#3b82f6); }
.status-chip.sc-leave_unpaid.is-active { background: linear-gradient(135deg,#fbbf24,#f59e0b); }
.status-chip.sc-holiday.is-active      { background: linear-gradient(135deg,#fde047,#eab308); color:#3f2d00; }
.status-chip.sc-clear.is-active        { background: linear-gradient(135deg,#94a3b8,#64748b); }

/* ===== Full-page forms — fit the viewport, no scroll needed to fill ===== */
.form-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 190px); /* topbar + content-area padding + panel padding */
}
.form-page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.form-page-head .back-link {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-light); color: var(--brand-dark);
    transition: background .15s ease;
}
.form-page-head .back-link:hover { background: var(--brand); color: #fff; }

.form-body { flex: 1; display: flex; flex-direction: column; }

.form-section {
    background: #fbfefe;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 16px 18px;
    margin-bottom: 14px;
}
.form-section-title {
    font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
    color: var(--brand-dark); margin-bottom: 12px;
    display: flex; align-items: center; gap: 7px;
}
.form-section-title i { font-size: 13px; }

.form-columns { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.form-page .form-label { font-size: 12.5px; font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.form-page .form-text { font-size: 11.5px; }
.form-page .form-control, .form-page .form-select { padding: 8px 12px; font-size: 14px; }

.form-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 991px) { .form-cols-2 { grid-template-columns: 1fr; } }

.form-actions-bar {
    position: sticky; bottom: 0;
    background: #fff;
    margin-top: auto;
    padding: 14px 2px 4px;
    border-top: 1px solid var(--card-border);
    display: flex; gap: 10px;
}

@media print {
    .main-area { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
}
/* ===========================================================================
   CRM upgrade — stat card hover polish, renewals table, message log badges
   =========================================================================== */

.stat-card {
    transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(20,35,43,.08);
}
.stat-icon {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.03);
}

#renewalsTable tbody tr:has(.text-bg-danger) {
    background: #fff8f7;
}

.js-api-send.btn-outline-success {
    pointer-events: none;
}

/* Sidebar badge alignment for the Renewals link count (badge uses ms-auto,
   which works fine since .nav-link is already display:flex) */
.sidebar-nav .nav-link .badge {
    font-size: 10.5px;
}

#crmFollowupModal .modal-content {
    border-radius: 18px;
    border: none;
    box-shadow: 0 20px 60px rgba(20,35,43,.25);
}
#crmFollowupModal .modal-header {
    border-bottom: 1px solid var(--card-border);
}
