/* ==========================================================================
   BOXFARMA ITAÚNA - SISTEMA DE DISPENSAÇÃO E VALIDAÇÃO DE RECEITAS
   DESIGN SYSTEM & MODERN LAYOUT STYLING (PREMIUM LIGHT THEME ONLY)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Default Light Theme */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8fafc;
    --glass-bg: #ffffff;
    --glass-border: #e2e8f0;
    --primary: #6095f8;
    --primary-hover: #6095f8;
    --primary-glow: rgba(2, 132, 199, 0.08);
    --secondary: #6095f8;
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.1);
    --warning: #d97706;
    --warning-glow: rgba(217, 119, 6, 0.1);
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-glow: rgba(37, 99, 235, 0.1);

    /* Text Colors */
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dark: #94a3b8;

    /* Spacing & Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 30px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    
    /* Shadows */
    --shadow-main: 0 4px 20px 0 rgba(148, 163, 184, 0.08);
    --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.1);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.03) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(2, 132, 199, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    transition: background-color var(--transition-smooth), color var(--transition-fast);
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-fast);
}

/* ==========================================================================
   SCROLLBAR (discreta, some quando não está em uso)
   ========================================================================== */
html {
    scroll-behavior: smooth;
}

* {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color var(--transition-fast);
}

*:hover {
    scrollbar-color: var(--text-dark) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background-color var(--transition-fast);
}

*:hover::-webkit-scrollbar-thumb {
    background-color: var(--text-dark);
    background-clip: padding-box;
}

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

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex: 1;
    padding: 2.5rem;
    margin-left: 280px; /* Sidebar Width */
    transition: margin-left var(--transition-smooth);
    width: 100%;
}

/* Off-canvas behavior when sidebar is collapsed */
.app-container.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* ==========================================================================
   SIDEBAR COMPONENT (MATCHING PAINT LAYOUT)
   ========================================================================== */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1.25rem 1rem;
    transition: width var(--transition-smooth), padding var(--transition-smooth);
    box-shadow: 4px 0 24px rgba(148, 163, 184, 0.05);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

/* Minimized view for sidebar collapse */
.app-container.sidebar-collapsed .sidebar {
    width: 80px;
    padding: 2rem 0.5rem 1.5rem;
    overflow: visible !important;
}

/* Hiding brand logo and text labels when sidebar is collapsed */
.app-container.sidebar-collapsed .brand,
.app-container.sidebar-collapsed .brand-name,
.app-container.sidebar-collapsed .nav-label,
.app-container.sidebar-collapsed .sidebar-section-title,
.app-container.sidebar-collapsed .profile-details,
.app-container.sidebar-collapsed .profile-logout,
.app-container.sidebar-collapsed .sidebar-close-btn span {
    display: none !important;
}

.app-container.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

.app-container.sidebar-collapsed .sidebar-close-btn {
    align-self: center;
}

.app-container.sidebar-collapsed .nav-item a {
    justify-content: center;
    padding: 0.8rem 0;
}

.app-container.sidebar-collapsed .sidebar-profile-box {
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border-color: transparent;
}

/* Top bar: Brand logo and hamburger to close sidebar */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.15rem;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.brand-name {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.sidebar-close-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.sidebar-close-btn i {
    font-size: 1.25rem;
}

.sidebar-close-btn span {
    font-size: 0.62rem;
    text-transform: lowercase;
    font-weight: 600;
    margin-top: 0.15rem;
    white-space: nowrap;
    color: var(--text-dark);
}

.sidebar-close-btn:hover {
    color: var(--danger);
}

.sidebar-close-btn:hover span {
    color: var(--danger);
}

/* Sidebar dividers matching paint lines */
.sidebar-divider {
    height: 1px;
    background-color: var(--glass-border);
    margin: 0.4rem 0;
    border: none;
}

/* Gestão Section Header */
.sidebar-section-title {
    font-size: 0.7rem;
    text-transform: lowercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
}

/* Navigation Items */
.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.38rem 0.85rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
}

.nav-item a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-dark);
}

.nav-item.active a {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.2);
}

.nav-item.active a i {
    color: var(--primary);
}

.nav-item a:hover {
    color: var(--text-main);
    border-color: var(--text-dark);
    background: var(--bg-primary);
}

