/* ===========================================================================
   朝日M&G 統合業務アプリ — デザイントークンと全画面のスタイル

   色・角丸・影・書体はすべてこのファイルの :root にまとめてあります。
   ブランド色を変えるときは --accent とその周辺（下の「ブランド色」の節）
   だけを差し替えてください。画面側のスタイルに色コードは書きません。
   =========================================================================== */

:root {
  /* --- ブランド色（朝日M&G＝赤）------------------------------------------ */
  --accent:          #cc0011;  /* ロゴの明るい赤（丸の部分）。白文字で 5.87:1 */
  --accent-strong:   #ab000d;  /* ロゴの中くらいの赤（Ｖ字の部分）。押したとき・濃い面 */
  --accent-soft:     #fdecee;  /* 淡い背景（選択行・バッジの地） */
  --accent-line:     #f2c9cc;  /* 淡い枠線 */
  --accent-ink:      #860005;  /* ロゴのいちばん濃い赤（斜めの棒）。淡い地の上に置く文字 */

  /* --- 地と文字 ---------------------------------------------------------- */
  --bg:        #f5f2f3;  /* 既存アプリと同じ、ほんのり赤みのある灰色 */
  --bg-elev:   #ece6e8;
  --surface:   #ffffff;
  --surface-2: #fbf9fa;
  --text:      #1d1d1f;
  --muted:     #6e6e73;
  --faint:     #9b9ba1;
  --line:      #e7dfe1;  /* 既存アプリと同じ罫線色 */
  --line-2:    rgba(0, 0, 0, 0.055);


  /* --- グラフの系列色（6区分。順番は固定し、使い回さない）----------------
     検証済み（dataviz の validate_palette.js：明度帯・彩度下限・色弱時の判別
     ΔE・コントラストすべて PASS）。順番を変えると判別性が崩れるので触らない */
  --cat-1: #cc0011;  /* 配送部 */
  --cat-2: #1f6fb2;  /* 物流1部 DaMC */
  --cat-3: #0e8f52;  /* 物流2部 KLC */
  --cat-4: #7046c0;  /* 第三冷蔵庫 */
  --cat-5: #c27803;  /* 酒類DC */
  --cat-6: #0b9aa0;  /* 本社・総務 */

  /* --- 状態 -------------------------------------------------------------- */
  --ok:        #2f7d5b;
  --ok-soft:   #e8f3ee;
  --warn:      #b0701a;
  --warn-soft: #fdf2e1;
  --danger:    #c0392b;
  --danger-soft: #fdeceb;
  --info:      #2b5f9e;
  --info-soft:  #eaf1fa;

  /* --- 形 ---------------------------------------------------------------- */
  --radius-l: 20px;
  --radius-m: 14px;
  --radius-s: 10px;
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.055);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-up: 0 -2px 24px rgba(0, 0, 0, 0.08);

  /* --- 書体 -------------------------------------------------------------- */
  --font: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN',
          'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
  --font-num: 'Helvetica Neue', Helvetica, Arial, sans-serif;  /* 数字（既存アプリと同じ） */

  /* --- 寸法 -------------------------------------------------------------- */
  --rail: 232px;
  --tabbar: 58px;
  --maxw: 1240px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --accent:        #ff5a5f;
    --accent-strong: #e0454a;
    --accent-soft:   #3a1618;
    --accent-line:   #5a2124;
    --accent-ink:    #ffa6a9;

    --cat-1: #f2555c;
    --cat-2: #4b94e0;
    --cat-3: #19a862;
    --cat-4: #9a6ff0;
    --cat-5: #bc8210;
    --cat-6: #0ba3a9;

    --bg:        #000000;
    --bg-elev:   #1c1c1e;
    --surface:   #1c1c1e;
    --surface-2: #2c2c2e;
    --text:      #f5f5f7;
    --muted:     #a1a1a6;
    --faint:     #6e6e73;
    --line:      rgba(255, 255, 255, 0.12);
    --line-2:    rgba(255, 255, 255, 0.07);

    --ok:        #4cd08a;
    --ok-soft:   #15291f;
    --warn:      #e8a33d;
    --warn-soft: #2d2213;
    --danger:    #ff6b5e;
    --danger-soft: #301814;
    --info:      #6aa6ef;
    --info-soft:  #16222f;

    --shadow:    0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-up: 0 -2px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme='dark'] {
  --accent:        #ff5a5f;
  --accent-strong: #e0454a;
  --accent-soft:   #3a1618;
  --accent-line:   #5a2124;
  --accent-ink:    #ffa6a9;

  --cat-1: #f2555c;
  --cat-2: #4b94e0;
  --cat-3: #19a862;
  --cat-4: #9a6ff0;
  --cat-5: #bc8210;
  --cat-6: #0ba3a9;
  --bg:        #000000;
  --bg-elev:   #1c1c1e;
  --surface:   #1c1c1e;
  --surface-2: #2c2c2e;
  --text:      #f5f5f7;
  --muted:     #a1a1a6;
  --faint:     #6e6e73;
  --line:      rgba(255, 255, 255, 0.12);
  --line-2:    rgba(255, 255, 255, 0.07);
  --ok:        #4cd08a;
  --ok-soft:   #15291f;
  --warn:      #e8a33d;
  --warn-soft: #2d2213;
  --danger:    #ff6b5e;
  --danger-soft: #301814;
  --info:      #6aa6ef;
  --info-soft:  #16222f;
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-up: 0 -2px 24px rgba(0, 0, 0, 0.5);
}

