* {
    box-sizing: border-box;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    background: #f3f4f6;
    color: #1f2933;
}

body.modal-open {
    overflow: hidden;
}

header {
    background: #0f5d7a;
    color: #fff;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    line-height: 1.4;
}

.header-bar {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.75rem;
}

.back-link {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

main {
    display: flex;
    min-height: calc(100vh - 140px);
}

.menu {
    width: 280px;
    padding: 1.5rem;
    background: #fff;
    border-right: 1px solid #e5e7eb;
}

.menu h2 {
    margin-top: 0;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
}

.menu__btn {
    display: block;
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid #0f5d7a;
    background: #fff;
    color: #0f5d7a;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.menu__btn:hover,
.menu__btn.active {
    background: #0f5d7a;
    color: #fff;
}

.forms {
    flex: 1;
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.form-card {
    display: none;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 10px rgba(15, 93, 122, 0.12);
}

.form-card.active {
    display: flex;
}

.form-card h3 {
    margin-top: 0;
    color: #0f5d7a;
}

form {
    display: grid;
    gap: 1rem;
}

.form-card > * + * {
    margin-top: 1.5rem;
}

label {
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.compact-field input {
    max-width: 220px;
}

input,
textarea,
select {
    padding: 0.65rem 0.8rem;
    border-radius: 6px;
    border: 1px solid #cbd5f5;
    font-size: 0.95rem;
}

textarea {
    resize: vertical;
}

button[type="submit"] {
    border: none;
    background: #0f5d7a;
    color: #fff;
    padding: 0.85rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s ease;
}

button[type="submit"]:hover {
    transform: translateY(-1px);
}

.form-status {
    min-height: 1.1rem;
    font-size: 0.85rem;
    margin: 0;
    color: #0f5d7a;
}

.form-status.success {
    color: #0f9d58;
}

.form-status.error {
    color: #b91c1c;
}

.product-panel {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.product-panel__notice {
    border: 1px dashed #0f5d7a;
    background: #f0f8fb;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #0f5d7a;
}

.product-panel__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.product-panel__hint {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    color: #64748b;
}

.product-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    background: #fff;
    max-width: 420px;
}

.product-search span {
    font-size: 0.9rem;
}

.product-search input {
    border: none;
    outline: none;
    width: 100%;
    padding: 0;
    font-size: 0.95rem;
}

.refresh-products {
    border: 1px solid #0f5d7a;
    background: transparent;
    color: #0f5d7a;
    padding: 0.65rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.refresh-products:hover {
    background: rgba(15, 93, 122, 0.1);
}

.product-form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.product-table-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
}

.product-table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.product-table-wrapper th,
.product-table-wrapper td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.product-table-wrapper th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

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

.product-lines {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f8fafc;
}

.product-lines__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.product-lines__hint {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: #64748b;
}

.product-lines__list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.product-line {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.product-line button.remove-line {
    border: 1px solid #b91c1c;
    background: transparent;
    color: #b91c1c;
    padding: 0.55rem 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    height: fit-content;
}

.add-product-line {
    border: 1px solid #0f5d7a;
    background: transparent;
    color: #0f5d7a;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.product-lines .add-product-line {
    align-self: flex-start;
}

.add-product-line:hover,
.product-line button.remove-line:hover {
    opacity: 0.85;
}

@media (max-width: 900px) {
    main {
        flex-direction: column;
    }

    .menu {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .menu h2 {
        width: 100%;
    }

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

    .forms {
        grid-template-columns: 1fr;
        padding: 1.5rem;
    }

    .product-panel__header {
        flex-direction: column;
        align-items: stretch;
    }
}

.site-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    color: #64748b;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.confirm-modal__dialog {
    position: relative;
    width: min(1080px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}

.confirm-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.confirm-modal__header h3 {
    margin: 0;
    color: #1f2933;
}

.confirm-modal__close {
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: #64748b;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.8rem;
    line-height: 1;
}

.confirm-modal__hint {
    margin: 0;
    text-align: center;
    padding: 1.2rem 1rem 0;
    color: #64748b;
    font-size: 1.1rem;
}

.confirm-modal__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
    padding: 1rem 1.5rem;
}

.confirm-summary-item {
    background: #f1f5f9;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.confirm-summary-item span {
    text-transform: uppercase;
    font-size: 0.78rem;
    color: #64748b;
    letter-spacing: 0.5px;
}

.confirm-summary-item strong {
    font-size: 1.05rem;
    color: #1f2933;
}

.confirm-modal__table-wrapper {
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 1.5rem;
}

.confirm-modal__table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}

.confirm-modal__table-wrapper th,
.confirm-modal__table-wrapper td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.confirm-modal__table-wrapper thead {
    background: #f1f5f9;
}

.confirm-modal__agreement {
    margin: 1.25rem 1.5rem 0;
    padding: 0.95rem 1rem;
    border: 1px solid #d9e2ec;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 1rem;
    cursor: pointer;
    background: #f8fafc;
}

.confirm-modal__agreement input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.confirm-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.9rem;
    padding: 1.4rem 1.5rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    margin-top: 1.4rem;
}

.confirm-modal__btn {
    border: none;
    border-radius: 999px;
    padding: 0.8rem 1.45rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
}

.confirm-modal__btn--ghost {
    background: #e2e8f0;
    color: #0f5d7a;
}

.confirm-modal__btn--primary {
    background: #5a9bb8;
    color: #fff;
}

.confirm-modal__btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 700px) {
    .confirm-modal__actions {
        flex-direction: column;
    }

    .confirm-modal__btn {
        width: 100%;
    }
}

/* ===== Paleta Pan de Tata ===== */
:root {
    --pdt-black: #000000;
    --pdt-cream: #F8F3E9;
    --pdt-cream-soft: #FFF8ED;
    --pdt-brown: #C06E32;
    --pdt-border: #D9C8AB;
}

body {
    background: var(--pdt-cream);
    color: var(--pdt-black);
}

header {
    background: var(--pdt-black);
    color: var(--pdt-cream);
}

header h1 {
    color: var(--pdt-cream);
}

.back-link {
    background: var(--pdt-brown);
    color: var(--pdt-cream);
    border: 1px solid var(--pdt-brown);
}

.back-link:hover,
.back-link:focus-visible {
    background: var(--pdt-black);
    color: var(--pdt-cream);
    border-color: var(--pdt-black);
    outline: none;
}

.menu {
    background: var(--pdt-cream-soft);
    border-right: 1px solid var(--pdt-border);
}

.menu__btn {
    border-color: var(--pdt-brown);
    background: var(--pdt-cream);
    color: var(--pdt-black);
    font-weight: 700;
}

.menu__btn:hover,
.menu__btn.active,
.menu__btn:focus-visible {
    background: var(--pdt-brown);
    color: var(--pdt-cream);
    border-color: var(--pdt-brown);
    outline: none;
}

.form-card {
    background: var(--pdt-cream-soft);
    border: 1px solid var(--pdt-border);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.1);
}

.form-card h3,
label,
.product-lines__hint,
.product-panel__hint,
.site-footer {
    color: var(--pdt-black);
}

input,
textarea,
select,
.product-search {
    background: #fffdf8;
    color: var(--pdt-black);
    border: 1px solid var(--pdt-border);
}

input::placeholder,
textarea::placeholder {
    color: #6c5848;
}

button[type="submit"],
.add-product-line,
.refresh-products,
.product-line button.remove-line,
.confirm-modal__btn--primary,
.confirm-modal__btn--ghost {
    background: var(--pdt-brown);
    color: var(--pdt-cream);
    border: 1px solid var(--pdt-brown);
}

button[type="submit"]:hover,
.add-product-line:hover,
.refresh-products:hover,
.product-line button.remove-line:hover,
.confirm-modal__btn--primary:hover,
.confirm-modal__btn--ghost:hover,
.confirm-modal__btn--primary:focus-visible,
.confirm-modal__btn--ghost:focus-visible {
    background: var(--pdt-black);
    color: var(--pdt-cream);
    border-color: var(--pdt-black);
    opacity: 1;
    outline: none;
}

.product-panel {
    border-top: 1px solid var(--pdt-border);
}

.product-panel__notice,
.product-lines,
.confirm-summary-item,
.confirm-modal__agreement {
    background: var(--pdt-cream);
    color: var(--pdt-black);
    border-color: var(--pdt-border);
}

.product-table-wrapper,
.confirm-modal__table-wrapper,
.confirm-modal__dialog {
    border-color: var(--pdt-border);
    background: var(--pdt-cream-soft);
}

.product-table-wrapper th,
.product-table-wrapper td,
.confirm-modal__table-wrapper th,
.confirm-modal__table-wrapper td,
.confirm-summary-item strong,
.confirm-modal__header h3,
.confirm-modal__hint,
.confirm-summary-item span,
.confirm-modal__agreement {
    color: var(--pdt-black);
}

.product-table-wrapper th,
.confirm-modal__table-wrapper thead,
.confirm-modal__header,
.confirm-modal__actions {
    background: #f1dcc1;
    border-color: var(--pdt-border);
}

.product-table-wrapper tbody tr:hover {
    background: #f7e7d1;
}

.form-status {
    color: var(--pdt-black);
}

.form-status.success {
    color: #1f7a3f;
}

.form-status.error {
    color: #9f1d1d;
}

.confirm-modal__close {
    background: var(--pdt-cream);
    color: var(--pdt-black);
    border-color: var(--pdt-border);
}