.nav-item a:hover i {
    color: var(--text-main);
}

/* Bottom Profile Box matching paint layout */
.sidebar-profile-box {
    flex-shrink: 0;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    padding: 0.55rem 0.85rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    gap: 0.65rem;
    overflow: hidden;
}

.profile-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}

.profile-details {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.profile-logout-form {
    flex-shrink: 0;
}

.profile-logout {
    background: none;
    border: none;
    font-family: inherit;
    color: var(--danger);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.profile-logout:hover {
    color: #b91c1c;
    text-decoration: underline;
}

.sidebar-profile-box {
    cursor: pointer;
}

.dropdown-header {
    padding: 0 0.25rem;
}

.dropdown-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
}

.dropdown-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.dropdown-divider {
    height: 1px;
    background: var(--glass-border);
    border: none;
    margin: 0.5rem 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    text-align: left;
}

.dropdown-item-danger {
    color: var(--danger);
}

/* ==========================================================================
   HEADER COMPONENT (WITH FLOATING HAMBURGER WHEN CLOSED)
   ========================================================================== */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    padding: 1.2rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
}

.page-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-title p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.header-left-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Floating hamburger reopen button - Only visible when menu is closed */
.hamburger-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    font-size: 1.15rem;
    cursor: pointer;
    display: none; /* Hidden by default when sidebar is open */
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    box-shadow: var(--shadow-main);
}

.app-container.sidebar-collapsed .hamburger-btn {
    display: flex; /* Display when collapsed */
}

.hamburger-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary);
    transform: scale(1.05);
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.glass-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-main);
    transition: transform var(--transition-smooth), border-color var(--transition-fast);
}

.glass-card:hover {
    border-color: rgba(2, 132, 199, 0.15);
}

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

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

/* ==========================================================================
   INPUTS & FORM ELEMENTS
   ========================================================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 1.25rem;
    color: var(--text-dark);
    font-size: 1.05rem;
    pointer-events: none;
    transition: var(--transition-fast);
}

.input-field {
    width: 100%;
    padding: 0.9rem 1.25rem 0.9rem 3.2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.input-field::placeholder {
    color: var(--text-dark);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.1);
}

.input-field:focus + .input-icon {
    color: var(--primary);
}

/* CEP Autocomplete Pulser styling */
.cep-loading {
    animation: pulse 1.5s infinite ease-in-out;
    border-color: var(--primary) !important;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.9rem 1.75rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(2, 132, 199, 0.15);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.25);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--text-dark);
    color: var(--text-main);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.25);
}

.btn-block {
    width: 100%;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-xl);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-success {
    background: var(--success-glow);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.15);
}
.badge-success .badge-dot { background: var(--success); }

.badge-warning {
    background: var(--warning-glow);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.15);
}
.badge-warning .badge-dot { background: var(--warning); }

.badge-danger {
    background: var(--danger-glow);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.15);
}
.badge-danger .badge-dot { background: var(--danger); }

.badge-info {
    background: var(--info-glow);
    color: #1e3a8a;
    border: 1px solid rgba(59, 130, 246, 0.15);
}
.badge-info .badge-dot { background: var(--info); }

/* ==========================================================================
   PRESCRIPTION VALIDATION COMPONENT
   ========================================================================== */
.receipt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.receipt-code-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dark);
    font-weight: 700;
    letter-spacing: 1px;
}

.receipt-code {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    font-family: monospace;
}

.receipt-code--lg { font-size: 1.15rem; }

.meta-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.meta-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
}

.meta-value {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
}

.meta-value--lg { font-size: 1.05rem; margin: 0.3rem 0; }

.meta-subvalue {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* Medications List */
.meds-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.meds-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.med-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-fast);
}

.med-card:hover {
    border-color: var(--text-dark);
}

.med-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.med-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.92rem;
}

.med-dosage {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.med-dosage--crm { color: var(--crm-color); opacity: 0.85; }

.med-qty {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary);
}

