:root {
  --bg: #f4f6f9;
  --panel: #fff;
  --ink: #1c2530;
  --muted: #6b7684;
  --line: #dfe4ea;
  --accent: #1f6feb;
  --accent-dark: #1558c0;
  --ng: #d1373a;
  --ng-bg: #fdecec;
  --ok: #1b8a5a;
  --ok-bg: #e8f6ef;
  --warn: #b26a00;
  --warn-bg: #fff5e3;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
               "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── ヘッダー ─────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: #16202c; color: #fff;
  padding: 10px 20px; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; opacity: .85; }
.clients-nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.chip {
  background: rgba(255,255,255,.12); color: #e8eef5;
  padding: 4px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.chip:hover { background: rgba(255,255,255,.22); text-decoration: none; }
.chip.active { background: var(--accent); color: #fff; font-weight: 600; }
.chip.ghost { background: none; border: 1px dashed rgba(255,255,255,.35); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar-right .link { color: #b9c6d4; }
.user { color: #8fa0b3; }

/* ── サブナビ ─────────────────────────── */
.subnav {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 20px;
}
.subnav-client { font-weight: 700; margin-right: 16px; padding: 12px 0; }
.subnav a {
  padding: 12px 14px; color: var(--muted); font-size: 14px;
  border-bottom: 3px solid transparent;
}
.subnav a:hover { color: var(--ink); text-decoration: none; }
.subnav a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block; background: var(--ng); color: #fff;
  border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 5px;
  vertical-align: middle; font-weight: 700;
}

/* ── レイアウト ───────────────────────── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 480px; margin: 60px auto; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.panel-tight { padding: 14px 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ── 数字カード ───────────────────────── */
.stat { text-align: center; padding: 18px 12px; }
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat.alert .num { color: var(--ng); }
.stat.good .num { color: var(--ok); }

/* ── フォーム ─────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }
input[type=text], input[type=password], input[type=email], input[type=number],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 7px; font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,111,235,.13);
}
.field { margin-bottom: 14px; }
input[type=file] { font-size: 14px; }

.btn {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 9px 18px; border-radius: 7px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn.sub { background: #eef1f5; color: var(--ink); }
.btn.sub:hover { background: #e2e7ee; color: var(--ink); }
.btn.danger { background: var(--ng); }
.btn.danger:hover { background: #b32b2e; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── テーブル ─────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line);
         vertical-align: top; }
th { background: #f7f9fb; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
tr.is-ng { background: var(--ng-bg); }
tr.is-ng td { border-bottom-color: #f5cfd0; }
td.nowrap, th.nowrap { white-space: nowrap; }

.tag {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.tag.ng { background: var(--ng); color: #fff; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.auto { background: #eceff3; color: var(--muted); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.info { background: #e7f0fd; color: var(--accent); }

/* ── お知らせ ─────────────────────────── */
.flash {
  padding: 11px 15px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
  border: 1px solid transparent;
}
.flash.ok { background: var(--ok-bg); color: #14603f; border-color: #b9e2cd; }
.flash.error { background: var(--ng-bg); color: #8f2124; border-color: #f2c3c4; }

.notice {
  background: var(--warn-bg); border: 1px solid #f0dcb4; color: #7a4a00;
  padding: 12px 15px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px;
}
.empty { color: var(--muted); text-align: center; padding: 30px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code, .mono {
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 12.5px;
  background: #eef1f5; padding: 1px 6px; border-radius: 4px;
}
.body-preview {
  background: #f7f9fb; border-left: 3px solid var(--line); padding: 9px 12px;
  font-size: 12.5px; color: #46505c; max-height: 130px; overflow-y: auto;
  border-radius: 0 6px 6px 0; white-space: pre-wrap; word-break: break-word;
}
ol.steps { padding-left: 20px; margin: 0; }
ol.steps li { margin-bottom: 7px; }
.inline-form { display: inline; }
.pager { display: flex; gap: 10px; justify-content: center; margin-top: 18px; align-items: center; }