/* ===== 土台 =============================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overscroll-behavior-y: contain;
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  font-feature-settings: 'palt';
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.35; letter-spacing: 0; }
h1 { font-size: 27px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; color: var(--muted); font-weight: 600; }
p  { margin: 0 0 0.9em; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.num { font-variant-numeric: tabular-nums; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hide { display: none !important; }

/* ===== 骨組み ============================================================= */

#app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100dvh;
}

/* --- 左の縦ナビ（PC） --- */
.rail {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 18px 12px 12px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1px solid var(--line-2);
}

/* メニューが画面の高さを超えたら、ここだけが動く。
   ブランドと自分の情報は上下に止めておく（見切れないように） */
.rail__nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.rail__nav::-webkit-scrollbar { width: 8px; }
.rail__nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.rail__nav::-webkit-scrollbar-track { background: transparent; }

.rail__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.rail__mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  background: #fff;                 /* ロゴは白地に置く決まり */
  border: 1px solid var(--line);
  display: grid; place-items: center;
  overflow: hidden;
}
.rail__mark svg { width: 22px; height: 22px; display: block; }
.rail__name { font-size: 14px; font-weight: 650; line-height: 1.25; }
.rail__sub   { font-size: 11px; color: var(--muted); line-height: 1.25; }

.rail__group {
  margin: 14px 10px 4px;
  font-size: 11px;
  font-weight: 650;
  color: var(--faint);
  letter-spacing: 0.04em;
}

.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius-s);
  background: none;
  color: var(--text);
  font-size: 14.5px;
  text-align: left;
  transition: background 0.18s var(--ease);
}
.navitem:hover { background: var(--bg-elev); }
.navitem[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 650;
}
.navitem svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.navitem__badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 19px;
}

.rail__foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-2); }

.whoami {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--radius-s); background: none; text-align: left;
}
.whoami:hover { background: var(--bg-elev); }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 999px;
  background: var(--bg-elev); color: var(--muted);
  display: grid; place-items: center; font-size: 12px; font-weight: 650;
}
.whoami__name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.whoami__role { font-size: 11px; color: var(--muted); line-height: 1.2; }

