/* =========================================================================
   admage v5 — components
   tokens.css の変数だけを参照する。クラス名は役割で付ける（.btn, .table …）。
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent-ring); }

[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-tertiary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }

/* ---- App shell ------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--dur-base) var(--ease-out); }
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.main { min-width: 0; display: flex; flex-direction: column; }

/* ---- Sidebar --------------------------------------------------------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow: hidden;
}
.sidebar__brand { height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-4); }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--brand-gradient); position: relative; flex: none; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.2) inset, 0 4px 14px -4px var(--accent-glow); }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 2px; border: 1.5px solid rgb(255 255 255 / 0.9); border-left-color: transparent; transform: rotate(-45deg); }
.brand-name { font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.brand-env { margin-left: auto; font-size: var(--text-2xs); font-family: var(--font-mono); color: var(--text-tertiary); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 0 5px; }

.sidebar__search { margin: 0 var(--space-3) var(--space-2); }
.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--space-1) var(--space-2) var(--space-4); }
.nav-group { margin-top: var(--space-4); }
.nav-group__label { padding: 0 var(--space-2) var(--space-1); font-size: var(--text-2xs); font-weight: var(--weight-medium); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-2);
  height: 30px; padding: 0 var(--space-2); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs), 0 0 0 1px var(--border); }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item__count { margin-left: auto; font-size: var(--text-2xs); color: var(--text-tertiary); }
.sidebar__footer { border-top: 1px solid var(--border); padding: var(--space-2); }

.app[data-sidebar="collapsed"] .brand-name,
.app[data-sidebar="collapsed"] .brand-env,
.app[data-sidebar="collapsed"] .nav-group__label,
.app[data-sidebar="collapsed"] .nav-item span,
.app[data-sidebar="collapsed"] .sidebar__search,
.app[data-sidebar="collapsed"] .user__meta { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; }

.user { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); }
.user:hover { background: var(--surface-hover); }
.avatar { width: 26px; height: 26px; border-radius: var(--radius-full); display: grid; place-items: center; font-size: var(--text-2xs); font-weight: var(--weight-semibold); color: #fff; background: var(--brand-gradient); flex: none; }
.user__meta { line-height: 1.2; min-width: 0; }
.user__name { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.user__role { font-size: var(--text-2xs); color: var(--text-tertiary); }

/* ---- Topbar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-6) 0 var(--space-3);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.breadcrumb { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); color: var(--text-tertiary); }
.breadcrumb [aria-current] { color: var(--text); font-weight: var(--weight-medium); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }

/* ---- Page ------------------------------------------------------------ */
.page { padding: var(--space-6) var(--space-6) var(--space-10); width: 100%; max-width: 1600px; }
.page-head {
  position: relative; display: flex; align-items: flex-end; gap: var(--space-4);
  padding-bottom: var(--space-5); margin-bottom: var(--space-4);
}
/* 見出しの背面に、ごく薄いドットグリッド（精密さの演出） */
.page-head::before {
  content: ""; position: absolute; inset: -24px -24px 0 -24px; z-index: -1;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 14px 14px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 100%);
}
.page-title { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: -0.02em; line-height: var(--leading-tight); }
.page-title .count { margin-left: var(--space-2); font-size: var(--text-md); font-weight: var(--weight-regular); color: var(--text-tertiary); }
.page-desc { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: var(--text-sm); }
.page-head__actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* ---- Stat strip ------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: var(--space-4); overflow: hidden; }
.stat { padding: var(--space-3) var(--space-4); border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
.stat__label { font-size: var(--text-xs); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-1); }
.stat__value { margin-top: 2px; font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: -0.02em; display: flex; align-items: baseline; gap: var(--space-2); }
.delta { font-size: var(--text-xs); font-weight: var(--weight-medium); }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.stat__spark { display: block; width: 100%; height: 22px; margin-top: var(--space-1); color: var(--accent); }

/* ---- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap;
  box-shadow: var(--shadow-xs); cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(0.5px); }
.btn--primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn--primary:hover { background: color-mix(in srgb, var(--text) 86%, var(--accent)); border-color: transparent; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.btn--accent:hover { background: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-secondary); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); border-color: transparent; }
.btn--danger { color: var(--danger); }
.btn--sm { height: 26px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 26px; }

kbd, .kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px;
  font-family: var(--font-sans); font-size: var(--text-2xs); line-height: 1; color: var(--text-tertiary);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--radius-xs); background: var(--surface);
}

/* ---- Inputs ---------------------------------------------------------- */
.input {
  display: flex; align-items: center; gap: var(--space-2);
  height: 32px; padding: 0 var(--space-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-tertiary); box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: var(--text-sm); }
