:root{
    --bg:#f4f6f8;
    --surface:#ffffff;
    --primary:#2563eb;
    --primary-light:#dbeafe;
    --text:#1f2937;
    --text-light:#6b7280;
    --border:#e5e7eb;
    --success:#16a34a;
    --radius:16px;
    --shadow: 0 4px 18px rgba(0,0,0,.08);
}

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

html{
    font-size:16px;
    overflow-x: hidden;
    width: 100%;
}

body{
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background:var(--bg);
    color:var(--text);
    overflow-x: hidden;
    width: 100%;
}

.app{
    width:100%;
    max-width:1200px;
    margin:auto;
    padding:18px;
}

/**************************************************
 HEADER
**************************************************/
.header{
    margin-bottom:22px;
}

.header h1{
    font-size:2rem;
    font-weight:700;
}

.header p{
    margin-top:6px;
    color:var(--text-light);
}

/**************************************************
 BUSCADOR
**************************************************/
.search-panel{
    margin-bottom:18px;
}

#search{
    width:100%;
    padding:16px 18px;
    border-radius:14px;
    border:1px solid var(--border);
    font-size:1rem;
    outline:none;
    transition:.2s;
    background:white;
}

#search:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

/**************************************************
 ESTADÍSTICAS
**************************************************/
.stats{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    color:var(--text-light);
    margin-bottom:18px;
    font-size:.95rem;
}

/**************************************************
 FILTROS
**************************************************/
.filters{
    display:flex;
    gap:10px;
    overflow-x:auto;
    margin-bottom:24px;
    padding-bottom:4px;
}

.filters::-webkit-scrollbar{
    display:none;
}

.filter{
    flex:none;
    cursor:pointer;
    padding:10px 18px;
    border-radius:999px;
    border:1px solid var(--border);
    background:white;
    transition:.2s;
    white-space:nowrap;
    user-select:none;
}

.filter.active{
    background:var(--primary);
    color:white;
    border-color:var(--primary);
}

/**************************************************
 TARJETA
**************************************************/
.card{
    background:white;
    border-radius:var(--radius);
    padding:20px;
    box-shadow:var(--shadow);
    border:1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.card-header{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
}

.box-title{
    font-size:1.2rem;
    font-weight:700;
}

.status{
    background:#ecfdf5;
    color:var(--success);
    padding:5px 12px;
    border-radius:999px;
    font-size:.82rem;
    white-space:nowrap;
}

.description{
    margin-top:10px;
    font-size:1.15rem;
    font-weight:600;
}

.meta{
    margin-top:10px;
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.badge{
    background:var(--primary-light);
    color:var(--primary);
    padding:5px 12px;
    border-radius:999px;
    font-size:.85rem;
}

.content{
    margin-top:18px;
}

.content ul{
    margin-left:18px;
    margin-top:8px;
}

.content li{
    margin-bottom:6px;
}

.comments{
    margin-top:18px;
    color:var(--text-light);
    font-size:.95rem;
}

.loading{
    text-align:center;
    padding:50px;
    color:var(--text-light);
}

.empty{
    background:white;
    border-radius:var(--radius);
    padding:40px;
    text-align:center;
    color:var(--text-light);
    border:1px solid var(--border);
}

#btn-add {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    font-size: 30px;
    border: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

#btn-add:active {
    transform: scale(0.95);
    background-color: #0056b3;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 25px;
    width: 90%;
    max-width: 450px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.btn-form {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    margin-right: 10px;
}

@media (min-width: 1025px) {
    .results {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
    }
}

@media (max-width: 1024px) {
    html, body {
        font-size: 18px !important;
    }
    .results {
        display: block !important;
        width: 100% !important;
    }
    .card {
        width: 100% !important;
        margin-bottom: 20px !important;
        padding: 24px !important;
    }
    .box-title { font-size: 1.5rem !important; }
    .description { font-size: 1.3rem !important; }
    .content, .content strong, .content li { font-size: 1.2rem !important; }
    .meta .badge { font-size: 1rem !important; padding: 8px 16px !important; }
    
    .search-panel {
        margin-bottom: 25px !important;
    }

    #btn-scan{
        width:120px;
        height:120px;
        font-size:52px;
    }
    
    #search {
        width: 100% !important;
        height: 120px !important;
        font-size: 2.8rem !important;
        padding: 0 20px !important;
        box-sizing: border-box !important;
    }
    
    .search-panel input {
        display: block !important;
        width: 100% !important;
    }
    
    .filter {
        font-size: 1.6rem !important;
        padding: 12px 20px !important;
    }

    #btn-add {
        width: 120px;
        height: 120px;
        font-size: 60px;
        bottom: 60px;
        right: 60px;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
        margin: 5% auto;
    }

    .form-input {
        padding: 14px;
        font-size: 22px;
        margin-bottom: 15px;
    }

    .btn-form {
        padding: 14px;
        font-size: 22px;
        width: 100%;
        margin-bottom: 10px;
        margin-right: 0;
    }
}

.btn-save { background-color: #007bff; color: white; }
.btn-cancel { background-color: #6c757d; color: white; }

#success-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #28a745;
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    z-index: 2000;
    transition: opacity 0.5s ease;
}

#qr-modal .modal-content{
    text-align:center;
}

#qr-image{
    display:flex;
    justify-content:center;
    align-items:center;
    margin:20px auto;
}

#qr-image canvas{
    display:block;
    margin:auto;
}

#qr-image img{
    display:block;
    margin:auto;
}

.highlight{
    background:#ffe95b;
    color:#000;
    padding:1px 2px;
    border-radius:3px;
    font-weight:700;
}

/********************************------------------
 BUSCADOR CON BOTÓN QR
**************************************************/
.search-wrapper{
    display:flex;
    align-items:center;
    gap:10px;
}

.search-wrapper input{
    flex:1;
}

#btn-scan{
    width:56px;
    height:56px;
    border:none;
    border-radius:14px;
    background:#2563eb;
    color:white;
    font-size:24px;
    cursor:pointer;
    transition:.2s;
    flex:none;
}

#btn-scan:hover{
    transform:scale(1.05);
}

#reader{
    width:100%;
    max-width:350px;
    margin:20px auto;
}