/* --- Command Center (Floating Observability) --- */
/* Optimized for Figma-like motion and interaction */
.aisin-command-center {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 400px;
    will-change: width, height, top, left, border-radius, transform;
}
.aisin-command-center:not(.minimized) {
    /* min-width and min-height are managed by JS AisinWindow instance */
}

/* During drag: disable transitions to avoid rubber-banding */
.aisin-command-center.dragging, .aisin-command-center.resizing {
    transition: none !important;
}

/* Hide body with a separate fade/slide to avoid layout fights */
.aisin-command-center .acc-body {
    transition: opacity 300ms var(--ease-smooth), transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
    transform-origin: top right;
    opacity: 1;
    overflow: auto;
}

.aisin-command-center.minimized .acc-body {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translate(20px, -20px);
}

.acc-donuts-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 4px;
}

.acc-donut-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease, background 0.2s ease;
}

.acc-donut-card:hover {
    background: var(--card-bg-hover);
    transform: translateY(-2px);
}

.acc-label-xs {
    font-size: 8px;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.acc-donut-wrap {
    position: relative;
    width: 100px;
    height: 100px;
}

.acc-donut-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.acc-donut-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 4.5;
}

body.theme-light .acc-donut-track {
    stroke: rgba(0, 0, 0, 0.05);
}

.acc-donut-slice {
    fill: none;
    stroke-width: 4.5;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.acc-donut-out { stroke: var(--accent-orange); }
.acc-donut-in { stroke: var(--accent-blue); }
.acc-donut-cached { 
    stroke: rgba(61, 214, 255, 0.9); 
    stroke-width: 1;
}

.acc-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.acc-donut-val {
    font-size: 11px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    line-height: 1;
}

.acc-donut-sub {
    font-size: 8px;
    color: var(--text-dim);
    font-weight: 600;
    margin-top: 1px;
}

.acc-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.acc-status-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 10px 12px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.acc-status-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.acc-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.acc-card-mini {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 10px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 85px;
}

.acc-label-sm {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.acc-coverage-container {
    position: relative;
    height: 44px;
    width: 44px;
    margin: 0 auto;
}

.acc-value-sm {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%);
    font-size: 11px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    pointer-events: none;
    color: var(--text-primary);
}

.acc-cost-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
}

.acc-header {
    transition: padding 260ms cubic-bezier(0.22, 1, 0.36, 1), background-color 260ms var(--ease-smooth), border-color 260ms var(--ease-smooth), opacity 300ms;
}

/* Provide a safe, always-clickable restore target */
.aisin-command-center.minimized::after {
    content: "";
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.92);
    pointer-events: none;
    transition: opacity 300ms;
    opacity: 1;
}

body.theme-light .aisin-command-center.minimized::after {
    color: var(--accent-blue-2);
}

.aisin-command-center:not(.minimized)::after {
    opacity: 0;
}

.acc-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.acc-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.acc-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.acc-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.acc-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.acc-dot.idle { background: #10b981; box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
.acc-dot.syncing { background: var(--accent-blue); box-shadow: 0 0 10px var(--accent-blue); animation: acc-sync-pulse 1s infinite alternate; }
.acc-dot.dirty { background: var(--accent-orange); box-shadow: 0 0 10px var(--accent-orange); }
.acc-dot.error { background: #ef4444; box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }

@keyframes acc-sync-pulse {
    from { opacity: 0.5; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1.1); }
}

.acc-status-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.02em;
}

.acc-subtext {
    font-size: 11px;
    color: var(--text-secondary);
    padding-left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-op-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.3s var(--ease-smooth);
}

.acc-op-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
}

.acc-view-logs-btn {
    margin-left: auto;
    background: rgba(47, 129, 255, 0.12);
    color: var(--accent-blue-2);
    border: 1px solid rgba(47, 129, 255, 0.2);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: url(https://www.lovart.ai/assets/pointer-hand-mini.png) 0 0, auto;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}
.acc-view-logs-btn:hover {
    background: rgba(47, 129, 255, 0.2);
    border-color: rgba(47, 129, 255, 0.4);
    transform: translateY(-1px);
}
.acc-view-logs-btn:active {
    transform: translateY(0);
}

.acc-round-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    font-weight: 800;
    color: var(--accent-blue-2);
    background: rgba(61, 214, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.acc-phase-badge {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.acc-phase-badge.executing {
    color: var(--accent-orange);
    background: rgba(255, 106, 26, 0.1);
}

.acc-phase-badge.thinking {
    color: var(--accent-blue);
    background: rgba(47, 129, 255, 0.1);
}

.acc-phase-badge.reading {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.acc-phase-badge.writing {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.acc-op-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-op-title.active {
    color: var(--text-primary);
}

.acc-op-details {
    font-size: 11px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-op-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.acc-stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.acc-stat-label {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
}

.acc-stat-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.acc-tool-pill {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    transition: all 0.3s var(--ease-smooth);
}
.acc-tool-pill.active {
    background: rgba(255, 106, 26, 0.15);
    border-color: rgba(255, 106, 26, 0.4);
    color: var(--accent-orange);
    text-shadow: 0 0 8px rgba(255, 106, 26, 0.3);
}

.acc-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.acc-col { flex: 1; }

.acc-value {
    font-size: 18px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.acc-sub-value {
    font-size: 10px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 1px;
    opacity: 0.8;
}

.acc-progress-track {
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
    border: 1px solid rgba(255,255,255,0.02);
}

.acc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-2));
    box-shadow: 0 0 10px rgba(47, 129, 255, 0.4);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.acc-chart-container {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--card-border);
    padding: 8px;
    position: relative;
}

.acc-token-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.acc-token-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.acc-token-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-dim);
}

.acc-token-val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
}

.pulse-highlight {
    animation: acc-highlight 0.6s var(--ease-smooth);
}

@keyframes acc-highlight {
    0% { color: var(--accent-blue-2); text-shadow: 0 0 12px var(--accent-blue-2); transform: translateY(-1px); }
    100% { color: inherit; text-shadow: none; transform: translateY(0); }
}

/* --- Model pricing tooltip (dashboard hover) --- */
.model-price-tooltip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 260px;
    max-width: 340px;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: rgba(12, 14, 20, 0.92);
    color: var(--text-primary);
    box-shadow: 0 18px 60px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 2100;
}

body.theme-light .model-price-tooltip {
    background: rgba(255, 255, 255, 0.92);
}

.model-price-tooltip[hidden] {
    display: none;
}

.model-price-tooltip::before {
    content: "";
    position: absolute;
    top: -6px;
    right: 14px;
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    background: inherit;
}

.mpt-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.mpt-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.mpt-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}

