/* ============================================================
   山内陸送 業務システム 共通フレーム（サイドバー＋ヘッダ＋本文）
   tokens.css の後、各アプリ固有の CSS の「後」に読み込む。
   対象マークアップ（受発注・債権債務・配車で共通）:
     .app > nav.sidebar + .content > .content__header + .content__body
   ============================================================ */

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ds-font);
  font-size: var(--ds-fs-md);
  line-height: var(--ds-lh);
  color: var(--ds-text);
  background: var(--ds-bg);
  font-variant-numeric: tabular-nums;   /* 数字の桁をそろえる */
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; height: 100dvh; }

/* ---------------- サイドバー ---------------- */
.sidebar {
  width: var(--ds-sidebar-w);
  background: var(--ds-nav-bg);
  color: var(--ds-nav-text);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  z-index: var(--ds-z-sidebar);
  transition: width .15s ease-out;
}
.sidebar.collapsed { width: var(--ds-sidebar-w-collapsed); }

.sidebar__logo {
  display: flex; align-items: center; gap: 10px;
  padding: var(--ds-sp-4) var(--ds-sp-4) var(--ds-sp-3);
  border-bottom: 1px solid var(--ds-nav-border);
}
.sidebar__logo-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--ds-radius);
  background: #fff; color: var(--ds-nav-bg);
  font-size: 15px; font-weight: 700;
}
.sidebar__logo-icon img { width: 100%; height: auto; display: block; padding: 4px; }
.sidebar__logo-text { font-size: 14px; font-weight: 700; color: var(--ds-nav-text-hi); white-space: nowrap; }
.sidebar__logo-sub  { font-size: var(--ds-fs-xs); color: var(--ds-nav-label); white-space: nowrap; }

.sidebar__toggle {
  width: 28px; height: 28px; margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--ds-nav-border); border-radius: var(--ds-radius-sm);
  color: var(--ds-nav-text); cursor: pointer; font-size: 15px; line-height: 1;
}
.sidebar__toggle:hover { background: var(--ds-nav-hover); color: var(--ds-nav-text-hi); }

.sidebar__section { padding: var(--ds-sp-3) 0 var(--ds-sp-1); }
.sidebar__section-label {
  padding: 0 var(--ds-sp-4) 6px;
  font-size: var(--ds-fs-xs); font-weight: 600; letter-spacing: .04em;
  color: var(--ds-nav-label); text-transform: none;
  white-space: nowrap; overflow: hidden;
}

