.mad-stack { display: grid; gap: 15px; }
.mad-form { max-width: 880px; }
.mad-span { grid-column: 1 / -1; }
.mad-table { overflow-x: auto; }
.mad-nowrap { white-space: nowrap; }
.mad-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.mad-top { margin-top: 14px; }
.mad-muted { color: var(--muted); }
.mad-inline { display: inline; }
.mad-nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #b45309;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
#submenus a { display: flex; align-items: center; gap: 8px; }

.mad-state {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
    background: #fef3c7;
    color: #92400e;
}
.mad-state.enviado, .mad-state.preparando { background: #e0f2fe; color: #0369a1; }
.mad-state.en_camino { background: #ffedd5; color: #9a3412; }
.mad-state.convertido, .mad-state.entregada, .mad-state.ok { background: #dcfce7; color: #166534; }
.mad-state.vencido, .mad-state.bajo { background: #fee2e2; color: #991b1b; }
.mad-state.cta_cte { background: #ede9fe; color: #5b21b6; }

.mad-calc-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
}
.mad-calc-box strong { color: #92400e; font-size: 15px; }

.mad-rows { margin: 14px 0 0; border: 1px solid var(--line); border-radius: 9px; min-width: 0; padding: 12px; }
.mad-rows legend { padding-inline: 6px; font-weight: 700; }
.mad-sale-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 180px; gap: 10px; margin-bottom: 10px; }
.mad-sale-row:last-child { margin-bottom: 0; }
.mad-sale-row select { width: 100%; text-overflow: ellipsis; }

.mad-facts dt, .mad-balance dt { color: var(--muted); font-size: 13px; }
.mad-facts dd, .mad-balance dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.mad-balance { display: flex; flex-wrap: wrap; gap: 12px 24px; border-top: 1px solid var(--line); padding: 12px 0 0; margin-bottom: 0; }
.mad-total { text-align: right; font-size: 18px; font-weight: 700; }
.mad-form textarea {
    display: block; width: 100%; margin-top: 4px; padding: 8px 10px; resize: vertical;
    font: inherit; color: var(--ink); background: white; border: 1px solid #cbd5e1; border-radius: 7px;
}

.mad-print main { max-width: 820px; margin: auto; padding: 20px; }
.mad-print-nav { margin-bottom: 16px; }
@media (max-width: 720px) { .mad-sale-row { grid-template-columns: minmax(0, 1fr); } }
@media print {
    body.mad-print { background: white; color: #000; }
    .mad-print .panel { border: 0; box-shadow: none; padding: 0; }
    .mad-print-nav { display: none; }
}
