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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  direction: rtl;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
header {
  text-align: center;
  padding: 40px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 16px;
  margin-bottom: 30px;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
  margin-bottom: 20px;
}

/* Wallet Section */
.wallet-section {
  margin-top: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.btn-wallet {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 14px 32px;
  font-size: 1.1rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
}

.btn-wallet:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(255, 255, 255, 0.2);
}

.btn-wallet.connected {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
}

.wallet-status {
  font-size: 0.95rem;
  opacity: 0.9;
  padding: 8px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

/* Config Panel */
.config-panel {
  background: var(--surface);
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}

.config-panel h2 {
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.token-select option:disabled {
  color: var(--text-muted);
  opacity: 0.5;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 10px;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn-secondary:hover {
  background: #475569;
}

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

.btn-success:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3);
}

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

/* Status Messages */
.status {
  margin-top: 15px;
  padding: 12px 16px;
  border-radius: 8px;
  font-weight: 500;
  display: none;
}

.status.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success);
  color: var(--success);
  display: block;
}

.status.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  display: block;
}

.status.loading {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid var(--primary);
  color: var(--primary);
  display: block;
}

/* Markets Section */
.markets-section {
  background: var(--surface);
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}

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

.section-header h2 {
  font-size: 1.5rem;
}

.actions {
  display: flex;
  gap: 10px;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
}

thead {
  background: var(--surface-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  padding: 16px 12px;
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover {
  background: var(--surface);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px !important;
  font-style: italic;
}

/* Sticky Checkbox Column */
.sticky-col {
  position: sticky;
  right: 0;
  background: var(--surface-light);
  z-index: 5;
  border-left: 2px solid var(--border);
}

tbody .sticky-col {
  background: var(--bg);
}

tbody tr:hover .sticky-col {
  background: var(--surface);
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-planned { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.status-approved { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.status-queued { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.status-executing { background: rgba(99, 102, 241, 0.2); color: #6366f1; }
.status-executed { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.status-failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

/* Countdown Timer */
.countdown {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--warning);
}

.countdown.soon {
  color: var(--error);
  animation: pulse 1s infinite;
}

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

/* Execution Status */
.execution-status {
  background: var(--surface);
  padding: 30px;
  border-radius: 12px;
  margin-bottom: 30px;
  border: 1px solid var(--border);
}

.progress-bar {
  width: 100%;
  height: 40px;
  background: var(--bg);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  margin: 20px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
  transition: width 0.3s ease;
  border-radius: 20px;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.execution-log {
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg);
  padding: 16px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

.log-entry {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  border-right: 3px solid;
}

.log-entry.info { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); }
.log-entry.success { border-color: var(--success); background: rgba(16, 185, 129, 0.1); }
.log-entry.error { border-color: var(--error); background: rgba(239, 68, 68, 0.1); }

/* Stats Panel */
.stats-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border);
  transition: transform 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.stat-value.success {
  color: var(--success);
}

.stat-value.error {
  color: var(--error);
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.8rem;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
  }
  
  .actions {
    flex-wrap: wrap;
  }
  
  .stats-panel {
    grid-template-columns: repeat(2, 1fr);
  }
  
  th, td {
    padding: 10px 8px;
    font-size: 0.9rem;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--surface-light);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}