/* ============================================
   SMTM Control Panel - Modern Design System
   Glassmorphism + 3D Depth + Microinteractions
   ============================================ */

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

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Header
   ============================================ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 74px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

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

.brand-mark {
  display: block;
  width: 12px;
  height: 36px;
  border-radius: 2px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--aqua) 100%);
  box-shadow: 0 2px 8px rgba(0, 162, 173, 0.25);
  animation: pulse-glow 3s ease-in-out infinite;
  /* Zelena 30% fill (opacity 0.3 za transparency) */
  opacity: 0.3;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(0, 162, 173, 0.25); }
  50% { box-shadow: 0 2px 12px rgba(0, 162, 173, 0.45); }
}

.eyebrow {
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 800;
  margin: 0 0 5px;
}

h1 {
  font-size: 19px;
  line-height: 1.1;
  font-weight: 700;
  margin: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 600;
  margin: 0;
}

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

.timestamp {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.badge {
  border-radius: 5px;
  font-size: 10px;
  line-height: 1;
  padding: 7px 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.badge-neutral {
  background: #e8edef;
  color: #4b5c65;
}

.badge-pass {
  background: var(--soft-teal);
  color: var(--teal);
}

.badge-block {
  background: var(--soft-red);
  color: var(--red);
}

.badge-watch {
  background: var(--soft-amber);
  color: var(--amber);
}

.icon-command {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 0 12px;
  font: 600 12px 'Manrope', sans-serif;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.icon-command:hover {
  border-color: var(--teal);
  color: var(--teal);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 125, 134, 0.15);
}

.icon-command:active {
  transform: translateY(0);
}

.icon-command svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Main Content
   ============================================ */

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

/* ============================================
   Health Overview - Glassmorphism Cards
   ============================================ */

.health-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.health-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(217, 225, 228, 0.5);
  border-radius: 12px;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.health-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--aqua));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.health-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 162, 173, 0.3);
}

.health-card:hover::before {
  opacity: 1;
}

.health-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--soft-teal) 0%, rgba(224, 243, 244, 0.4) 100%);
  color: var(--teal);
  transition: all 0.3s ease;
}

.health-card:hover .health-icon {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 162, 173, 0.2);
}

.health-icon svg {
  width: 24px;
  height: 24px;
}

.health-icon-tasks {
  background: linear-gradient(135deg, var(--soft-teal) 0%, rgba(224, 243, 244, 0.4) 100%);
  color: var(--teal);
}

.health-icon-layers {
  background: linear-gradient(135deg, var(--soft-amber) 0%, rgba(255, 243, 217, 0.4) 100%);
  color: var(--amber);
}

