/* clawnanny.css — ClawNanny dashboard styles */

/* -------------------------------------------------------------------------
   Connection status badge
   ------------------------------------------------------------------------- */

/* Root variable fallback — overwritten by JS in Body_onLoad */
:root { --cn-header-h: 90px; }

.cn-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #ddd;
    background: #f5f5f5;
    transition: background 0.3s, border-color 0.3s;
}

.cn-badge::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #aaa;
    flex-shrink: 0;
    transition: background 0.3s;
}

.cn-badge-connected {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}
.cn-badge-connected::before { background: #4caf50; }

.cn-badge-disconnected {
    background: #ffebee;
    border-color: #ef9a9a;
    color: #c62828;
}
.cn-badge-disconnected::before { background: #e53935; }

.cn-badge-connecting {
    background: #fff8e1;
    border-color: #ffd54f;
    color: #e65100;
}
.cn-badge-connecting::before {
    background: #ffc107;
    animation: cn-pulse 1s infinite;
}

@keyframes cn-pulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.3; }
    100% { opacity: 1; }
}

/* -------------------------------------------------------------------------
   Tab navigation
   ------------------------------------------------------------------------- */

.cn-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    border-bottom: 2px solid #ddd;
    margin-bottom: 20px;
    position: sticky;
    top: var(--cn-header-h);
    z-index: 100;
    background: #e8eef5;
    /* Extend the tabs background slightly around the buttons. */
    padding-bottom: 3px;
    margin-left: -4px;
    padding-left: 4px;
}

.cn-tab-btn {
    padding: 8px 16px;
    font-size: 12pt;
    font-weight: 600;
    color: #555;
    background: #f0f0f0;
    border: 1px solid #ccc;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    position: relative;
    top: 2px;
}

.cn-tab-btn:hover {
    background: #e0e8f8;
    color: #1565c0;
}

.cn-tab-btn.cn-tab-active {
    background: white;
    color: #1565c0;
    border-color: #ddd;
    border-bottom-color: white;
    z-index: 1;
}

/* -------------------------------------------------------------------------
   Tab panels
   ------------------------------------------------------------------------- */

.cn-tab-panel {
    display: none;
}

.cn-tab-panel.cn-tab-panel-active {
    display: block;
}

/* -------------------------------------------------------------------------
   Placeholder panels (future phases)
   ------------------------------------------------------------------------- */

.cn-placeholder {
    padding: 40px;
    text-align: center;
    color: #999;
    font-size: 14px;
    font-style: italic;
    border: 2px dashed #ddd;
    border-radius: 6px;
    background: #fafafa;
}

/* -------------------------------------------------------------------------
   Connection test panel (Phase 1)
   ------------------------------------------------------------------------- */

/* Chat input — black border on focus */
#cn-chat-input:focus {
border: 2px solid #000 !important;
outline: none !important;
}

.cn-event-log {
    width: 100%;
    height: 300px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.5;
    background: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
    resize: vertical;
    white-space: pre-wrap;
    word-break: break-all;
}

.cn-test-btn {
    background-color: #2196F3;
    color: white;
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11pt;
    font-weight: 600;
    margin-right: 8px;
    transition: background-color 0.2s;
}

.cn-test-btn:hover {
    background-color: #1565c0;
}

.cn-test-btn:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

.cn-section-label {
    font-weight: bold;
    font-size: 13pt;
    color: #333;
    margin: 0 0 8px 0;
}

/* -------------------------------------------------------------------------
   Chat panel (Phase 2)
   ------------------------------------------------------------------------- */

.cn-chat-session-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.cn-chat-session-label {
    font-weight: 600;
    font-size: 12pt;
    color: #333;
}

.cn-chat-session-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 11pt;
    min-width: 160px;
}

/* Context monitor bar — shown in header on ClawNanny_UI only */
#cn-context-monitor-bar {
    display: none;
    padding: 3px 8px;
    background: white;
    border-radius: 6px;
    border: 1px solid #ddd;
}
#cn-context-monitor-bar .cn-ctx-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}
#cn-ctx-progress-track {
    flex: 1;
    height: 12px;
    background: #eee;
    border-radius: 6px;
    overflow: hidden;
}
#cn-ctx-progress-fill {
    height: 100%;
    width: 0%;
    background: #27ae60;
    border-radius: 6px;
    transition: width 0.6s ease, background 0.6s ease;
}
.cn-ctx-label {
    font-size: 9pt;
    color: #666;
    white-space: nowrap;
}

