/* Ian Risk Dashboard — Dark theme, mobile-first */

:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1e1e36;
    --bg-detail: #141428;
    --bg-input: #12122a;
    --border: #2a2a4a;
    --text: #e0e0e0;
    --text-muted: #888;
    --text-dim: #666;
    --accent: #4a6cf7;
    --accent-hover: #5b7df8;
    --danger: #e94560;
    --danger-hover: #f05670;
    --success: #2ecc71;
    --warning: #f39c12;
    --sev-critical: #e94560;
    --sev-high: #f39c12;
    --sev-medium: #3498db;
    --sev-low: #2ecc71;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Top bar */
.top-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.top-bar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
}
.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    text-decoration: none;
}
.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 6px;
}
.nav-link.active {
    color: var(--text);
    background: rgba(74, 108, 247, 0.15);
}

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

/* Exposure bar */
.exposure-bar {
    background: linear-gradient(135deg, #1a1a3e, #0f0f2a);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
}
.exposure-main {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}
.exposure-label {
    font-size: 14px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.exposure-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--danger);
}
.exposure-meta {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-select, .filter-toggle {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    min-height: 44px;
}
.filter-select:focus { outline: 2px solid var(--accent); }
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
.filter-toggle input { accent-color: var(--accent); }

/* Buttons */
.btn {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s;
}
.btn:hover { background: var(--bg-card-hover); }
.btn-sm { padding: 8px 12px; font-size: 16px; }
.btn-save {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-save:hover { background: var(--accent-hover); }
.btn-resolve {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}
.btn-resolve:hover { background: rgba(233, 69, 96, 0.1); }

/* Risk cards */
.risks-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.risk-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.risk-card:hover { border-color: var(--accent); }
.risk-card.expanded { border-color: var(--accent); }

.risk-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    gap: 12px;
    min-height: 56px;
}

.risk-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
}

/* Severity badges */
.sev-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.sev-critical { background: var(--sev-critical); color: #fff; }
.sev-high { background: var(--sev-high); color: #000; }
.sev-medium { background: var(--sev-medium); color: #fff; }
.sev-low { background: var(--sev-low); color: #000; }

.risk-metrics {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
.metric {
    font-size: 13px;
    white-space: nowrap;
}
.metric.ev {
    font-weight: 600;
    color: var(--warning);
    min-width: 80px;
    text-align: right;
}
.metric.ev.muted { color: var(--text-dim); font-weight: 400; }
.metric.owner { color: var(--text-muted); min-width: 80px; }
.metric.overdue {
    color: var(--danger);
    font-weight: 600;
}
.metric.score {
    color: var(--text-dim);
    font-size: 12px;
    min-width: 30px;
    text-align: right;
}

/* Expand panel */
.risk-detail {
    border-top: 1px solid var(--border);
    padding: 20px;
    background: var(--bg-detail);
}
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 16px;
}
.detail-section h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.5);
}
.dl { color: var(--text-muted); }
.dv { color: var(--text); text-align: right; max-width: 60%; }
.dv.overdue { color: var(--danger); font-weight: 600; }

.detail-notes {
    margin-bottom: 16px;
    padding: 12px;
    background: rgba(15, 15, 26, 0.5);
    border-radius: 8px;
}

/* Edit controls */
.edit-controls {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.edit-controls h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.edit-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.edit-field, .edit-input {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    flex: 1;
    min-width: 140px;
    min-height: 44px;
}
.edit-field:focus, .edit-input:focus, .edit-note:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}
.edit-note {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    width: 100%;
    min-height: 60px;
    resize: vertical;
    font-family: inherit;
}
/* Inline-editable fields (replace static display values) */
.inline-edit {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
    min-height: 32px;
    max-width: 200px;
    cursor: pointer;
}
.inline-edit:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}
.inline-text {
    max-width: 100%;
    width: 100%;
    flex: 1;
}
.inline-dollar, .inline-pct {
    max-width: 140px;
    font-variant-numeric: tabular-nums;
}
.ev-hint {
    font-size: 10px;
    color: var(--text-dim);
    font-style: italic;
}
.edit-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 16px;
}
.save-status {
    font-size: 12px;
    color: var(--text-dim);
}

