/* clinea 利用状況ダッシュボード */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --card: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --line: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.04);
  --btn: #0b0b0b;
  --btn-ink: #ffffff;
  --up: #006300;
  --down: #d03b3b;
  --focus: #2a78d6;
  --s-calendar: #1baf7a;
  --s-ikkatsu: #2a78d6;
  --s-souba: #eb6834;
  --s-type: #4a3aa7;
  --s-signup: #52514e;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 6px 18px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --card: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --line: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.05);
    --btn: #ffffff;
    --btn-ink: #0b0b0b;
    --up: #0ca30c;
    --down: #e66767;
    --focus: #3987e5;
    --s-calendar: #199e70;
    --s-ikkatsu: #3987e5;
    --s-souba: #d95926;
    --s-type: #9085e9;
    --s-signup: #c3c2b7;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --card: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --line: rgba(255, 255, 255, 0.1);
  --wash: rgba(255, 255, 255, 0.05);
  --btn: #ffffff;
  --btn-ink: #0b0b0b;
  --up: #0ca30c;
  --down: #e66767;
  --focus: #3987e5;
  --s-calendar: #199e70;
  --s-ikkatsu: #3987e5;
  --s-souba: #d95926;
  --s-type: #9085e9;
  --s-signup: #c3c2b7;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ 枠 */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1120px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand small { color: var(--muted); font-size: 11.5px; letter-spacing: .04em; }
.brand b { font-size: 16px; font-weight: 700; white-space: nowrap; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-mail { color: var(--ink-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.tabs {
  max-width: 1120px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: none; padding: 8px 12px 10px; cursor: pointer;
  color: var(--ink-2); font-size: 14px; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }
.bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.stamp { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* ------------------------------------------------------------ 部品 */
.seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--wash); border: 1px solid var(--line);
}
.seg button {
  border: 0; background: none; cursor: pointer; padding: 5px 13px; border-radius: 999px;
  color: var(--ink-2); font-size: 13.5px; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--btn); background: var(--btn); color: var(--btn-ink);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px;
  white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); font-weight: 500; }
.btn--ghost:hover { background: var(--wash); }
.btn--s { padding: 5px 12px; font-size: 13px; }
.btn--danger { color: var(--down); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.card h2 { font-size: 15px; margin: 0; font-weight: 700; }
.card .sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; }
.grid { display: grid; gap: 14px; }
.grid--metrics { display: flex; flex-wrap: wrap; }
.grid--metrics > .card { flex: 1 1 300px; min-width: 0; }
.grid--two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 14px; }
.space { margin-top: 14px; }