.input input::placeholder { color: var(--text-tertiary); }

.select {
  height: 32px; padding: 0 28px 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-size: var(--text-sm); box-shadow: var(--shadow-xs); appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e9c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.checkbox { appearance: none; width: 15px; height: 15px; margin: 0; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); cursor: pointer; display: grid; place-items: center; transition: background var(--dur-fast), border-color var(--dur-fast); }
.checkbox:checked, .checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); }
.checkbox:indeterminate::after { content: ""; width: 7px; height: 2px; background: #fff; border-radius: 1px; }

/* ---- Segmented / chips ----------------------------------------------- */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-subtle); }
.segmented button { height: 26px; padding: 0 var(--space-2); border: 0; border-radius: 4px; background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-medium); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.segmented .tally { color: var(--text-tertiary); font-weight: var(--weight-regular); }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 6px 0 var(--space-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-full); color: var(--text-secondary); font-size: var(--text-xs); background: transparent; cursor: pointer; }
.chip:hover { color: var(--text); border-color: var(--text-tertiary); }
.chip--active { border-style: solid; border-color: var(--accent); background: var(--accent-weak); color: var(--text); }
.chip__value { font-weight: var(--weight-medium); }
.chip__x { display: grid; place-items: center; width: 16px; height: 16px; border-radius: var(--radius-full); color: var(--text-tertiary); }
.chip__x:hover { background: var(--surface-hover); color: var(--text); }

/* ---- Badges / status ------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-medium); background: var(--neutral-weak); color: var(--text-secondary); white-space: nowrap; }
.badge--success { background: var(--success-weak); color: var(--success); }
.badge--warning { background: var(--warning-weak); color: var(--warning); }
.badge--danger  { background: var(--danger-weak);  color: var(--danger); }
.badge--info    { background: var(--info-weak);    color: var(--info); }
.badge--outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

.status-dot { width: 7px; height: 7px; border-radius: var(--radius-full); background: currentColor; position: relative; flex: none; }
.status-dot--live::after { content: ""; position: absolute; inset: -3px; border-radius: inherit; background: currentColor; opacity: 0.35; animation: pulse 2s var(--ease-out) infinite; }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.45; } 100% { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .status-dot--live::after { animation: none; } }

/* ---- Card / panel ---------------------------------------------------- */
.panel { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border); }
.toolbar__spacer { flex: 1; }
.toolbar .input { width: 240px; }

/* ---- Table ----------------------------------------------------------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 300px); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table th, .table td { padding: 0 var(--space-3); height: var(--row-h); border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.table thead th {
  position: sticky; top: 0; z-index: 2; height: 36px;
  background: var(--bg-subtle); color: var(--text-secondary);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
}
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr[aria-selected="true"] td { background: var(--surface-selected); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td { background: var(--surface); }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 40px; min-width: 40px; max-width: 40px; padding-right: 0; }
.table .col-id { width: 68px; min-width: 68px; max-width: 68px; }
.table .col-menu { width: 44px; text-align: right; }
/* 操作の列は右端に固定（横スクロールしても行メニューを開ける） */
.table .col-menu { position: sticky; right: 0; z-index: 1; box-shadow: -1px 0 0 var(--border); }
.table thead .col-menu { z-index: 3; }
.table tbody tr td.col-menu { background: var(--surface); }
.table tbody tr:hover td.col-menu { background: var(--surface-hover); }
.table tbody tr[aria-selected="true"] td.col-menu { background: var(--surface-selected); }
/* 横スクロールしても、チェック・ID・広告名は左に固定 */
.table .sticky-1 { position: sticky; left: 0; z-index: 1; }
.table .sticky-2 { position: sticky; left: 40px; z-index: 1; }
.table .sticky-3 { position: sticky; left: 108px; z-index: 1; box-shadow: 1px 0 0 var(--border); }
/* 固定列の left は、左の列の幅（.col-check 40px + .col-id 68px）と合わせる */
.table thead .sticky-1, .table thead .sticky-2, .table thead .sticky-3 { z-index: 3; }
.table td.sticky-1, .table td.sticky-2, .table td.sticky-3 { background: inherit; }
.table tbody tr td.sticky-1, .table tbody tr td.sticky-2, .table tbody tr td.sticky-3 { background: var(--surface); }
.table tbody tr:hover td.sticky-1, .table tbody tr:hover td.sticky-2, .table tbody tr:hover td.sticky-3 { background: var(--surface-hover); }
.table tbody tr[aria-selected="true"] td.sticky-1, .table tbody tr[aria-selected="true"] td.sticky-2, .table tbody tr[aria-selected="true"] td.sticky-3 { background: var(--surface-selected); }

