:root {
    --accent: #8a6d3b;
    --accent-dark: #5c4826;
    --bg: #faf8f5;
    --card-bg: #ffffff;
    --border: #ddd4c7;
    --text: #2a2420;
    --text-muted: #70665a;
    --danger-bg: #fff4e5;
    --danger-border: #e0a940;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 16px;
    padding-bottom: 48px;
}

.wrap {
    max-width: 480px;
    margin: 0 auto;
}

header.topbar {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.lang-switch {
    display: flex;
    justify-content: center;
    gap: 6px;
    font-size: 0.85rem;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.lang-switch a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 2px 4px;
}

.lang-switch a.active {
    color: var(--accent);
    font-weight: 700;
    text-decoration: underline;
}

.estilo-thumb {
    width: 140px;
    height: 140px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 auto 10px;
    display: block;
}

.estilo-nombre {
    text-align: center;
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 18px;
}

header.topbar h1 {
    font-size: 1.3rem;
    margin: 4px 0 2px;
}

header.topbar p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.9rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}

.estilo-link {
    display: block;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    text-decoration: none;
    color: var(--text);
}

.estilo-link strong {
    display: block;
    font-size: 1.05rem;
}

.estilo-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

fieldset {
    border: none;
    padding: 0;
    margin: 0 0 18px;
}

legend {
    font-weight: 600;
    margin-bottom: 8px;
    padding: 0;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.92rem;
}

.req::after {
    content: " *";
    color: #b8401a;
}

input[type="text"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 14px;
    background: #fff;
    color: var(--text);
}

input[readonly] {
    background: #f0f0f0;
    color: var(--text-muted);
}

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

.talla-box {
    background: var(--danger-bg);
    border: 1.5px solid var(--danger-border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 18px;
}

.talla-box label {
    margin-bottom: 8px;
}

.talla-box select {
    margin-bottom: 0;
}

.hint {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin: -10px 0 14px;
}

.crest-fijo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.82rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    margin: 0;
}

.crest-star {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: #000;
    stroke: #000;
    stroke-width: 0.5;
}

button.submit {
    width: 100%;
    padding: 15px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
}

button.submit:active {
    background: var(--accent-dark);
}