/* ==========================================================================
   ALERTS & FEEDBACK
   ========================================================================== */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
    font-size: 0.88rem;
    line-height: 1.4;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.alert-danger {
    background: var(--danger-glow);
    border-color: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.alert-success {
    background: var(--success-glow);
    border-color: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.alert-warning {
    background: var(--warning-glow);
    border-color: rgba(217, 119, 6, 0.15);
    color: #92400e;
}

.alert-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* ==========================================================================
   ANIMATIONS & TRANSITIONS
   ========================================================================== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scale-up {
    animation: scaleUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.empty-state-icon {
    width: 70px;
    height: 70px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: var(--transition-smooth);
}

.empty-state:hover .empty-state-icon {
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-3px);
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 320px;
    line-height: 1.5;
}

.quick-hint {
    background: var(--primary-glow);
    border: 1px dashed rgba(2, 132, 199, 0.3);
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius-md);
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ==========================================================================
   SUCCESS FULLSCREEN CELEBRATION
   ========================================================================== */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(241, 245, 249, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    animation: fadeIn 0.25s ease forwards;
}

.success-modal-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-lg);
    padding: 3rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 30px rgba(148, 163, 184, 0.12);
    animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.success-check-ring {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success-glow);
    border: 2px solid var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: var(--success);
    margin: 0 auto 1.5rem;
}

.success-modal-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.success-modal-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

/* ==========================================================================
   BREADCRUMB & MODAL TRANSITIONS
   ========================================================================== */
.header-bar.breadcrumb-mode {
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    min-height: auto;
}

/* When breadcrumb mode is active, align breadcrumb and title to the left */
.header-bar.breadcrumb-mode .header-left-actions {
    align-items: flex-start;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease forwards;
}

.modal-overlay.active {
    display: flex;
}

/* ==========================================================================
   USER PROFILE DROPDOWN COMPONENT
   ========================================================================== */
.sidebar-profile-box {
    position: relative; /* Base anchor */
}

.profile-dropdown {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px -5px rgba(148, 163, 184, 0.15), 0 8px 10px -6px rgba(148, 163, 184, 0.15);
    min-width: 180px;
    padding: 0.75rem;
    z-index: 1200;
    text-align: left;
    pointer-events: auto;
}

.profile-dropdown.active {
    display: block;
    animation: slideUpFade 0.2s ease forwards;
}