.th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: inherit; font-weight: inherit; cursor: pointer; }
.th-sort:hover { color: var(--text); }
.th-sort .icon { opacity: 0; width: 12px; height: 12px; }
.th-sort:hover .icon, .th-sort[aria-sort] .icon { opacity: 1; }
.th-sort[aria-sort] { color: var(--text); }

.cell-title { display: flex; align-items: center; gap: var(--space-3); max-width: 340px; }
.cell-title__icon { width: 28px; height: 28px; border-radius: var(--radius-sm); flex: none; display: grid; place-items: center; font-size: 14px; border: 1px solid var(--border); background: var(--bg-subtle); }
.cell-title__text { min-width: 0; }
.cell-title__name { font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; }
.cell-title__name:hover { color: var(--accent); }
.cell-title__sub { font-size: var(--text-xs); color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; }
:root[data-density="compact"] .cell-title__sub, :root[data-density="compact"] .cell-title__icon { display: none; }

.id-link { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.id-link:hover { color: var(--accent); }

.meter { display: flex; align-items: center; gap: var(--space-2); justify-content: flex-end; }
.meter__bar { width: 56px; height: 4px; border-radius: var(--radius-full); background: var(--neutral-weak); overflow: hidden; }
.meter__bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter__bar > i.warn { background: var(--warning); }

.spark { width: 64px; height: 20px; color: var(--accent); display: block; margin-left: auto; }

.row-menu-btn { opacity: 0; }
.table tbody tr:hover .row-menu-btn, .row-menu-btn[aria-expanded="true"] { opacity: 1; }

/* ---- Pagination / footer -------------------------------------------- */
.table-foot { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-secondary); background: var(--surface); }
.pager { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.pager .btn { min-width: 26px; }
.pager .btn[aria-current="page"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---- Bulk action bar ------------------------------------------------- */
.bulkbar {
  position: fixed; left: 50%; bottom: 24px; z-index: 40;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px 6px 6px var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  background: var(--surface-raised); box-shadow: var(--shadow-lg);
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base);
}
.bulkbar[data-open="true"] { transform: translate(-50%, 0); opacity: 1; }
.bulkbar__count { font-size: var(--text-sm); font-weight: var(--weight-medium); margin-right: var(--space-2); }
.bulkbar .divider { width: 1px; height: 18px; background: var(--border); }

/* ---- Menus / popovers ----------------------------------------------- */
.popover {
  position: absolute; z-index: 50; min-width: 200px; padding: var(--space-1);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-raised); box-shadow: var(--shadow-lg);
  transform-origin: top right; animation: pop var(--dur-fast) var(--ease-out);
}
.popover[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(-2px); } }
.menu-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; height: 30px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-sm); background: none; font-size: var(--text-sm); color: var(--text); text-align: left; cursor: pointer; }
.menu-item:hover, .menu-item[data-active="true"] { background: var(--surface-hover); }
.menu-item .icon { color: var(--text-tertiary); }
.menu-item kbd { margin-left: auto; }
.menu-item--danger { color: var(--danger); }
.menu-item--danger .icon { color: var(--danger); }
.menu-sep { height: 1px; margin: var(--space-1) calc(-1 * var(--space-1)); background: var(--border); }
.menu-label { padding: var(--space-1) var(--space-2); font-size: var(--text-2xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }
.menu-check { display: flex; align-items: center; gap: var(--space-2); height: 30px; padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-sm); cursor: pointer; }
.menu-check:hover { background: var(--surface-hover); }

