:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --ink: #111827;
    --paper: #f6f1e8;
    --sand: #efe3d3;
    --primary-deep: #0d4b52;
    --accent-color: #f0b429;
    --muted-color: #6b7280;
    --card-radius: 18px;
    --card-shadow: 0 12px 24px rgba(17, 24, 39, 0.08);
    --shell-bg: #f6f1e8;
    --sidebar-bg: #0d4b52;
    --sidebar-bg-2: #09363b;
    --surface: #ffffff;
    --surface-muted: #f9f3ea;
    --shadow-soft: 0 12px 24px rgba(15, 23, 42, 0.08);
    --stat-blue: #1a65d6;
    --stat-amber: #f4b41a;
    --stat-red: #e24b5b;
    --stat-green: #1a8a5b;
}

/* Global Styles */
body {
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--ink);
    background: radial-gradient(1200px 600px at 10% -20%, #ffe6bf 0%, transparent 55%),
                radial-gradient(800px 600px at 110% 10%, #cce9e3 0%, transparent 60%),
                var(--shell-bg);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    background: linear-gradient(90deg, var(--sidebar-bg), var(--sidebar-bg-2));
    color: #e5f4f2;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(9, 30, 32, 0.16);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.brand-badge {
    width: 36px;
    height: 36px;
    background: #e6fffb;
    color: var(--primary-deep);
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    overflow: hidden;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-title {
    font-family: 'Sora', sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.brand-subtitle {
    font-size: 12px;
    color: rgba(229, 244, 242, 0.7);
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    flex-wrap: wrap;
}

.app-nav-link {
    text-decoration: none;
    color: #d2f3ef;
    padding: 8px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
}

.app-nav-link.active,
.app-nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-main {
    padding: 24px 28px 48px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-header {
    padding: 12px 16px;
    background: #fffaf4;
    border: 1px solid #efe3d3;
    border-radius: 18px;
    box-shadow: var(--shadow-soft);
}

.page-title-text {
    font-family: 'Sora', sans-serif;
    font-size: 28px;
    margin: 0;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted-color);
    font-size: 14px;
}

.page-subtitle:empty {
    display: none;
}

.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-user {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: #fff;
    color: var(--primary-deep);
    position: relative;
    box-shadow: var(--card-shadow);
}

.icon-pill-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 10px;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: #fff;
    color: var(--primary-deep);
    font-weight: 600;
    box-shadow: var(--card-shadow);
}

.page-content {
    display: block;
}

.page-flash {
    margin-bottom: 20px;
}

.app-footer {
    margin-top: 40px;
    color: var(--muted-color);
    font-size: 12px;
}

/* Navigation */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: all 0.3s ease;
}

.navbar-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.navbar-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
}

/* Cards */
.card {
    border: 1px solid #efe3d3;
    box-shadow: var(--shadow-soft);
    border-radius: var(--card-radius);
    transition: all 0.3s ease;
    background-color: #fff;
}

.card:hover {
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: var(--surface-muted);
    border-bottom: 1px solid #efe3d3;
    font-weight: 600;
}

.card-header.bg-primary,
.card-header.bg-info,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger {
    background-color: var(--surface-muted) !important;
    color: var(--ink) !important;
    border-bottom: 1px solid #efe8de;
}

.card-header.bg-primary.text-white,
.card-header.bg-info.text-white,
.card-header.bg-success.text-white,
.card-header.bg-warning.text-white,
.card-header.bg-danger.text-white {
    color: var(--ink) !important;
}

.dashboard-hero {
    border-radius: 20px;
    background: linear-gradient(135deg, #ffffff, #fff7ee);
    border: 1px solid #efe3d3;
    box-shadow: var(--shadow-soft);
}

.clickable-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.clickable-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 32px rgba(15, 23, 42, 0.12);
}

.stat-card {
    border-radius: 18px;
    color: var(--ink);
    position: relative;
    overflow: hidden;
    border: 1px solid #efe3d3;
    box-shadow: var(--shadow-soft);
    background: #fff;
}

.stat-card .card-body {
    padding: 18px 20px;
}