.profile-dropdown .dropdown-item:hover {
    background: rgba(239, 68, 68, 0.06) !important;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translate(-50%, 8px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   ========================================================================== */
@media (max-width: 768px) {
    /* Main container adapts to vertical stacking */
    .app-container {
        flex-direction: column;
    }

    .main-content {
        margin-left: 0 !important;
        margin-top: 60px; /* Leave space for the top navbar */
        padding: 1.5rem 1rem !important;
        min-height: calc(100vh - 60px);
    }

    /* 1. COLLAPSED (MINIMIZED) STATE ON MOBILE - BECOMES TOP NAVBAR */
    .app-container.sidebar-collapsed .sidebar {
        width: 100% !important;
        height: 60px !important;
        flex-direction: row-reverse !important; /* Puts hamburger on the right, profile badge on the left */
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0 1.25rem !important;
        border-right: none !important;
        border-bottom: 1px solid var(--glass-border) !important;
        box-shadow: 0 4px 20px rgba(148, 163, 184, 0.05) !important;
        z-index: 9999 !important; /* Floating above breadcrumbs/all contents */
        overflow: visible !important; /* Enable dropdown output rendering */
    }

    /* Hide navigation menu entirely in mobile collapsed mode */
    .app-container.sidebar-collapsed .sidebar-nav {
        display: none !important;
    }

    /* Adjust header inside collapsed sidebar/navbar */
    .app-container.sidebar-collapsed .sidebar-header {
        margin-bottom: 0 !important;
        width: auto !important;
        justify-content: flex-end !important;
        overflow: visible !important;
    }

    .app-container.sidebar-collapsed .sidebar-close-btn {
        align-self: center !important;
    }

    /* Hide divider in collapsed navbar */
    .app-container.sidebar-collapsed .sidebar-divider {
        display: none !important;
    }

    /* Align avatar badge on mobile navbar left side */
    .app-container.sidebar-collapsed .sidebar-profile-box {
        margin-top: 0 !important;
        margin-left: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        overflow: visible !important; /* Enable dropdown output rendering */
    }

    /* Mobile profile dropdown adjustments to open downwards */
    .app-container.sidebar-collapsed .profile-dropdown {
        bottom: auto !important;
        top: calc(100% + 10px) !important;
        left: 0 !important;
        transform: none !important;
        animation: slideDownFadeMobile 0.2s ease forwards !important;
    }

    /* 2. OPENED STATE ON MOBILE - OCCUPIES WHOLE SCREEN OVERLAY */
    .sidebar {
        width: 100% !important;
        height: 100vh !important;
        padding: 1.5rem 1.5rem !important;
        z-index: 1100 !important;
    }

    /* Brand stays next to hamburger when expanded */
    .sidebar-header {
        margin-bottom: 2rem !important;
        overflow: visible !important;
    }

    /* Make profile box a standard flex display on bottom */
    .sidebar-profile-box {
        padding: 1rem !important;
        background: var(--bg-tertiary) !important;
        border: 1px solid var(--glass-border) !important;
    }

    /* Hide footer margins */
    .app-footer {
        margin-top: 2rem !important;
    }
}

@keyframes slideDownFadeMobile {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Margin Top */
.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: 0.25rem !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mt-5 {
    margin-top: 3rem !important;
}

.mt-auto {
    margin-top: auto !important;
}

/* Margin Bottom */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.mb-5 {
    margin-bottom: 3rem !important;
}

.mb-auto {
    margin-bottom: auto !important;
}
.img-fluid{
    width: 100%;
    height: auto;
}

/* ==========================================================================
   LOGIN PAGE
   ========================================================================== */
body.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    min-height: 100vh;
}

.login-card {
    max-width: 420px;
    width: 100%;
    padding: 3rem 2.5rem;
    animation: scaleUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.8rem;
    box-shadow: var(--shadow-glow);
}

.login-brand-text {
    text-align: center;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 800;
    background: var(--primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.login-alert {
    margin-bottom: 1.5rem;
    font-size: 0.88rem;
    padding: 0.75rem 1rem;
}

.login-alert-icon {
    font-size: 1rem;
}

.login-form-group-tight {
    margin-bottom: 2rem;
}

.login-remember-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    font-size: 0.85rem;
}

.login-remember-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.login-remember-checkbox {
    accent-color: var(--primary);
}

.login-submit {
    padding: 1.1rem;
    font-size: 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--text-dark);
}

.app-footer {
    margin-top: 4rem;
    border-top: 1px solid var(--glass-border);
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-dark);
}

/* ==========================================================================
   AUTORIZAÇÃO DE RETIRADA — wizard (scanner / crm / url)
   ========================================================================== */
:root {
    --crm-color: #6161ff;
    --crm-color-dark: #4040cc;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.step-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.step-icon--primary { background: var(--primary-glow); border: 1px solid rgba(2, 132, 199, 0.2); color: var(--primary); }
.step-icon--crm { background: rgba(97, 97, 255, 0.1); border: 1px solid rgba(97, 97, 255, 0.2); color: var(--crm-color); }
.step-icon--success { background: var(--success-glow); border: 1px solid rgba(16, 185, 129, 0.2); color: var(--success); }
.step-icon--warning { background: var(--warning-glow); border: 1px solid rgba(245, 158, 11, 0.2); color: var(--warning); }
.step-icon--danger { background: var(--danger-glow); border: 2px solid var(--danger); color: var(--danger); }
.step-icon--url { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); color: #10b981; }

.step-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.step-subtitle {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Escolha de método */
.method-intro {
    text-align: center;
    margin-bottom: 2rem;
}

.method-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.method-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-main);
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
}

.method-card {
    width: 100%;
    padding: 2rem 1.5rem;
    background: var(--bg-tertiary);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
}

.method-card--scanner:hover { border-color: rgba(2, 132, 199, 0.5); background: var(--primary-glow); }
.method-card--crm:hover { border-color: rgba(97, 97, 255, 0.5); background: rgba(97, 97, 255, 0.06); }
.method-card--url:hover { border-color: rgba(16, 185, 129, 0.5); background: rgba(16, 185, 129, 0.06); }

.method-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.6rem;
}

