/* アサシンツールズ 管理画面（暗色の土台・差し色1色・外部フォントなし） */
:root {
  --bg: #0d0d10;
  --bg2: #141418;
  --panel: #18181d;
  --line: #2a2a31;
  --text: #e4e4e8;
  --muted: #8b8b95;
  --dim: #5c5c66;
  --bar: #4a4a53;
  --bar2: #34343b;
  --accent: #c8102e;
  --accent-soft: rgba(200, 16, 46, .14);
  --ok: #4fae7b;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
body.accent-gold { --accent: #b8913a; --accent-soft: rgba(184, 145, 58, .15); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #fff; }
h1, h2 { font-weight: 600; letter-spacing: .02em; margin: 0; }
h1 { font-size: 20px; }
h2 { font-size: 14px; color: var(--muted); margin-bottom: 14px; text-transform: none; }
h1 small, h2 small { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 8px; }
code { font-family: var(--mono); font-size: 12px; color: #cfcfd6; }

/* 上部バー */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 13px; letter-spacing: .28em; color: var(--text); }
.brand b { color: var(--accent); font-weight: 700; }
.mainnav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.mainnav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.mainnav a:hover { color: var(--text); background: var(--panel); }
.mainnav a.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--dim); font-size: 12px; }

.main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }

/* ボタン・入力 */
.btn {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; letter-spacing: .08em; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.btn.wide { width: 100%; padding: 11px; }
input[type=text], input[type=password], select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 14px; }
label input { margin-top: 6px; }
.hint { display: block; color: var(--dim); margin-top: 4px; }
.req, .opt { font-size: 10px; margin-left: 6px; padding: 1px 6px; border-radius: 3px; }
.req { background: var(--accent-soft); color: var(--accent); }
.opt { background: var(--bar2); color: var(--muted); }

