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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #0a0e27;
  color: #e0e6ed;
  overflow: hidden;
}

/* Header */
.header {
  background: linear-gradient(135deg, #1a1f3a 0%, #0f1424 100%);
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #2a3447;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #8b92a7;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #6c757d;
  animation: pulse 2s infinite;
}

.status-indicator.connected {
  background-color: #10b981;
}

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

.price-update-timer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #6bcf7f;
  transition: color 0.3s ease;
}

.timer-label {
  color: #8b92a7;
}

.timer-value {
  font-weight: 600;
  min-width: 20px;
  text-align: center;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.price-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.token-pair {
  font-size: 0.875rem;
  color: #8b92a7;
}

.current-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: #3b82f6;
  min-width: 85px;
  text-align: right;
}

.price-change {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  min-width: 70px;
  text-align: center;
}

.price-change.positive {
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.1);
}

.price-change.negative {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
}

.balance-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 2rem;
  border-left: 1px solid #2a3447;
}

.balance-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.balance-item.sol .balance-value {
  color: #8b5cf6;
}

.balance-item.usdc .balance-value {
  color: #10b981;
}

.balance-item.total {
  padding-left: 0.5rem;
  border-left: 1px solid #2a3447;
}

.balance-label {
  font-size: 1.05rem;
  color: #8b92a7;
}

.balance-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: #e0e6ed;
  min-width: 95px;
  display: inline-block;
  text-align: right;
}

.balance-value.total-value {
  font-size: 1.2rem;
  color: #f59e0b;
  font-weight: 700;
  min-width: 85px;
}

.balance-usd {
  font-size: 0.9rem;
  color: #6b7280;
  min-width: 75px;
  display: inline-block;
  text-align: right;
}

/* Main Container */
.main-container {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Center Panel */
.center-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  justify-content: flex-end;
}

/* Right Sidebar */
.right-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  height: 100%;
}

/* Panel */
.panel {
  background: #161b2e;
  border: 1px solid #2a3447;
  border-radius: 8px;
  padding: 1.25rem;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 1rem;
}

.panel-content {
  font-size: 0.875rem;
  line-height: 1.6;
}

/* Loading */
.loading {
  color: #8b92a7;
  text-align: center;
  padding: 2rem 0;
}

/* Chart Panel */
.chart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.5rem !important;
  margin-bottom: 1rem;
}

.tradingview-widget-container {
  flex: 1;
  overflow: hidden;
  background: #0a0e27;
  border-radius: 6px;
}

#tradingview_widget {
  width: 100%;
  height: 100%;
}

/* Trade History Panel */
.trade-history-panel {
  flex: 0 0 auto;
  height: 21vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.5rem !important;
  position: relative;
}

.clear-history-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: #6b7280;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
  z-index: 10;
}

.clear-history-btn:hover {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

.clear-history-btn:active {
  background: rgba(107, 114, 128, 0.3);
  color: #d1d5db;
}

.trade-history-content {
  flex: 1;
  overflow-y: auto;
  background: #0a0e27;
  border: 1px solid #2a3447;
  border-radius: 4px;
  padding: 0;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.trade-history-content::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

/* Trade History Table */
.trade-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.trade-history-table thead {
  position: sticky;
  top: 0;
  background: #1a1f3a;
  z-index: 1;
}

.trade-history-table th {
  padding: 0.5rem 0.4rem;
  text-align: left;
  font-weight: 600;
  color: #8b92a7;
  border-bottom: 1px solid #2a3447;
  white-space: nowrap;
  font-size: 0.7rem;
}

.trade-history-table th:nth-child(4),
.trade-history-table th:nth-child(5),
.trade-history-table th:nth-child(6),
.trade-history-table th:nth-child(7),
.trade-history-table th:nth-child(8) {
  text-align: right;
}

.trade-history-table td {
  padding: 0.4rem 0.4rem;
  border-bottom: 1px solid #2a3447;
  color: #e0e6ed;
  white-space: nowrap;
}

.trade-row:hover {
  background: rgba(59, 130, 246, 0.05);
}

.trade-row.success {
  border-left: 2px solid #10b981;
}

.trade-row.failed {
  border-left: 2px solid #ef4444;
}

.trade-datetime {
  font-size: 0.7rem;
  color: #8b92a7;
}

.trade-type {
  font-weight: 500;
}

.trade-side.positive {
  color: #10b981;
  font-weight: 600;
}

.trade-side.negative {
  color: #ef4444;
  font-weight: 600;
}

.trade-amount {
  text-align: right;
}

.trade-price {
  text-align: right;
}

.trade-total {
  text-align: right;
  font-weight: 500;
}

.trade-gas {
  text-align: right;
  font-size: 0.7rem;
}

.trade-impact {
  text-align: right;
  color: #f59e0b;
}

.trade-status.success {
  color: #10b981;
}

.trade-status.failed {
  color: #ef4444;
}

.no-trades {
  text-align: center;
  padding: 2rem;
  color: #6b7280;
  font-size: 0.875rem;
}

.tx-link {
  color: #3b82f6;
  text-decoration: none;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
}

.tx-link:hover {
  text-decoration: underline;
}

/* Active Orders Panel */
.active-orders-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}

/* Grid Orders Panel */
.grid-panel {
  flex: 0 0 auto;
  padding: 0.65rem 1.1rem 1.1rem 1.1rem;
}

.grid-panel .panel-title {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  margin-top: 0;
}

.grid-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.grid-row {
  display: grid;
  grid-template-columns: 20px 1fr 1fr 1fr auto;
  gap: 0.3rem;
  align-items: center;
}

.grid-row-label {
  font-size: 0.75rem;
  color: #8b92a7;
  font-weight: 600;
  text-align: left;
}

.grid-input-wrapper {
  position: relative;
  width: 100%;
  min-width: 0;
}

.grid-input-wrapper .input {
  width: 100%;
  padding-right: 1.5rem;
}

.grid-percent {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: #8b92a7;
  pointer-events: none;
}

.grid-create-btn,
.grid-delete-btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.active-orders-panel .panel-title {
  font-size: 0.84rem;
  margin-bottom: 0.6rem;
}

.active-orders {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.no-orders {
  text-align: center;
  padding: 1.5rem;
  color: #6b7280;
  font-size: 0.92rem;
}

.order-entry {
  background: #1a1f3a;
  border: 1px solid #2a3447;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  transition: border-color 0.2s;
}

.order-entry:hover {
  border-color: #3b82f6;
}

.order-single-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.79rem;
}

.order-type {
  font-weight: 600;
  font-size: 0.79rem;
  min-width: 30px;
}

.order-type.positive {
  color: #10b981;
}

.order-type.negative {
  color: #ef4444;
}

.order-amount {
  color: #e0e6ed;
  min-width: 60px;
  font-size: 0.79rem;
}

.order-price {
  color: #eab308;
  min-width: 50px;
  font-size: 0.79rem;
  font-weight: 600;
}

.order-estimated {
  color: #6b7280;
  font-size: 0.74rem;
  min-width: 45px;
}

.order-delta {
  min-width: 50px;
  font-size: 0.74rem;
  text-align: center;
}

.btn-cancel {
  background: transparent;
  border: none;
  color: #ef4444;
  font-size: 0.89rem;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
  margin-left: 0;
  flex-shrink: 0;
}

.btn-cancel:hover {
  background-color: rgba(239, 68, 68, 0.1);
}

/* Swap Panel */
.swap-panel .panel-title,
.limit-panel .panel-title {
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  margin-top: 0;
}

.swap-panel {
  padding: 0.65rem 1.1rem 1.1rem 1.1rem;
}

.limit-panel {
  padding: 0.65rem 1.1rem 1.1rem 1.1rem;
}

.swap-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Limit Orders Grid */
.limit-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.limit-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
  min-width: 0;
}

