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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --light-bg: #ecf0f1;
    --white: #ffffff;
    --dark-text: #2c3e50;
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--dark-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    background: var(--white);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.2);
}

.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
    color: var(--white);
    padding: 40px 20px;
    text-align: center;
    border-bottom: 4px solid var(--secondary-color);
    position: relative;
}

.header-content h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.header-content p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    flex: 1;
    padding: 40px 20px;
}

.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--light-bg);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 15px 30px;
    font-size: 1em;
    cursor: pointer;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    font-weight: 600;
}

.tab-btn:hover,
.tab-btn.active {
    color: var(--secondary-color);
}

.tab-btn.active {
    border-bottom-color: var(--secondary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.form-container,
.history-container {
    background: var(--white);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-container {
    border-left: 4px solid var(--secondary-color);
}

.form-container h2,
.history-container h2 {
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 1.8em;
}

.form-group {
    margin-bottom: 20px;
}

.form-row,
.history-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-group label,
.filter-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-group input,
.form-group textarea,
.filter-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 1em;
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-note {
    margin-bottom: 20px;
    color: #5f6d7a;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #2980b9 100%);
    color: var(--white);
    width: 100%;
    justify-content: center;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-light:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--success-color);
    color: var(--white);
}

.btn-light {
    background: #eef4fb;
    color: var(--primary-color);
}

.header-logout {
    position: absolute;
    top: 20px;
    right: 20px;
}

.alert {
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 20px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border-left: 4px solid var(--success-color);
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--danger-color);
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(52, 152, 219, 0.2);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.history-filters {
    margin-bottom: 24px;
    padding: 20px;
    background: #f8fbff;
    border: 1px solid #dbe7f3;
    border-radius: var(--border-radius);
}

.filter-actions {
    display: flex;
    align-items: end;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #2980b9 100%);
    color: var(--white);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
}

.stat-card-secondary {
    background: linear-gradient(135deg, #2c3e50 0%, #415b76 100%);
}

.stat-number {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 10px;
}

.stat-label {
    display: block;
    opacity: 0.9;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
    color: var(--white);
}

.history-table th,
.history-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.history-table tbody tr:hover {
    background-color: #f5f9fc;
}

.action-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.92em;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
}

.action-link {
    background: #eef6ff;
    color: #1f6fb2;
}

.action-button {
    background: #eef4fb;
    color: var(--primary-color);
}

.action-button.danger {
    background: #fff0f0;
    color: var(--danger-color);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 1.1em;
}

.footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
    color: var(--white);
    padding: 20px;
    text-align: center;
    margin-top: auto;
}

#apiStatus {
    margin-left: 10px;
    font-weight: 600;
}

.validation-body {
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(135deg, #0e1220 0%, #253758 100%);
}

.validation-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 48px 20px;
}

.validation-hero {
    color: #ffffff;
    margin-bottom: 24px;
}

.validation-kicker {
    display: inline-block;
    margin-bottom: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.validation-hero h1 {
    font-size: 2.4rem;
    margin-bottom: 12px;
}

.validation-hero p {
    max-width: 620px;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.6;
}

.validation-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 28px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.login-card {
    max-width: 480px;
}

.validation-form label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.validation-form input {
    width: 100%;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 2px solid #d4deea;
    border-radius: 10px;
    font-size: 1rem;
}

.validation-form input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.14);
}

.validation-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.validation-row input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #d4deea;
    border-radius: 10px;
    font-size: 1rem;
}

.validation-row input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.14);
}

.validation-result {
    margin-top: 24px;
    padding: 22px;
    border: 1px solid #d9e6d3;
    background: #f7fcf5;
    border-radius: 14px;
}

.validation-badge {
    display: inline-flex;
    margin-bottom: 18px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #dff3dc;
    color: #25693a;
    font-weight: 700;
}

.validation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.validation-label {
    display: block;
    margin-bottom: 6px;
    color: #5f6d7a;
    font-size: 0.9rem;
}

.validation-code-block {
    grid-column: 1 / -1;
}

.validation-actions {
    margin-top: 22px;
}

.login-submit {
    width: 100%;
    justify-content: center;
}

@media (max-width: 768px) {
    .header-content h1 {
        font-size: 1.8em;
    }

    .form-row,
    .history-filters,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .tabs-nav {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 12px 20px;
        font-size: 0.9em;
    }

    .main-content {
        padding: 20px;
    }

    .form-container,
    .history-container {
        padding: 20px;
    }

    .history-table {
        display: block;
        overflow-x: auto;
    }

    .validation-row,
    .validation-grid {
        grid-template-columns: 1fr;
    }

    .validation-hero h1 {
        font-size: 1.9rem;
    }

    .header-logout {
        position: static;
        margin-top: 18px;
    }
}