/* Create Task */
.task-create {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-bottom: 16px;
}
.task-create h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.task-title {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    width: 100%;
    min-height: 44px;
    font-family: inherit;
}
.task-title:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.task-owner, .task-due {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    min-height: 44px;
    flex: 1;
}
.btn-task {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-task:hover { background: #27ae60; }
.btn-task:disabled { opacity: 0.6; cursor: default; }
.task-link {
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
}
.task-link:hover { text-decoration: underline; }
.btn-suggest {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}
.btn-suggest:hover { background: rgba(74, 108, 247, 0.1); }
.btn-created {
    background: var(--text-dim) !important;
    border-color: var(--text-dim) !important;
    cursor: default;
}
.suggestion-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}
.suggestion-card.sug-expanded { border-color: var(--accent); }
.suggestion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
}
.suggestion-header:hover { background: rgba(74, 108, 247, 0.05); border-radius: 8px; }
.suggestion-info { flex: 1; min-width: 0; }
.suggestion-title {
    display: block;
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.suggestion-meta {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
}
.suggestion-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.btn-edit-toggle {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-muted);
    padding: 6px 10px;
    font-size: 12px;
    min-height: 32px;
}
.btn-edit-toggle:hover { border-color: var(--accent); color: var(--accent); }
.suggestion-edit {
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border);
}
.sug-edit-row { margin-bottom: 8px; }
.sug-edit-row-inline {
    display: flex;
    gap: 10px;
}
.sug-edit-col { flex: 1; }
.sug-label {
    display: block;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.sug-input {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    width: 100%;
    min-height: 36px;
    font-family: inherit;
}
.sug-input:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}
.no-suggestions {
    font-size: 13px;
    color: var(--text-dim);
    padding: 8px 0;
}
.manual-task-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Review History */
.review-history {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-bottom: 16px;
}
.review-history h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.review-entry {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    align-items: baseline;
}
.review-date {
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 120px;
    flex-shrink: 0;
    font-size: 12px;
}
.review-note {
    color: var(--text);
    line-height: 1.4;
    flex: 1;
}

/* Quick Update */
.quick-update {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-bottom: 16px;
}
.quick-update h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 10px;
}
.quick-update-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.quick-update-input {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
}
.quick-update-input:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

/* Ian Chat */
.risk-chat {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}
.risk-chat h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 10px;
}
.chat-messages {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.chat-msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.chat-user {
    background: var(--accent);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.chat-ian {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.chat-ian.thinking {
    color: var(--text-dim);
    font-style: italic;
}
.chat-ian.chat-error {
    border-color: var(--danger);
    color: var(--danger);
}
.chat-input-row {
    display: flex;
    gap: 8px;
}
.chat-input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-family: inherit;
    min-height: 44px;
}
.chat-input:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}
.btn-chat {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    padding: 10px 20px;
    min-height: 44px;
}
.btn-chat:hover { background: var(--accent-hover); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
    font-size: 16px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: var(--danger); }

/* ════════════════════════════════════════════════════════════════════════════ */
/* Letters to Kids                                                            */
/* ════════════════════════════════════════════════════════════════════════════ */

.letters-header {
    margin-bottom: 20px;
}
.letters-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.template-hint {
    font-size: 13px;
    color: var(--text-muted);
}
.template-editor {
    min-height: 700px;
    font-size: 14px;
    line-height: 1.6;
}
.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}
.section-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Children cards */
.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.child-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: border-color 0.15s;
}
.child-card:hover { border-color: var(--accent); }
.child-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.child-age {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}
.child-pending {
    font-size: 13px;
    color: var(--text-dim);
    font-style: italic;
}
.btn-generate {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-generate:hover { background: var(--accent-hover); }
.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Generation status */
.gen-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1a1a3e, #0f0f2a);
    border: 1px solid var(--accent);
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text);
}
.gen-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Generated letter preview */
.gen-preview {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
}
.gen-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.gen-preview-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.gen-preview-body {
    padding: 20px;
    font-size: 14px;
    line-height: 1.7;
    max-height: 600px;
    overflow-y: auto;
}
.gen-preview-body h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin: 20px 0 8px;
}
.gen-preview-body h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin: 16px 0 8px;
}
.gen-preview-body p {
    margin-bottom: 12px;
}
.gen-preview-body mark.placeholder {
    background: rgba(243, 156, 18, 0.2);
    color: var(--warning);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
}