/* ---- Command palette ------------------------------------------------- */
.palette-backdrop { position: fixed; inset: 0; z-index: 90; background: var(--overlay); backdrop-filter: blur(4px); animation: fade var(--dur-fast); }
.palette-backdrop[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.palette {
  position: fixed; left: 50%; top: 14vh; z-index: 91; width: min(620px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-raised); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: pop var(--dur-base) var(--ease-out);
}
.palette[hidden] { display: none; }
/* 上辺のアクセントの光（未来感の差し色はここだけ） */
.palette::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.8; }
.palette__input { display: flex; align-items: center; gap: var(--space-3); height: 52px; padding: 0 var(--space-4); border-bottom: 1px solid var(--border); }
.palette__input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: var(--text-lg); }
.palette__list { max-height: 360px; overflow-y: auto; padding: var(--space-2); }
.palette__foot { display: flex; gap: var(--space-4); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-2xs); color: var(--text-tertiary); }
.palette__foot span { display: inline-flex; align-items: center; gap: 4px; }
.palette__empty { padding: var(--space-8); text-align: center; color: var(--text-tertiary); font-size: var(--text-sm); }

/* ---- Toast ----------------------------------------------------------- */
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 95; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-lg); font-size: var(--text-sm); animation: pop var(--dur-base) var(--ease-out); }
.toast[hidden] { display: none; }
.toast .icon { color: var(--success); }

/* =========================================================================
   Forms / detail page（edit.html）
   ========================================================================= */

/* ---- Page head with entity ------------------------------------------ */
.entity { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.entity__icon { width: 48px; height: 48px; border-radius: var(--radius-lg); display: grid; place-items: center; font-size: 24px; flex: none; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm); }
.entity__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-secondary); }
.entity__meta .sep { width: 3px; height: 3px; border-radius: var(--radius-full); background: var(--text-tertiary); }
.copy-id { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-secondary); cursor: pointer; }
.copy-id:hover { color: var(--text); border-color: var(--border-strong); }

/* ---- Tabs ------------------------------------------------------------ */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); margin-bottom: var(--space-6); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 var(--space-3); color: var(--text-secondary); font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.tab .tally { font-size: var(--text-2xs); color: var(--text-tertiary); background: var(--neutral-weak); border-radius: var(--radius-full); padding: 0 6px; }

/* ---- Two-column layout ---------------------------------------------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--space-8); align-items: start; }
.detail__main { display: flex; flex-direction: column; gap: var(--space-5); min-width: 0; }
.detail__aside { position: sticky; top: calc(var(--topbar-h) + var(--space-6)); display: flex; flex-direction: column; gap: var(--space-4); }

/* ---- Section card --------------------------------------------------- */
.section { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); scroll-margin-top: calc(var(--topbar-h) + var(--space-4)); }
.section__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.section__title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: -0.01em; }
.section__desc { margin: 2px 0 0; font-size: var(--text-xs); color: var(--text-secondary); }
.section__num { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-tertiary); margin-top: 3px; }
.section__body { padding: var(--space-1) var(--space-5); }
.section--danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.section--danger .section__title { color: var(--danger); }