/* --- 本体 --- */
.main { min-width: 0; padding: 0 0 48px; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.topbar__title { font-size: 17px; font-weight: 650; }
.topbar__spacer { flex: 1; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 22px 24px 0; }

.page__head { margin-bottom: 18px; }
.page__head p { color: var(--muted); font-size: 14px; margin: 4px 0 0; }

/* ===== 部品 =============================================================== */

.card {
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.card--pad0 { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 12px;
}
.card__head h3 { flex: 1; }
.card__note { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--tight { gap: 6px; }
.spacer { flex: 1; }

/* --- ボタン --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px; font-weight: 600;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease), opacity 0.18s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn svg { width: 17px; height: 17px; }

.btn--primary {
  background: var(--accent); border-color: transparent; color: #fff;
}
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { background: none; border-color: transparent; color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--quiet { background: var(--bg-elev); border-color: transparent; }
.btn--danger { color: var(--danger); border-color: var(--line); }
.btn--sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn--lg { min-height: 50px; padding: 0 24px; font-size: 16px; }
.btn--block { width: 100%; }

.iconbtn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 999px; background: none; color: var(--muted);
  transition: background 0.18s var(--ease), transform 0.12s var(--ease);
}
.iconbtn:hover { background: var(--bg-elev); color: var(--text); }
.iconbtn:active { transform: scale(0.94); }
.iconbtn svg { width: 20px; height: 20px; }

/* --- 入力 --- */
.field { display: block; margin-bottom: 14px; }
.field > span, .label {
  display: block; margin-bottom: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.field .hint { font-size: 12px; color: var(--faint); font-weight: 400; margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* iOS で拡大されないように 16px を下回らせない */
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.65; }
.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.input--invalid, .select--invalid, .textarea--invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  min-height: 34px; padding: 0 13px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13.5px; font-weight: 550;
  white-space: nowrap;          /* 氏名が縦に割れないように */
  transition: background 0.16s var(--ease), transform 0.12s var(--ease);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed='true'], .chip--on {
  background: var(--accent); border-color: transparent; color: #fff;
}

.switchrow {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line-2);
}
.switchrow:last-child { border-bottom: 0; }
.switchrow__text { flex: 1; min-width: 0; }
.switchrow__text b { display: block; font-size: 14.5px; font-weight: 600; }
.switchrow__text span { font-size: 12.5px; color: var(--muted); }

.switch {
  position: relative; width: 50px; height: 30px; flex: none;
  border: 0; border-radius: 999px; background: var(--bg-elev);
  transition: background 0.2s var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px; border-radius: 999px; background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}
.switch[aria-checked='true'] { background: var(--accent); }
.switch[aria-checked='true']::after { transform: translateX(20px); }

.slider { width: 100%; accent-color: var(--accent); height: 28px; }

/* --- 値の見せ方 --- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat__value {
  font-size: 28px; font-weight: 680; line-height: 1.15;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.stat__unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat__sub { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat--up .stat__sub   { color: var(--ok); }
.stat--down .stat__sub { color: var(--danger); }

.meter { height: 6px; border-radius: 999px; background: var(--bg-elev); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.meter--ok   > i { background: var(--ok); }
.meter--warn > i { background: var(--warn); }
.meter--bad  > i { background: var(--danger); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  background: var(--bg-elev); color: var(--muted);
  font-size: 12px; font-weight: 650; white-space: nowrap;
}
.badge--ok     { background: var(--ok-soft);     color: var(--ok); }
.badge--warn   { background: var(--warn-soft);   color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info   { background: var(--info-soft);   color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-ink); }

.dot { width: 8px; height: 8px; border-radius: 999px; background: currentColor; flex: none; }

/* --- 一覧 --- */
.list { list-style: none; margin: 0; padding: 0; }
.list__daysep {
  position: sticky; top: 56px; z-index: 5;
  padding: 10px 20px 6px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 650; color: var(--muted);
}
.li {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  text-align: left; width: 100%; border-left: 0; border-right: 0; border-top: 0;
}
.li:last-child { border-bottom: 0; }
.li:hover { background: var(--surface-2); }
.li__body { flex: 1; min-width: 0; }
.li__title {
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.li__meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.li__right { text-align: right; flex: none; }
.li--unread .li__title::before {
  content: ''; display: inline-block; width: 7px; height: 7px;
  border-radius: 999px; background: var(--accent); margin-right: 7px; vertical-align: 1px;
}

.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty h3 { font-size: 15px; margin-bottom: 4px; }
.empty p { font-size: 13.5px; margin: 0; }

/* --- 表 --- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 650;
}
.table td.n, .table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr:hover { background: var(--surface-2); }
.tablewrap { overflow: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }

/* --- かんばん --- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board__col {
  flex: 0 0 272px; min-width: 272px;
  background: var(--bg-elev); border-radius: var(--radius-m); padding: 10px;
}
.board__colhead {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 6px 10px; font-size: 13px; font-weight: 650;
}
.board__colhead .badge { margin-left: auto; }
.board__col--over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.taskcard {
  background: var(--surface); border-radius: var(--radius-s);
  padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow-sm);
  cursor: grab; text-align: left; width: 100%; border: 0;
}
.taskcard:active { cursor: grabbing; }
.taskcard__title { font-size: 14px; font-weight: 600; margin-bottom: 5px; }
.taskcard__meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; }

/* --- グラフ --- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-size: 10.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--line-2); stroke-width: 1; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .bar { fill: var(--accent); }
.chart .bar--2 { fill: var(--muted); opacity: 0.45; }
.chart .lineseries { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .lineseries--2 { stroke: var(--info); }
.chart .area { fill: var(--accent); opacity: 0.1; }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart .target { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* --- 読み込み中（スケルトン） --- */
.sk { background: var(--bg-elev); border-radius: 7px; position: relative; overflow: hidden; }
.sk::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 65%, transparent), transparent);
  animation: skshine 1.5s ease-in-out infinite;
}
@keyframes skshine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.sk--line { height: 13px; }
.sk--title { height: 20px; width: 42%; }
.sk--card { height: 104px; border-radius: var(--radius-l); }
.sk--row { height: 54px; border-radius: 0; margin-bottom: 1px; }

