:root {
    /* Primary Colors - Calm & Professional */
    --sage-green: #A8BA9A;
    --sage-light: #C4D1BB;
    --sage-dark: #8E9F82;

    /* Accent - Quality & Trust */
    --gold: #D4AF37;
    --gold-light: #E5C363;

    /* Neutrals - Clean & Spacious */
    --white: #FFFFFF;
    --cream: #F9F8F4;
    --grey-light: #F0F2ED;
    --grey-mid: #D1D5CB;
    --text-dark: #2C332A;
    --text-muted: #6B7A66;

    /* Semantic Colors */
    --confirmed: #A8BA9A;
    --pending: #E6A8A8;
    --weekend: #F0F2ED;

    /* Spacing & Borders */
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 4px 20px rgba(168, 186, 154, 0.08);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--cream);
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    font-family: 'Playfair Display', serif;
    font-weight: 600;
}

.app-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 33px);
}

.sidebar {
    background: var(--white);
    border-right: 1px solid var(--grey-light);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.logo-container img {
    height: 48px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-item:hover,
.nav-item.active {
    background-color: var(--sage-light);
    color: var(--text-dark);
}

.main-content {
    background-color: var(--cream);
    padding: 3rem;
    overflow-y: auto;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2rem;
}

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(168, 186, 154, 0.1);
    transition: var(--transition);
}

.card h2 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--sage-dark);
}

.metric-container {
    display: flex;
    gap: 1.5rem;
    grid-column: span 12;
}

.metric-card {
    flex: 1;
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--sage-green);
    box-shadow: var(--shadow-soft);
}

.metric-card span {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.metric-card strong {
    font-size: 1.8rem;
    color: var(--text-dark);
    font-family: 'Playfair Display', serif;
}

.hero-card {
    grid-column: span 12;
    height: 320px;
    background: linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.4)), url('assets/hero.png');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    color: var(--white);
}

.hero-content {
    padding: 2.5rem;
    z-index: 1;
}

.hero-content h2 {
    color: var(--white);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.btn-primary {
    background-color: var(--sage-green);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: var(--sage-dark);
    transform: translateY(-1px);
}

.input-field {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--grey-mid);
    background: var(--white);
    font-family: inherit;
    font-size: 1rem;
}

.input-field:focus {
    outline: none;
    border-color: var(--sage-green);
    box-shadow: 0 0 0 3px rgba(168, 186, 154, 0.1);
}

/* Calendar */
.month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
}

.day-cell {
    aspect-ratio: 1;
    background: var(--grey-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: var(--text-muted);
    transition: var(--transition);
    cursor: pointer;
    font-weight: 500;
}

.day-cell:hover {
    background: var(--sage-light);
    color: var(--text-dark);
}

.day-cell.active-load {
    background: var(--sage-green);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(168, 186, 154, 0.3);
}

.day-cell.weekend {
    background: var(--weekend);
    opacity: 0.6;
}

/* ==========================================================================
   JUNO v2 — Extended Styles
   Appended below existing design system. All original variables preserved.
   ========================================================================== */

/* --- Calendar load levels (1–4 appointments, progressively darker green) --- */
.day-cell.apt-1 {
    background: #D4E3CF;
    color: var(--text-dark);
}

.day-cell.apt-2 {
    background: #B0C9A9;
    color: var(--text-dark);
}

.day-cell.apt-3 {
    background: var(--sage-green);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(168, 186, 154, 0.3);
}

.day-cell.apt-4 {
    background: #5E7A55;
    color: var(--white);
    box-shadow: 0 4px 12px rgba(94, 122, 85, 0.4);
}

/* Keep legacy classes for any old references */
.day-cell.active-load { background: var(--sage-green); color: var(--white); }
.day-cell.heavy-load  { background: var(--sage-dark); color: var(--white); box-shadow: 0 4px 12px rgba(142, 159, 130, 0.45); }

.day-cell.today {
    outline: 2px solid var(--gold);
    outline-offset: -2px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.calendar-nav button {
    background: transparent;
    border: 1px solid var(--grey-mid);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.9rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.calendar-nav button:hover {
    background: var(--grey-light);
    color: var(--text-dark);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.weekday-label {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.4rem 0;
}

.day-detail-back {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition);
}

.day-detail-back:hover { color: var(--text-dark); }

.time-slot {
    display: flex;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--grey-light);
    align-items: flex-start;
}

.time-slot:last-child { border-bottom: none; }

.time-slot .slot-time {
    width: 52px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-top: 0.15rem;
    flex-shrink: 0;
}

.apt-card {
    flex: 1;
    background: var(--white);
    border: 1px solid var(--grey-mid);
    border-left: 4px solid var(--sage-green);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.apt-card:hover {
    border-color: var(--sage-green);
    box-shadow: var(--shadow-soft);
    transform: translateX(2px);
}

.apt-card.birth { border-left-color: var(--gold); }
.apt-card.postnatal { border-left-color: var(--sage-light); }

/* --- Map & Routes view --- */
#map {
    height: 420px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--grey-mid);
    z-index: 0;
    transition: height 0.25s ease;
}

#route-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
    transition: grid-template-columns 0.25s ease;
}