/* ---- Field row: label | control ------------------------------------- */
.field { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: var(--space-2) var(--space-6); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.field:last-child { border-bottom: 0; }
.field__label { padding-top: 6px; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.field__label .req { margin-left: 4px; color: var(--danger); font-size: var(--text-xs); }
.field__label .opt { margin-left: 4px; color: var(--text-tertiary); font-size: var(--text-2xs); font-weight: var(--weight-regular); }
.field__label small { display: block; margin-top: 2px; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--text-tertiary); line-height: 1.45; }
.field__control { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); min-width: 0; }
/* 中身の幅で置く部品（切り替え・スイッチ等）は左寄せ。横いっぱいに使う部品だけ伸ばす */
.field__control > .w-full, .field__control > .textarea, .field__control > .choices, .field__control > .code,
.field__control > .margin, .field__control > .hours, .field__control > .hours-scale, .field__control > .field__row { align-self: stretch; }
.field__control > .hours, .field__control > .hours-scale { max-width: 560px; }
.field__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.hint { font-size: var(--text-xs); color: var(--text-tertiary); }
.error-msg { display: none; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--danger); }
.field[data-invalid="true"] .error-msg { display: flex; }
.field[data-invalid="true"] .input, .field[data-invalid="true"] .textarea { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent); }
.counter { margin-left: auto; font-size: var(--text-2xs); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

/* 入力欄（フォーム用は文字色を本文の色に） */
.field .input { color: var(--text); }
.input--lg { height: 36px; }
.input__affix { color: var(--text-tertiary); font-size: var(--text-sm); white-space: nowrap; }
.input[data-readonly="true"] { background: var(--bg-subtle); color: var(--text-secondary); }
.input input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.input input::-webkit-outer-spin-button, .input input::-webkit-inner-spin-button { -webkit-appearance: none; }
.w-xs { width: 120px; } .w-sm { width: 180px; } .w-md { width: 320px; } .w-full { width: 100%; }

.textarea { width: 100%; min-height: 84px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: var(--text-sm); line-height: var(--leading-normal); resize: vertical; box-shadow: var(--shadow-xs); }
.textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field .select { color: var(--text); }

/* ---- Switch ---------------------------------------------------------- */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-size: var(--text-sm); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { position: relative; width: 32px; height: 18px; flex: none; border-radius: var(--radius-full); background: var(--border-strong); transition: background var(--dur-base) var(--ease-out); }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: var(--radius-full); background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform var(--dur-base) var(--ease-out); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch__text small { display: block; font-size: var(--text-xs); color: var(--text-tertiary); }

/* ---- Radio cards ---------------------------------------------------- */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-2); }
.choice { position: relative; display: flex; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast); }
.choice:hover { border-color: var(--border-strong); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice__dot { width: 16px; height: 16px; flex: none; margin-top: 1px; border-radius: var(--radius-full); border: 1px solid var(--border-strong); display: grid; place-items: center; transition: border-color var(--dur-fast); }
.choice__dot::after { content: ""; width: 8px; height: 8px; border-radius: inherit; background: var(--accent); transform: scale(0); transition: transform var(--dur-base) var(--ease-out); }
.choice__title { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.choice__desc { display: block; font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--surface-selected); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice:has(input:checked) .choice__dot { border-color: var(--accent); }
.choice:has(input:checked) .choice__dot::after { transform: scale(1); }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Day / hour pickers --------------------------------------------- */
.days { display: inline-flex; gap: 4px; }
.day { width: 34px; height: 30px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-secondary); cursor: pointer; transition: all var(--dur-fast); }
.day[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.day.is-holiday { color: var(--danger); }
.day.is-holiday[aria-pressed="true"] { color: var(--bg); }
.hours { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; max-width: 560px; user-select: none; }
.hour { height: 26px; padding: 0; border: 0; border-radius: 3px; background: var(--neutral-weak); cursor: pointer; transition: background var(--dur-fast); }
.hour[aria-pressed="true"] { background: var(--accent); }
.hour:hover { outline: 1px solid var(--border-strong); }
.hours-scale { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); max-width: 560px; font-size: 10px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.hours-scale span:nth-child(odd) { visibility: hidden; }

/* ---- Margin preview（粗利） ----------------------------------------- */
.margin { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-3); border: 1px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--bg-subtle); font-size: var(--text-xs); color: var(--text-secondary); }
.margin b { display: block; font-size: var(--text-lg); color: var(--text); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.margin__bar { flex: 1; height: 6px; border-radius: var(--radius-full); background: var(--neutral-weak); overflow: hidden; display: flex; }
.margin__bar .net { background: var(--text-tertiary); }
.margin__bar .gp { background: var(--accent); }
.margin[data-warn="true"] { border-color: var(--danger); color: var(--danger); }

/* ---- Code / URL field ----------------------------------------------- */
.code { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-subtle); overflow: hidden; }
.code__text { flex: 1; min-width: 0; padding: 7px var(--space-3); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); white-space: nowrap; overflow-x: auto; }
.code__text mark { background: var(--accent-weak); color: var(--text); border-radius: 3px; padding: 0 2px; }
.code .btn { border: 0; border-left: 1px solid var(--border); border-radius: 0; box-shadow: none; height: auto; }