/* Sticky wrapper — stays below the site header while page scrolls */
.cn-chat-sticky-wrap {
    position: sticky;
    top: var(--cn-header-h);
    z-index: 100;
    background: #e8eef5;
    padding: 6px 0 6px 0;
    /* Visual separation from messages scrolling underneath */
    box-shadow: 0 4px 8px -2px rgba(0, 0, 0, 0.12);
}

.cn-chat-messages {
    min-height: 120px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* No fixed height — grows with content and page scrolls */
}

.cn-chat-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    word-break: break-word;
}

.cn-bubble-user {
    align-self: flex-end;
    background: #425999;
    color: white;
}

.cn-bubble-assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid #ddd;
    color: #333;
}

.cn-bubble-inject {
    align-self: flex-start;
    background: #fff8e1;
    border: 1px solid #ffd54f;
    color: #333;
}

.cn-bubble-system {
    align-self: center;
    background: transparent;
    color: #999;
    font-size: 11px;
    font-style: italic;
    border: none;
    padding: 4px 0;
}

.cn-bubble-label {
    font-size: 12px;
    font-weight: 700;
    opacity: 0.7;
    margin-bottom: 4px;
}

.cn-bubble-user .cn-bubble-label {
    color: rgba(255, 255, 255, 0.85);
}

.cn-bubble-content {
    font-size: 12pt;
    line-height: 1.5;
    white-space: pre-wrap;
}

.cn-bubble-body-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.cn-bubble-body-row .cn-bubble-content,
.cn-bubble-body-row .cn-bubble-html-preview {
    flex: 1;
}

.cn-bubble-html-preview {
    font-size: 12pt;
    line-height: 1.5;
    white-space: normal;
    word-wrap: break-word;
}

.cn-bubble-btn-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}

.cn-copy-btn {
    flex-shrink: 0;
    background: none;
    height: 48px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 21px;
    line-height: 1;
    padding: 3px 8px;
    color: #888;
    opacity: 0;
    transition: opacity 0.15s;
}

.cn-bubble-assistant:hover .cn-copy-btn {
    opacity: 1;
}

.cn-html-toggle-btn {
    font-size: 11px;
    font-weight: bold;
    padding: 7px 5px;
    height: 48px;
}

.cn-bubble-assistant:hover .cn-html-toggle-btn {
    opacity: 1;
}

.cn-bubble-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}


.cn-popout-btn {
    opacity: 1 !important;
}
.cn-footer-popout-btn {
    color: #444 !important;
    height: 48px;
    width: 48px;
    padding: 3px 8px;
    align-self: flex-end;
}

.cn-streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: #1565c0;
    vertical-align: text-bottom;
    animation: cn-blink 0.8s step-end infinite;
}

@keyframes cn-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* Tool call cards */
.cn-tool-card {
    align-self: flex-start;
    max-width: 90%;
    background: #f0f4ff;
    border: 1px solid #b0c4ff;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 11pt;
}

.cn-tool-card-done {
    background: #f0fff4;
    border-color: #a8e6c0;
}

.cn-tool-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cn-tool-card-name {
    font-weight: 700;
    color: #1a237e;
    font-size: 11pt;
}

.cn-tool-card-name::before {
    content: '⚙ ';
    opacity: 0.6;
}

.cn-tool-card-toggle {
    font-size: 10px;
    color: #555;
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
}

.cn-tool-card-input,
.cn-tool-card-output {
    margin-top: 8px;
    font-size: 10px;
    font-family: 'Consolas', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    background: white;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.cn-tool-card-output {
    color: #2e7d32;
    border-color: #a8e6c0;
    background: #f8fff9;
}

/* ---- Collapsible tool-results group ---- */

.cn-tool-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 4px;
}

.cn-tool-group-toggle-btn {
    display: inline-block;
    align-self: flex-start;
    margin: 2px 0 8px 0;
    padding: 4px 14px;
    font-size: 9.5pt;
    color: #1565c0;
    background: transparent;
    border: 1px solid #1565c0;
    border-radius: 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.cn-tool-group-toggle-btn:hover {
    background: #e3f0ff;
}

/* ---- Markdown-generated tables ---- */

.cn-md-table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0 14px 0;
    font-size: 10.5pt;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    border-radius: 5px;
    overflow: hidden;
}