.method-card-icon--scanner { background: var(--primary-glow); border: 1px solid rgba(2, 132, 199, 0.2); color: var(--primary); }
.method-card-icon--crm { background: rgba(97, 97, 255, 0.1); border: 1px solid rgba(97, 97, 255, 0.2); color: var(--crm-color); }
.method-card-icon--url { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.2); color: #10b981; }

.method-card-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.method-card-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Banner do médico validado (CRM) */
.medico-banner {
    padding: 1rem 1.5rem;
    margin-bottom: 1.25rem;
}

.medico-banner--ativo { border-color: rgba(16, 185, 129, 0.25); }
.medico-banner--inativo { border-color: rgba(239, 68, 68, 0.25); }

.medico-banner-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.medico-banner-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.medico-banner-badge {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid;
}

.medico-banner-badge--ativo { background: var(--success-glow); border-color: var(--success); color: var(--success); }
.medico-banner-badge--inativo { background: var(--danger-glow); border-color: var(--danger); color: var(--danger); }

.medico-banner-crm {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.medico-banner-crm--ativo { color: var(--success); }
.medico-banner-crm--inativo { color: var(--danger); }

.medico-banner-nome {
    font-weight: 700;
    color: var(--text-main);
}

.medico-banner-especialidades {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Botões ghost / link */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-ghost:hover {
    border-color: var(--text-dark);
    color: var(--text-main);
}

.btn-link-muted {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
}

/* Formulários do wizard */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

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

.form-grid-numero {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 1rem;
}

.form-grid-tipo-registro {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1rem;
}

.form-grid-crm {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.field-required {
    color: var(--danger);
}

.action-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.action-row--end {
    justify-content: flex-end;
}

.action-row--center {
    text-align: center;
    margin-top: 1.25rem;
}

.form-actions-right {
    margin-top: 0.75rem;
    text-align: right;
}

.field-inline-search {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.field-inline-search .input-container {
    flex: 1;
}

/* Cards de informação (paciente confirmar / resumo) */
.info-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    font-size: 0.88rem;
}

.info-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.info-value {
    font-weight: 600;
    color: var(--text-main);
}

.info-value--mono { font-family: monospace; }
.info-label--section { margin-bottom: 1rem; }

.status-inline {
    margin-top: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-inline--success { color: var(--success); }
.status-inline--warning { color: var(--warning); }
.status-inline--danger { color: var(--danger); }

/* Estados de página inteira (bloqueado / mismatch) */
.state-card {
    text-align: center;
    padding: 2.5rem;
}

.state-card--danger { border-color: rgba(239, 68, 68, 0.3); }

.state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 1.8rem;
}

.state-icon--danger { background: var(--danger-glow); border: 2px solid var(--danger); color: var(--danger); }

.state-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.state-title--danger { color: var(--danger); }

.state-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 460px;
    margin: 0 auto 1.75rem;
    line-height: 1.6;
}

/* Receita — cabeçalho + badges (dispensar CRM/scanner) */
.receipt-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.receipt-badges {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: var(--success-glow);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

.dates-row {
    display: flex;
    gap: 2rem;
    background: var(--bg-tertiary);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.summary-info-row {
    display: flex;
    gap: 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

/* Embed Memed (iframe) */
.memed-embed-card {
    padding: 0;
    overflow: hidden;
    margin-bottom: 1.25rem;
    border-color: rgba(97, 97, 255, 0.15);
}

.memed-embed-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.memed-embed-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.memed-embed-logo {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--crm-color), var(--crm-color-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.memed-embed-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--crm-color);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.memed-embed-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.memed-embed-link:hover {
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.3);
}

.memed-embed-frame-wrap {
    position: relative;
    width: 100%;
    min-height: 640px;
    background: var(--bg-tertiary);
}

.memed-embed-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    z-index: 1;
    transition: opacity 0.2s ease;
}

.memed-embed-loader.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.memed-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(97, 97, 255, 0.2);
    border-top-color: var(--crm-color);
    border-radius: 50%;
    animation: memedSpin 0.8s linear infinite;
}

@keyframes memedSpin {
    to { transform: rotate(360deg); }
}

.memed-embed-iframe {
    width: 100%;
    min-height: 640px;
    border: none;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.memed-embed-iframe.is-loaded {
    opacity: 1;
}

/* Modal de checkout */
.checkout-modal-card {
    max-width: 100%;
    padding: 2.5rem;
    position: relative;
    border-color: rgba(16, 185, 129, 0.25);
}

.modal-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-dark);
}

/* Modal câmera QR */
.qr-modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.qr-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qr-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.qr-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

.qr-video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.qr-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-video-frame canvas {
    display: none;
}

.qr-corners {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.qr-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: var(--primary);
    border-style: solid;
    border-width: 0;
}

.qr-corner--tl { top: 15%; left: 15%; border-top-width: 3px; border-left-width: 3px; border-radius: 2px 0 0 0; }
.qr-corner--tr { top: 15%; right: 15%; border-top-width: 3px; border-right-width: 3px; border-radius: 0 2px 0 0; }
.qr-corner--bl { bottom: 15%; left: 15%; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 2px; }
.qr-corner--br { bottom: 15%; right: 15%; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 2px 0; }

.qr-scan-line {
    position: absolute;
    left: 15%;
    right: 15%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: qrScanLine 2s linear infinite;
    top: 15%;
}

@keyframes qrScanLine {
    0% { top: 15%; }
    50% { top: 82%; }
    100% { top: 15%; }
}

.qr-status {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 1.2em;
}

#receita_id.scanner-flash {
    animation: scannerFlash 0.4s ease;
}

