:root {
    --bg: #f5f7fb;
    --card: #ffffff;
    --accent: #0ea779;
    --accent-strong: #0c9369;
    --muted: #4b5563;
    --text: #0f172a;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #2563eb;
    --radius: 14px;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 15px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 20% 15%, rgba(14, 167, 121, 0.08), transparent 28%),
        radial-gradient(circle at 78% 12%, rgba(37, 99, 235, 0.08), transparent 24%),
        radial-gradient(circle at 40% 80%, rgba(245, 158, 11, 0.06), transparent 26%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

html { height: 100%; }

a { color: inherit; text-decoration: none; }

.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(6px);
    padding: 28px 20px;
    border-right: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 24px;
}

.nav {
    display: grid;
    gap: 8px;
    margin-bottom: auto;
}

.nav a {
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.18s ease;
}

.nav a.active,
.nav a:hover {
    background: linear-gradient(120deg, rgba(14, 167, 121, 0.12), rgba(37, 99, 235, 0.1));
    color: var(--text);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 12px 0 18px;
    padding: 12px 14px;
    background: rgba(15, 23, 42, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(15, 23, 42, 0.06);
}
.filters-actions {
    display: flex;
    align-items: flex-end;
}
.filters label { display: block; margin-bottom: 6px; color: var(--muted); font-weight: 600; }
.filters input,
.filters select { width: 100%; }

.status-chip {
    display: inline-flex;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}
.status-aberta { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.status-aguardando_pagamento { background: #dbeafe; color: #1d4ed8; border-color: #60a5fa; }
.status-paga { background: #dcfce7; color: #166534; border-color: #22c55e; }
.status-cancelada { background: #fee2e2; color: #b91c1c; border-color: #f87171; }

.pagination {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 12px;
}

.sidebar-footer {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px dashed rgba(15, 23, 42, 0.08);
}

.sidebar-footer a {
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.18s ease;
    background: rgba(15, 23, 42, 0.04);
}

.sidebar-footer a.sidebar-link-plain {
    background: transparent;
    color: var(--muted);
    font-weight: 600;
}

.sidebar-footer a.sidebar-link-plain:hover,
.sidebar-footer a.sidebar-link-plain.active {
    background: transparent;
    color: var(--text);
}

.sidebar-footer a:hover,
.sidebar-footer a.active {
    background: linear-gradient(120deg, rgba(14, 167, 121, 0.16), rgba(37, 99, 235, 0.12));
}

.content {
    padding: 28px 32px 40px;
    overflow-y: auto;
    height: 100vh;
}

.page-title {
    margin: 0 0 18px;
    font-size: 26px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.card {
    background: var(--card);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.card h4 {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.card .number {
    font-size: 26px;
    font-weight: 800;
}

.grid {
    display: grid;
    gap: 14px;
}

.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: var(--shadow);
}

.panel h3 {
    margin: 0 0 14px;
    font-size: 18px;
}

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

label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #fff;
    color: var(--text);
}

textarea { min-height: 90px; }

input[type="radio"],
input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: none;
    background: transparent;
}
input[type="radio"] { accent-color: var(--accent); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn:hover { background: var(--accent-strong); }

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-info {
    background: var(--info);
    color: #fff;
}
.btn-eligiveis {
    background: #f58a5f;
    color: #fff;
}
.btn-eligiveis:hover {
    background: #e87b52;
}
.btn-info:hover { background: #1d4ed8; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    width: 38px;
    height: 38px;
}
.btn-icon svg {
    width: 18px;
    height: 18px;
}
.btn-payment { background: #1e2b5e; color: #fff; }
.btn-payment:hover { background: #1a2552; }

.eligiveis-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 260px;
    max-width: 100%;
}
.eligiveis-stack .btn { width: 100%; }
.eligiveis-stack .muted { font-size: 12px; line-height: 1.3; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #1f2a3d; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
}

.flash-message { display: inline-flex; }

.alert-blink {
    animation: alertPulse 1.8s ease-in-out infinite;
}

.alert-faturas {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 14px 0 18px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.04));
    color: #92400e;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.08);
}

.alert-faturas strong { font-weight: 700; display: block; }
.alert-faturas div { line-height: 1.3; }

.alert-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    margin-top: 4px;
    background: #f59e0b;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18);
    animation: alertDot 1.8s ease-in-out infinite;
}

.overdue-alert-icon {
    width: 18px;
    height: 18px;
    margin-left: 6px;
    vertical-align: middle;
    animation: alertPulse 1.4s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

@keyframes alertDot {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.18); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 9px rgba(245, 158, 11, 0.08); }
}

.btn-blink {
    animation: btnPulse 1.6s ease-in-out infinite;
}

@keyframes btnPulse {
    0%, 100% { transform: translateY(0); box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
    50% { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(245, 158, 11, 0.25); }
}

table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 12px;
    text-align: left;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
}

tbody tr:nth-child(odd) {
    background: #f9fafb;
}

.status {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    display: inline-block;
}

.status.novo { background: rgba(37, 99, 235, 0.14); color: #1d4ed8; }
.status.cozinha { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.status.em_entrega { background: rgba(14, 167, 121, 0.16); color: #047857; }
.status.em_faturamento { background: rgba(99, 102, 241, 0.18); color: #4f46e5; }
.status.faturado { background: rgba(14, 116, 144, 0.16); color: #0f766e; }
.status.aguardando_pagamento { background: rgba(234, 179, 8, 0.18); color: #a16207; }
.status.pago { background: rgba(14, 167, 121, 0.2); color: #065f46; }

.muted { color: var(--muted); font-size: 13px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
    font-weight: 600;
    font-size: 12px;
}
.pill.pagamento {
    color: #fff;
    font-weight: 700;
}
.pill.pagamento-dinheiro { background: #065f46; }
.pill.pagamento-cartao { background: #1d4ed8; }
.pill.pagamento-pix { background: #6d28d9; }
.pill.tipo-particular {
    background: #dbeafe;
    color: #1e3a8a;
}
.pill.tipo-convenio {
    background: #e9d5ff;
    color: #6b21a8;
}

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

.table-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.kitchen-ticket {
    background: #fff;
    color: #111;
    padding: 14px;
    border-radius: 8px;
    font-family: "Courier New", monospace;
    font-size: 14px;
    line-height: 1.4;
}

.badge {
    padding: 5px 9px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.06);
    color: #111827;
    font-size: 12px;
}

.badge-error { background: #fee2e2; color: #7f1d1d; border: 1px solid rgba(239, 68, 68, 0.35); }
.badge-success { background: #dcfce7; color: #166534; border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid rgba(234, 179, 8, 0.4); }

.total-estimado-box {
    border-top: 1px solid rgba(127, 29, 29, 0.35);
    border-bottom: 1px solid rgba(127, 29, 29, 0.35);
    padding: 10px 0;
}
.total-estimado-label {
    color: #7f1d1d;
    font-weight: 700;
}
.total-estimado-valor {
    color: #7f1d1d;
    font-size: 18px;
    font-weight: 800;
}

.icon-18 { height: 18px; width: 18px; object-fit: contain; }
.wrap-row { display: flex; gap: 6px; flex-wrap: wrap; }
.panel--spaced { margin-top: 12px; }
.item-row { margin-bottom: 10px; }

.modal--wide {
    width: 80%;
    max-width: 2000px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 12px;
}

.payment-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    border-radius: 12px;
    background: #f8fafc;
}

.payment-summary-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid rgba(203, 213, 225, 0.6);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.payment-summary-label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
}

.payment-summary-value {
    font-size: 16px;
    color: #1e293b;
    font-weight: 700;
}

.payment-form-section {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px dashed rgba(148, 163, 184, 0.6);
}

.payment-form-section h4 {
    margin: 0 0 8px;
    color: #1f2937;
    font-size: 14px;
}

.payment-actions {
    justify-content: flex-end;
    margin: 6px 0 12px;
    gap: 8px;
}

.modal--narrow {
    width: 380px;
    max-width: 95vw;
    padding: 16px;
    border-radius: 14px;
}

.modal-backdrop--dark { background: rgba(0, 0, 0, 0.7); z-index: 12; }
.modal-backdrop--tight { padding: 12px; }

.modal-header--tight { gap: 12px; }
.modal-header h3 { margin: 0; }

.modal-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.divider { border: 1px solid rgba(255,255,255,0.05); margin: 16px 0; }
.mt-16 { margin-top: 16px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.spacer-12 { height: 12px; }
.spacer-16 { height: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions-end { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.inline-group { display: flex; gap: 6px; align-items: center; }
.align-end { display: flex; align-items: flex-end; }

.ticket-content {
    font-size: 14px;
    line-height: 1.4;
}
.ticket-content .linha { margin-bottom: 6px; }
.ticket-content .muted { color: #9ca3af; font-size: 12px; }
.ticket-content--padded { margin-top: 8px; }

#ticketModal .modal * {
    font-family: "Courier New", monospace;
    font-size: 10pt;
}
#ticketModal .linha-cliente {
    font-size: 14pt;
    font-weight: 700;
    display: grid;
    gap: 0;
}
#ticketModal .linha-cliente-nome {
    font-size: 14pt;
    font-weight: 700;
}
#ticketModal .linha-cliente-telefone {
    font-size: 10pt;
    font-weight: 400;
}
#ticketModal .modal-header h3 {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 16px;
}
#ticketModal .ticket-meta {
    font-family: "Courier New", monospace;
    font-size: 10pt;
    margin-top: 4px;
}
#ticketModal .ticket-header {
    display: grid;
    gap: 2px;
}
#ticketModal .ticket-divider {
    margin: 8px 0 10px;
    border-top: 3px double #000;
    height: 0;
}
#ticketModal .observacao {
    font-style: italic;
    color: #000;
}
#ticketModal .divider {
    border: none;
    height: 0;
    margin: 12px 0;
    position: relative;
    padding-left: 18px;
    width: 100%;
    border-top: 2px dotted #000;
}
#ticketModal .divider::before {
    content: "\2702";
    position: absolute;
    left: 0;
    top: -8px;
    font-size: 12pt;
    background: #fff;
    padding: 0 2px;
}
#ticketModal .ticket-itens {
    display: grid;
    gap: 8px;
}
#ticketModal .ticket-item {
    display: grid;
    grid-template-columns: 32px 1fr;
    column-gap: 8px;
    align-items: start;
}
#ticketModal .ticket-num {
    font-weight: 700;
}
#ticketModal .ticket-body {
    display: grid;
    gap: 4px;
}
#ticketModal .linha-item-principal {
    font-weight: 700;
}