.cn-md-table th {
    background: #f0f4fb;
    color: #1a237e;
    font-weight: 700;
    padding: 4px;
    text-align: left;
    border: 1px solid #d0d4e8;
    border-bottom: 2px solid #c5cae9;
    white-space: nowrap;
}

.cn-md-table td {
    padding: 4px;
    border: 1px solid #e0e2ec;
    vertical-align: top;
}

.cn-md-table tbody tr:nth-child(even) {
    background: #f8f9ff;
}

/* In-flight indicator */
.cn-chat-inflight {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 11pt;
    color: #555;
    font-style: italic;
}

.cn-inflight-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1565c0;
    animation: cn-pulse 1s infinite;
}

/* Pencil rename button in Chat tab session bar */
.cn-rename-pencil-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    cursor: pointer;
    color: #555;
    line-height: 1;
    flex-shrink: 0;
}
.cn-rename-pencil-btn:hover {
    background: #e0e8f8;
    color: #1565c0;
    border-color: #1565c0;
}

/* Inline rename input in Chat tab session bar — matches select width */
.cn-chat-rename-input {
    padding: 6px 10px;
    border: 2px solid #1565c0;
    border-radius: 4px;
    font-size: 11pt;
    min-width: 360px;
}

/* Click-to-edit session name in Sessions table */
.cn-session-name-text {
    cursor: pointer;
    border-bottom: 1px dashed #aaa;
}
.cn-session-name-text:hover {
    color: #1565c0;
    border-bottom-color: #1565c0;
}
.cn-session-name-input {
    font-size: 11pt;
    font-family: inherit;
    padding: 3px 6px;
    border: 2px solid #1565c0;
    border-radius: 3px;
    width: 180px;
}

/* Chat input area */
.cn-chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.cn-chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12pt;
    font-family: inherit;
    font-weight: normal;
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
    background: #fffcec;
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: text;
    outline: none;
}

/* Placeholder text when the input is empty */
.cn-chat-input:empty::before {
    content: attr(data-placeholder);
    color: #aaa;
    pointer-events: none;
}

/* Pasted images inside the input */
.cn-chat-input img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    vertical-align: middle;
    margin: 4px 0;
    display: block;
}

.cn-chat-send-btn {
    flex-shrink: 0;
    height: 44px;
}

/* -------------------------------------------------------------------------
   Sessions panel (Phase 2)
   ------------------------------------------------------------------------- */

.cn-sessions-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cn-sessions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11pt;
}

.cn-sessions-table th {
    background: #f0f0f0;
    padding: 8px 12px;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.cn-sessions-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

.cn-sessions-table tr:hover td {
    background: #f5f8ff;
}

.cn-session-row-active td {
    background: #e8f5e9;
}

.cn-session-active-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    background: #4caf50;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.cn-sessions-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
}

.cn-toggle-btn {
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 600;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f0f0f0;
    color: #555;
    cursor: pointer;
    margin-right: 4px;
    transition: all 0.15s;
}

.cn-toggle-btn.cn-toggle-on {
    background: #1565c0;
    color: white;
    border-color: #1565c0;
}

/* -------------------------------------------------------------------------
   Modals (Phase 2)
   ------------------------------------------------------------------------- */

