:root {
  --navy: #1f3a5f;
  --navy-2: #2d5487;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1d2430;
  --muted: #667085;
  --line: #dde3ea;
  --ok: #1a7f4b;
  --ok-bg: #e5f5ec;
  --warn: #9a6200;
  --warn-bg: #fff4dc;
  --ng: #b42318;
  --ng-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { height: 30px; width: auto; }
.app-name { font-weight: 700; color: var(--navy); font-size: 17px; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
.user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px;
}
.card.center { text-align: center; padding: 56px 24px; max-width: 560px; margin: 40px auto; }
h1 { font-size: 24px; margin: 0 0 12px; color: var(--navy); }
h2 { font-size: 17px; margin: 0 0 14px; color: var(--navy); }
.lead { font-size: 16px; margin: 0 0 28px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.btn {
  font: inherit; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  padding: 8px 16px; font-weight: 600; transition: background .15s, border-color .15s;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--navy-2); }
.btn.primary:disabled { background: #a9b6c7; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--navy); color: var(--navy); }
.btn.danger { background: #fff; border-color: #f1c0bb; color: var(--ng); }
.btn.danger:hover { background: var(--ng-bg); }
.btn.large { padding: 12px 28px; font-size: 16px; }
.btn.small { padding: 4px 10px; font-size: 13px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  border: 2px dashed #b8c4d3; border-radius: var(--radius); padding: 32px 16px; cursor: pointer;
  background: #f9fbfd; transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus, .drop.over { border-color: var(--navy); background: #eef3f9; outline: none; }
.drop.has-file { border-style: solid; border-color: var(--navy); background: #eef3f9; }
.drop-icon { font-size: 28px; color: var(--navy); line-height: 1; }
.drop-main { font-weight: 600; word-break: break-all; }
.drop-sub { font-size: 13px; color: var(--muted); }
.kinds { margin-top: 8px; font-size: 13px; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.grid .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; }
.span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
input, select, textarea {
  font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9cbe3; border-color: var(--navy); }
details.more { grid-column: 1 / -1; }
details.more summary { cursor: pointer; font-size: 14px; color: var(--navy); font-weight: 600; }

.help {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid #9fb0c5; background: #fff;
  color: var(--navy); font-size: 11px; font-weight: 700; line-height: 1; padding: 0; cursor: help;
  display: inline-flex; align-items: center; justify-content: center; margin-left: 2px; flex: none;
}
.help:hover, .help:focus, .help[aria-expanded="true"] { background: var(--navy); color: #fff; outline: none; }
.tip {
  position: fixed; z-index: 100; max-width: min(340px, calc(100vw - 32px));
  background: #1d2430; color: #fff; font-size: 13px; line-height: 1.6; padding: 10px 12px;
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

.actions { display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.progress { flex: 1; min-width: 200px; position: relative; height: 26px; background: #e7ecf2; border-radius: 13px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--navy-2); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }

.list-head { display: flex; justify-content: space-between; align-items: center; }
.list-head h2 { margin: 0; }
.jobs { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.job {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
}
.job-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-err { grid-column: 1 / -1; font-size: 13px; color: var(--ng); background: var(--ng-bg); padding: 6px 10px; border-radius: 6px; }
.job-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 10px; margin-right: 6px; vertical-align: 1px; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.run { color: var(--warn); background: var(--warn-bg); }
.badge.ng { color: var(--ng); background: var(--ng-bg); }
.spin { display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; margin-right: 4px; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { border: none; border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dlg { padding: 20px 24px 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dlg-head h2 { margin: 0; word-break: break-all; }
.dlg h3 { font-size: 15px; color: var(--navy); margin: 18px 0 6px; }
.dlg ul { margin: 0; padding-left: 20px; }
.spk { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.spk .basis { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  background: #1d2430; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.error { background: var(--ng); }

@media (max-width: 720px) {
  .topbar { padding: 8px 16px; }
  .app-name { font-size: 15px; }
  #userEmail { display: none; }
  .card { padding: 18px 16px; }
  .grid, .grid .grid { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .job { grid-template-columns: minmax(0, 1fr); }
  .job-actions { justify-content: flex-start; }
}

.refs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.refs label.btn { cursor: pointer; }
.ref-list { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.ref-list:empty { display: none; }
.ref-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; background: #f4f6f9; border-radius: 6px; padding: 4px 4px 4px 10px; }
.ref-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
