:root {
  --accent-red: #c00000;
  --text: #555555;
  --text-dark: #1a1a1a;
  --border: #eeeeee;
  --bg: #fafafa;
  --card: #ffffff;
  --silver: #6b7280;
  --gold: #b45309;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI",
    "Yu Gothic", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent-red);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, #f5f5f5 0%, #fff 45%, #f8f0f0 100%);
}

/* display:flex 指定が [hidden] より優先され、要素が消えない問題を防ぐ */
.login-page[hidden] {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem 2rem 1.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand img {
  height: 52px;
  width: auto;
  display: inline-block;
}

.login-brand .tagline {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--text);
}

.login-card h1 {
  margin: 0 0 1.25rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-dark);
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  color: var(--text-dark);
}

.form-group input:focus {
  outline: none;
  border-color: #ccc;
  box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.7rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  width: 100%;
  background: var(--accent-red);
  color: #fff;
  margin-top: 0.25rem;
}

.btn-primary:hover {
  background: #a00000;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: #f5f5f5;
}

.demo-accounts {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.demo-accounts h2 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
}

.demo-account-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.demo-account-list button {
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--text-dark);
  line-height: 1.45;
  transition: border-color 0.15s, background 0.15s;
}

.demo-account-list button:hover {
  border-color: #ddd;
  background: #fff;
}

.demo-account-list .id {
  font-weight: 700;
  color: var(--accent-red);
}

.demo-account-list .pw {
  font-size: 0.75rem;
  color: var(--text);
}

/* App shell */
.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-header .brand img {
  height: 40px;
  width: auto;
}

.app-header .brand-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
}

.app-header .brand-logo-link:hover {
  text-decoration: none;
  opacity: 0.92;
}

.app-header .user-meta {
  font-size: 0.8125rem;
  color: var(--text);
}

.app-header .user-meta strong {
  color: var(--text-dark);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.rank-badge.silver {
  background: #f3f4f6;
  color: var(--silver);
  border: 1px solid #e5e7eb;
}

.rank-badge.gold {
  background: #fffbeb;
  color: var(--gold);
  border: 1px solid #fde68a;
}

.app-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.app-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.app-nav a:hover {
  background: var(--bg);
  text-decoration: none;
}

.app-nav a.active {
  background: rgba(192, 0, 0, 0.08);
  color: var(--accent-red);
}

.app-nav button {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.app-nav button:hover {
  background: var(--bg);
}

.form-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.form-link-list li + li {
  margin-top: 0.5rem;
}

.form-link-list a {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--text-dark);
  text-decoration: none;
  background: var(--bg);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.form-link-list a:hover,
.form-link-list a:focus-visible {
  background: #fff;
  border-color: #ddd;
  color: var(--accent-red);
}

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.app-main > section > h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}

.month-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.month-toolbar label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-dark);
}

.month-toolbar select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-dark);
  background: var(--card);
  min-width: 200px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.summary-card .label {
  font-size: 0.75rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.summary-card .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data th,
table.data td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.data th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
}

table.data tr:last-child td {
  border-bottom: none;
}

table.data .case-name {
  font-weight: 600;
  color: var(--text-dark);
}

table.data .rank-note {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text);
  margin-top: 0.2rem;
}

table.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--text);
  font-size: 0.9375rem;
}

.conditions-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .conditions-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.condition-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.condition-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
}

.condition-card ul {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.875rem;
}

.condition-card li {
  margin-bottom: 0.4rem;
}

.condition-card .rate {
  color: var(--accent-red);
  font-weight: 700;
}

.note-box {
  margin-top: 1.25rem;
  padding: 1rem;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  font-size: 0.8125rem;
  color: #78350f;
}

.qual-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.qual-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.qual-list li:last-child {
  border-bottom: none;
}

footer.app-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: #9ca3af;
}

.error-msg {
  color: var(--accent-red);
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
}
