/* 経営ダッシュボード 共通スタイル */
:root {
  color-scheme: light;
  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --error: #c03535;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --border: #2f2f2d;
    --grid: #2a2a28;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --accent: #3987e5;
    --series-1: #3987e5;
    --error: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --border: #2f2f2d;
  --grid: #2a2a28;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #3987e5;
  --series-1: #3987e5;
  --error: #e66767;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- ログイン ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 22px;
}
.login-title { font-size: 20px; margin: 0 0 20px; text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 13px; color: var(--text-secondary); }
.login-form input {
  font-size: 17px; padding: 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-0);
}
#code { letter-spacing: 0.3em; text-align: center; font-size: 22px; }
.login-form button[type="submit"] {
  margin-top: 8px; padding: 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; cursor: pointer;
}
.login-form button:disabled { opacity: 0.6; cursor: default; }
.login-hint, .login-sent { font-size: 13px; color: var(--text-muted); margin: 4px 0 0; }
.login-sent { color: var(--text-secondary); margin: 0 0 4px; word-break: break-all; }
.login-links { display: flex; justify-content: space-between; margin-top: 8px; }
.link-button { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; font-size: 13px; }
.login-message { min-height: 1.6em; font-size: 13px; color: var(--text-secondary); margin: 16px 0 0; }
.login-message.is-error, .status.is-error { color: var(--error); }

/* ---------- ダッシュボード ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.ghost-button {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 13px; cursor: pointer;
}
.page { max-width: 1120px; margin: 0 auto; padding: 16px; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 12px; }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.filter select {
  min-width: 180px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); font-size: 15px;
}
.filter-note { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--text-muted); }
.status { color: var(--text-secondary); }

.scope-title { font-size: 18px; margin: 4px 0 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { font-size: 12px; color: var(--text-secondary); }
.tile-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.tile-sub { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel h2 { font-size: 14px; margin: 0 0 10px; }
.panel-note { font-size: 11px; color: var(--text-muted); margin: 8px 0 0; }
.comment p { margin: 0 0 6px; }
.muted { color: var(--text-muted); }

.charts { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 840px) { .charts { grid-template-columns: 1fr 1fr; } }
.chart-box { position: relative; height: 240px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.data-table th, .data-table td { padding: 7px 8px; border-bottom: 1px solid var(--grid); text-align: left; }
.data-table th { font-weight: 600; color: var(--text-secondary); font-size: 12px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th:first-child, .data-table td:first-child { position: sticky; left: 0; background: var(--surface-1); }
.group-row td { font-size: 12px; color: var(--text-muted); background: var(--surface-0) !important; padding-top: 10px; }

.footer { font-size: 11px; color: var(--text-muted); padding: 8px 0 24px; }
.footer p { margin: 2px 0; }

@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile-value { font-size: 19px; }
  .filter { flex: 1 1 140px; }
  .filter select { min-width: 0; width: 100%; }
}