@keyframes scannerFlash {
    0%, 100% { box-shadow: none; border-color: var(--glass-border); }
    50% { box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.4); border-color: var(--primary); }
}

/* Progresso do wizard */
.wizard-progress {
    padding: 1.1rem 1.75rem;
    margin-bottom: 1.75rem;
}

.wizard-progress-row {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    z-index: 1;
}

.wizard-step-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--text-dark);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.wizard-step-circle--ativo {
    border-color: var(--primary);
    background: var(--primary-glow);
    color: var(--primary);
}

.wizard-step-circle--concluido {
    border-color: var(--success);
    background: var(--success-glow);
    color: var(--success);
}

.wizard-step-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
}

.wizard-step-label--ativo {
    font-weight: 700;
    color: var(--text-main);
}

.wizard-connector {
    flex: 1;
    height: 2px;
    background: var(--glass-border);
    margin-bottom: 1.4rem;
}

.wizard-connector--concluido {
    background: var(--success);
}

/* Overlay de sucesso — variante compacta pra métricas do checkout */
.success-checkout-box {
    justify-content: center;
    background: var(--success-glow);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
    margin-bottom: 2rem;
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
}

.success-checkout-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.success-checkout-value {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 1px;
}

/* ==========================================================================
   AUDITORIA — listagens (autorizações / consultas)
   ========================================================================== */
.auditoria-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.auditoria-stats { display: flex; gap: 1rem; flex-wrap: wrap; }
.auditoria-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.5rem;
    min-width: 150px;
}

.stat-card-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.stat-card-icon--primary { background: var(--primary-glow); color: var(--primary); }
.stat-card-icon--success { background: var(--success-glow); color: var(--success); }
.stat-card-icon--warning { background: var(--warning-glow); color: var(--warning); }
.stat-card-icon--danger { background: var(--danger-glow); color: var(--danger); }

.stat-card-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.stat-card-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.filter-card { margin-bottom: 1.5rem; padding: 1.25rem 1.5rem; }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.85rem;
    align-items: flex-end;
}

/* Sem padding-top fixo: alinhamento com os campos vem do label invisível
   (mesma marcação de .form-label) que .filter-actions carrega em cima dos
   botões — evita descompasso quando um rótulo de campo vizinho quebra
   linha, o que o valor fixo antigo não cobria. */
.filter-actions { display: flex; flex-direction: column; }
.filter-actions .form-label { visibility: hidden; }
.filter-actions-row { display: flex; gap: 0.5rem; }
.filter-actions .btn-primary { flex: 1; padding: 0.65rem; font-size: 0.85rem; }
.filter-actions .btn-secondary { padding: 0.65rem 0.75rem; font-size: 0.85rem; }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

.data-table thead th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--glass-border);
}

.data-table tbody td {
    padding: 0.9rem 1rem;
    vertical-align: top;
    border-bottom: 1px solid var(--glass-border);
}