/* --- トースト --- */
.toasts {
  position: fixed; z-index: 90;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 761px) { .toasts { bottom: 24px; } }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: color-mix(in srgb, var(--text) 92%, transparent);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toastin 0.24s var(--ease);
  touch-action: pan-x;
}
.toast--error { background: var(--danger); color: #fff; }
.toast__text { flex: 1; min-width: 0; }
.toast__act {
  border: 0; background: none; color: inherit;
  font-weight: 700; font-size: 14px; text-decoration: underline; padding: 0 2px;
}
.toast--out { animation: toastout 0.2s var(--ease) forwards; }
@keyframes toastin  { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
@keyframes toastout { to   { opacity: 0; transform: translateY(8px) scale(0.98); } }

/* --- シート／ダイアログ --- */
.scrim {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, 0.32);
  animation: fadein 0.2s var(--ease);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 80;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 40px));
  max-height: min(86dvh, 860px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
  animation: dlgin 0.22s var(--ease);
}
@keyframes dlgin { from { opacity: 0; transform: translate(-50%, -46%) scale(0.98); } }
.sheet__grip { display: none; }
.sheet__head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 10px;
}
.sheet__head h2 { flex: 1; font-size: 18px; }
.sheet__body { padding: 4px 18px 18px; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet__foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-2);
}
.sheet__foot .btn { min-width: 96px; }

/* --- スワイプ操作の行 --- */
.swipe { position: relative; overflow: hidden; }
.swipe__under {
  position: absolute; inset: 0; display: flex; align-items: stretch;
  font-size: 13.5px; font-weight: 700; color: #fff;
}
.swipe__under > * {
  display: flex; align-items: center; padding: 0 20px; flex: 1;
}
.swipe__under .left  { background: var(--ok); justify-content: flex-start; }
.swipe__under .right { background: var(--warn); justify-content: flex-end; }
.swipe__top { position: relative; background: var(--surface); will-change: transform; }
.swipe__hint { font-size: 11.5px; color: var(--faint); padding: 8px 20px 0; }

/* --- 引っ張って更新 --- */
.ptr {
  position: absolute; top: 0; left: 0; right: 0;
  display: grid; place-items: center;
  height: 0; overflow: hidden; color: var(--muted);
}
.ptr__spin {
  width: 20px; height: 20px; border-radius: 999px;
  border: 2px solid var(--line); border-top-color: var(--accent);
}
.ptr--busy .ptr__spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 入力候補 --- */
.ac { position: relative; }
.ac__list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 5px);
  max-height: 268px; overflow: auto;
  margin: 0; padding: 5px; list-style: none;
  background: var(--surface); /* 透けさせない */
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.ac__opt { padding: 9px 11px; border-radius: var(--radius-s); font-size: 14.5px; cursor: pointer; }
.ac__opt[aria-selected='true'] { background: var(--accent-soft); color: var(--accent-ink); }
.ac__opt b { font-weight: 700; }
.ac__opt small { display: block; font-size: 11.5px; color: var(--muted); }

