/* ================================
   Dashboard Styles - Modern & Responsive
   ================================ */

:root {
  --bg-primary: #0a1f44;
  --bg-secondary: #081630;
  --bg-card: #0d2852;
  --text-primary: #00c896;
  --text-secondary: #ffffff;
  --text-muted: #9ba4b5;
  --border-color: #1a3a6b;
  --accent-gold: #ffd700;
  --success: #00c896;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --shadow: rgba(0, 200, 150, 0.15);
  --error-bg: rgba(244, 67, 54, 0.1);
}

[data-theme='light'] {
  --bg-primary: #e8f0f8;
  --bg-secondary: #ffffff;
  --bg-card: #f5f9fc;
  --text-primary: #00a076;
  --text-secondary: #0a1f44;
  --text-muted: #5a6b7f;
  --border-color: #c5d5e8;
  --accent-gold: #d4af37;
  --success: #00c896;
  --danger: #f44336;
  --warning: #ff9800;
  --info: #2196f3;
  --shadow: rgba(10, 31, 68, 0.1);
}

body {
  margin: 0;
  font-family:
    'Segoe UI',
    'Inter',
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-secondary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================================
   Sidebar
   ================================ */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  min-height: 100vh;
  padding: 20px;
  box-sizing: border-box;
  position: fixed;
  left: 0;
  top: 0;
  border-right: 2px solid var(--text-primary);
  transition: transform 0.3s ease;
  z-index: 1000;
}

.sidebar h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 1.5rem;
  letter-spacing: 2px;
}

.sidebar .white {
  color: var(--text-secondary);
}

.sidebar .gold {
  color: var(--accent-gold);
  font-weight: bold;
}

.sidebar nav a {
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: 6px;
  margin: 8px 0;
  transition: 0.2s;
  font-weight: 500;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.1);
}

/* ✅ Update v1.2 - Sidebar Separator */
.sidebar-separator {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: 12px 0;
}

/* ✅ Update v1.2 - Sidebar Hint (App Version) */
.sidebar-hint {
  display: block;
  margin-top: 12px;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  opacity: 0.6;
}

/* ✅ Unified Version Label */
.app-version-label {
  opacity: 0.75;
  font-size: 11px;
  display: inline-block;
  text-align: center;
  margin-top: 6px;
}

/* ================================
   Mode Switch
   ================================ */
.mode-switch {
  margin: 20px 0 40px 0;
  padding: 15px;
  background: rgba(0, 200, 150, 0.05);
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.mode-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  text-align: center;
  font-weight: 600;
}

.mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  text-align: center;
  width: 100%;
}

.mode-btn:hover {
  transform: translateX(5px);
  border-color: var(--text-primary);
}

.mode-btn.active {
  background: var(--text-primary);
  color: var(--bg-secondary);
  border-color: var(--text-primary);
  box-shadow: 0 2px 12px rgba(0, 200, 150, 0.3);
}

.mode-btn[data-mode='demo'].active {
  background: #4caf50;
  border-color: #4caf50;
  box-shadow: 0 2px 12px rgba(76, 175, 80, 0.3);
}

.mode-btn[data-mode='testnet'].active {
  background: #2196f3;
  border-color: #2196f3;
  box-shadow: 0 2px 12px rgba(33, 150, 243, 0.3);
}

.mode-btn[data-mode='live'].active {
  background: #ff5252;
  border-color: #ff5252;
  box-shadow: 0 2px 12px rgba(255, 82, 82, 0.3);
  animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

/* Theme-Toggle Styles sind jetzt zentral in style.css definiert */

/* ================================
   Mobile Menu Toggle
   ================================ */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1001;
  background: var(--text-primary);
  border: none;
  color: var(--bg-secondary);
  font-size: 1.5rem;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
}

/* ================================
   Main Content
   ================================ */
main {
  margin-left: 280px;
  padding: 30px;
  flex: 1;
  max-width: 100%;
  box-sizing: border-box;
}

/* ================================
   Header Section
   ================================ */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 15px;
  position: relative;
}

.header h1 {
  color: var(--text-primary);
  margin: 0;
  font-size: 2rem;
}

