/*
 * 明るいトーンで統一する。ダークは用意しない。
 * 1画面に収める設計: ページ自体はスクロールさせず、各ペインの中だけをスクロールさせる。
 */
:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f7;
  --border: #e6e9ef;
  --border-strong: #d3d8e2;
  --text: #1a1d23;
  --text-dim: #5c6472;
  --text-faint: #8d95a3;
  --accent: #2f6bdd;
  --error: #c0392f;
  --error-bg: #fdf2f1;
  --warn: #9a6a10;
  --warn-bg: #fdf8ec;
  --ok: #227a4d;
  --ok-bg: #eef8f2;
  --radius: 10px;

  /* チャート。系列は1本しか出さないので単色。目盛と罫は後退させる */
  --series-1: #2a78d6;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-muted: #898781;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top-spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- header */
header.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 14.5px; font-weight: 650; white-space: nowrap; }
.meta { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.views { display: flex; gap: 4px; }
.vtab {
  font: inherit;
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.vtab:hover { background: var(--surface-2); }
.vtab[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
  font-weight: 600;
}

button.btn {
  font: inherit;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.btn:hover { background: var(--surface-2); }
button.btn:disabled { opacity: .5; cursor: default; }

/* ---------------------------------------------------------------- 1画面レイアウト */
.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 20px 16px;
}

.summary { flex: 0 0 auto; display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  font: inherit;
  text-align: left;
  flex: 1 1 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  color: var(--text);
}
.stat.today { cursor: default; background: var(--surface-2); }
button.stat:hover { border-color: var(--border-strong); }
.stat-v {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.25;
}
.stat.today .stat-v { font-size: 15px; font-weight: 550; }
.stat-l { font-size: 11px; color: var(--text-faint); }
.stat.bad .stat-v { color: var(--error); }
.stat.attn .stat-v { color: var(--warn); }
.stat.good .stat-v { color: var(--ok); }
.stat.muted .stat-v { color: var(--text-faint); }

.panes {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
}
.panes.single { grid-template-columns: minmax(0, 1fr); }

.pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.pane-head {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.pane-head.bordered { border-top: 1px solid var(--border); }
.pane-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; }
.pane-side .pane-body { flex: 1 1 50%; }

h2 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .03em;
  color: var(--text-dim);
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
h2 .count { color: var(--text-faint); font-weight: 400; font-size: 11.5px; }

.linkbtn {
  font: inherit;
  font-size: 11.5px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-weight: 400;
  letter-spacing: 0;
}
.linkbtn:hover { text-decoration: underline; }

.empty {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
}

/* ---------------------------------------------------------------- 事業タブ */
.filters { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  font: inherit;
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }

/* ---------------------------------------------------------------- プロダクト一覧 */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 10px; }
.prod {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  background: var(--surface);
}
.prod:hover { border-color: var(--border-strong); background: var(--surface-2); }
.prod:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.prod.pending { border-style: dashed; }
.prod-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.prod-name { font-size: 13.5px; font-weight: 650; }
.pill {
  font-size: 10.5px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  margin-left: auto;
}
.pill.ok { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.pill.attn { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pill.bad { color: var(--error); background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 30%, transparent); }
.pill.off { border-style: dashed; }

.prod-rows { display: flex; flex-direction: column; gap: 7px; }
.prow { display: grid; grid-template-columns: 1fr auto 90px; align-items: center; gap: 8px; }
.prow-l {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prow-v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.prow-s { display: block; }
.prow .delta { grid-column: 1 / -1; font-size: 11px; margin-top: -3px; }

/* ---------------------------------------------------------------- KPIカード */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.kpi {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 11px 13px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}
.kpi:hover { border-color: var(--border-strong); }
.kpi:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.kpi.selected { border-color: var(--series-1); box-shadow: 0 0 0 1px var(--series-1) inset; }
.kpi.pending { border-style: dashed; cursor: default; }
.khead { display: flex; align-items: center; gap: 8px; }
.khead .label {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prov {
  font-size: 10px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  white-space: nowrap;
  margin-left: auto;
  cursor: help;
}
.prov.primary { color: var(--ok); background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.prov.sheet { color: var(--warn); background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.prov.pending { border-style: dashed; }
.kpi .value {
  font-size: 23px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.kpi .value.muted { color: var(--text-faint); }
.kpi .value .unit { font-size: 12px; font-weight: 400; color: var(--text-dim); margin-left: 3px; }
.kpi .flag {
  font-size: 11px;
  color: var(--error);
  border-top: 1px solid var(--border);
  margin-top: 5px;
  padding-top: 6px;
}

.delta { font-size: 11.5px; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 4px; }
.delta .arrow { font-size: 9px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--error); }
.delta.flat { color: var(--text-faint); }

.spark { display: block; width: 100%; height: 32px; margin-top: 3px; }
.spark .line { fill: none; stroke: var(--series-1); stroke-width: 1.6; stroke-linejoin: round; }
.spark .fill { fill: color-mix(in srgb, var(--series-1) 11%, transparent); stroke: none; }
.prow .spark { height: 20px; margin: 0; }

/* ---------------------------------------------------------------- チャート */
.chartbox { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 6px; }
.chart-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-title { font-size: 13.5px; font-weight: 650; }
.chart-sub { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; }
.chart-svg { display: block; width: 100%; height: 190px; }
.chart-svg .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-svg .axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--chart-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .fill { fill: color-mix(in srgb, var(--series-1) 10%, transparent); stroke: none; }
.chart-svg .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-svg .cross { stroke: var(--chart-axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .hit { fill: transparent; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(11, 11, 11, .08);
  white-space: nowrap;
  z-index: 5;
}
.chart-empty { height: 190px; display: grid; place-items: center; color: var(--text-faint); font-size: 12.5px; }

/* ---------------------------------------------------------------- 今日やること */
.titem {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.titem + .titem { margin-top: 2px; }
.titem.bad { background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 22%, transparent); }
.titem.attn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.tname { font-size: 12.5px; line-height: 1.4; }
.tlink { font-size: 11.5px; white-space: nowrap; }
.sub { color: var(--text-dim); font-size: 11px; display: block; }

.due { display: flex; flex-direction: column; font-variant-numeric: tabular-nums; white-space: nowrap; }
.due-d { font-size: 12.5px; }
.due-s { font-size: 10.5px; }
.due.overdue .due-d, .due.overdue .due-s { color: var(--error); font-weight: 600; }
.due.today .due-d, .due.today .due-s { color: var(--warn); font-weight: 600; }
.due.soon .due-s, .due.later .due-d, .due.later .due-s { color: var(--text-dim); }
.due.anytime { color: var(--text-faint); font-size: 12px; }

/* ---------------------------------------------------------------- 要対応 */
.alert {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 12px 9px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.alert + .alert { margin-top: 6px; }
.alert .bar { background: var(--border-strong); align-self: stretch; }
.alert.error { background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 28%, transparent); }
.alert.error .bar { background: var(--error); }
.alert.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.alert.warn .bar { background: var(--warn); }
.alert .subject { font-weight: 600; font-size: 12px; }
.alert .msg { font-size: 12px; line-height: 1.45; }
.alert .detail { font-size: 11px; color: var(--text-dim); margin-top: 1px; font-variant-numeric: tabular-nums; }
.alert .go { font-size: 11.5px; white-space: nowrap; padding-top: 1px; }

/* ---------------------------------------------------------------- テーブル */
.grid-table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.grid-table th, .grid-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.grid-table th {
  font-size: 11px;
  letter-spacing: .03em;
  color: var(--text-faint);
  font-weight: 500;
  white-space: nowrap;
}
.grid-table tbody tr:last-child td { border-bottom: none; }
.grid-table tbody tr:hover { background: var(--surface-2); }
.grid-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.search {
  font: inherit;
  font-size: 12.5px;
  padding: 5px 11px;
  width: 240px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
}
.tag {
  display: inline-block;
  font-size: 10.5px;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  white-space: nowrap;
}
.tag.noaccess { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* ---------------------------------------------------------------- 移行 */
.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}
.bar-fill { height: 100%; background: var(--ok); transition: width .3s ease; }
.retire {
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 10px;
}
.retire strong { font-weight: 600; }
.retire span { color: var(--text-dim); margin-left: 6px; }
.retire.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.retire.ok strong { color: var(--ok); }

/* ---------------------------------------------------------------- 認証まわりの単独ページ */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card {
  max-width: 560px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 40px;
}
.card h1 { font-size: 19px; margin: 0 0 6px; }
.card p, .card ol { color: var(--text-dim); font-size: 13.5px; }
.card li { margin-bottom: 8px; }
.card code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-all;
}
.card pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
}
.gbtn {
  display: inline-block;
  margin-top: 18px;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
}
.gbtn:hover { text-decoration: none; opacity: .9; }
