/* === Base === */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
               "Noto Sans CJK JP", sans-serif;
  background: #0e1116;
  color: #e6e8ec;
}
body.app-body { height: 100vh; height: 100dvh; overflow: hidden; }

a { color: #6cb6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Auth pages === */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #0e1116, #1a2030);
}
.auth-card {
  width: min(420px, 92vw);
  background: #161a22;
  border: 1px solid #232936;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.auth-card h1 { margin-top: 0; font-size: 22px; }
.auth-card form { display: grid; gap: 12px; margin-top: 16px; }
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: #9aa3b2; }
.auth-card input[type=email],
.auth-card input[type=password],
.auth-card input[type=text] {
  background: #0e1116;
  border: 1px solid #2a3140;
  color: #e6e8ec;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
}
.auth-card input:focus { outline: none; border-color: #6cb6ff; }
.auth-card button {
  background: #2964ff;
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
.auth-card button:hover { background: #3a76ff; }
.auth-card .auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 13px;
}
.msg { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.msg.err { background: #2a1218; color: #ffb4be; border: 1px solid #5a1f2a; }
.msg.ok  { background: #0f2a1c; color: #b4f1cf; border: 1px solid #1f5a3e; }

/* === App === */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #161a22;
  border-bottom: 1px solid #232936;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar nav { display: flex; gap: 12px; align-items: center; }
.filter-btn {
  background: #2964ff;
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}
.filter-btn:hover { background: #3a76ff; }
.filter-btn.active { background: #1ea05a; }
.logout {
  font-size: 13px;
  color: #9aa3b2;
}

.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  padding: 16px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}
.panel {
  background: #161a22;
  border: 1px solid #232936;
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel header h2 { margin: 0 0 8px; font-size: 15px; color: #c8cfdb; }
.panel header h2 span { color: #6b7384; font-weight: normal; font-size: 12px; margin-left: 6px; }

.table-wrap { overflow: auto; flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid #232936; }
th { color: #9aa3b2; font-weight: 500; position: sticky; top: 0; background: #161a22; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: #c8cfdb; }
th[data-sort].active { color: #6cb6ff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.row { cursor: pointer; }
tr.row:hover { background: #1c2230; }
tr.row.selected { background: #1f3052; }

/* chart panel */
.chart-panel { min-height: 0; }
.chart-panel header { flex: 0 0 auto; }
#chart-title { font-size: 16px; }
#chart-container {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
  background: #0e1116;
  border-radius: 8px;
  overflow: hidden;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
}
.meta-grid .k { color: #9aa3b2; }
.meta-grid .v { color: #e6e8ec; font-weight: 500; }
.meta-grid .item {
  background: #1c2230;
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
}
