/* NetBox as a Service — 利用者ポータルと管理者ポータルで共有する CSS
   方向性：正確で静か、実務の道具。色は状態の意味にだけ使う。
   印：正方形のポート LED（状態）と、netbox_id を主にしたホスト名の表示。 */

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
}

:root {
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Hiragino Sans", "Noto Sans JP", monospace;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --raised: #eceef1;
  --sunken: #f1f3f5;
  --line: rgba(20, 24, 31, 0.10);
  --line-strong: rgba(20, 24, 31, 0.20);
  --text: #14181f;
  --text-2: #4a5260;
  --text-3: #646c7a;
  --accent: #1d5bbf;
  --accent-ink: #1a52ad;
  --accent-tint: rgba(29, 91, 191, 0.06);
  --focus: #2f6fdb;

  /* 状態の色（LED と、意味のある箇所だけに使う） */
  --ok: #1f9d57;
  --busy: #2f74e0;
  --wait: #d58a0a;
  --bad: #d83a3a;
  --off: #a2a8b1;
  --bad-ink: #b42828;
  --bad-line: rgba(196, 40, 40, 0.30);
  --bad-tint: rgba(216, 58, 58, 0.05);
  --wait-ink: #9a6206;
  --wait-line: rgba(213, 138, 10, 0.35);
  --wait-tint: rgba(213, 138, 10, 0.06);

  --btn-bg: #14181f;
  --btn-fg: #ffffff;
  --btn-hover: #2a303a;

  --side-bg: #15181d;
  --side-text: #aeb5c0;
  --side-strong: #eef0f3;
  --side-line: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 24, 31, 0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #171a1f;
    --raised: #20242a;
    --sunken: #0d0f12;
    --line: rgba(236, 239, 243, 0.08);
    --line-strong: rgba(236, 239, 243, 0.16);
    --text: #e8ebef;
    --text-2: #a9b0bb;
    --text-3: #868e9a;
    --accent: #6fa3f2;
    --accent-ink: #84b1f5;
    --accent-tint: rgba(111, 163, 242, 0.08);
    --focus: #84b1f5;

    --ok: #46c27f;
    --busy: #5b97f0;
    --wait: #e6a23c;
    --bad: #ec6363;
    --off: #6b727c;
    --bad-ink: #f08080;
    --bad-line: rgba(236, 99, 99, 0.35);
    --bad-tint: rgba(236, 99, 99, 0.06);
    --wait-ink: #f0bd6e;
    --wait-line: rgba(230, 162, 60, 0.35);
    --wait-tint: rgba(230, 162, 60, 0.07);

    --btn-bg: #e8ebef;
    --btn-fg: #111317;
    --btn-hover: #ffffff;

    --side-bg: #0b0d10;
    --side-text: #9aa2ad;
    --side-strong: #eef0f3;

    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

/* ---------- 土台 ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset, pre { margin: 0; }
ul, ol { padding: 0; list-style: none; }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
img, svg { display: block; }
strong, b { font-weight: 600; }
/* 日本語は文節で折り返す（対応していないブラウザでは通常の折り返し） */
body { word-break: auto-phrase; }
h1, h2, h3 { text-wrap: balance; }

a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.muted { color: var(--text-3); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.strong { font-weight: 600; color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: absolute; left: 16px; top: -48px; z-index: 10;
  padding: 8px 12px; border-radius: 8px;
  background: var(--btn-bg); color: var(--btn-fg); text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- 状態の LED（このプロダクトの印） ---------- */

.led {
  display: inline-block; flex: none;
  width: 8px; height: 8px; border-radius: 2px;
  background: var(--off);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.led-ok { background: var(--ok); }
.led-busy { background: var(--busy); }
.led-wait { background: var(--wait); }
.led-bad { background: var(--bad); }
.led-off { background: var(--off); }

/* 処理が実際に動いているときだけ、活動 LED のように点滅させる */
.is-busy .led, .led.is-blink { animation: blink 1.6s steps(2, jump-none) infinite; }
@keyframes blink { 0% { opacity: 1; } 100% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) {
  .is-busy .led, .led.is-blink { animation: none; }
}

.state {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; line-height: 20px; color: var(--text);
  white-space: nowrap;
}
.state-off { color: var(--text-2); }

/* ---------- ホスト名 ---------- */

.fqdn { font-family: var(--mono); letter-spacing: 0; overflow-wrap: anywhere; }
.fqdn-id { color: var(--text); font-weight: 500; }
.fqdn-dom { color: var(--text-3); }

/* ---------- ボタン ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--raised); text-decoration: none; }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.btn-quiet-danger:hover { color: var(--bad-ink); }
.btn-danger { background: var(--bad-ink); color: #fff; }
.btn-danger:hover { background: #9c2020; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }

@media (prefers-color-scheme: dark) {
  .btn-danger { background: #c43c3c; }
  .btn-danger:hover { background: #d44a4a; }
}

.linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit;
}
.linklike:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
form.inline { display: inline; }

/* ---------- 利用者ポータルの枠 ---------- */

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-in {
  max-width: 1120px; margin: 0 auto; padding: 0 32px;
  height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
/* 印：ポートを正面から見た形 */
.brand-short { display: none; }
.brand-mark {
  position: relative; width: 16px; height: 16px; flex: none;
  border: 1.5px solid currentColor; border-radius: 3px;
}
.brand-mark::after {
  content: ""; position: absolute; left: 3px; right: 3px; bottom: 3px; height: 4px;
  background: currentColor; border-radius: 1px;
}
.topnav { display: flex; align-items: center; gap: 24px; font-size: 14px; color: var(--text-2); white-space: nowrap; }
.topnav a:not(.btn) { color: var(--text-2); text-decoration: none; padding: 4px 0; border-top: 2px solid transparent; border-bottom: 2px solid transparent; }
.topnav a:not(.btn):hover { color: var(--text); }
.topnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 40px 32px 64px; }
.main-auth { padding-top: 64px; }

.footer { border-top: 1px solid var(--line); color: var(--text-3); font-size: 13px; }
.footer-in { max-width: 1120px; margin: 0 auto; padding: 20px 32px; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ---------- 共通の部品 ---------- */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; min-height: 40px; }
.page-title { font-size: 26px; line-height: 1.3; font-weight: 500; }
.page-count { font-size: 15px; font-weight: 400; color: var(--text-3); margin-left: 8px; vertical-align: 3px; }
.page-lead { color: var(--text-2); font-size: 14px; margin: -8px 0 24px; max-width: 44rem; }

.crumbs { margin-bottom: 12px; font-size: 14px; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: none; margin-left: -4px; padding: 2px 4px; border-radius: 6px; }
.crumbs a:hover { color: var(--text); background: var(--raised); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; box-shadow: var(--shadow-sm);
}
.panel-title { font-size: 16px; font-weight: 500; line-height: 1.5; margin-bottom: 16px; }
.panel p + p { margin-top: 8px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin-top: 24px; align-items: start; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px; box-shadow: var(--shadow-sm);
}
.card-narrow { max-width: 420px; margin: 0 auto; }
.card-title { font-size: 22px; font-weight: 500; line-height: 1.4; margin-bottom: 8px; }
.card-lead { color: var(--text-2); font-size: 14px; margin-bottom: 24px; }
.card-title + .form, .card-title + .notice { margin-top: 24px; }
.card-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-2); }

.msg-code { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.msg-title { font-size: 22px; font-weight: 500; line-height: 1.4; margin-bottom: 12px; }
.msg-body { color: var(--text-2); font-size: 14px; }
.msg-body + .msg-body { margin-top: 8px; }
.msg-addr { margin-top: 16px; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; overflow-wrap: anywhere; }
.msg .actions { margin-top: 24px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.actions-end { justify-content: flex-end; }

.flash, .notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  font-size: 14px; line-height: 1.6;
}
.flash { margin-bottom: 24px; }
.flash .led, .notice .led { margin-top: 7px; }
.notice { margin-bottom: 20px; }
.notice-bad { border-color: var(--bad-line); background: var(--bad-tint); box-shadow: none; }
.notice-warn { border-color: var(--wait-line); background: var(--wait-tint); box-shadow: none; }
.notice-list { margin: 6px 0 0; padding-left: 1.2em; list-style: disc; }
.notice-list li + li { margin-top: 2px; }

.empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 48px 24px; text-align: center;
}
.empty-title { font-size: 16px; font-weight: 500; }
.empty-text { color: var(--text-2); font-size: 14px; margin: 8px auto 0; max-width: 32rem; }
.empty .btn { margin-top: 20px; }

.taglist + .hint { margin-top: 12px; }
.taglist { display: flex; flex-wrap: wrap; gap: 8px; }
.taglist li { font-size: 13px; line-height: 1; padding: 6px 8px; border-radius: 6px; background: var(--raised); color: var(--text); }

.kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--sunken); font-size: 0.92em; }