.coleccion-header {
    font-size: 1rem;
    margin: 22px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.coleccion-header:first-of-type {
    margin-top: 4px;
}

.gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.photo-card {
    display: block;
    text-decoration: none;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.photo-card .thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fff;
    display: block;
}

.photo-card .label {
    padding: 8px 10px 10px;
}

.photo-card .label strong {
    display: block;
    font-size: 0.86rem;
    line-height: 1.2;
}

.photo-card .badge {
    margin-top: 2px;
}

.photo-card.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.buscar-form {
    display: flex;
    gap: 8px;
}

.buscar-form input {
    flex: 1;
    margin-bottom: 0;
}

.buscar-form button {
    width: auto;
    padding: 0 16px;
}

.orden-item {
    display: block;
    text-decoration: none;
    color: var(--text);
}

.orden-item strong {
    display: block;
}

.orden-item span {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.edit-link {
    display: inline-block;
    margin-top: 16px;
    padding: 12px 18px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
}

.token-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.confirm-box {
    text-align: center;
    padding: 28px 16px;
}

.confirm-box .check {
    font-size: 2.6rem;
    margin-bottom: 8px;
}

.estilo-talla {
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
    margin: 14px 0 0;
}

.ficha {
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    background: #f4f4f4;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.ficha dt {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.ficha dd {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: right;
}

.resumen {
    text-align: left;
}

.resumen dt {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.resumen dd {
    margin: 0;
    font-size: 1rem;
}

.texto-piedra-confirm {
    text-align: center;
    margin: 14px 0;
}

.texto-piedra-confirm-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.texto-piedra-confirm-valor {
    font-size: 1.1rem;
    font-weight: 600;
}

.laterales-layout {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    margin: 14px 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.lateral-col {
    flex: 1;
}

.lateral-col.lateral-col-der {
    text-align: right;
}

.lateral-col.lateral-col-der .lateral-thumb-confirm {
    margin-left: auto;
}

.lateral-col-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
}

.lateral-col-texto {
    font-size: 1rem;
    font-weight: 600;
}

.lateral-col-nombre {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.foto-cliente-badge {
    font-style: italic;
    color: var(--accent);
}

.lateral-thumb-confirm {
    display: block;
    width: 70px;
    height: 70px;
    object-fit: contain;
    background: #000;
    border-radius: 6px;
    margin: 6px 0;
}

.foto-cliente-img {
    width: 160px;
    height: 160px;
    object-fit: cover;
    background: #f0f0f0;
    cursor: zoom-in;
}

.resumen dt.resumen-seccion {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Selector de laterales (Forma 2) */

.lateral-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px;
    margin-bottom: 4px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text);
}

.lateral-picker.lateral-picker-error {
    border-color: #b8401a;
}

.lateral-preview-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #fafafa;
    border-radius: 6px;
    flex-shrink: 0;
}

.foto-propia {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.foto-propia label {
    font-weight: 600;
    font-size: 0.9rem;
}

.foto-propia-preview {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    margin: 6px 0;
}

.foto-propia input[type="file"] {
    width: 100%;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.lateral-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 50;
    padding: 16px;
}

.lateral-modal.abierto {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lateral-modal-inner {
    background: var(--bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lateral-modal-header {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}

.lateral-modal-header input {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}

.lateral-modal-header button {
    padding: 0 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

.lateral-grid {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
}

.lateral-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    text-align: center;
    min-width: 0;
}

.lateral-card img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #fafafa;
    display: block;
    margin-bottom: 4px;
}

.lateral-card span {
    font-size: 0.72rem;
    line-height: 1.2;
    display: block;
    overflow-wrap: break-word;
}

.lateral-clave {
    font-size: 0.62rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.lateral-sin-resultados {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.estado-orden,
.locked-message {
    padding: 10px 12px;
    border-radius: 8px;
    background: #f4f1e8;
    font-weight: 700;
}

.estado-aprobada { background: #e5f5e9; color: #23663a; }
.estado-cancelada { background: #f9e3e0; color: #8b2924; }
.estado-pendiente_tienda,
.estado-pendiente_joyero { background: #fff2cd; color: #755514; }

.estado-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    margin: 3px 0;
    background: #f4f1e8;
}
.estado-badge.estado-aprobada { background: #e5f5e9; color: #23663a; }
.estado-badge.estado-cancelada { background: #f9e3e0; color: #8b2924; }
.estado-badge.estado-pendiente_tienda,
.estado-badge.estado-pendiente_joyero { background: #fff2cd; color: #755514; }

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 4px 0;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: underline;
}

.breadcrumbs strong {
    color: var(--text);
}

.breadcrumb-sep {
    margin: 0 6px;
}

.carpeta-lista {
    display: flex;
    flex-direction: column;
}

.carpeta-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 4px;
    border-top: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
}

.carpeta-item:first-child {
    border-top: none;
}

.carpeta-icono {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.carpeta-nombre {
    flex: 1;
    font-weight: 600;
    min-width: 0;
    overflow-wrap: break-word;
}

.carpeta-badge {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: #f4f1e8;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.carpeta-badge.carpeta-badge-pendiente {
    background: #fff2cd;
    color: #755514;
    font-weight: 700;
}

.panel-actions,
.order-tools form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

.panel-actions form { margin: 0; }
.panel-actions input { width: auto; margin: 0; }

.link-button {
    border: 0;
    background: none;
    padding: 0;
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.link-button.danger { color: #a52d27; }

.gabriel-orden-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.gabriel-orden-thumb {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    flex-shrink: 0;
}

.gabriel-orden-specs {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.phone-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.phone-link:hover { text-decoration: underline; }

.copy-phone-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 2px;
}

.order-tools {
    margin-top: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f8f7f3;
}

.order-tools summary { cursor: pointer; font-weight: 700; }
.order-tools textarea { min-height: 65px; margin: 8px 0; }
.history-list { margin: 10px 0 0; padding-left: 20px; color: var(--text-muted); }