@media print {
    @page { size: 80mm auto; margin: 0; }
    html, body { width: 80mm; margin: 0; padding: 0; height: auto !important; }
    body { overflow: visible !important; }
    .shell { display: block; width: 80mm; height: auto !important; grid-template-columns: 1fr !important; }
    .sidebar { display: none !important; }
    .content { width: 80mm; padding: 0 !important; margin: 0 !important; height: auto !important; overflow: visible !important; }
    .content > * { display: none !important; }
    #ticketModal, #ticketModal * { visibility: visible !important; }
    #ticketModal {
        position: static !important;
        display: block !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 80mm !important;
    }
    #ticketModal.modal-backdrop,
    #ticketModal.modal-backdrop.active {
        position: static !important;
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
        background: #fff !important;
    }
    #ticketModal .modal {
        box-shadow: none !important;
        border: none !important;
        width: 80mm !important;
        max-width: 80mm !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: #fff !important;
        color: #000;
        margin: 0 !important;
        padding: 2mm !important;
    }
    #ticketModal .modal-actions, #ticketModal .close-btn, .sidebar { display: none !important; }
    #ticketModal .ticket-itens { page-break-inside: auto; break-inside: auto; }
    #ticketModal .ticket-item { page-break-inside: avoid; break-inside: avoid; }
    #ticketModal .ticket-cut { page-break-inside: avoid; break-inside: avoid; }
}