/* ------------------------------------------------------------ 指標カード */
.metric-head { display: flex; align-items: baseline; gap: 8px; }
.key { width: 10px; height: 10px; border-radius: 3px; flex: none; align-self: center; }
.metric-name { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.metric-value { font-size: 32px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; margin-top: 6px; }
.note-start { color: var(--muted); }
.metric-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.delta { font-size: 12.5px; color: var(--muted); margin-top: 2px; min-height: 20px; }
.delta b { font-weight: 600; }
.delta .up { color: var(--up); }
.delta .down { color: var(--down); }
.chart { position: relative; margin-top: 10px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .hit { cursor: crosshair; }
.chart .hit:focus-visible { outline: none; }
.chart:focus-within .cross { stroke: var(--focus); }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.cross { stroke: var(--ink-2); stroke-width: 1; }

.tip {
  position: absolute; z-index: 3; pointer-events: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s);
  box-shadow: 0 4px 16px rgba(0,0,0,.12); padding: 7px 10px; font-size: 12.5px; white-space: nowrap;
}
.tip .tip-day { color: var(--muted); }
.tip .tip-row { display: flex; align-items: center; gap: 6px; }
.tip .tip-row b { font-size: 15px; }
.tip .tip-key { width: 12px; height: 2px; border-radius: 1px; }

/* ------------------------------------------------------------ 横棒 (入口・流れ) */
.hbars { margin-top: 12px; display: grid; gap: 12px; }
.hbar-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.hbar-label span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-label b { color: var(--ink); }
.hbar-track { height: 10px; margin-top: 5px; border-radius: 4px; background: var(--wash); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.flow { margin-top: 16px; }
.flow + .flow { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.flow h3 { font-size: 13.5px; margin: 0; font-weight: 600; color: var(--ink-2); }
.note { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }

/* ------------------------------------------------------------ 表 */
.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius-s); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
td.text, th.text { text-align: left; }
/* 横に流しても日付 (1 列目) が見えるように */
th:first-child, td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); }
thead th:first-child, tfoot td:first-child { background: var(--surface); }
thead th:first-child { z-index: 3; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); color: var(--ink-2); font-weight: 600; font-size: 12.5px; }
th.sub-col, td.sub-col { color: var(--ink-2); }
th.sub-col { font-weight: 500; }
tbody tr:hover { background: var(--wash); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 1px solid var(--axis); border-bottom: 0; background: var(--surface); }
td { font-variant-numeric: tabular-nums; }
td.zero { color: var(--muted); }
.sort { border: 0; background: none; padding: 0; cursor: pointer; font-weight: inherit; color: inherit; }
.sort[aria-sort]::after { content: " ↓"; }
.sort[aria-sort="ascending"]::after { content: " ↑"; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.input {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-s);
  padding: 8px 12px; font-size: 14px; min-width: 0;
}
.toolbar .input { flex: 1 1 220px; max-width: 360px; }

/* ------------------------------------------------------------ 一括くんの登録者 */
.figures { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.figure { display: flex; flex-direction: column; padding: 12px 14px; border-radius: var(--radius-s); background: var(--wash); min-width: 0; }
.figure-label { color: var(--ink-2); font-size: 13px; }
.figure-value { font-size: 26px; font-weight: 700; line-height: 1.25; }
.figure-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.figure-note { color: var(--muted); font-size: 12px; }
td.wrap { white-space: normal; min-width: 160px; max-width: 280px; }
/* 長い一覧は枠の中でスクロールする (見出しは上に残る) */
.table-wrap--tall { max-height: min(640px, 75vh); overflow: auto; }
.grid--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ------------------------------------------------------------ ログイン */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate .card { width: 100%; max-width: 400px; padding: 28px 24px; }
.gate h1 { font-size: 20px; margin: 4px 0 6px; }
.gate p { color: var(--ink-2); font-size: 14px; margin: 0 0 18px; }
.gate .brand small { display: block; }
.gate form { display: grid; gap: 10px; }
.gate label { font-size: 13px; color: var(--ink-2); }
.gate .input { width: 100%; padding: 11px 12px; font-size: 16px; }
.gate .btn { width: 100%; padding: 12px 16px; }
.msg { font-size: 13.5px; margin: 12px 0 0; padding: 10px 12px; border-radius: var(--radius-s); background: var(--wash); color: var(--ink-2); }
.msg.err { color: var(--down); }

/* ------------------------------------------------------------ メンバー */
.invite { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; margin-top: 12px; }
.invite .input { width: 100%; }
.roles { margin: 10px 0 0; padding: 0; list-style: none; color: var(--ink-2); font-size: 13px; display: grid; gap: 2px; }
.roles b { color: var(--ink); font-weight: 600; }
.state-wait { color: var(--muted); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
select.input { padding-right: 28px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.loading { opacity: .55; transition: opacity .15s; }

@media (max-width: 520px) {
  .who-mail { display: none; }
  .metric-value { font-size: 28px; }
  .grid--two { grid-template-columns: minmax(0, 1fr); }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--pair { grid-template-columns: minmax(0, 1fr); }
  .invite { grid-template-columns: minmax(0, 1fr) auto; }
  .invite .btn { grid-column: 1 / -1; }
  .stamp { margin-left: 0; width: 100%; }
  .card { padding: 14px 14px; }
}