.data-table tbody tr:nth-child(even) { background: rgba(15, 23, 42, 0.015); }
.data-table tbody tr:hover { background: var(--primary-glow); }
.table-row-clicavel { cursor: pointer; }

.cell-title { font-weight: 600; color: var(--text-main); }
.cell-muted { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.cell-mono { font-family: monospace; font-weight: 700; letter-spacing: 0.5px; color: var(--text-main); word-break: break-all; }
.cell-empty { color: var(--text-dark); font-size: 0.78rem; }
.cell-id { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.cell-checkout { font-family: monospace; font-weight: 700; font-size: 0.9rem; color: var(--success); }
.cell-highlight { color: var(--primary); font-weight: 600; }

.med-chip-list { display: flex; flex-direction: column; gap: 0.4rem; min-width: 200px; }

.med-chip {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.7rem;
}

.med-chip-name { font-weight: 600; color: var(--text-main); font-size: 0.78rem; }
.med-chip-dose { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.1rem; }
.med-chip-qty { font-size: 0.7rem; color: var(--primary); font-weight: 600; margin-top: 0.1rem; }

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
}

.table-footer-count { font-size: 0.78rem; color: var(--text-muted); }

.pagination { display: flex; gap: 0.4rem; align-items: center; }
.pagination-arrow { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--bg-secondary);
    color: var(--text-muted);
    border: 1px solid var(--glass-border);
}

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

.state-icon--neutral { background: var(--bg-tertiary); border: 2px solid var(--glass-border); color: var(--text-dark); }

.badge-neutral { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--glass-border); }
.badge-brand { background: rgba(97, 97, 255, 0.1); color: #6161ff; border: 1px solid rgba(97, 97, 255, 0.25); }
.badge-brand-deep { background: rgba(64, 64, 204, 0.1); color: #4040cc; border: 1px solid rgba(64, 64, 204, 0.25); }

.badge-row { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.35rem; }
.badge-row--flush { margin-top: 0; }

.memed-link-chip {
    margin-top: 0.45rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(97, 97, 255, 0.1);
    color: #6161ff;
    border: 1px solid rgba(97, 97, 255, 0.3);
    cursor: pointer;
    transition: background 0.15s;
}

.memed-link-chip:hover { background: rgba(97, 97, 255, 0.18); }

/* Modal viewer Memed (auditoria de autorizações) */
.memed-viewer-modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 900px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-self: flex-start;
    margin-top: 1rem;
}

.memed-viewer-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.memed-viewer-modal-brand { display: flex; align-items: center; gap: 0.65rem; }

.memed-viewer-modal-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6161ff, #4040cc);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.memed-viewer-modal-eyebrow { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: #6161ff; letter-spacing: 0.4px; }
.memed-viewer-modal-codigo { font-family: monospace; font-size: 0.95rem; font-weight: 800; color: var(--text-main); }
.memed-viewer-modal-actions { display: flex; align-items: center; gap: 0.65rem; }

.memed-viewer-modal-link {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
    transition: color 0.15s, border-color 0.15s;
}

.memed-viewer-modal-link:hover { color: var(--primary); border-color: rgba(2, 132, 199, 0.3); }

.memed-viewer-modal-frame-wrap { position: relative; width: 100%; min-height: 680px; background: var(--bg-tertiary); }

.memed-viewer-modal-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    z-index: 1;
}

.memed-viewer-modal-loader.is-hidden { display: none; }

