:root {
    --primary: #1f5eff;
    --dark: #0f172a;
    --sidebar: #111827;
    --light: #f5f7fb;
    --card: #ffffff;
    --muted: #64748b;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--light); color: var(--dark); }
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top left, #dbeafe, transparent 35%), linear-gradient(135deg, #0f172a, #1e3a8a); }
.login-card { width: 420px; background: white; border-radius: 22px; padding: 32px; box-shadow: 0 25px 70px rgba(0,0,0,.25); }
.logo-title { font-size: 30px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.subtitle { color: var(--muted); margin-bottom: 25px; }
.form-group { margin-bottom: 16px; }
label { display: block; margin-bottom: 7px; font-weight: 700; font-size: 14px; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid #cbd5e1; border-radius: 12px; font-size: 15px; }
textarea { min-height: 95px; }
.btn { border: none; padding: 11px 16px; border-radius: 12px; cursor: pointer; font-weight: 700; text-decoration: none; display: inline-block; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-light { background: #e2e8f0; color: #0f172a; }
.btn-sm { padding: 7px 10px; font-size: 13px; }
.alert { padding: 12px; border-radius: 12px; margin-bottom: 15px; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar); color: white; padding: 24px 18px; position: fixed; min-height: 100vh; }
.brand { font-size: 24px; font-weight: 800; margin-bottom: 30px; }
.nav a { display: block; color: #d1d5db; padding: 13px 14px; border-radius: 12px; text-decoration: none; margin-bottom: 8px; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.11); color: white; }
.main { margin-left: 260px; width: calc(100% - 260px); padding: 28px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.page-title h1 { margin: 0; font-size: 28px; }
.page-title p { margin: 6px 0 0; color: var(--muted); }
.card { background: var(--card); border-radius: 18px; padding: 22px; box-shadow: 0 10px 30px rgba(15,23,42,.07); margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat { font-size: 30px; font-weight: 800; margin-top: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: #475569; font-size: 13px; border-bottom: 1px solid #e2e8f0; padding: 12px; }
.table td { border-bottom: 1px solid #e2e8f0; padding: 13px 12px; vertical-align: top; }
.badge { padding: 6px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; display:inline-block; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.clock-panel { text-align: center; padding: 35px; background: linear-gradient(135deg, #ffffff, #eef4ff); border-radius: 22px; }
.clock-time { font-size: 42px; font-weight: 900; margin: 15px 0; }
.profile-header { display: flex; gap: 20px; align-items: center; }
.avatar { width: 86px; height: 86px; border-radius: 22px; background: #dbeafe; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 900; color: #1e40af; object-fit: cover; }
.info-line { margin-bottom: 10px; color: #334155; }
.info-line strong { color: #0f172a; }
.searchbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.searchbar input { max-width: 360px; }
.section-title { margin-top: 30px; border-top: 1px solid #e2e8f0; padding-top: 22px; }
.signature-pad { border: 2px dashed #94a3b8; border-radius: 14px; background: #fff; width: 100%; height: 190px; touch-action: none; }
.signature-preview { max-width: 260px; border: 1px solid #e2e8f0; border-radius: 10px; background: white; padding: 6px; }
.mar-card { border-left: 5px solid var(--primary); }
.due-now { border-left-color: var(--warning); }
.overdue { border-left-color: var(--danger); }
.administered { border-left-color: var(--success); }
.note-card { border-left: 5px solid var(--primary); }
.note-locked { border-left-color: var(--success); }
.note-pending { border-left-color: var(--warning); }
.print-area { background: white; }
@media print {
    .sidebar, .topbar, .actions, .btn { display:none !important; }
    .main { margin-left:0; width:100%; padding:0; }
    .card { box-shadow:none; border:1px solid #ddd; }
}
@media(max-width: 900px) {
    .sidebar { position: relative; width: 100%; min-height: auto; }
    .layout { display: block; }
    .main { margin-left: 0; width: 100%; }
    .grid, .grid-2, .grid-3, .form-row { grid-template-columns: 1fr; }
    .profile-header { align-items: flex-start; }
    .searchbar { display: block; }
    .searchbar input { max-width: 100%; margin-bottom: 10px; }
}

.task-card { border-left: 5px solid var(--primary); }
.task-pending { border-left-color: var(--warning); }
.task-completed { border-left-color: var(--success); }
.task-missed { border-left-color: var(--danger); }
.task-note { font-size: 14px; color: #475569; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(150px, 1fr));
    gap: 12px;
}
.calendar-day {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    min-height: 220px;
    padding: 12px;
}
.calendar-day h3 {
    margin: 0 0 10px;
    font-size: 15px;
}
.shift-pill {
    display: block;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 9px;
    background: #eef2ff;
    border-left: 4px solid var(--primary);
    font-size: 13px;
    text-decoration: none;
    color: #0f172a;
}
.shift-pill strong { display:block; margin-bottom:3px; }
.shift-open { border-left-color: var(--warning); background: #fffbeb; }
.shift-filled { border-left-color: var(--success); background: #f0fdf4; }
.shift-cancelled { border-left-color: var(--danger); background: #fef2f2; }
@media(max-width: 1100px) {
    .calendar-grid { grid-template-columns: 1fr; }
    .calendar-day { min-height: auto; }
}

.incident-card { border-left: 5px solid var(--danger); }
.incident-open { border-left-color: var(--warning); }
.incident-reviewed { border-left-color: var(--success); }
.attachment-box {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8fafc;
}

.permission-grid {
    display: grid;
    grid-template-columns: 1fr repeat(3, 90px);
    gap: 8px;
    align-items: center;
}
.permission-row {
    display: contents;
}
.permission-cell {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}
.access-denied-box {
    max-width: 620px;
    margin: 80px auto;
    background: white;
    padding: 32px;
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15,23,42,.08);
}

/* Mobile Responsive Upgrade */
@media (max-width: 900px) {

    body {
        overflow-x: hidden;
    }

    .layout {
        display: block;
    }

    .sidebar {
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        max-height: 260px;
        overflow-y: auto !important;
        padding: 18px !important;
    }

    .brand {
        font-size: 24px !important;
        margin-bottom: 12px !important;
    }

    .nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding-bottom: 20px !important;
    }

    .nav a {
        font-size: 14px !important;
        padding: 10px !important;
        margin: 0 !important;
        border-radius: 10px;
        background: rgba(255,255,255,0.06);
    }

    .main {
        margin-left: 0 !important;
        padding: 18px !important;
        width: 100% !important;
    }

    .topbar {
        display: block !important;
        text-align: left !important;
    }

    .topbar > div:last-child {
        margin-top: 12px;
    }

    .grid,
    .grid-2,
    .grid-3,
    .calendar-grid {
        grid-template-columns: 1fr !important;
    }

    .card {
        padding: 18px !important;
        border-radius: 16px !important;
        overflow-x: auto;
    }

    .stat {
        font-size: 28px !important;
    }

    .form-row {
        display: block !important;
    }

    .form-group {
        width: 100% !important;
        margin-bottom: 14px !important;
    }

    input,
    select,
    textarea {
        width: 100% !important;
        font-size: 16px !important;
    }

    .searchbar {
        display: block !important;
    }

    .searchbar input,
    .searchbar select,
    .searchbar button,
    .searchbar a {
        width: 100% !important;
        margin-bottom: 10px !important;
    }

    .actions {
        display: block !important;
        width: 100%;
    }

    .actions a,
    .actions button,
    .btn {
        width: 100%;
        margin-bottom: 10px;
        text-align: center;
    }

    .table {
        min-width: 750px;
    }

    table {
        font-size: 14px;
    }

    .avatar {
        width: 75px !important;
        height: 75px !important;
        font-size: 28px !important;
    }
}

@media (max-width: 480px) {

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

    h1 {
        font-size: 28px !important;
    }

    h2 {
        font-size: 22px !important;
    }

    .card {
        padding: 14px !important;
    }

    .btn {
        font-size: 14px !important;
        padding: 12px !important;
    }
}

.sidebar {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 40px;
}
.avatar{
width:110px;
height:110px;
overflow:hidden;
border-radius:18px;
background:#dbeafe;
}

.avatar img{
width:100%;
height:100%;
object-fit:cover;
display:block;
}

.avatar-fallback{
width:100%;
height:100%;

display:flex;

align-items:center;

justify-content:center;

font-size:34px;

font-weight:700;

color:#1d4ed8;

background:#dbeafe;
}
/* ======================================================
   APPOINTMENT CALENDAR — FINAL VERSION
====================================================== */

.calendar-grid{
    display:grid;
    grid-template-columns:repeat(7,minmax(180px,1fr));
    gap:14px;
}

.calendar-day{
    background:#fff;
    border:1px solid #e2e8f0;
    border-radius:18px;
    padding:14px;
    min-height:220px;
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.calendar-day h3{
    margin:0 0 12px;
    font-size:16px;
    font-weight:700;
    color:#0f172a;
}

.appointment-card{
    display:block !important;
    padding:12px !important;
    margin-top:8px !important;
    border-radius:14px !important;
    border-left:6px solid !important;
    text-decoration:none !important;
    font-size:13px !important;
    line-height:1.5 !important;
    transition:.18s;
    box-shadow:0 3px 10px rgba(0,0,0,.05);
    word-break:break-word;
}

.appointment-card:hover{
    transform:translateY(-2px);
    box-shadow:0 8px 18px rgba(0,0,0,.08);
}

.appointment-card *{
    color:inherit !important;
    text-decoration:none !important;
}

.appointment-card strong{
    display:block;
    font-size:16px;
    margin-bottom:6px;
}

.appointment-card.appt-upcoming{
    background:#dcfce7 !important;
    border-color:#16a34a !important;
    color:#166534 !important;
}

.appointment-card.appt-today{
    background:#fef3c7 !important;
    border-color:#f59e0b !important;
    color:#92400e !important;
}

.appointment-card.appt-past{
    background:#fee2e2 !important;
    border-color:#dc2626 !important;
    color:#991b1b !important;
}

.appointment-label{
    display:inline-block;
    margin-top:8px;
    padding:4px 10px;
    border-radius:999px;
    font-size:11px;
    font-weight:700;
    background:rgba(255,255,255,.75);
}

.calendar-actions{
    display:flex;
    gap:8px;
    margin-top:8px;
    flex-wrap:wrap;
}

.calendar-actions .btn{
    width:auto !important;
    margin:0 !important;
}

@media(max-width:1200px){
    .calendar-grid{
        grid-template-columns:repeat(4,1fr);
    }
}

@media(max-width:900px){
    .calendar-grid{
        grid-template-columns:repeat(2,1fr);
    }
}

@media(max-width:700px){
    .calendar-grid{
        grid-template-columns:1fr;
    }

    .calendar-day{
        min-height:auto;
    }
}

/* Keep appointment calendar inside the card */
.appointment-calendar-card {
    overflow-x: auto;
}

.appointment-calendar-card .calendar-grid {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.appointment-calendar-card .calendar-day {
    min-width: 0;
}