.quote { border-left: 2px solid var(--line-strong); padding: 2px 0 2px 12px; margin-top: 16px; }
.quote-label { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.quote-body { font-size: 14px; white-space: pre-wrap; }

.errlog {
  margin-top: 12px; padding: 12px 16px; max-height: 240px; overflow: auto;
  background: var(--sunken); border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
}

/* ---------- フォーム ---------- */

.form > * + * { margin-top: 20px; }
.form-wide { max-width: 760px; }
.form-wide > .panel + .panel { margin-top: 16px; }
.form-wide > .actions { margin-top: 24px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-size: 14px; font-weight: 500; line-height: 1.5; }
.field legend { margin-bottom: 12px; }
.legend-sub { font-weight: 400; color: var(--text-3); font-size: 13px; margin-left: 8px; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  transition: border-color 140ms var(--ease);
}
textarea { height: auto; min-height: 88px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); border-radius: 8px; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: 1; }
input.mono, textarea.mono { font-family: var(--mono); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; }

.hint { font-size: 13px; color: var(--text-3); line-height: 1.6; }
/* 短い補足は、同じ内容のエラーが出ているあいだ隠す */
.field-error { font-size: 13px; color: var(--bad-ink); line-height: 1.6; }

.input-id { font-size: 16px; }
.id-preview { font-size: 18px; line-height: 1.5; margin-top: 6px; }
.id-preview .fqdn-id:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.id-check { display: flex; align-items: center; gap: 8px; min-height: 22px; font-size: 13px; color: var(--text-2); }
.id-check[data-state="idle"] { visibility: hidden; }
.id-check[data-state="available"] .led { background: var(--ok); }
.id-check[data-state="checking"] .led { background: var(--busy); animation: blink 1.6s steps(2, jump-none) infinite; }
.id-check[data-state="invalid_format"] .led, .id-check[data-state="reserved"] .led, .id-check[data-state="taken"] .led { background: var(--bad); }
.id-check[data-state="invalid_format"], .id-check[data-state="reserved"], .id-check[data-state="taken"] { color: var(--bad-ink); }
.id-check[data-state="error"] .led { background: var(--wait); }

