/* CSS Variables */
:root {
    --color-high: #dc2626;
    --color-high-bg: #fef2f2;
    --color-high-border: #fecaca;

    --color-medium: #d97706;
    --color-medium-bg: #fffbeb;
    --color-medium-border: #fde68a;

    --color-low: #16a34a;
    --color-low-bg: #f0fdf4;
    --color-low-border: #bbf7d0;

    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-secondary: #64748b;

    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-light: #64748b;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--color-text);
}

.subtitle {
    color: var(--color-text-light);
    margin: 0 0 12px 0;
    font-size: 16px;
}

.btn-linear-settings {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-text-light);
    transition: all 0.2s;
}

.btn-linear-settings:hover {
    border-color: #5e6ad2;
    color: #5e6ad2;
}

.btn-linear-settings.connected {
    background: #f0f1ff;
    border-color: #5e6ad2;
    color: #5e6ad2;
}

/* Form Section */
.form-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.form-section h2 {
    font-size: 20px;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

/* Fieldset */
fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

legend {
    font-weight: 600;
    padding: 0 8px;
    color: var(--color-text);
}

/* Form Groups */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.helper-text {
    display: block;
    font-size: 12px;
    color: var(--color-text-light);
    margin-top: 4px;
}

.helper-text.past {
    color: var(--color-high);
    font-weight: 500;
}

.helper-text.future {
    color: var(--color-low);
    font-weight: 500;
}

/* Form Row (two columns) */
.form-row {
    display: flex;
    gap: 16px;
}

.form-group.half {
    flex: 1;
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary,
.btn-secondary,
.btn-copy {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-secondary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg);
}

/* Output Section */
.output-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.output-header h2 {
    margin: 0;
    font-size: 20px;
}

.output-actions {
    display: flex;
    gap: 8px;
}

.btn-linear {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: white;
    border: 1px solid #5e6ad2;
    border-radius: var(--radius);
    cursor: pointer;
    color: #5e6ad2;
    transition: all 0.2s;
}

.btn-linear:hover {
    background: #5e6ad2;
    color: white;
}

.btn-linear:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-linear.created {
    background: var(--color-low);
    color: white;
    border-color: var(--color-low);
}

.btn-linear.error {
    background: var(--color-high);
    color: white;
    border-color: var(--color-high);
}

.btn-copy {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 8px 16px;
    font-size: 13px;
}

.btn-copy:hover {
    background: var(--color-border);
}

/* Risk Card */
.risk-card {
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.risk-card.high {
    background: var(--color-high-bg);
    border: 2px solid var(--color-high-border);
}

.risk-card.medium {
    background: var(--color-medium-bg);
    border: 2px solid var(--color-medium-border);
}

.risk-card.low {
    background: var(--color-low-bg);
    border: 2px solid var(--color-low-border);
}

.risk-level {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 12px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 12px;
}

.risk-card.high .risk-level {
    background: var(--color-high);
    color: white;
}

.risk-card.medium .risk-level {
    background: var(--color-medium);
    color: white;
}

.risk-card.low .risk-level {
    background: var(--color-low);
    color: white;
}

.scenario {
    font-size: 13px;
    color: var(--color-text-light);
    margin-bottom: 12px;
}

.key-focus {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
}

/* Priority Actions */
.priority-actions {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
}

.priority-actions h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #92400e;
}

.priority-actions ol {
    margin: 0;
    padding-left: 20px;
}

.priority-actions li {
    margin-bottom: 8px;
    font-weight: 500;
}

.priority-actions li:last-child {
    margin-bottom: 0;
}

.priority-actions li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.action-text {
    flex: 1;
}

/* Info icon with tooltip */
.info-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    flex-shrink: 0;
    margin-left: 4px;
}

.info-icon[data-confidence="high"] {
    color: #16a34a;
}

.info-icon[data-confidence="medium"] {
    color: #d97706;
}

.info-icon[data-confidence="low"] {
    color: #dc2626;
}

.info-icon .tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    width: 280px;
    padding: 10px 12px;
    background: var(--color-text);
    color: white;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.info-icon .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 12px;
    border: 6px solid transparent;
    border-top-color: var(--color-text);
}

.info-icon:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Disclaimer */
.disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
    color: #0369a1;
    line-height: 1.5;
}

.disclaimer svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #0284c7;
}

.disclaimer strong {
    font-weight: 600;
}

/* Staged Checklist */
.staged-checklist {
    display: grid;
    gap: 20px;
}

.stage {
    background: var(--color-bg);
    border-radius: var(--radius);
    padding: 16px;
}

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

.stage-actions {
    display: flex;
    gap: 6px;
}

.stage h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--color-text);
}

.btn-copy-stage {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--color-text-light);
    transition: all 0.2s;
}

.btn-copy-stage:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-copy-stage.copied {
    background: var(--color-low);
    color: white;
    border-color: var(--color-low);
}

.btn-linear-stage {
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    background: white;
    border: 1px solid #5e6ad2;
    border-radius: 4px;
    cursor: pointer;
    color: #5e6ad2;
    transition: all 0.2s;
}

.btn-linear-stage:hover {
    background: #5e6ad2;
    color: white;
}

.btn-linear-stage:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-linear-stage.created {
    background: var(--color-low);
    color: white;
    border-color: var(--color-low);
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
}

.checklist li {
    padding: 8px 0;
    padding-left: 28px;
    position: relative;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.checklist li:last-child {
    border-bottom: none;
}

.checklist li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-radius: 3px;
    background: white;
}

.checklist li.completed::before {
    background: var(--color-low);
    border-color: var(--color-low);
}

.checklist li.completed::after {
    content: '✓';
    position: absolute;
    left: 3px;
    top: 8px;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Task labels */
.task-label {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 6px;
    text-transform: uppercase;
}

.task-label.sales {
    background: #dbeafe;
    color: #1e40af;
}

.task-label.billing {
    background: #f3e8ff;
    color: #7c3aed;
}

.task-label.escalate {
    background: #fee2e2;
    color: #991b1b;
}

.task-label.action {
    background: #fef3c7;
    color: #92400e;
}

/* Special Alerts */
.special-alerts {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 24px;
}

.special-alerts h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #991b1b;
}

.special-alerts ul {
    margin: 0;
    padding-left: 20px;
}

.special-alerts li {
    margin-bottom: 8px;
    color: #7f1d1d;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: #dc2626;
}

.toast a {
    color: #93c5fd;
    text-decoration: underline;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-light);
    font-size: 13px;
}

/* Print Styles */
@media print {
    .form-section,
    .form-actions,
    .btn-copy,
    footer {
        display: none;
    }

    .output-section {
        box-shadow: none;
        padding: 0;
    }
}

/* Animation for output appearance */
.output-section {
    animation: fadeIn 0.3s ease;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.active,
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.active .modal,
.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

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

.modal-body {
    padding: 20px;
}

.modal-description {
    font-size: 13px;
    color: var(--color-text-light);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

.modal-description a {
    color: #5e6ad2;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

.linear-status {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 6px;
    margin-top: 12px;
    display: none;
}

.linear-status.success {
    display: block;
    background: #dcfce7;
    color: #166534;
}

.linear-status.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

.linear-status.loading {
    display: block;
    background: #f0f9ff;
    color: #0369a1;
}