.col-itens {
    width: 260px;
    max-width: 260px;
    white-space: normal;
}
.col-itens .item-line { margin-bottom: 4px; }

.compact-form {
    font-size: 14px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    padding: 8px;
    border-radius: 6px;
}
.compact-form label {
    font-size: 12px;
    margin-bottom: 4px;
}
.compact-form .row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 6px;
    margin-bottom: 8px;
}
.compact-form .row.row-narrow {
    grid-template-columns: minmax(200px, 260px);
}
.label-badge {
    margin-left: 6px;
    vertical-align: middle;
}
.compact-form .item-row {
    grid-template-columns: minmax(150px, 1.1fr) minmax(170px, 1.5fr) minmax(150px, 1fr) minmax(180px, 1.5fr) minmax(120px, 0.7fr);
}
.compact-form input,
.compact-form select,
.compact-form textarea {
    padding: 7px 9px;
    font-size: 13.5px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
}
.compact-form textarea { min-height: 70px; }

.troco-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.troco-row .troco-label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.table-scroll {
    overflow-x: auto;
}

.top-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.faturar-actions {
    margin-top: 16px;
}

.tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 6px 0 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

.tab-btn {
    background: #eef2f7;
    color: #111827;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    padding: 10px 16px;
}

.tab-btn.tab-active {
    background: var(--card);
    color: var(--text);
    position: relative;
    top: 1px;
    box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.08);
}

