:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --border: #dde2ea;
  --text: #1b2333;
  --muted: #667085;
  --navy-900: #0e1c38;
  --navy-800: #16294d;
  --navy-700: #203a63;
  --accent: var(--navy-800);
  --accent-dark: var(--navy-900);
  --gold: #b7995a;
  --good: #1a7a52;
  --bad: #b3392c;
  --radius: 10px;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--navy-900);
  border-bottom: 1px solid var(--navy-900);
}

header.topbar .brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: #ffffff;
}

header.topbar nav a {
  margin-left: 16px;
  color: rgba(255, 255, 255, 0.68);
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}

header.topbar nav a.active,
header.topbar nav a:hover {
  color: #ffffff;
  font-weight: 600;
}

.login-hero {
  text-align: center;
  padding: 32px 20px 6px;
}

.login-hero .brand-logo {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--navy-900);
  text-transform: uppercase;
}

.login-hero .brand-rule {
  width: 56px;
  height: 2px;
  background: var(--gold);
  margin: 16px auto;
}

.login-hero .brand-tagline {
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--muted);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
  font-size: 18px;
}

.card p.hint {
  color: var(--muted);
  font-size: 13px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  /* 16px未満だとiOS Safariがフォーカス時に自動ズームしてしまうため16pxを下限にする */
  font-size: 16px;
  font-family: inherit;
}

.form-row textarea {
  resize: vertical;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

button:hover { background: var(--accent-dark); }

button.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

button.secondary:hover { background: #eaf0fe; }

button.danger {
  background: var(--bad);
}

.error-msg {
  color: var(--bad);
  font-size: 13px;
  margin-top: 8px;
}

.success-msg {
  color: var(--good);
  font-size: 13px;
  margin-top: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat {
  background: #f8f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 4px;
}

.value.pos { color: var(--good); }
.value.neg { color: var(--bad); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
}

table.data th, table.data td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

table.data th:first-child, table.data td:first-child { text-align: left; }

table.data th {
  color: var(--muted);
  font-weight: 600;
  background: #f8f9fc;
}

table.data tbody tr:hover { background: #f5f8ff; }

.table-scroll {
  overflow-x: auto;
}

.chart-wrap {
  position: relative;
  height: 220px;
  margin: 12px 0 20px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f8;
  color: var(--muted);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.muted { color: var(--muted); font-size: 13px; }

.top-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tag-warn {
  background: #fff4e5;
  color: #9a5b00;
  border: 1px solid #ffe0b2;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- タブレット (768px以下) ---------- */
@media (max-width: 768px) {
  main {
    padding: 24px 16px 60px;
  }

  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

/* ---------- スマートフォン (640px以下) ---------- */
@media (max-width: 640px) {
  header.topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
  }

  header.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
  }

  header.topbar nav a {
    margin-left: 0;
  }

  main {
    padding: 20px 14px 60px;
  }

  .card {
    padding: 16px;
  }

  .login-hero {
    padding: 28px 16px 4px;
  }

  .login-hero .brand-logo {
    font-size: 21px;
    letter-spacing: 2px;
  }

  .top-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .top-actions .form-row {
    min-width: 0 !important;
  }

  button {
    min-height: 44px;
  }

  .summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px;
  }

  .stat .value {
    font-size: 17px;
  }

  table.data {
    font-size: 12px;
  }
}
