/* 管理コンソール（実API）— プロトタイプ 03_システム管理者Web に準拠したデザイン */
:root {
  --brand: #5b76b0;
  --brand-dark: #4a6296;
  --bg: #eef1f5;
  --surface: #fff;
  --line: #e2e7ee;
  --text: #1d2733;
  --text-sub: #5f6c7b;
  --text-mute: #97a3b2;
  --ok: #3a9d6e;
  --warn: #d29a24;
  --danger: #d2604f;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(20, 30, 45, 0.07);
  --shadow-lg: 0 12px 34px rgba(20, 30, 45, 0.2);
  --sidebar-w: 252px;
  --font: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', Meiryo, system-ui, sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.muted {
  color: var(--text-mute);
}
.sm {
  font-size: 12px;
}
.err {
  color: var(--danger);
}
.mono {
  font-family: monospace;
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  white-space: nowrap;
  direction: ltr;
  display: inline-block;
  vertical-align: middle;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}
.material-symbols-outlined.big {
  font-size: 30px;
}

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  transition: filter 0.15s;
}
.btn:hover {
  filter: brightness(1.07);
}
.btn.ghost {
  background: var(--bg);
  color: var(--text);
}
.btn.ghost.danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn.sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}
.btn.full {
  width: 100%;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ===== ログイン ===== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1b2433, #2c3a52);
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 30px;
  box-shadow: var(--shadow-lg);
}
.logo {
  text-align: center;
  margin-bottom: 20px;
}
.logo .mark {
  width: 58px;
  height: 58px;
  border-radius: 15px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #5b76b0, #76a3db);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.logo h1 {
  margin: 4px 0 2px;
  font-size: 20px;
}

.field {
  margin-bottom: 14px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
}

/* ===== シェル ===== */
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #1b2433;
  color: #cdd6e3;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #5b76b0, #76a3db);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.brand-text b {
  font-size: 15px;
  color: #fff;
}
.brand-text small {
  font-size: 11px;
  color: #8d9bb0;
}
.side-nav {
  flex: 1;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.nav-cap {
  font-size: 10.5px;
  font-weight: 800;
  color: #6c7a90;
  letter-spacing: 0.06em;
  padding: 14px 14px 5px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #aeb9c9;
  padding: 10px 14px;
  border-radius: 9px;
  text-align: left;
  width: 100%;
}
.nav:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav.on {
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}
.side-foot {
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.side-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cdd6e3;
}
.side-user b {
  font-size: 13px;
  color: #fff;
  display: block;
}
.side-user small {
  font-size: 11px;
  color: #8d9bb0;
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}
.page-title {
  flex: 1;
  font-size: 19px;
  font-weight: 800;
  margin: 0;
}
.content {
  flex: 1;
  padding: 24px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
}
.content h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

/* ===== KPI ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.kpi-v {
  font-size: 27px;
  font-weight: 800;
  color: var(--brand);
}
.kpi-l {
  color: var(--text-sub);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== カード / テーブル ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  overflow-x: auto;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input,
.toolbar select {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}
.toolbar input {
  flex: 1;
  max-width: 320px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  background: #f5f7fa;
  color: var(--text-sub);
  font-size: 12.5px;
  font-weight: 800;
}
tr.click {
  cursor: pointer;
}
tr.click:hover {
  background: #f6f8fc;
}
.actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
/* 操作列はボタンを右寄せ（ボタン右の余白を出さない）。幅は内容に任せる */
td.actions {
  white-space: nowrap;
  text-align: right;
}
/* 書籍カバー（420:595。画像は全体表示=contain） */
.book-cover {
  width: 100%;
  aspect-ratio: 420 / 595;
  border-radius: 8px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--line);
  display: flex;
  align-items: flex-end;
  padding: 6px;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cover-cell {
  width: 44px;
  cursor: pointer;
}
.cover-cell:hover {
  opacity: 0.85;
}
.book-cover.xs {
  font-size: 9px;
  padding: 3px;
  border-radius: 6px;
}
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
code {
  font-family: ui-monospace, Menlo, monospace;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-sub);
}
.badge.gray {
  background: #eef1f5;
  color: var(--text-mute);
}

/* ===== セクション管理（並び替え） ===== */
.section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-mute);
  margin: 18px 2px 10px;
}
.sortable .sort-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.sortable .sort-row:last-child {
  border-bottom: 0;
}
.sort-handle {
  color: var(--text-mute);
  font-size: 18px;
}
.sort-row .s-main {
  flex: 1;
  min-width: 0;
}
.sort-row .s-title {
  font-weight: 700;
}
.sort-row .s-sub {
  font-size: 12px;
  color: var(--text-mute);
}
.order-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.order-btns button {
  border: 0;
  background: var(--bg);
  width: 28px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.order-btns button:hover:not(:disabled) {
  background: #e2e7ee;
}
.order-btns button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ===== モーダル ===== */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 22, 33, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 18px;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 {
  margin: 0 0 14px;
}
.modal .field input,
.modal .field select,
.modal .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
}
.inq-body {
  background: var(--bg);
  border-radius: 9px;
  padding: 12px;
  margin: 10px 0;
  white-space: pre-wrap;
  font-size: 14px;
  max-height: 240px;
  overflow: auto;
}
.ck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
}
.ck input {
  width: 16px;
  height: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #1d2733;
  color: #fff;
  padding: 12px 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

/* side-nav は常時表示（狭い画面でも隠さない） */
@media (max-width: 900px) {
  .content {
    padding: 16px;
  }
}

/* ドラッグ並び替え */
.sort-row[draggable='true'] {
  cursor: move;
}
.sort-row.dragging {
  opacity: 0.45;
  background: #eef2f9;
}
.sort-handle {
  cursor: grab;
}
