* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --ui-radius-sm: 6px;
    --ui-radius-md: 10px;
    --ui-radius-lg: 12px;
    --ui-border: #d9e2ec;
    --ui-border-strong: #c6d2df;
    --ui-text: #1f2d3d;
    --ui-muted: #5f6f82;
    --ui-accent: #0056b3;
    --ui-accent-strong: #003da5;
    --ui-accent-soft: #e8f0ff;
    --ui-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --ui-shadow-md: 0 2px 8px rgba(15, 23, 42, 0.08);
    --ui-focus: 0 0 0 3px rgba(0, 86, 179, 0.18);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
    background: linear-gradient(135deg, #003DA5 0%, #0056B3 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--ui-text);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #003DA5 0%, #0056B3 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

main {
    padding: 30px;
}

main section {
    margin-bottom: 18px;
}

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--ui-radius-lg);
    border: 1px solid var(--ui-border);
    box-shadow: var(--ui-shadow-sm);
}

.form-section h2 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--ui-accent) !important;
    border-bottom: 2px solid var(--ui-accent) !important;
    padding-bottom: 10px;
}

.form-section h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--ui-accent) !important;
}

.form-group {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 15px;
    border: 1px solid var(--ui-border-strong);
    border-radius: var(--ui-radius-md);
    font-size: 1em;
    font-family: inherit;
    color: var(--ui-text);
    background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #003DA5;
    box-shadow: var(--ui-focus);
}

.form-group small {
    font-size: 0.9em;
    color: #666;
    margin-top: 3px;
}

.target {
    font-size: 0.9em;
    color: #0056B3;
    font-weight: 600;
    margin-top: 3px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.form-section .form-group {
    margin-bottom: 0;
}

button {
    padding: 12px 24px;
    font-size: 1em;
    border: none;
    border-radius: var(--ui-radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: var(--ui-focus);
}

.btn-primary {
    background: var(--ui-accent) !important;
    color: white !important;
    border: 1px solid var(--ui-accent-strong) !important;
    margin-right: 10px;
}

.btn-primary:hover {
    background: var(--ui-accent-strong) !important;
    box-shadow: 0 5px 15px rgba(0, 86, 179, 0.28);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--ui-accent) !important;
    color: white !important;
    border: 1px solid var(--ui-accent-strong) !important;
}

.btn-secondary:hover {
    background: var(--ui-accent-strong) !important;
}

.top-nav-btn {
    background: linear-gradient(135deg, #0056b3 0%, #003da5 100%) !important;
    border: 1px solid #003da5 !important;
}

.top-nav-btn:hover {
    background: linear-gradient(135deg, #004494 0%, #00327f 100%) !important;
}

.top-nav-btn-manage {
    background: linear-gradient(135deg, #ff8f1c 0%, #f26a21 100%) !important;
    border: 1px solid #c95a1d !important;
}

.top-nav-btn-manage:hover {
    background: linear-gradient(135deg, #f07d0c 0%, #df5a0f 100%) !important;
}

.btn-ai {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(124, 58, 237, 0.2);
    border: none;
}

.btn-ai:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(124, 58, 237, 0.3);
}

#resultsSection {
    padding: 30px;
    background: white;
}

.results-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #003DA5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-header h2 {
    color: #003DA5;
    font-size: 1.8em;
}

.button-group {
    display: flex;
    gap: 10px;
}

.button-group button {
    margin: 0;
}

.coaching-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.coaching-section h3 {
    color: #003DA5;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.coaching-script {
    background: white;
    padding: 20px;
    border-left: 4px solid #003DA5;
    line-height: 1.8;
    color: #333;
    font-size: 1.05em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.resource-list {
    list-style: none;
    padding: 0;
}

.resource-list li {
    margin-bottom: 12px;
}

.resource-link {
    display: inline-block;
    padding: 10px 15px;
    background: #e3f2fd;
    color: #0056B3;
    text-decoration: none;
    border-radius: 5px;
    border-left: 4px solid #0056B3;
    transition: all 0.3s ease;
}

.resource-link:hover {
    background: #bbdefb;
    padding-left: 20px;
}

/* ============================================
   DEBUG PANEL
   ============================================ */

.debug-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.debug-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.debug-card {
    background: #ffffff;
    border: 1px solid #ffe0b2;
    border-radius: var(--ui-radius-md);
    padding: 15px;
}

.debug-card h3 {
    margin-top: 0;
    color: #7a4f00;
    margin-bottom: 10px;
}

.debug-pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #fff8e1;
    border: 1px dashed #ffcc80;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85em;
    color: #4e342e;
    max-height: 320px;
    overflow: auto;
}

.history-employee {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #003DA5;
}

.history-employee h3 {
    color: #003DA5;
    margin-bottom: 15px;
}

.history-item {
    background: white;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: var(--ui-radius-md);
    border: 1px solid #ddd;
}

/* App-wide consistency layer for inline-styled panels/cards */
.form-section > div[style*="background: #fff"],
.form-section > div[style*="background: #ffffff"],
.form-section > div[style*="background: white"] {
    border-radius: var(--ui-radius-md) !important;
    box-shadow: var(--ui-shadow-sm);
}

.form-section input,
.form-section select,
.form-section textarea {
    border-radius: var(--ui-radius-md) !important;
}

.form-section h3,
.form-section h4,
.form-section h5 {
    line-height: 1.3;
}

.form-section p,
.form-section small,
.form-section label {
    color: var(--ui-text) !important;
}

.form-section [style*="border-left"] {
    border-left-color: var(--ui-accent) !important;
}

.form-section [style*="border: 2px solid"],
.form-section [style*="border: 1px solid"] {
    border-color: var(--ui-border-strong) !important;
}

.form-section [style*="background: #e8f5f3"],
.form-section [style*="background: #f3e5f5"],
.form-section [style*="background: #eef5ff"],
.form-section [style*="background: #fff3cd"],
.form-section [style*="background: #ffebee"],
.form-section [style*="background: #e3f2fd"] {
    background: var(--ui-accent-soft) !important;
}

.history-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #666;
    font-size: 0.9em;
}

.history-preview {
    color: #333;
    line-height: 1.6;
    margin-bottom: 10px;
    font-style: italic;
}

.view-full {
    padding: 8px 15px;
    font-size: 0.9em;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .button-group button {
        width: 100%;
    }

    button {
        width: 100%;
    }
}

/* Toast animations */
@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}