.cn-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cn-modal-box {
    background: white;
    border-radius: 8px;
    padding: 28px;
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.cn-modal-large {
    width: 760px;
    max-height: 85vh;
}

.cn-modal-title {
    font-size: 14pt;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: #1565c0;
}

.cn-modal-desc {
    font-size: 11pt;
    color: #555;
    margin: 0 0 14px 0;
}

.cn-modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.cn-btn-secondary {
    background-color: #888;
}

.cn-btn-secondary:hover {
    background-color: #555;
}

.cn-inject-text {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12pt;
    font-weight: normal;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    background-color: #f4f4fc;
}

/* -------------------------------------------------------------------------
   Session transcript modal content (Phase 2)
   ------------------------------------------------------------------------- */

.cn-transcript-content {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.cn-transcript-message {
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #eee;
}

.cn-transcript-user {
    background: #e3f0ff;
    border-color: #b0c4e8;
}

.cn-transcript-assistant {
    background: #f9f9f9;
    border-color: #ddd;
}

.cn-transcript-time {
    font-size: 9px;
    color: #999;
    margin-bottom: 4px;
}

.cn-transcript-text {
    font-size: 11pt;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: inherit;
}

/* -------------------------------------------------------------------------
   Channels panel (Phase 3)
   ------------------------------------------------------------------------- */

.cn-channels-toolbar {
    margin-bottom: 16px;
}

.cn-channels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.cn-channels-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
}

.cn-channel-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cn-channel-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cn-channel-name {
    font-weight: 700;
    font-size: 12pt;
    color: #1565c0;
}

.cn-channel-identity {
    font-size: 10pt;
    color: #555;
}

.cn-channel-actions {
    margin-top: 4px;
}

.cn-channel-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.cn-channel-badge-connected      { background: #e8f5e9; color: #2e7d32; border: 1px solid #4caf50; }
.cn-channel-badge-disconnected   { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.cn-channel-badge-pairing_required { background: #fff8e1; color: #e65100; border: 1px solid #ffd54f; }
.cn-channel-badge-not_connected  { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.cn-channel-badge-unknown        { background: #f5f5f5; color: #777;     border: 1px solid #ddd; }

/* QR Modal */
.cn-qr-modal-box {
    text-align: center;
    max-width: 400px;
}

.cn-qr-image-container {
    padding: 16px 0;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cn-qr-image {
    max-width: 280px;
    max-height: 280px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.cn-qr-text {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 9px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    word-break: break-all;
    text-align: left;
    max-width: 100%;
}

.cn-qr-status {
    font-size: 11pt;
    color: #555;
    margin: 8px 0;
}

/* -------------------------------------------------------------------------
   Cron Jobs panel (Phase 3)
   ------------------------------------------------------------------------- */

.cn-cron-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cn-cron-status-cell {
    max-width: 80px;
    width: 80px;
}

.cn-cron-actions-cell {
    min-width: 300px;
    white-space: normal;
}

.cn-cron-actions-cell .cn-test-btn {
    margin: 2px 3px 2px 0;
}

.cn-cron-schedule-cell {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10pt;
    color: #1a237e;
}

/* Cron / run history rows */
.cn-run-row {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #eee;
    background: #f9f9f9;
}

.cn-run-success { background: #f0fff4; border-color: #a8e6c0; }
.cn-run-failed  { background: #fff0f0; border-color: #ffb3b3; }
.cn-run-running { background: #fff8e1; border-color: #ffd54f; }

.cn-run-meta {
    font-size: 9px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.cn-run-output {
    font-size: 10px;
    font-family: 'Consolas', 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
    max-height: 160px;
    overflow-y: auto;
}

/* -------------------------------------------------------------------------
   Skills panel (Phase 3)
   ------------------------------------------------------------------------- */

.cn-skills-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cn-skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.cn-skills-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
}

.cn-skill-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cn-skill-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.cn-skill-name {
    font-weight: 700;
    font-size: 12pt;
    color: #1565c0;
}

.cn-skill-version {
    font-size: 9px;
    color: #999;
}

.cn-skill-description {
    font-size: 10pt;
    color: #555;
    line-height: 1.4;
}

.cn-skill-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.cn-skill-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.cn-skill-badge-enabled  { background: #e8f5e9; color: #2e7d32; border: 1px solid #4caf50; }
.cn-skill-badge-disabled { background: #f5f5f5; color: #777;     border: 1px solid #ddd; }
.cn-skill-badge-unknown  { background: #fff8e1; color: #e65100;  border: 1px solid #ffd54f; }

/* -------------------------------------------------------------------------
   Exec Approvals panel (Phase 3)
   ------------------------------------------------------------------------- */

.cn-exec-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.cn-exec-badge {
    display: inline-block;
    background: #e53935;
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    margin-left: 4px;
    vertical-align: middle;
}

.cn-exec-queue {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cn-exec-card {
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-radius: 6px;
    padding: 14px 16px;
}

.cn-exec-meta {
    font-size: 9px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.cn-exec-command {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11pt;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    margin: 0 0 10px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.cn-exec-buttons {
    display: flex;
    gap: 8px;
}

.cn-btn-approve {
    background-color: #2e7d32;
}
.cn-btn-approve:hover {
    background-color: #1b5e20;
}

.cn-btn-deny {
    background-color: #c62828;
}
.cn-btn-deny:hover {
    background-color: #7f0000;
}

.cn-exec-allowlist {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 14px;
}

.cn-exec-allowlist-label {
    font-weight: 700;
    font-size: 11pt;
    color: #333;
    margin-bottom: 6px;
}

.cn-exec-allowlist-pre {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10px;
    background: white;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 8px;
    margin: 0 0 12px 0;
    white-space: pre-wrap;
}

.cn-exec-history-row { margin-bottom: 12px; }
.cn-exec-status-approved { background: #f0fff4; border-color: #a8e6c0; }
.cn-exec-status-denied   { background: #fff0f0; border-color: #ffb3b3; }
.cn-exec-status-pending  { background: #fff8e1; border-color: #ffd54f; }

/* -------------------------------------------------------------------------
   Config editor (Phase 4)
   ------------------------------------------------------------------------- */

.cn-config-toolbar {
    display: block;
    margin-bottom: 36px;
}

.cn-config-toolbar > .cn-test-btn,
.cn-config-toolbar > .cn-config-raw-label {
    display: inline-block;
    vertical-align: middle;
    margin-right: 24px;
}

.cn-config-raw-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11pt;
    color: #333;
    cursor: pointer;
    user-select: none;
}

.cn-config-unsaved {
    font-size: 10pt;
    font-weight: 700;
    color: #e65100;
}

.cn-config-file-path {
    font-family: monospace;
    font-size: 10pt;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.cn-btn-danger {
    background-color: #c62828;
}
.cn-btn-danger:hover {
    background-color: #7f0000;
}

.cn-config-form-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cn-config-section {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.cn-config-section-header {
    background: #f0f0f0;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 12pt;
    color: #1565c0;
    cursor: pointer;
    user-select: none;
}

.cn-config-section-header:hover {
    background: #e0e8f8;
}

.cn-config-section-collapsed::after {
    content: ' ▶';
    font-size: 10px;
}

.cn-config-section-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Form field styles */
.cn-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cn-form-label {
    font-weight: 600;
    font-size: 10pt;
    color: #333;
}

.cn-form-input {
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 11pt;
    font-family: inherit;
    max-width: 480px;
}

.cn-form-hint {
    font-size: 9pt;
    color: #888;
}

.cn-config-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.cn-config-json-field {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 10px;
    max-width: 560px;
    field-sizing: content;
}

/* Monaco container */
.cn-config-monaco-area {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.cn-config-monaco-container {
    height: 520px;
}


/* -------------------------------------------------------------------------
   Health panel (Phase 4)
   ------------------------------------------------------------------------- */

.cn-health-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.cn-health-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 8px;
}

@media (max-width: 680px) {
    .cn-health-grid { grid-template-columns: 1fr; }
}

.cn-health-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
}

.cn-health-offline {
    color: #999;
    font-style: italic;
    font-size: 11pt;
}

.cn-health-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 11pt;
}

.cn-health-stat-key {
    color: #555;
    font-weight: 600;
}

.cn-health-stat-val {
    color: #1565c0;
    font-weight: 700;
    font-family: 'Consolas', 'Courier New', monospace;
}

.cn-health-subheader {
    font-weight: 700;
    font-size: 10pt;
    color: #333;
    text-transform: uppercase;
    margin-top: 12px;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.cn-health-model-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 10pt;
}

.cn-health-model-badge {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 10px;
}

.cn-health-model-ok       { background: #e8f5e9; color: #2e7d32; }
.cn-health-model-active   { background: #e8f5e9; color: #2e7d32; }
.cn-health-model-degraded { background: #fff8e1; color: #e65100; }
.cn-health-model-offline  { background: #ffebee; color: #c62828; }
.cn-health-model-unknown  { background: #f5f5f5; color: #777; }

.cn-health-token-summary {
    font-size: 12pt;
    color: #333;
    padding: 8px 0 12px 0;
}

.cn-health-token-table {
    margin-top: 8px;
    font-size: 10pt;
}

/* -------------------------------------------------------------------------
   Persona selector — compact dropdown in the Chat tab session bar
   ------------------------------------------------------------------------- */

.cn-persona-select {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 11pt;
    min-width: 160px;
    background: white;
    color: #333;
}

/* -------------------------------------------------------------------------
   Config & Security Audit page
   ------------------------------------------------------------------------- */

.cn-audit-intro {
    color: #555;
    margin-bottom: 20px;
    font-size: 11pt;
}

.cn-audit-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.cn-audit-last-run {
    font-size: 10pt;
    color: #888;
}

.cn-audit-summary {
    display: flex;
    gap: 24px;
    padding: 12px 20px;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 24px;
    font-size: 11pt;
    font-weight: 600;
}

.cn-audit-summary-pass   { color: #1b5e20; }
.cn-audit-summary-warn   { color: #e65100; }
.cn-audit-summary-fail   { color: #b71c1c; }
.cn-audit-summary-skip   { color: #888; }

.cn-audit-section {
    margin-bottom: 28px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.cn-audit-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f0f4ff;
    border-bottom: 1px solid #ddd;
    font-weight: 700;
    font-size: 11pt;
}

.cn-audit-section-label { flex: 1; }

.cn-audit-check-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #c8c8c8;
    font-size: 10pt;
}

.cn-audit-check-row:last-child { border-bottom: 1px solid #c8c8c8; }

.cn-audit-check-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }

.cn-audit-check-body { flex: 1; }

.cn-audit-check-label {
    font-weight: 600;
    margin-bottom: 2px;
}

.cn-audit-check-message { color: #444; }

.cn-audit-check-detail {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 9pt;
    color: #666;
    margin-top: 4px;
}

.cn-audit-check-fix {
    margin-top: 6px;
    color: #333;
    background: #fff8e1;
    border-left: 3px solid #ffd54f;
    padding: 4px 8px;
    border-radius: 0 4px 4px 0;
}

.cn-audit-check-actions { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }

.cn-audit-badge {
    display: inline-block;
    font-size: 8pt;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    margin-right: 6px;
    vertical-align: middle;
}

.cn-audit-critical  { background: #ffebee; border-left: 4px solid #b71c1c; }
.cn-audit-high      { background: #fff3e0; border-left: 4px solid #e65100; }
.cn-audit-medium    { background: #fffde7; border-left: 4px solid #f57f17; }
.cn-audit-info-sev  { background: #e3f2fd; border-left: 4px solid #1565c0; }
.cn-audit-pass      { background: #f1f8e9; }
.cn-audit-skip      { background: #fafafa; color: #999; }
.cn-audit-manual    { background: #fafafa; border-left: 4px solid #78909c; }
.cn-audit-accepted  { background: #f5f5f5; border-left: 4px solid #bdbdbd; color: #757575; }

.cn-audit-badge-critical { background: #b71c1c; color: white; }
.cn-audit-badge-high     { background: #e65100; color: white; }
.cn-audit-badge-medium   { background: #f57f17; color: white; }
.cn-audit-badge-info     { background: #1565c0; color: white; }
.cn-audit-badge-manual   { background: #546e7a; color: white; }
.cn-audit-badge-accepted { background: #9e9e9e; color: white; }

/* Procedure card — shown for manual checks */
.cn-audit-procedure {
    margin-top: 8px;
    padding: 10px 14px;
    background: #eceff1;
    border-radius: 4px;
    border-left: 3px solid #78909c;
    font-size: 12px;
    white-space: pre-wrap;
    color: #37474f;
}

.cn-audit-section-skip {
    padding: 16px;
    color: #888;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* -------------------------------------------------------------------------
   Version rollback guidance card (audit Section F)
   ------------------------------------------------------------------------- */

.cn-version-rollback-card {
    margin-top: 12px;
    padding: 14px 18px;
    background: #fff8e1;
    border: 1px solid #ffd54f;
    border-left: 4px solid #f9a825;
    border-radius: 4px;
}
.cn-version-rollback-title {
    font-weight: bold;
    font-size: 11pt;
    margin-bottom: 8px;
    color: #333;
}
.cn-version-rollback-steps {
    margin: 0 0 10px 20px;
    padding: 0;
    color: #333;
    font-size: 10pt;
    line-height: 1.7;
}
.cn-version-rollback-steps code {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 1px 6px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 10pt;
}

/* -------------------------------------------------------------------------
   "Open in OpenClaw dashboard" link bar
   ------------------------------------------------------------------------- */

.cn-openclaw-link-bar {
    margin-bottom: 12px;
    padding: 6px 0;
}
.cn-openclaw-link {
    font-size: 12pt;
    margin-top: 12px;
    color: #1565c0;
    text-decoration: none;
    opacity: 0.85;
}
.cn-openclaw-link:hover {
    opacity: 1;
    text-decoration: underline;
}