.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 34px; padding: 7px var(--ds-sp-4);
  background: none; border: 0; border-left: 3px solid transparent; border-radius: 0;
  color: var(--ds-nav-text); font: inherit; font-size: var(--ds-fs-md);
  text-align: left; text-decoration: none; white-space: nowrap; overflow: hidden;
  cursor: pointer; transition: background-color .12s, color .12s;
}
.sidebar__item:hover { background: var(--ds-nav-hover); color: var(--ds-nav-text-hi); }
.sidebar__item.active {
  background: var(--ds-nav-hover); color: var(--ds-nav-text-hi);
  border-left-color: var(--ds-accent); font-weight: 600;
}
.sidebar__item:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: -2px; }
.sidebar__item-icon { width: 18px; flex-shrink: 0; text-align: center; font-size: 15px; }
.sidebar__item-badge {
  margin-left: auto; padding: 1px 8px; border-radius: var(--ds-radius-pill);
  font-size: var(--ds-fs-xs); font-weight: 600;
  background: rgba(255,255,255,.10); color: var(--ds-nav-text);
}
.sidebar__item.active .sidebar__item-badge { background: var(--ds-accent); color: #fff; }

.sidebar.collapsed .sidebar__logo { padding: var(--ds-sp-3) 0; justify-content: center; flex-direction: column; gap: var(--ds-sp-2); }
.sidebar.collapsed .sidebar__logo > div:not(.sidebar__logo-icon),
.sidebar.collapsed .sidebar__item-label,
.sidebar.collapsed .sidebar__item-badge { display: none; }
.sidebar.collapsed .sidebar__section-label { opacity: 0; height: 0; padding: 0; }
.sidebar.collapsed .sidebar__item { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .sidebar__toggle { margin: 0 auto; }

/* 要対応アラート：赤は「本当に件数があるとき」だけ。点滅はしない */
.sidebar__alert {
  display: flex; align-items: center; gap: var(--ds-sp-2);
  margin: 10px var(--ds-sp-3) 0; padding: var(--ds-sp-2) 10px;
  background: var(--ds-danger); border: 0; border-radius: var(--ds-radius);
  color: #fff; font-size: var(--ds-fs-sm); font-weight: 700; cursor: pointer;
}
.sidebar__alert:hover { background: #9b1717; }
.sidebar__alert-icon { animation: none !important; }
.sidebar__alert-count { margin-left: auto; background: #fff; color: var(--ds-danger); border-radius: var(--ds-radius-pill); padding: 1px 8px; font-size: var(--ds-fs-xs); font-weight: 700; }
.sidebar__alert--none { background: var(--ds-nav-hover); color: var(--ds-nav-label); cursor: default; }
.sidebar__alert--none:hover { background: var(--ds-nav-hover); }
.sidebar__alert--none .sidebar__alert-count { background: var(--ds-nav-border); color: var(--ds-nav-text); }

.sidebar__foot, .sidebar__role { border-top: 1px solid var(--ds-nav-border); }

/* riku-sol のロゴ（shell.js が差し替え）。マークそのものが色を持つので枠の背景は消す */
.sidebar__logo-icon.ds-logo-mark { background: none; padding: 0; }
.sidebar__logo-icon.ds-logo-mark svg { width: 32px; height: 32px; display: block; }
.sidebar__logo-text { letter-spacing: .01em; }

/* ---------------- 本文側 ---------------- */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.content__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--ds-sp-3);
  min-height: var(--ds-topbar-h); padding: var(--ds-sp-1) var(--ds-sp-5); flex-shrink: 0;
  background: var(--ds-surface); border-bottom: 1px solid var(--ds-border);
}
.content__title { font-size: var(--ds-fs-xl); font-weight: 700; letter-spacing: 0; display: flex; align-items: center; gap: var(--ds-sp-2); }
.content__title-icon { font-size: 16px; color: var(--ds-text-2); }
.content__actions { display: flex; align-items: center; gap: var(--ds-sp-2); }
.content__body { flex: 1; overflow: auto; }  /* 余白は各アプリの画面ごとに持つ（高さ計算を前提にした画面があるため） */

/* アプリ切替の見た目は launcher.css（shell.js が読み込む。枠組みを持たないページでも使うため分けている） */

/* ヘッダ右端のログインユーザー（shell.js が挿入） */
.ds-user { display: flex; align-items: center; gap: var(--ds-sp-2); margin-left: var(--ds-sp-2); padding-left: var(--ds-sp-3); border-left: 1px solid var(--ds-border); font-size: var(--ds-fs-sm); color: var(--ds-text-2); white-space: nowrap; }
.ds-user__name { color: var(--ds-text); font-weight: 600; }
.ds-user a { color: var(--ds-text-2); }

/* ---------------- 基本部品 ---------------- */
a { color: var(--ds-accent); }
:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }

.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--ds-control-h); padding: 0 14px; white-space: nowrap;
  border: 1px solid var(--ds-border-strong); border-radius: var(--ds-radius-sm);
  background: var(--ds-surface); color: var(--ds-text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.ds-btn:hover { background: var(--ds-surface-sunk); }
.ds-btn:active { transform: translateY(1px); }
.ds-btn--primary { background: var(--ds-accent); border-color: var(--ds-accent); color: #fff; }
.ds-btn--primary:hover { background: var(--ds-accent-hover); border-color: var(--ds-accent-hover); }
.ds-btn--danger { background: var(--ds-surface); border-color: var(--ds-danger); color: var(--ds-danger); }

.ds-panel { background: var(--ds-surface); border: 1px solid var(--ds-border); border-radius: var(--ds-radius); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* スマホ幅：余白だけ詰める（サイドバーの開閉は各アプリの既存動作に任せる） */
@media (max-width: 767px) {
  .content__header { padding: var(--ds-sp-1) var(--ds-sp-3); }
}