/* Letters archive */
.letters-archive {
    margin-top: 8px;
}
.archive-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 12px;
}
.letters-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.letter-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: border-color 0.15s;
}
.letter-row:hover { border-color: var(--accent); }
.letter-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    gap: 12px;
    min-height: 56px;
}
.letter-title {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}
.letter-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.letter-child {
    font-size: 13px;
    color: var(--text-muted);
}
.letter-date {
    font-size: 13px;
    color: var(--text-dim);
}
.letter-status {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 500;
}
.status-draft {
    background: rgba(243, 156, 18, 0.15);
    color: var(--warning);
}
.status-final {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}
.status-archived {
    background: rgba(136, 136, 136, 0.15);
    color: var(--text-muted);
}

/* Letter view page */
.letter-view {
    max-width: 800px;
    margin: 0 auto;
}
.letter-view-header {
    margin-bottom: 24px;
}
.back-link {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 12px;
}
.back-link:hover { text-decoration: underline; }
.letter-view-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}
.letter-view-title {
    font-size: 22px;
    font-weight: 700;
}
.letter-view-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}
.letter-view-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
/* Letter editor (replaces static body) */
.letter-editor {
    width: 100%;
    min-height: 600px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.8;
    resize: vertical;
    white-space: pre-wrap;
    tab-size: 4;
}
.letter-editor:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

/* Save indicator */
.save-indicator {
    font-size: 12px;
    padding: 4px 8px;
}
.save-indicator.unsaved { color: var(--warning); }
.save-indicator.saving { color: var(--text-muted); }
.save-indicator.saved { color: var(--success); }

/* Delete button */
.btn-delete {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    min-height: 44px;
}
.btn-delete:hover { background: rgba(233, 69, 96, 0.1); }

/* Delete confirmation modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
}
.modal-box h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.modal-box p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ════════════════════════════════════════════════════════════════════════════ */
/* Home Page                                                                  */
/* ════════════════════════════════════════════════════════════════════════════ */

/* Home page — two-column layout */
.home-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 16px;
    align-items: start;
}

/* Left: Ian Chat */
.home-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ian-chat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 400px;
}
.ian-chat .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: none;
}
.ian-chat .chat-input-row {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}
.ian-chat .chat-input {
    flex: 1;
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    line-height: 1.4;
}
.ian-chat .chat-input:focus {
    outline: 2px solid var(--accent);
    border-color: var(--accent);
}

/* Right: Sidebar */
.home-sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 64px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}
.sidebar-nav {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}
.sidebar-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    transition: border-color 0.15s;
}
.sidebar-link:hover { border-color: var(--accent); }
.sidebar-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(74, 108, 247, 0.15);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.command-group {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}
.command-group h4 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.command-group .cmd-btn {
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
    padding: 7px 10px;
    font-size: 12px;
    min-height: 32px;
    border-radius: 6px;
}
.command-group .cmd-btn:last-child { margin-bottom: 0; }

/* Nav link spacing */
.nav-link + .nav-link { margin-left: 4px; }

/* Command Center */
.command-center {
    margin-top: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}
