:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-sm: 0.375rem;
    --radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);

    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: var(--bg-body);
    margin: 0;
    line-height: 1.4;
    /* Tighter line height */
    font-size: 0.9rem;
    /* Slightly smaller base size */
}

/* Auth Layout */
#app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 240px;
    /* narrowed */
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    margin-bottom: 0.2rem;
    transition: all 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    width: 100%;
    text-align: left;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.nav-link.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 500;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: 50px;
    /* shorter */
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
}

.mobile-only {
    display: none;
}

.view-container {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Base Components */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1rem;
    /* Less padding */
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    /* Smaller padding */
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #f8fafc;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
}

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

.btn-icon {
    padding: 0.3rem;
    border-radius: 50%;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--primary);
}

.form-group {
    margin-bottom: 0.8rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
}

.form-input:focus {
    outline: 2px solid #93c5fd;
    border-color: var(--primary);
}

.grid {
    display: grid;
    gap: 1rem;
}

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

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

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

/* Table (Compact) */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.85rem;
}

th,
td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

/* reduced padding */
th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

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

tr:hover {
    background: #f8fafc;
}

/* Status Badges */
.badge {
    display: inline-flex;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #e0f2fe;
    color: #075985;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

/* Calendar */
.calendar-container {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1rem;
}

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

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
}

.calendar-cell {
    background: white;
    min-height: 100px;
    /* Reduced */
    padding: 0.4rem;
    cursor: pointer;
    transition: background 0.2s;
}

.calendar-cell:hover {
    background: #f8fafc;
}

.calendar-cell.today {
    background: #eff6ff;
}

.calendar-header-cell {
    background: #f8fafc;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.visit-pill {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    margin-bottom: 2px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--primary);
    color: white;
}

.visit-pill.finished {
    background: var(--success);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: absolute;
        height: 100%;
        z-index: 50;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-only {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        cursor: pointer;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .top-bar,
    .header-actions,
    .mobile-only,
    .btn {
        display: none !important;
    }

    #app-shell {
        height: auto;
        display: block;
    }

    .main-content {
        overflow: visible;
        display: block;
    }

    .view-container {
        padding: 0;
        margin: 0;
        max-width: none;
        width: 100%;
    }

    body {
        background: white;
        color: black;
        font-size: 10pt;
    }

    #report-content {
        display: flex !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: none !important;
        min-height: auto !important;
        position: absolute;
        top: 0;
        left: 0;
    }

    .page-break {
        page-break-before: always;
    }
}