/* =====================================================================
   CowAgent Console Styles
   ===================================================================== */

/* Animations */
@keyframes pulseDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: #94a3b8 transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }
.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* Generic Tooltip (via data-tooltip attribute) */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 100;
}
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
}
.dark [data-tooltip]::after {
    background: #334155;
    color: #f1f5f9;
}
[data-tooltip]:hover::after {
    opacity: 1;
}
[data-tooltip=""]:hover::after {
    display: none;
}

/* Sidebar */
.sidebar-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
}
.sidebar-item.active .item-icon { color: #4ABE6E; }
.sidebar-home-item { margin-bottom: 10px; }
.menu-group-toggle { border-radius: 8px; letter-spacing: .04em; }
.menu-group-toggle:hover { background: rgba(255, 255, 255, 0.035); }
.menu-group-items { border-left: 1px solid rgba(255,255,255,.08); margin-left: 9px; }
.menu-group-items .sidebar-item { margin-left: 5px; }

/* Session Panel */
.session-panel {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    border-right: 1px solid #e5e7eb;
    height: 100vh;
    overflow: hidden;
    transition: width 0.2s ease;
}
.dark .session-panel {
    background: #111111;
    border-right-color: rgba(255, 255, 255, 0.08);
}
.session-panel.hidden { display: none; }
.session-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.dark .session-panel-header { border-bottom-color: rgba(255, 255, 255, 0.08); }
.session-panel-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.dark .session-panel-title { color: #d1d5db; }
.session-panel-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 12px;
}
.session-panel-close:hover {
    background: #f3f4f6;
    color: #374151;
}
.dark .session-panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e5e5e5;
}
.session-panel-new {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 12px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px dashed #d1d5db;
    background: none;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}
.session-panel-new:hover {
    border-color: #9ca3af;
    color: #374151;
    background: #f9fafb;
}
.dark .session-panel-new {
    border-color: rgba(255, 255, 255, 0.12);
    color: #9ca3af;
}
.dark .session-panel-new:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.04);
}

/* Session List */
.session-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    scrollbar-width: none;
}
.session-list:hover { scrollbar-width: thin; }
.session-list::-webkit-scrollbar { width: 4px; background: transparent; }
.session-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.session-list:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); }
.dark .session-list:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
.session-group-label {
    padding: 10px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9ca3af;
}
.dark .session-group-label { color: #525252; }
.session-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}
.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin: 1px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    color: #6b7280;
    font-size: 13px;
    position: relative;
}
.dark .session-item { color: #a3a3a3; }
.session-item:hover {
    background: #f3f4f6;
    color: #111827;
}
.dark .session-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e5e5;
}
.session-item.active {
    background: #e5e7eb;
    color: #111827;
}
.dark .session-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.session-icon {
    flex-shrink: 0;
    font-size: 11px;
    color: #9ca3af;
    width: 16px;
    text-align: center;
}
.dark .session-icon { color: #525252; }
.session-item.active .session-icon { color: #4ABE6E; }
.session-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-delete {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 10px;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}
.dark .session-delete:hover { background: rgba(239, 68, 68, 0.15); }

/* Rename button: shares the look of the delete button, sits to its left.
   Negative right margin tightens the gap to the delete button only. */
.session-rename {
    flex-shrink: 0;
    margin-right: -6px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #9ca3af;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.session-item:hover .session-rename { opacity: 1; }
.session-rename:hover {
    color: #4ABE6E;
    background: rgba(74, 190, 110, 0.12);
}
.dark .session-rename:hover { background: rgba(74, 190, 110, 0.18); }

/* Inline title editor */
.session-title-input {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-family: inherit;
    color: #111827;
    background: #ffffff;
    border: 1px solid #4ABE6E;
    border-radius: 6px;
    padding: 2px 6px;
    outline: none;
}
.dark .session-title-input {
    color: #e5e5e5;
    background: rgba(255, 255, 255, 0.06);
    border-color: #4ABE6E;
}

/* Context Divider */
.context-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: #9ca3af;
}
.context-divider::before, .context-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, #d1d5db, transparent);
}
.dark .context-divider::before, .dark .context-divider::after {
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.12), transparent);
}
.context-divider span {
    font-size: 12px;
    white-space: nowrap;
    color: #9ca3af;
}