/* ---- Aside ---------------------------------------------------------- */
.aside-card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: var(--space-3) var(--space-4); }
.aside-card__title { font-size: var(--text-2xs); font-weight: var(--weight-medium); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); margin-bottom: var(--space-2); }
.toc { display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.toc a { position: relative; padding: 5px 0 5px var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); transition: color var(--dur-fast); }
.toc a:hover { color: var(--text); }
.toc a[aria-current="true"] { color: var(--text); font-weight: var(--weight-medium); }
.toc a[aria-current="true"]::before { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--accent); }
.toc a .dirty { display: none; width: 6px; height: 6px; margin-left: 6px; border-radius: var(--radius-full); background: var(--warning); vertical-align: middle; }
.toc a[data-dirty="true"] .dirty { display: inline-block; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--space-3); margin: 0; font-size: var(--text-xs); }
.kv dt { color: var(--text-tertiary); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.mini-stats div { font-size: var(--text-2xs); color: var(--text-tertiary); }
.mini-stats b { display: block; font-size: var(--text-md); color: var(--text); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

/* ---- Save bar ------------------------------------------------------- */
.savebar {
  position: sticky; bottom: var(--space-4); z-index: 30; margin-top: var(--space-6);
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-raised) 88%, transparent); backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px); opacity: 0; pointer-events: none;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base);
}
.savebar[data-open="true"] { transform: none; opacity: 1; pointer-events: auto; }
.savebar__text { font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2); }
.savebar__text .status-dot { color: var(--warning); }
.savebar__actions { margin-left: auto; display: flex; gap: var(--space-2); }

/* =========================================================================
   Dashboard（dashboard.html）
   ========================================================================= */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.live { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-full); font-size: var(--text-xs); color: var(--text-secondary); background: var(--surface); }
.live .status-dot { color: var(--success); }

.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

.card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); min-width: 0; display: flex; flex-direction: column; }
.card__head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); min-height: 48px; }
.card__title { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.card__sub { font-size: var(--text-xs); color: var(--text-tertiary); }
.card__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.card__body { padding: 0 var(--space-4) var(--space-4); flex: 1; min-width: 0; }
.card__foot { border-top: 1px solid var(--border); padding: var(--space-2) var(--space-4); font-size: var(--text-xs); color: var(--text-secondary); display: flex; align-items: center; }
.card__foot a { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); }
.card__foot a:hover { color: var(--accent); }

/* ---- Hero（1画面に1つだけ） ---------------------------------------- */
.hero { position: relative; overflow: hidden; padding: var(--space-5); justify-content: space-between; }
.hero::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--chart-1) 14%, transparent), transparent 60%); pointer-events: none; }
.hero__label { font-size: var(--text-sm); color: var(--text-secondary); display: flex; align-items: center; gap: var(--space-2); }
.hero__value { margin-top: var(--space-2); font-size: 48px; line-height: 1; font-weight: var(--weight-semibold); letter-spacing: -0.035em; }
.hero__value .unit { font-size: var(--text-xl); margin-right: 2px; color: var(--text-secondary); font-weight: var(--weight-medium); }
.hero__delta { margin-top: var(--space-3); display: flex; gap: var(--space-3); font-size: var(--text-xs); color: var(--text-secondary); }
.goal { margin-top: var(--space-5); }
.goal__row { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--text-secondary); margin-bottom: 6px; }
.goal__bar { position: relative; height: 8px; border-radius: var(--radius-full); background: color-mix(in srgb, var(--chart-1) 14%, var(--surface)); overflow: hidden; }
.goal__bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--chart-1); }
.goal__bar > .pace { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; background: var(--text); }

.tile { padding: var(--space-4); }
.tile__label { font-size: var(--text-xs); color: var(--text-secondary); }
.tile__value { margin-top: 4px; font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: -0.025em; }
.tile__delta { font-size: var(--text-xs); margin-left: var(--space-1); }
.tile__spark { display: block; width: 100%; height: 30px; margin-top: var(--space-2); overflow: visible; }