.health-icon-ibkr {
  background: linear-gradient(135deg, #e6f4ec 0%, rgba(230, 244, 236, 0.4) 100%);
  color: var(--green);
}

.health-icon-trades {
  background: linear-gradient(135deg, var(--soft-red) 0%, rgba(252, 233, 233, 0.4) 100%);
  color: var(--red);
}

.health-card p {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.health-card strong {
  display: block;
  font: 600 20px 'DM Mono', monospace;
  margin-bottom: 4px;
  color: var(--ink);
}

.health-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

/* ============================================
   Panel System
   ============================================ */

.panel {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(217, 225, 228, 0.5);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
}

.panel:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.wide-panel {
  margin-bottom: 24px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(217, 225, 228, 0.4);
}

.hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
  font-weight: 400;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 0 12px;
  font: 600 11px 'Manrope', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.action-btn:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.action-btn-success {
  border-color: var(--green);
  color: var(--green);
}

.action-btn-success:not(:disabled):hover {
  background: var(--green);
  color: #fff;
}

.action-btn-warning {
  border-color: var(--amber);
  color: var(--amber);
}

.action-btn-warning:not(:disabled):hover {
  background: var(--amber);
  color: #fff;
}

.action-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   Task Grid - 3D Depth
   ============================================ */

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

.task-card {
  position: relative;
  padding: 16px;
  background: linear-gradient(135deg, #fff 0%, #f9fbfb 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.06),
    0 8px 16px -8px rgba(0, 0, 0, 0.04);
}

.task-card:hover {
  transform: translateY(-2px) translateZ(10px);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 16px 32px -12px rgba(0, 125, 134, 0.12);
  border-color: var(--aqua);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.task-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.task-state-badge {
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.task-state-running {
  background: var(--soft-teal);
  color: var(--teal);
}

.task-state-ready {
  background: #e6f4ec;
  color: var(--green);
}

.task-state-stopped {
  background: var(--soft-red);
  color: var(--red);
}

.task-description {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.task-controls {
  display: flex;
  gap: 6px;
}

.task-btn {
  flex: 1;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 5px;
  font: 600 10px 'Manrope', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.task-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  transform: scale(1.02);
}

/* Filled button states - 30% zelena fill */
.task-btn-filled {
  background: rgba(0, 162, 173, 0.3) !important;
  border-color: var(--teal) !important;
  color: var(--ink) !important;
  font-weight: 700;
}

.task-btn-filled:hover {
  background: rgba(0, 162, 173, 0.4) !important;
  transform: scale(1.05);
}

.task-btn svg {
  width: 12px;
  height: 12px;
}

/* ============================================
   Layers Accordion - Smooth Animations
   ============================================ */

.layers-accordion {
  display: grid;
  gap: 8px;
}

.layer-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.layer-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.layer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.layer-header:hover {
  background: #f9fbfb;
}

.layer-indicator {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.layer-indicator-pass {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 89, 0.15);
}

.layer-indicator-block {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(187, 63, 69, 0.15);
  animation: pulse-block 2s ease-in-out infinite;
}

.layer-indicator-watch {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(155, 107, 0, 0.15);
}

@keyframes pulse-block {
  0%, 100% { box-shadow: 0 0 0 3px rgba(187, 63, 69, 0.15); }
  50% { box-shadow: 0 0 0 5px rgba(187, 63, 69, 0.25); }
}

.layer-info {
  flex: 1;
  min-width: 0;
}

.layer-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 3px;
}

.layer-status {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-toggle {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  font: 700 14px 'DM Mono', monospace;
  transition: transform 0.3s ease;
}

.layer-item-open .layer-toggle {
  transform: rotate(45deg);
}

.layer-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.layer-item-open .layer-content {
  max-height: 1000px;
}

.layer-detail {
  padding: 16px;
  background: #f7fafb;
  border-top: 1px solid var(--line);
}

.layer-detail-text {
  font-size: 11px;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 8px;
}

.layer-next-action {
  padding: 10px 12px;
  background: rgba(0, 162, 173, 0.05);
  border-left: 3px solid var(--teal);
  border-radius: 5px;
  font-size: 11px;
  color: var(--ink);
  line-height: 1.4;
}

/* ============================================
   Work Grids
   ============================================ */

.work-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

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

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

/* ============================================
   Quick Actions
   ============================================ */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, #fff 0%, #f9fbfb 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 600 12px 'Manrope', sans-serif;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.quick-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 125, 134, 0.12);
  border-color: var(--teal);
  color: var(--teal);
}

.quick-action-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ============================================
   System Logs
   ============================================ */

.system-logs {
  max-height: 240px;
  overflow-y: auto;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.log-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(217, 225, 228, 0.3);
}

.log-entry:last-child {
  border-bottom: 0;
}

.log-time {
  color: var(--slate);
}

.log-message {
  color: var(--ink);
}

/* ============================================
   Charts
   ============================================ */

.chart-canvas-frame {
  position: relative;
  width: 100%;
  height: 260px;
}

canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ============================================
   Blockers List
   ============================================ */

.blockers-list {
  display: grid;
  gap: 12px;
}

.blocker-card {
  padding: 14px;
  background: var(--soft-red);
  border-left: 3px solid var(--red);
  border-radius: 6px;
}

.blocker-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 6px;
}

.blocker-detail {
  font-size: 11px;
  color: var(--ink);
  line-height: 1.4;
}

/* ============================================
   Footer
   ============================================ */

footer {
  border-top: 1px solid var(--line);
  padding: 20px 32px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
}

footer a {
  color: var(--teal);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--aqua);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 14px 18px;
    flex-direction: column;
    align-items: flex-start;
  }

  .header-state {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: 16px;
  }

  .health-overview {
    grid-template-columns: 1fr;
  }

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

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

  .quick-actions {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Accessibility
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   Loading States
   ============================================ */

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

.loading-skeleton {
  background: linear-gradient(
    90deg,
    #f0f2f3 25%,
    #e4e8ea 50%,
    #f0f2f3 75%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: 4px;
}
