/* ============ Reset & Base ============ */
:root {
  --color-primary: #06C755;
  --color-primary-dark: #04A444;
  --color-bg: #FFFFFF;
  --color-text: #202124;
  --color-muted: #888888;
  --color-error: #DC2626;
  --color-warn-bg: #FDE7E9;
  --color-border: #E5E7EB;
  --color-card: #FFFFFF;
  --color-card-shadow: rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100vh;
}

/* ============ Screens ============ */
.screen { display: block; }
.screen[hidden] { display: none; }

/* ============ Header ============ */
.app-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--color-primary);
}
.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}
.user-name {
  margin-top: 4px;
  font-size: 14px;
  color: var(--color-muted);
}

/* ============ Job Cards ============ */
.jobs-list { display: flex; flex-direction: column; gap: 12px; }

.job-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 6px var(--color-card-shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.job-card.is-submitted { background: #F0FFF4; border-color: var(--color-primary); }
.job-card.is-cancelled { background: var(--color-warn-bg); }

.job-card-head {
  display: flex; align-items: center; gap: 10px;
}
.case-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-weight: 700;
}
.case-name { font-size: 16px; font-weight: 600; flex: 1; }
.case-time { color: var(--color-muted); font-size: 14px; }

.status-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.status-chip.pending { background: #F3F4F6; color: var(--color-muted); }
.status-chip.submitted { background: var(--color-primary); color: white; }
.status-chip.cancelled { background: var(--color-error); color: white; }

.job-card-actions {
  display: flex; gap: 8px;
}
.job-card-actions .btn { flex: 1; }

/* ============ Buttons ============ */
.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }

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

.btn-link {
  background: none;
  color: var(--color-muted);
  border: none;
  padding: 12px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
  display: block;
  width: 100%;
  margin-top: 4px;
}

.btn-row { display: flex; gap: 8px; margin-top: 20px; }
.btn-row .btn { flex: 1; }

/* ============ Form ============ */
.case-pill {
  background: #F0FFF4;
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  padding: 10px 16px;
  margin-bottom: 20px;
  font-weight: 600;
}

.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field .label { font-size: 14px; font-weight: 600; color: var(--color-text); }

.field input[type="time"] {
  font-size: 18px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
  font-family: inherit;
}
.field input[type="time"]:focus {
  outline: none;
  border-color: var(--color-primary);
}

.note { font-size: 13px; margin: -4px 0 4px; }

/* ============ Completion ============ */
.check-icon {
  width: 80px; height: 80px;
  margin: 40px auto 20px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700;
}
.error-icon {
  width: 80px; height: 80px;
  margin: 40px auto 20px;
  border-radius: 50%;
  background: var(--color-error);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; font-weight: 700;
}

[data-screen="done"], [data-screen="done-cancel"],
[data-screen="error"], [data-screen="register-error"], [data-screen="no-file"] {
  text-align: center;
}
[data-screen="done"] h2, [data-screen="done-cancel"] h2,
[data-screen="error"] h2, [data-screen="register-error"] h2, [data-screen="no-file"] h2 {
  font-size: 20px; margin-bottom: 16px;
}

.result {
  margin: 20px auto 32px;
  max-width: 280px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  text-align: left;
  background: #F9FAFB;
  padding: 16px 20px;
  border-radius: var(--radius);
}
.result dt { font-size: 13px; color: var(--color-muted); align-self: center; }
.result dd { font-weight: 600; }

.format-sample {
  display: inline-block;
  margin: 12px 0;
  padding: 8px 16px;
  background: #F3F4F6;
  border-radius: 8px;
  font-family: monospace;
  font-size: 16px;
}
.format-sample code, code { font-family: ui-monospace, SFMono-Regular, monospace; }

.confirm { text-align: center; padding: 40px 16px; }
.confirm p:first-child { font-size: 18px; font-weight: 600; margin-bottom: 8px; }

/* ============ Spinner ============ */
.spinner-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Utility ============ */
.muted { color: var(--color-muted); font-size: 14px; }
.error-text { color: var(--color-error); font-size: 14px; }
.empty-state { text-align: center; padding: 60px 16px; color: var(--color-muted); }
