/* 管理画面。指示の画面と同じ色・同じ面の作法を使う。
   ここを読むのは「いくらかかったか」を知りたい人なので、
   5つのタブ（メトリクス・データ収集・画像・アカウント・設定）に分け、
   どのタブも、まず図で全体を見せてから表へ落とす。

   面は**紙1枚**にする。節ごとに白いカードを敷くと、どれも同じ高さで浮き、
   どこが大事なのか読めなくなる（並べた箱は順位を持てない）。
   節の切れ目は見出しと細い罫だけで示す。 */

#admin {
  min-height: 100vh; min-height: var(--app-h, 100dvh);
  padding: var(--gap);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--gap);
}
#admin .head {
  min-height: 60px;
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--lift-2);
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  /* 貼り付けない。台の余白ぶんだけ下の中身が帯の上をすり抜けて見えていたし、
     この画面は数画面ぶんしかないので、上へ戻るのに困らない */
}
#admin .body {
  border-radius: var(--r-l);
  background: var(--surface);
  box-shadow: var(--lift-1);
  padding: 22px 24px 26px;
  display: grid; gap: 0;
  align-content: start;
}

/* 節の切れ目。罫は見出しの字面から引き、右へ消す（指示の画面の行と同じ作法） */
#admin .sect { display: grid; gap: 12px; align-content: start; padding: 22px 0 4px; }
#admin .sect + .sect, #admin .two + .sect, #admin .sect + .two, #admin .two + .two {
  border-top: 1px solid var(--separator);
}
#admin .two {
  display: grid; grid-template-columns: 1fr 1fr; column-gap: 34px;
}
#admin .two > .sect + .sect { border-top: 0; }
#admin .two > .sect:last-child { border-left: 1px solid var(--separator); padding-left: 34px; }
#admin h2 { font-size: 15px; font-weight: 600; }
#admin h3 { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .04em; }
#admin .sect-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

/* 先頭。費用だけを大きく出し、残りは文で読ませる。
   同じ大きさの数字を9個並べると、どれを見ればよいのか決まらない */
.lead { display: flex; align-items: baseline; gap: 22px; flex-wrap: wrap; padding-bottom: 4px; }
.cost { display: flex; align-items: baseline; gap: 2px; }
.cost-v {
  font-size: 46px; font-weight: 600; line-height: 1.1;
  color: var(--accent); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.cost-u { font-size: 15px; color: var(--ink-3); }
/* 1行の長さは全角40字までに抑える。広い画面で端まで伸ばすと1行95字になり、
   次の行の頭を探すのに目が迷う */
.lead-text { flex: 1 1 22em; min-width: 0; max-width: 40em; display: grid; gap: 6px; }
.lead-text h2 { color: var(--ink-2); font-size: 12px; letter-spacing: .04em; }
/* 日本語は語の切れ目にスペースが無いので、指定しないと文節の途中で折れる
   （「作ったこと／はまだありません」のように） */
#admin .summary { font-size: 13px; line-height: 1.85; color: var(--ink); word-break: auto-phrase; }
#admin .summary b { font-weight: 600; font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  #admin { --gap: 10px; }
  #admin .body { padding: 16px 16px 20px; }
  #admin .two { grid-template-columns: 1fr; column-gap: 0; }
  #admin .two > .sect:last-child { border-left: 0; padding-left: 0; border-top: 1px solid var(--separator); }
  .cost-v { font-size: 38px; }
}

/* 指示の画面では、帯が細くなると名前を隠す（写真に場所を譲るため）。
   管理画面の帯は横に空いているので、名前は出したままにする */
#admin .brand-name, #admin .brand-ver { display: inline !important; }


/* 機能の入切。何が起きるかを名前の下に書く。
   「入／切」だけの行を並べても、押した先で何が変わるのかは分からない */