/* --- 未提出の名前（押すとその人へ） --- */
.missing__names {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  margin-top: 6px;
}
.missing__name {
  border: 0; background: none; padding: 0;
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--danger);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  cursor: pointer;
}
.missing__name:hover { opacity: 0.75; }

/* --- 同期の表示 --- */
.sync {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
.sync--off  { color: var(--warn); }
.sync--busy { color: var(--accent); }

/* --- 下のタブバー（スマホ） --- */
.tabbar { display: none; }

/* ===== ログイン画面 ======================================================= */

.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--bg);
}
.login__card {
  width: min(400px, 100%);
  background: var(--surface); border-radius: 24px;
  box-shadow: var(--shadow); padding: 30px 26px 26px;
}
.login__mark {
  width: 58px; height: 58px; border-radius: 17px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid; place-items: center;
  margin-bottom: 18px;
}
.login__mark svg { width: 40px; height: 40px; display: block; }
.login h1 { font-size: 23px; margin-bottom: 4px; }
.login__sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login__or {
  display: flex; align-items: center; gap: 12px;
  color: var(--faint); font-size: 12px; margin: 20px 0 16px;
}
.login__or::before, .login__or::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.login__err {
  background: var(--danger-soft); color: var(--danger);
  border-radius: var(--radius-m); padding: 10px 13px;
  font-size: 13.5px; margin-bottom: 14px;
}
.login__foot { margin-top: 20px; font-size: 12px; color: var(--faint); text-align: center; }

/* ===== スマホ ============================================================= */

@media (max-width: 760px) {
  body { font-size: 15.5px; }
  h1 { font-size: 23px; }

  #app { grid-template-columns: 1fr; }
  .rail { display: none; }

  .main {
    padding-bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom));
  }

  .topbar { padding: 10px 16px; min-height: 52px; }
  .topbar__title { font-size: 16px; }

  .wrap { padding: 16px 16px 0; }

  .grid--2, .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--auto { grid-template-columns: 1fr; }
  .card { padding: 15px 16px; border-radius: var(--radius-m); }
  .stat__value { font-size: 24px; }

  .li { padding: 13px 16px; }
  .list__daysep { top: 52px; padding: 10px 16px 6px; }

  /* 下からせり上がるパネル */
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; transform: none;
    width: 100%; max-height: 90dvh;
    border-radius: 22px 22px 0 0;
    animation: sheetin 0.26s var(--ease);
  }
  @keyframes sheetin { from { transform: translateY(100%); } }
  .sheet--drag { animation: none; transition: transform 0.22s var(--ease); }
  .sheet__grip {
    display: grid; place-items: center; padding: 9px 0 3px; touch-action: none; cursor: grab;
  }
  .sheet__grip::after {
    content: ''; width: 38px; height: 4px; border-radius: 999px; background: var(--line);
  }
  .sheet__foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .sheet__foot .btn { flex: 1; }

  /* 下のタブバー */
  .tabbar {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(1.8) blur(18px);
    -webkit-backdrop-filter: saturate(1.8) blur(18px);
    border-top: 1px solid var(--line-2);
    box-shadow: var(--shadow-up);
  }
  .tab {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; height: var(--tabbar);
    border: 0; background: none; color: var(--muted);
    font-size: 10.5px; font-weight: 600;
    transition: color 0.18s var(--ease);
  }
  .tab svg { width: 23px; height: 23px; }
  .tab[aria-current='page'] { color: var(--accent); }
  .tab__badge {
    position: absolute; transform: translate(14px, -10px);
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  }

  .board { margin: 0 -16px; padding: 0 16px 8px; }
  .board__col { flex: 0 0 82vw; min-width: 82vw; }

  .table th, .table td { padding: 8px 10px; }
}

@media (min-width: 761px) {
  .onlymobile { display: none !important; }
}
@media (max-width: 760px) {
  .onlydesktop { display: none !important; }
}

/* 動きを減らす設定のとき */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .sk::after { display: none; }
}

@media print {
  .rail, .tabbar, .topbar, .toasts { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
