*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f4f8;
    color: #1a202c;
    line-height: 1.5;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 28px;
}

h1 {
    margin: 0 0 8px;
    font-size: 1.75rem;
    color: #2d3748;
}

.subtitle {
    margin: 0 0 24px;
    color: #718096;
    font-size: 0.95rem;
}

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

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #4a5568;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    background: #3182ce;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn:hover {
    background: #2b6cb0;
}

.btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.btn-block {
    width: 100%;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert-error {
    background: #fed7d7;
    color: #9b2c2c;
    border: 1px solid #feb2b2;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert-info {
    background: #bee3f8;
    color: #2a4365;
    border: 1px solid #90cdf4;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.user-info {
    font-size: 0.95rem;
    color: #4a5568;
}

.user-info strong {
    color: #2d3748;
}

.logout-link {
    color: #e53e3e;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.logout-link:hover {
    text-decoration: underline;
}

.rule-slot {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background: #fafbfc;
}

.rule-content.disabled {
    opacity: 0.55;
    pointer-events: none;
}

.rule-slot h3 {
    margin: 0 0 16px;
    font-size: 1.1rem;
    color: #2d3748;
}

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

.rule-header h3 {
    margin: 0;
}

.enable-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: #4a5568;
}

.enable-toggle input {
    width: auto;
}

.rule-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.dynamic-field {
    margin-top: 8px;
}

.dynamic-field.hidden {
    display: none;
}

.hint {
    font-size: 0.8rem;
    color: #a0aec0;
    margin-top: 4px;
}

.loading-overlay {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #ebf8ff;
    border: 1px solid #90cdf4;
    border-radius: 6px;
    margin-top: 20px;
    color: #2c5282;
    font-weight: 500;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #bee3f8;
    border-top-color: #3182ce;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#results {
    margin-top: 20px;
}

@media (max-width: 640px) {
    .rule-row {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px 16px;
    }
}
