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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--color-bg);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--color-text);
    line-height: 1.6;
}

:root {
    --gradient-start: #4F46E5;
    --gradient-end: #7C3AED;
    --gradient: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    --gradient-hover: linear-gradient(135deg, #4338CA, #6D28D9);
    --color-primary: #4F46E5;
    --color-primary-dark: #4338CA;
    --color-secondary: #7C3AED;
    --color-text: #1E293B;
    --color-text-light: #64748B;
    --color-bg: #FFFFFF;
    --color-bg-light: #F8FAFC;
    --color-border: #E2E8F0;
    --color-success: #10B981;
    --color-error: #EF4444;
    --color-warning: #F59E0B;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 48px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    width: 100%;
    max-width: 420px;
}

.login-box h1 {
    text-align: center;
    color: var(--color-text);
    margin-bottom: 32px;
    font-size: 2em;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-transform: uppercase;
    position: relative;
}

.login-box h1::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--gradient);
    border-radius: 2px;
}

.login-form label {
    display: block;
    margin-bottom: 10px;
    margin-top: 20px;
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-form label:first-child {
    margin-top: 0;
}

.login-form input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 20px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.login-form input::placeholder {
    color: var(--color-text-light);
    opacity: 0.7;
}

#login-btn {
    width: 100%;
    padding: 16px 32px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

#login-btn:hover:not(:disabled) {
    background: var(--gradient-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#login-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

#login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

.header h1 {
    margin-bottom: 0;
}

.logout-btn {
    padding: 10px 20px;
    background: var(--color-bg-light);
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.logout-btn:hover {
    background: var(--color-border);
    color: var(--color-text-light);
    transform: translateY(-1px);
}

.logout-btn:active {
    transform: translateY(0);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
}

h1 {
    text-align: center;
    color: var(--color-text);
    margin-bottom: 40px;
    font-size: 2.5em;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-transform: uppercase;
    position: relative;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--gradient);
    border-radius: 2px;
}

.query-form {
    margin-bottom: 40px;
    padding: 32px;
    background: var(--color-bg-light);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.query-form label {
    display: block;
    margin-bottom: 10px;
    margin-top: 24px;
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.query-form label:first-child {
    margin-top: 0;
}

.device-type-selector {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
    padding: 14px 16px;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    height: 63px;
    min-height: 63px;
}

.device-type-selector label {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-light);
    font-size: 15px;
    text-transform: none;
    letter-spacing: normal;
    transition: color 0.2s ease;
}

.device-type-selector input[type="radio"],
.device-type-selector input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--color-primary);
}

.device-type-selector label:hover {
    color: var(--color-primary);
}

.form-row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.form-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-column label {
    margin-top: 0;
    margin-bottom: 10px;
}

.query-form input,
.query-form textarea {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 15px;
    transition: all 0.2s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 24px;
}

.query-form textarea {
    resize: vertical;
    min-height: 180px;
    line-height: 1.6;
}

.form-column:first-child input {
    height: 63px;
}

.query-form input:focus,
.query-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.query-form input::placeholder,
.query-form textarea::placeholder {
    color: var(--color-text-light);
    opacity: 0.7;
}

#query-btn {
    width: 100%;
    padding: 16px 32px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#query-btn:hover:not(:disabled) {
    background: var(--gradient-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

#query-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

#query-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
    padding: 18px 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border-left: 4px solid var(--color-error);
    font-weight: 500;
}

.queue-status {
    background: rgba(79, 70, 229, 0.1);
    padding: 20px 24px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border-left: 4px solid var(--color-primary);
    color: var(--color-primary-dark);
    font-weight: 500;
    font-size: 15px;
    line-height: 1.8;
}

.queue-status span {
    font-weight: 700;
    color: var(--color-primary);
}

#results {
    margin-top: 40px;
}

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

