* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(135deg, #f5f7ff, #dde3ff);
    color: #1d1d1f;
}

/* Estilo general */

.main-container {
    max-width: 1100px;
    margin: 40px auto;
    background: #ffffff;
    border-radius: 24px;
    padding: 24px 28px 32px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.08);
}

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

.app-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.app-subtitle {
    font-size: 14px;
    color: #6e6e73;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    background: #007aff;
    color: #fff;
    gap: 6px;
    text-decoration: none;
}

.btn-secondary {
    background: #f2f2f7;
    color: #1d1d1f;
}

.btn-danger {
    background: #ff3b30;
    color: #fff;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 999px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.tag {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    background: #f2f2f7;
    color: #6e6e73;
}

/* TABLAS */

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 14px;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f1f5;
    text-align: left;
}

.table th {
    font-weight: 600;
    color: #6e6e73;
    background: #fafafa;
}

/* Inputs */

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="password"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #e5e5ea;
    font-size: 14px;
    outline: none;
    transition: border 0.2s, box-shadow 0.2s;
    background: #f9f9fb;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #007aff;
    box-shadow: 0 0 0 2px rgba(0,122,255,0.15);
    background: #ffffff;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* Notificaciones */

.alert {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-ok {
    background: #e8f9ee;
    color: #1b7a3c;
}

.alert-error {
    background: #ffecec;
    color: #b3261e;
}

/* Layout dos columnas */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.section-card {
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 18px;
    background: #f9f9fb;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 15px;
}

.section-title-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Secciones dinámicas (+) */

.section-hidden {
    display: none;
}

.section-highlight {
    box-shadow: 0 0 0 2px rgba(0,122,255,0.2);
    transition: box-shadow 0.4s ease;
}

.mas-opciones {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.mas-opciones.mas-opciones-visible {
    display: flex;
}

/* Garantía */

.badge-garantia {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
}

.garantia-ok {
    background: #d4f8e8;
    color: #0c7c3b;
}

.garantia-media {
    background: #fff4d6;
    color: #b35a00;
}

.garantia-vencida {
    background: #ffe0e0;
    color: #b3261e;
}

.garantia-sin {
    background: #e5e5ea;
    color: #6e6e73;
}

/* Productos en la nota */

.producto-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed #e5e5ea;
}

.producto-thumb {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 11px;
    color: #6e6e73;
}

.producto-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.producto-main {
    font-size: 14px;
}

.producto-nombre {
    font-weight: 600;
}

.producto-desc {
    font-size: 12px;
    color: #6e6e73;
    margin-top: 2px;
}

.producto-precio {
    margin-top: 4px;
    font-weight: 600;
}

/* Fotos */

.fotos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.foto-item {
    border-radius: 16px;
    overflow: hidden;
    background: #f2f2f7;
    position: relative;
    padding: 4px;
}

.foto-item img {
    width: 100%;
    border-radius: 12px;
    display: block;
}

/* Botones de nota */

.note-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.note-button {
    border-radius: 999px;
    padding: 6px 14px;
    background: #007aff;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
}

/* Login estilo iPhone */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iphone-frame {
    width: 320px;
    height: 640px;
    border-radius: 46px;
    background: radial-gradient(circle at top, #f9fafc 0, #f3f4fb 40%, #e9ebf5 100%);
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
    padding: 20px 16px 26px;
    position: relative;
}

.iphone-notch {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 150px;
    height: 26px;
    background: #111827;
    border-radius: 20px;
}

.iphone-inner {
    position: relative;
    margin-top: 46px;
    height: calc(85% - 60px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.iphone-header {
    text-align: center;
    margin-top: 20px;
}

.iphone-header h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.iphone-header p {
    font-size: 13px;
    color: #6e6e73;
}

.code-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

.code-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #d1d5db;
}

.code-dot.filled {
    background: #111827;
}

.num-pad {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 60px;
    gap: 10px;
    margin-top: 24px;
}

.num-btn {
    border-radius: 999px;
    border: none;
    background: #f2f2f7;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.num-btn:active {
    background: #e0e0e7;
}

.num-sub {
    font-size: 9px;
    text-transform: uppercase;
    margin-left: 4px;
    color: #a1a1aa;
}

.iphone-footer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 6px;
}

.hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Cliente */

.cliente-container {
    max-width: 600px;
    margin: 40px auto;
    background: #ffffff;
    border-radius: 24px;
    padding: 22px 24px 30px;
    box-shadow: 0 18px 45px rgba(0,0,0,0.08);
}


.copyable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* Ordenador de bloques (drag & drop) */
.bloques-sortable {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
}
.bloque-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 12px;
    background: #f2f2f7;
    cursor: grab;
    user-select: none;
}
.bloque-item:active {
    cursor: grabbing;
}
.bloque-handle {
    font-size: 16px;
    line-height: 1;
    letter-spacing: 2px;
    opacity: 0.6;
}
.bloque-item.dragging {
    opacity: 0.7;
    transform: scale(0.99);
}
/* Utilidades */

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }

.text-right { text-align: right; }
.text-center { text-align: center; }


/* Modal flotante para fotos en cliente */
.foto-thumb-click {
    cursor: pointer;
    border-radius: 16px;
    overflow: hidden;
}
.foto-thumb-click img {
    display: block;
    width: 100%;
    height: auto;
}

.foto-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.foto-modal.visible {
    display: flex;
}
.foto-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}
.foto-modal-content img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.foto-modal-close {
    position: absolute;
    top: -14px;
    right: -14px;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: #ffffff;
    color: #000;
    font-size: 20px;
    line-height: 32px;
    text-align: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    cursor: pointer;
}


@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .main-container {
        max-width: 100%;
        margin: 10px;
        padding: 14px;
        border-radius: 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.04);
    }

    .cliente-container {
        max-width: 100%;
        margin: 10px;
        padding: 16px;
        border-radius: 18px;
        box-shadow: 0 12px 32px rgba(0,0,0,0.06);
    }

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

    .app-title {
        font-size: 20px;
    }

    .app-subtitle {
        font-size: 13px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .section-card {
        padding: 14px 14px 16px;
        border-radius: 18px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .producto-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .producto-thumb {
        margin-bottom: 8px;
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table thead {
        display: table-header-group;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    .iphone-frame {
        transform: scale(0.95);
        transform-origin: top center;
    }

    .fotos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .main-container {
        margin: 8px;
        padding: 12px;
        border-radius: 14px;
    }

    .cliente-container {
        margin: 8px;
        padding: 14px;
        border-radius: 16px;
    }

    .app-title {
        font-size: 18px;
    }

    .section-card {
        padding: 12px 12px 14px;
        border-radius: 14px;
    }

    .iphone-frame {
        transform: scale(0.9);
        transform-origin: top center;
    }

    .fotos-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .note-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .note-button {
        width: 100%;
        justify-content: center;
    }
}

.section-card.dragging {
    opacity: 0.85;
    transform: scale(0.99);
}
