/* Y-FILTER. 管理系ページ共通スタイル（options / remote / diagnostics / policy） */
/* 配色は Y-FILTER. の盾アイコン（金・琥珀色）に合わせる。管理コンソール（SK Hub Systems）は console.css で青に上書きする */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --border: #e7e2d8;
  --border-strong: #d5cdbf;
  --text: #141821;
  --muted: #5c6475;
  --faint: #8a91a1;
  --primary: #9a5a00;
  --primary-hover: #7f4a00;
  --primary-soft: #fff4d9;
  --primary-ring: rgba(214, 150, 30, 0.22);
  --ok: #1b7f3b;
  --ok-soft: #e6f5ec;
  --danger: #b3261e;
  --danger-soft: #fdeceb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.04), 0 4px 16px rgba(20, 24, 33, 0.04);
  --font: "Inter", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
code { font-family: var(--mono); font-size: 0.92em; background: rgba(0,0,0,0.05); padding: 1px 5px; border-radius: 5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: sticky; top: 0; flex: 0 0 260px; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { display: block; width: 34px; height: 34px; border-radius: 9px; flex: none; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; border: 0; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background 150ms ease, color 150ms ease; }
.nav-item svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 14px 4px 0; margin-top: 12px; display: grid; gap: 8px; }
.msg { color: var(--muted); font-size: 12px; text-align: center; min-height: 18px; }

.main { flex: 1; min-width: 0; padding: 36px 44px 64px; }
.main-inner { max-width: 820px; margin: 0 auto; }
.main-inner.wide { max-width: 1080px; }