/* Bot Status Indicator (Center) */
/* ✅ Update v1.1 - Mobile Optimierung */
.bot-status-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  font-weight: 600;
  font-size: 1.1em;
  padding: 8px 20px;
  border-radius: 50px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px var(--shadow);
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  top: 50%;
  transform: translate(-50%, -50%);
}

.bot-status-indicator.active {
  color: #4caf50;
  border-color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

.bot-status-indicator.inactive {
  color: #ff5252;
  border-color: #ff5252;
  background: rgba(255, 82, 82, 0.1);
}

/* Connection Status Badge (Right) */
.status-badge {
  padding: 8px 20px;
  border-radius: 50px;
  font-weight: bold;
  display: inline-block;
}

.status-badge .active {
  color: var(--success);
  animation: pulse 2s infinite;
}

.status-badge .inactive {
  color: var(--text-muted);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* ================================
   Status Overlay (Connection + Balance)
   ================================ */
.status-overlay {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px auto 25px;
}

.status-overlay #wsStatus {
  min-width: 220px;
  flex: 1 1 240px;
}

.status-overlay .live-balance-panel {
  flex: 0 1 auto;
}

.config-warning {
  width: 100%;
  display: none;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 193, 7, 0.4);
  background: rgba(255, 193, 7, 0.12);
  color: #7a4b00;
  font-size: 0.9rem;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 100%;
}

.config-warning-text {
  flex: 1 1 auto;
}

.config-warning-btn {
  background: #f5c842;
  border: none;
  border-radius: 6px;
  color: #1e1e1e;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}

.config-warning-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ================================
   KPI Cards
   ================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 15px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 2px 8px var(--shadow);
}

.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 20px var(--shadow);
}

.kpi-icon {
  font-size: 2.5rem;
  background: rgba(0, 200, 150, 0.15);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.kpi-content h3 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* [USDC UI UPDATE] Balance-Wert Position angepasst */
.kpi-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--text-primary);
  margin: 5px 0 5px 10px;
}

