* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #0a0a0a;
    color: #e8e0d4;
}

.app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    background: #111111;
    display: flex;
    flex-direction: column;
}

header {
    background: #111111;
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #e8e0d4;
}

.header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.add-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #d4a853;
    color: #0a0a0a;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.add-btn:hover {
    background: #e0b45e;
    transform: scale(1.02);
}

.scan-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #2a2a2a;
    color: #e8e0d4;
    border: 1px solid #3a3a3a;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-btn:hover {
    background: #3a3a3a;
    border-color: #d4a853;
}

.stats-bar {
    display: flex;
    gap: 20px;
    padding: 16px 20px;
    background: #111111;
    border-bottom: 1px solid #2a2a2a;
}

.stat {
    flex: 1;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #d4a853;
    font-family: 'DM Mono', monospace;
}

.stat-label {
    font-size: 0.7rem;
    color: #7a7060;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: 'DM Mono', monospace;
}

.filters-bar {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: #111111;
    border-bottom: 1px solid #2a2a2a;
    flex-wrap: wrap;
}

.filter-select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #1a1a1a;
    color: #e8e0d4;
    font-family: 'DM Mono', monospace;
}

.search-input {
    flex: 2;
    padding: 10px 12px;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #1a1a1a;
    color: #e8e0d4;
    font-family: 'DM Mono', monospace;
}

.search-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #d4a853;
}

.rolls-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.roll-card {
    background: #1a1a1a;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #2a2a2a;
    transition: all 0.2s;
}

.roll-card:hover {
    border-color: #d4a853;
}

.roll-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.roll-title {
    font-size: 1rem;
    font-weight: 500;
    color: #e8e0d4;
    flex: 1;
}

.edit-roll {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #7a7060;
    padding: 4px 8px;
    transition: color 0.2s;
}

.edit-roll:hover {
    color: #d4a853;
}

.delete-roll {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: #7a7060;
    padding: 4px 8px;
    transition: color 0.2s;
}

.delete-roll:hover {
    color: #c47a7a;
}

.roll-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    font-family: 'DM Mono', monospace;
}

.badge-format {
    background: #2a2a2a;
    color: #7a7060;
}

.badge-type {
    background: #d4a853;
    color: #0a0a0a;
}

.badge-frames {
    background: #1a2a2a;
    color: #7aa8d0;
}

.badge-iso {
    background: #2a2a1a;
    color: #d4a853;
}

.roll-expiry {
    font-size: 0.7rem;
    color: #7a7060;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'DM Mono', monospace;
}

.expiry-warning {
    color: #d49060;
}

.expiry-expired {
    color: #c47a7a;
}

.backup-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px;
    background: #111111;
    border-top: 1px solid #2a2a2a;
    border-bottom: 1px solid #2a2a2a;
    justify-content: center;
}

.backup-btn {
    flex: 1;
    min-width: 100px;
    padding: 10px 16px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'DM Mono', monospace;
    color: #e8e0d4;
}

.backup-btn:hover {
    background: #2a2a2a;
    border-color: #d4a853;
}

.qr-btn {
    background: #d4a853;
    color: #0a0a0a;
    border-color: #d4a853;
}

.qr-btn:hover {
    background: #e0b45e;
}