body.theme-light .mpt-row {
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.06);
}

.mpt-row span:first-child {
    font-size: 11px;
    color: var(--text-secondary);
}

.mpt-row span:last-child {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Scribe Sync Toggle Switch */
.aisin-switch {
  position: relative;
  display: inline-block;
  width: 28px;
  height: 16px;
  cursor: pointer;
}

.aisin-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.aisin-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s var(--ease-smooth);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.theme-light .aisin-slider {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}

.aisin-slider:before {
  position: absolute;
  content: "";
  height: 10px;
  width: 10px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-dim);
  transition: .3s var(--ease-smooth);
  border-radius: 50%;
}

input:checked + .aisin-slider {
  background-color: rgba(47, 129, 255, 0.2);
  border-color: rgba(47, 129, 255, 0.4);
}

input:checked + .aisin-slider:before {
  transform: translateX(12px);
  background-color: var(--accent-blue-2);
  box-shadow: 0 0 8px var(--accent-blue-2);
}

.acc-sync-toggle-wrapper:hover .aisin-slider {
  border-color: rgba(255, 255, 255, 0.2);
}

body.theme-light .acc-sync-toggle-wrapper:hover .aisin-slider {
  border-color: rgba(0, 0, 0, 0.2);
}


.mpt-foot {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Donut layout */
.usage-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    justify-items: center;
}

.usage-donut {
    position: relative;
    width: 100%;
    height: 86px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.usage-donut .donut {
    width: 120px;
    height: 120px;
    display: block;
    transform: rotate(-90deg);
}

.donut-track {
    fill: none;
    stroke: rgba(255,255,255,0.10);
    stroke-width: var(--usage-donut-stroke, 6);
}

body.theme-light .donut-track {
    stroke: rgba(15, 23, 42, 0.12);
}

.donut-slice {
    fill: none;
    stroke-width: var(--usage-donut-stroke, 6);
    stroke-linecap: round;
    transition: stroke-dasharray 300ms var(--ease-smooth), stroke-dashoffset 300ms var(--ease-smooth), opacity 180ms var(--ease-smooth);
    opacity: 0.95;
}

.donut-output { stroke: var(--accent-orange); stroke-width: var(--usage-donut-output-stroke, 6); }
.donut-input { stroke: var(--accent-blue); stroke-width: var(--usage-donut-input-stroke, 6); }
.donut-cached {
    stroke: rgba(61, 214, 255, 0.92);
    stroke-width: var(--usage-donut-cached-stroke, 3.5);
    opacity: 0.95;
}

.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
}

.donut-total {
    font-size: 14px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    line-height: 1.1;
}

.donut-sub {
    font-size: 11px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* Tooltip */
.usage-tooltip {
    flex-direction: column;
    gap: 10px;
    position: absolute;
    top: 150px;
    width: 230px;
    padding: 10px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(10, 12, 16, 0.86);
    color: var(--text-primary);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 60;
}
#usage-last-donut .usage-tooltip {
    right: -120px;
}
#usage-conv-donut .usage-tooltip {
    right: 80px;
}

body.theme-light .usage-tooltip {
    background: rgba(255, 255, 255, 0.92);
}

.usage-tooltip[hidden] {
    display: none;
}

.ut-title {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.ut-row {
    display: flex;
    position: relative;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 12px;
    font-weight: bold;
}
.usage-bar-inner {
    height: 100%;
    transition: width 0.25s var(--ease-smooth);
    position: absolute;
    top: 0;
    left: 0;
    border-radius: var(--radius-sm);
}
.usage-bar-inner.usage-in {
    background: linear-gradient(90deg, rgb(47, 129, 255, 0.55), rgb(47, 129, 255, 0.25));
}
.usage-bar-inner.usage-cached {
    background: linear-gradient(90deg, rgba(61, 214, 255, 0.55), rgba(61, 214, 255, 0.25));
}
.usage-bar-inner.usage-out {
    background: linear-gradient(90deg, rgba(234, 88, 12, 0.55), rgba(234, 88, 12, 0.25));
}

body.theme-light .ut-row {
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.06);
}

.ut-row span:first-child {
    color: var(--text-secondary);
}

.ut-row span:last-child {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* Hover shows tooltip */
.usage-donut:hover .usage-tooltip,
.usage-donut:focus-within .usage-tooltip {
    display: flex;
}

.usage-kpis { display: none; }

.kpi { display: none; }

.kpi-label { display: none; }

.kpi-value { display: none; }

.usage-meta {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.usage-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.usage-actions .toolbar-btn {
    padding: 5px 10px;
    font-size: 11px;
}

.log-entry.hidden { display: none; }

#logs {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    font-family: 'Fira Code', ui-monospace, monospace;
    max-height: calc(100vh - 200px);
}

/* keep log header tools readable */
