* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #f4f6f9;
  color: #1f2933;
}

.topbar {
  background: #1f2d3d;
  color: #fff;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.nav a {
  color: #cbd2d9;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
}
.nav a.active {
  color: #fff;
  background: #33475b;
}
@media (hover: hover) {
  .nav a:hover { color: #fff; background: #33475b; }
}
.nav-logout {
  margin-left: 1.5rem;
}

.nav-dropdown {
  position: relative;
}
.nav-dropdown > summary {
  color: #cbd2d9;
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown[open] > summary,
.nav-dropdown > summary.active {
  color: #fff;
  background: #33475b;
}
@media (hover: hover) {
  .nav-dropdown > summary:hover { color: #fff; background: #33475b; }
}
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: #1f2d3d;
  border: 1px solid #33475b;
  border-radius: 6px;
  padding: 0.35rem;
  min-width: 160px;
  z-index: 20;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

select, textarea, input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  padding: 0.55rem 0.6rem;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  color: #1f2933;
}

textarea {
  min-height: 220px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.field {
  margin-bottom: 1.1rem;
}

.btn {
  display: inline-block;
  background: #2f6fed;
  color: #fff;
  border: none;
  padding: 0.65rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: #2559c7; }

.btn-secondary {
  background: #fff;
  color: #2f6fed;
  border: 1px solid #2f6fed;
}
.btn-secondary:hover { background: #eef3fe; }

.flash {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.flash-error, .alert-error {
  background: #fdecea;
  color: #b3261e;
  border: 1px solid #f5c2c0;
}
.flash-success, .alert-success {
  background: #e6f4ea;
  color: #1e7e34;
  border: 1px solid #b7e1c1;
}
.alert-info {
  background: #e8f2fc;
  color: #2f6fed;
  border: 1px solid #bcd7f8;
}

.alert-list { margin-bottom: 1rem; }
.alert-error, .alert-success, .alert-info {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 360px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filters .field { margin-bottom: 0; min-width: 140px; flex: 1; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #e4e7eb;
  text-align: right;
  white-space: nowrap;
}
th:nth-child(-n+3), td:nth-child(-n+3) { text-align: left; }
thead th {
  background: #f0f2f5;
  font-weight: 700;
  position: sticky;
  top: 0;
}
tr.profit-positive td.profit { color: #1e7e34; font-weight: 700; }
tr.profit-negative td.profit { color: #b3261e; font-weight: 700; }
tr.is-open td.profit { color: #8a94a6; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.summary-item {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: center;
}
.summary-item .value { font-size: 1.5rem; font-weight: 700; }
.summary-item .label { font-size: 0.85rem; color: #616e7c; margin-top: 0.25rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.stats-grid table { font-size: 0.95rem; }

.chart-wrap { position: relative; height: 320px; }

.position-card h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.trend { font-size: 1.2rem; font-weight: 700; }
.trend-up { color: #1e7e34; }
.trend-down { color: #b3261e; }
.trend-flat { color: #8a94a6; }

.position-body {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}
.position-info {
  flex: 1;
  min-width: 220px;
}
.position-info th {
  text-align: left;
  color: #616e7c;
  font-weight: 600;
  padding: 0.3rem 0.6rem 0.3rem 0;
  white-space: nowrap;
}
.position-info td {
  text-align: left;
  padding: 0.3rem 0;
  white-space: nowrap;
}
.profit-positive-text { color: #1e7e34; font-weight: 700; }
.profit-negative-text { color: #b3261e; font-weight: 700; }

.small-chart {
  flex: 2;
  min-width: 260px;
  height: 220px;
}

.verdict { font-size: 1.05rem; margin-top: 1rem; }
.hint-text { font-size: 0.85rem; color: #616e7c; margin-top: 0.5rem; }
.check-time { font-size: 0.85rem; color: #616e7c; margin-bottom: 0.5rem; }

tr.row-buy { background: #e6f4ea; }
tr.row-sell { background: #fdecea; }
.summary-item.row-sell { background: #fdecea; }

@media (max-width: 640px) {
  .nav a, .nav-dropdown > summary { font-size: 0.85rem; }
  th, td { padding: 0.4rem; }
}
