:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6eb;
  --border-strong: #d2d6dd;
  --text: #1a1d21;
  --text-muted: #6b7280;
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.app-header nav {
  display: flex;
  align-items: center;
  gap: 14px;
}
.user-email { color: var(--text-muted); font-size: 13px; }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.container.narrow { max-width: 460px; }
.container.medium { max-width: 720px; }
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-subtitle { color: var(--text-muted); margin: 0 0 24px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}
.textarea { min-height: 80px; resize: vertical; }
.field-hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary, .btn-google {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.g-icon { width: 18px; height: 18px; }

.divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider span { padding: 0 12px; }

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.report-list { display: flex; flex-direction: column; gap: 10px; }
.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.report-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.report-title { font-weight: 600; }
.report-sub { color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.status-uploaded { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.status-processing { background: #fff7ed; color: var(--warning); border-color: #fed7aa; }
.status-completed { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.status-error { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.location { background: #fff; color: var(--text); border-color: var(--border-strong); }
.error-detail {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: #fef2f2;
  color: var(--text);
}
.dropzone.has-file { border-style: solid; border-color: var(--success); background: #f0fdf4; }
.dropzone input[type="file"] { display: none; }
.dropzone .icon { font-size: 36px; margin-bottom: 8px; }
.file-name { font-weight: 600; color: var(--text); }
.file-size { font-size: 12px; color: var(--text-muted); }

.progress-wrap { margin-top: 18px; }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > .bar { height: 100%; width: 0%; background: var(--primary); transition: width 0.2s; }
.progress-label { color: var(--text-muted); font-size: 12px; margin-top: 6px; }
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty .icon { font-size: 36px; margin-bottom: 8px; }

.segment {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.segment input { display: none; }
.segment label {
  padding: 8px 16px;
  margin: 0;
  color: var(--text-muted);
  cursor: pointer;
}
.segment input:checked + label { background: var(--primary); color: #fff; }

.guidelines {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.guideline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gl-figure {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gl-figure svg {
  width: 100%;
  height: 100%;
  display: block;
}
.gl-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.gl-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  align-self: center;
}
.gl-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}
.gl-note {
  font-size: 11.5px;
  color: var(--danger);
  margin: 4px 0 0;
}

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .app-header { padding: 12px 16px; }
  .app-header nav { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .container { padding: 20px 16px 48px; }
  .card { padding: 18px; }
  .report-item { flex-direction: column; align-items: flex-start; }
  .report-actions, .report-actions .btn { width: 100%; }
  .guidelines { grid-template-columns: 1fr; }
}