.tab-pane {
    display: none;
    padding-top: 14px;
    margin-top: -1px;
    border-top: 1px solid rgba(15, 23, 42, 0.12);
}

.tab-pane.active {
    display: block;
    background: var(--card);
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-top: none;
    border-radius: 0 14px 14px 14px;
    padding: 18px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.payment-split {
    margin-top: 16px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.06);
    display: grid;
    gap: 10px;
}

.payment-split-title {
    font-weight: 700;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.payment-split-item {
    display: grid;
    grid-template-columns: 80px 1fr 48px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.payment-split-label { font-weight: 600; }

.payment-split-bar {
    height: 8px;
    background: rgba(15, 23, 42, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.payment-split-bar span {
    display: block;
    height: 100%;
}

.bar-pix { background: #6d28d9; }
.bar-cartao { background: #1d4ed8; }
.bar-dinheiro { background: #065f46; }

.payment-split-value {
    text-align: right;
    font-weight: 700;
}

@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100dvh;
        overflow: auto;
    }
    .shell {
        grid-template-columns: 1fr;
        height: auto;
        min-height: 100dvh;
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 3;
        padding: 18px 16px;
        border-right: none;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }
    .content {
        height: auto;
        overflow: visible;
    }
    .filters {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    .table-scroll { -webkit-overflow-scrolling: touch; }
    .table-scroll table { min-width: 760px; }
    .compact-form .item-row {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
    .payment-split-item {
        grid-template-columns: 1fr;
        align-items: start;
    }
    .payment-split-value { text-align: left; }
    .eligiveis-stack { width: 100%; }
    .modal--wide { width: 95vw; }
}

.modal-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 20px;
}

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

.modal {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    padding: 18px;
    width: min(720px, 100%);
    box-shadow: var(--shadow);
    border: 1px solid rgba(15, 23, 42, 0.06);
    position: relative;
}
.modal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.35), rgba(14, 167, 121, 0.35));
}
.modal.modal--wide {
    width: 80%;
    max-width: 2000px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}
.modal-header h3 {
    font-weight: 700;
    color: #0f172a;
}
.modal .row {
    margin-bottom: 10px;
}
.modal input,
.modal select,
.modal textarea {
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.modal .btn-secondary {
    background: #e2e8f0;
}

@media (max-width: 1100px) {
    :root { font-size: 14px; }
    .content { padding: 22px 20px 32px; }
}

@media (max-width: 768px) {
    :root { font-size: 13.5px; }
    .content { padding: 18px 14px 28px; }
    .top-actions { flex-direction: column; align-items: flex-start; }
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 3; }
}

@media (max-width: 600px) {
    :root { font-size: 13px; }
    .page-title { font-size: 22px; }
    .content { padding: 16px 12px 24px; }
    .filters {
        grid-template-columns: 1fr;
        padding: 10px;
    }
    form .row { grid-template-columns: 1fr; }
    .compact-form .row { grid-template-columns: 1fr; }
    .compact-form .item-row { grid-template-columns: 1fr; }
    .top-actions { gap: 6px; }
    .btn { padding: 9px 12px; font-size: 13px; }
    .btn-small { padding: 6px 8px; font-size: 11px; }
    th, td { padding: 8px; font-size: 12px; }
    .table-scroll table { min-width: 700px; }
    .table-actions { flex-wrap: nowrap; }
    .table-actions .btn { white-space: nowrap; }
    .modal { width: 100%; padding: 14px; }
    .modal--narrow { width: 95vw; }
    .tabs { gap: 6px; }
    .tab-btn { padding: 8px 10px; }
}

@media (max-width: 720px) {
    .table-scroll { overflow-x: visible; }
    .table-scroll table {
        min-width: 0;
        border: none;
    }
    .table-scroll thead { display: none; }
    .table-scroll tbody,
    .table-scroll tr,
    .table-scroll td {
        display: block;
        width: 100%;
    }
    .table-scroll tr {
        background: var(--card);
        border: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 12px;
        margin-bottom: 10px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    }
    .table-scroll tbody tr:nth-child(odd) { background: var(--card); }
    .table-scroll td {
        border: none;
        border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
        padding: 8px 10px;
        display: block;
    }
    .table-scroll td[data-label] {
        display: grid;
        grid-template-columns: minmax(120px, 40%) 1fr;
        gap: 8px;
        align-items: center;
    }
    .table-scroll td:last-child { border-bottom: none; }
    .table-scroll td[data-label]::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }
    .table-actions { justify-content: flex-start; }
    .modal-backdrop {
        padding: 0 !important;
        align-items: stretch !important;
        justify-content: stretch !important;
    }
    .modal {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        padding: 16px !important;
        overflow-y: auto !important;
    }
    .modal--wide,
    .modal--narrow {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
    }
}


/* === FORÇAR TEMA CLARO EM QUALQUER CENÁRIO === */

/* Se alguém estiver usando data-theme="dark" ou similar, ignora e mantém paleta clara */
:root,
:root[data-theme="dark"],
html.dark,
body.dark {
    --bg: #f5f7fb;
    --card: #ffffff;
    --accent: #0ea779;
    --accent-strong: #0c9369;
    --muted: #4b5563;
    --text: #0f172a;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #2563eb;
    --radius: 14px;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

/* Garante que o fundo nunca vá pro “darkzão” */
body,
body.dark,
body[data-theme="dark"] {
    background:
        radial-gradient(circle at 20% 15%, rgba(14, 167, 121, 0.08), transparent 28%),
        radial-gradient(circle at 78% 12%, rgba(37, 99, 235, 0.08), transparent 24%),
        radial-gradient(circle at 40% 80%, rgba(245, 158, 11, 0.06), transparent 26%),
        var(--bg) !important;
    color: var(--text) !important;
    color-scheme: light;
}
