/* Shared BtoB controls. Only opt-in components/pages use these rules. */
.ui-shell {
  font-family: var(--font-sans);
  font-size: var(--ui-font-body);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-secondary);
  --text-muted: var(--ui-text-muted);
  --font-size-sm: var(--ui-font-body);
  --font-size-xs: var(--ui-font-note);
}
.ui-shell *, .ui-shell *::before, .ui-shell *::after { box-sizing: border-box; }
.ui-page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; }
.ui-page-heading h1 { font-size: 24px; line-height: 1.4; font-weight: 600; letter-spacing: 0; margin: 0; }
.ui-context { color: var(--text-secondary); font-size: var(--ui-font-note); margin: 4px 0 0; }
.ui-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ui-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--ui-control-height); padding: 6px 12px;
  border: 1px solid var(--border-color-strong); border-radius: var(--radius-md);
  background: var(--bg-primary); color: var(--text-primary);
  font: inherit; font-size: var(--ui-font-body); font-weight: 500; line-height: 1.5;
  text-decoration: none; cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.ui-button:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
/* Existing Bootstrap controls opt into the same component with ui-button. */
.ui-shell .ui-button { min-height: var(--ui-control-height); border-radius: var(--radius-md); padding: 6px 12px; font-size: var(--ui-font-body); line-height: 1.5; font-weight: 500; box-shadow: none; }
.ui-shell .ui-button.btn-sm { min-height: var(--ui-control-height-compact); padding: 4px 8px; }
/* 塗りのボタンの文字は DESIGN.md の button-primary と同じ #ffffff。slate-50 だと Bootstrap の青に対して 4.3:1 で AA（4.5:1）に届かない */
.ui-shell .ui-button.btn-primary { color: #ffffff; background: var(--ui-action-bg); border-color: var(--ui-action-bg); }
.ui-shell .ui-button.btn-danger { color: #ffffff; background: var(--ui-danger-bg); border-color: var(--ui-danger-bg); }
.ui-shell .ui-button:is(.btn-secondary,.btn-outline,.btn-outline-secondary,.btn-outline-success) { color: var(--text-primary); background: var(--bg-primary); border: 1px solid var(--border-color-strong); }
.ui-shell .ui-button.btn-outline-primary { color: var(--ui-action-bg); background: var(--bg-primary); border: 1px solid var(--ui-action-bg); }
.ui-button-primary { color: #ffffff; background: var(--ui-action-bg); border-color: var(--ui-action-bg); }
.ui-button-primary:hover, .ui-shell .ui-button.btn-primary:hover { color: #ffffff; background: var(--ui-action-hover); border-color: var(--ui-action-hover); }
.ui-button-danger { color: #ffffff; background: var(--ui-danger-bg); border-color: var(--ui-danger-bg); }
.ui-button-danger:hover { color: #ffffff; background: var(--color-danger-dark); }
.ui-button-compact { min-height: var(--ui-control-height-compact); padding-block: 4px; }
.ui-button:disabled, .ui-button[aria-disabled='true'] { opacity: .65; cursor: not-allowed; }
.ui-shell :focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.ui-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ui-field > label { font-size: var(--ui-font-note); line-height: 1.5; color: var(--text-secondary); font-weight: 500; margin: 0; }
.ui-field :is(input:not([type='checkbox']):not([type='radio']):not([type='hidden']), select, textarea) {
  width: 100%; min-width: 0; min-height: var(--ui-control-height); padding: 6px 12px;
  border: 1px solid var(--border-color-strong); border-radius: var(--radius-md);
  color: var(--text-primary); background-color: var(--bg-primary);
  font-family: inherit; font-size: var(--ui-font-body); line-height: 1.5;
}
.ui-field select { padding-right: 28px; }
.ui-field :is(input, select, textarea):focus { border-color: var(--ui-focus); }
.ui-field :is(input, select, textarea):disabled { background-color: var(--bg-tertiary); }
.ui-help { color: var(--text-secondary); font-size: var(--ui-font-note); }
.ui-field-invalid :is(input, select, textarea), .ui-shell .ui-field.has-error :is(input, select, textarea) { border-color: var(--ui-danger-bg); }
.ui-field-error { color: var(--ui-danger-bg); font-size: var(--ui-font-note); }
.ui-field-error ul { list-style: none; margin: 0; padding: 0; }
.ui-pagination { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.ui-pagination [aria-current] { background: var(--color-info-light); border-color: var(--ui-action-bg); color: var(--color-info-dark); }
.ui-page-gap { padding: 4px; }
@media (prefers-reduced-motion: reduce) { .ui-shell * { scroll-behavior: auto; transition-duration: 0s; animation-duration: 0s; } }
/* Explicit controls from legacy forms and Bootstrap forms share one size. */
.ui-shell .ui-control {
  min-height: var(--ui-control-height); max-width: 100%; padding: 6px 12px;
  font-family: inherit; font-size: var(--ui-font-body); line-height: 1.5;
  color: var(--text-primary); background-color: var(--bg-primary);
  border: 1px solid var(--border-color-strong); border-radius: var(--radius-md);
}
.ui-shell select.ui-control { padding-right: 28px; }
.ui-shell table.ui-table .ui-control { min-height: var(--ui-control-height-compact); padding: 4px 8px; }
.ui-shell .ui-button:is(.btn-b,.btn-db,.btn-g,.btn-yg,.btn-success):not(.btn-outline) { color: #ffffff; background: var(--ui-action-bg); border-color: var(--ui-action-bg); }
.ui-shell .ui-button:is(.btn-b,.btn-db,.btn-g,.btn-yg,.btn-success):not(.btn-outline):hover { color: #ffffff; background: var(--ui-action-hover); border-color: var(--ui-action-hover); }
/* 裏で処理が走るボタン（予測・計画作成・JEPX や広域機関との通信）だけ緑。ほかの主操作は青 */
.ui-shell .ui-button.ui-button-run:not(.btn-outline) { color: #ffffff; background: var(--ui-run-bg); border-color: var(--ui-run-bg); }
.ui-shell .ui-button.ui-button-run:not(.btn-outline):hover { color: #ffffff; background: var(--ui-run-hover); border-color: var(--ui-run-hover); }
.ui-shell .ui-button.btn-r { color: #ffffff; background: var(--ui-danger-bg); border-color: var(--ui-danger-bg); }
.ui-shell .ui-button:is(.btn-y,.btn-gray,.btn-info) { color: var(--text-primary); background: var(--bg-primary); border-color: var(--border-color-strong); }
.ui-shell .ui-button { white-space: nowrap; }
.ui-shell .btn-group .ui-button { border-radius: 0; }
.ui-shell .btn-group .ui-button:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.ui-shell .btn-group .ui-button:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.ui-shell .ui-button:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }
.ui-shell .ui-text { font-size: var(--ui-font-body); }
.ui-shell .ui-note { font-size: var(--ui-font-note); }
.ui-shell .ui-strong { font-weight: 600; }
.ui-shell .ui-secondary-text { color: var(--text-secondary); }
.ui-shell .ui-action-text { color: var(--ui-action-bg); }
.ui-shell .ui-inherit-text { color: inherit; }
.ui-shell .ui-bordered { border: 1px solid var(--border-color-strong); }
.ui-shell .ui-rounded { border-radius: var(--radius-md); }
.ui-shell .ui-surface-muted { background: var(--bg-secondary); }
.ui-shell .ui-surface-danger { background: var(--color-danger-light); }
.ui-shell .ui-border-danger { border-color: var(--ui-danger-bg); }
/* Selection is a separate state, including Bootstrap button/radio toggles. */
.ui-shell .ui-button:is(.btn-outline-primary,.btn-outline-secondary,.btn-outline-success).active,
.ui-shell .ui-button[aria-pressed='true'],
.ui-shell .ui-button[aria-current='true'],
.ui-shell .btn-check:checked + .ui-button {
  /* 選んだ側は平らな青の塗りだけにする（下線の影は浮き上がった立体に見えるため付けない） */
  color: #ffffff; background: var(--ui-action-bg); border-color: var(--ui-action-bg);
  box-shadow: none;
}
/* Bootstrap のページ送りも罫線色にそろえ、外側の余白を消す */
.ui-shell .pagination {
  --bs-pagination-color: var(--ui-action-bg); --bs-pagination-hover-color: var(--ui-action-hover);
  --bs-pagination-border-color: var(--border-color); --bs-pagination-hover-bg: var(--bg-tertiary);
  --bs-pagination-active-bg: var(--ui-action-bg); --bs-pagination-active-border-color: var(--ui-action-bg);
  --bs-pagination-disabled-color: var(--text-muted); --bs-pagination-focus-box-shadow: none;
  --bs-pagination-border-radius: var(--radius-md); margin: 0;
}
/* Bootstrap の form-control を付けた select は矢印が消え、入力欄と見分けられない。矢印を戻す */
.ui-shell select.form-control:not([multiple]):not([size]) {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px 10px;
}
/* 素の input/select を並べた旧画面は、外側に ui-controls-scope を付けて同じ見た目にそろえる ( Bootstrap の class が付いたものは触らない ) */
/* :where で詳細度を下げ、下の select・表の中の規則が勝つようにする */
.ui-shell .ui-controls-scope :where(input:not([type='checkbox']):not([type='radio']):not([type='hidden']):not([type='submit']):not([type='button']):not([type='file']), select, textarea):not(.form-control):not(.form-select):not(.ui-control) {
  min-height: var(--ui-control-height); max-width: 100%; padding: 6px 12px;
  font-family: inherit; font-size: var(--ui-font-body); line-height: 1.5;
  color: var(--text-primary); background-color: var(--bg-primary);
  border: 1px solid var(--border-color-strong); border-radius: var(--radius-md);
}
.ui-shell .ui-controls-scope select:not(.form-control):not(.form-select):not(.ui-control):not([multiple]):not([size]) {
  appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23475569' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px 10px;
}
.ui-shell .ui-controls-scope table :where(input:not([type='checkbox']):not([type='radio']):not([type='hidden']), select):not(.form-control):not(.form-select):not(.ui-control) { min-height: var(--ui-control-height-compact); padding-block: 2px; }
.ui-shell .ui-controls-scope :is(input, select, textarea):focus { border-color: var(--ui-focus); }
