/* Analytics chrome, loaded before authentication to match the inert navigation frame. */

    /* ===== サイドバー専用トークン: mall-ops/frontend/staff/shared/tokens.cssの
       「シェル(サイドバー/ヘッダー)用トークン」ブロックと同じ名前・同じ値のミラー。
       サイドバーは常に固定のダークネイビーで、Analytics本体のprefers-color-schemeとは
       無関係(mall-ops側もダークモード非対応のため、ここも:root直下で固定値のまま良い) ===== */
    :root {
      --shell-sidebar-bg: #14161a;
      --shell-sidebar-text: #c7cad1;
      --shell-sidebar-text-dim: #82868f;
      --shell-sidebar-border: #262a31;
      --shell-sidebar-hover-bg: #1f232a;
      --shell-sidebar-active-bg: #262c36;
      --shell-sidebar-active-text: #fff;
      --shell-sidebar-active-accent: #4d9fff;
      --shell-sidebar-width: 232px;
      --shell-sidebar-width-collapsed: 64px;
      --shell-header-height: 68px;
      --radius-sm: 6px;
      --radius-md: 10px;
      --radius-lg: 12px;
      /* 権限プレビュー用トークン(mall-ops側--group-kikuchi-bg/border・--kpi-orangeと同名同値) */
      --group-kikuchi-bg: #fff7ed;
      --group-kikuchi-border: #f59e0b;
      --kpi-orange: #d97706;
    }
    .shell-root { display: flex; min-height: 100vh; align-items: stretch; }
    .shell-sidebar {
      flex: 0 0 var(--shell-sidebar-width); width: var(--shell-sidebar-width);
      background: var(--shell-sidebar-bg); color: var(--shell-sidebar-text);
      display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    }
    .shell-brand {
      display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px;
      font-weight: 700; font-size: 14.5px; color: #fff; white-space: nowrap; overflow: hidden;
      text-decoration: none; cursor: pointer;
    }
    .shell-brand:hover { opacity: 0.85; }
    .shell-brand-mark { flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px; object-fit: contain; display: block; }

    /* レポートナビ(.shell-analytics-tabs)を囲むラッパー。flex:1で伸ばし、APPS/Settings/ログアウトを
       サイドバー最下部へ押し下げる(mall-ops shell.jsの.shell-navと同じ役割・同じクラス名) */
    .shell-nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
    .shell-nav-group { margin-bottom: 14px; }
    .shell-nav-group-label {
      font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--shell-sidebar-text-dim);
      padding: 6px 10px 4px; text-transform: uppercase; white-space: nowrap; overflow: hidden;
    }
    .shell-nav-icon { flex: 0 0 18px; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
    .shell-nav-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; }

    /* 既存.shell-analytics-tabs(横並びピル、index.html側の古い.shell-analytics-tabs button{...}ルールが残っているため
       !importantで確実に上書きする——mall-ops shell.jsの.shell-nav-linkと寸法・書体を揃える */
    .shell-analytics-tabs { display: flex !important; flex-direction: column; gap: 2px !important; border-bottom: none !important; margin: 0 !important; padding: 0 !important; }
    .shell-analytics-tabs button {
      all: unset; box-sizing: border-box; cursor: pointer; font-family: inherit;
      display: flex !important; align-items: center; gap: 11px; width: 100%;
      padding: 9px 10px !important; border-radius: var(--radius-sm);
      color: var(--shell-sidebar-text) !important; font-size: 13.5px !important; font-weight: 500 !important;
      border-left: 3px solid transparent; margin-bottom: 2px;
    }
    .shell-analytics-tabs button:hover { background: var(--shell-sidebar-hover-bg); color: #fff !important; }
    .shell-analytics-tabs button.active {
      background: var(--shell-sidebar-active-bg) !important; color: var(--shell-sidebar-active-text) !important;
      border-left-color: var(--shell-sidebar-active-accent); font-weight: 700 !important;
    }

    /* APPSセクション(2026-08-21新設)。mall-ops shell.jsの.shell-apps-sectionと同じクラス名・
       同じ値をそのまま複製(以前は.ana-shell-apps-section配下にスコープした独自定義だったが、
       トークン名を揃えたことで単純な値コピーで済むようになった) */
    .shell-apps-section { padding: 10px 10px 4px; border-top: 1px solid var(--shell-sidebar-border); }
    .shell-apps-label {
      font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--shell-sidebar-text-dim);
      padding: 4px 10px 6px; text-transform: uppercase; white-space: nowrap; overflow: hidden;
    }
    .shell-apps-item {
      display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
      color: var(--shell-sidebar-text); text-decoration: none; font-size: 13px; font-weight: 600;
      white-space: nowrap; overflow: hidden; margin-bottom: 2px; border-left: 3px solid transparent;
    }
    .shell-apps-item:hover { background: var(--shell-sidebar-hover-bg); color: #fff; }
    .shell-apps-item.active {
      background: var(--shell-sidebar-active-bg); color: var(--shell-sidebar-active-text);
      border-left-color: var(--shell-sidebar-active-accent); font-weight: 700;
    }
    .shell-apps-item-icon { flex: 0 0 20px; width: 20px; height: 20px; border-radius: 5px; overflow: hidden; }
    .shell-apps-item-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
    /* Other Apps折りたたみ(2026-09-14、サイドバー再構成)。mall-ops shell.cssの
       .shell-apps-other-*と同じクラス名・同じ値をそのまま複製 */
    .shell-apps-other-toggle {
      display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px;
      border-radius: var(--radius-sm); color: var(--shell-sidebar-text); font-size: 13px; font-weight: 600;
      white-space: nowrap; overflow: hidden; margin-bottom: 2px; border: none; border-left: 3px solid transparent;
      background: none; cursor: pointer; font-family: inherit; text-align: left;
    }
    .shell-apps-other-toggle:hover { background: var(--shell-sidebar-hover-bg); color: #fff; }
    .shell-apps-other-icon { display: flex; align-items: center; justify-content: center; color: var(--shell-sidebar-text-dim); }
    .shell-apps-other-icon svg { width: 16px; height: 16px; fill: currentColor; }
    .shell-apps-other-toggle:hover .shell-apps-other-icon { color: inherit; }
    .shell-apps-other-caret {
      margin-left: auto; width: 14px; height: 14px; display: flex; align-items: center;
      color: var(--shell-sidebar-text-dim); transition: transform 0.15s ease;
    }
    .shell-apps-other-caret svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
    .shell-apps-other.open .shell-apps-other-caret { transform: rotate(180deg); }
    .shell-apps-other-items { display: none; }
    .shell-apps-other.open .shell-apps-other-items { display: block; }
    .shell-apps-other-items .shell-apps-item { padding-left: 20px; }
    /* ===== PC のサイドバー: APPS を 3 列グリッド(2026-11-02、ユーザー要望「領域大きすぎて」) =====
       アイコン上・小さい文字下の 3 列。Other Apps は畳まずフラットに並べる(スマホのドロワーと同じ形)。
       現在地は左の青い線の代わりに、背景+枠線で示す。折りたたみ(64px)時は従来のアイコン 1 列のまま */
    @media (min-width: 901px) {
      .shell-root:not(.collapsed) .shell-apps-section { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 6px 6px 4px; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-label { grid-column: 1 / -1; padding: 2px 6px 3px; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-other,
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-other-items { display: contents; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-other-toggle { display: none; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-item {
        flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 5px 1px 4px; margin: 0; border-left: none; border-radius: 8px;
        font-size: 9.5px; font-weight: 600; letter-spacing: -0.01em; text-align: center; line-height: 1.15; min-width: 0;
      }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-other-items .shell-apps-item { padding-left: 1px; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-item.active { box-shadow: inset 0 0 0 1px var(--shell-sidebar-active-accent); }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-item-icon { flex: 0 0 24px; width: 24px; height: 24px; border-radius: 6px; }
      .shell-root:not(.collapsed) .shell-apps-section .shell-apps-item-label { display: block; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
      /* 下の固定領域: 設定 / ログアウト / 折りたたむ を 1 行にまとめて縦を詰める(折りたたむはアイコンのみ) */
      .shell-root:not(.collapsed) .shell-sidebar-footer { display: flex; flex-wrap: nowrap; gap: 4px; padding: 6px 8px 8px; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-nav-link { flex: 1 1 0; min-width: 0; justify-content: center; margin: 0; padding: 6px 4px; gap: 5px; font-size: 12px; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-nav-link[hidden] { display: none; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-nav-link .shell-nav-icon svg { width: 15px; height: 15px; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-collapse-btn { flex: 0 0 34px; width: 34px; padding: 6px 0; justify-content: center; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-collapse-btn .shell-collapse-label { display: none; }
      .shell-root:not(.collapsed) .shell-sidebar-footer .shell-collapse-btn .shell-nav-icon svg { width: 15px; height: 15px; }
      /* メニューを一段小さく(2026-11-28、mall-ops shell.cssの同名ブロックと同じ値) */
      .shell-root:not(.collapsed) .shell-nav-group { margin-bottom: 10px; }
      .shell-root:not(.collapsed) .shell-nav-group-label { font-size: 10px; padding: 4px 10px 3px; }
      .shell-root:not(.collapsed) .shell-analytics-tabs button { gap: 9px; padding: 6px 10px !important; font-size: 12.5px !important; margin-bottom: 1px; }
      .shell-root:not(.collapsed) .shell-nav .shell-nav-icon { flex-basis: 16px; width: 16px; height: 16px; }
      .shell-root:not(.collapsed) .shell-nav .shell-nav-icon svg { width: 16px; height: 16px; }
    }

    /* Settings/ログアウト(mall-ops shell.jsの.shell-sidebar-footer/.shell-nav-link/
       .shell-logout-linkと同じクラス名・同じ値) */
    .shell-sidebar-footer { padding: 10px; border-top: 1px solid var(--shell-sidebar-border); }
    .shell-nav-link {
      display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
      color: var(--shell-sidebar-text); text-decoration: none; font-size: 13.5px; font-weight: 500;
      white-space: nowrap; overflow: hidden; margin-bottom: 2px;
    }
    .shell-nav-link:hover { background: var(--shell-sidebar-hover-bg); color: #fff; }
    .shell-sidebar-footer .shell-logout-link {
      width: 100%; background: transparent; border: none; font-family: inherit; text-align: left; cursor: pointer;
    }

    /* ===== メインエリア(ヘッダー+ページ本体)。mall-ops shell.jsの.shell-main/.shell-header/
       .shell-contentと同じクラス名・同じ値 ===== */
    .shell-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
    .shell-content { flex: 1; padding: 20px 24px 100px; }

    /* .shell-header/.shell-preview-bannerの内側だけ、汎用トークン(--panel-bg/--text等)を
       mall-ops側の固定値(ダークモード非対応)で再定義する。CSSカスタムプロパティは最も近い
       祖先の定義を使うため、これは.shell-header/.shell-preview-banner自身とその子孫にのみ
       効き、兄弟である.shell-content(Analytics本体、既存のprefers-color-scheme対応を
       維持する必要がある)には一切波及しない。「シェルはCS/Logisticsと同じく常に同じ見た目」
       「Analytics本体は既存のダークモード対応を維持」を両立させるための意図的な設計 */
    .shell-header, .shell-preview-banner {
      --panel-bg: #fff; --border-light: #eceff2; --text: #111827; --text-muted: #6b7280;
      --text-faint: #9ca3af; --bg: #f7f8fa; --shadow: rgba(0,0,0,0.05);
      --accent: #06c; --accent-bg: #e6f0fb; --active-bg: #1a1a1a; --active-fg: #fff;
    }
    .shell-header {
      background: var(--panel-bg); border-bottom: 1px solid var(--border-light);
      padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
      position: sticky; top: 0; z-index: 30; min-height: 60px;
    }
    .shell-header-left { min-width: 0; display: flex; align-items: center; gap: 12px; }
    .shell-header-titleblock { min-width: 0; }
    .shell-breadcrumb { font-size: 12px; color: var(--text-faint); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
    .shell-header-title { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -0.01em; color: var(--text); }
    .shell-header-right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

    .shell-menu-btn {
      display: none; background: transparent; border: 1px solid var(--border-light); border-radius: var(--radius-sm);
      padding: 7px; cursor: pointer; color: var(--text);
    }
    .shell-menu-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; display: block; }

    .shell-user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 5px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border-light); }
    .shell-user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: 0 0 26px; }
    .shell-user-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
    .shell-user-role { font-size: 10px; color: var(--text-faint); }

    /* 権限プレビュー(mall-ops shell.jsの.shell-preview-*と同じクラス名・同じ値) */
    .shell-preview-select-wrap {
      display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 20px;
      background: var(--group-kikuchi-bg); border: 1px dashed var(--group-kikuchi-border);
    }
    .shell-preview-select-label { font-size: 10.5px; color: var(--kpi-orange); font-weight: 700; white-space: nowrap; }
    .shell-preview-select { font-size: 12.5px; font-weight: 600; color: var(--text); background: transparent; border: none; max-width: 150px; }
    .shell-preview-select:focus { outline: 1px solid var(--kpi-orange); border-radius: 4px; }

    .shell-preview-banner {
      display: flex; align-items: center; justify-content: space-between; gap: 12px;
      padding: 8px 24px; background: var(--group-kikuchi-bg); border-bottom: 1px solid var(--group-kikuchi-border);
      font-size: 12.5px; color: var(--kpi-orange);
    }
    .shell-preview-banner[hidden] { display: none; }
    .shell-preview-banner-text strong { color: var(--kpi-orange); }
    .shell-preview-banner-reset {
      flex: 0 0 auto; font-size: 12px; font-weight: 700; padding: 5px 12px; cursor: pointer;
      background: #fff; color: var(--kpi-orange); border: 1px solid var(--group-kikuchi-border);
      border-radius: var(--radius-sm); white-space: nowrap;
    }

    .shell-denied { margin: 60px auto; max-width: 420px; text-align: center; color: var(--text-muted, #6b7280); font-size: 14px; padding: 0 16px; }
    .shell-denied-reset {
      display: inline-block; margin-top: 14px; font-size: 12.5px; font-weight: 700; padding: 7px 14px;
      cursor: pointer; background: var(--group-kikuchi-bg); color: var(--kpi-orange);
      border: 1px solid var(--group-kikuchi-border); border-radius: var(--radius-sm);
    }

    /* ===== レスポンシブ: mall-ops shell.cssと同じ900pxブレークポイント・同じドロワー方式
       (Analytics独自のブレークポイントは持たない) ===== */
    .shell-scrim { display: none; }
    @media (max-width: 900px) {
      .shell-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
      .shell-sidebar {
        position: fixed; left: 0; top: 0; width: 260px; flex-basis: 260px;
        transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 2px 0 16px rgba(0,0,0,0.2);
        z-index: 40;
      }
      .shell-root.mobile-open .shell-sidebar { transform: translateX(0); }
      .shell-scrim {
        display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 39;
      }
      .shell-root.mobile-open .shell-scrim { display: block; }
      .shell-header { padding: 12px 16px; }
      .shell-content { padding: 16px 16px 80px; }
      .shell-user-name { display: none; }
    }
@media(min-width:901px){
 .shell-root.collapsed .shell-sidebar{width:64px;flex-basis:64px}
 .shell-root.collapsed .shell-brand-label,.shell-root.collapsed .shell-nav-label,.shell-root.collapsed .shell-collapse-label,.shell-root.collapsed .shell-apps-label,.shell-root.collapsed .shell-apps-item-label,.shell-root.collapsed .shell-apps-other-toggle span:not(.shell-apps-other-icon){display:none}
 .shell-root.collapsed .shell-nav-group-label{height:0;opacity:0;padding:0;margin:0;overflow:hidden}
 .shell-root.collapsed .shell-collapse-btn .shell-nav-icon{transform:rotate(180deg)}
}
.shell-collapse-btn{display:flex;align-items:center;gap:10px;width:100%;min-height:36px;border:0;background:transparent;color:var(--shell-sidebar-text-dim);padding:8px 10px;font:inherit;font-size:12px;text-align:left;cursor:pointer;border-radius:6px}
.shell-collapse-btn:hover{background:var(--shell-sidebar-hover-bg);color:#fff}