/* お知らせ */
.alert, .flash { padding: 10px 14px; border-radius: var(--radius); margin: 0 0 16px; }
.alert { background: var(--accent-soft); border: 1px solid var(--accent); color: #ffd6dc; }
body.accent-gold .alert { color: #f3e3bd; }
.flash { background: rgba(79, 174, 123, .12); border: 1px solid var(--ok); color: #c9f0da; }
.note { color: var(--dim); font-size: 12px; margin: 12px 0 0; }
.empty { color: var(--dim); }

/* ページ見出し */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.scope-form { display: flex; align-items: center; gap: 8px; }
.scope-form label { margin: 0; }
.scope-form select { width: auto; min-width: 220px; }

/* パネル */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel.narrow { max-width: 420px; margin: 80px auto; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2 .panel { margin-bottom: 0; }
.grid2 > * { min-width: 0; }

/* 数字タイル */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.tile:first-child { border-top: 2px solid var(--accent); }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .v.muted { color: var(--muted); }
.tile .s { color: var(--dim); font-size: 11px; }

/* グラフ */
.chart { width: 100%; min-height: 220px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { fill: var(--dim); font-size: 10px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--bar); }
.chart .bar.today { fill: var(--accent); }
.chart .uu { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 3; }
.chart .uu-dot { fill: var(--muted); }
.chart .uu-dot.today { fill: var(--accent); }
.chart .val { fill: var(--text); font-size: 11px; font-weight: 600; }
.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.legend .l-pv { background: var(--bar); }
.legend .l-today { background: var(--accent); }
.legend .l-uu { border-top: 2px dashed var(--muted); height: 0; width: 14px; }
.chart-tip { position: fixed; pointer-events: none; background: #000; border: 1px solid var(--line); padding: 6px 10px; border-radius: 4px; font-size: 12px; z-index: 20; white-space: nowrap; }

/* 表 */
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { color: var(--dim); font-weight: 500; font-size: 12px; }
table.data .num { text-align: right; }
table.data tr.today td { color: var(--accent); }
.table-toggle { margin-top: 12px; }
.table-toggle summary { color: var(--muted); cursor: pointer; font-size: 12px; }

/* サイト登録 */
.site-form { display: grid; grid-template-columns: 2fr 1.4fr 1fr auto; gap: 14px; align-items: start; }
.site-form .btn { margin-top: 24px; white-space: nowrap; }
.site-list { list-style: none; margin: 0; padding: 0; }
.site { border-top: 1px solid var(--line); padding: 14px 0; }
.site:first-child { border-top: 0; padding-top: 0; }
.site.child { margin-left: 24px; padding-left: 14px; border-left: 2px solid var(--bar2); }
.site.stopped { opacity: .55; }
.site-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.site-head form { margin: 0; }
.site-name { font-size: 15px; font-weight: 600; margin-right: 8px; }
.site-name em { font-style: normal; color: var(--accent); }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--bar2); color: var(--muted); margin-right: 4px; }
.badge.on { background: rgba(79, 174, 123, .15); color: var(--ok); }
.badge.off { background: var(--bar2); color: var(--dim); }
.site-meta { color: var(--dim); font-size: 12px; margin: 6px 0 8px; }
.tag-box { display: flex; gap: 8px; }
.tag-input { font-family: var(--mono) !important; font-size: 12px !important; color: #cfcfd6 !important; }

/* ログイン */
body.bare {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, var(--accent-soft), transparent 60%),
    repeating-linear-gradient(135deg, transparent 0 22px, rgba(255, 255, 255, .012) 22px 23px),
    var(--bg);
}
.bare-main { width: 100%; padding: 24px 16px; }
.login-card {
  max-width: 360px; margin: 0 auto; padding: 36px 32px 28px;
  background: rgba(20, 20, 24, .92); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .03);
  position: relative;
}
.login-card::before { content: ""; position: absolute; left: 24px; right: 24px; top: -1px; height: 2px; background: var(--accent); }
.login-emblem { text-align: center; margin-bottom: 10px; }
.login-title { text-align: center; font-size: 15px; letter-spacing: .38em; font-weight: 500; }
.login-title b { color: var(--accent); }
.login-sub { text-align: center; color: var(--dim); font-size: 12px; letter-spacing: .2em; margin: 6px 0 24px; }

/* 絞り込み */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 10px; }
.f-item { display: flex; align-items: center; gap: 8px; }
.f-item label { margin: 0; white-space: nowrap; }
.f-item select { width: auto; min-width: 220px; }
.f-item input[type=date] { width: auto; }
.sep { color: var(--dim); }
input[type=date], input[type=number] {
  font: inherit; color: var(--text); background: var(--bg); color-scheme: dark;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 8px;
}
input[type=number] { width: 100%; margin-top: 6px; }
.presets { display: flex; gap: 4px; flex-wrap: wrap; }
.presets a, .tabs a { font-size: 12px; text-decoration: none; color: var(--muted); padding: 3px 10px; border: 1px solid var(--line); border-radius: 12px; }
.presets a:hover, .tabs a:hover { color: var(--text); border-color: var(--muted); }
.presets a.on, .tabs a.on { color: #fff; border-color: var(--accent); background: var(--accent-soft); }
.compare { margin-bottom: 18px; }
.compare summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.compare form { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 10px; }
label.chk { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); font-size: 13px; }
.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.tabs .note { margin: 0 0 0 8px; }
.group-title { color: var(--text); font-size: 15px; margin: 8px 0 12px; padding-left: 10px; border-left: 3px solid var(--accent); }

/* 表の補助 */
.table-wrap { overflow-x: auto; }
table.data td.url { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.ua { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
table.data th a { color: var(--dim); text-decoration: none; }
table.data th a.sorted { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
table.data tr.bad td { color: #e8a0ab; }
body.accent-gold table.data tr.bad td { color: #e3c98c; }
.barcell { width: 30%; }
meter { width: 100%; height: 8px; }
meter::-webkit-meter-bar { background: var(--bar2); border: 0; border-radius: 4px; height: 8px; }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value { background: var(--bar); border-radius: 4px; }
meter.top::-webkit-meter-optimum-value, meter.top::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { background: var(--accent); border-radius: 4px; }
meter::-moz-meter-bar { background: var(--bar); }
meter.top::-moz-meter-bar { background: var(--accent); }
.tile meter { margin-top: 8px; }
.tile .v small { font-size: 13px; color: var(--muted); font-weight: 400; }
.tiles.tiles3 { grid-template-columns: repeat(3, 1fr); }

/* フォーム */
form.stack { display: block; }
form.stack .btn { margin-top: 4px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 12px; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
.panel.narrow-left { max-width: 560px; }
.grid2.wide-left { grid-template-columns: 2fr 1fr; }
.grid2 + .grid2 { margin-top: 20px; }
.grid2 { margin-bottom: 20px; }

@media (max-width: 860px) {
  .mainnav { overflow-x: auto; scrollbar-width: none; }
  .mainnav a { white-space: nowrap; }
  .f-item select { min-width: 0; width: 100%; }
  .f-item { flex-wrap: wrap; }
  .tiles.tiles3 { grid-template-columns: 1fr; }
  .grid2.wide-left { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .site-form { grid-template-columns: 1fr; }
  .site-form .btn { margin-top: 0; }
  .topbar { padding: 0 16px; gap: 12px; }
  .brand span, .who { display: none; }
  .main { padding: 20px 16px 48px; }
}

/* APIキー */
table.data tr.dim td { color: var(--dim); }
.panel.issued { border-color: var(--accent); }
.panel.issued strong { color: var(--accent); }
.site-form fieldset { margin: 0; }
.api-form { display: grid; grid-template-columns: 1.2fr 2fr 0.8fr 0.9fr; gap: 14px; align-items: start; }
.api-form fieldset { margin: 0; }
.api-form .btn { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 860px) { .api-form { grid-template-columns: 1fr; } }

/* 変更・削除 */
.site-actions { display: flex; gap: 6px; }
.site-actions form { margin: 0; }
.btn.danger { color: #ff9aa9; border-color: rgba(200, 16, 46, .5); }
.btn.danger:hover { border-color: var(--accent); background: var(--accent-soft); }
.site-edit { margin-top: 10px; }
.site-edit summary, details summary.h2-like { color: var(--muted); font-size: 12px; cursor: pointer; }
details summary.h2-like { font-size: 14px; font-weight: 600; }
details summary.h2-like small { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 8px; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.inline-form input[type=text] { flex: 1; }
.note.warn { color: #e8c07a; }
.deleted-list { margin-top: 14px; }
.edit-row td { background: var(--bg2); }
.edit-grid { display: grid; grid-template-columns: 1.2fr 2fr .8fr .9fr auto; gap: 12px; align-items: end; padding: 8px 0; }
.edit-grid label { margin: 0; }
.edit-grid fieldset { margin: 0; }
@media (max-width: 860px) { .edit-grid { grid-template-columns: 1fr; } .inline-form { flex-wrap: wrap; } }
