:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f6;
  --line: #d7e0e7;
  --text: #17212b;
  --muted: #627080;
  --primary: #0c6975;
  --primary-dark: #084e58;
  --accent: #8a5a12;
  --danger: #a33b3b;
  --ok: #276749;
  --blue: #2563eb;
  --purple: #7c3aed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic", "Meiryo", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 13px;
  min-height: 36px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

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

.secondary {
  background: #dae4eb;
  color: #17212b;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 22px;
  background: #17323a;
  color: #fff;
  border-bottom: 4px solid #d39c2f;
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
}

.topbar p {
  margin: 4px 0 0;
  color: #d6e3e7;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-label {
  color: #d6e3e7;
  font-size: 12px;
}

main {
  padding: 20px;
}

.band,
#appView {
  max-width: 1280px;
  margin: 0 auto;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 28px;
  max-width: 620px;
}

.auth-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-panel p {
  color: var(--muted);
  margin: 0 0 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 14px;
  min-height: 82px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2,
.work-surface h2 {
  margin: 0;
  font-size: 18px;
}

.work-surface {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.form-column,
.result-column,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  margin-top: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea,
pre {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

textarea {
  resize: vertical;
  min-height: 180px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.status-line {
  color: var(--muted);
  margin: 10px 0 0;
  font-size: 13px;
}

pre {
  margin: 12px 0 0;
  background: #111820;
  color: #dbece7;
  padding: 13px;
  min-height: 390px;
  max-height: 620px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 6px;
  font-size: 12px;
}

.job-list {
  display: grid;
  gap: 10px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(140px, 0.6fr) minmax(160px, 0.7fr) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 11px;
}

.job-row strong {
  display: block;
  font-size: 13px;
}

.job-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-block;
  width: fit-content;
  min-width: 86px;
  text-align: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.pill.completed {
  background: #dcfce7;
  color: var(--ok);
}

.pill.failed {
  background: #fee2e2;
  color: var(--danger);
}

.pill.running,
.pill.queued {
  background: #dbeafe;
  color: var(--blue);
}

.pill.waiting_for_user {
  background: #ede9fe;
  color: var(--purple);
}

.pill.other {
  background: #e5e7eb;
  color: #374151;
}

.detail-panel {
  margin-top: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.candidate {
  border: 1px solid var(--line);
  padding: 12px;
  margin-top: 10px;
  background: #fbfdff;
}

.candidate h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.candidate p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
}

.admin-panel.wide {
  grid-column: 1 / -1;
}

.admin-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.compact-pre {
  min-height: 180px;
  max-height: 360px;
}

.guide-layout {
  display: grid;
  gap: 14px;
}

.guide-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 16px;
}

.guide-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.guide-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-cards > div {
  border: 1px solid var(--line);
  background: #fbfdff;
  padding: 12px;
}

.guide-cards strong {
  display: block;
  margin-bottom: 6px;
}

.guide-cards p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.api-guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.5;
}

.api-guide-table th,
.api-guide-table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.api-guide-table th {
  background: #eef4f6;
  color: #243b45;
}

.api-guide-table td:first-child {
  width: 30%;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.api-guide-table td:last-child {
  width: 22%;
  font-weight: 700;
  color: #244756;
}

.api-check-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(190px, 1fr) minmax(120px, 0.6fr) minmax(260px, 1.4fr);
  gap: 10px;
  align-items: end;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #17212b;
  color: #fff;
  padding: 11px 14px;
  border-radius: 6px;
  max-width: 460px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-surface,
  .form-grid,
  .detail-grid,
  .admin-grid,
  .guide-cards,
  .api-check-grid,
  .job-row {
    grid-template-columns: 1fr;
  }
}
