:root {
  --bg: #14181f;
  --surface: #1c2230;
  --border: #454e60;
  --text: #e7ebf3;
  --text-sub: #9aa5b8;
  --accent: #4c8dff;
  --accent-hover: #6ea1ff;
  --ok-bg: #103322;
  --ok-border: #1e5c3a;
  --err-bg: #3a1414;
  --err-border: #7a2323;
  --err-text: #ff6b6b;
  --loading-bg: #3a331a;
}
* { box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.2;
  font-size: 20px;
  font-weight: bold;
}
.container {
  padding: 0;
  height: 100vh;
  height: 100dvh; /* モバイルのアドレスバー伸縮に追従 */
  display: flex;
  flex-direction: column;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 40px);
}
.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.save-indicator {
  display: none;
}
.save-indicator.saved { color: #16a34a; }
button {
  font: inherit;
  font-size: 16px;
  font-weight: bold;
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-sync {
  font-size: 13px;
  padding: 4px 12px;
}
.btn-danger {
  background: var(--surface);
  color: var(--err-text);
  border-color: var(--err-border);
  font-size: 13px;
  padding: 4px 12px;
}
.btn-danger:hover:not(:disabled) { background: var(--err-bg); }
#status {
  display: none;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.table-wrap {
  background: var(--surface);
  overflow: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.table-wrap::-webkit-scrollbar {
  display: none;
}
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td {
  padding: 4px 6px;
  font-size: 19px;
  font-weight: bold;
  text-align: right;
  border: none;
  border-right: 2px solid #6b7690;
  border-bottom: 2px solid #6b7690;
  white-space: nowrap;
  background: #000000;
  color: var(--text-sub);
}
th:first-child, td:first-child { border-left: 2px solid #6b7690; }
thead th { border-top: 2px solid #6b7690; }
th {
  background: #000000;
  color: var(--text-sub);
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: 0.02em;
  padding: 6px 6px;
}
th .unit {
  display: block;
  font-weight: bold;
  font-size: 13px;
  color: #7b8598;
}
tbody tr:hover td { background: #232a3a; }
td.code-cell { text-align: center; padding-left: 2px; padding-right: 2px; }
td.name, th.name-col {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 1;
}
th.name-col { z-index: 2; }
td.name { text-align: left; min-width: 130px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
a.nameLink { color: inherit; text-decoration: none; }
a.nameLink:hover { color: var(--accent-hover); text-decoration: underline; }
td.market { text-align: center; font-weight: bold; }
td.market.market-P { color: #16a34a; }
td.market.market-S { color: #eab308; }
td.market.market-G { color: #ff4d4d; }
td.industry {
  text-align: center;
  font-size: 15px;
  color: var(--text-sub);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.marketLink { color: inherit; text-decoration: none; }
a.marketLink:hover { text-decoration: underline; }
input.codeInput {
  width: 56px;
  text-align: center;
  font-size: 19px;
  font-weight: bold;
  padding: 4px 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-sub);
}
input.codeInput:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--accent);
}
tr.loading td { background: var(--loading-bg) !important; }
tr.done td { background: #000000 !important; }
tr.error td { background: var(--err-bg) !important; }
.err-msg { color: var(--err-text); font-size: 14px; }
.price { font-variant-numeric: tabular-nums; font-weight: 600; }
td.neg { color: #ff6b6b; }
td.pos { color: #4ade80; }
