/* ===== DESIGN SYSTEM: LIVIA ===== */
/* Dark mode exclusivo — premium tech-médico */

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #1e2130;
    color: #ffffff;
    line-height: 1.6;
    min-height: 100vh;
    scroll-behavior: smooth;
}

/* Scrollbar customizada — accent laranja */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1e2130;
}

::-webkit-scrollbar-thumb {
    background: #E8875A;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #d47a50;
}

/* ===== HEADER ===== */
.header {
    background: #252839;
    color: white;
    padding: 28px 0;
    margin-bottom: 36px;
    border-bottom: 1px solid rgba(155, 111, 212, 0.25);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.4);
}

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

.header-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #9B6FD4 0%, #E8875A 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(155, 111, 212, 0.4);
    flex-shrink: 0;
}

.header-icon svg {
    width: 30px;
    height: 30px;
    color: white;
}

.header-text {
    flex: 1;
}

.header h1 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    background: linear-gradient(135deg, #9B6FD4 0%, #E8875A 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 5px;
    font-weight: 400;
}

/* ===== LAYOUT ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== CARDS ===== */
.card {
    background: #252839;
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    animation: fadeInUp 0.4s ease-out;
}

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

.card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border-color: rgba(155, 111, 212, 0.2);
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.2px;
}

.card-title::before {
    content: '';
    width: 3px;
    height: 20px;
    background: linear-gradient(180deg, #9B6FD4 0%, #E8875A 100%);
    border-radius: 2px;
    flex-shrink: 0;
}

.section-icon {
    width: 20px;
    height: 20px;
    color: #9B6FD4;
    flex-shrink: 0;
}

.card-error {
    border-left: 4px solid #e74c3c;
    background: rgba(231, 76, 60, 0.08);
    border-color: rgba(231, 76, 60, 0.3);
}

.card-error .card-title {
    color: #ff7070;
}

.card-error .card-title::before {
    background: #e74c3c;
}

/* ===== FORMS ===== */
.form-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-grid.cols-3-action { grid-template-columns: 1fr 2fr auto; align-items: end; }

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group input,
.form-group select {
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: #ffffff;
    background: #2a2d3e;
    transition: all 0.2s ease;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
}

/* Remove spinners from number inputs */
.form-group input[type="number"]::-webkit-outer-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.form-group input[type="number"] {
    -moz-appearance: textfield;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ffffff60' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select option {
    background: #2a2d3e;
    color: #ffffff;
}

.form-group input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.form-group input:hover,
.form-group select:hover {
    border-color: rgba(155, 111, 212, 0.4);
    background: #2f3247;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #9B6FD4;
    box-shadow: 0 0 0 3px rgba(155, 111, 212, 0.18);
    background: #2f3247;
}

.form-group input:disabled,
.form-group select:disabled {
    background: #1e2130;
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    letter-spacing: 0.3px;
}

.btn:hover {
    transform: translateY(-2px);
}

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

.btn-primary {
    background: linear-gradient(135deg, #9B6FD4 0%, #E8875A 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(155, 111, 212, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 8px 24px rgba(155, 111, 212, 0.5);
    filter: brightness(1.08);
}

.btn-add {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.btn-add:hover {
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.45);
    filter: brightness(1.08);
}

.btn-secondary {
    background: #2a2d3e;
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: #333650;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.45);
    filter: brightness(1.08);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-lg {
    padding: 16px 40px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.btn-remove {
    background: none;
    border: 1px solid rgba(231, 76, 60, 0.5);
    color: #ff7070;
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-remove:hover {
    background: rgba(231, 76, 60, 0.15);
    border-color: #e74c3c;
    color: #ff5050;
}

/* ===== TABLES ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.data-table thead th {
    background: #2a2d42;
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid rgba(155, 111, 212, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.data-table tbody td {
    padding: 13px 16px;
    font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: #252839;
    color: rgba(255, 255, 255, 0.85);
    transition: background 0.2s ease;
}

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

.data-table tbody tr:hover td {
    background: #2a2d42;
}

.data-table tbody tr:nth-child(even) td {
    background: #222535;
}

.data-table tbody tr:nth-child(even):hover td {
    background: #2a2d42;
}

.empty-message {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    padding: 24px;
    font-style: italic;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    margin-top: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.08);
}

/* ===== AUTOCOMPLETE ===== */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #252839;
    border: 1px solid rgba(155, 111, 212, 0.3);
    border-radius: 12px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
}

.autocomplete-item:hover {
    background: #2a2d42;
    border-left: 3px solid #9B6FD4;
    padding-left: 13px;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item strong {
    display: block;
    font-size: 14px;
    color: #ffffff;
    font-weight: 600;
}

.autocomplete-item .dcb-code {
    font-size: 12px;
    color: #9B6FD4;
    font-weight: 600;
}

.autocomplete-item .brand-name {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 8px;
}

.autocomplete-empty,
.autocomplete-error {
    padding: 12px 14px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    font-style: italic;
}

.autocomplete-error {
    color: #ff7070;
}

/* ===== SELECTED MED INFO ===== */
.selected-med-info {
    background: rgba(155, 111, 212, 0.1);
    border: 1px solid rgba(155, 111, 212, 0.25);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 18px;
    font-size: 14px;
}

.selected-med-info .med-name {
    font-weight: 700;
    color: #ffffff;
    font-size: 15px;
}

.selected-med-info .med-dcb {
    color: #E8875A;
    font-weight: 700;
    background: rgba(232, 135, 90, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid rgba(232, 135, 90, 0.3);
}

/* ===== MED DETAIL FORM ===== */
.med-detail-form {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(155, 111, 212, 0.3);
    border-radius: 12px;
    padding: 20px;
    margin-top: 16px;
    margin-bottom: 16px;
}

/* ===== ACTION BAR ===== */
.action-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 32px 0;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ===== PAYLOAD DEBUG ===== */
#payload-content {
    background: #1a1d2e;
    color: #a6e3a1;
    padding: 16px;
    border-radius: 8px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid rgba(166, 227, 161, 0.15);
}

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 33, 48, 0.97);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

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

.loading-overlay p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 18px;
    font-weight: 600;
    margin-top: 24px;
    letter-spacing: 0.5px;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(155, 111, 212, 0.2);
    border-top-color: #9B6FD4;
    border-right-color: #E8875A;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

/* ===== RESULTS ===== */
.alert-count-badge {
    background: linear-gradient(135deg, #9B6FD4 0%, #E8875A 100%);
    color: white;
    padding: 7px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(155, 111, 212, 0.35);
    letter-spacing: 0.3px;
    gap: 4px;
}

.side-panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.json-debug-toggle {
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.62);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.json-debug-toggle:hover,
.json-debug-toggle-active {
    border-color: rgba(155, 111, 212, 0.55);
    background: rgba(155, 111, 212, 0.16);
    color: #ffffff;
}

.json-debug-panel {
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.14);
    padding: 12px 14px;
    max-height: 45vh;
    overflow-y: auto;
}

.json-debug-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    font-weight: 700;
}

.json-debug-close {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    padding: 2px 0;
}

.json-debug-close:hover {
    color: #ffffff;
}

.json-debug-panel details {
    margin-top: 8px;
}

.json-debug-panel summary {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
    font-weight: 700;
    user-select: none;
}

.json-debug-section-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.json-debug-copy {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.62);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    transition: all 0.2s ease;
}

.json-debug-copy:hover:not(:disabled) {
    background: rgba(155, 111, 212, 0.16);
    border-color: rgba(155, 111, 212, 0.45);
    color: #ffffff;
}

.json-debug-copy:disabled {
    cursor: default;
    opacity: 0.7;
}

.json-debug-panel pre {
    margin-top: 8px;
    padding: 10px;
    border-radius: 8px;
    background: #1a1d2e;
    border: 1px solid rgba(166, 227, 161, 0.12);
    color: #a6e3a1;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 260px;
    overflow: auto;
}

.no-alerts {
    text-align: center;
    padding: 60px 20px;
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.06);
    border-radius: 12px;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

.no-alerts h3 {
    font-size: 22px;
    margin-bottom: 10px;
    font-weight: 700;
    color: #2ecc71;
}

.no-alerts p {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
}

/* ===== DRUG CARD ===== */
.drug-card {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 5px solid #6c757d;
    border-radius: 14px;
    margin-bottom: 20px;
    overflow: hidden;
    background: #222535;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
}

.drug-card:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
    transform: translateX(2px);
}

.drug-card-header {
    background: #2a2d42;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.drug-route-info {
    font-size: 11px;
    color: #9ca3af;
    background: rgba(255,255,255,0.07);
    border-radius: 4px;
    padding: 2px 8px;
    letter-spacing: 0.02em;
}

.drug-card-remove {
    margin-left: auto;
    font-size: 11px;
    padding: 3px 10px;
}

.drug-card-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.drug-card-title-block {
    flex: 1;
    min-width: 0;
}

.drug-card-title-block h3 {
    font-size: 16px;
    font-weight: 700;
    text-transform: capitalize;
    margin-bottom: 4px;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.drug-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.drug-card-header .dcb-label {
    font-size: 11px;
    color: #E8875A;
    font-weight: 700;
    background: rgba(232, 135, 90, 0.12);
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid rgba(232, 135, 90, 0.25);
}

.drug-card-badges {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    align-items: center;
    flex-shrink: 0;
}

.drug-card-body {
    padding: 12px 18px;
}

/* ===== FALL RISK CARD ===== */
.fall-risk-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    position: relative;
}

.fall-risk-header .side-card-chevron {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.fall-risk-card.expanded .fall-risk-header .side-card-chevron {
    transform: translateY(-50%) rotate(180deg);
}

.fall-risk-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fall-risk-icon {
    font-size: 16px;
    opacity: 0.85;
}

.fall-risk-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.fall-risk-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.fall-risk-msg {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 8px;
    line-height: 1.5;
}

.fall-risk-orientacao {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.5;
    margin-top: 0;
}

.fall-risk-meds {
    margin-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding-top: 8px;
}

.fall-risk-meds ul {
    margin: 0;
    padding-left: 16px;
}

.fall-risk-meds li {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.6;
    margin-bottom: 4px;
}

.fall-risk-meds strong {
    color: rgba(255, 255, 255, 0.85);
}

/* Interaction icons row */
.drug-interaction-icons {
    display: flex;
    gap: 8px;
    padding: 10px 18px;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.interaction-icon-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
}

.interaction-icon-circle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
    border-color: currentColor;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.interaction-icon-circle svg {
    width: 22px;
    height: 22px;
}

/* "Interage com" tags */
.drug-interacts-with {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.interacts-label {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
    font-size: 12px;
}

.drug-interact-tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, #9B6FD4 0%, #E8875A 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(155, 111, 212, 0.3);
    transition: all 0.2s ease;
}

.drug-interact-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(155, 111, 212, 0.45);
}

.drug-interact-tag.tag-more {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Last section in drug card shouldn't have bottom border */
.drug-interaction-icons:last-child,
.drug-interacts-with:last-child {
    border-bottom: none;
}

/* Severity border colors */
.severity-border-contraindicated { border-left-color: #c0392b; }
.severity-border-major { border-left-color: #e74c3c; }
.severity-border-moderate { border-left-color: #f39c12; }
.severity-border-minor { border-left-color: #f1c40f; }
.severity-border-info { border-left-color: #4a5568; }

/* Severity number colors */
.severity-border-contraindicated .drug-card-number { background: rgba(192, 57, 43, 0.3); color: #ff7070; }
.severity-border-major .drug-card-number { background: rgba(231, 76, 60, 0.25); color: #ff8a7a; }
.severity-border-moderate .drug-card-number { background: rgba(243, 156, 18, 0.25); color: #ffc966; }
.severity-border-minor .drug-card-number { background: rgba(241, 196, 15, 0.2); color: #ffe066; }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

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

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

.badge-posologia {
    background: rgba(33, 150, 243, 0.15);
    color: #90caf9;
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Severity badges */
.severity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.severity-contraindicated { background: rgba(139, 0, 0, 0.5); color: #ffb3b3; border: 1px solid rgba(192, 57, 43, 0.5); }
.severity-major { background: rgba(231, 76, 60, 0.25); color: #ff8a7a; border: 1px solid rgba(231, 76, 60, 0.4); }
.severity-moderate { background: rgba(243, 156, 18, 0.2); color: #ffc966; border: 1px solid rgba(243, 156, 18, 0.4); }
.severity-minor { background: rgba(241, 196, 15, 0.15); color: #ffe066; border: 1px solid rgba(241, 196, 15, 0.3); }
.severity-caution { background: rgba(33, 150, 243, 0.2); color: #90caf9; border: 1px solid rgba(33, 150, 243, 0.3); }

/* Type badges */
.interaction-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    opacity: 0.9;
}

.type-drug { background: #7B6FD4; }
.type-alcohol { background: #8e44ad; }
.type-food { background: #27ae60; }
.type-pregnancy { background: #e91e63; }
.type-lactation { background: #e91e63; }
.type-lab-test { background: #00bcd4; }
.type-health-condition { background: #ff5722; }
.type-elderly { background: #795548; }
.type-posologia { background: #2196F3; }

/* ===== INTERACTION ITEMS ===== */
.interaction-item {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.03);
}

.interaction-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.interaction-header .secondary-drug {
    font-weight: 600;
    color: #ffffff;
    font-size: 14px;
}

.interaction-detail {
    margin-top: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.7;
}

.interaction-body {
    margin-top: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.7;
}

.interaction-body.collapsed,
.drug-card-body.collapsed {
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    padding: 0 18px;
}

.expand-btn {
    background: none;
    border: none;
    color: #9B6FD4;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    margin-top: 4px;
    font-family: inherit;
}

.expand-btn:hover {
    color: #E8875A;
    text-decoration: underline;
}

.elderly-details {
    margin-top: 8px;
    padding: 10px;
    background: rgba(121, 85, 72, 0.15);
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid rgba(121, 85, 72, 0.3);
    color: rgba(255, 255, 255, 0.75);
}

.elderly-details p {
    margin-bottom: 6px;
}

.interaction-sources {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
}

/* ===== POSOLOGIA ===== */
.posologia-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid rgba(33, 150, 243, 0.2);
}

.posologia-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #90caf9;
    margin-bottom: 16px;
}

.posologia-field {
    margin-bottom: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== DRUG ALERT COUNT ===== */
.drug-alert-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

/* ===== POPOVER ===== */
.sim-popover {
    position: absolute;
    z-index: 10000;
    width: 340px;
    max-width: calc(100vw - 20px);
    background: #252839;
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 4px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(155, 111, 212, 0.25);
    overflow: hidden;
    animation: popover-in 0.15s ease-out;
}

@keyframes popover-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.sim-popover.popover-pinned {
    width: 420px;
    max-height: 70vh;
    overflow-y: auto;
}

.popover-header {
    padding: 10px 14px;
    background: #2a2d42;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.popover-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}

.popover-summary {
    padding: 12px 14px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.6;
}

.popover-interaction-item {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.popover-interaction-item:last-child {
    border-bottom: none;
}

.popover-warning-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    line-height: 1.5;
}

.popover-more {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.35);
    font-style: italic;
    margin-top: 6px;
}

.popover-posologia {
    font-size: 13px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.75);
}

.popover-hint {
    padding: 6px 14px 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-align: center;
    font-style: italic;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* PA Attribution Styles */
.pa-attribution {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
    margin-bottom: 4px;
    padding-left: 2px;
}

.pa-attribution-full {
    font-size: 12px;
    color: #9B6FD4;
    font-weight: 600;
    margin-bottom: 6px;
    padding-left: 2px;
}

.popover-full {
    padding: 0 14px 14px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
}

.popover-full-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.popover-full-item:last-child {
    border-bottom: none;
}

.popover-full-header {
    margin-bottom: 4px;
}

.popover-full-text {
    color: rgba(255, 255, 255, 0.65);
    font-size: 13px;
    line-height: 1.6;
    margin: 4px 0;
}

.popover-sources {
    margin-top: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
}

/* === LACTATION V3 ALTERNATIVAS === */
.lactation-alternativas {
    margin-top: 12px;
    padding: 12px;
    background: rgba(233, 30, 99, 0.08);
    border-left: 3px solid #e91e63;
    border-radius: 6px;
    border: 1px solid rgba(233, 30, 99, 0.2);
}

.lactation-alternativas p:first-child {
    margin-bottom: 6px;
    color: #f06292;
}

.alternativas-text {
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.7;
    font-size: 13px;
}

.popover-posologia-full {
    font-size: 13px;
    line-height: 1.6;
}

.popover-posologia-full .posologia-field {
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.6;
}

.posologia-via-header {
    background: rgba(33, 150, 243, 0.12);
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    color: #90caf9;
    font-size: 13px;
    border: 1px solid rgba(33, 150, 243, 0.2);
}

.posologia-divider {
    border: none;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
    margin: 12px 0;
}

/* ===== ERROR CONTENT ===== */
#error-content {
    font-size: 14px;
    color: #ff8a7a;
}

#error-content pre {
    background: rgba(231, 76, 60, 0.1);
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    margin-top: 8px;
    border: 1px solid rgba(231, 76, 60, 0.2);
    color: rgba(255, 255, 255, 0.7);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .form-grid.cols-3,
    .form-grid.cols-4,
    .form-grid.cols-3-action {
        grid-template-columns: 1fr;
    }

    .header h1 { font-size: 22px; }
    .container { padding: 0 14px; }
    .card { padding: 18px; }

    .action-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .action-bar .btn { text-align: center; }

    .interaction-icon-circle {
        width: 44px;
        height: 44px;
    }

    .interaction-icon-circle svg {
        width: 18px;
        height: 18px;
    }

    .data-table { font-size: 12px; }
    .data-table thead th,
    .data-table tbody td { padding: 8px; }
}

/* ===== PRESCRIPTION LIST TABLE ===== */
.prescription-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.prescription-table thead th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.prescription-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s;
}

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

.prescription-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.prescription-table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    color: rgba(255, 255, 255, 0.85);
}

.presc-name {
    display: block;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.prescription-table .dcb-label {
    display: inline-block;
    font-size: 11px;
    color: #E8875A;
    font-weight: 700;
    background: rgba(232, 135, 90, 0.12);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ===== API MODE TOGGLE ===== */
.api-mode-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.api-mode-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

/* Modo Banco Interno (default) - usa o estilo base */
.api-mode-btn.api-mode-internal {
    /* mantém o estilo neutro padrão */
}

/* Modo API Dev - azul/teal para indicar ambiente de testes */
.api-mode-btn.api-mode-dev {
    background: rgba(38, 166, 154, 0.22);
    border-color: #26a69a;
    color: #5eead4;
}

.api-mode-btn.api-mode-dev:hover {
    background: rgba(38, 166, 154, 0.35);
    color: #99f6e4;
}

/* Modo API Produção - laranja/âmbar (atenção, dado real) */
.api-mode-btn.api-mode-prod {
    background: rgba(230, 126, 34, 0.25);
    border-color: #e67e22;
    color: #f0a060;
}

.api-mode-btn.api-mode-prod:hover {
    background: rgba(230, 126, 34, 0.38);
    color: #fbb46e;
}

/* Compatibilidade com classe legada api-mode-active (= prod) */
.api-mode-btn.api-mode-active {
    background: rgba(230, 126, 34, 0.25);
    border-color: #e67e22;
    color: #f0a060;
}

.api-mode-btn.api-mode-active:hover {
    background: rgba(230, 126, 34, 0.38);
    color: #fbb46e;
}

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

/* ===== RESULTS MODE BADGE ===== */
.results-mode-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.results-mode-badge.internal-mode {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.results-mode-badge.api-mode {
    background: rgba(230, 126, 34, 0.15);
    color: #e67e22;
    border: 1px solid rgba(230, 126, 34, 0.3);
}

.results-mode-badge.dev-mode {
    background: rgba(38, 166, 154, 0.15);
    color: #26a69a;
    border: 1px solid rgba(38, 166, 154, 0.3);
}

/* ===== API RAW RESULT ===== */
.api-raw-result {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    overflow: auto;
}

.api-raw-notice {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
}

.api-raw-result pre {
    font-size: 0.72rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.75);
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    max-height: 70vh;
    overflow-y: auto;
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
    margin-left: auto;
}

.theme-toggle-btn:hover {
    background: rgba(155, 111, 212, 0.25);
    border-color: #9B6FD4;
    color: #ffffff;
    transform: scale(1.05);
}

/* ===== FOOTER ===== */
.footer {
    background: #1a1d2e;
    color: rgba(255, 255, 255, 0.4);
    padding: 24px 0;
    margin-top: 60px;
    text-align: center;
    font-size: 13px;
    border-top: 1px solid rgba(155, 111, 212, 0.2);
}

.footer p {
    margin: 0;
    font-weight: 400;
}

/* ===== LAYOUT GRID 2 COLUNAS ===== */
.page-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 0 24px;
    align-items: start;
}

.page-col-form {
    min-width: 0;
}

.page-col-sidebar {
    position: sticky;
    top: 24px;
    height: calc(100vh - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===== SIDEBAR PANEL ===== */
.side-panel-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #252839;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.side-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 14px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.side-panel-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.side-panel-title::before {
    content: '';
    width: 3px;
    height: 18px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #9B6FD4, #E8875A);
    border-radius: 2px;
}

.side-panel-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.side-panel-empty {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 14px;
    font-style: italic;
}

/* ===== ACCORDION SIDEBAR CARDS ===== */
.side-drug-card .drug-card-header {
    cursor: pointer;
    user-select: none;
}

.side-drug-card .drug-card-header:hover {
    background: #30334e;
}

.side-drug-card .drug-card-body {
    display: none;
}

.side-drug-card.expanded .drug-card-body {
    display: block;
}

.side-card-chevron {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.side-drug-card.expanded .side-card-chevron {
    transform: rotate(180deg);
}

/* ===== ÍCONES COMPACTOS NA TABELA DE PRESCRIÇÃO ===== */
.presc-row-icons {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    margin-left: 8px;
    vertical-align: middle;
}

.presc-icon-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1.5px solid transparent;
    flex-shrink: 0;
}

.presc-icon-small:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: currentColor;
    transform: scale(1.15);
}

.presc-icon-small svg {
    width: 13px;
    height: 13px;
}

/* ===== INTERAÇÕES INLINE NO SIDEBAR ===== */
.sidebar-inline-interactions {
    margin-top: 4px;
}

.sidebar-interaction-group {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid transparent;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.sidebar-group-header:hover {
    filter: brightness(1.12);
}

.sidebar-group-label {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sidebar-group-chevron {
    margin-left: auto;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease;
    transform: rotate(0deg);
}

.sidebar-interaction-group-collapsed .sidebar-group-chevron {
    transform: rotate(-90deg);
}

.sidebar-group-body {
    padding: 8px 12px 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.6;
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-interaction-group-collapsed .sidebar-group-body {
    display: none;
}

/* ===== RESPONSIVO ===== */
@media (max-width: 1024px) {
    .page-grid {
        grid-template-columns: 1fr;
    }

    .page-col-sidebar {
        position: static;
        height: auto;
        overflow: visible;
    }

    .side-panel-inner {
        height: auto;
    }

    .side-panel-results {
        overflow-y: visible;
    }
}

/* ===== LIGHT MODE ===== */
[data-theme="light"] body { background: #f0f2f8; color: #1a1d2e; }

[data-theme="light"] ::-webkit-scrollbar-track { background: #f0f2f8; }

[data-theme="light"] .header {
    background: #ffffff;
    border-bottom-color: rgba(155, 111, 212, 0.2);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .header .subtitle { color: rgba(0, 0, 0, 0.5); }

[data-theme="light"] .theme-toggle-btn {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .theme-toggle-btn:hover {
    background: rgba(155, 111, 212, 0.15);
    border-color: #9B6FD4;
    color: #9B6FD4;
}

[data-theme="light"] .api-mode-btn {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .api-mode-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    color: rgba(0, 0, 0, 0.9);
}

[data-theme="light"] .json-debug-toggle {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.55);
}

[data-theme="light"] .json-debug-toggle:hover,
[data-theme="light"] .json-debug-toggle-active {
    background: rgba(155, 111, 212, 0.12);
    border-color: rgba(155, 111, 212, 0.45);
    color: #6f45a6;
}

[data-theme="light"] .json-debug-panel {
    background: rgba(0, 0, 0, 0.025);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .json-debug-header,
[data-theme="light"] .json-debug-panel summary {
    color: rgba(0, 0, 0, 0.62);
}

[data-theme="light"] .json-debug-close {
    color: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .json-debug-close:hover {
    color: #1a1d2e;
}

[data-theme="light"] .json-debug-copy {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
    color: rgba(0, 0, 0, 0.55);
}

[data-theme="light"] .json-debug-copy:hover:not(:disabled) {
    background: rgba(155, 111, 212, 0.12);
    border-color: rgba(155, 111, 212, 0.45);
    color: #6f45a6;
}

[data-theme="light"] .json-debug-panel pre {
    background: #f5f6fa;
    border-color: rgba(0, 0, 0, 0.08);
    color: rgba(0, 0, 0, 0.76);
}

[data-theme="light"] .api-raw-result {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .api-raw-result pre {
    color: rgba(0, 0, 0, 0.75);
}

[data-theme="light"] .api-raw-notice {
    color: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    border-color: rgba(155, 111, 212, 0.25);
}

[data-theme="light"] .card-title {
    color: #1a1d2e;
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .card-error .card-title { color: #c0392b; }

[data-theme="light"] .form-group label { color: rgba(0, 0, 0, 0.55); }

[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select {
    background-color: #f5f6fa;
    color: #1a1d2e;
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2300000060' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="light"] .form-group select option { background: #ffffff; color: #1a1d2e; }

[data-theme="light"] .form-group input::placeholder { color: rgba(0, 0, 0, 0.3); }

[data-theme="light"] .form-group input:hover,
[data-theme="light"] .form-group select:hover {
    border-color: rgba(155, 111, 212, 0.4);
    background-color: #edeef5;
}

[data-theme="light"] .form-group select:hover,
[data-theme="light"] .form-group select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2300000060' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

[data-theme="light"] .form-group input:focus,
[data-theme="light"] .form-group select:focus {
    background-color: #edeef5;
    border-color: #9B6FD4;
}

[data-theme="light"] .form-group input:disabled,
[data-theme="light"] .form-group select:disabled {
    background-color: #e8eaf2;
    color: rgba(0, 0, 0, 0.25);
    border-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .btn-secondary {
    background: #f0f1f8;
    color: rgba(0, 0, 0, 0.7);
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .btn-secondary:hover {
    background: #e4e5f0;
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .btn-remove {
    border-color: rgba(231, 76, 60, 0.4);
    color: #c0392b;
}

[data-theme="light"] .data-table { border-color: rgba(0, 0, 0, 0.07); }

[data-theme="light"] .data-table thead th {
    background: #f0f1f8;
    color: rgba(0, 0, 0, 0.5);
    border-bottom-color: rgba(155, 111, 212, 0.25);
}

[data-theme="light"] .data-table tbody td {
    background: #ffffff;
    color: rgba(0, 0, 0, 0.8);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .data-table tbody tr:hover td { background: #f0f1f8; }
[data-theme="light"] .data-table tbody tr:nth-child(even) td { background: #f8f8fc; }
[data-theme="light"] .data-table tbody tr:nth-child(even):hover td { background: #f0f1f8; }

[data-theme="light"] .empty-message {
    color: rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .autocomplete-dropdown {
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .autocomplete-item { border-bottom-color: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .autocomplete-item:hover { background: #f0f1f8; }
[data-theme="light"] .autocomplete-item strong { color: #1a1d2e; }
[data-theme="light"] .autocomplete-item .brand-name { color: rgba(0, 0, 0, 0.4); }
[data-theme="light"] .autocomplete-empty { color: rgba(0, 0, 0, 0.35); }

[data-theme="light"] .selected-med-info .med-name { color: #1a1d2e; }

[data-theme="light"] .med-detail-form {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(155, 111, 212, 0.25);
}

[data-theme="light"] .loading-overlay { background: rgba(230, 232, 240, 0.97); }
[data-theme="light"] .loading-overlay p { color: rgba(0, 0, 0, 0.8); }



[data-theme="light"] .no-alerts p { color: rgba(0, 0, 0, 0.5); }

[data-theme="light"] .drug-card {
    background: #f8f9fd;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .drug-card:hover { box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12); }

[data-theme="light"] .drug-card-header {
    background: #f0f1f8;
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .drug-route-info { color: #6b7280; background: rgba(0, 0, 0, 0.06); }

[data-theme="light"] .drug-card-number { background: rgba(0, 0, 0, 0.08); color: rgba(0, 0, 0, 0.7); }

[data-theme="light"] .drug-card-title-block h3 { color: #1a1d2e; }
[data-theme="light"] .fall-risk-header h3 { color: #1a1d2e; }
[data-theme="light"] .fall-risk-msg { color: rgba(0, 0, 0, 0.7); }
[data-theme="light"] .fall-risk-orientacao { color: rgba(0, 0, 0, 0.55); }
[data-theme="light"] .fall-risk-meds { border-top-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .fall-risk-meds li { color: rgba(0, 0, 0, 0.65); }
[data-theme="light"] .fall-risk-meds strong { color: rgba(0, 0, 0, 0.85); }

[data-theme="light"] .drug-interaction-icons { border-bottom-color: rgba(0, 0, 0, 0.05); }

[data-theme="light"] .interaction-icon-circle { background: rgba(0, 0, 0, 0.05); }

[data-theme="light"] .interaction-icon-circle:hover {
    background: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .drug-interacts-with { border-bottom-color: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .interacts-label { color: rgba(0, 0, 0, 0.4); }

[data-theme="light"] .drug-interact-tag.tag-more {
    background: rgba(0, 0, 0, 0.07);
    color: rgba(0, 0, 0, 0.5);
    border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .severity-border-contraindicated .drug-card-number { background: rgba(192, 57, 43, 0.15); color: #c0392b; }
[data-theme="light"] .severity-border-major .drug-card-number { background: rgba(231, 76, 60, 0.15); color: #e74c3c; }
[data-theme="light"] .severity-border-moderate .drug-card-number { background: rgba(243, 156, 18, 0.15); color: #d68910; }
[data-theme="light"] .severity-border-minor .drug-card-number { background: rgba(241, 196, 15, 0.12); color: #b7950b; }

[data-theme="light"] .severity-contraindicated { background: rgba(192, 57, 43, 0.12); color: #922b21; border-color: rgba(192, 57, 43, 0.3); }
[data-theme="light"] .severity-major { background: rgba(231, 76, 60, 0.12); color: #c0392b; border-color: rgba(231, 76, 60, 0.3); }
[data-theme="light"] .severity-moderate { background: rgba(243, 156, 18, 0.12); color: #9a6c00; border-color: rgba(243, 156, 18, 0.3); }
[data-theme="light"] .severity-minor { background: rgba(241, 196, 15, 0.1); color: #8a6900; border-color: rgba(241, 196, 15, 0.25); }
[data-theme="light"] .severity-caution { background: rgba(33, 150, 243, 0.1); color: #1565c0; border-color: rgba(33, 150, 243, 0.25); }

[data-theme="light"] .badge-duplicate { color: #9a6c00; }
[data-theme="light"] .badge-allergy { color: #c0392b; }
[data-theme="light"] .badge-posologia { color: #1565c0; }

[data-theme="light"] .interaction-item {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .interaction-header .secondary-drug { color: #1a1d2e; }
[data-theme="light"] .interaction-detail,
[data-theme="light"] .interaction-body { color: rgba(0, 0, 0, 0.65); }
[data-theme="light"] .interaction-sources { color: rgba(0, 0, 0, 0.35); }

[data-theme="light"] .elderly-details {
    background: rgba(121, 85, 72, 0.08);
    border-color: rgba(121, 85, 72, 0.2);
    color: rgba(0, 0, 0, 0.7);
}

[data-theme="light"] .posologia-section { border-top-color: rgba(33, 150, 243, 0.2); }
[data-theme="light"] .posologia-section-title { color: #1565c0; }

[data-theme="light"] .posologia-field {
    background: rgba(0, 0, 0, 0.03);
    color: rgba(0, 0, 0, 0.7);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .drug-alert-count { color: rgba(0, 0, 0, 0.4); }

[data-theme="light"] .sim-popover {
    background: #ffffff;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
    border-color: rgba(155, 111, 212, 0.2);
}

[data-theme="light"] .popover-header {
    background: #f0f1f8;
    border-bottom-color: rgba(0, 0, 0, 0.07);
}

[data-theme="light"] .popover-summary { color: rgba(0, 0, 0, 0.7); }
[data-theme="light"] .popover-interaction-item { border-bottom-color: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .popover-warning-text { color: rgba(0, 0, 0, 0.6); }
[data-theme="light"] .popover-more { color: rgba(0, 0, 0, 0.35); }
[data-theme="light"] .popover-posologia { color: rgba(0, 0, 0, 0.7); }
[data-theme="light"] .popover-hint { color: rgba(0, 0, 0, 0.3); border-top-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .pa-attribution { color: rgba(0, 0, 0, 0.4); }
[data-theme="light"] .popover-full { color: rgba(0, 0, 0, 0.65); }
[data-theme="light"] .popover-full-item { border-bottom-color: rgba(0, 0, 0, 0.06); }
[data-theme="light"] .popover-full-text { color: rgba(0, 0, 0, 0.6); }
[data-theme="light"] .popover-sources { color: rgba(0, 0, 0, 0.3); }

[data-theme="light"] .lactation-alternativas {
    background: rgba(233, 30, 99, 0.05);
    border-color: rgba(233, 30, 99, 0.15);
}
[data-theme="light"] .alternativas-text { color: rgba(0, 0, 0, 0.65); }

[data-theme="light"] .popover-posologia-full .posologia-field { background: rgba(0, 0, 0, 0.03); }

[data-theme="light"] .posologia-via-header {
    background: rgba(33, 150, 243, 0.08);
    color: #1565c0;
    border-color: rgba(33, 150, 243, 0.15);
}

[data-theme="light"] .posologia-divider { border-top-color: rgba(0, 0, 0, 0.1); }

[data-theme="light"] #error-content { color: #c0392b; }
[data-theme="light"] #error-content pre {
    background: rgba(231, 76, 60, 0.05);
    color: rgba(0, 0, 0, 0.65);
    border-color: rgba(231, 76, 60, 0.15);
}

[data-theme="light"] .prescription-table thead th {
    color: rgba(0, 0, 0, 0.45);
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .prescription-table tbody tr { border-bottom-color: rgba(0, 0, 0, 0.05); }
[data-theme="light"] .prescription-table tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .prescription-table tbody td { color: rgba(0, 0, 0, 0.8); }
[data-theme="light"] .presc-name { color: #1a1d2e; }

[data-theme="light"] .footer {
    background: #e8eaf2;
    color: rgba(0, 0, 0, 0.45);
    border-top-color: rgba(155, 111, 212, 0.2);
}

[data-theme="light"] .side-panel-inner { background: #ffffff; border-color: rgba(0, 0, 0, 0.06); box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08); }
[data-theme="light"] .side-panel-header { border-bottom-color: rgba(0, 0, 0, 0.08); }
[data-theme="light"] .side-panel-title { color: #1a1d2e; }
[data-theme="light"] .side-panel-empty { color: rgba(0, 0, 0, 0.3); }
[data-theme="light"] .side-drug-card .drug-card-header:hover { background: #f0f1f8; }
[data-theme="light"] .presc-icon-small { background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .presc-icon-small:hover { background: rgba(0, 0, 0, 0.09); }
[data-theme="light"] .sidebar-group-header { background: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .sidebar-group-label { color: rgba(0, 0, 0, 0.7); }
[data-theme="light"] .sidebar-group-body { background: rgba(0, 0, 0, 0.01); color: rgba(0, 0, 0, 0.65); }
[data-theme="light"] .sidebar-interaction-group { border-color: rgba(0, 0, 0, 0.05); }

/* Compound fallback banner — composto não cadastrado como entrada única */
.compound-fallback-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 10px 0;
    padding: 10px 12px;
    border-radius: 6px;
    background: rgba(243, 156, 18, 0.12);
    border: 1px solid rgba(243, 156, 18, 0.35);
    border-left-width: 4px;
    font-size: 12.5px;
    line-height: 1.45;
    color: #ffc966;
}

.compound-fallback-icon {
    flex: 0 0 auto;
    font-size: 16px;
    line-height: 1;
    color: #f39c12;
    margin-top: 1px;
}

.compound-fallback-text {
    flex: 1 1 auto;
}

.compound-fallback-text strong {
    color: #ffd98a;
    font-weight: 700;
}

[data-theme="light"] .compound-fallback-banner {
    background: rgba(243, 156, 18, 0.1);
    border-color: rgba(243, 156, 18, 0.4);
    color: #8a6300;
}

[data-theme="light"] .compound-fallback-text strong {
    color: #6b4d00;
}

/* === VIEW TOGGLE: por medicamento vs por gravidade (prototipo) === */
.view-toggle {
    display: inline-flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 2px;
}
.view-toggle-btn {
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #aab2c5;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.view-toggle-btn:hover { color: #fff; }
.view-toggle-btn.active {
    background: #667eea;
    color: #fff;
}
[data-theme="light"] .view-toggle {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .view-toggle-btn { color: #5a6072; }
[data-theme="light"] .view-toggle-btn:hover { color: #1a1a2e; }
[data-theme="light"] .view-toggle-btn.active { color: #fff; }

/* === VISAO POR GRAVIDADE === */
.priority-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.priority-pill {
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 14px;
}
.priority-pill-critical { background: rgba(231, 76, 60, 0.22); color: #ff8a7a; border: 1px solid rgba(231, 76, 60, 0.4); }
.priority-pill-moderate { background: rgba(243, 156, 18, 0.2); color: #ffc966; border: 1px solid rgba(243, 156, 18, 0.4); }
.priority-pill-minor { background: rgba(39, 174, 96, 0.18); color: #5fd99a; border: 1px solid rgba(39, 174, 96, 0.4); }

.priority-group { margin-bottom: 12px; }
.priority-group-summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #c8cede;
    padding: 6px 4px;
    list-style: none;
    user-select: none;
}
.priority-group-summary::-webkit-details-marker { display: none; }
.priority-group-summary::before { content: "▸ "; color: #8089a0; }
.priority-group[open] > .priority-group-summary::before { content: "▾ "; }
.priority-group-count {
    display: inline-block;
    min-width: 18px;
    text-align: center;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #c8cede;
}

.priority-row {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    border-left: 4px solid #555;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 11px 13px;
    margin: 8px 0;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.priority-row:hover {
    background: rgba(255, 255, 255, 0.07);
    transform: translateX(2px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.28);
}
/* fundo levemente tingido pela gravidade (mesma paleta dos cards) */
.priority-row.severity-border-contraindicated { background: rgba(192, 57, 43, 0.10); }
.priority-row.severity-border-major { background: rgba(231, 76, 60, 0.09); }
.priority-row.severity-border-moderate { background: rgba(243, 156, 18, 0.08); }
/* leve -> verde (diferencia do moderado ambar e reforca "baixo risco") */
.priority-row.severity-border-minor { background: rgba(39, 174, 96, 0.12); border-left-color: #27ae60; }
/* badge "Leve" verde — escopado a view por gravidade (cards de medicamento mantem amarelo) */
.priority-row .severity-badge.severity-minor { background: rgba(39, 174, 96, 0.18); color: #5fd99a; border: 1px solid rgba(39, 174, 96, 0.4); }

/* circulo do icone do tipo — espelha .interaction-icon-circle dos cards */
.priority-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid currentColor;
    margin-top: 1px;
}
.priority-icon svg { width: 19px; height: 19px; }

.priority-row-main { flex: 1; min-width: 0; }
.priority-row-head {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}
.priority-rank { font-size: 11px; font-weight: 700; color: #8089a0; }
.priority-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 2px 8px;
    border-radius: 10px;
    border: 1px solid currentColor;
    background: rgba(255, 255, 255, 0.04);
}
.priority-drug { font-size: 13px; font-weight: 700; color: #e8ebf2; }
.priority-row-text { font-size: 12px; line-height: 1.5; color: #b6bccb; }

[data-theme="light"] .priority-group-summary { color: #3a3f52; }
[data-theme="light"] .priority-group-count { background: rgba(0, 0, 0, 0.08); color: #3a3f52; }
[data-theme="light"] .priority-row { background: rgba(0, 0, 0, 0.02); }
[data-theme="light"] .priority-row:hover { background: rgba(0, 0, 0, 0.05); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1); }
[data-theme="light"] .priority-row.severity-border-contraindicated { background: rgba(192, 57, 43, 0.07); }
[data-theme="light"] .priority-row.severity-border-major { background: rgba(231, 76, 60, 0.06); }
[data-theme="light"] .priority-row.severity-border-moderate { background: rgba(243, 156, 18, 0.07); }
[data-theme="light"] .priority-row.severity-border-minor { background: rgba(39, 174, 96, 0.10); }
[data-theme="light"] .priority-icon { background: rgba(0, 0, 0, 0.04); }
[data-theme="light"] .priority-type { background: rgba(0, 0, 0, 0.03); }
[data-theme="light"] .priority-drug { color: #1a1a2e; }
[data-theme="light"] .priority-row-text { color: #4a4f62; }
[data-theme="light"] .priority-pill-critical { background: rgba(231, 76, 60, 0.12); color: #c0392b; border-color: rgba(231, 76, 60, 0.3); }
[data-theme="light"] .priority-pill-moderate { background: rgba(243, 156, 18, 0.12); color: #9a6c00; border-color: rgba(243, 156, 18, 0.3); }
[data-theme="light"] .priority-pill-minor { background: rgba(39, 174, 96, 0.12); color: #1e7a45; border-color: rgba(39, 174, 96, 0.3); }
[data-theme="light"] .priority-row .severity-badge.severity-minor { background: rgba(39, 174, 96, 0.12); color: #1e7a45; border-color: rgba(39, 174, 96, 0.3); }