.command-center-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 16px;
    letter-spacing: 0.5px;
}
.command-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}
.command-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 8px;
}
.command-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.cmd-btn {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 36px;
}
.cmd-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    color: #fff;
}
.cmd-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Command output */
.command-output {
    display: none;
    margin-bottom: 20px;
    background: var(--bg-detail);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    max-height: 500px;
    overflow-y: auto;
}
.cmd-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 8px;
}
.cmd-result {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    margin: 0;
}
.cmd-thinking {
    font-size: 13px;
    color: var(--text-dim);
    font-style: italic;
}
.cmd-error {
    font-size: 13px;
    color: var(--danger);
}

/* ═══ Wizard Modals ═══ */
.wizard-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
}
.wizard-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
    padding: 28px 32px;
    position: relative;
    animation: wizardIn 0.2s ease-out;
}
@keyframes wizardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.wizard-close {
    position: absolute; top: 12px; right: 16px;
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; line-height: 1;
}
.wizard-close:hover { color: var(--text); }
.wizard-header { text-align: center; margin-bottom: 20px; }
.wizard-icon { font-size: 32px; display: block; margin-bottom: 4px; }
.wizard-title { font-size: 20px; font-weight: 700; color: var(--text); }
.wizard-risk-name { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.wizard-progress {
    height: 4px; background: var(--border); border-radius: 2px;
    margin-bottom: 24px; overflow: hidden;
}
.wizard-progress-bar {
    height: 100%; background: var(--accent); border-radius: 2px;
    transition: width 0.3s ease;
}
.wizard-step { animation: fadeStep 0.25s ease; }
@keyframes fadeStep {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}
.wizard-ian {
    background: rgba(74, 108, 247, 0.1);
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    font-size: 14px; line-height: 1.6;
    margin-bottom: 16px;
    color: var(--text);
}
.wizard-ian strong { color: var(--accent); }
.wizard-file-note {
    background: rgba(243, 156, 18, 0.08);
    border-left: 3px solid var(--warning);
    padding: 10px 14px;
    border-radius: 0 8px 8px 0;
    font-size: 13px; line-height: 1.5;
    margin-bottom: 16px;
    color: var(--text-muted);
}
.wizard-input {
    width: 100%;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px;
    padding: 10px 14px; font-size: 14px;
    font-family: inherit; resize: vertical;
}
.wizard-input:focus { border-color: var(--accent); outline: none; }
.wizard-field-row {
    margin-bottom: 14px;
}
.wizard-label {
    display: block; font-size: 13px; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 500;
}
.wizard-nav {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 20px; gap: 12px;
}
/* Bracket buttons */
.wizard-brackets {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; margin-bottom: 16px;
}
.bracket-btn {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px;
    padding: 10px 8px; font-size: 13px; cursor: pointer;
    transition: all 0.15s;
}
.bracket-btn:hover { border-color: var(--accent); background: rgba(74, 108, 247, 0.08); }
.bracket-btn.selected { border-color: var(--accent); background: rgba(74, 108, 247, 0.15); color: var(--accent); font-weight: 600; }
/* Option buttons */
.wizard-options {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.opt-btn {
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px;
    padding: 8px 18px; font-size: 13px; cursor: pointer;
    transition: all 0.15s;
}
.opt-btn:hover { border-color: var(--accent); }
.opt-btn.selected { border-color: var(--accent); background: rgba(74, 108, 247, 0.15); color: var(--accent); font-weight: 600; }
.opt-btn.opt-wide { flex: 1; min-width: 180px; text-align: center; padding: 12px 18px; }
.wizard-question { margin-bottom: 16px; }
/* Gut feel slider */
.wizard-gut-row { display: flex; align-items: center; gap: 12px; }
.wizard-slider {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 6px; background: var(--border); border-radius: 3px; outline: none;
}
.wizard-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 20px; height: 20px;
    background: var(--accent); border-radius: 50%; cursor: pointer;
}
.wizard-gut-val { font-size: 16px; font-weight: 700; color: var(--accent); min-width: 42px; }
.wizard-gut-skip { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
/* Summary / EV preview */
.wizard-summary {
    background: var(--bg-detail); border: 1px solid var(--border);
    border-radius: 8px; padding: 14px 16px;
    margin-bottom: 16px; font-size: 14px; line-height: 1.6;
}
.wizard-ev-preview {
    font-size: 18px; font-weight: 700;
    color: var(--warning); text-align: center;
    padding: 10px 0; margin-bottom: 8px;
}
/* Wizard button style */
.btn-wizard {
    background: rgba(74, 108, 247, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.btn-wizard:hover {
    background: rgba(74, 108, 247, 0.2);
}
/* Wizard chat area */
.wizard-chat-area {
    max-height: 340px; overflow-y: auto;
    margin-bottom: 14px;
    display: flex; flex-direction: column; gap: 10px;
    padding: 4px 0;
}
.wiz-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px; line-height: 1.55;
    animation: fadeStep 0.2s ease;
}
.wiz-msg.ian {
    align-self: flex-start;
    background: rgba(74, 108, 247, 0.1);
    border: 1px solid rgba(74, 108, 247, 0.2);
}
.wiz-msg.user {
    align-self: flex-end;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
}
.wiz-msg.research {
    align-self: flex-start;
    background: rgba(46, 204, 113, 0.08);
    border: 1px solid rgba(46, 204, 113, 0.2);
    font-size: 13px;
    color: var(--text-muted);
}
.wiz-msg.research::before {
    content: '🔎 ';
}
.wiz-msg.thinking {
    align-self: flex-start;
    background: rgba(74, 108, 247, 0.05);
    border: 1px solid rgba(74, 108, 247, 0.1);
    color: var(--text-muted);
    font-style: italic;
}
.wizard-chat-input-row {
    display: flex; gap: 8px;
    margin-bottom: 14px;
}
.wizard-chat-input {
    flex: 1;
    background: var(--bg-input); border: 1px solid var(--border);
    color: var(--text); border-radius: 8px;
    padding: 10px 14px; font-size: 14px;
    font-family: inherit;
}
.wizard-chat-input:focus { border-color: var(--accent); outline: none; }
/* Wizard final assessment panel */
.wizard-final {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
}
.wizard-data-points {
    margin-bottom: 14px;
}
.wizard-data-point {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 13px; color: var(--text-muted);
    padding: 4px 0;
}
.wizard-data-point::before {
    content: '•'; color: var(--accent); font-weight: bold;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .home-layout {
        grid-template-columns: 1fr;
    }
    .home-sidebar {
        position: static;
        max-height: none;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    .command-group {
        flex: 1;
        min-width: 140px;
    }
    .sidebar-nav { width: 100%; }
    .risk-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px 14px;
    }
    .risk-metrics {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    .metric.ev { min-width: auto; }
    .metric.owner { min-width: auto; }
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .exposure-value { font-size: 24px; }
    .filter-bar { gap: 6px; }
    .filter-select { min-width: 0; flex: 1; font-size: 12px; padding: 8px; }
    .edit-row { flex-direction: column; }
    .edit-field, .edit-input { min-width: 100%; }
    .sug-edit-row-inline { flex-direction: column; gap: 8px; }
    .suggestion-header { flex-wrap: wrap; }
    /* Letters mobile */
    .children-grid { grid-template-columns: 1fr; }
    .child-card { flex-direction: column; align-items: flex-start; }
    .letter-link { flex-direction: column; align-items: flex-start; gap: 6px; }
    .letter-meta { flex-wrap: wrap; }
    .letter-view-title-row { flex-direction: column; }
    .letter-view-actions { width: 100%; }
    .wizard-modal { padding: 20px 18px; }
    .wizard-brackets { grid-template-columns: repeat(2, 1fr); }
    .opt-btn.opt-wide { min-width: 140px; }
}