/* ---- Chart ---------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis text { fill: var(--chart-axis); font-size: 11px; font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .s1 { stroke: var(--chart-1); } .chart .s2 { stroke: var(--chart-2); }
.chart .area1 { fill: var(--chart-1); opacity: 0.1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .crosshair { stroke: var(--text-tertiary); stroke-width: 1; shape-rendering: crispEdges; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.s1 { fill: var(--chart-1); } .chart .dot.s2 { fill: var(--chart-2); }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart.is-loading svg { opacity: 0.45; transition: opacity var(--dur-base); }
.chart-hit { cursor: crosshair; }

.legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--text-xs); color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .key { width: 14px; height: 2px; border-radius: 1px; }
.legend .key.s1 { background: var(--chart-1); } .legend .key.s2 { background: var(--chart-2); }

.tooltip { position: absolute; z-index: 10; pointer-events: none; min-width: 150px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-raised); box-shadow: var(--shadow-lg); font-size: var(--text-xs); transform: translate(-50%, calc(-100% - 12px)); }
.tooltip[hidden] { display: none; }
.tooltip__title { color: var(--text-tertiary); margin-bottom: 4px; }
.tooltip__row { display: flex; align-items: center; gap: var(--space-2); }
.tooltip__row b { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.tooltip__row span { color: var(--text-secondary); margin-left: auto; }
.tooltip .key { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .key.s1 { background: var(--chart-1); } .tooltip .key.s2 { background: var(--chart-2); }

.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-xs); }
.data-table th, .data-table td { padding: 6px var(--space-2); border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--text-tertiary); font-weight: var(--weight-medium); }
.chart-scroll { max-height: 260px; overflow: auto; }

/* ---- Heatmap -------------------------------------------------------- */
.heat { display: grid; grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10px; color: var(--chart-axis); font-variant-numeric: tabular-nums; }
.heat__day { display: flex; align-items: center; }
.heat__cell { aspect-ratio: 1 / 1.1; border-radius: 3px; background: var(--chart-1); cursor: default; transition: transform var(--dur-fast); }
.heat__cell:hover, .heat__cell:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.heat__hour { text-align: center; }
.heat__hour:nth-child(odd) { visibility: hidden; }
.heat-scale { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-2xs); color: var(--text-tertiary); }
.heat-scale i { width: 14px; height: 10px; border-radius: 2px; background: var(--chart-1); }

