/* MCAH 運用コンソール: デザイントークン・リセット・レイアウト
   外部フォント・外部 CDN は使わない（CSP: style-src 'self'）。 */

:root {
  color-scheme: light dark;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #cfd6de;
  --border-strong: #8b97a5;
  --text: #17202a;
  --text-muted: #46525f;
  --accent: #1a5fb4;
  --accent-hover: #144a8f;
  --accent-on: #ffffff;
  --accent-soft: #e5eefb;
  --link: #174f96;
  --focus: #c2410c;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.06);

  --ok-fg: #0d5c2e;      --ok-bg: #e3f4ea;      --ok-bd: #8fcaa5;
  --danger-fg: #a12222;  --danger-bg: #fde8e8;  --danger-bd: #e8a3a3;
  --warn-fg: #7a4a00;    --warn-bg: #fff2d6;    --warn-bd: #e6c37a;
  --info-fg: #174f96;    --info-bg: #e5eefb;    --info-bd: #a3bfe8;
  --neutral-fg: #3f4a56; --neutral-bg: #eceff3; --neutral-bd: #c1c9d2;

  /* グラフ（dataviz: 青・橙・紫は色覚多様性で検証済み。意味は凡例・ラベルでも示す） */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #4a3aa7;
  --series-bar: #3a7bd0;
  --series-other: #9aa3ad;
  --grid: #e1e0d9;
  --axis: #a9b0b8;

  --radius: 8px;
  --radius-sm: 5px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Meiryo", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans Mono CJK JP", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171c22;
    --surface-2: #1d232a;
    --border: #333d48;
    --border-strong: #6b7887;
    --text: #e6eaef;
    --text-muted: #a9b3bf;
    --accent: #2c6cc0;
    --accent-hover: #3a7bd0;
    --accent-on: #ffffff;
    --accent-soft: #14263f;
    --link: #8ab8f5;
    --focus: #ffb454;
    --shadow: none;

    --ok-fg: #7fd8a0;      --ok-bg: #12301f;      --ok-bd: #2a6a45;
    --danger-fg: #ff9c9c;  --danger-bg: #3a1717;  --danger-bd: #7a3535;
    --warn-fg: #f3c46b;    --warn-bg: #33270c;    --warn-bd: #7a5d1c;
    --info-fg: #9cc4fb;    --info-bg: #14263f;    --info-bd: #2e5a99;
    --neutral-fg: #c3ccd6; --neutral-bg: #232a32; --neutral-bd: #46515d;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #9085e9;
    --series-bar: #3987e5;
    --series-other: #8b8b86;
    --grid: #2c2c2a;
    --axis: #4a4a47;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4 { line-height: 1.35; margin: 0 0 0.6em; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
p { margin: 0 0 0.9em; }
ul, ol { margin: 0 0 0.9em; padding-left: 1.4em; }
a { color: var(--link); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
code, pre, .mono { font-family: var(--mono); font-size: 0.88em; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
img, svg { max-width: 100%; }
dl { margin: 0; }
dt { color: var(--text-muted); font-size: 0.85rem; }
dd { margin: 0 0 0.6em; }
table { border-collapse: collapse; }
button, input, select, textarea { font: inherit; color: inherit; }

/* フォーカスは常に可視（WCAG 2.4.7 / 2.4.11） */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
main:focus { outline: none; }
h1:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px; top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: var(--accent-on);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
}
.skip-link:focus { top: 8px; }

/* ── ヘッダ・ナビ ─────────────────────────── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.02em;
  min-height: 44px;
  align-items: center;
}
.brand small { font-weight: 500; font-size: 0.8rem; color: var(--text-muted); }
.brand__mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: var(--accent); color: var(--accent-on);
  font-size: 0.8rem; font-weight: 800;
}
.btn.nav-toggle { display: none; }
.site-nav { flex: 1 1 auto; min-width: 0; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px; }
.site-nav a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-bottom: 3px solid transparent;
  font-weight: 500;
}
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
}
.user-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.user-box__name { display: flex; flex-direction: column; line-height: 1.3; font-size: 0.85rem; }
.user-box__name strong { font-size: 0.9rem; }

@media (max-width: 860px) {
  .btn.nav-toggle { display: inline-flex; margin-left: auto; }
  .site-nav { flex-basis: 100%; order: 3; }
  .site-nav[data-open="false"] { display: none; }
  .site-nav ul { flex-direction: column; }
  .site-nav a { width: 100%; }
  .user-box { order: 2; flex-basis: 100%; margin-left: 0; justify-content: space-between; }
  .user-box[hidden] { display: none; }
}

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
@media (min-width: 900px) { main { padding: 28px 24px 56px; } }

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
}
.app-footer p { max-width: 1360px; margin: 0 auto; padding: 12px 16px; }

/* ── ページ見出し ─────────────────────────── */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 8px 16px; margin-bottom: 16px;
}
.page-head h1 { margin: 0; }
.page-head__lead { color: var(--text-muted); margin: 4px 0 0; max-width: 70ch; }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.split { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; } }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; word-break: break-all; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .badge, .btn, .card { border: 1px solid CanvasText; }
}

@media print {
  .app-header, .app-footer, .skip-link, .page-head__actions { display: none !important; }
  body { background: #fff; color: #000; }
}