/* Topbar layout (diagnostics / policy) */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; background: rgba(255,255,255,0.86); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar .brand { padding: 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page { max-width: 1080px; margin: 0 auto; padding: 32px 28px 64px; }

/* ---------- Sections ---------- */
.section { display: none; }
.section.active { display: block; animation: rise 240ms ease; }
.section-head { margin-bottom: 22px; }
.section-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
.section-head p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-head { padding: 18px 22px 0; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.card-head.split { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head.split > div { flex: 1; min-width: 240px; }
.card-body { padding: 16px 22px 20px; }
.card-body > * + * { margin-top: 12px; }
.card-body.flush { padding: 8px 0 0; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.divider { border-top: 1px solid var(--border); }

/* Setting rows */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; cursor: pointer; }
.setting + .setting { border-top: 1px solid var(--border); }
.setting-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-title { font-size: 14px; font-weight: 500; }
.setting-desc { font-size: 12.5px; color: var(--muted); }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.hint { font-size: 12px; color: var(--muted); }

/* Switch */
input.switch { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; margin: 0; transition: background 160ms ease; }
input.switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 180ms cubic-bezier(.3,.7,.4,1); }
input.switch:checked { background: var(--primary); }
input.switch:checked::before { transform: translateX(18px); }
input.switch:disabled { opacity: 0.45; cursor: not-allowed; }
input.switch:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }

input[type="checkbox"]:not(.switch) { accent-color: var(--primary); width: 16px; height: 16px; }

/* Inputs */
input[type="text"], input[type="password"], input[type="time"], input[type="search"], textarea, select { width: 100%; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; font-size: 13.5px; transition: border-color 150ms ease, box-shadow 150ms ease; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
select:disabled { background: var(--surface-2); color: var(--faint); }
select[multiple] { padding: 6px; }
select[multiple] option { padding: 7px 8px; border-radius: 6px; font-size: 13px; }
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline > select, .inline > input[type="time"] { width: auto; }
.inline > .grow { flex: 1; min-width: 180px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background 150ms ease, border-color 150ms ease, transform 100ms ease; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-tonal { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-tonal:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Chips (checkbox tiles) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px; font-size: 13px; background: var(--surface); transition: all 140ms ease; user-select: none; }
.chip span::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--border-strong); flex: none; background: var(--surface) center / 10px no-repeat; transition: all 140ms ease; }
.chip:hover span { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.chip input:checked + span::before { background-color: var(--primary); border-color: var(--primary); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E"); }
.chip input:focus-visible + span { box-shadow: 0 0 0 4px var(--primary-ring); }
.chips.mono .chip span { font-family: var(--mono); }

/* Status tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stats.wide { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.stat-value { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--faint); white-space: nowrap; }
.stat-value::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.stat-value[data-state="on"] { color: var(--ok); }
.stat-value[data-state="off"] { color: var(--faint); }

/* Key-value rows */
.kv-list { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; }
.kv-list > .row { display: contents; }
.kv-list .k, .kv-list .v { padding: 11px 22px; border-top: 1px solid var(--border); font-size: 13px; }
.kv-list > .row:first-child .k, .kv-list > .row:first-child .v { border-top: 0; }
.kv-list .k { color: var(--muted); }
.kv-list .v { word-break: break-word; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.meta { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.meta-k { font-size: 11.5px; color: var(--muted); }
.meta-v { font-size: 13px; font-weight: 500; word-break: break-all; }

/* Pills */
.ok, .warn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 999px; }
.ok { color: var(--ok); background: var(--ok-soft); }
.warn { color: var(--danger); background: var(--danger-soft); }
td.warn { display: table-cell; background: none; border-radius: 0; font-weight: 500; color: var(--muted); text-align: center; padding: 28px; }

/* Table */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { padding-left: 22px; }
table.data th:last-child, table.data td:last-child { padding-right: 22px; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td:first-child { white-space: nowrap; color: var(--muted); }
table.data td.mono { word-break: break-all; }

.log { font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; max-height: 280px; overflow: auto; }
.log > div { padding: 8px 12px; border-bottom: 1px solid var(--border); word-break: break-all; }
.log > div:last-child { border-bottom: 0; }
.log > .count-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-family: var(--font); font-size: 13px; }
.count-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-row b { flex: none; color: var(--ok); font-variant-numeric: tabular-nums; }
.log > .hint { font-family: var(--font); }

.notice { padding: 14px 16px; border-radius: 12px; background: var(--primary-soft); border: 1px solid #f0dca8; font-size: 13px; }
.notice.danger { background: var(--danger-soft); border-color: #f1c9c5; color: #6d1a14; }
.notice h4 { font-size: 13.5px; margin-bottom: 6px; }
.status-error { color: var(--danger); font-size: 12px; margin: 0; }

/* Terms list (options) */
.kv { display: grid; grid-template-columns: 1fr auto; }
.kv > div { padding: 12px 22px; border-top: 1px solid var(--border); display: flex; align-items: center; }
.kv > div:nth-child(-n+2) { border-top: 0; }
.kv .k { color: var(--muted); font-size: 13px; gap: 6px; }
.kv .k span { color: var(--text); font-weight: 600; }

/* About */
.about-hero { display: flex; align-items: center; gap: 14px; padding: 22px; border-bottom: 1px solid var(--border); }
.about-hero img { width: 40px; height: 40px; }
.about-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; user-select: none; }
#about-product-name { cursor: pointer; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13.5px; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-row .arrow { color: var(--faint); }
#remote-note { color: var(--danger); font-weight: 600; padding: 12px 22px; display: none; }

.dev-card { border-color: #f1c9c5; }
.dev-card .card-head h3 { color: var(--danger); }

/* Document reader (policy) */
.doc-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; align-items: start; }
.doc-nav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 4px; padding: 8px; }
.doc-nav button { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; font-size: 13px; color: var(--muted); line-height: 1.45; transition: background 150ms ease, color 150ms ease; }
.doc-nav button::before { content: ""; flex: none; width: 3px; align-self: stretch; border-radius: 3px; background: transparent; }
.doc-nav button:hover { background: var(--surface-2); color: var(--text); }
.doc-nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.doc-nav button.active::before { background: var(--primary); }
.doc-article { padding: 36px 44px 48px; }
.doc-eyebrow { font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: 0.06em; text-transform: uppercase; }
#doc-title { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin: 8px 0 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
#doc-body { white-space: pre-wrap; line-height: 1.95; font-size: 14px; color: #2a2f3b; max-width: 76ch; overflow-wrap: anywhere; }

/* Gate screens (rendered by page scripts) */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 32px; }
.gate-card .brand { padding: 0 0 22px; }
.gate-card h1 { font-size: 20px; margin-bottom: 8px; }
.gate-card p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; }
.gate-card .consent { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: 13px; margin-bottom: 16px; cursor: pointer; }
.gate-card .gate-msg { margin-top: 12px; font-size: 12.5px; color: var(--danger); min-height: 18px; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { position: sticky; top: 0; z-index: 5; flex: none; height: auto; padding: 12px 12px 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 4px 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: none; }
  .nav-label { display: none; }
  .nav-item { width: auto; white-space: nowrap; padding: 8px 12px; }
  .sidebar-foot { grid-template-columns: 1fr 1fr; padding-top: 10px; margin-top: 8px; }
  .sidebar-foot .msg { grid-column: 1 / -1; }
  .main { padding: 24px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .page { padding: 20px 16px 48px; }
  .doc-layout { grid-template-columns: 1fr; gap: 12px; }
  .doc-nav { position: static; flex-direction: row; overflow-x: auto; padding: 0; scrollbar-width: none; }
  .doc-nav button { flex: none; max-width: 240px; }
  .doc-article { padding: 24px 20px 32px; }
  .kv-list { grid-template-columns: 1fr; }
  .kv-list .v { border-top: 0; padding-top: 0; }
}

/* シークレットモードで動いていないときの警告（設定画面） */
.card.incognito-warn { border-color: var(--danger); background: var(--danger-soft); }
.card.incognito-warn .card-head h3 { color: var(--danger); }


/* 曜日・時間帯のルール（設定画面・管理コンソール） */
.schedule-rules { display: flex; flex-direction: column; gap: 8px; }
.schedule-rule { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.schedule-days { display: flex; gap: 4px; }
.schedule-days label { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; font-weight: 700; cursor: pointer; user-select: none; }
.schedule-days input { position: absolute; opacity: 0; pointer-events: none; }
.schedule-days label:has(input:checked) { background: var(--primary); border-color: var(--primary); color: #fff; }
.schedule-rule input[type="time"] { width: auto; }
.schedule-rule .remove { margin-left: auto; }

/* 直近 7 日の利用時間 */
.usage-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 110px; margin-top: 12px; }
.usage-week:empty { display: none; }
.usage-day { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 11px; color: var(--muted); }
.usage-bar { width: 100%; max-width: 34px; border-radius: 6px 6px 2px 2px; background: var(--primary); min-height: 2px; }
.usage-bar.over { background: var(--danger); }
.usage-day b { font-size: 11px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

/* 見出しの左に小さなアイコンを付ける（例: SK Hub Systems） */
.with-mark { display: flex; align-items: center; gap: 8px; }
.with-mark img { width: 20px; height: 20px; flex: none; }