/* ---- Ranking bars ---------------------------------------------------- */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.rank li { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 2px var(--space-3); }
.rank__no { font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--text-tertiary); }
.rank__name { font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank__value { font-size: var(--text-sm); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; text-align: right; }
.rank__bar { grid-column: 2 / 4; height: 6px; border-radius: 0 3px 3px 0; background: color-mix(in srgb, var(--chart-1) 12%, var(--surface)); }
.rank__bar > i { display: block; height: 100%; border-radius: 0 3px 3px 0; background: var(--chart-1); }

/* ---- Live feed ------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--text-xs); }
.feed li:last-child { border-bottom: 0; }
.feed li.is-new { animation: feed-in 600ms var(--ease-out); }
@keyframes feed-in { from { opacity: 0; transform: translateY(-6px); background: var(--accent-weak); } }
.feed__time { font-family: var(--font-mono); color: var(--text-tertiary); }
.feed__main { min-width: 0; }
.feed__title { font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__sub { color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed__amount { font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; text-align: right; }
.feed__amount small { display: block; font-weight: var(--weight-regular); color: var(--text-tertiary); }

/* ---- Todo / system -------------------------------------------------- */
.todo { list-style: none; margin: 0; padding: 0; }
.todo a { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-2); margin: 0 calc(-1 * var(--space-2)); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.todo a:hover { background: var(--surface-hover); }
.todo__icon { width: 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: none; }
.todo__icon.warning { background: var(--warning-weak); color: var(--warning); }
.todo__icon.danger { background: var(--danger-weak); color: var(--danger); }
.todo__icon.info { background: var(--info-weak); color: var(--info); }
.todo__text small { display: block; font-size: var(--text-xs); color: var(--text-tertiary); }
.todo__count { margin-left: auto; font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.todo .icon-chev { color: var(--text-tertiary); }

.sys { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sys__item { padding: var(--space-3) var(--space-4); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.sys__item:first-child { border-left: 0; }
.sys__label { font-size: var(--text-xs); color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.sys__value { font-size: var(--text-md); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.sys__value .icon { width: 15px; height: 15px; }
.ok { color: var(--success); } .warn { color: var(--warning); } .bad { color: var(--danger); }
.mini-bars { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.mini-bars i { flex: 1; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--success) 70%, transparent); }

@media (max-width: 1200px) {
  .span-3 { grid-column: span 6; } .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
  .sys { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sys__item:nth-child(3) { border-left: 0; }
  .sys__item:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .span-3, .span-6 { grid-column: span 12; }
}


/* =========================================================================
   Report（report.html）
   ========================================================================= */
.stats--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats--6 .stat__value { font-size: var(--text-lg); flex-wrap: wrap; column-gap: var(--space-2); row-gap: 0; }
.stat__sub { font-size: var(--text-2xs); color: var(--text-tertiary); margin-top: 2px; }

.range-pop { display: grid; grid-template-columns: 140px 1fr; gap: var(--space-2); padding: var(--space-2); }
.range-pop[hidden] { display: none; }
.range-pop__presets { display: flex; flex-direction: column; border-right: 1px solid var(--border); padding-right: var(--space-2); }
.range-pop__custom { padding: 0 var(--space-1); }
.range-pop .input input[type="date"] { font-variant-numeric: tabular-nums; }

.report-wrap { max-height: calc(100vh - 220px); }
.report-table th.col-num .th-sort { justify-content: flex-end; width: 100%; }
.report-table td.col-name { min-width: 220px; }
.report-table .col-pin { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border); }
.report-table thead .col-pin { z-index: 3; }
.report-table tbody tr:hover td.col-pin { background: var(--surface-hover); }
.report-table tbody tr { cursor: pointer; }
.report-table .weekend { color: var(--danger); }
/* 合計の行は下に固定 */
.report-table tfoot td {
  position: sticky; bottom: 0; z-index: 2; height: 40px;
  background: var(--bg-subtle); font-weight: var(--weight-semibold);
  border-top: 1px solid var(--border-strong); border-bottom: 0; white-space: nowrap;
}
.report-table tfoot td.col-pin { z-index: 3; }
/* 数値の後ろに、列の中での大きさを薄い棒で（売上・粗利だけ） */
.cell-bar { position: relative; }
.cell-bar::before { content: ""; position: absolute; right: var(--space-3); bottom: 2px; height: 2px; width: calc(var(--w, 0) * (100% - 24px)); border-radius: 1px; background: color-mix(in srgb, var(--chart-1) 45%, transparent); }
.cell-bar > span { position: relative; }
.cmp { display: block; font-size: var(--text-2xs); font-weight: var(--weight-regular); }
.cmp.up { color: var(--success); } .cmp.down { color: var(--danger); } .cmp.flat { color: var(--text-tertiary); }
:root[data-density="compact"] .cmp { display: none; }
.neg { color: var(--danger); }

@media (max-width: 1200px) {
  .stats--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats--6 .stat:nth-child(4) { border-left: 0; }
  .stats--6 .stat:nth-child(n+4) { border-top: 1px solid var(--border); }
}

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 1100px) {
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail__aside { position: static; order: -1; display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
}
@media (max-width: 760px) {
  .app, .app[data-sidebar="collapsed"] { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .page { padding: var(--space-4); }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head__actions { margin-left: 0; }
  .toolbar .input { width: 100%; }
  .field { grid-template-columns: 1fr; gap: var(--space-2); }
  .field__label { padding-top: 0; }
}
.cv-url-title { margin: var(--space-3) 0 var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-medium); }
.cv-url-title:first-child { margin-top: 0; }
.textarea[data-autosize] { overflow: hidden; resize: none; }

/* レポートの分け方（期間・対象の 2 行。幅が狭ければ折り返す） */
.group-tabs { display: flex; flex-direction: column; gap: var(--space-1); flex-basis: 100%; }
.group-tabs__row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.group-tabs__label { flex: none; width: 2.5em; color: var(--text-tertiary); font-size: var(--text-xs); }
.group-tabs .segmented { flex-wrap: wrap; min-width: 0; }

/* 画面の下の規約・プライバシーポリシー・運営会社のリンク */
.legal-links { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-4); margin: var(--space-8) 0 var(--space-2); font-size: var(--text-xs); }
.legal-links a { color: var(--text-tertiary); }
.legal-links a:hover { color: var(--text-secondary); text-decoration: underline; }

/* ラベル */
.label-input { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 34px; padding: 3px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: text; }
.label-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.label-input input[type=text] { flex: 1; min-width: 12em; border: 0; outline: 0; background: transparent; font: inherit; font-size: var(--text-sm); color: var(--text); padding: 2px 4px; }
.label-chip { display: inline-flex; align-items: center; gap: 2px; height: 22px; padding: 0 2px 0 8px; border-radius: var(--radius-full); background: var(--accent-weak, var(--neutral-weak)); color: var(--text); font-size: var(--text-xs); white-space: nowrap; }
.label-chip button { border: 0; background: none; color: var(--text-tertiary); cursor: pointer; width: 18px; height: 18px; border-radius: 50%; line-height: 1; }
.label-chip button:hover { background: var(--neutral-weak); color: var(--text); }
a.label-chip { padding-right: 8px; text-decoration: none; }
a.label-chip:hover { text-decoration: underline; }
.label-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