.switch-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.switch { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; max-width: 44em; }
.switch input { margin: 2px 0 0; flex: none; }
.switch-body { display: grid; gap: 3px; min-width: 0; }
.switch-name { font-size: 13px; font-weight: 600; }
.switch-why { font-size: 12px; line-height: 1.75; color: var(--ink-3); word-break: auto-phrase; }
.switch-state { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.switch-state[data-on="true"] { color: var(--accent); }

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart text { font-family: var(--font); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
/* 凡例の言葉は折らない。折れると色の四角と字がずれて、どれの説明か読めない */
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* 割合は帯1本で出す。輪の真ん中に合計を置く形は、真ん中の数と外の割合の
   どちらを読むのか決まらないうえ、角度は長さより比べにくい */
.share { display: grid; gap: 9px; }
.share-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--fill-1); }
.share-bar > i { display: block; height: 100%; }
.share-list { display: grid; gap: 5px; }
.share-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 9px; align-items: baseline; font-size: 12px; white-space: nowrap; }
.share-row i { width: 10px; height: 10px; border-radius: 3px; align-self: center; }
.share-row .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.share-row .p { color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

.table-wrap { overflow-x: auto; }
#admin table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#admin th, #admin td { padding: 8px 10px; text-align: left; white-space: nowrap; }
#admin th { font-weight: 600; color: var(--ink-3); font-size: 11.5px; }
#admin tbody tr + tr td { border-top: 1px solid var(--separator); }
#admin td.num, #admin th.num { text-align: right; font-variant-numeric: tabular-nums; }
#admin td.name { white-space: normal; min-width: 180px; }
#admin .pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
#admin .pill.done { background: rgba(26, 110, 62, .12); color: var(--ok); }
#admin .pill.wait { background: var(--accent-12); color: var(--accent); }
#admin .pill.rework { background: rgba(192, 51, 42, .12); color: var(--danger); }
#admin .pill.todo { background: var(--fill-2); color: var(--ink-3); }

/* 誰の行かは、折らずに一行で読ませる。印は札を増やさず、字の脇に小さく添える */
#admin td.who { display: flex; align-items: baseline; gap: 7px; min-width: 240px; }
#admin .who-mail { overflow: hidden; text-overflow: ellipsis; }
#admin .tag { color: var(--accent); font-size: 11px; font-weight: 600; white-space: nowrap; }

/* 単価はその場で直す。表の中に置いて、どのモデルの話かを見失わせない */
#admin .price-in {
  width: 5.5em; padding: 5px 8px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------- 画像一覧 */

/* 元画像と納品物を左右に並べる。カット一覧と同じ見え方にそろえる */
.pairs {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.pair {
  margin: 0; display: grid; gap: 8px;
  border-radius: var(--r-m);
  background: var(--card); box-shadow: var(--lift-1);
  overflow: hidden; cursor: pointer;
  transition: box-shadow .18s var(--ease);
}
.pair:hover { box-shadow: var(--lift-2); }
.pair-shots {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: rgba(92, 101, 112, .18);
}
.pair-shots img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.pair-none {
  display: grid; place-items: center; aspect-ratio: 3 / 4;
  background: var(--fill-1); color: var(--ink-3); font-size: 11px;
}
.pair figcaption {
  display: grid; gap: 2px; padding: 0 11px 12px; min-width: 0;
  font-size: 11px; line-height: 1.6; color: var(--ink-3);
}
.pair b { font-size: 12px; font-weight: 600; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pair figcaption .btn { margin-top: 6px; justify-self: start; }
#admin .tag.gone { margin-left: 6px; color: var(--danger); }

/* 頁送り。表の下にも同じものを使う */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.pager .btn.on { background: var(--accent-12); color: var(--accent); }
.pager .small { margin-left: 6px; }

/* 見比べの窓。左右いっぱいに広げ、矢印で隣のカットへ移る */
.lightbox {
  width: calc(100vw - 32px); max-width: none;
  height: calc(100vh - 32px); height: calc(var(--app-h, 100dvh) - 32px); max-height: none;
  padding: 0; border: 0; border-radius: var(--r-m);
  background: var(--surface); overflow: hidden;
}
.lightbox::backdrop { background: rgba(26, 30, 38, .72); }
.lb-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--separator);
}
.lb-head b { font-size: 14px; }
.lb-head .row { margin-left: auto; }
.lb-body {
  position: relative; height: calc(100% - 53px);
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: rgba(92, 101, 112, .18);
}
.lb-body figure { margin: 0; position: relative; overflow: hidden; background: var(--ground); }
.lb-body img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lb-body figcaption {
  position: absolute; left: 10px; top: 10px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(26, 30, 38, .62); color: #fff; font-size: 11px;
}
.lb-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 64px; padding: 0;
  border: 0; border-radius: var(--r-s);
  background: rgba(26, 30, 38, .55); color: #fff;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.lb-arrow:hover { background: rgba(26, 30, 38, .75); }
.lb-arrow[disabled] { opacity: .25; cursor: default; }
.lb-arrow.prev { left: 10px; }
.lb-arrow.next { right: 10px; }
@media (max-width: 860px) {
  .lb-body { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* 置き場の空き。棒一本で足りる。数字は文のほうに書く */
.gauge { height: 8px; border-radius: 999px; background: var(--fill-2); overflow: hidden; }
.gauge span { display: block; height: 100%; background: var(--accent); transition: width .3s var(--ease); }
.gauge span[data-warn="true"] { background: var(--danger); }


/* ----------------------------------------------------------- タブ

   帯の真ん中に置く。指示の画面の切り替え（丸ピルの溝とつまみ）と同じ部品。
   狭い画面では帯の下の段へ回し、横に流して全部を押せるようにする */
#admin .tabs { margin: 0 auto; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
#admin .tabs::-webkit-scrollbar { display: none; }
#admin .tabs .seg-btn { padding: 6px 16px; }
#admin .head-actions { margin-left: 0; }
@media (max-width: 1100px) {
  #admin .head { flex-wrap: wrap; }
  #admin .tabs { order: 3; flex: 1 1 100%; margin: 0; }
  #admin .head-actions { margin-left: auto; }
}
#admin .panel { display: grid; align-content: start; }
#admin .tabpanel[hidden] { display: none; }
#admin .sub { margin: 14px 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
#admin .sub .small { font-weight: 400; }
#admin .sect > .sub:first-of-type { margin-top: 2px; }
#admin .sect-head .sub { margin: 14px 0 6px; }
#admin .lead .btn { align-self: center; }

/* ----------------------------------------------------------- いまの台

   箱に入れて並べない。名前・大きな数・帯・添え書きを縦に積んだ柱を、
   罫1本ずつで仕切って横に流す（数の大きさで先に目が行き、帯で全体に対する量を読む） */
.now {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  border-top: 1px solid var(--separator);
}
.now-item { display: grid; gap: 5px; align-content: start; padding: 14px 18px 14px 0; min-width: 0; }
.now-item + .now-item { padding-left: 18px; border-left: 1px solid var(--separator); }
.now-name { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.now-v { font-size: 28px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.now-v small { font-size: 13px; font-weight: 400; color: var(--ink-3); margin-left: 2px; }
.now-note { font-size: 11px; color: var(--ink-3); line-height: 1.5; word-break: auto-phrase; }
.meter { display: block; height: 5px; border-radius: 999px; background: var(--fill-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s var(--ease); }
.meter i[data-warn="true"] { background: var(--danger); }
@media (max-width: 700px) {
  .now-item + .now-item { padding-left: 0; border-left: 0; }
  .now-item { border-bottom: 1px solid var(--separator); }
  .now-item:last-child { border-bottom: 0; }
}

/* ----------------------------------------------------------- 時間の図

   指を当てた所の値は札で出す。札は図の上に浮かせ、図の幅からはみ出させない */
.tc { position: relative; }
.tc svg { touch-action: pan-y; }
.tc-hit { cursor: crosshair; }
.tc-tip {
  position: absolute; top: 4px; z-index: 2; pointer-events: none;
  display: grid; gap: 3px; padding: 8px 10px;
  border-radius: var(--r-s); background: var(--surface); box-shadow: var(--lift-2);
  font-size: 11.5px; white-space: nowrap;
}
.tc-tip b { font-weight: 600; font-size: 11px; color: var(--ink-3); }
.tc-tip span { display: flex; align-items: center; gap: 6px; }
.tc-tip i { width: 8px; height: 8px; border-radius: 2px; }
.tc-tip em { margin-left: auto; padding-left: 14px; font-style: normal; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------- 横棒

   名前・帯・数の3列。名前は1行で切り、全文は指を当てると出る */
.hb { display: grid; gap: 7px; }
.hb-row { display: grid; grid-template-columns: minmax(6em, 11em) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 12px; }
.hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.hb-track { display: block; height: 12px; border-radius: 4px; background: var(--fill-1); overflow: hidden; }
.hb-track > i { display: block; height: 100%; border-radius: 4px; }
.hb-v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; text-align: right; min-width: 4.5em; }
.hb-v small { display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-3); }
/* 通った割合。帯の長さが件数、色の境が率 */
.rt { display: flex; height: 100%; border-radius: 4px; overflow: hidden; }
.rt i { display: block; height: 100%; }
.rt-ok { background: var(--ok); }
.rt-ng { background: rgba(192, 51, 42, .55); }
.legend i.rt-ok, .legend i.rt-ng { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ----------------------------------------------------------- アカウント

   1人1段。受け持ちは十二宮の印で並べる ── 入口で光る物と同じ絵なので、
   ここで入れた所がそのまま入口で光ると読める */
.users { display: grid; }
.user { display: grid; gap: 10px; padding: 16px 0; }
.user + .user { border-top: 1px solid var(--separator); }
.user[data-off="true"] > :not(.user-head) { opacity: .5; }
.user-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.user-mail { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.user-when { margin-left: auto; font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.roles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.role {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 7px;
  border-radius: var(--r-s); background: var(--fill-1); cursor: pointer;
  transition: background-color .16s var(--ease);
}
.role input { position: absolute; opacity: 0; pointer-events: none; }
.role i {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink-3); opacity: .35;
  -webkit-mask: var(--src) center / 80% no-repeat; mask: var(--src) center / 80% no-repeat;
}
.role span { display: grid; min-width: 0; font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--ink-3); }
.role small { font-size: 10.5px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role:hover { background: var(--fill-2); }
.role:has(input:checked) { background: var(--accent-12); }
.role:has(input:checked) i { background: var(--accent); opacity: 1; }
.role:has(input:checked) span { color: var(--ink); }
.role:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: 12px; color: var(--ink-2); }
.user-opts label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.user-opts select { width: auto; min-width: 124px; }
.user-acts { margin-left: auto; display: flex; gap: 6px; }
/* 見出しに添える小さな注記。字の間を空白で空けず、余白で離す */
#admin .aside { margin-left: .9em; font-weight: 400; }
.pair:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 口を作る。一覧の上に開く。面を重ねず、細い罫で囲むだけにする */
.new-user {
  display: grid; gap: 14px; padding: 16px 0 18px;
  border-top: 1px solid var(--separator); border-bottom: 1px solid var(--separator);
}
.new-user[hidden], .issued[hidden] { display: none; }
.nu-field { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.nu-field small, .nu-check small { margin-left: .9em; font-weight: 400; color: var(--ink-3); }
.nu-field input { max-width: 26em; font-weight: 400; }
.nu-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.nu-error { color: var(--danger); }

/* 発行したパスワード。一度きりなので、読み違えない字（等幅）で大きめに出す */
.issued {
  display: grid; gap: 10px; padding: 16px 18px;
  border-radius: var(--r-m); background: var(--accent-8);
}
.issued-head { font-size: 13px; }
.issued-pair { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; align-items: baseline; }
.issued-k { font-size: 11.5px; color: var(--ink-3); }
.issued-v { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; user-select: all; }
.issued-pw { font-family: var(--mono); font-size: 18px; letter-spacing: .08em; }

/* 並べて置く欄（組とプラン、メールアドレスとプラン）。狭い画面では縦に積む */
.nu-row { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: end; }
.nu-row .nu-field { flex: 1 1 14em; }
.nu-field select { max-width: 26em; font-weight: 400; }

/* 運営の入口（dev.topx.jp）の入る欄 */
.dev-login { min-height: var(--app-h, 100vh); display: grid; place-items: center; padding: 24px 16px; }
.dev-login[hidden] { display: none; }
.dev-login-box { display: grid; gap: 14px; width: min(22rem, 100%); }
.dev-login-box h1 { margin: 0; font-size: 22px; }
.dev-login-box .nu-field input { max-width: none; }
#admin[hidden] { display: none; }
/* サブスクの時だけ出す欄（label や td は display を持つので、hidden を効かせる） */
#planForm [hidden] { display: none !important; }
#plItems .price-in { width: 7em; }

/* 分析：見ていた場所の升目（写真の中の位置を、見ていた時間で濃く） */
.heat-row { display: flex; flex-wrap: wrap; gap: 16px; }
.heat { margin: 0; display: grid; gap: 6px; }
.heat canvas { width: min(240px, 100%); aspect-ratio: 1; border-radius: 8px; background: #eef0f4; }
.heat figcaption { font-size: 12px; color: var(--ink-2); }
