* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fa;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #111827;
    --green: #16a34a;
    --red: #dc2626;
}

body {
    margin: 0;
    font-family:
        Inter,
        Arial,
        Helvetica,
        sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: inherit;
}

.login-body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 36px;
    box-shadow:
        0 20px 50px rgba(0,0,0,.08);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 35px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: #111827;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.brand strong {
    display: block;
}

.brand small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

h1 {
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
}

label {
    display: block;
    margin-top: 20px;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    background: white;
    font-size: 15px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #6b7280;
    box-shadow:
        0 0 0 3px rgba(17,24,39,.08);
}

.btn {
    border: 0;
    border-radius: 9px;
    padding: 11px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-full {
    width: 100%;
    margin-top: 25px;
}

.alert {
    padding: 12px 14px;
    border-radius: 9px;
    margin-top: 18px;
    font-size: 14px;
}

.alert-error {
    color: #991b1b;
    background: #fee2e2;
}

.admin-header {
    height: 68px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.admin-main {
    width: min(1200px, calc(100% - 40px));
    margin: 35px auto;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logout-form {
    margin: 0;
}

.dashboard-title {
    margin-bottom: 25px;
}

.dashboard-title h1 {
    font-size: 28px;
}

.cards {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
}

.card-label {
    color: var(--muted);
    font-size: 14px;
}

.card-value {
    font-size: 30px;
    font-weight: 700;
    margin-top: 8px;
}

.table-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.table-header {
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 15px 22px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    color: #166534;
    background: #dcfce7;
}

.status-paused {
    color: #92400e;
    background: #fef3c7;
}

.url-small {
    max-width: 350px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--muted);
}

@media (max-width: 850px) {

    .cards {
        grid-template-columns:
            repeat(2, minmax(0,1fr));
    }

    .table-card {
        overflow-x: auto;
    }

}

@media (max-width: 520px) {

    .cards {
        grid-template-columns: 1fr;
    }

    .admin-header {
        padding: 0 16px;
    }

}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.form-container {
    max-width: 850px;
    margin: 0 auto;
}

.form-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 26px;
}

.field-help {
    color: var(--muted);
    font-size: 13px;
    margin-top: 6px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}

.slug-input {
    display: flex;
    align-items: stretch;
}

.slug-input span {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-right: 0;
    border-radius: 9px 0 0 9px;
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.slug-input input {
    border-radius: 0 9px 9px 0;
}

.readonly-box {
    padding: 12px 13px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 9px;
    overflow-wrap: anywhere;
}

.detail-grid {
    display: grid;
    grid-template-columns:
        minmax(0, 1.8fr)
        300px;
    gap: 22px;
    align-items: start;
}

.detail-grid aside {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.status-section {
    margin-top: 12px;
    margin-bottom: 18px;
}

.stats-card hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 12px;
    font-size: 14px;
}

.stat-row span {
    color: var(--muted);
}

.alert-success {
    color: #166534;
    background: #dcfce7;
    margin-bottom: 20px;
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-warning {
    background: #f59e0b;
    color: #111827;
}

.btn-success {
    background: #16a34a;
    color: white;
}

.qr-name-link {
    font-weight: 600;
    text-decoration: none;
}

.qr-name-link:hover {
    text-decoration: underline;
}

.table-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.table-subtitle {
    margin-top: 4px;
    font-size: 13px;
}


@media (max-width: 750px) {

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .slug-input {
        display: block;
    }

    .slug-input span {
        border-right: 1px solid #d1d5db;
        border-bottom: 0;
        border-radius: 9px 9px 0 0;
        padding: 10px 12px;
    }

    .slug-input input {
        border-radius: 0 0 9px 9px;
    }

}

.qr-preview-card {
    text-align: center;
}

.qr-preview-wrap {
    margin: 18px auto;
    max-width: 320px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.qr-preview {
    display: block;
    width: 100%;
    height: auto;
}

.qr-public-url {
    margin-top: 12px;
    padding: 10px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.qr-downloads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.qr-downloads .btn {
    width: 100%;
}

@media (max-width: 420px) {

    .qr-downloads {
        grid-template-columns: 1fr;
    }

}

.filter-card {
    margin-bottom: 24px;
    padding: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.filters {
    display: grid;
    grid-template-columns:
        minmax(230px, 2fr)
        minmax(130px, 1fr)
        minmax(140px, 1fr)
        minmax(150px, 1fr)
        auto;
    gap: 14px;
    align-items: end;
}

.filter-field label {
    margin: 0 0 7px;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.table-actions {
    display: flex;
    gap: 7px;
    align-items: center;
}

.btn-small {
    padding: 8px 11px;
    font-size: 12px;
}

.table-slug {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.status-archived {
    margin-left: 5px;
    color: #374151;
    background: #e5e7eb;
}

.row-archived {
    opacity: .72;
}

.copy-link-button {
    margin-top: 10px;
}

.archive-info {
    margin-top: 12px;
}

@media (max-width: 1000px) {

    .filters {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .filter-search {
        grid-column: 1 / -1;
    }

}

@media (max-width: 600px) {

    .filters {
        grid-template-columns: 1fr;
    }

    .filter-search {
        grid-column: auto;
    }

    .filter-actions {
        flex-direction: column;
    }

}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.settings-grid input[type="color"] {
    height: 52px;
    padding: 5px;
    cursor: pointer;
}

.settings-section-title {
    margin-top: 35px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    margin-bottom: 18px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

@media (max-width: 600px) {

    .settings-grid {
        grid-template-columns: 1fr;
    }

}

.chart-card {
    margin-top: 24px;
    padding: 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
}

.chart-header h2 {
    margin: 0 0 5px;
    font-size: 18px;
}

.chart-total {
    text-align: right;
}

.chart-total span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.chart-total strong {
    display: block;
    margin-top: 3px;
    font-size: 25px;
}

.scan-chart {
    height: 260px;
    display: grid;
    grid-template-columns: repeat(30, minmax(8px, 1fr));
    gap: 4px;
    align-items: stretch;
}

.chart-column {
    min-width: 0;
    display: grid;
    grid-template-rows: 20px 1fr 20px;
    align-items: end;
    text-align: center;
}

.chart-number {
    height: 20px;
    overflow: hidden;
    font-size: 10px;
    color: var(--muted);
}

.chart-track {
    height: 190px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bar {
    width: 70%;
    min-height: 3px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
}

.chart-label {
    padding-top: 5px;
    font-size: 9px;
    color: var(--muted);
}

@media (max-width: 700px) {

    .scan-chart {
        overflow-x: auto;
        grid-template-columns:
            repeat(30, minmax(18px, 1fr));
    }

}

/* =========================================================
   AJUSTES FINALES - VISTA QR
   ========================================================= */

.qr-preview-card {
    text-align: center;
}

.qr-preview-wrap {
    width: 240px;
    max-width: 100%;
    margin: 18px auto;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.qr-preview {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.qr-public-url {
    margin-top: 12px;
    padding: 9px 10px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.qr-downloads {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
}

/* =========================================================
   ESTADÍSTICAS QR - 30 DÍAS
   ========================================================= */

.chart-card {
    margin-top: 24px;
    padding: 24px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-header h2 {
    margin: 0 0 5px;
    font-size: 18px;
}

.chart-header p {
    margin: 0;
}

.chart-total {
    min-width: 80px;
    text-align: right;
}

.chart-total span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.chart-total strong {
    display: block;
    margin-top: 3px;
    font-size: 26px;
}


/* Gráfico */

.scan-chart {
    width: 100%;
    height: 220px;

    display: grid;
    grid-template-columns:
        repeat(30, minmax(8px, 1fr));

    gap: 4px;
    align-items: end;
}


.chart-column {
    height: 220px;

    display: grid;

    grid-template-rows:
        20px
        170px
        20px;

    align-items: end;

    text-align: center;

    min-width: 0;
}


.chart-number {
    height: 20px;

    font-size: 9px;

    color: var(--muted);

    overflow: hidden;
}


.chart-track {
    height: 170px;

    display: flex;

    justify-content: center;

    align-items: flex-end;

    border-bottom: 1px solid #e5e7eb;
}


.chart-bar {
    width: 70%;

    min-height: 3px;

    background: var(--primary);

    border-radius:
        4px
        4px
        0
        0;
}


.chart-label {
    padding-top: 5px;

    font-size: 9px;

    color: var(--muted);
}

@media (max-width: 700px) {

    .chart-card {
        padding: 18px;
    }

    .chart-header {
        align-items: center;
    }

    .scan-chart {
        overflow-x: auto;

        grid-template-columns:
            repeat(30, 18px);

        justify-content: start;
    }

    .chart-column {
        width: 18px;
    }

}