
:root {
  --brand-red: #ea3a3a;
  --brand-red-dark: #d92f2f;
  --brand-red-soft: #fff4f4;
  --badge-red: #df536d;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #20242a;
  --muted: #777b82;
  --border: #e6e6e8;
  --blue: #2f64f5;
  --blue-dark: #2455dc;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.page { min-height: 100vh; }
.page-header {
  background: var(--brand-red); color: #fff; padding: 22px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.service-label { margin: 0 0 3px; font-size: 12px; font-weight: 500; letter-spacing: 0.06em; opacity: 0.88; }
.service-label.red { color: var(--brand-red); opacity: 1; }
.page-header h1 { margin: 0; font-size: 26px; line-height: 1.25; font-weight: 700; }
.auth-info { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; }
.app-section, #login-section { padding: 24px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.login-panel { max-width: 560px; margin: 30px auto 0; padding: 28px; }
.panel-title { margin: 0 0 16px; font-size: 20px; font-weight: 600; line-height: 1.4; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-note { margin: 0; color: var(--muted); font-size: 13px; }
.controls-panel, .customers-panel, #loading-section, #message-section { padding: 22px; }
.controls-grid { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 18px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label, .dummy-label { font-size: 14px; font-weight: 500; color: var(--text); }
input {
  width: 100%; border: 1px solid #cfd6e2; background: #fff; border-radius: 14px;
  padding: 13px 16px; font-size: 15px; color: var(--text); outline: none;
}
input:focus { border-color: var(--brand-red); box-shadow: 0 0 0 4px rgba(234, 58, 58, 0.12); }
.login-form { display: grid; gap: 16px; }
.actions, .actions-field { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions-field { flex-direction: column; align-items: flex-start; }
.button {
  appearance: none; border: none; border-radius: 14px; padding: 12px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.button:disabled { opacity: 0.5; cursor: default; }
.button.primary { background: var(--blue); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { background: #fff; color: var(--text); border: 1px solid #cfd6e2; }
.message { margin: 0; font-size: 14px; }
.message.error, #login-message.error { color: #c62828; font-weight: 500; }
.customer-list { display: flex; flex-direction: column; gap: 10px; }
.customer-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--border); border-radius: 14px; padding: 13px 16px; background: #fff; cursor: pointer;
}
.customer-row:hover { background: #fffafa; border-color: #f1b8b8; }
.customer-main { display: flex; align-items: center; gap: 10px; }
.customer-checkbox { width: 18px; height: 18px; accent-color: var(--brand-red); }
.customer-name { font-size: 15px; font-weight: 500; }
.customer-id { font-size: 12px; color: var(--muted); }
.results { padding: 0 24px 24px; }
.customer-result { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.customer-result-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: baseline;
}
.customer-result-header h2 { margin: 0; font-size: 19px; font-weight: 600; }
.customer-result-header span { color: var(--muted); font-size: 13px; }
.event-group-list { background: #fff; }
.event-block { padding: 28px 18px 18px; border-bottom: 1px solid var(--border); }
.event-block:last-child { border-bottom: none; }
.event-title { display: flex; align-items: center; gap: 9px; margin: 0 0 18px; font-size: 19px; line-height: 1.4; font-weight: 600; }
.event-dot { width: 13px; height: 13px; background: #ff8585; border: 6px solid #ffe4e4; border-radius: 999px; display: inline-block; flex: 0 0 auto; }
.event-table-wrap { overflow-x: auto; }
.event-table { border-collapse: collapse; width: auto; min-width: 720px; }
.event-table th { color: #777; font-size: 13px; font-weight: 600; text-align: left; padding: 0 13px 10px 0; white-space: nowrap; }
.event-table td { padding: 6px 13px 6px 0; white-space: nowrap; vertical-align: middle; font-size: 16px; }
.visit-cell { width: 36px; }
.visit-badge {
  display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--badge-red); color: #fff; font-size: 14px; font-weight: 700;
}
.set-no { width: 26px; font-weight: 600; color: #222; }
.main-value { font-weight: 600; color: #20242a; }
.sub-value { color: #8b8b8b; font-weight: 500; }
.unit { margin-left: 2px; font-weight: 600; }
.fake-check { display: inline-block; width: 18px; height: 18px; border: 1px solid #c9c9c9; border-radius: 4px; background: #fff; }
.fake-check.checked { background: var(--badge-red); border-color: var(--badge-red); }
.memo-cell { color: #666; min-width: 120px; }
.empty-text { margin: 0; padding: 16px 18px; color: var(--muted); }
.loading-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spinner { width: 34px; height: 34px; border: 4px solid #eadede; border-top-color: var(--brand-red); border-radius: 50%; animation: spin 0.8s linear infinite; }
.loading-text { font-size: 14px; font-weight: 500; color: var(--muted); }
.progress-bar { width: min(420px, 100%); height: 8px; border-radius: 999px; background: #f0dada; overflow: hidden; }
.progress-bar-inner { width: 42%; height: 100%; background: linear-gradient(90deg, var(--brand-red), #ff8e8e); border-radius: 999px; animation: progressMove 1.2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes progressMove { 0% { margin-left: -20%; } 50% { margin-left: 35%; } 100% { margin-left: 100%; } }
.hidden { display: none !important; }
@media (max-width: 900px) {
  .controls-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
  .app-section, #login-section { padding: 16px; }
  .page-header { padding: 18px 16px; }
  .page-header h1 { font-size: 22px; }
  .button { width: 100%; }
  .actions { width: 100%; flex-direction: column; align-items: stretch; }
  .customer-row { align-items: flex-start; flex-direction: column; }
}


/* ===== compact customer table ===== */
.customer-list {
  display: block;
  overflow-x: auto;
}

.customer-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

.customer-table th,
.customer-table td {
  border-bottom: 1px solid var(--border);
  padding: 7px 10px;
  line-height: 1.35;
  vertical-align: middle;
}

.customer-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  background: #fafafa;
}

.customer-table tr {
  cursor: pointer;
}

.customer-table tbody tr:hover {
  background: #fffafa;
}

.customer-table .check-col {
  width: 36px;
  text-align: center;
}

.customer-table .id-col {
  width: 120px;
  color: var(--muted);
  text-align: right;
  font-size: 12px;
}

.customer-table .name-col {
  font-weight: 500;
}

.customer-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--brand-red);
}


/* ===== width alignment and compact history typography ===== */

/* 検索条件・お名前一覧・結果カセットの左端/右端を揃える */
.results {
  padding: 0 24px 24px;
}

.result-card,
.customer-result {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

/* 既存の下位カセットが中央寄せ・幅制限されないように固定 */
#result-list {
  width: 100%;
}

/* 履歴全体のフォントサイズをお名前一覧に寄せる */
.event-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.event-table {
  min-width: 680px;
}

.event-table th {
  font-size: 11px;
  font-weight: 600;
  padding: 0 10px 7px 0;
}

.event-table td {
  font-size: 13px;
  padding: 4px 10px 4px 0;
  line-height: 1.35;
}

.main-value {
  font-size: 13px;
  font-weight: 600;
}

.sub-value {
  font-size: 12px;
  font-weight: 500;
}

.unit {
  font-size: 12px;
}

.memo-cell {
  font-size: 12px;
}

.set-no {
  font-size: 13px;
}

.visit-badge {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 12px;
}

.visit-cell {
  width: 30px;
}

.fake-check {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.event-block {
  padding: 20px 18px 14px;
}

.customer-result-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.customer-result-header span {
  font-size: 11px;
}

.customer-result-header {
  padding: 14px 18px;
}

/* 小さい画面でも結果カセットの横幅を他のカセットと合わせる */
@media (max-width: 640px) {
  .results {
    padding: 0 16px 16px;
  }
}
