:root {
  --brand-red: #ea3a3a;
  --brand-red-dark: #d92f2f;
  --brand-red-soft: #fff1f1;
  --brand-pink-line: #f4caca;

  --bg: #f3f4f7;
  --card: #ffffff;
  --text: #222222;
  --muted: #6b7280;
  --border: #e3e6ec;
  --table-border: #dfe3ea;

  --blue-btn: #2f64f5;
  --blue-btn-dark: #2455dc;

  --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont,
    "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

.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;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.auth-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 700;
}

/* コンテンツ全体 */
#login-section,
#app-section {
  padding: 24px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.panel-title {
  margin: 0 0 18px;
  font-size: 22px;
  font-weight: 800;
}

/* ログイン */
#login-section.panel {
  max-width: 560px;
  margin: 28px auto 0;
  padding: 28px;
}

.login-form {
  display: grid;
  gap: 18px;
}

/* フィルターカード */
.controls-panel {
  padding: 24px;
}

.controls-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 280px) auto;
  gap: 18px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label,
.dummy-label {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

input,
select {
  width: 100%;
  border: 1px solid #cfd6e2;
  background: #fff;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 4px rgba(234, 58, 58, 0.12);
}

.actions-field .actions,
.login-form .actions,
#auth-info {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* ボタン */
.button {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.05s ease, opacity 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}

.button:active {
  transform: translateY(1px);
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.button.primary {
  background: var(--blue-btn);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--blue-btn-dark);
}

.button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid #cfd6e2;
}

.button.secondary:hover:not(:disabled) {
  background: #f8f9fc;
}

/* メッセージ */
.message {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.message.error,
#login-message.error {
  color: #c62828;
  font-weight: 700;
}

#login-message.success {
  color: #1f7a3d;
  font-weight: 700;
}

#message-section {
  padding: 18px 22px;
}

/* ローディング */
#loading-section {
  padding: 24px;
}

.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: 15px;
  font-weight: 700;
  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%;
  }
}

/* テーブル */
#table-section {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
  border-radius: var(--radius);
}

.result-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.result-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f8f9fc;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  border-bottom: 1px solid var(--table-border);
}

.result-table th,
.result-table td {
  padding: 14px 16px;
  border-right: 1px solid var(--table-border);
  border-bottom: 1px solid var(--table-border);
  text-align: right;
  white-space: nowrap;
  font-size: 15px;
}

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

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

.result-table th:last-child,
.result-table td:last-child {
  border-right: none;
}

.result-table tbody tr:nth-child(even) td {
  background: #fcfcfd;
}

.result-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.result-table thead .sticky-col {
  z-index: 4;
  background: #f8f9fc;
}

.result-table tbody tr:nth-child(even) .sticky-col {
  background: #fcfcfd;
}

/* 隠し */
.hidden {
  display: none !important;
}

/* レスポンシブ */
@media (max-width: 960px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-info {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  #login-section,
  #app-section {
    padding: 16px;
  }

  .page-header {
    padding: 18px 16px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .button {
    width: 100%;
  }

  .actions-field .actions,
  .login-form .actions {
    flex-direction: column;
    align-items: stretch;
  }
}