.filter-section {
    background: var(--color-bg-light);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-item label {
    font-weight: 600;
    color: var(--color-text-light);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-item input,
.filter-item select {
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-bg);
    color: var(--color-text);
    transition: all 0.2s ease;
}

.filter-item input:focus,
.filter-item select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-item input::placeholder {
    color: var(--color-text-light);
    opacity: 0.6;
}

#results h2 {
    color: var(--color-text);
    font-size: 1.8em;
    font-weight: 700;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

#results h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 28px;
    background: var(--gradient);
    border-radius: 2px;
}

.export-btn {
    padding: 10px 20px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.export-btn:hover {
    background: var(--gradient-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.export-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.results-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.clear-btn {
    padding: 10px 20px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-error);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -2px rgba(239, 68, 68, 0.3);
}

.clear-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.results-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.results-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 24px;
    border-radius: 8px;
    overflow: hidden;
}

.results-table th,
.results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    vertical-align: middle;
    height: 48px;
}

.results-table th {
    background: var(--color-bg-light);
    color: var(--color-text);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table tbody tr {
    transition: all 0.15s ease;
}

.results-table tbody tr:nth-child(even) {
    background-color: rgba(248, 250, 252, 0.5);
}

.results-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.08);
}


.results-table tbody tr:last-child td {
    border-bottom: none;
}

.status-success {
    color: var(--color-success);
    font-weight: 600;
    font-size: 13px;
}

.status-failed {
    color: var(--color-error);
    font-weight: 600;
    font-size: 13px;
}

.status-pending {
    color: var(--color-warning);
    font-weight: 600;
    font-size: 13px;
}

.title-cell {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
    font-weight: 500;
}

.url-cell {
    max-width: 450px;
    word-break: break-all;
}

.url-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.15s ease;
}

.url-link:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

.modal {
    display: block;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--color-bg);
    margin: 4% auto;
    padding: 32px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close {
    color: var(--color-text-light);
    float: right;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
}

.close:hover,
.close:focus {
    color: var(--color-text);
}

.modal h2 {
    color: var(--color-text);
    margin-bottom: 24px;
    font-size: 2em;
    font-weight: 700;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
}

.modal h3 {
    color: var(--color-text);
    margin-top: 28px;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: 600;
}

.modal p {
    margin: 12px 0;
    color: var(--color-text-light);
    font-size: 15px;
    line-height: 1.6;
}

.modal strong {
    color: var(--color-text);
    font-weight: 600;
}

.ranking-details-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.ranking-details-table th,
.ranking-details-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.ranking-details-table th {
    background: var(--color-bg-light);
    color: var(--color-text);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ranking-details-table tbody tr:nth-child(even) {
    background-color: rgba(248, 250, 252, 0.5);
}

.ranking-details-table tbody tr:hover {
    background: rgba(79, 70, 229, 0.08);
}

.ranking-details-table tbody tr:last-child td {
    border-bottom: none;
}

.ranking-details-table a {
    color: var(--color-primary);
    text-decoration: none;
    word-break: break-all;
    font-weight: 500;
    transition: all 0.15s ease;
}

.ranking-details-table a:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

.view-details-btn {
    padding: 8px 16px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.view-details-btn:hover {
    background: var(--gradient-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.view-details-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
    body {
        padding: 20px 10px;
    }

    .container {
        padding: 24px;
    }

    h1 {
        font-size: 1.8em;
        margin-bottom: 24px;
    }

    .query-form {
        padding: 20px;
    }

    .form-row {
        flex-direction: column;
        gap: 16px;
    }

    .form-column {
        width: 100%;
    }

    .device-type-selector {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
        align-items: flex-start;
        height: auto;
        min-height: 80px;
    }

    .filter-section {
        padding: 16px;
    }

    .filter-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .results-table {
        font-size: 14px;
    }

    .results-table th,
    .results-table td {
        padding: 12px 10px;
    }

    .title-cell {
        max-width: 200px;
    }

    .url-cell {
        max-width: 250px;
    }

    .modal-content {
        margin: 10% auto;
        padding: 24px;
        width: 95%;
    }
}
