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

:root {
    --primary-color: #2c3e50;
    --primary-light: #34495e;
    --secondary-color: #3498db;
    --background: #f5f7fa;
    --surface: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border: #dfe6e9;
    --success: #27ae60;
    --error: #e74c3c;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-lg: rgba(0, 0, 0, 0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

header {
    margin-bottom: 40px;
    padding: 30px 40px;
    background: var(--surface);
    border-radius: 2px;
    box-shadow: 0 1px 3px var(--shadow);
    border-left: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    text-align: left;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--background);
    border-radius: 2px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.user-info svg {
    display: none;
}

#usernameDisplay {
    font-weight: 500;
    color: var(--text-primary);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-logout svg {
    display: none;
}

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

/* Dropdown Section */
.dropdown-section {
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0;
}

.dropdown-header label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.results-info {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#resultsCount {
    font-weight: 600;
    color: var(--primary-color);
}

/* Custom Dropdown */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-selected {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.dropdown-selected:hover {
    border-color: var(--text-secondary);
}

.dropdown-selected.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.dropdown-selected .placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.dropdown-selected .selected-text {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.dropdown-selected.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    z-index: 1000;
    max-height: 500px;
    display: flex;
    flex-direction: column;
}

/* Dropdown Search */
.dropdown-search {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.search-icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
}

.dropdown-search #searchInput {
    width: 100%;
    padding: 8px 36px 8px 36px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    transition: all 0.2s ease;
    outline: none;
    font-family: inherit;
}

.dropdown-search #searchInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.clear-btn {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    color: var(--text-secondary);
}

.clear-btn svg {
    width: 14px;
    height: 14px;
}

.clear-btn:hover {
    color: var(--text-primary);
}

/* Dropdown List */
.dropdown-list {
    overflow-y: auto;
    max-height: 400px;
    padding: 4px;
}

.dropdown-list::-webkit-scrollbar {
    width: 6px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Dropdown Item */
.dropdown-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 2px;
}

.dropdown-item:hover {
    background: var(--background);
}

.dropdown-item:active {
    background: rgba(52, 152, 219, 0.1);
}

.dropdown-item-icon {
    display: none;
}

.dropdown-item-content {
    flex: 1;
}

.dropdown-item-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 2px;
}

.dropdown-item-name {
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 400;
    line-height: 1.4;
}

/* No Results in Dropdown */
.no-results-dropdown {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.no-results-dropdown svg {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    opacity: 0.3;
}

.no-results-dropdown p {
    font-size: 0.875rem;
}

/* Selected Product Card */
.selected-product {
    margin-top: 30px;
    background: var(--surface);
    border-radius: 2px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
}

.selected-product-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.selected-product-icon {
    display: none;
}

.selected-product-title {
    flex: 1;
}

.selected-product-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 4px;
}

.selected-product-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.selected-product-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.product-plan {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--background);
    color: var(--text-primary);
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
}

.product-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(39, 174, 96, 0.2);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    header {
        padding: 20px 16px;
        margin-bottom: 30px;
        gap: 16px;
        flex-wrap: wrap;
    }

    .header-content {
        flex: 1;
        min-width: 200px;
    }

    .header-title {
        width: 100%;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 8px !important;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.8125rem;
    }

    .dropdown-section {
        max-width: 100%;
    }

    .dropdown-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .selected-product {
        padding: 20px;
    }

    .selected-product-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .patient-info-section {
        margin-left: 0;
        margin-right: 0;
    }

    .products-table-section {
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px 10px;
    }

    header {
        padding: 16px;
    }

    header h1 {
        font-size: 1.125rem;
    }

    .subtitle {
        font-size: 0.8125rem;
    }

    .user-info,
    .btn-logout {
        font-size: 0.8125rem;
        padding: 6px 10px;
    }

    .order-info,
    .sedena-orders-section,
    .products-table-section {
        padding: 12px;
        border-radius: 0;
        margin-left: -10px;
        margin-right: -10px;
        width: calc(100% + 20px);
    }

    .sedena-order-field {
        font-size: 0.8125rem;
    }

    .btn-create-planning,
    .btn-request-collection {
        padding: 10px 16px;
        font-size: 0.8125rem;
    }

    .table-container {
        margin: 0 -12px;
        padding: 0 12px;
    }
}

