:root {
  --bg-a: #f3faf7;
  --bg-b: #eef5ff;
  --ink: #1f2937;
  --muted: #5b6473;
  --line: #d5dde9;
  --card: #ffffff;
  --accent: #0f766e;
  --accent-2: #0b5f58;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 12px 34px rgba(20, 40, 80, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(120% 100% at 0% 0%, #e8f7ff 0%, transparent 55%),
    radial-gradient(120% 100% at 100% 100%, #e7fff3 0%, transparent 40%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

.app-root {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 18px;
  display: grid;
  gap: 14px;
}

.app-header {
  border-radius: var(--radius);
  border: 1px solid #d3e7ff;
  background: linear-gradient(148deg, #ffffff 0%, #f0f9ff 58%, #ecfdf5 100%);
  box-shadow: var(--shadow);
  padding: 18px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.7vw, 1.8rem);
}

.app-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.notice {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
}

.notice.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.notice.success {
  border-color: #86efac;
  background: #ecfdf5;
  color: #166534;
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 14px;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

h3 {
  margin: 0 0 8px;
  font-size: 0.97rem;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 12px;
}

.auth-mode-switch {
  margin-top: 10px;
}

.auth-panel {
  margin-top: 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

.auth-form-single {
  grid-template-columns: minmax(220px, 1fr);
}

.auth-actions {
  margin-top: 0;
  flex-direction: column;
  gap: 12px;
}

.auth-actions > button {
  width: 100%;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  color: #475569;
}

input,
button,
select {
  font: inherit;
}

input[type="text"],
input[type="url"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid #cdd7e5;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px;
}

button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), #14b8a6);
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button.secondary {
  color: #1e3a8a;
  background: #eff6ff;
  border-color: #bfdbfe;
}

button.secondary.active {
  color: #ffffff;
  background: #1d4ed8;
  border-color: #1d4ed8;
}

button.danger {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

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

.button-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row.compact {
  margin-top: 0;
}

.panel {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  padding: 12px;
  margin-top: 12px;
}

.inline-form {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form input[type="url"] {
  min-width: min(560px, 100%);
  flex: 1;
}

.split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.table th,
.table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px;
  text-align: left;
  vertical-align: top;
  font-size: 0.84rem;
}

.table th {
  color: #334155;
  font-size: 0.79rem;
}

.table tr:hover td {
  background: #f8fafc;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  background: #ecfeff;
  color: #155e75;
}

.badge.pending {
  background: #eff6ff;
  color: #1e3a8a;
}

.badge.running {
  background: #fff7ed;
  color: #9a3412;
}

.badge.done {
  background: #ecfdf5;
  color: #166534;
}

.badge.failed,
.badge.cancelled {
  background: #fef2f2;
  color: #991b1b;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #334155;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.progress-wrap {
  min-width: 250px;
  display: grid;
  gap: 5px;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 220ms ease-out;
  background: linear-gradient(90deg, #0f766e, #14b8a6);
}

.progress-fill.pending {
  background: linear-gradient(90deg, #1d4ed8, #60a5fa);
}

.progress-fill.running {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.progress-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-percent {
  min-width: 56px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.progress-log {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 920px) {
  .app-root {
    padding: 12px;
  }

  .card {
    padding: 12px;
  }

  .panel {
    padding: 10px;
  }

  .split-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .inline-form {
    align-items: stretch;
  }

  .inline-form > * {
    flex: 1 1 100%;
    min-width: 0;
  }

  .inline-form input[type="url"] {
    min-width: 0;
  }

  .button-row button {
    flex: 1 1 auto;
  }

  .progress-wrap {
    min-width: 0;
  }

  .auth-panel {
    padding: 10px;
  }

  .table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .app-root {
    padding: 8px;
    gap: 10px;
  }

  .app-header,
  .card,
  .panel {
    border-radius: 12px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .table {
    white-space: normal;
  }

  .table th,
  .table td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .table a,
  .sub {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}