.memed-viewer-modal-iframe {
    width: 100%;
    min-height: 680px;
    border: none;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.memed-viewer-modal-iframe.is-loaded { opacity: 1; }

@media print {
    .sidebar, .header-bar, .filter-card, .auditoria-actions, .table-footer .pagination { display: none !important; }
    body, .main-content, .app-container { background: #fff !important; color: #000 !important; }
    .glass-card { border: 1px solid #ccc !important; box-shadow: none !important; background: #fff !important; }
    .data-table { font-size: 0.75rem !important; }
    .data-table th, .data-table td { padding: 0.4rem 0.6rem !important; color: #000 !important; border-bottom: 1px solid #ddd !important; }
    .data-table th { background: #f5f5f5 !important; color: #333 !important; }
    @page { margin: 1.5cm; size: landscape; }
}

/* ==========================================================================
   UTILITÁRIOS PONTUAIS
   Pequeno conjunto de classes pra eliminar ajustes de espaçamento/cor que
   antes eram feitos com style="" solto nas views (regra do projeto: CSS
   sempre em arquivo separado, nunca inline).
   ========================================================================== */
.form-inline { display: inline; }
.form-group--tight { margin-bottom: 0; }
.mb-lg { margin-bottom: 1.25rem; }
.mb-xl { margin-bottom: 1.5rem; }
.text-faint { color: var(--text-dark); }
.icon-inline { margin-right: 0.4rem; }
.icon-inline-sm { margin-right: 0.3rem; }
.text-muted-inline { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.status-inline--flush { margin-top: 0; }
.form-flex-item { flex: 1; min-width: 200px; }
.form-group--span2 { grid-column: span 2; }
.input-field--locked { opacity: 0.6; cursor: not-allowed; pointer-events: none; }

/* ==========================================================================
   CONFIGURAÇÕES — seções, toggles e radio-pills
   ========================================================================== */
.settings-section { margin-bottom: 1.5rem; }

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    padding-bottom: 0.85rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--glass-border);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-label { display: flex; flex-direction: column; gap: 0.2rem; }
.settings-row-label strong { color: var(--text-main); font-size: 0.9rem; }
.settings-row-label span { color: var(--text-muted); font-size: 0.8rem; }

.toggle-switch { position: relative; display: inline-block; width: 46px; height: 25px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--glass-border);
    border-radius: 999px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 19px;
    width: 19px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(21px); }

.radio-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.radio-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.radio-pill:has(input:checked) { border-color: var(--primary); background: var(--primary-glow); color: var(--primary); font-weight: 700; }

.settings-sub {
    margin-left: 1rem;
    padding-left: 1rem;
    border-left: 2px solid var(--glass-border);
    margin-top: 0.5rem;
}

.settings-footer { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-top: 1rem; }

/* ==========================================================================
   MONITORAMENTO — filtros de período, rankings com barra
   ========================================================================== */
.period-filters { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.period-buttons { display: flex; gap: 0.4rem; }

.period-btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-fast);
}

.period-btn:hover { border-color: rgba(2, 132, 199, 0.4); color: var(--primary); }
.period-btn--active { background: var(--primary); border-color: var(--primary); color: #fff; }

.period-custom-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.period-custom-form .input-field { padding: 0.5rem 0.75rem; font-size: 0.82rem; width: auto; }

.mon-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }

.rank-list { display: flex; flex-direction: column; gap: 0.75rem; }

.rank-row { display: flex; align-items: center; gap: 0.85rem; }

.rank-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
    background: var(--bg-tertiary);
    color: var(--text-dark);
}

.rank-icon--1 { background: rgba(245, 158, 11, 0.15); color: #d97706; }
.rank-icon--2 { background: rgba(148, 163, 184, 0.2); color: #64748b; }
.rank-icon--3 { background: rgba(180, 83, 9, 0.15); color: #b45309; }

.rank-body { flex: 1; min-width: 0; }

.rank-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.rank-name { font-size: 0.85rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-count { font-size: 0.85rem; font-weight: 800; color: var(--text-main); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.rank-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }

.bar-track { width: 100%; height: 6px; border-radius: 999px; background: var(--bg-tertiary); margin-top: 0.35rem; overflow: hidden; }
.bar-fill { width: 0; height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.4s ease; }

.mon-chart-wrap { position: relative; height: 220px; margin-bottom: 1.1rem; }
.mon-chart-wrap--sm { height: 180px; }
.mon-chart-divider { border: none; border-top: 1px dashed var(--border-color, #e2e8f0); margin: 0 0 1.1rem; }

.textarea-field {
    width: 100%;
    padding: 0.9rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.9rem;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-smooth);
}

.textarea-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.1);
}

.termo-uso-texto {
    white-space: pre-line;
    max-height: 260px;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.6;
}

.mon-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.form-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--glass-border);
    margin-top: 0.5rem;
}

.contatos-form-extra {
    display: none;
    margin-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

.contatos-form-extra.is-visible { display: block; }
.is-hidden { display: none !important; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
.table-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.receita-item-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }

.receita-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.25rem;
}

.receita-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.receita-item-meta { margin-top: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.panel-count { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }

