:root {
  --primary: #bf0000;
  --primary-light: #e8d0d0;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-muted: #888;
  --border: #e0e0e0;
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* Nav */
.nav {
  background: var(--primary);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}
.nav-brand { font-size: 1.1rem; font-weight: 700; text-decoration: none; color: #fff; }
.nav a { color: rgba(255,255,255,.8); text-decoration: none; font-size: .9rem; }
.nav a:hover, .nav a.active { color: #fff; }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.3rem; margin-bottom: 1rem; }

/* Card */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* Table */
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; position: sticky; top: 0; }
tr:hover { background: #fafafa; }

/* Rank indicators */
.rank { font-size: 1.1rem; font-weight: 700; }
.rank-up { color: var(--green); }
.rank-down { color: var(--red); }
.rank-same { color: var(--text-muted); }
.change-arrow { font-size: .8rem; margin-right: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border: none; border-radius: 6px;
  font-size: .85rem; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }

/* Forms */
input, select, textarea {
  font-family: inherit; font-size: .85rem;
  padding: .5rem .6rem; border: 1px solid var(--border);
  border-radius: 6px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
}
label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: .3rem; }
.form-group { margin-bottom: .75rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 100;
  justify-content: center; align-items: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card-bg); border-radius: 10px;
  padding: 1.5rem; width: 90%; max-width: 520px;
  max-height: 80vh; overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* Status */
.badge {
  display: inline-block; padding: .15rem .5rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

/* Loading */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--text); color: #fff;
  padding: .6rem 1rem; border-radius: 8px; font-size: .85rem;
  opacity: 0; transition: opacity .3s; z-index: 200;
}
.toast.show { opacity: 1; }

/* Chart container */
.chart-container { position: relative; height: 400px; }

/* Date filter */
.filter-bar { display: flex; gap: .75rem; align-items: flex-end; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; flex: 0 0 auto; }
.filter-bar input[type="date"] { width: 160px; }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .chart-container { height: 280px; }
  table { font-size: .78rem; }
  th, td { padding: .4rem .5rem; }
}