/* Action Section */
.action-section {
    max-width: 800px;
    margin: 30px auto;
    text-align: center;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

/* Products Table Section */
.products-table-section {
    max-width: 1000px;
    margin: 0 auto 30px;
    background: var(--surface);
    border-radius: 2px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
    overflow: visible;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.table-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-secondary {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.table-container {
    overflow: visible;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    overflow: visible;
}

.products-table thead {
    background: var(--background);
}

.products-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

.products-table th input[type="checkbox"],
.products-table td input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.products-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.products-table tbody tr {
    overflow: visible;
}

.products-table tbody tr:hover {
    background: var(--background);
}

/* Table Select with Search */
.products-table td {
    overflow: visible;
}

.custom-select-wrapper {
    position: relative;
    width: 100%;
    overflow: visible;
}

.custom-select-trigger {
    width: 100%;
    padding: 8px 30px 8px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    user-select: none;
    position: relative;
}

.custom-select-trigger:hover {
    border-color: var(--text-secondary);
}

.custom-select-trigger.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.custom-select-trigger .placeholder {
    color: var(--text-secondary);
}

.custom-select-trigger .arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-secondary);
    transition: transform 0.2s ease;
    pointer-events: none;
}

.custom-select-trigger.active .arrow {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-dropdown {
    position: fixed;
    min-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    z-index: 1001;
    max-height: 300px;
    display: none;
    flex-direction: column;
}

.custom-select-dropdown.active {
    display: flex;
}

.custom-select-search {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.custom-select-search input {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    outline: none;
    font-family: inherit;
}

.custom-select-search input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.custom-select-options {
    overflow-y: auto;
    max-height: 240px;
}

.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: transparent;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.custom-select-option {
    padding: 8px 10px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.custom-select-option:hover {
    background: var(--background);
}

.custom-select-option.selected {
    background: rgba(44, 62, 80, 0.1);
    font-weight: 500;
}

.custom-select-option.no-results {
    color: var(--text-secondary);
    text-align: center;
    cursor: default;
    padding: 16px;
}

.custom-select-option.no-results:hover {
    background: transparent;
}

/* Table Input */
.table-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.table-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.table-input[type="number"] {
    text-align: center;
}

/* Delete Button */
.btn-delete {
    padding: 6px 12px;
    background: transparent;
    color: var(--error);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 2px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-delete:hover {
    background: rgba(231, 76, 60, 0.1);
    border-color: var(--error);
}

/* Add Row Button */
.btn-add-row {
    width: 100%;
    padding: 10px;
    margin-top: 16px;
    background: transparent;
    color: var(--primary-color);
    border: 1px dashed var(--border);
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-add-row svg {
    width: 16px;
    height: 16px;
}

.btn-add-row:hover {
    background: rgba(44, 62, 80, 0.05);
    border-color: var(--primary-color);
    border-style: solid;
}

/* Patient Info Section */
.patient-info-section {
    max-width: 1000px;
    margin: 0 auto 30px;
    background: var(--surface);
    border-radius: 2px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--shadow);
}

.section-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.section-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.patient-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-field label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input {
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.form-input:required {
    background-image: none;
}

/* Observations Section */
.observations-section {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.observations-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.observations-textarea {
    width: 100%;
    padding: 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.observations-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

/* Table Actions */
.table-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.btn-create-planning {
    padding: 12px 24px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-create-planning svg {
    width: 18px;
    height: 18px;
}

.btn-create-planning:hover:not(:disabled) {
    background: #229954;
    transform: translateY(-1px);
}

.btn-create-planning:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.spinner-small {
    width: 16px;
    height: 16px;
    animation: spin 0.8s linear infinite;
}

.spinner-small circle {
    stroke: white;
    stroke-dasharray: 50;
    stroke-dashoffset: 25;
}

/* Responsive Table */
@media (max-width: 768px) {
    .products-table-section {
        padding: 16px;
        margin: 30px 0;
    }

    .order-info {
        margin: 0 0 20px 0;
        padding: 16px;
    }

    .sedena-orders-section {
        margin: 0 0 20px 0;
        padding: 16px;
    }

    .sedena-order-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .sedena-order-row {
        flex-direction: column;
        gap: 8px;
    }

    .sedena-order-actions {
        width: 100%;
    }

    .btn-request-collection {
        width: 100%;
        justify-content: center;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .table-header h2 {
        font-size: 1rem;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -16px;
        padding: 0 16px;
    }

    .products-table {
        min-width: 650px;
    }

    .custom-select-dropdown {
        min-width: 300px;
        max-width: 90vw;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Order Info */
.order-info {
    max-width: 1000px;
    margin: 0 auto 30px;
    background: var(--surface);
    border-radius: 2px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
}

/* Sedena Orders Section */
.sedena-orders-section {
    max-width: 1000px;
    margin: 0 auto 30px;
    background: var(--surface);
    border-radius: 2px;
    padding: 24px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border);
}

.section-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sedena-order-card {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.sedena-order-info {
    flex: 1;
}

.sedena-order-row {
    display: flex;
    gap: 30px;
    margin-bottom: 8px;
}

.sedena-order-row:last-child {
    margin-bottom: 0;
}

.sedena-order-field {
    display: flex;
    gap: 8px;
}

.sedena-order-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sedena-order-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.sedena-order-actions {
    display: flex;
    gap: 10px;
}

.btn-request-collection {
    padding: 8px 16px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-request-collection:hover {
    background: #2980b9;
}

.btn-request-collection:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.state-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.state-badge.placed {
    background: rgba(241, 196, 15, 0.15);
    color: #f39c12;
    border: 1px solid rgba(241, 196, 15, 0.3);
}

.state-badge.pickup {
    background: rgba(39, 174, 96, 0.15);
    color: var(--success);
    border: 1px solid rgba(39, 174, 96, 0.3);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-value {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Orders Table Styles */
/* Filters Section */
.filters-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filters-row {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 250px;
}

.search-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.filter-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-select {
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--primary-color);
}

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 700;
    color: var(--primary-color);
}

/* Orders Table */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.orders-table thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

.orders-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.813rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.orders-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.order-row {
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.order-row:hover {
    background: rgba(52, 73, 94, 0.05);
}

.order-date {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.order-id {
    font-weight: 600;
    color: var(--primary-color);
}

.order-patient {
    font-weight: 500;
    color: var(--text-primary);
}

.order-state {
    text-align: center;
}

.state-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 2px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-badge.placed {
    background: #fff3e0;
    color: #f57c00;
}

.state-badge.pickup {
    background: #e3f2fd;
    color: #1976d2;
}

.state-badge.waiting {
    background: #f3e5f5;
    color: #7b1fa2;
}

.state-badge.waiting-approval {
    background: #e8f5e9;
    color: #388e3c;
}

.state-badge.waiting-supervisor {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.state-badge.production {
    background: #e8f5e9;
    color: #2e7d32;
}

.state-badge.incident {
    background: #fff3e0;
    color: #f57c00;
}

.state-badge.rejected {
    background: #ffebee;
    color: #c62828;
}

.order-products {
    text-align: center;
    font-weight: 500;
    color: var(--text-primary);
}

.order-total {
    text-align: right;
    font-weight: 600;
    color: var(--success);
}

/* No Orders */
.no-orders {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.no-orders svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.no-orders h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.no-orders p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    background: var(--surface);
    min-height: 200px;
}

.loading[style*="display: none"] {
    display: none !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Comments Section Styles */
.comments-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin: 24px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 100%;
    position: relative;
    z-index: 1;
}

.comments-container {
    margin-bottom: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.comments-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary);
}

.comments-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.comment-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    border-left: 3px solid #9c27b0;
    transition: all 0.2s ease;
}

.comment-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.comment-item.clinic-comment {
    border-left-color: var(--primary-color);
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: #9c27b0;
    color: white;
}

.comment-badge.clinic {
    background: var(--primary-color);
}

.comment-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.comment-text {
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.comment-form {
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.comment-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.char-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-send-comment {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-send-comment:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

.btn-send-comment:active {
    transform: translateY(0);
}

.btn-send-comment:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.loading p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Pagination Section */
.pagination-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 16px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-page {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.813rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-page:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-page.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 700;
}

.page-numbers {
    display: flex;
    gap: 4px;
}

.items-per-page {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.items-per-page label {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .filters-section {
        padding: 12px;
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .search-group {
        min-width: 100%;
    }

    .pagination-section {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn-page {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .page-numbers {
        order: -1;
        width: 100%;
        justify-content: center;
        margin-bottom: 8px;
    }

    .items-per-page {
        width: 100%;
        justify-content: center;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .orders-table {
        min-width: 750px;
    }
    
    .orders-table th,
    .orders-table td {
        padding: 8px 12px;
        font-size: 0.813rem;
    }
}

/* Botón de generar guía */
.btn-generate-guide {
    padding: 8px 16px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.813rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-generate-guide:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

.btn-generate-guide svg {
    flex-shrink: 0;
}

/* Form Styles for Modal */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 2px;
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 62, 80, 0.1);
}

.form-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232c3e50' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-input[required]:invalid {
    border-color: var(--border);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border-radius: 2px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Modal Buttons */
.btn-cancel {
    padding: 10px 20px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--background);
    border-color: var(--text-secondary);
}

.btn-confirm {
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.btn-confirm:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
}

/* Success Modal */
.success-modal {
    max-width: 450px;
}

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: rgba(39, 174, 96, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon svg {
    color: var(--success);
}

/* Triage Modal */
.triage-modal {
    max-width: 600px;
}

.triage-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.triage-option {
    padding: 16px 12px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.triage-option:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.triage-option.selected {
    border-width: 2px;
    transform: scale(1.02);
}

.triage-option.accepted.selected {
    border-color: var(--success);
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.triage-option.incident.selected {
    border-color: var(--warning);
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.triage-option.rejected.selected {
    border-color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
    color: var(--danger);
}

.triage-option svg {
    flex-shrink: 0;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 4px;
    padding: 10px;
    transition: all 0.3s;
    background: var(--background);
}

.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(0, 123, 255, 0.05);
}

.dropzone-content {
    padding: 30px;
    text-align: center;
    cursor: pointer;
    color: var(--text-secondary);
}

.dropzone-content svg {
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.dropzone-content p {
    margin: 8px 0;
    font-size: 0.9375rem;
    font-weight: 500;
}

.dropzone-hint {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.files-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.file-preview-item {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    background: var(--surface);
}

.file-preview-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.file-preview-item .file-name {
    display: block;
    padding: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--background);
}

.file-preview-item .remove-file {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.file-preview-item .remove-file:hover {
    background: var(--danger);
    transform: scale(1.1);
}

/* Textarea */
textarea.form-input {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

/* Responsive Triage Options */
@media (max-width: 768px) {
    .triage-options {
        grid-template-columns: 1fr;
    }
    
    .files-preview {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* Order Detail Page Styles */
.btn-back {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 2px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
}

.btn-back:hover {
    background: var(--background);
    border-color: var(--text-secondary);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
}

.products-table thead {
    background: var(--background);
    border-bottom: 2px solid var(--border);
}

.products-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.products-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.products-table tbody tr:hover {
    background: var(--background);
}

.products-table td {
    padding: 12px 16px;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.products-table tfoot {
    background: var(--background);
    border-top: 2px solid var(--border);
}

.products-table tfoot td {
    padding: 16px;
    font-size: 1rem;
}

/* State badges for order detail */
.state-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 2px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.state-badge.initial {
    background: rgba(158, 158, 158, 0.15);
    color: #9e9e9e;
    border: 1px solid rgba(158, 158, 158, 0.3);
}

.state-badge.placed {
    background: rgba(33, 150, 243, 0.15);
    color: #2196f3;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.state-badge.production {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

.state-badge.pickup {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.state-badge.waiting-model {
    background: rgba(63, 81, 181, 0.15);
    color: #3f51b5;
    border: 1px solid rgba(63, 81, 181, 0.3);
}

.state-badge.incident {
    background: rgba(243, 156, 18, 0.15);
    color: #f39c12;
    border: 1px solid rgba(243, 156, 18, 0.3);
}

.state-badge.rejected {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.state-badge.waiting-supervisor {
    background: rgba(255, 152, 0, 0.15);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.state-badge.waiting-admin {
    background: rgba(156, 39, 176, 0.15);
    color: #9c27b0;
    border: 1px solid rgba(156, 39, 176, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .products-table {
        font-size: 0.8125rem;
    }
    
    .products-table th,
    .products-table td {
        padding: 8px 12px;
    }
    
    .btn-back {
        margin-bottom: 12px;
    }
}

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