.kpi-unit {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.kpi-subtext {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ================================
   Controls
   ================================ */
.controls {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 30px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  justify-content: space-between;
}

.control-group {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-secondary {
  background: var(--accent-gold);
  color: var(--bg-primary);
}

.btn-loading {
  cursor: wait;
  opacity: 0.7;
  pointer-events: none;
}

.btn-disabled {
  background: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
}

.form-select {
  padding: 10px 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
}

label {
  color: var(--text-muted);
  font-weight: 500;
}

/* ================================
   Charts Section
   ================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.chart-card {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px var(--shadow);
}

.chart-card h3 {
  color: var(--text-primary);
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.1rem;
}

.chart-container {
  position: relative;
  height: 300px;
}

/* ================================
   Trade Table
   ================================ */
.trade-table {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px var(--shadow);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 15px;
}

.table-header h3 {
  color: var(--text-primary);
  margin: 0;
}

.search-input {
  padding: 8px 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 0.9rem;
  width: 200px;
}

/* Table wrapper styles now handled by .mtx-table-wrapper in style.css */

/* Table styles now handled by .mtx-table in style.css */

/* Table row styles now handled by .mtx-table in style.css */

/* ================================
   Skeleton Loader
   ================================ */
.skeleton-loader {
  padding: 20px;
}

.skeleton-line {
  height: 15px;
  background: linear-gradient(
    90deg,
    var(--border-color) 25%,
    rgba(0, 200, 150, 0.1) 50%,
    var(--border-color) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 10px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    display: block;
  }

  main {
    margin-left: 0;
    padding: 80px 20px 20px 20px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  /* ✅ Update v1.1 - Badge kleiner und repositioniert */
  .bot-status-indicator {
    position: relative;
    left: 0;
    top: 0;
    transform: none;
    font-size: 0.9em;
    padding: 6px 16px;
    margin-top: 10px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .kpi-icon {
    width: 50px;
    height: 50px;
    font-size: 2rem;
  }

  .kpi-value {
    font-size: 1.4rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group {
    width: 100%;
    justify-content: center;
  }

  .btn {
    flex: 1;
    justify-content: center;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 100%;
  }
  
  /* Mobile table adjustments - reset fixed column widths for better scrolling */
  table {
    table-layout: auto;
  }
  
  th:nth-child(1), td:nth-child(1),
  th:nth-child(2), td:nth-child(2),
  th:nth-child(3), td:nth-child(3),
  th:nth-child(4), td:nth-child(4),
  th:nth-child(5), td:nth-child(5),
  th:nth-child(6), td:nth-child(6),
  th:nth-child(7), td:nth-child(7) {
    width: auto;
    min-width: 80px;
  }
  
  th, td {
    padding: 10px 8px;
    font-size: 0.85rem;
  }
  
  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 480px) {
  /* ✅ Update v1.1 - Mobile Schriftgrößen */
  .header h1 {
    font-size: 1.3rem;
  }

  .bot-status-indicator {
    font-size: 0.85em;
    padding: 5px 12px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 15px;
  }

  .kpi-value {
    font-size: 1.3rem;
  }

  /* Table styles now handled by .mtx-table in style.css */
}

/* ================================
   Live Value Animations
   ================================ */
.value-up {
  color: #00ff99 !important;
  animation: flashGreen 1s ease-out;
}

.value-down {
  color: #ff4d4d !important;
  animation: flashRed 1s ease-out;
}

@keyframes flashGreen {
  0% {
    color: #00ff99;
    transform: scale(1.1);
  }
  50% {
    color: #00ff99;
    opacity: 0.9;
  }
  100% {
    color: var(--text-primary);
    transform: scale(1);
  }
}

@keyframes flashRed {
  0% {
    color: #ff4d4d;
    transform: scale(1.1);
  }
  50% {
    color: #ff4d4d;
    opacity: 0.9;
  }
  100% {
    color: var(--text-primary);
    transform: scale(1);
  }
}

.kpi-value {
  transition: all 0.3s ease;
}

/* ================================
   Balance Actions (Deposit/Withdraw)
   ================================ */
.balance-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.btn-deposit,
.btn-withdraw {
  flex: 1;
  padding: 8px 15px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-deposit {
  background: var(--success);
  color: white;
}

.btn-deposit:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 200, 150, 0.4);
}

.btn-withdraw {
  background: var(--accent-gold);
  color: var(--bg-primary);
}

.btn-withdraw:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.btn-deposit:disabled,
.btn-withdraw:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ================================
   Modal
   ================================ */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border: 2px solid var(--text-primary);
  border-radius: 16px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 8px 32px var(--shadow);
  animation: slideInScale 0.3s ease;
}

@keyframes slideInScale {
  from {
    transform: scale(0.9) translateY(-20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

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

.modal-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.4rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.3s ease;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 25px;
}

.modal-body label {
  display: block;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 1rem;
}

.modal-body input {
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  box-sizing: border-box;
  transition: border-color 0.3s ease;
}

.modal-body input:focus {
  outline: none;
  border-color: var(--text-primary);
}

.modal-info {
  margin-top: 15px;
  padding: 12px;
  background: rgba(0, 200, 150, 0.1);
  border: 1px solid var(--text-primary);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 20px 25px;
  border-top: 1px solid var(--border-color);
  justify-content: flex-end;
}

.modal-footer .btn {
  min-width: 120px;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-width: none;
    margin: 0 10px;
  }

  .modal-header h2 {
    font-size: 1.2rem;
  }

  .balance-actions {
    flex-direction: column;
  }

  .btn-deposit,
  .btn-withdraw {
    width: 100%;
  }
}

/* ================================
   Live Balance Panel - v2.0
   ================================ */
.live-balance-panel {
  background: #0b1733;
  color: #e8f0ff;
  padding: 12px 20px;
  border-radius: 12px;
  min-width: 180px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 1rem;
}

.live-balance-panel .indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #11c46a;
  box-shadow: 0 0 6px rgba(17, 196, 106, 0.6);
}

.live-balance-panel .amount {
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 1.1rem;
}

.app-footer {
  text-align: right;
  color: var(--text-muted);
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 24px;
  padding-right: 4px;
}

/* ================================
   Testnet Feed Status & Event Bridge
   ================================ */
.feed-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px 20px;
  margin: 20px 0;
  box-shadow: 0 4px 12px var(--shadow);
}

.feed-status-main {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-weight: 600;
}

.feed-status-label {
  color: var(--text-muted);
  letter-spacing: 1px;
}

.feed-status-mode {
  background: rgba(255, 201, 71, 0.15);
  color: #f5c842;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  border: 1px solid rgba(245, 200, 66, 0.4);
}

.feed-status-mode.live {
  background: rgba(0, 200, 150, 0.15);
  color: var(--success);
  border-color: rgba(0, 200, 150, 0.4);
}

.feed-status-transport {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.feed-status-note {
  margin: 10px 0 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.decision-feed {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 30px;
  box-shadow: 0 4px 12px var(--shadow);
}

.decision-feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.decision-feed-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 10px 0;
}

.decision-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 15px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.decision-item.executed {
  border-color: rgba(0, 200, 150, 0.4);
}

.decision-item.skipped {
  border-color: rgba(255, 193, 7, 0.4);
}

.decision-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 600;
}

.decision-main .symbol {
  font-size: 1rem;
  color: var(--text-secondary);
}

.decision-main .action {
  letter-spacing: 1px;
  color: var(--text-primary);
}

.decision-main .reason {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.decision-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.decision-meta span {
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 6px;
}

/* ================================
   Loading States & Error Feedback v1.9.0-pre
   ================================ */

.loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--text-muted);
  border-top: 2px solid var(--text-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.skeleton-loader {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--border-color) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 4px;
  height: 20px;
  margin: 4px 0;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.error-message {
  background: var(--error-bg);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--danger);
  margin: 8px 0;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.success-message {
  background: rgba(0, 200, 150, 0.1);
  color: var(--success);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid var(--success);
  margin: 8px 0;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease-in;
}

/* ================================
   Responsive Design v1.9.0-pre
   ================================ */

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .kpi-card {
    padding: 16px;
    min-height: 0;
  }

  .kpi-value {
    font-size: 1.8rem;
  }

  .status-overlay {
    flex-direction: column;
    align-items: stretch;
    margin: 12px 0 20px;
  }

  .status-overlay > * {
    flex: 1 1 auto;
  }

  .live-balance-panel {
    min-width: auto;
    font-size: 1rem;
    justify-content: center;
  }

  .btn-deposit,
  .btn-withdraw {
    min-width: 80px;
    padding: 8px 12px;
    font-size: 0.8rem;
    margin: 4px 2px;
  }

  .balance-actions {
    flex-direction: column;
    gap: 4px;
  }

  .chart-container {
    height: 200px;
    margin: 12px 0;
  }

  .trade-table {
    font-size: 0.8rem;
  }

  .trade-table th,
  .trade-table td {
    padding: 6px 4px;
  }

  .error-message,
  .success-message {
    font-size: 0.8rem;
    padding: 6px 10px;
    margin: 6px 0;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .kpi-card {
    padding: 12px;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  .live-balance-panel {
    padding: 6px 10px;
    min-width: auto;
    font-size: 0.85rem;
  }

  .btn-deposit,
  .btn-withdraw {
    min-width: 70px;
    padding: 6px 10px;
    font-size: 0.7rem;
  }

  .chart-container {
    height: 150px;
  }

  .trade-table {
    font-size: 0.7rem;
  }

  .trade-table th,
  .trade-table td {
    padding: 4px 2px;
  }
}

/* Touch-optimierte Buttons */
@media (hover: none) and (pointer: coarse) {
  .btn-deposit,
  .btn-withdraw {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
  }

  .kpi-card {
    padding: 20px;
  }

  .live-balance-panel {
    padding: 12px 16px;
    min-width: 160px;
  }
}

/* ================================
   Lazy Loading Indicators v1.9.0-pre
   ================================ */

.lazy-loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--text-muted);
  border-top: 2px solid var(--text-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 8px;
}

.lazy-loading-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--danger);
  font-size: 0.9rem;
  background: var(--error-bg);
  border-radius: 8px;
  margin: 10px 0;
}

.error-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

/* Lazy-loaded content fade-in */
.lazy-loaded {
  animation: fadeInUp 0.5s ease-out;
}

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

/* ================================
   Mobile Container Hotfix (v2026-02-15)
   Prevent overlap/overflow on narrow screens
   ================================ */

.table-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 220px;
  min-width: 0;
}

.search-input {
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    left: auto;
    right: 12px;
    top: 12px;
    padding: 10px 12px;
    font-size: 1.35rem;
  }

  main {
    padding: 88px 14px 18px;
    overflow-x: hidden;
  }

  .kpi-grid,
  .feed-status-card,
  .controls,
  .charts-grid,
  .decision-feed,
  .trade-table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .table-header {
    align-items: stretch;
  }

  .table-controls {
    width: 100%;
    justify-content: stretch;
    flex-basis: 100%;
  }

  .search-input {
    width: 100%;
    max-width: 100%;
  }

  .control-group {
    justify-content: stretch;
  }

  .control-group .btn,
  .control-group .form-select {
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .controls {
    padding: 14px;
  }

  .control-group {
    flex-direction: column;
    align-items: stretch;
  }

  .control-group .btn,
  .control-group .form-select {
    width: 100%;
  }

  .feed-status-main,
  .feed-status-note,
  .table-header h3 {
    overflow-wrap: anywhere;
  }
}

/* iOS/Small-viewport overflow fix for top dashboard containers */
@media (max-width: 768px) {
  main {
    width: 100%;
    min-width: 0;
  }

  .status-overlay,
  .kpi-grid {
    min-width: 0;
  }

  .status-overlay #wsStatus {
    min-width: 0;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
  }

  .kpi-card,
  .kpi-content {
    min-width: 0;
  }

  .kpi-card {
    padding: 14px;
  }

  .kpi-content h3,
  .kpi-subtext {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 6px;
  }
}