#route-layout.map-expanded {
    grid-template-columns: 1fr;
}

#route-layout.map-expanded #map {
    height: 580px;
}

/* Leaflet-injected expand button */
.map-expand-btn {
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.25);
    color: var(--text-dark);
    line-height: 1;
    padding: 0;
}

.map-expand-btn:hover {
    background: #f4f4f4;
}

.route-stop {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--grey-light);
}

.route-stop:last-child { border-bottom: none; }

.route-stop-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--sage-green);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
    font-family: 'Playfair Display', serif;
}

.travel-segment {
    padding: 5px 12px;
    background: var(--grey-light);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 3px 0 3px 44px;
}

.route-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* --- Patient table (Mothers view) --- */
.patient-table {
    width: 100%;
    border-collapse: collapse;
}

.patient-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--grey-light);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
}

.patient-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--grey-light);
    vertical-align: middle;
    font-size: 0.9rem;
}

.patient-table tr:last-child td { border-bottom: none; }

.patient-table tr:hover td { background: var(--grey-light); }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.active {
    background: rgba(168, 186, 154, 0.2);
    color: var(--sage-dark);
}

.status-badge.postpartum {
    background: rgba(212, 175, 55, 0.15);
    color: #8B6914;
}

.status-badge.discharged {
    background: var(--grey-light);
    color: var(--text-muted);
}

.ga-alert {
    color: var(--pending);
    font-weight: 700;
}

/* --- Modal overlay --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 51, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(44, 51, 42, 0.18);
}

.modal-box h2 { margin-bottom: 1.5rem; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.form-grid .full-width { grid-column: span 2; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--grey-light);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--grey-mid);
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--grey-light);
    color: var(--text-dark);
}

.btn-danger {
    background: transparent;
    color: #C0392B;
    border: 1px solid #E8A8A8;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-danger:hover { background: #FEF0F0; }

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

/* --- Toast notifications --- */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-dark);
    color: var(--white);
    padding: 0.9rem 1.4rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    z-index: 2000;
    animation: slideUp 0.3s ease;
    max-width: 320px;
}

.toast.success { border-left: 4px solid var(--sage-green); }
.toast.error   { border-left: 4px solid var(--pending); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Loading state --- */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    gap: 0.75rem;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state p { margin: 0.5rem 0 1.5rem; font-size: 0.95rem; }

/* --- Visit type badge --- */
.visit-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.visit-badge.prenatal  { background: rgba(168,186,154,0.2); color: var(--sage-dark); }
.visit-badge.birth     { background: rgba(212,175,55,0.2);  color: #8B6914; }
.visit-badge.postnatal { background: rgba(100,140,200,0.15); color: #3a5a8c; }

/* --- Summary bar --- */
.summary-bar {
    display: flex;
    gap: 2rem;
    padding: 1rem 1.5rem;
    background: var(--grey-light);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.summary-bar strong { color: var(--text-dark); }

/* --- Route drag-and-drop --- */
.drag-handle {
    font-size: 1.1rem;
    color: var(--grey-mid);
    cursor: grab;
    padding: 0 6px 0 0;
    user-select: none;
    flex-shrink: 0;
    line-height: 1;
    align-self: center;
    transition: color 0.15s;
}

.route-stop[data-apt-idx]:hover .drag-handle {
    color: var(--text-muted);
}

.route-stop.dragging {
    opacity: 0.4;
    background: var(--grey-light);
}

.route-stop.drag-over {
    outline: 2px dashed var(--sage-green);
    outline-offset: -2px;
    background: rgba(168, 186, 154, 0.1);
}

.route-stop-home {
    opacity: 0.85;
    cursor: default;
}

/* --- Optimize animate-in --- */
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* --- Prototype warning banner --- */
.prototype-banner {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: #FFF3CD;
    color: #856404;
    border-bottom: 1px solid #FFE083;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 3.5rem 0.5rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.01em;
}

.lang-toggle-btn {
    position: absolute;
    right: 1rem;
    background: rgba(133, 100, 4, 0.12);
    border: 1px solid rgba(133, 100, 4, 0.3);
    color: #856404;
    border-radius: 4px;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.05em;
    transition: background 0.15s;
}

.lang-toggle-btn:hover {
    background: rgba(133, 100, 4, 0.22);
}

/* --- Password gate --- */
#password-gate {
    position: fixed;
    inset: 0;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.password-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 360px;
    max-width: 95vw;
    box-shadow: 0 24px 64px rgba(44, 51, 42, 0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}