/* Confirm Modal */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.confirm-overlay.visible { opacity: 1; }
.confirm-modal {
    background: #fff;
    border-radius: 14px;
    width: 380px;
    max-width: 90vw;
    padding: 28px 24px 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    transform: scale(0.92);
    transition: transform 0.2s ease;
}
.confirm-overlay.visible .confirm-modal { transform: scale(1); }
.dark .confirm-modal {
    background: #1e1e1e;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.confirm-title {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}
.dark .confirm-title { color: #e5e7eb; }
.confirm-message {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 24px;
}
.dark .confirm-message { color: #9ca3af; }
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.confirm-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}
.confirm-btn-cancel {
    background: #f3f4f6;
    color: #374151;
}
.confirm-btn-cancel:hover { background: #e5e7eb; }
.dark .confirm-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
}
.dark .confirm-btn-cancel:hover { background: rgba(255, 255, 255, 0.14); }
.confirm-btn-ok {
    background: #ef4444;
    color: #fff;
}
.confirm-btn-ok:hover { background: #dc2626; }

/* Session panel overlay (mobile only, click to close) */
.session-panel-overlay {
    display: none;
}
@media (max-width: 768px) {
    .session-panel-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 44;
        background: rgba(0, 0, 0, 0.3);
    }
    .session-panel-overlay.hidden {
        display: none;
    }
}

/* Mobile: session panel as overlay */
@media (max-width: 768px) {
    .session-panel {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 45;
        width: 220px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
    .dark .session-panel {
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }
}

/* Menu Groups */
[data-roles].hidden,
.menu-group.hidden {
    display: none !important;
}
.menu-group-items { max-height: 0; overflow: hidden; transition: max-height 0.25s ease-out; }
.menu-group.open .menu-group-items { max-height: 2000px; transition: max-height 0.35s ease-in; }
.menu-group .chevron { transition: transform 0.25s ease; }
.menu-group.open .chevron { transform: rotate(90deg); }

/* View Switching */
.view { display: none; height: 100%; }
.view.active { display: flex; flex-direction: column; }

/* Operations command center */
.ops-sync-health{margin-bottom:10px;padding:9px 12px;border:1px solid rgba(49,104,149,.55);background:rgba(8,26,48,.72);border-radius:8px}.ops-sync-health.has-issues{border-color:rgba(255,123,114,.65)}.ops-sync-health-title{display:flex;justify-content:space-between;gap:12px;color:#b9eaff;font-size:12px;margin-bottom:7px}.ops-sync-health-title small{color:#63efb9}.ops-sync-health.has-issues .ops-sync-health-title small{color:#ff9a8f}.ops-sync-health-item{display:inline-flex;align-items:center;gap:7px;margin-right:16px;color:#8eabc3;font-size:11px}.ops-sync-health-item b{font-weight:600;color:#63efb9}.ops-sync-health-item.bad b{color:#ff8a80}.ops-sync-health-item small{color:#6688a5}
.operations-view{height:100%;overflow:auto;background:radial-gradient(circle at 80% 0,#142a50 0,transparent 32%),#07111f;color:#dcecff}.ops-shell{min-height:100%;padding:28px;max-width:1600px;margin:auto;width:100%}.ops-header{display:flex;justify-content:space-between;align-items:center;gap:20px;margin-bottom:18px}.ops-header p{margin:0 0 5px;color:#38d9ff;font-size:11px;letter-spacing:.2em}.ops-header h2{margin:0;color:#fff;font-size:28px}.ops-actions,.ops-periods{display:flex;align-items:center;gap:10px;color:#7f9bb8;font-size:12px}.ops-actions button,.ops-periods button{border:1px solid #245b83;border-radius:7px;background:#0b2138;color:#bceaff;padding:9px 13px;cursor:pointer}.ops-periods button.active{background:#126da1;color:#fff}.ops-notice{padding:10px 13px;margin-bottom:14px;border:1px solid #173b5a;background:#0b1c2f;color:#82a9c8;font-size:13px}.ops-metrics{display:grid;grid-template-columns:repeat(7,minmax(130px,1fr));gap:10px;margin-bottom:14px}.ops-metrics article,.ops-grid article,.ops-wall-grid article{border:1px solid #173f61;background:linear-gradient(145deg,rgba(14,38,64,.96),rgba(7,23,40,.96));box-shadow:inset 0 1px rgba(102,210,255,.08)}.ops-metrics article{padding:15px}.ops-metrics span{display:block;color:#7f9bb8;font-size:12px;margin-bottom:9px}.ops-metrics strong{color:#f2fbff;font-size:21px;font-variant-numeric:tabular-nums}.ops-grid{display:grid;gap:14px;margin-bottom:14px}.ops-grid-alerts{grid-template-columns:1.45fr 1fr}.ops-grid-rank{grid-template-columns:1fr 1fr}.ops-grid article,.ops-wall-grid article{padding:18px;min-height:180px}.ops-grid h3,.ops-wall-grid h3{margin:0 0 14px;color:#b9eaff;font-size:14px}.ops-alert-list>div,#ops-accounts>div,#ops-quality>div,#ops-channels>div{display:flex;justify-content:space-between;padding:9px 0;border-top:1px solid rgba(62,126,169,.25);color:#9eb8cc;font-size:13px}.ops-alert-list strong{color:#45e6b6}.ops-alert-list strong.warn{color:#ff7b72}.ops-grid p,.ops-wall-grid p{color:#6688a5;font-size:13px}.ops-wall-grid{display:grid;grid-template-columns:1.6fr 1fr;gap:14px}.ops-screen{max-width:none}.analytics-view .ops-metrics{grid-template-columns:repeat(4,1fr)}
.ops-chart{height:210px;display:flex;align-items:flex-end;gap:3px;border-bottom:1px solid #245b83;padding:10px 3px 24px}.ops-chart-point{height:100%;flex:1;min-width:3px;position:relative;display:flex;align-items:flex-end}.ops-chart-point i{display:block;width:100%;min-height:2px;background:linear-gradient(180deg,#38d9ff,#126da1);box-shadow:0 0 8px rgba(56,217,255,.28)}.ops-chart-point span{position:absolute;bottom:-21px;left:0;color:#6688a5;font-size:9px;white-space:nowrap}.ops-chart-legend{display:flex;gap:18px;margin-top:12px;color:#7f9bb8;font-size:11px}.ops-chart-legend b{display:inline-block;width:10px;height:10px;margin-right:5px}.ops-chart-legend .sales{background:#25b9eb}.ops-chart-legend .quality{border:2px solid #ffb84d;border-radius:50%}.ops-channel-head,.ops-channel-row{display:grid;grid-template-columns:minmax(100px,1fr) 100px 110px;gap:8px;align-items:center}.ops-channel-head{color:#6688a5;font-size:11px;padding:0 0 8px 30px}.ops-channel-row{grid-template-columns:22px minmax(100px,1fr) 100px 110px;padding:9px 0;border-top:1px solid rgba(62,126,169,.25);font-size:12px}.ops-channel-row>b{color:#38d9ff}.ops-channel-row>span{color:#b9d2e6}.ops-channel-row>strong{text-align:right;color:#f2fbff;font-variant-numeric:tabular-nums}.ops-product-card{border:1px solid #173f61;background:linear-gradient(145deg,rgba(14,38,64,.96),rgba(7,23,40,.96));padding:18px}.ops-product-card h3{margin:0 0 14px;color:#b9eaff;font-size:14px}.ops-table-wrap{overflow:auto}.ops-table{width:100%;border-collapse:collapse;font-size:12px}.ops-table th{color:#6688a5;text-align:right;padding:9px;border-bottom:1px solid #245b83}.ops-table th:first-child{text-align:left}.ops-table td{color:#dcecff;text-align:right;padding:10px 9px;border-bottom:1px solid rgba(62,126,169,.2)}.ops-table td:first-child{text-align:left;min-width:280px}.ops-table td small,.ops-table td strong,.ops-table td em{display:block}.ops-table td small{color:#38d9ff}.ops-table td strong{margin:3px 0;color:#f2fbff}.ops-table td em{font-style:normal;color:#6688a5;font-size:10px}.ops-table tr.over-limit{background:rgba(255,74,74,.12)}
@media(max-width:1100px){.ops-metrics{grid-template-columns:repeat(4,1fr)}}
@media(max-width:700px){.ops-shell{padding:16px}.ops-header{align-items:flex-start;flex-direction:column}.ops-metrics,.analytics-view .ops-metrics{grid-template-columns:repeat(2,1fr)}.ops-grid-alerts,.ops-grid-rank,.ops-wall-grid{grid-template-columns:1fr}.ops-actions{width:100%;justify-content:space-between}}

/* Operations live wall */
.ops-home-shell{max-width:1800px;height:100%;min-height:690px;padding:16px 18px;display:flex;flex-direction:column;background:radial-gradient(circle at 50% 8%,rgba(87,70,232,.16),transparent 30%)}
.ops-live-header{margin-bottom:8px;flex:0 0 auto}
.ops-live-header h2{font-size:24px;letter-spacing:.04em}
.ops-live-header .ops-actions{flex-wrap:wrap;justify-content:flex-end}
.ops-home-periods{padding-right:4px;border-right:1px solid rgba(68,126,170,.35)}
.ops-home-periods button{padding:7px 10px;font-size:11px}
.ops-loading{display:flex;align-items:center;justify-content:center;min-height:120px;color:#75a2c3;font-size:13px}
.ops-loading:before{content:"";width:14px;height:14px;margin-right:9px;border:2px solid rgba(56,217,255,.22);border-top-color:#38d9ff;border-radius:50%;animation:ops-spin .8s linear infinite}
.ops-error{display:flex;align-items:center;justify-content:space-between;gap:12px;color:#ffb1aa}
.ops-retry-button{border:1px solid #3877a4;border-radius:6px;background:#10304d;color:#d8f4ff;padding:6px 10px;cursor:pointer;white-space:nowrap}
@keyframes ops-spin{to{transform:rotate(360deg)}}
.ops-live-dot{color:#63efb9}
.ops-live-dot:before{content:"";display:inline-block;width:7px;height:7px;margin-right:6px;border-radius:50%;background:#63efb9;box-shadow:0 0 12px rgba(99,239,185,.8)}
.ops-live-notice{flex:0 0 auto;margin-bottom:9px;padding:7px 11px;border-color:rgba(49,104,149,.55);background:rgba(8,26,48,.72);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ops-home-grid{display:grid;grid-template-columns:minmax(210px,1fr) minmax(470px,2.12fr) minmax(210px,1fr);gap:10px;flex:1;min-height:0}
.ops-home-column{display:grid;gap:10px;min-width:0;min-height:0}
.ops-home-left{grid-template-rows:1.08fr .92fr}
.ops-home-center{grid-template-rows:minmax(225px,1.18fr) minmax(180px,.82fr)}
.ops-home-right{grid-template-rows:1.05fr .95fr}
.ops-panel{position:relative;min-height:0;padding:13px;border:1px solid #194873;border-radius:9px;background:linear-gradient(145deg,rgba(14,39,70,.97),rgba(6,22,42,.97));box-shadow:inset 0 1px rgba(106,214,255,.07);overflow:hidden}
.ops-panel:before{content:"";position:absolute;left:0;top:0;width:70px;height:2px;background:#38d9ff;box-shadow:0 0 12px rgba(56,217,255,.55)}
.ops-panel h3{margin:0 0 10px;color:#c3ecff;font-size:13px;font-weight:600;letter-spacing:.05em}
.ops-panel p{margin:12px 0;color:#6d91af;font-size:12px}
.ops-sales-hero{position:relative;width:100%;min-height:0;padding:17px 20px 15px;border:1px solid rgba(178,214,255,.42);border-radius:11px;background:linear-gradient(135deg,#315ae5 0%,#5947e9 48%,#9d43e8 100%);color:#fff;box-shadow:0 16px 44px rgba(67,60,218,.28),inset 0 1px rgba(255,255,255,.23);cursor:pointer;overflow:hidden;text-align:center}
.ops-sales-hero:before{content:"";position:absolute;inset:0;background:radial-gradient(circle at 50% -20%,rgba(255,255,255,.25),transparent 48%);pointer-events:none}
.ops-sales-hero:hover{filter:brightness(1.05);transform:translateY(-1px)}
.ops-sales-hero:focus-visible{outline:2px solid #c8f5ff;outline-offset:2px}
.ops-hero-kicker{position:relative;display:block;color:#dbe7ff;font-size:13px;letter-spacing:.16em}
.ops-sales-hero>strong{position:relative;display:block;margin:8px 0 2px;font-size:clamp(38px,4.2vw,66px);line-height:1.06;font-weight:700;font-variant-numeric:tabular-nums;text-shadow:0 5px 24px rgba(22,18,91,.35)}
.ops-hero-hint{position:relative;display:block;margin-bottom:12px;color:#d5e3ff;font-size:10px;opacity:.82}
.ops-hero-metrics{position:relative;display:grid;grid-template-columns:repeat(5,1fr);padding-top:13px;border-top:1px solid rgba(255,255,255,.2)}
.ops-hero-metrics>span{min-width:0;padding:0 7px;border-right:1px solid rgba(255,255,255,.17)}
.ops-hero-metrics>span:last-child{border-right:0}
.ops-hero-metrics em,.ops-hero-metrics b{display:block;overflow:hidden;text-overflow:ellipsis}
.ops-hero-metrics em{margin-bottom:5px;color:#d9e1ff;font-size:10px;font-style:normal;white-space:nowrap}
.ops-hero-metrics b{color:#fff;font-size:16px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap}
.ops-hero-metrics .ops-hero-warning b{color:#ffd37c}
.ops-live-chart{height:calc(100% - 26px);min-height:110px;display:flex;align-items:flex-end;gap:3px;padding:8px 3px 23px;border-left:1px solid #23557f;border-bottom:1px solid #23557f;background:repeating-linear-gradient(to bottom,transparent 0,transparent 32%,rgba(63,120,165,.16) 33%,transparent 34%)}
.ops-live-chart-point{position:relative;display:flex;align-items:flex-end;flex:1;height:100%;min-width:3px}
.ops-live-chart-point i{display:block;width:100%;min-height:3px;border-radius:2px 2px 0 0;background:linear-gradient(180deg,#48e0ff,#2474d8);box-shadow:0 0 8px rgba(56,217,255,.25)}
.ops-live-chart-point span{position:absolute;left:0;bottom:-20px;color:#668ca9;font-size:9px;white-space:nowrap;transform:translateX(-20%)}
.ops-alert-list>div,#ops-quality>div,#ops-channels>div{display:grid;grid-template-columns:20px minmax(0,1fr) auto;gap:6px;align-items:center;padding:8px 0;border-top:1px solid rgba(62,126,169,.25);color:#a3c0d6;font-size:12px}
.ops-alert-list>div:first-child,#ops-quality>div:first-child,#ops-channels>div:first-child{border-top:0}
.ops-alert-list b,#ops-quality>div>b,#ops-channels>div>b{color:#46d8ff;font-size:10px}
.ops-alert-list strong,#ops-quality>div>strong,#ops-channels>div>strong{color:#eefaff;text-align:right;font-variant-numeric:tabular-nums}
.ops-alert-list strong.warn,#ops-quality strong.warn{color:#ff817a;text-shadow:0 0 10px rgba(255,81,81,.25)}
.ops-quality-empty{height:calc(100% - 4px);display:flex!important;grid-template-columns:1fr!important;align-content:center;justify-items:center;text-align:center;border:0!important}
.ops-quality-empty strong{color:#f4c56e!important;font-size:15px}
.ops-quality-empty span{color:#7498b6;font-size:11px}
.ops-home-table{height:calc(100% - 26px);display:flex;flex-direction:column;min-height:0}
.ops-home-table-head,.ops-home-table-row{display:grid;grid-template-columns:minmax(160px,1.55fr) .72fr .48fr .9fr;gap:7px;align-items:center}
.ops-home-table-head{padding:0 7px 7px;color:#648ba9;font-size:9px}
.ops-home-table-head span:not(:first-child){text-align:right}
.ops-home-table-row{flex:1;min-height:29px;padding:5px 7px;border-top:1px solid rgba(62,126,169,.22);color:#a8c4da;font-size:10px}
.ops-home-table-row>span{display:grid;grid-template-columns:20px minmax(0,1fr);column-gap:6px;min-width:0}
.ops-home-table-row>span .ops-product-title{grid-column:2;color:#6688a5;font-size:8px;font-style:normal;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ops-home-table-row>span b{grid-row:1/3;align-self:center;display:grid;place-items:center;width:18px;height:18px;border-radius:4px;background:#123b64;color:#52dcff;font-size:9px}
.ops-home-table-row>span i,.ops-home-table-row>span strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ops-home-table-row>span i{color:#43ccec;font-size:8px;font-style:normal}
.ops-home-table-row>span strong{color:#e9f8ff;font-size:10px}
.ops-quality-model{display:block;color:#dcecff;font-size:12px;font-weight:600}.ops-quality-panel .ops-alert-list small,.ops-quality-panel small{display:block;color:#6688a5;font-size:9px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:180px}
.ops-home-table-row>em{text-align:right;color:#e9f8ff;font-style:normal;font-variant-numeric:tabular-nums}
.ops-home-table-row.over-limit{background:rgba(255,74,74,.1)}
.ops-home-table-row.over-limit>em:last-child{color:#ff817a}
.ops-finance-strip{display:grid;grid-template-columns:repeat(3,minmax(135px,1fr));gap:10px;margin-top:10px;flex:0 0 auto}
.ops-finance-strip.hidden{display:none}
.ops-finance-card{min-height:77px;padding:12px 14px;border:1px solid #1b4b78;border-radius:9px;background:linear-gradient(135deg,rgba(14,43,75,.98),rgba(8,27,50,.98))}
.ops-finance-card span,.ops-finance-card strong,.ops-finance-card small{display:block}
.ops-finance-card span{margin-bottom:7px;color:#759dbd;font-size:10px}
.ops-finance-card strong{color:#f3fbff;font-size:19px;font-variant-numeric:tabular-nums}
.ops-finance-card small{margin-top:4px;color:#52d3ff;font-size:9px}
.ops-sensitive-card{border-color:#554488;background:linear-gradient(135deg,rgba(56,34,90,.95),rgba(15,29,55,.98))}
.ops-sensitive-card small{color:#a995ed}

@media(max-width:1250px){
  .ops-home-shell{padding:13px;min-height:660px}
  .ops-home-grid{grid-template-columns:minmax(190px,.9fr) minmax(420px,1.8fr) minmax(190px,.9fr);gap:8px}
  .ops-home-column{gap:8px}.ops-finance-strip{gap:8px;margin-top:8px}
  .ops-panel{padding:10px}.ops-sales-hero{padding:14px 13px 12px}.ops-sales-hero>strong{font-size:42px}
  .ops-hero-metrics>span{padding:0 4px}.ops-hero-metrics b{font-size:13px}.ops-alert-list>div,#ops-quality>div,#ops-channels>div{padding:6px 0;font-size:10px}
}
@media(max-width:900px){
  .ops-home-shell{height:auto;min-height:100%;padding:16px}.ops-live-notice{white-space:normal}
  .ops-home-grid{display:flex;flex-direction:column}.ops-home-center{order:1}.ops-home-right{order:2}.ops-home-left{order:3}
  .ops-home-column{display:grid;grid-template-columns:1fr}.ops-sales-hero{min-height:260px}.ops-panel{min-height:210px}
  .ops-finance-strip{grid-template-columns:repeat(2,minmax(150px,1fr))}.ops-home-table{min-height:200px}
}
@media(max-width:600px){
  .ops-home-shell{padding:12px}.ops-live-header{align-items:flex-start}.ops-live-header .ops-actions{width:100%;justify-content:space-between}
  .ops-home-periods{order:3;width:100%;padding:7px 0 0;border-right:0;border-top:1px solid rgba(68,126,170,.35)}
  .ops-home-periods button{flex:1}
  .ops-sales-hero{padding:16px 10px}.ops-sales-hero>strong{font-size:36px}.ops-hero-metrics{grid-template-columns:repeat(2,1fr);gap:10px}.ops-hero-metrics>span{border-right:0}
  .ops-finance-strip{grid-template-columns:1fr}.ops-home-table-head,.ops-home-table-row{grid-template-columns:minmax(130px,1.4fr) .75fr .48fr}.ops-home-table-head span:last-child,.ops-home-table-row>em:last-child{display:none}
}

/* Markdown Content */
.msg-content p { margin: 0.5em 0; line-height: 1.7; }
.msg-content p:first-child { margin-top: 0; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
    margin-top: 1.2em; margin-bottom: 0.6em; font-weight: 600; line-height: 1.3;
}
.msg-content h1 { font-size: 1.4em; }
.msg-content h2 { font-size: 1.25em; }
.msg-content h3 { font-size: 1.1em; }
.msg-content ul { margin: 0.5em 0; padding-left: 1.8em; list-style: disc; }
.msg-content ol { margin: 0.5em 0; padding-left: 1.8em; list-style: decimal; }
.msg-content li { margin: 0.25em 0; }
.msg-content pre {
    border-radius: 8px; overflow-x: auto; margin: 0.8em 0;
    background: #f1f5f9; padding: 1em;
}
.dark .msg-content pre { background: #111111; }
.msg-content code {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.875em;
}
.msg-content :not(pre) > code {
    background: rgba(74, 190, 110, 0.1); color: #1C6B3B;
    padding: 2px 6px; border-radius: 4px;
}
.dark .msg-content :not(pre) > code {
    background: rgba(74, 190, 110, 0.15); color: #74E9A4;
}
.msg-content pre code { background: transparent; padding: 0; color: inherit; }
.msg-content blockquote {
    border-left: 3px solid #4ABE6E; padding: 0.5em 1em;
    margin: 0.8em 0; background: rgba(74, 190, 110, 0.05); border-radius: 0 6px 6px 0;
}
.dark .msg-content blockquote { background: rgba(74, 190, 110, 0.08); }
.msg-content table { border-collapse: collapse; width: 100%; margin: 0.8em 0; }
.msg-content th, .msg-content td {
    border: 1px solid #e2e8f0; padding: 8px 12px; text-align: left;
}
.dark .msg-content th, .dark .msg-content td { border-color: rgba(255,255,255,0.1); }
.msg-content th { background: #f1f5f9; font-weight: 600; }
.dark .msg-content th { background: #111111; }
.msg-content img { max-width: 100%; height: auto; border-radius: 8px; margin: 0.5em 0; }
.msg-content a { color: #35A85B; text-decoration: underline; }
.msg-content a:hover { color: #228547; }

/* Overrides for user bubble (white text on green bg) */
.user-bubble.msg-content a { color: #ffffff !important; text-decoration: underline; text-decoration-color: rgba(255,255,255,0.6); }
.user-bubble.msg-content a:hover { color: #e0f5e8 !important; text-decoration-color: #e0f5e8; }
.user-bubble.msg-content :not(pre) > code { background: rgba(255,255,255,0.2); color: #ffffff; }
.msg-content hr { border: none; height: 1px; background: #e2e8f0; margin: 1.2em 0; }
.dark .msg-content hr { background: rgba(255,255,255,0.1); }

/* SSE Streaming cursor */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.sse-streaming::after {
    content: '▋';
    display: inline-block;
    margin-left: 2px;
    color: #4ABE6E;
    animation: blink 0.9s step-end infinite;
    font-size: 0.85em;
    vertical-align: middle;
}

/* Agent steps (thinking summaries + tool indicators) */
.agent-steps:empty { display: none; }
.agent-steps:not(:empty) {
    margin-bottom: 0.625rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}
.dark .agent-steps:not(:empty) { border-bottom-color: rgba(255, 255, 255, 0.08); }

.agent-step {
    font-size: 0.75rem;
    line-height: 1.4;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}
.agent-step:last-child { margin-bottom: 0; }

/* Thinking step - collapsible */
.agent-thinking-step .thinking-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    user-select: none;
}
.agent-thinking-step .thinking-header:hover { color: #64748b; }
.dark .agent-thinking-step .thinking-header:hover { color: #cbd5e1; }
.agent-thinking-step .thinking-header i:first-child { font-size: 0.625rem; margin-top: 1px; }
.agent-thinking-step .thinking-chevron {
    font-size: 0.5rem;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.5;
}
.agent-thinking-step.expanded .thinking-chevron { transform: rotate(90deg); }
.agent-thinking-step .thinking-full {
    display: none;
    margin-top: 0.375rem;
    margin-left: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    font-size: 0.75rem;
    line-height: 1.5;
    color: #94a3b8;
    max-height: 300px;
    overflow-y: auto;
}
.dark .agent-thinking-step .thinking-full {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
}
.agent-thinking-step.expanded .thinking-full { display: block; }
.agent-thinking-step .thinking-full p { margin: 0.25em 0; }
.agent-thinking-step .thinking-full p:first-child { margin-top: 0; }
.agent-thinking-step .thinking-full p:last-child { margin-bottom: 0; }
.agent-thinking-step .thinking-duration {
    font-size: 0.625rem;
    color: #b0b8c4;
    margin-bottom: 0.375rem;
}
/* Streaming reasoning: render as plain pre to avoid expensive markdown
   re-parsing on every chunk. Wrap long lines so the bubble width is
   respected and use the same font size/color as the rendered version. */
.agent-thinking-step .thinking-stream-pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.5;
    color: inherit;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Content step - real text output frozen before tool calls */
.agent-content-step {
    font-size: 0.875rem;
    line-height: 1.6;
    color: inherit;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.06);
}
.dark .agent-content-step { border-bottom-color: rgba(255, 255, 255, 0.06); }
.agent-content-step .agent-content-body p { margin: 0.25em 0; }
.agent-content-step .agent-content-body p:first-child { margin-top: 0; }
.agent-content-step .agent-content-body p:last-child { margin-bottom: 0; }

/* Tool step - collapsible */
.agent-tool-step .tool-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    cursor: pointer;
    user-select: none;
    padding: 1px 0;
    border-radius: 4px;
}
.agent-tool-step .tool-header:hover { color: #64748b; }
.dark .agent-tool-step .tool-header:hover { color: #cbd5e1; }
.agent-tool-step .tool-icon { font-size: 0.625rem; }
.agent-tool-step .tool-chevron {
    font-size: 0.5rem;
    margin-left: auto;
    transition: transform 0.2s ease;
    opacity: 0.5;
}
.agent-tool-step.expanded .tool-chevron { transform: rotate(90deg); }
.agent-tool-step .tool-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-left: 0.25rem;
}

/* Tool detail panel */
.agent-tool-step .tool-detail {
    display: none;
    margin-top: 0.375rem;
    margin-left: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.dark .agent-tool-step .tool-detail {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.04);
}
.agent-tool-step.expanded .tool-detail { display: block; }
.tool-detail-section { margin-bottom: 0.375rem; }
.tool-detail-section:last-child { margin-bottom: 0; }
.tool-detail-label {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin-bottom: 0.125rem;
}
.tool-detail-content {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.7rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    padding: 0.25rem 0;
    background: transparent;
    color: inherit;
}
.tool-error-text { color: #f87171; }
.tool-live-output:empty { display: none; }
.tool-streaming .tool-live-output:not(:empty)::after {
    content: ' ';
    display: inline-block;
    width: 0.45em;
    height: 1em;
    margin-left: 0.15em;
    vertical-align: -0.15em;
    background: currentColor;
    animation: tool-cursor-blink 1s steps(1) infinite;
}
@keyframes tool-cursor-blink { 50% { opacity: 0; } }

/* Log level highlighting */
.log-line { display: block; }
.log-line-debug    { color: #94a3b8; }
.log-line-info     { background-color: rgba(59, 130, 246, 0.08); }
.log-line-warning  { background-color: rgba(234, 179, 8, 0.15); color: #fde68a; }
.log-line-error    { background-color: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.log-line-critical { background-color: rgba(239, 68, 68, 0.35); color: #ff4444; font-weight: bold;  }

/* Tool failed state */
.agent-tool-step.tool-failed .tool-name { color: #f87171; }

/* Config form controls */
#view-config input[type="text"],
#view-config input[type="number"],
#view-config input[type="password"] {
    height: 40px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
#view-config input:focus {
    border-color: #4ABE6E;
    box-shadow: 0 0 0 3px rgba(74, 190, 110, 0.12);
}
#view-config input[type="text"]:hover,
#view-config input[type="number"]:hover,
#view-config input[type="password"]:hover {
    border-color: #94a3b8;
}
.dark #view-config input[type="text"]:hover,
.dark #view-config input[type="number"]:hover,
.dark #view-config input[type="password"]:hover {
    border-color: #64748b;
}

/* Custom dropdown */
.cfg-dropdown {
    position: relative;
    outline: none;
}
.cfg-dropdown-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 40px;
    padding: 0 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 0.875rem;
    color: #1e293b;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}
.dark .cfg-dropdown-selected {
    border-color: #475569;
    background: rgba(255, 255, 255, 0.05);
    color: #f1f5f9;
}
.cfg-dropdown-selected:hover { border-color: #94a3b8; }
.dark .cfg-dropdown-selected:hover { border-color: #64748b; }
.cfg-dropdown.open .cfg-dropdown-selected,
.cfg-dropdown:focus .cfg-dropdown-selected {
    border-color: #4ABE6E;
    box-shadow: 0 0 0 3px rgba(74, 190, 110, 0.12);
}
.cfg-dropdown-arrow {
    font-size: 0.625rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 0.5rem;
}
.cfg-dropdown.open .cfg-dropdown-arrow { transform: rotate(180deg); }
.cfg-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 4px;
}
.dark .cfg-dropdown-menu {
    border-color: #334155;
    background: #1e1e1e;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
}
.cfg-dropdown.open .cfg-dropdown-menu { display: block; }
.cfg-dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .cfg-dropdown-item { color: #cbd5e1; }
.cfg-dropdown-item:hover { background: #f1f5f9; }
.dark .cfg-dropdown-item:hover { background: rgba(255, 255, 255, 0.08); }
.cfg-dropdown-item.active {
    background: rgba(74, 190, 110, 0.1);
    color: #228547;
    font-weight: 500;
}
.dark .cfg-dropdown-item.active {
    background: rgba(74, 190, 110, 0.15);
    color: #74E9A4;
}
/* When an item carries a hint (e.g. brand alias next to a technical model
   id), label/hint are split into two spans so the hint sits on the right in
   a dim, smaller weight. Without a hint the row stays a plain text node and
   uses the default ellipsis behaviour, so no layout regressions for old call
   sites. */
.cfg-dropdown-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cfg-dropdown-hint {
    flex-shrink: 0;
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 400;
}
.dark .cfg-dropdown-hint {
    color: #64748b;
}
.cfg-dropdown-item.active .cfg-dropdown-hint {
    /* Tint the hint toward the brand colour on the active row so it doesn't
       fight with the highlighted label tone. */
    color: rgba(34, 133, 71, 0.65);
}
.dark .cfg-dropdown-item.active .cfg-dropdown-hint {
    color: rgba(116, 233, 164, 0.6);
}
/* The active row gets a trailing brand-green checkmark via a Font Awesome
   pseudo-element so every dropdown (chat / vision / image / asr / tts / etc.)
   surfaces "this is what's currently selected" without per-call JS plumbing.
   When a hint is present, the ✓ sits to its right with a small gap; without
   a hint, margin-left:auto pushes the ✓ flush against the right edge. */
.cfg-dropdown-item.active::after {
    content: '\f00c';                  /* FontAwesome check glyph */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 5 Free', 'FontAwesome';
    font-weight: 900;
    margin-left: auto;
    padding-left: 12px;
    color: #4abe6e;
    font-size: 11px;
    flex-shrink: 0;
}
.cfg-dropdown-item.active:has(.cfg-dropdown-hint)::after {
    /* When hint occupies the auto-margin slot, the ✓ no longer benefits
       from `margin-left: auto`; replace it with a small fixed gap so the
       ✓ trails the hint cleanly. */
    margin-left: 0;
    padding-left: 10px;
}

/* API Key masking via CSS (avoids browser password prompts) */
.cfg-key-masked {
    -webkit-text-security: disc;
    text-security: disc;
}

/* Provider logo image — vendors flagged as `provider-logo-invert-dark`
   ship a black wordmark that disappears on the dark canvas; we invert their
   luminance only in dark mode so the brand stays recognizable without
   touching multi-color marks like Google/MiniMax. */
.provider-logo-img {
    object-fit: contain;
    object-position: center;
}
.dark .provider-logo-invert-dark {
    filter: invert(1) brightness(1.15);
}

/* Models page — provider dropdown rows.
   Configured rows look like ordinary picker entries; the .active row's
   trailing brand-green ✓ already announces "this is what's selected"
   (handled globally by .cfg-dropdown-item.active::after above).
   Unconfigured rows are visually subdued and carry a trailing gear icon
   as a "click to set up" affordance. */
.cap-provider-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cap-provider-gear {
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}
.cap-provider-item.cap-provider-unconfigured {
    color: #94a3b8;
}
.dark .cap-provider-item.cap-provider-unconfigured {
    color: #64748b;
}
.cap-provider-item.cap-provider-unconfigured:hover {
    color: #475569;
}
.dark .cap-provider-item.cap-provider-unconfigured:hover {
    color: #cbd5e1;
}
.cap-provider-item.cap-provider-unconfigured:hover .cap-provider-gear {
    color: #475569;
}
.dark .cap-provider-item.cap-provider-unconfigured:hover .cap-provider-gear {
    color: #cbd5e1;
}
/* If the active row ever lands on an unconfigured vendor (defensive — the
   click handler normally diverts to the modal), suppress the global ✓ so
   the gear remains the sole trailing icon and the row keeps reading as
   "needs setup" rather than "already selected". */
.cap-provider-item.cap-provider-unconfigured.active::after {
    content: none;
}

/* "Add vendor" modal picker — each configured row carries a static
   brand-green ✓ via decorateVendorModalPicker so users can see what's set
   up at a glance. The active row's global ✓ is suppressed here to avoid
   showing two checks side by side on configured + selected rows. */
.vendor-picker-item.active::after {
    content: none;
}
.vendor-picker-configured-mark {
    margin-left: auto;
    padding-left: 12px;
    color: #4abe6e;
    font-size: 11px;
    flex-shrink: 0;
}
/* "Custom" row is an add-new action: trailing + instead of ✓. */
.vendor-picker-add-mark {
    margin-left: auto;
    padding-left: 12px;
    color: #94a3b8;
    font-size: 11px;
    flex-shrink: 0;
}

/* Chat Input */
#chat-input {
    resize: none; height: 42px; max-height: 180px;
    overflow-y: hidden;
    transition: border-color 0.2s ease;
}

/* Attachment Preview Bar */
.attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}
.attachment-preview.hidden { display: none; }

.attach-menu {
    position: absolute;
    left: 72px;
    bottom: calc(100% + 6px);
    min-width: 148px;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.1), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    z-index: 55;
    animation: slashMenuIn 0.15s ease-out;
}
.attach-menu.hidden { display: none; }
.attach-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    text-align: left;
}
.attach-menu-item:hover {
    background: #EDFDF3;
    color: #228547;
}
.attach-menu-item i {
    width: 14px;
    text-align: center;
    color: #64748b;
}
.attach-menu-item:hover i { color: inherit; }

.att-thumb {
    position: relative;
    width: 64px; height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.dark .att-thumb { border-color: rgba(255,255,255,0.1); }
.att-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.att-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 28px 6px 10px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 12px;
    color: #475569;
    max-width: 180px;
}
.dark .att-chip { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: #94a3b8; }
.att-uploading { opacity: 0.6; pointer-events: none; }
.att-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.att-remove {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    border: none;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}
.att-thumb:hover .att-remove,
.att-chip:hover .att-remove { opacity: 1; }

/* Drag-over highlight */
.drag-over {
    background: rgba(74, 190, 110, 0.08) !important;
    border-color: #4ABE6E !important;
}

/* User message attachments */
.user-msg-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.user-msg-image {
    max-width: 200px;
    max-height: 160px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
}
.user-msg-image:hover { opacity: 0.9; }
.user-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,0.15);
    font-size: 12px;
}

/* Placeholder Cards */
.placeholder-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.placeholder-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Slash Command Menu */
.slash-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.1), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
    z-index: 50;
    padding: 4px;
    animation: slashMenuIn 0.15s ease-out;
}
.slash-menu.hidden { display: none; }

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

.slash-menu-header {
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.slash-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}
.slash-menu-item:hover,
.slash-menu-item.active {
    background: #EDFDF3;
}
.slash-menu-item .cmd {
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
}
.slash-menu-item.active .cmd {
    color: #228547;
}
.slash-menu-item .desc {
    font-size: 12px;
    color: #94a3b8;
    margin-left: 12px;
    white-space: nowrap;
}

/* Dark mode */
.dark .slash-menu {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.35), 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}
.dark .slash-menu-header {
    color: #64748b;
}
.dark .slash-menu-item:hover,
.dark .slash-menu-item.active {
    background: rgba(74, 190, 110, 0.1);
}
.dark .slash-menu-item .cmd {
    color: #e2e8f0;
}
.dark .slash-menu-item.active .cmd {
    color: #4ABE6E;
}
.dark .slash-menu-item .desc {
    color: #64748b;
}

.dark .attach-menu {
    background: #1A1A1A;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 30px -6px rgba(0, 0, 0, 0.35), 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}
.dark .attach-menu-item {
    color: #e2e8f0;
}
.dark .attach-menu-item i {
    color: #94a3b8;
}
.dark .attach-menu-item:hover {
    background: rgba(74, 190, 110, 0.1);
    color: #4ABE6E;
}

/* ============================================================
   Knowledge View
   ============================================================ */

/* Tab toggle */
.knowledge-tab, .memory-tab {
    color: #64748b;
}
.knowledge-tab.active, .memory-tab.active {
    background: #fff;
    color: #334155;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dark .knowledge-tab.active, .dark .memory-tab.active {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* File tree */
.knowledge-tree-group {
    margin-bottom: 2px;
}
.knowledge-tree-group-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border: none;
    background: none;
    transition: background 0.15s, color 0.15s;
    text-transform: capitalize;
}
.knowledge-tree-group-btn:hover {
    background: rgba(0,0,0,0.04);
    color: #334155;
}
.dark .knowledge-tree-group-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.knowledge-tree-group-btn i.chevron {
    font-size: 8px;
    transition: transform 0.15s;
}
.knowledge-tree-group.open > .knowledge-tree-group-btn .chevron {
    transform: rotate(90deg);
}
.knowledge-tree-group-items {
    display: none;
}
.knowledge-tree-group.open > .knowledge-tree-group-items {
    display: block;
}

.knowledge-tree-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 24px;
    border-radius: 6px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.knowledge-tree-file:hover {
    background: rgba(0,0,0,0.04);
    color: #334155;
}
.knowledge-tree-file.active {
    background: #EDFDF3;
    color: #228547;
}

.knowledge-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s;
}
.knowledge-tree-file:hover .knowledge-actions,
.knowledge-tree-group-btn:hover .knowledge-actions,
.knowledge-tree-file:focus-within .knowledge-actions,
.knowledge-tree-group-btn:focus-within .knowledge-actions {
    opacity: 1;
}
.knowledge-action {
    padding: 3px 5px;
    border-radius: 5px;
    color: #94a3b8;
    font-size: 9px;
}
.knowledge-action:hover {
    color: #228547;
    background: rgba(34, 133, 71, 0.08);
}
.knowledge-action.danger:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}
.dark .knowledge-tree-file:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.dark .knowledge-tree-file.active {
    background: rgba(74, 190, 110, 0.1);
    color: #4ABE6E;
}
.knowledge-import-drag-over {
    outline: 2px dashed rgba(74, 190, 110, 0.55);
    outline-offset: 4px;
    border-radius: 14px;
}
#knowledge-dialog-card.knowledge-document-dialog {
    max-width: 760px;
}
#knowledge-document-content {
    min-height: 320px;
    line-height: 1.55;
}

/* Graph legend */
.knowledge-graph-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
    z-index: 10;
}
.knowledge-graph-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.knowledge-graph-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Graph tooltip */
.knowledge-graph-tooltip {
    position: absolute;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 12px;
    color: #334155;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 20;
}
.dark .knowledge-graph-tooltip {
    background: #1A1A1A;
    border-color: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* Config field tooltip */
.cfg-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: #94a3b8;
    cursor: help;
    font-size: 12px;
}
.cfg-tip:hover { color: #64748b; }
.dark .cfg-tip:hover { color: #cbd5e1; }
/* Floating tooltip portal — appended to <body> by JS so it isn't clipped
   by overflow:hidden ancestors. */
.cfg-tip-floating {
    position: fixed;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    background: #1e293b;
    color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    z-index: 9999;
}
.dark .cfg-tip-floating {
    background: #334155;
    color: #f1f5f9;
}
.cfg-tip-floating.show {
    opacity: 1;
}

/* Example cards: equal height via flex stretch + fixed 2-line description area */
.example-card {
    display: flex;
    flex-direction: column;
}
.example-card > p {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;  /* ~2 lines at text-sm leading-relaxed */
}

/* --------------------------------------------------------------------
 * Voice pill — compact custom audio player used by mic uploads and TTS
 * replies. Replaces the bulky native <audio controls> with a play/pause
 * icon + thin progress bar + duration counter so it blends into chat
 * bubbles without the chrome-grey browser default look.
 * ------------------------------------------------------------------ */
.voice-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.05);
    color: rgb(71, 85, 105);
    font-size: 12px;
    line-height: 1;
    max-width: 240px;
    user-select: none;
    cursor: default;
}
.dark .voice-pill {
    background: rgba(255, 255, 255, 0.08);
    color: rgb(203, 213, 225);
}
.voice-pill[data-loading="1"] {
    opacity: 0.65;
}
.voice-pill-btn {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-500, #2563eb);
    color: #fff;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.1s ease;
}
.voice-pill-btn:hover { transform: scale(1.05); }
.voice-pill-btn i { font-size: 9px; margin-left: 1px; }
.voice-pill-btn[data-state="play"] i { margin-left: 2px; }
.voice-pill-btn[data-state="pause"] i { margin-left: 0; }
.voice-pill-track {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.25);
    overflow: hidden;
    min-width: 70px;
}
.dark .voice-pill-track {
    background: rgba(148, 163, 184, 0.25);
}
.voice-pill-fill {
    height: 100%;
    width: 0%;
    background: var(--color-primary-500, #2563eb);
    border-radius: inherit;
    transition: width 0.1s linear;
}
.voice-pill-time {
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    color: inherit;
    opacity: 0.75;
    flex-shrink: 0;
    min-width: 28px;
    text-align: right;
}
.voice-pill audio { display: none; }

/* Send button toggles into a Stop button while an SSE stream is in flight.
   Match the look of the disabled send button (light grey block + white
   glyph) so it reads as the same visual element, just paused/idle from
   sending perspective and clickable to stop. */
#send-btn.send-btn-cancel {
    background-color: rgb(203 213 225) !important; /* slate-300, == disabled send-btn */
    color: white !important;
}
#send-btn.send-btn-cancel:hover {
    background-color: rgb(148 163 184) !important; /* slate-400 */
}
#send-btn.send-btn-cancel:disabled {
    background-color: rgb(226 232 240) !important; /* slate-200, while stop is in flight */
    color: white !important;
    cursor: progress;
}
.dark #send-btn.send-btn-cancel {
    background-color: rgb(71 85 105) !important; /* slate-600, == dark disabled send-btn */
    color: white !important;
}
.dark #send-btn.send-btn-cancel:hover {
    background-color: rgb(100 116 139) !important; /* slate-500 */
}
.dark #send-btn.send-btn-cancel:disabled {
    background-color: rgb(51 65 85) !important; /* slate-700 */
    color: rgb(203 213 225) !important;
}

.agent-cancelled-tag {
    font-style: italic;
}

/* =====================================================================
   Code Block Enhancements
   ===================================================================== */
.code-block-wrapper {
    position: relative;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
}

.dark .code-block-wrapper {
    background: #1e293b;
    border-color: #334155;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
    background: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
    font-size: 0.85em;
}

.dark .code-block-header {
    background: #0f172a;
    border-bottom-color: #334155;
}

.code-block-lang {
    color: #64748b;
    font-weight: 500;
    text-transform: lowercase;
}

.dark .code-block-lang {
    color: #94a3b8;
}

.code-copy-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0.25em 0.5em;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.9em;
}

.code-copy-btn:hover {
    background: rgba(100, 116, 139, 0.1);
    color: #475569;
}

.dark .code-copy-btn {
    color: #94a3b8;
}

.dark .code-copy-btn:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #cbd5e1;
}

.code-block-wrapper pre {
    margin: 0;
    border-radius: 0;
    border: none;
}

/* =====================================================================
   Drag and Drop Overlay
   ===================================================================== */
/* Anchor the absolutely-positioned overlay to the chat view. */
#view-chat {
    position: relative;
}

.drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.1);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.drag-overlay.active {
    opacity: 1;
}

.drag-overlay.hidden {
    display: none;
}

/* =====================================================================
   Finance Approval Ledger
   ===================================================================== */
#view-finance { height: 100%; background: #f5f7f6; color: #24312f; }
.finance-scroll { height: 100%; overflow-y: auto; padding: 28px; }
.finance-page { width: min(1180px, 100%); margin: 0 auto; }
.finance-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.finance-header h2 { margin: 0; color: #176a5e; font-size: 26px; line-height: 1.25; font-weight: 700; letter-spacing: 0; }
.finance-header p { margin: 7px 0 0; color: #637571; font-size: 15px; }
.finance-status { min-height: 36px; display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid #b8d8d1; border-radius: 18px; background: #e8f5f2; color: #176a5e; font-size: 14px; white-space: nowrap; }
.finance-status.error { border-color: #e8c5ba; background: #fff1ec; color: #a4422d; }
.finance-toolbar { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(150px, .7fr) minmax(150px, .7fr) 44px auto; gap: 10px; margin-bottom: 16px; }
.finance-toolbar select, .finance-toolbar input, .finance-toolbar button, .finance-bookkeeping { min-width: 0; height: 44px; padding: 0 12px; border: 1px solid #bfd0cc; border-radius: 8px; outline: none; background: #fff; color: #24312f; font-size: 14px; }
.finance-toolbar select:focus, .finance-toolbar input:focus, .finance-bookkeeping:focus { border-color: #2d8c7c; box-shadow: 0 0 0 3px rgba(45,140,124,.13); }
.finance-toolbar button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; color: #176a5e; font-weight: 700; }
.finance-toolbar .soft-refresh-button {
    width: 44px;
    padding: 0;
    border: 1px solid #e2e7e5;
    border-radius: 9px;
    background: #edf1f0;
    color: #176a5e;
    box-shadow: 4px 4px 9px #c9cecc, -4px -4px 9px #ffffff;
    transition: color .2s, box-shadow .2s, transform .2s;
}
.finance-toolbar .soft-refresh-button:hover { color: #0e594f; transform: translateY(-1px); }
.finance-toolbar .soft-refresh-button:active {
    color: #66736f;
    transform: translateY(0);
    box-shadow: inset 3px 3px 8px #c9cecc, inset -3px -3px 8px #ffffff;
}
.finance-toolbar .soft-refresh-button:focus-visible { outline: 3px solid rgba(45,140,124,.24); outline-offset: 2px; }
.dark .finance-toolbar .soft-refresh-button {
    border-color: #42514d;
    background: #34413e;
    color: #8dd2c5;
    box-shadow: 4px 4px 9px #202a27, -4px -4px 9px #4a5a56;
}
.dark .finance-toolbar .soft-refresh-button:active {
    box-shadow: inset 3px 3px 8px #202a27, inset -3px -3px 8px #4a5a56;
}
#finance-export { border-color: #2d8c7c; background: #2d8c7c; color: #fff; }
.finance-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.finance-metrics > div { min-height: 92px; padding: 16px; border: 1px solid #d5e1de; border-radius: 8px; background: #fff; }
.finance-metrics span { display: block; margin-bottom: 9px; color: #687975; font-size: 13px; }
.finance-metrics strong { color: #24312f; font-size: 22px; font-weight: 700; }
.finance-breakdowns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.finance-breakdown { min-width: 0; padding: 15px 16px; border-top: 2px solid #78a69d; border-bottom: 1px solid #d5e1de; background: #fff; }
.finance-breakdown h3 { margin: 0 0 11px; color: #344641; font-size: 14px; font-weight: 700; }
.finance-breakdown-rows > div, .finance-exception-summary > div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid #edf1f0; font-size: 12px; }
.finance-breakdown-rows span, .finance-exception-summary span { min-width: 0; color: #667773; overflow-wrap: anywhere; }
.finance-breakdown-rows strong, .finance-exception-summary strong { color: #24312f; font-size: 12px; text-align: right; white-space: nowrap; }
.finance-breakdown-rows p { margin: 16px 0; color: #788783; font-size: 12px; }
.finance-table-wrap { overflow-x: auto; border: 1px solid #d5e1de; border-radius: 8px; background: #fff; }
.finance-table { width: 100%; min-width: 980px; border-collapse: collapse; table-layout: fixed; }
.finance-table th { padding: 12px; border-bottom: 1px solid #d5e1de; background: #eef4f2; color: #536660; font-size: 12px; text-align: left; }
.finance-table td { padding: 13px 12px; border-bottom: 1px solid #e5ecea; color: #344641; font-size: 13px; vertical-align: middle; overflow-wrap: anywhere; }
.finance-table tr:last-child td { border-bottom: 0; }
.finance-table td strong, .finance-table td small { display: block; }
.finance-detail-link { display: block; max-width: 100%; padding: 0; border: 0; background: transparent; color: #176a5e; font: inherit; font-weight: 700; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.finance-detail-link:hover { text-decoration: underline; }
.finance-table td small { margin-top: 4px; color: #788783; font-size: 11px; }
.finance-table th:nth-child(1) { width: 138px; } .finance-table th:nth-child(2) { width: 190px; }
.finance-table th:nth-child(3) { width: 180px; } .finance-table th:nth-child(4) { width: 105px; }
.finance-table th:nth-child(5), .finance-table th:nth-child(6) { width: 90px; } .finance-table th:nth-child(7) { width: 90px; } .finance-table th:nth-child(8) { width: 120px; }
.finance-amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.finance-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 8px; border-radius: 13px; background: #edf2f1; color: #536660; white-space: nowrap; }
.finance-pill.approved, .finance-pill.paid { background: #e5f4ef; color: #176a5e; }
.finance-pill.pending_payment, .finance-pill.pending { background: #fff4dc; color: #8a5c12; }
.finance-pill.exception, .finance-pill.rejected { background: #fff0eb; color: #a4422d; }
.finance-bookkeeping { width: 100%; height: 36px; padding: 0 8px; }
.finance-empty { height: 120px; color: #788783 !important; text-align: center; }
.finance-message { min-height: 20px; margin: 10px 0 28px; color: #a4422d; font-size: 13px; }
.finance-detail-modal { position: fixed; inset: 0; z-index: 120; display: flex; justify-content: flex-end; }
.finance-detail-modal.hidden { display: none; }
.finance-detail-backdrop { position: absolute; inset: 0; border: 0; background: rgba(12, 22, 20, .42); cursor: default; }
.finance-detail-panel { position: relative; width: min(680px, 92vw); height: 100%; overflow: hidden; background: #f7f9f8; box-shadow: -12px 0 30px rgba(20, 45, 40, .14); }
.finance-detail-panel > header { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid #d5e1de; background: #fff; }
.finance-detail-panel header span { color: #788783; font-size: 11px; }
.finance-detail-panel h3 { margin: 3px 0 0; color: #24312f; font-size: 19px; letter-spacing: 0; }
#finance-detail-close { width: 40px; height: 40px; border: 1px solid #c9d7d3; border-radius: 8px; background: #fff; color: #536660; cursor: pointer; }
.finance-detail-body { height: calc(100% - 76px); overflow-y: auto; padding: 20px; }
.finance-detail-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 0 0 22px; background: #dce5e2; border: 1px solid #dce5e2; }
.finance-detail-fields > div { min-width: 0; padding: 12px; background: #fff; }
.finance-detail-fields dt { margin-bottom: 5px; color: #788783; font-size: 11px; }
.finance-detail-fields dd { margin: 0; color: #24312f; font-size: 13px; overflow-wrap: anywhere; }
.finance-detail-body section { margin-top: 22px; }
.finance-detail-body h4 { margin: 0 0 10px; color: #344641; font-size: 14px; }
.finance-detail-table { overflow-x: auto; border: 1px solid #d5e1de; background: #fff; }
.finance-detail-table table { width: 100%; min-width: 520px; border-collapse: collapse; }
.finance-detail-table th, .finance-detail-table td { padding: 10px; border-bottom: 1px solid #e5ecea; color: #536660; font-size: 12px; text-align: left; }
.finance-attachments { display: grid; gap: 8px; }
.finance-attachment-link { min-height: 44px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid #d5e1de; border-radius: 8px; background: #fff; color: #176a5e; font-size: 13px; }
.finance-attachment-link span { overflow-wrap: anywhere; }.finance-attachment-link small { color: #788783; }
.finance-detail-empty, .finance-detail-loading, .finance-detail-error { margin: 14px 0; color: #788783; font-size: 13px; }
.finance-detail-error { color: #a4422d; }

@media (max-width: 760px) {
    .finance-scroll { padding: 20px 14px; }
    .finance-header { flex-direction: column; gap: 12px; }
    .finance-header h2 { font-size: 24px; }
    .finance-status { white-space: normal; }
    .finance-toolbar { grid-template-columns: 1fr 1fr; }
    .finance-toolbar select:first-child { grid-column: 1 / -1; }
    #finance-export { grid-column: 1 / -1; }
    .finance-metrics { grid-template-columns: 1fr 1fr; }
    .finance-metrics strong { font-size: 18px; }
    .finance-breakdowns { grid-template-columns: 1fr; }
    .finance-detail-panel { width: 100%; }
    .finance-detail-fields { grid-template-columns: 1fr; }
}

/* =====================================================================
   Order Logistics Lookup
   ===================================================================== */
#view-orders {
    height: 100%;
    background: #f3f8f7;
    color: #213532;
}

.order-view-scroll {
    height: 100%;
    overflow-y: auto;
    padding: 28px;
}

.order-page {
    width: min(1040px, 100%);
    margin: 0 auto;
}

.order-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.order-page-header h2 {
    margin: 0;
    font-size: 26px;
    line-height: 1.25;
    font-weight: 700;
    color: #176a5e;
    letter-spacing: 0;
}

.order-page-header p {
    margin: 7px 0 0;
    color: #637571;
    font-size: 15px;
}

.order-sync-badge {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border: 1px solid #b8d8d1;
    border-radius: 18px;
    background: #e8f5f2;
    color: #176a5e;
    font-size: 14px;
    white-space: nowrap;
}

.order-sync-badge.delayed {
    border-color: #efd1bf;
    background: #fff3e8;
    color: #9b4f39;
}

.order-search-panel {
    padding: 20px;
    border: 1px solid #cfddd9;
    border-radius: 8px;
    background: #fbfefd;
}

.order-query-tabs {
    display: inline-grid;
    grid-template-columns: repeat(4, minmax(82px, 1fr));
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
    background: #e8f0ee;
}

.order-query-tab {
    min-height: 42px;
    padding: 8px 16px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4d625d;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.order-query-tab.active {
    background: #fbfefd;
    color: #176a5e;
    box-shadow: 0 1px 3px rgba(33, 53, 50, 0.12);
}

.order-search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 10px;
    margin-top: 16px;
}

#order-query-input {
    width: 100%;
    height: 50px;
    padding: 0 15px;
    border: 1px solid #b9cec9;
    border-radius: 8px;
    outline: none;
    background: #ffffff;
    color: #213532;
    font-size: 16px;
}

#order-query-input:focus {
    border-color: #2d8c7c;
    box-shadow: 0 0 0 3px rgba(45, 140, 124, 0.14);
}

#order-query-button {
    height: 50px;
    border: 0;
    border-radius: 8px;
    background: #2d8c7c;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

#order-query-button i { margin-right: 7px; }
#order-query-button:hover { background: #176a5e; }
#order-query-button:disabled { opacity: 0.65; cursor: wait; }

.order-query-hint {
    margin: 11px 0 0;
    color: #637571;
    font-size: 13px;
}

.order-query-state {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #637571;
}

.order-query-state i {
    font-size: 28px;
    color: #77a9a0;
}

.order-query-state p { margin: 0; font-size: 16px; }
.order-query-state.error i, .order-query-state.error p { color: #b85b43; }

.order-results {
    display: grid;
    gap: 14px;
    padding: 18px 0 32px;
}
.order-results.hidden, .order-query-state.hidden { display: none; }

.order-result-card {
    border: 1px solid #cfddd9;
    border-radius: 8px;
    background: #fbfefd;
    overflow: hidden;
}

.order-result-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-bottom: 1px solid #dce8e5;
}

.order-result-head h3 {
    margin: 5px 0;
    color: #213532;
    font-size: 17px;
    line-height: 1.45;
    font-weight: 700;
    letter-spacing: 0;
}

.order-result-head p, .order-result-foot {
    margin: 0;
    color: #637571;
    font-size: 13px;
}

.order-store { color: #2d8c7c; font-size: 13px; font-weight: 700; }

.order-status-tag {
    min-width: 72px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 10px;
    border-radius: 16px;
    background: #fff3e8;
    color: #a4523b;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.order-status-tag.shipped { background: #e8f5f2; color: #176a5e; }

.order-package-list { padding: 2px 20px; }
.order-package-row {
    display: grid;
    grid-template-columns: 32px 1fr 1.4fr 1fr 0.8fr;
    gap: 14px;
    align-items: center;
    min-height: 76px;
    padding: 12px 0;
    border-bottom: 1px solid #e3ecea;
}
.order-package-row:last-child { border-bottom: 0; }
.order-package-row > div:not(.order-package-index) { min-width: 0; }
.order-package-row span { display: block; margin-bottom: 4px; color: #637571; font-size: 12px; }
.order-package-row strong { display: block; color: #213532; font-size: 14px; overflow-wrap: anywhere; }
.order-package-index {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eaf6f8;
    color: #176a5e;
    font-size: 13px;
    font-weight: 700;
}
.order-tracking { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.order-no-package { padding: 20px 0; color: #637571; font-size: 14px; }
.order-result-foot { padding: 12px 20px; border-top: 1px solid #dce8e5; background: #f6faf9; }

.order-import-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0 0 32px;
    padding: 18px 20px;
    border: 1px solid #cfddd9;
    border-radius: 8px;
    background: #fbfefd;
}
.order-import-panel.hidden { display: none; }
.order-import-panel h3 { margin: 0; color: #213532; font-size: 16px; font-weight: 700; }
.order-import-panel p { margin: 5px 0 0; color: #637571; font-size: 13px; }
.order-import-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.order-template-link, .order-file-picker, #order-import-button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid #b9cec9;
    border-radius: 8px;
    background: #ffffff;
    color: #176a5e;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
#order-import-button { border-color: #2d8c7c; background: #e8f5f2; }
#order-import-button:disabled { cursor: not-allowed; opacity: 0.5; }
.order-import-result { flex-basis: 100%; text-align: right; }
.order-import-result.error { color: #b85b43; }

.order-account-panel {
    margin: 0 0 32px;
    padding: 20px;
    border: 1px solid #cfddd9;
    border-radius: 8px;
    background: #fbfefd;
}

.order-account-panel.hidden { display: none; }

.order-account-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.order-account-heading h3 {
    margin: 0;
    color: #213532;
    font-size: 17px;
    font-weight: 700;
}

.order-account-heading p {
    margin: 5px 0 0;
    color: #637571;
    font-size: 13px;
}

#order-account-refresh,
.order-account-actions button {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid #b9cec9;
    border-radius: 8px;
    background: #ffffff;
    color: #176a5e;
    cursor: pointer;
}

#order-account-refresh:hover,
.order-account-actions button:hover {
    border-color: #77a9a0;
    background: #e8f5f2;
}

.order-account-actions .account-enable-button {
    width: auto;
    min-width: 96px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.order-account-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.order-account-form input,
.order-account-form select,
#order-account-save {
    width: 100%;
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    border: 1px solid #b9cec9;
    border-radius: 8px;
    outline: none;
    background: #ffffff;
    color: #213532;
    font-size: 14px;
}

.order-account-form input:focus,
.order-account-form select:focus {
    border-color: #2d8c7c;
    box-shadow: 0 0 0 3px rgba(45, 140, 124, 0.14);
}

#order-account-save {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-color: #2d8c7c;
    background: #2d8c7c;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

#order-account-save { min-width: 132px; }

#order-account-save:hover { background: #176a5e; }
.order-account-result { min-height: 20px; margin: 10px 0 0; color: #176a5e; font-size: 13px; }
.order-account-result.error { color: #b85b43; }
.order-account-list { margin-top: 8px; border-top: 1px solid #dce8e5; }

.order-account-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) 104px minmax(180px, 1.4fr) 72px 46px;
    gap: 12px;
    align-items: center;
    min-height: 62px;
    padding: 10px 0;
    border-bottom: 1px solid #e3ecea;
    color: #4d625d;
    font-size: 14px;
}

.order-account-name { color: #213532; font-weight: 700; overflow-wrap: anywhere; }
.order-account-scopes { overflow-wrap: anywhere; }
.account-enabled { color: #176a5e; font-weight: 700; }
.account-disabled { color: #8a9693; font-weight: 600; }
.order-account-actions { display: flex; justify-content: flex-end; }
.order-account-empty { margin: 20px 0 4px; color: #637571; font-size: 14px; text-align: center; }

@media (max-width: 760px) {
    .order-view-scroll { padding: 20px 14px; }
    .order-page-header { flex-direction: column; gap: 12px; }
    .order-page-header h2 { font-size: 24px; }
    .order-sync-badge { white-space: normal; }
    .order-query-tabs { width: 100%; grid-template-columns: repeat(2, 1fr); }
    .order-search-row { grid-template-columns: 1fr; }
    #order-query-button { width: 100%; }
    .order-result-head { flex-direction: column; }
    .order-package-row { grid-template-columns: 32px 1fr; gap: 10px; }
    .order-package-row > div:not(.order-package-index) { grid-column: 2; }
    .order-import-panel { align-items: flex-start; flex-direction: column; }
    .order-import-actions { width: 100%; justify-content: flex-start; }
    .order-import-result { text-align: left; }
    .order-account-panel { padding: 16px; }
    .order-account-form { grid-template-columns: 1fr; }
    #order-account-save { min-height: 46px; }
    .order-account-row {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 7px 12px;
        padding: 14px 0;
    }
    .order-account-row > span { min-width: 0; }
    .order-account-row > span:nth-child(2),
    .order-account-row > span:nth-child(3),
    .order-account-row > span:nth-child(4) { grid-column: 1; }
    .order-account-actions { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
}

.drag-overlay-content {
    background: white;
    border: 3px dashed #3b82f6;
    border-radius: 16px;
    padding: 3em 4em;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: bounce 1s ease infinite;
}

.dark .drag-overlay-content {
    background: #1e293b;
    border-color: #60a5fa;
}

.drag-overlay-content i {
    font-size: 4em;
    color: #3b82f6;
    margin-bottom: 0.5em;
}

.dark .drag-overlay-content i {
    color: #60a5fa;
}

.drag-overlay-content p {
    font-size: 1.5em;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.dark .drag-overlay-content p {
    color: #f1f5f9;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* =====================================================================
   Message Action Buttons
   ===================================================================== */
/* =====================================================================
   After-sales operation video library
   ===================================================================== */
.video-library-shell { min-height: 280px; }
.video-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-items: stretch; }
.after-sales-video-card { display: flex; flex-direction: column; min-width: 0; overflow: hidden; border: 1px solid #e2e8f0; border-radius: 14px; background: linear-gradient(145deg, #fff, #f8fafc); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.after-sales-video-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15,23,42,.10); border-color: #b8d8ca; }
.dark .after-sales-video-card { border-color: rgba(255,255,255,.10); background: linear-gradient(145deg, #1a1a1a, #141414); }
.dark .after-sales-video-card:hover { border-color: rgba(74,190,110,.55); box-shadow: 0 14px 32px rgba(0,0,0,.25); }
.after-sales-video-card.is-deleted { opacity: .72; }
.after-sales-video-thumb { position: relative; display: flex; align-items: center; justify-content: center; min-height: 132px; color: #d1fae5; background: radial-gradient(circle at 30% 20%, rgba(74,190,110,.28), transparent 55%), linear-gradient(135deg, #102a25, #0f172a 70%); }
.after-sales-video-thumb i { font-size: 38px; filter: drop-shadow(0 5px 12px rgba(0,0,0,.25)); }
.after-sales-video-thumb span { position: absolute; right: 10px; top: 10px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 3px 7px; color: #d1fae5; font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(0,0,0,.24); }
.after-sales-video-body { flex: 1; padding: 14px 14px 8px; }
.after-sales-video-body h4 { margin: 0; color: #1e293b; font-size: 14px; font-weight: 700; line-height: 1.35; }
.dark .after-sales-video-body h4 { color: #f1f5f9; }
.after-sales-video-meta, .after-sales-video-version { margin: 6px 0 0; color: #64748b; font-size: 11px; line-height: 1.5; }
.dark .after-sales-video-meta, .dark .after-sales-video-version { color: #94a3b8; }
.after-sales-video-caution { display: flex; gap: 5px; margin: 9px 0 0; color: #a16207; font-size: 11px; line-height: 1.45; }
.dark .after-sales-video-caution { color: #facc15; }
.after-sales-video-caution i { margin-top: 2px; }
.after-sales-video-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 14px; }
.after-sales-video-actions button, .video-primary-btn, .video-secondary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; border-radius: 8px; padding: 7px 10px; font-size: 11px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.after-sales-video-actions button { border: 1px solid #dbe4e1; color: #45625a; background: #fff; }
.after-sales-video-actions button:hover { border-color: #8fc8a6; color: #176a5e; background: #f0fdf4; }
.after-sales-video-actions button.danger { color: #b42318; }
.after-sales-video-actions button.danger:hover { border-color: #f0a5a0; background: #fff5f5; }
.dark .after-sales-video-actions button { border-color: rgba(255,255,255,.12); color: #cbd5e1; background: rgba(255,255,255,.04); }
.dark .after-sales-video-actions button:hover { border-color: rgba(74,190,110,.55); color: #86efac; background: rgba(74,190,110,.10); }
.video-primary-btn { border: 1px solid #3a9f5b; color: #fff; background: #2f9952; }
.video-primary-btn:hover { background: #258447; }
.video-secondary-btn { border: 1px solid #d6e1dd; color: #49655d; background: transparent; }
.video-secondary-btn:hover { border-color: #9acaae; background: #f1faf4; }
.dark .video-secondary-btn { border-color: rgba(255,255,255,.12); color: #cbd5e1; }
.dark .video-secondary-btn:hover { background: rgba(74,190,110,.10); }
.video-filter-input { width: 190px; border: 1px solid #dbe4e1; border-radius: 8px; padding: 7px 10px; color: #334155; background: #f8fafc; font-size: 11px; outline: none; }
.video-filter-input:focus { border-color: #7cc896; box-shadow: 0 0 0 2px rgba(74,190,110,.14); }
.dark .video-filter-input { border-color: rgba(255,255,255,.12); color: #e2e8f0; background: rgba(255,255,255,.05); }
.video-toggle-label { display: inline-flex; align-items: center; gap: 5px; color: #64748b; font-size: 11px; cursor: pointer; user-select: none; }
.dark .video-toggle-label { color: #94a3b8; }
.video-toggle-label input { accent-color: #2f9952; }
.video-status-badge { display: inline-block; vertical-align: 1px; margin-left: 4px; border-radius: 999px; padding: 2px 6px; color: #b42318; background: #fff1f0; font-size: 9px; font-weight: 600; }
.video-library-empty { grid-column: 1 / -1; display: flex; min-height: 160px; align-items: center; justify-content: center; gap: 9px; color: #94a3b8; font-size: 12px; }
.video-library-empty.error { color: #dc2626; }
.video-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.video-form-grid label { display: flex; flex-direction: column; gap: 5px; color: #64748b; font-size: 11px; font-weight: 600; }
.video-form-grid input, .video-form-grid textarea { width: 100%; border: 1px solid #dbe4e1; border-radius: 8px; padding: 8px 10px; color: #334155; background: #f8fafc; font-size: 12px; outline: none; }
.video-form-grid input:focus, .video-form-grid textarea:focus { border-color: #7cc896; box-shadow: 0 0 0 2px rgba(74,190,110,.14); }
.dark .video-form-grid label { color: #94a3b8; }
.dark .video-form-grid input, .dark .video-form-grid textarea { border-color: rgba(255,255,255,.12); color: #e2e8f0; background: rgba(255,255,255,.05); }
.video-form-full { grid-column: 1 / -1; }
.after-sales-video-player { position: relative; width: min(920px, calc(100vw - 32px)); padding: 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 16px; background: #0b1220; box-shadow: 0 20px 60px rgba(0,0,0,.42); }
.after-sales-video-player video { display: block; width: 100%; max-height: 72vh; border-radius: 10px; background: #000; }
.after-sales-video-player-close { position: absolute; z-index: 1; top: 26px; right: 26px; width: 30px; height: 30px; border: 0; border-radius: 999px; color: #fff; background: rgba(0,0,0,.55); cursor: pointer; }
#after-sales-video-player-caption { padding: 10px 2px 0; color: #cbd5e1; font-size: 12px; }
.after-sales-video-audit-table { overflow-x: auto; min-width: 760px; }
.after-sales-video-audit-table .audit-head, .after-sales-video-audit-table .audit-row { display: grid; grid-template-columns: 150px 120px 120px 130px 70px 1fr; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid #e2e8f0; font-size: 11px; }
.after-sales-video-audit-table .audit-head { color: #64748b; font-weight: 700; }
.after-sales-video-audit-table .audit-row { color: #475569; }
.dark .after-sales-video-audit-table .audit-head, .dark .after-sales-video-audit-table .audit-row { border-bottom-color: rgba(255,255,255,.09); color: #cbd5e1; }
@media (max-width: 640px) { .video-library-grid { grid-template-columns: 1fr; } .video-filter-input { width: 100%; } .video-form-grid { grid-template-columns: 1fr; } .video-form-full { grid-column: auto; } }

.edit-msg-btn,
.delete-msg-btn,
.regenerate-msg-btn {
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.user-message-group:hover .edit-msg-btn,
.user-message-group:hover .delete-msg-btn,
.bot-message-group:hover .regenerate-msg-btn {
    opacity: 1;
}

.edit-msg-btn:hover,
.regenerate-msg-btn:hover {
    color: #3b82f6 !important;
}

.delete-msg-btn:hover {
    color: #ef4444 !important;
}

.edit-msg-btn:disabled,
.delete-msg-btn:disabled {
    cursor: not-allowed !important;
    opacity: 0.35 !important;
}