.stat-card-title {
    font-size: 0.95rem;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--muted-color);
}

.stat-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
}

.stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: var(--stat-accent, var(--stat-blue));
}

.stat-card--primary {
    --stat-accent: var(--stat-blue);
    background: #f1f5ff;
}

.stat-card--warning {
    --stat-accent: var(--stat-amber);
    background: #fff6e1;
}

.stat-card--danger {
    --stat-accent: var(--stat-red);
    background: #ffe9ed;
}

.stat-card--success {
    --stat-accent: var(--stat-green);
    background: #e6f7ef;
}

.stat-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--stat-accent, var(--stat-blue));
}

.panel-header {
    background: var(--surface-muted);
    border-bottom: 1px solid #efe3d3;
    color: var(--ink);
}

.panel-header .btn {
    border-radius: 999px;
}

/* Buttons */
.btn {
    font-weight: 500;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.btn.rounded-pill {
    border-radius: 999px;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

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

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
    transform: translateY(-1px);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background-color: #157347;
    border-color: #146c43;
    transform: translateY(-1px);
}

.btn-outline-primary:hover {
    transform: translateY(-1px);
}

/* Forms */
.form-control {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-select {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
}

.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Labels */
.form-label {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

/* Tables */
.table {
    background-color: #fff;
    border-radius: 14px;
    border: 1px solid #efe8de;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    margin-bottom: 0;
}

.table th {
    background-color: #fbf6ef;
    font-weight: 600;
    border-bottom: 1px solid #efe8de;
    color: var(--muted-color);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.table td {
    border-bottom: 1px solid #efe8de;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

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

.table-responsive {
    border-radius: 14px;
    border: 1px solid #efe8de;
    box-shadow: var(--card-shadow);
    background-color: #fff;
}

.table-responsive .table {
    border: none;
    box-shadow: none;
}

/* Badges */
.badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
}

/* Alert styles */
.alert {
    border: none;
    border-radius: 0.5rem;
    font-weight: 500;
}

.alert-success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.alert-danger {
    background-color: #f8d7da;
    color: #842029;
}

.alert-warning {
    background-color: #fff3cd;
    color: #664d03;
}

.alert-info {
    background-color: #d1ecf1;
    color: #055160;
}

/* Login page */
.min-vh-100 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
}

/* Dashboard cards */
.dashboard-card {
    transition: all 0.3s ease;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* OS Form specific styles */
.section-divider {
    border-top: 2px solid #dee2e6;
    margin: 2rem 0 1.5rem 0;
    padding-top: 1.5rem;
    position: relative;
}

.section-divider h5 {
    background-color: white;
    padding: 0 1rem;
    display: inline-block;
    margin-top: -0.75rem;
    color: var(--primary-color);
    font-weight: 600;
}

.items-table th {
    background-color: var(--light-color);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.items-table td {
    vertical-align: middle;
}

.service-description {
    min-height: 120px;
    resize: vertical;
}

.service-description-compact {
    max-width: 300px;
    word-wrap: break-word;
}

.alert-sm {
    padding: 0.375rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.calendar-grid {
    display: grid;
    grid-template-rows: auto repeat(6, 1fr);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.calendar-day-header {
    padding: 8px 4px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid #dee2e6;
}

.calendar-day {
    aspect-ratio: 1;
    border-right: 1px solid #dee2e6;
    position: relative;
}

.calendar-day:last-child {
    border-right: none;
}

.calendar-day.empty {
    background: #f8f9fa;
}

.calendar-day.today {
    background: #e3f2fd;
}

.calendar-day.selected {
    background: #bbdefb;
}

.calendar-day.has-appointments {
    background: #f0f8e8;
}

.calendar-day.has-overdue {
    background: #ffebee;
}

.calendar-day.has-today {
    background: #fff3e0;
}

.day-link {
    display: block;
    width: 100%;
    height: 100%;
    padding: 4px;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.day-link:hover {
    background: rgba(0,123,255,0.1);
    color: inherit;
    text-decoration: none;
}

.day-number {
    font-size: 14px;
    font-weight: 500;
}

.appointment-count {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #0d6efd;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.appointment-card {
    border-left: 4px solid #0d6efd;
    transition: transform 0.2s;
}

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

.appointment-details {
    font-size: 14px;
}

.appointment-details i {
    width: 16px;
    text-align: center;
    color: #6c757d;
}

.appointment-actions .btn {
    font-size: 12px;
}

/* Status badges */
.status-badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
}

/* Currency formatting */
.currency {
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
    border-color: #dee2e6;
}

.pagination .page-link:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    body {
        font-size: 11pt;
        line-height: 1.4;
        color: black;
        background: white;
    }
    
    .card {
        border: none !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    .section-divider {
        border-top: 1px solid #000;
        margin: 1rem 0 0.5rem 0;
        padding-top: 0.5rem;
    }
    
    .section-divider h5 {
        font-size: 12pt;
        font-weight: bold;
        margin-bottom: 0.5rem;
        color: black;
        background: white;
    }
    
    .table {
        font-size: 10pt;
    }
    
    .table th,
    .table td {
        padding: 0.25rem;
        border: 1px solid #000;
    }
    
    .table th {
        background-color: #f0f0f0 !important;
        font-weight: bold;
    }
    
    .btn {
        display: none !important;
    }
    
    .navbar {
        display: none !important;
    }
    
    .container-fluid {
        padding: 0 !important;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }
    
    .text-primary {
        color: black !important;
    }
    
    .badge {
        color: black !important;
        background-color: #f0f0f0 !important;
        border: 1px solid #000 !important;
    }
}

.print-only {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .app-shell {
        flex-direction: column;
    }

    .app-topbar {
        position: sticky;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .app-main {
        padding: 20px;
    }

    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        margin-bottom: 0.25rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .section-divider h5 {
        font-size: 1.1rem;
    }

    .app-nav {
        justify-content: flex-start;
    }

    .calendar-day-header {
        font-size: 10px;
        padding: 6px 2px;
    }

    .day-number {
        font-size: 12px;
    }

    .appointment-count {
        width: 14px;
        height: 14px;
        font-size: 9px;
    }
}

.form-control, .form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
}

input[type="number"] {
    -webkit-appearance: textfield;
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.container-fluid {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Loading states */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-color);
}

/* Footer */
footer {
    margin-top: auto;
    background-color: var(--light-color);
    border-top: 1px solid #dee2e6;
}

/* Utility classes */
.text-currency {
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.shadow {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.shadow-lg {
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
}

.border-radius {
    border-radius: 0.375rem;
}

.border-radius-lg {
    border-radius: 0.5rem;
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-10px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Focus states for accessibility */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Custom modal styles */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
    border-radius: 0.5rem 0.5rem 0 0;
}

.modal-title {
    font-weight: 600;
    color: var(--dark-color);
}

/* Toast notifications */
.toast {
    background-color: white;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast-header {
    background-color: var(--light-color);
    border-bottom: 1px solid #dee2e6;
}

/* Chart containers */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* File upload styling */
.form-control[type="file"] {
    padding: 0.375rem 0.75rem;
}

.form-control[type="file"]::-webkit-file-upload-button {
    background-color: var(--secondary-color);
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 0.25rem;
    margin-right: 0.75rem;
    cursor: pointer;
}

.form-control[type="file"]::-webkit-file-upload-button:hover {
    background-color: #5a6268;
}

/* Color picker */
.form-control-color {
    width: 100%;
    height: 38px;
    border-radius: 0.375rem;
}

/* Step indicator */
.step {
    position: relative;
    padding-left: 0;
}

.step .badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Success states */
.text-success {
    color: var(--success-color) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

/* Error states */
.text-danger {
    color: var(--danger-color) !important;
}

.bg-danger {
    background-color: var(--danger-color) !important;
}

/* Warning states */
.text-warning {
    color: var(--warning-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
}

/* Info states */
.text-info {
    color: var(--info-color) !important;
}

.bg-info {
    background-color: var(--info-color) !important;
}
