:root {
  --bg-dark: #0a0e17;
  --bg-card: #121826;
  --bg-card-hover: #1a2234;
  --bg-subtle: #1e293b;
  --border-color: #26344d;
  --border-light: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --terminal-bg: #030712;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-mono: 'Fira Code', monospace;
}

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

body.dark-theme {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 320px;
  min-width: 320px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  user-select: none;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  font-size: 24px;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: #fff;
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.host-pill {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; box-shadow: 0 0 14px var(--accent-emerald); }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Telemetry Panel */
.telemetry-panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.panel-header h3, .actions-panel h3 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.refresh-time {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.stat-card {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.stat-card.mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-val {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.cpu-bar { background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue)); }
.ram-bar { background: linear-gradient(90deg, var(--accent-emerald), #10b981); }
.disk-bar { background: linear-gradient(90deg, var(--accent-amber), var(--accent-rose)); }

.stat-sub {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.docker-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Quick Actions */
.actions-panel {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.quick-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-light);
  transform: translateX(2px);
}

.btn-icon {
  font-size: 16px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
}

.telegram-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.telegram-pill:hover {
  background: var(--bg-subtle);
}

.tg-icon {
  font-size: 18px;
}

.tg-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tg-title {
  font-size: 11px;
  font-weight: 600;
}

.tg-sub {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-amber);
}

.status-indicator-dot.online {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.settings-btn {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.settings-btn:hover {
  background: var(--bg-subtle);
}

/* Chat Main Area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
  position: relative;
}

.chat-header {
  height: 60px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-card);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.status-chip {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.header-right {
  display: flex;
  gap: 10px;
}

.header-action-btn {
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.header-action-btn:hover {
  background: var(--bg-card-hover);
}

.header-action-btn.primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
}

/* Chat Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.system-welcome {
  margin: 30px auto;
  max-width: 680px;
  text-align: center;
  padding: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.welcome-badge {
  display: inline-block;
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.system-welcome h2 {
  font-size: 22px;
  margin-bottom: 10px;
}

.system-welcome p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

/* Message bubbles */
.msg-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

.msg-row.user {
  align-items: flex-end;
}

.msg-row.assistant {
  align-items: flex-start;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.6;
  max-width: 100%;
}

.msg-row.user .msg-bubble {
  background: #1e3a8a;
  color: #eff6ff;
  border-bottom-right-radius: 2px;
}

.msg-row.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 2px;
  width: 100%;
}

.msg-bubble pre {
  background: var(--terminal-bg);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 10px 0;
}

.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 4px;
  border-radius: 3px;
}

.msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  text-align: left;
}

.msg-bubble th {
  background: var(--bg-subtle);
}

/* Tool execution steps display */
.tool-step-card {
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  overflow: hidden;
  width: 100%;
}

.tool-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-subtle);
  cursor: pointer;
  user-select: none;
}

.tool-step-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tool-name-badge {
  background: #0369a1;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.tool-args-preview {
  color: var(--text-muted);
  max-width: 450px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-step-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-exit-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.tool-exit-badge.success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.tool-exit-badge.fail {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

.tool-terminal {
  background: var(--terminal-bg);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e2e8f0;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid var(--border-color);
  white-space: pre-wrap;
  word-break: break-all;
}

/* Chat Input Bar */
.chat-input-wrapper {
  padding: 16px 30px 20px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  transition: border-color 0.2s;
  max-width: 820px;
  margin: 0 auto;
}

.input-box:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  max-height: 160px;
}

.send-btn {
  background: var(--accent-blue);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
}

.send-btn:hover {
  opacity: 0.9;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  max-width: 820px;
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-card.wide {
  max-width: 620px;
}

.modal-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

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

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 18px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent-blue);
}

.preset-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.preset-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  cursor: pointer;
}

.preset-chip:hover {
  border-color: var(--accent-cyan);
}

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

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

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn.primary {
  background: var(--accent-blue);
  color: #fff;
}

.btn.secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-color);
}

.tg-card {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.tg-status-row {
  display: flex;
  justify-content: space-between;
}

.copy-input-row {
  display: flex;
  gap: 8px;
}
