:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --border: #2a2e38;
  --text: #e6e8eb;
  --muted: #9aa1ac;
  --up: #e5484d;
  --down: #2f9e44;
  --flat: #9aa1ac;
  --halt: #f59f00;
  --accent: #4c6ef5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

header h1 { font-size: 18px; margin: 0; }

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-nav a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}
.header-nav a:hover { text-decoration: underline; }

.header-info {
  display: flex;
  gap: 20px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.cash strong { color: var(--text); font-size: 16px; }

main {
  padding: 24px;
  display: grid;
  gap: 24px;
}

#symbols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}

.symbol-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  transition: border-color 0.3s;
}
.symbol-card.halted {
  border-color: var(--halt);
}

.card-art {
  position: relative;
  height: 90px;
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}
.card-art-type {
  align-self: flex-start;
  background: rgba(0,0,0,0.35);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
}
.card-art-emoji {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 40px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.card-art-name {
  color: white;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.symbol-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.symbol-name { font-size: 16px; margin: 0; }

.reference-note {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 10px;
}

.real-alert {
  display: none;
  font-size: 12px;
  color: var(--halt);
  border: 1px solid var(--halt);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 0 0 10px;
}

.status-badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #2a2e38;
  color: var(--flat);
}
.status-badge.open { background: #16301f; color: var(--down); }
.status-badge.limit-up { background: #3a1c1c; color: var(--up); }
.status-badge.limit-down { background: #1f2a44; color: #74a8ff; }
.status-badge.halted { background: #2a2210; color: var(--halt); }

canvas.chart {
  width: 100%;
  height: 120px;
  background: #10131a;
  border-radius: 6px;
  margin-bottom: 12px;
}

.price-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 12px;
  margin: 0 0 12px 0;
}
.price-info div { display: flex; flex-direction: column; gap: 2px; }
.price-info dt { font-size: 11px; color: var(--muted); }
.price-info dd { margin: 0; font-size: 14px; font-weight: 600; }
.change-pct.up { color: var(--up); }
.change-pct.down { color: var(--down); }

.info-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #2a2e38;
  color: var(--muted);
  font-size: 9px;
  cursor: help;
}

.trade-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.order-type-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
}
.order-type-row label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.order-type-row .option-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.order-type-hint {
  font-size: 10px;
  color: var(--muted);
  margin-left: 18px;
}
.order-inputs {
  display: flex;
  gap: 8px;
}
.trade-form .qty,
.trade-form .limit-price {
  flex: 1;
  background: #10131a;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
}
.trade-form .limit-price:disabled {
  opacity: 0.4;
}
.order-buttons {
  display: flex;
  gap: 8px;
}
.trade-form button {
  flex: 1;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}
.trade-form .buy { background: var(--up); color: white; }
.trade-form .sell { background: var(--down); color: white; }
.trade-form button:disabled { opacity: 0.4; cursor: not-allowed; }

.panel-note {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.orders-table th, .orders-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.orders-table th { color: var(--muted); font-weight: 600; }
.orders-table .cancel-order {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 12px;
}
.orders-table .cancel-order:hover { color: var(--text); border-color: var(--text); }

.error-msg {
  color: var(--up);
  font-size: 12px;
  min-height: 16px;
  margin: 8px 0 0;
}

.halted-note {
  display: none;
  background: #2a2210;
  color: var(--halt);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 8px 0 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.panel h2 { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
#log {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#log li { color: var(--muted); }
#log li strong { color: var(--text); }
