* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  margin: 0;
  padding: 16px;
  background: #f5f6f8;
  color: #222;
}

.app-header {
  max-width: 1600px;
  margin: 0 auto 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.app-header h1 { font-size: 18px; margin: 0; }
.app-header .meta { color: #666; font-size: 13px; }
.app-header .meta a { color: #00b894; text-decoration: none; margin-left: 12px; }

.date-section { max-width: 1600px; margin: 0 auto 28px; }
.date-header {
  font-size: 15px;
  font-weight: 600;
  color: #444;
  padding: 8px 4px;
  border-bottom: 2px solid #00b894;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
}
.date-count { color: #00b894; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card .product-img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: #fafafa;
  border-radius: 6px;
  cursor: pointer;
  transition: transform .15s;
}
.card .product-img:hover { transform: scale(1.02); }

.no-image {
  height: 160px;
  background: #fafafa;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 13px;
}

.title {
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  cursor: pointer;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  padding: 4px;
  border-radius: 4px;
  transition: background .15s;
}
.title:hover { background: #f0f9f6; }

.row { display: flex; gap: 6px; font-size: 12px; align-items: center; }
.row .label { color: #888; width: 42px; flex-shrink: 0; }

.copyable {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f0f2f5;
  padding: 3px 7px;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
  transition: background .15s;
  user-select: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copyable:hover { background: #e6f7f2; }

.price { font-size: 22px; font-weight: 700; color: #00b894; margin-top: 2px; }

.keepa-graph { background: #fff; border: 1px solid #eee; border-radius: 6px; padding: 4px; }
.keepa-graph img { width: 100%; display: block; }
.keepa-label { font-size: 10px; color: #888; padding: 2px 4px 4px; display: flex; justify-content: space-between; }

/* QuickShop */
.quickshop { background: #fafbfc; border: 1px solid #e8eaed; border-radius: 6px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.qs-title { font-size: 12px; font-weight: 600; color: #555; border-bottom: 1px dashed #dcdfe3; padding-bottom: 6px; }
.qs-inputs { display: flex; flex-direction: column; gap: 6px; }
.qs-inputs label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #555; gap: 6px; }
.qs-inputs input { flex: 1; max-width: 120px; padding: 5px 8px; border: 1px solid #d1d5da; border-radius: 4px; font-size: 13px; text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.qs-inputs input:focus { outline: 2px solid #00b894; outline-offset: -1px; border-color: transparent; }
.qs-inputs .unit { width: 18px; text-align: left; color: #888; }

.fees { border-top: 1px dashed #dcdfe3; padding-top: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #555; }
.fee-row { display: flex; justify-content: space-between; align-items: baseline; }
.fee-row small { color: #999; font-size: 10px; margin-left: 4px; }
.fee-row.total { border-top: 1px dotted #dcdfe3; padding-top: 3px; font-weight: 600; color: #333; }

.outputs { border-top: 1px dashed #dcdfe3; padding-top: 6px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.section-label { font-size: 10px; color: #888; font-weight: 600; letter-spacing: 1px; margin-top: 4px; padding-bottom: 2px; border-bottom: 1px dotted #dcdfe3; }
.section-label:first-child { margin-top: 0; }
.out-row { display: flex; justify-content: space-between; align-items: baseline; }
.out-row.sub { font-size: 11px; color: #777; padding-left: 8px; }
.out-row.big { font-size: 16px; font-weight: 700; }
.out-profit.positive, .out-cash-profit.positive { color: #00b894; }
.out-profit.negative, .out-cash-profit.negative { color: #e74c3c; }
.out-profit.neutral, .out-cash-profit.neutral { color: #999; }

/* Mall buttons */
.mall-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.mall-btn { border: none; color: #fff; padding: 8px 4px; border-radius: 4px; font-size: 12px; font-weight: 700; cursor: pointer; transition: filter .15s, transform .05s; }
.mall-btn:hover { filter: brightness(1.08); }
.mall-btn:active { transform: translateY(1px); }
.mall-btn:disabled { background: #bbb !important; cursor: not-allowed; }
.mall-rakuten { background: #bf0000; }
.mall-yahoo { background: #ff0033; }
.mall-amazon { background: #ff9900; color: #111; }

.footer-row { display: flex; justify-content: flex-end; padding-top: 6px; border-top: 1px solid #eee; }
.amazon-link { font-size: 11px; color: #0066c0; text-decoration: none; }
.amazon-link:hover { text-decoration: underline; }

/* Loading */
.loading-screen { text-align: center; padding: 80px 20px; color: #888; }
.spinner { width: 36px; height: 36px; border: 3px solid #e0e0e0; border-top-color: #00b894; border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: #222; color: #fff; padding: 12px 24px; border-radius: 24px; font-size: 13px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 9999; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { max-width: 1400px; margin: 80px auto; text-align: center; color: #999; }

/* Mobile responsive */
@media (max-width: 640px) {
  body { padding: 10px; }
  .app-header h1 { font-size: 15px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card .product-img { height: 140px; }
  .price { font-size: 20px; }
}
