/* =============================================================
   EC-WEBSYS-TOEI — Base / Shared Component Layer
   tokens.css を先に読み込んでから使うこと。
   ページ固有スタイルはここに書かない。
   ============================================================= */

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body ── */
body {
  background: var(--bg-grad);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography: 見出し・ブランドは明朝 ── */
.page-title,
.dash-title,
.sec-title,
.brand-name,
h1, h2 {
  font-family: var(--font-display);
}

/* ── 数字: タブラ揃え ── */
.num,
.kpi-value,
.file-month,
td.amount,
.data-table td {
  font-variant-numeric: tabular-nums;
}

/* ── Layout ── */
.wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px clamp(16px, 3vw, 36px) 72px;
}

.page-title {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 4px;
}

.page-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 24px;
}

/* ── Containers ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.panel-inner {
  padding: 22px 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 20px;
  margin-bottom: 18px;
}

/* ── Section header ── */
.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sec-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

/* ── Data table ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.5);
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: rgba(13, 107, 93, 0.03);
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 0;
  text-decoration: none;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: var(--accent-h);
}

.btn.ghost {
  background: var(--ok-s);
  color: var(--accent);
}

.btn-mini {
  font-size: 12px;
  line-height: 1;
  padding: 7px 11px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}

.btn-mini:hover {
  background: var(--soft);
  border-color: rgba(13, 107, 93, 0.22);
}

.btn-mini.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-mini.primary:hover {
  background: var(--accent-h);
  border-color: var(--accent-h);
}

.sec-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s;
}

.sec-btn:hover {
  background: var(--soft);
  border-color: rgba(13, 107, 93, 0.22);
  color: var(--accent-h);
}

.chip-link {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--soft);
  color: var(--accent);
  text-decoration: none;
}

.chip-link:hover {
  background: var(--soft-2);
}

/* ── Status chips ── */
.status-chip {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
}

.status-chip.ok {
  background: var(--ok-s);
  color: var(--ok);
}

.status-chip.warn {
  background: var(--warn-s);
  color: var(--warn);
}

.status-chip.dim {
  background: rgba(107, 117, 112, 0.10);
  color: var(--muted);
}

/* ── Data freshness strip ── */
.freshness-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-1);
}

.freshness-strip.freshness-warn {
  border-color: rgba(184, 95, 46, 0.35);
  background: rgba(184, 95, 46, 0.06);
}

.freshness-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.freshness-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}

.freshness-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.freshness-item {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  min-width: 0;
}

.freshness-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.freshness-value {
  font-size: 12px;
  color: var(--ink);
  margin-top: 2px;
  word-break: break-word;
}

.freshness-age {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.freshness-alerts {
  margin-top: 10px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
}

.badge.ok {
  background: var(--ok-s);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-s);
  color: var(--warn);
}

.badge.muted {
  background: rgba(107, 117, 112, 0.10);
  color: var(--muted);
}

/* ── Slot tags (file readiness) ── */
.slot {
  display: inline-block;
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
}

.slot.ok {
  background: var(--ok-s);
  color: var(--accent);
}

.slot.miss {
  background: #f2e6d4;
  color: #9a5c1d;
}

/* ── Num variants ── */
.num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.num.ok    { color: var(--ok); }
.num.warn  { color: var(--warn); }
.num.muted { color: var(--muted); opacity: 0.55; }

/* ── KPI strip ── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  margin-bottom: 44px;
}

.kpi-cell {
  padding: 22px 22px 20px;
  border-right: 1px solid var(--line);
  position: relative;
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.kpi-value.small { font-size: 16px; line-height: 1.3; }
.kpi-value.warn  { color: var(--warn); }
.kpi-value.green { color: var(--ok); }
.kpi-value.muted { color: var(--muted); }

.kpi-sub {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.kpi-link {
  text-decoration: none;
  color: var(--accent);
  font-weight: 700;
}

.kpi-link:hover {
  color: var(--accent-h);
  text-decoration: underline;
}

/* ── Utility ── */
.empty-hint {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0;
}

/* ── a11y: フォーカスリング（全 interactive 要素に適用） ── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Plain layout (no nav) ── */
body.plain {
  padding-left: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-grad);
}

/* ── Toast notifications ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: 13px;
  line-height: 1.5;
  max-width: 380px;
  word-break: break-word;
  white-space: pre-wrap;
  animation: toast-in 0.18s ease;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
}

.toast.ok {
  border-left: 4px solid var(--ok);
}

.toast.warn {
  border-left: 4px solid var(--warn);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast-body {
  flex: 1;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 0 0 4px;
  font-family: inherit;
  transition: color 0.12s;
}

.toast-close:hover {
  color: var(--ink);
}

canvas { width: 100% !important; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
