:root {
  --bg: #0f1419;
  --surface: #1a2027;
  --surface2: #232b34;
  --line: #2d3742;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2f81f7;
  --ok: #2ea043;
  --warn: #d29922;
  --danger: #f85149;
  --gray: #6e7781;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
.view { min-height: 100vh; }
[hidden] { display: none !important; }

/* ---------- ログイン ---------- */
#login-view { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 28px 24px;
}
.brand { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.brand.sm { font-size: 16px; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.fld { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.fld input {
  width: 100%; margin-top: 4px; padding: 9px 11px; font-size: 14px;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
}
.fld input:focus { outline: none; border-color: var(--accent); }
.cfg { margin: 14px 0 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.cfg summary { cursor: pointer; color: var(--muted); font-size: 12px; }
button { font-family: inherit; cursor: pointer; }
.primary {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .55; cursor: default; }
#lg-submit { width: 100%; margin-top: 18px; }
.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 13px;
}
.ghost:hover { border-color: var(--accent); }
.err { color: var(--danger); font-size: 13px; margin: 12px 0 0; white-space: pre-wrap; }

/* ---------- ダッシュボード ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); font-size: 12px; }
.auto { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.who { color: var(--muted); font-size: 13px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dash-error { margin: 14px 18px 0; }

.summary { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 18px 4px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 96px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--muted); }

.table-wrap { padding: 12px 18px 4px; overflow-x: auto; }
table.sessions { width: 100%; border-collapse: collapse; min-width: 760px; }
.sessions th, .sessions td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sessions th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.sessions td { font-size: 13px; }
.sessions tr:hover td { background: var(--surface); }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.run  { background: rgba(46,160,67,.18);  color: #56d364; }
.badge.boot { background: rgba(210,153,34,.18); color: #e3b341; }
.badge.pause{ background: rgba(110,118,129,.22); color: #adbac7; }
.badge.end  { background: rgba(248,81,73,.16);  color: #ff7b72; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 5px 9px; font-size: 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); }
.row-actions button:hover { border-color: var(--accent); }
.row-actions button.danger { color: #ff7b72; border-color: rgba(248,81,73,.4); }
.row-actions button.danger:hover { background: rgba(248,81,73,.12); }
.row-actions button:disabled { opacity: .4; cursor: default; }

/* メトリクス展開行 */
.metrics-row td { background: var(--surface); }
.metrics { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-end; padding: 6px 2px; }
.metric { min-width: 160px; }
.metric .mh { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.metric .mv { font-size: 18px; font-weight: 700; }
.metric .mv small { font-size: 11px; color: var(--muted); font-weight: 400; }
.spark { display: block; margin-top: 4px; }

/* アクセス情報展開行（サポート用） */
.access-row td { background: var(--surface); }
.acc { display: flex; flex-direction: column; gap: 4px; padding: 6px 2px; }
.acc-sec { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 8px; }
.acc-row { display: flex; align-items: center; gap: 8px; }
.acc-k { min-width: 96px; font-size: 12px; color: var(--muted); }
.acc-v { flex: 1; word-break: break-all; }
.acc-row .copy { padding: 3px 8px; font-size: 11px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); cursor: pointer; }
.acc-row .copy:hover { border-color: var(--accent); }

/* 予約・CR状況（Package D 4/4） */
.sec-h { font-size: 16px; margin: 26px 0 10px; }
.rbadge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.rbadge[data-st="cr_secured"] { color: #3fb950; border-color: rgba(63,185,80,.4); }
.rbadge[data-st="launched"] { color: #58a6ff; border-color: rgba(88,166,255,.4); }
.rbadge[data-st="cr_pending"] { color: #d29922; border-color: rgba(210,153,34,.4); }
.rbadge[data-st="cancelled"], .rbadge[data-st="done"] { color: var(--muted); }
.note { color: var(--muted); font-size: 12px; padding: 8px 18px 24px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--surface2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 20;
  box-shadow: 0 6px 24px rgba(0,0,0,.4); max-width: 90vw;
}
.toast.bad { border-color: rgba(248,81,73,.5); }