footer {
    text-align: center;
    padding: 20px;
    color: #7a7060;
    font-size: 0.7rem;
    border-top: 1px solid #2a2a2a;
    margin-top: 20px;
    font-family: 'DM Mono', monospace;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-card {
    background: #111111;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #2a2a2a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e8e0d4;
    font-family: 'DM Mono', monospace;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7a7060;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

form {
    padding: 20px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #7a7060;
    font-family: 'DM Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.field input,
.field select {
    width: 100%;
    padding: 12px;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'DM Mono', monospace;
    background: #1a1a1a;
    color: #e8e0d4;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #d4a853;
}

.field select:disabled {
    background-color: #0a0a0a;
    color: #4a4540;
    cursor: not-allowed;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: #d4a853;
    color: #0a0a0a;
    border: none;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
    font-family: 'DM Mono', monospace;
}

.submit-btn:hover {
    background: #e0b45e;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7a7060;
}

.edit-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2a2a2a;
    padding: 4px 8px;
    border-radius: 4px;
}

.qty-btn {
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    color: #e8e0d4;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: #d4a853;
    color: #0a0a0a;
}

.qty-number {
    font-weight: 600;
    min-width: 24px;
    text-align: center;
    color: #e8e0d4;
}

.roll-header > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* QR y Scanner Styles */
.qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.qr-modal-content {
    background: #111111;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    text-align: center;
}

.qr-modal-image {
    width: 280px;
    height: 280px;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
}

.qr-modal-stats {
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    color: #e8e0d4;
    margin: 16px 0 8px;
}

.qr-modal-hint {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: #7a7060;
}

.qr-modal-close {
    font-family: 'DM Mono', monospace;
    font-size: 0.6rem;
    color: #4a4540;
    margin-top: 12px;
}

.qr-scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.qr-scanner-video {
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    border: 2px solid #d4a853;
}

.qr-scanner-text {
    color: #e8e0d4;
    margin-top: 16px;
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem;
    text-align: center;
    padding: 0 20px;
}

.qr-scanner-button {
    margin-top: 20px;
    padding: 10px 24px;
    background: #d4a853;
    border: none;
    border-radius: 8px;
    font-family: 'DM Mono', monospace;
    cursor: pointer;
    font-size: 0.9rem;
    color: #0a0a0a;
    font-weight: bold;
}

.qr-scanner-button:hover {
    background: #e0b45e;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #2a2a2a;
    border: 1px solid #d4a853;
    color: #e8e0d4;
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    padding: 10px 18px;
    border-radius: 8px;
    z-index: 4000;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    max-width: 90%;
    white-space: normal;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.btn-secondary {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    color: #e8e0d4;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'DM Mono', monospace;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #3a3a3a;
    border-color: #d4a853;
}

/* =============================================
   PIN Screen
   ============================================= */
.pin-screen {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: pinFadeIn 0.3s ease;
}

.pin-screen.pin-exit {
    animation: pinFadeOut 0.3s ease forwards;
}

@keyframes pinFadeIn {
    from { opacity: 0; transform: scale(1.02); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pinFadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.97); }
}

.pin-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    width: 100%;
    max-width: 320px;
}

.pin-logo {
    font-size: 3rem;
    margin-bottom: 12px;
}

.pin-title {
    font-family: 'DM Mono', monospace;
    font-size: 1.2rem;
    color: #e8e0d4;
    font-weight: 500;
    margin-bottom: 4px;
}

.pin-subtitle {
    font-family: 'DM Mono', monospace;
    font-size: 0.75rem;
    color: #7a7060;
    margin-bottom: 32px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.pin-dots {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.pin-dots-small {
    margin: 12px auto 16px;
    justify-content: center;
}

.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #3a3a3a;
    background: transparent;
    transition: all 0.15s ease;
}

.pin-dot.active {
    background: #d4a853;
    border-color: #d4a853;
    transform: scale(1.1);
}

.pin-dot.shake {
    animation: dotShake 0.5s ease;
    border-color: #c47a7a;
    background: #c47a7a;
}

@keyframes dotShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.pin-error {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: #c47a7a;
    min-height: 18px;
    margin-bottom: 8px;
    text-align: center;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 280px;
    margin-top: 16px;
}

.pin-keypad-small {
    max-width: 260px;
    gap: 10px;
    margin: 0 auto;
}

.pin-key {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    color: #e8e0d4;
    font-family: 'DM Mono', monospace;
    font-size: 1.3rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.pin-key:hover {
    background: #2a2a2a;
    border-color: #d4a853;
}

.pin-key:active {
    background: #d4a853;
    color: #0a0a0a;
    transform: scale(0.94);
}

.pin-key-empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
    pointer-events: none;
}

.pin-key-empty:hover {
    background: transparent;
    border-color: transparent;
}

.pin-modal-title {
    font-family: 'DM Mono', monospace;
    font-size: 1rem;
    color: #e8e0d4;
    font-weight: 500;
}

.pin-setup-label {
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem;
    color: #7a7060;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-align: center;
    margin-bottom: 8px;
}

.pin-setup-hint {
    font-family: 'DM Mono', monospace;
    font-size: 0.72rem;
    color: #7a7060;
    text-align: center;
    min-height: 18px;
    margin-top: 12px;
}

.pin-footer-btn {
    background: none;
    border: none;
    color: #3a3a3a;
    font-family: 'DM Mono', monospace;
    font-size: 0.65rem;
    cursor: pointer;
    margin-top: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s;
}

.pin-footer-btn:hover {
    color: #7a7060;
}
    .rolls-container {
        padding: 12px;
    }
    
    .backup-buttons {
        flex-direction: column;
    }
    
    .backup-btn {
        width: 100%;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .qr-scanner-video {
        max-width: 90%;
    }
    
    .toast {
        font-size: 0.7rem;
        padding: 8px 14px;
    }
}