:root {
    --csp-primary: #1d8b7b;
    --csp-primary-dark: #0f5f57;
    --csp-primary-soft: color-mix(in srgb, var(--csp-primary) 18%, white);
    --csp-accent: #6fcbbd;
    --csp-surface: #f4fbfa;
    --csp-background: #eef8f7;
    --csp-text: #183b37;
    --csp-sidebar: #134f49;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(180deg, var(--csp-surface) 0%, var(--csp-background) 100%);
    color: var(--csp-text);
}

.navbar-white {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
}

.main-sidebar {
    background: linear-gradient(180deg, var(--csp-primary-dark) 0%, var(--csp-sidebar) 100%) !important;
}

.brand-link {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-right: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.14);
}

.nav-sidebar .nav-link.active {
    background: linear-gradient(90deg, var(--csp-primary) 0%, var(--csp-accent) 100%) !important;
    box-shadow: 0 10px 24px rgba(24, 98, 89, 0.22);
}

.content-wrapper {
    background: transparent;
}

.card {
    border: 0;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(19, 79, 73, 0.08);
}

.card-primary.card-outline {
    border-top: 3px solid var(--csp-primary);
}

.btn-primary,
.bg-primary {
    background-color: var(--csp-primary) !important;
    border-color: var(--csp-primary) !important;
}

.btn-primary:hover {
    background-color: var(--csp-primary-dark) !important;
    border-color: var(--csp-primary-dark) !important;
}

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

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

.text-teal,
.text-primary {
    color: var(--csp-primary) !important;
}

.small-box {
    border-radius: 20px;
    overflow: hidden;
}

.small-box.bg-info,
.small-box.bg-success,
.small-box.bg-warning,
.small-box.bg-danger {
    color: #fff !important;
}

.small-box.bg-info {
    background: linear-gradient(135deg, var(--csp-primary) 0%, var(--csp-accent) 100%) !important;
}

.small-box.bg-success {
    background: linear-gradient(135deg, var(--csp-primary-dark) 0%, var(--csp-primary) 100%) !important;
}

.small-box.bg-warning {
    background: linear-gradient(135deg, var(--csp-accent) 0%, var(--csp-primary) 100%) !important;
}

.small-box.bg-danger {
    background: linear-gradient(135deg, var(--csp-sidebar) 0%, var(--csp-primary-dark) 100%) !important;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--csp-primary) 0%, var(--csp-accent) 100%);
    color: #fff;
    font-weight: 700;
}

.user-panel .info {
    min-width: 0;
    flex: 1;
}

.sidebar-user-name {
    max-width: 100%;
    font-size: 0.84rem;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
}

.user-panel .info small {
    display: block;
    font-size: 0.72rem;
    line-height: 1.25;
    white-space: normal;
}

.login-page {
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--csp-accent) 35%, transparent), transparent 35%),
        linear-gradient(140deg, var(--csp-surface) 0%, var(--csp-background) 100%);
}

.login-box {
    width: 920px;
    max-width: calc(100% - 2rem);
}

.login-card-body,
.register-card-body {
    border-radius: 24px;
}

.login-brand-panel {
    background: linear-gradient(160deg, var(--csp-primary-dark) 0%, var(--csp-primary) 55%, var(--csp-accent) 100%);
    color: #fff;
    min-height: 100%;
}

.login-brand-panel .hero-icon {
    width: 78px;
    height: 78px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.metric-label {
    color: color-mix(in srgb, var(--csp-text) 55%, white);
    font-size: 0.9rem;
}

.table thead th {
    border-bottom: 0;
    color: var(--csp-primary-dark);
}

.badge-status {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.82rem;
}

.badge-status.pending {
    background: var(--csp-primary-soft);
    color: var(--csp-primary-dark);
}

.badge-status.done {
    background: color-mix(in srgb, var(--csp-primary) 28%, white);
    color: var(--csp-primary-dark);
}

.form-control:focus,
.custom-select:focus {
    border-color: var(--csp-primary);
    box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--csp-primary) 22%, transparent);
}

.hero-card {
    background: linear-gradient(135deg, var(--csp-surface) 0%, var(--csp-background) 100%);
}

.theme-preview {
    min-height: 150px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--preview-primary), var(--preview-accent));
    color: #fff;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.theme-preview:hover { transform: translateY(-3px); box-shadow: 0 12px 25px rgba(0,0,0,.12); }
.color-field { width: 58px; height: 42px; padding: 3px; cursor: pointer; }

.prescription-sheet {
    background: #fff;
    border: 1px solid var(--csp-primary-soft);
    border-radius: 22px;
    overflow: hidden;
}

.exam-sheet {
    background: #fff;
    border: 1px solid var(--csp-primary-soft);
    border-radius: 22px;
    overflow: hidden;
}

.exam-header {
    background: linear-gradient(90deg, #ffffff 0%, var(--csp-surface) 100%);
    border-bottom: 2px solid var(--csp-accent);
}

.exam-box {
    border: 1px solid var(--csp-primary-soft);
    border-radius: 14px;
    background: var(--csp-surface);
}

.seal-preview,
.signature-preview {
    max-width: 180px;
    max-height: 120px;
    object-fit: contain;
}

.prescription-header {
    background: linear-gradient(90deg, #ffffff 0%, var(--csp-surface) 100%);
    border-bottom: 2px solid var(--csp-accent);
}

.prescription-brand {
    color: var(--csp-primary-dark);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.prescription-watermark {
    color: color-mix(in srgb, var(--csp-primary) 8%, transparent);
    font-size: 4rem;
    line-height: 1;
    font-weight: 700;
}

.rx-line {
    border-bottom: 1px dashed var(--csp-accent);
    min-height: 42px;
}

@media print {
    .main-header,
    .main-sidebar,
    .main-footer,
    .content-header,
    .btn,
    .card-header,
    .no-print {
        display: none !important;
    }

    .content-wrapper,
    .content,
    .container-fluid,
    .card,
    .card-body {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
    }

    .prescription-sheet {
        border: 0 !important;
    }
}

@media (max-width: 768px) {
    .login-box {
        width: 100%;
    }
}