.limit-column .input {
  width: 100%;
  min-width: 0;
}

.limit-column .input-row {
  width: 100%;
  min-width: 0;
}

.input-group,
.input-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input {
  background: #0a0e27;
  border: 1px solid #2a3447;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: #3b82f6;
}

.input::placeholder {
  color: #6b7280;
}

/* Убираем стрелочки у input number */
.input[type="number"]::-webkit-inner-spin-button,
.input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input[type="number"] {
  -moz-appearance: textfield;
}

.input-suffix {
  font-size: 0.75rem;
  color: #8b92a7;
  padding-left: 0.5rem;
}

.swap-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: #374151;
  color: #e0e6ed;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-success {
  background: #10b981;
  color: #fff;
  opacity: 0.5;
}

.btn-success:hover {
  background: #059669;
  opacity: 0.7;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
  opacity: 0.5;
}

.btn-danger:hover {
  background: #dc2626;
  opacity: 0.7;
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
}

.swap-btn {
  width: 100%;
}

/* Active Orders */
.active-orders {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

.no-orders {
  color: #6b7280;
  text-align: center;
  padding: 2rem 0;
  font-size: 0.875rem;
}

.order-item {
  background: #0a0e27;
  border: 1px solid #2a3447;
  border-radius: 6px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-type {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.order-type.buy {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.order-type.sell {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.order-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.order-detail {
  display: flex;
  justify-content: space-between;
}

.order-label {
  color: #8b92a7;
}

.order-value {
  color: #e0e6ed;
  font-weight: 600;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: #161b2e;
  border: 1px solid #2a3447;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #2a3447;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #8b92a7;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.modal-close:hover {
  background: #2a3447;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid #2a3447;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #e0e6ed;
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  background: #0a0e27;
  border: 1px solid #2a3447;
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.875rem;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: #3b82f6;
}

.form-help {
  display: block;
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

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

::-webkit-scrollbar-track {
  background: #0a0e27;
}

::-webkit-scrollbar-thumb {
  background: #2a3447;
  border-radius: 4px;
}

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

/* Responsive */
@media (max-width: 1600px) {
  .top-row {
    grid-template-columns: 1fr 1.5fr 1fr;
  }
}

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

  .market-panel,
  .portfolio-panel,
  .config-panel {
    max-height: none;
  }
}

@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
  }

  .right-sidebar {
    grid-row: 1;
  }
}

/* Refresh Button */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-refresh {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    color: #e2e8f0;
    background: rgba(148, 163, 184, 0.1);
}

.btn-refresh:active {
    transform: rotate(180deg);
}

.btn-refresh svg {
    transition: transform 0.3s ease;
}

.btn-refresh:hover svg {
    transform: rotate(180deg);
}


/* Force header content to single line */
.header {
  flex-wrap: nowrap;
  overflow: hidden;
}

.header-left {
  flex-wrap: nowrap;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-center {
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
}

.price-info {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.balance-info {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.balance-item {
  flex-wrap: nowrap;
  white-space: nowrap;
}