@supports (padding: max(0px)) {
  @media (max-width: 768px) {
    main {
      padding-left: max(14px, env(safe-area-inset-left));
      padding-right: max(14px, env(safe-area-inset-right));
    }
  }
}

/* Global mobile flow normalization (all pages using dashboard.css) */
@media (max-width: 768px) {
  main {
    padding-top: 84px;
    padding-bottom: 16px;
    min-width: 0;
  }

  main > * {
    margin-bottom: 14px !important;
  }

  main > *:last-child {
    margin-bottom: 0 !important;
  }

  .kpi-grid,
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .kpi-card,
  .chart-card,
  .trade-table,
  .coin-list,
  .history-table,
  .filters,
  .feed-status-card,
  .decision-feed,
  .controls {
    padding: 14px !important;
    box-sizing: border-box;
  }

  .controls,
  .control-group,
  .filter-group,
  .filter-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .kpi-card,
  .chart-card,
  .trade-table,
  .coin-list,
  .history-table,
  .filters,
  .feed-status-card,
  .decision-feed,
  .controls {
    padding: 12px !important;
  }
}

/* iPhone-specific tuning */
@supports (-webkit-touch-callout: none) {
  @media screen and (max-width: 430px) {
    html,
    body {
      width: 100%;
      max-width: 100%;
      overflow-x: hidden;
      -webkit-text-size-adjust: 100%;
    }

    .mobile-menu-toggle {
      top: calc(10px + env(safe-area-inset-top));
      right: max(10px, env(safe-area-inset-right));
      left: auto;
      z-index: 1002;
    }

    main {
      width: 100%;
      min-width: 0;
      padding-top: calc(76px + env(safe-area-inset-top));
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
      padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .header {
      gap: 12px;
      margin-bottom: 14px;
    }

    .header h1 {
      font-size: 1.5rem;
      line-height: 1.2;
    }

    .status-overlay,
    .kpi-grid,
    .charts-grid {
      width: 100%;
      max-width: 100%;
      min-width: 0;
    }

    .kpi-grid,
    .charts-grid {
      grid-template-columns: 1fr !important;
      gap: 10px !important;
    }

    .kpi-card,
    .chart-card,
    .trade-table,
    .coin-list,
    .history-table,
    .filters,
    .feed-status-card,
    .decision-feed,
    .controls,
    .settings-section,
    .risk-card,
    .status-card,
    .api-monitor,
    .cooldown-status,
    .card,
    .summary-section,
    .recent-trades-section,
    .system-logs,
    .additional-stats {
      padding: 12px !important;
      border-radius: 10px;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-warning,
    .btn-danger,
    .form-select,
    .search-input,
    .filter-input,
    .filter-select,
    input,
    select,
    textarea {
      font-size: 16px !important; /* avoid Safari auto-zoom on focus */
    }

    .table-header,
    .feed-status-main,
    .status-info,
    .status-item,
    .monitor-item {
      gap: 8px;
    }

    .mtx-table-wrapper {
      width: 100%;
      max-width: 100%;
    }
  }
}