.plugins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.plugins-compact { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.plugin {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 10px;
  cursor: pointer; transition: border-color 140ms var(--ease), background-color 140ms var(--ease);
}
.plugin input { margin-top: 3px; }
.plugin:hover { border-color: var(--text-3); }
.plugin:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.plugin:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }
.plugin input:focus-visible { outline: none; }
.plugin-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.plugin-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.plugin-name { font-size: 14px; font-weight: 500; line-height: 1.5; }
.plugin-ver { font-size: 12px; color: var(--text-3); }
.plugin-sum { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.plugin-key { font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 20px; }
.field-inline { gap: 4px; }
.field-inline label { font-size: 12px; font-weight: 400; color: var(--text-3); }
.filters input, .filters select { height: 36px; font-size: 14px; width: 240px; }
.filters select { width: 180px; background-position: calc(100% - 17px) 15px, calc(100% - 12px) 15px; }
.filters .btn { height: 36px; }

.new-layout { display: grid; grid-template-columns: minmax(0, 760px) minmax(0, 1fr); gap: 40px; align-items: start; }
.aside { position: sticky; top: 24px; padding: 4px 0 0; max-width: 300px; }
.aside-title { font-size: 14px; font-weight: 500; margin-bottom: 12px; }
.aside-steps { counter-reset: step; }
.aside-steps li { position: relative; padding: 0 0 16px 32px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.aside-steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 20px; height: 20px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 4px; font-family: var(--mono); font-size: 11px; line-height: 1; color: var(--text-3);
}
.aside-note { font-size: 13px; color: var(--text-3); padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- トップページ ---------- */

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 56px; align-items: center;
  padding: 32px 0 64px;
}
.hero-title { font-size: 36px; line-height: 1.4; font-weight: 500; letter-spacing: 0.01em; text-wrap: wrap; }
.hero-sub { margin-top: 20px; font-size: 16px; line-height: 1.9; color: var(--text-2); max-width: 34rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

.preview {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-md); overflow: hidden;
}
.preview-bar { height: 44px; display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--text-3); }
.preview-row {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  height: 52px; padding: 0 20px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.preview-row.is-main { background: var(--sunken); }
.preview-row .fqdn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta { font-size: 12px; color: var(--text-3); }
.preview-detail { padding: 20px; }
.preview-label { font-size: 12px; color: var(--text-3); }
.preview-url { font-size: 16px; color: var(--accent-ink); font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.preview-note { font-size: 13px; color: var(--text-2); margin-top: 8px; }

.section { padding: 48px 0 0; border-top: 1px solid var(--line); }
.section + .section { margin-top: 48px; }
.section-title { font-size: 20px; font-weight: 500; margin-bottom: 24px; }

.hops-intro { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.hop { display: flex; gap: 16px; align-items: flex-start; }
.hop-no {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 6px; font-size: 13px; color: var(--text-2); background: var(--surface);
}
.hop-title { font-size: 15px; font-weight: 500; line-height: 1.6; }
.hop-text { font-size: 14px; color: var(--text-2); margin-top: 4px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.fact-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.fact p { font-size: 14px; color: var(--text-2); }

/* ---------- インスタンスの一覧 ---------- */

.ilist { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.ilist li + li { border-top: 1px solid var(--line); }
.irow {
  display: grid; grid-template-columns: 128px minmax(0, 1fr) auto 16px; align-items: center; gap: 20px;
  min-height: 60px; padding: 12px 20px; color: var(--text); text-decoration: none;
  transition: background-color 140ms var(--ease);
}
.irow:hover { background: var(--sunken); text-decoration: none; }
.irow:focus-visible { outline-offset: -2px; border-radius: 0; }
.irow-host { font-size: 15px; min-width: 0; }
.irow-state { display: flex; flex-direction: column; gap: 2px; }
.irow-queue { font-size: 12px; color: var(--text-3); padding-left: 18px; }
.irow-meta { display: grid; grid-template-columns: 80px 56px 196px; gap: 24px; font-size: 13px; color: var(--text-3); white-space: nowrap; }
.irow-go { color: var(--text-3); }
.poll-note { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--text-3); }

/* ---------- インスタンスの詳細 ---------- */

.inst-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 24px; }
.inst-title { font-size: 28px; line-height: 1.3; font-weight: 400; min-width: 0; }
.inst-title .fqdn-id { font-weight: 500; }

.live {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 24px 28px; box-shadow: var(--shadow-sm);
}
.live-main { min-width: 0; }
.live-label { font-size: 12px; color: var(--text-3); }
.live-url { display: inline-block; font-size: 20px; font-weight: 500; line-height: 1.4; margin-top: 2px; overflow-wrap: anywhere; text-decoration: none; }
.live-url:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.live-note { margin-top: 8px; font-size: 14px; color: var(--text-2); max-width: 40rem; }
.live .btn { flex: none; }

.phase {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 24px 28px; box-shadow: var(--shadow-sm);
}
.phase-bad { border-color: var(--bad-line); }
.phase-warn { border-color: var(--wait-line); }
.phase-warn .phase-sub { margin-top: 16px; }
.phase-text { font-size: 15px; max-width: 44rem; }
.phase-sub { font-size: 13px; color: var(--text-3); margin-top: 8px; }
.phase .track + .phase-text { margin-top: 20px; }
.phase-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-top: 20px; }
.phase .actions { margin-top: 16px; }

/* 順番待ちの案内 */
.queue-note { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; }
.phase .track + .queue-note { margin-top: 20px; }
.queue-note + .phase-text { margin-top: 8px; color: var(--text-2); }
.queue-n { font-size: 17px; }

/* 承認のボタンのそばの補足 */
.approve-hint { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text-2); margin-bottom: 16px; max-width: 44rem; }
.approve-hint .led { margin-top: 6px; }
.approve-hint.is-bad { color: var(--bad-ink); }
.phase .track + .approve-hint { margin-top: 20px; margin-bottom: 0; }
.phase .approve-hint + .phase-actions { margin-top: 12px; }
/* 却下の理由だけを載せるとき（管理者の却下済みの画面）に、上の余白が空かないようにする */
.phase > .quote:first-child { margin-top: 0; }

/* 申請から稼働までの段階 */
.track { display: flex; align-items: center; max-width: 560px; }
.track-step { display: flex; align-items: center; gap: 8px; flex: 1; font-size: 14px; color: var(--text-3); white-space: nowrap; }
.track-step:last-child { flex: none; }
.track-step:not(:last-child)::after { content: ""; flex: 1; height: 0; border-top: 1px dashed var(--line-strong); margin: 0 12px; min-width: 16px; }
.track-step.is-done:not(:last-child)::after { border-top-style: solid; border-top-color: var(--text-3); }
.track-mark {
  width: 22px; height: 22px; flex: none; display: grid; place-items: center;
  border: 1px dashed var(--line-strong); border-radius: 5px; color: var(--text-3);
}
.track-mark .icon { width: 14px; height: 14px; stroke-width: 2.25; }
.track-step.is-done { color: var(--text-2); }
.track-step.is-done .track-mark { border: 1px solid var(--text-2); color: var(--text-2); }
.track-step.is-current { color: var(--text); font-weight: 500; }
.track-step.is-current .track-mark { border: 1px solid var(--line-strong); background: var(--sunken); }
.track-step.is-todo .track-mark .led { visibility: hidden; }

.props > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.props > div:first-child { border-top: 0; padding-top: 0; }
.props dt { font-size: 13px; color: var(--text-3); line-height: 1.7; }
.props dd { font-size: 14px; min-width: 0; }
.props dd .errlog { margin-top: 0; }

.panel-danger { margin-top: 24px; border-color: var(--bad-line); }

/* 有効期限 */
.expiry { margin-top: 24px; }
.expiry-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 24px; }
.expiry .panel-title { margin-bottom: 4px; }
.expiry-date { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
.expiry-day { font-size: 20px; font-weight: 500; line-height: 1.4; }
.expiry-left { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.expiry-form { flex: none; }
.expiry-note { margin-top: 16px; font-size: 14px; color: var(--text-2); max-width: 44rem; }
.panel.expiry p.hint { margin-top: 4px; }
.expiry-warn { border-color: var(--wait-line); }
.expiry-warn .expiry-left { color: var(--wait-ink); font-weight: 500; }
.expiry-bad { border-color: var(--bad-line); background: var(--bad-tint); box-shadow: none; }
.expiry-bad .expiry-left { color: var(--bad-ink); font-weight: 600; }
.irow-exp { display: inline-flex; align-items: baseline; gap: 4px; }
.irow-left { font-weight: 500; }
.exp-warn { color: var(--wait-ink); }
.exp-bad { color: var(--bad-ink); font-weight: 500; }
.exp-left { font-weight: 500; }
.panel-danger .panel-title { color: var(--bad-ink); }
.panel-danger > p { font-size: 14px; color: var(--text-2); max-width: 44rem; }
.panel-danger .form { margin-top: 20px; max-width: 400px; }
.confirm .actions { margin-top: 12px; }

/* ---------- 管理者ポータル ---------- */

.admin {
  display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; flex: 1;
  /* 左の帯を、ページが長くても下まで伸ばす（色の境目は硬く切る） */
  background: linear-gradient(90deg, var(--side-bg) 0 232px, transparent 232px);
}
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 16px 12px; background: var(--side-bg); color: var(--side-text);
}
.side-head { padding: 4px 8px; height: 40px; display: flex; align-items: center; }
.side .brand { color: var(--side-strong); }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--side-text); text-decoration: none; font-size: 14px;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.sidenav a:hover { background: rgba(255, 255, 255, 0.05); color: var(--side-strong); }
.sidenav a[aria-current="page"] { background: rgba(255, 255, 255, 0.09); color: var(--side-strong); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.sidenav a:focus-visible { outline-color: #9cc0f7; }
.count { font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 4px; background: rgba(230, 162, 60, 0.18); color: #f0c27a; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.side-user { font-size: 12px; color: var(--side-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .linklike { color: var(--side-strong); font-size: 13px; text-align: left; }
.side-foot .linklike:hover { color: #fff; }
.admin-main { padding: 32px 40px 64px; max-width: 1280px; width: 100%; }

.portal-admin .topbar { background: var(--side-bg); border-bottom-color: transparent; }
.portal-admin .topbar .brand { color: var(--side-strong); }

.tally {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.tally-item { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tally-item + .tally-item { border-left: 1px solid var(--line); }
.tally dt .state { font-size: 13px; color: var(--text-2); }
.tally dd { font-size: 20px; font-weight: 500; line-height: 1; }
/* 稼働数と処理の件数（承認待ちの画面の上段） */
.tally.tally-ops { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 12px; }
.tally-ops dt { font-size: 13px; color: var(--text-2); }
.tally-ops dd { display: flex; align-items: baseline; gap: 4px; }
.tally-ops .tally-text { font-size: 13px; font-weight: 400; color: var(--text-2); gap: 4px; }
.tally-ops .tally-text .tally-n { font-size: 20px; font-weight: 500; color: var(--text); }
.tally-of { font-size: 14px; font-weight: 400; color: var(--text-3); }
.tally-ops .is-full .tally-n { color: var(--bad-ink); }

.queue > li + li { margin-top: 12px; }
.queue-more { margin-top: 16px; font-size: 13px; color: var(--text-2); }
.req {
  display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 32px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; box-shadow: var(--shadow-sm);
}
.req-host { font-size: 18px; font-weight: 400; line-height: 1.4; }
.req-host a { text-decoration: none; color: inherit; }
.req-host a:hover .fqdn-id { text-decoration: underline; text-underline-offset: 3px; }
.req-who { font-size: 14px; margin-top: 4px; }
.req-who .mono { font-size: 13px; margin-left: 8px; }
.req-props { display: flex; flex-wrap: wrap; gap: 4px 32px; margin-top: 12px; font-size: 13px; }
.req-props > div { display: flex; gap: 8px; }
.req-props dt { color: var(--text-3); }
.req-actions { display: flex; flex-direction: column; gap: 8px; }

.reject summary { list-style: none; }
.reject summary::-webkit-details-marker { display: none; }
.reject[open] summary { background: var(--raised); }
.reject .form { margin-top: 12px; }
.reject .form > * + * { margin-top: 12px; }
.phase-actions .reject { flex: 1; max-width: 420px; }
.phase-actions .reject:not([open]) { flex: none; }

.table-wrap + .hint { margin-top: 12px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--sunken); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; line-height: 1.5; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--sunken); }
.table .num { text-align: right; }
.table td.mono { font-size: 13px; }
.table tr.is-dim td:not(.cell-action) { color: var(--text-3); }
.rowlink { text-decoration: none; color: inherit; white-space: nowrap; }
.rowlink:hover .fqdn-id { text-decoration: underline; text-underline-offset: 3px; }
.cell-2 { display: flex; flex-direction: column; gap: 2px; }
.cell-2 .mono, .cell-2 .small { font-size: 12px; }
.cell-action { text-align: right; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 4px; }
.role { display: inline-block; width: fit-content; font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 4px; }
.role-admin { background: var(--accent-tint); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--line); }
.cell-wide { min-width: 280px; color: var(--text-2); }
.errline { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

.events li { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; padding-top: 0; }
.event-time { font-size: 12px; color: var(--text-3); line-height: 1.9; }
.event-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 14px; min-width: 0; }
.event-type { font-weight: 500; }
.event-actor { font-size: 12px; color: var(--text-3); }
.event-detail { flex-basis: 100%; font-size: 12px; color: var(--text-2); overflow-wrap: anywhere; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; }
.pager-pos { font-size: 13px; color: var(--text-3); }

/* ---------- 画面幅ごとの調整 ---------- */

@media (max-width: 960px) {
  .new-layout { grid-template-columns: minmax(0, 1fr); }
  .aside { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 8px; }
  .hops-intro, .facts { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .tally { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tally-item:nth-child(4) { border-left: 0; }
  .tally-item:nth-child(n+4) { border-top: 1px solid var(--line); }
}

@media (max-width: 860px) {
  .admin { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px; }
  .side-head { padding: 0; }
  .sidenav { order: 3; flex-direction: row; overflow-x: auto; width: calc(100% + 32px); margin: 0 -16px; padding: 0 12px 4px; gap: 4px; scrollbar-width: none; }
  .sidenav a { flex: none; height: 32px; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 12px; }
  .side-user { display: none; }
  .admin-main { padding: 24px 16px 48px; }
  .req { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .topbar-in { padding: 0 16px; }
  .brand-long { display: none; }
  .brand-short { display: inline; }
  .topnav { gap: 16px; font-size: 13px; }
  .main { padding: 24px 16px 48px; }
  .main-auth { padding-top: 24px; }
  .footer-in { padding: 16px; }
  .card { padding: 24px 20px; }
  .panel, .phase, .live { padding: 20px; }
  .page-title { font-size: 22px; }
  .hero-title { font-size: 28px; line-height: 1.45; }
  .hero-sub { font-size: 15px; }
  .br-wide { display: none; }
  .hero-actions .btn { flex: 1; }
  .preview-row { grid-template-columns: 88px minmax(0, 1fr); }
  .preview-row .preview-meta { display: none; }
  .preview-url { font-size: 14px; }
  .preview-row { font-size: 13px; gap: 12px; padding: 0 16px; }
  .section { padding-top: 32px; }
  .section + .section { margin-top: 32px; }

  .irow { grid-template-columns: minmax(0, 1fr) 16px; grid-template-areas: "host go" "state go" "meta go"; gap: 4px 12px; padding: 14px 16px; }
  .irow-host { grid-area: host; }
  .irow-state { grid-area: state; flex-direction: row; align-items: baseline; gap: 8px; }
  .irow-queue { padding-left: 0; }
  .irow-meta { grid-area: meta; display: flex; gap: 4px 16px; font-size: 12px; flex-wrap: wrap; }
  .irow-go { grid-area: go; }

  .inst-title { font-size: 20px; }
  .live { flex-direction: column; align-items: stretch; }
  .live-url { font-size: 16px; }
  .live .btn { width: 100%; }
  .props > div { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .plugins { grid-template-columns: minmax(0, 1fr); }
  .actions-end { flex-direction: column-reverse; align-items: stretch; }
  .actions-end .btn { width: 100%; }
  .track-step:not(:last-child)::after { margin: 0 8px; min-width: 8px; }
  .track-step { font-size: 13px; gap: 6px; }
  .page-head .btn { height: 36px; padding: 0 12px; font-size: 13px; }

  .tally { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tally-item { padding: 12px 16px; }
  .tally-item:nth-child(n) { border-left: 0; border-top: 1px solid var(--line); }
  .tally-item:nth-child(-n+2) { border-top: 0; }
  .tally-item:nth-child(even) { border-left: 1px solid var(--line); }
  .tally-item:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tally.tally-ops { grid-template-columns: minmax(0, 1fr); }
  .tally-ops .tally-item:nth-child(n) { border-left: 0; }
  .tally-ops .tally-item + .tally-item { border-top: 1px solid var(--line); }
  .filters .field-inline { flex: 1 1 140px; }
  .filters input, .filters select { width: 100%; }
  .events li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .req-actions { flex-direction: column; }
}
