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

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --surface-alt: #22222f;
  --border: #2e2e3e;
  --text: #e2e2ea;
  --text-muted: #8888a0;
  --primary: #7b61ff;
  --primary-hover: #6a4fff;
  --danger: #e5484d;
  --danger-hover: #d13438;
  --success: #30a46c;
  --warning: #f5a623;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.wallet-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.input-row input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: "SF Mono", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus {
  border-color: var(--primary);
}

.wallet-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-small:hover {
  color: var(--text);
  background: var(--border);
}

.status-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  font-weight: 500;
}

.status-disconnected {
  background: rgba(229, 72, 77, 0.15);
  color: var(--danger);
}

.status-connected {
  background: rgba(48, 164, 108, 0.15);
  color: var(--success);
}

.orders-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.orders-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.orders-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.orders-actions {
  display: flex;
  gap: 0.5rem;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(123, 97, 255, 0.04);
}

.col-check {
  width: 40px;
}

.col-check input,
tbody td:first-child input {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.direction-ask {
  color: var(--danger);
  font-weight: 600;
}

.direction-bid {
  color: var(--success);
  font-weight: 600;
}

.tx-link {
  color: var(--primary);
  text-decoration: none;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8rem;
}

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

.status-section {
  margin-bottom: 1.5rem;
}

.status-panel {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-all;
}

.status-panel.info {
  background: rgba(123, 97, 255, 0.1);
  border: 1px solid rgba(123, 97, 255, 0.25);
  color: var(--text);
}

.status-panel.success {
  background: rgba(48, 164, 108, 0.1);
  border: 1px solid rgba(48, 164, 108, 0.25);
  color: var(--success);
}

.status-panel.error {
  background: rgba(229, 72, 77, 0.1);
  border: 1px solid rgba(229, 72, 77, 0.25);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-mask p {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

footer {
  text-align: center;
  padding: 2rem 0 1rem;
  margin-top: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

footer a {
  color: var(--text);
  text-decoration: underline;
}

@media (max-width: 640px) {
  #app {
    padding: 1rem;
  }

  .input-row {
    flex-direction: column;
  }

  .orders-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  table {
    font-size: 0.8rem;
  }
}
