:root {
  --bg: #faf9f5;          /* 生成りの背景 */
  --card: #ffffff;
  --text: #1f1e1d;
  --muted: #87867f;
  --line: #e8e6e0;
  --accent: #c96442;       /* 落ち着いたテラコッタ */
  --accent-soft: #f5ece8;
  --ink: #2d2c2a;          /* ヘッダー：濃いニュートラル */
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- ヘッダー ---------- */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
}
.brand { color: #fff; font-size: 19px; font-weight: 700; letter-spacing: .03em; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand span { font-size: 13px; font-weight: 400; opacity: .75; margin-left: 6px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { color: #e8e6e0; padding: 6px 11px; border-radius: 7px; font-size: 13px; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.nav .logout { opacity: .75; }

/* ---------- レイアウト ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: .01em; }
h1 .count { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.kana-inline { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.head-actions { display: flex; gap: 8px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f4f2ed; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #b25538; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger { color: #b3261e; border-color: #e3b9b6; }
.btn.big { padding: 12px 32px; font-size: 16px; }

/* ---------- 検索・タブ ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.search-bar input[type=search] {
  flex: 1; min-width: 200px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 16px; background: #fff;
}
.search-bar select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: #fff; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; color: var(--text); text-decoration: none; }
.tab:hover { text-decoration: none; background: #f4f2ed; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- 一覧テーブル ---------- */
.table-wrap { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.table-wrap.inner { margin-top: 4px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #faf9f5;
}
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f7f5f0; }
td.name a { font-weight: 600; }
td.name .kana { display: block; font-size: 11px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; white-space: nowrap; }
.badge.red { background: var(--accent-soft); color: var(--accent); }
.badge.yellow { background: #faf3d9; color: #8a6d00; }
.badge.gray { background: #efedea; color: #6b6a64; }
.badge.plain { background: #f1efe9; color: #6b6a64; }
.badge.urgent { background: #fbe9e7; color: #b3261e; margin-left: 6px; }
.badge.warn { background: #faf3d9; color: #8a6d00; margin-left: 6px; }

/* ---------- サマリーカード ---------- */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 20px; }
.summary-cards .card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.summary-cards .card span { display: block; font-size: 11px; color: var(--muted); }
.summary-cards .card strong { font-size: 17px; }

/* ---------- 詳細 ---------- */
.detail-group { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.detail-group h2 { font-size: 15px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); display: inline-block; font-weight: 700; }
dl { margin: 0; }
dl .row { display: grid; grid-template-columns: 190px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid #f1efe9; }
dl .row:last-child { border-bottom: none; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; font-size: 14px; word-break: break-word; }
dd.pre { white-space: pre-wrap; }
.muted { color: var(--muted); }
.meta { color: var(--muted); font-size: 12px; text-align: right; }
.meta-link { margin: -8px 0 16px; font-size: 14px; }

/* ---------- フォーム ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 16px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field.wide { grid-column: 1 / -1; }
.field textarea { resize: vertical; }
.checkwrap { display: flex; align-items: center; gap: 6px; padding: 9px 0; font-size: 14px; }
.checkwrap input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 10px; margin: 20px 0; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.linkform { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.linkform select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: #fff; }

/* ---------- ログイン等 ---------- */
.auth-box { max-width: 420px; margin: 40px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.auth-box h1 { margin-bottom: 12px; }
.auth-box label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.auth-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 16px; margin-top: 4px; }
.auth-box .btn { width: 100%; padding: 12px; font-size: 15px; }
.error { background: #fbe9e7; color: #b3261e; padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.flash { background: #eaf3ec; color: #1c6b3a; padding: 10px 14px; border-radius: 9px; font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---------- ユーザー管理 ---------- */
.user-ops { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-ops form.inline { display: flex; gap: 6px; align-items: center; }
.user-ops input[type=password] { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; width: 130px; }

/* ---------- スマホ対応 ---------- */
@media (max-width: 700px) {
  table.list thead { display: none; }
  table.list tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px;
    padding: 12px; border-bottom: 1px solid var(--line);
  }
  table.list td { display: block; border: none; padding: 2px 0; font-size: 13px; }
  table.list td::before { content: attr(data-l); display: block; font-size: 10px; color: var(--muted); }
  table.list td.name { grid-column: 1 / -1; font-size: 16px; }
  table.list td.name::before { display: none; }
  dl .row { grid-template-columns: 1fr; gap: 2px; }
  .form-actions { padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); }
}

/* ---------- クイックナビ・かな絞り込み ---------- */
.quicknav { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.quicknav .btn { font-size: 13px; }
.kana-tabs { gap: 4px; }
.kana-tabs .tab { min-width: 38px; text-align: center; padding: 6px 0; }
#info, #orders { scroll-margin-top: 70px; }
@media (max-width: 700px) {
  .kana-tabs { display: grid; grid-template-columns: repeat(11, 1fr); }
}

/* ---------- 添付ファイル ---------- */
.filelist { list-style: none; margin: 0 0 12px; padding: 0; }
.filelist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1efe9; flex-wrap: wrap; }
.filelist li:last-child { border-bottom: none; }
.filelist a { font-weight: 600; }
.filelist form.inline { margin-left: auto; }
.uploadform { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.uploadform input[type=file] { font-size: 13px; }
#files { scroll-margin-top: 70px; }

/* ---------- 一覧のPDFボタン ---------- */
.pdfcell { white-space: nowrap; }
.pdfbtn { font-weight: 600; }
@media (max-width: 700px) {
  td.pdfcell { grid-column: 1 / -1; }
  td.pdfcell::before { display: none; }
}
.badge.ok { background: #eaf3ec; color: #1c6b3a; }
.assignform input[type=number] { width: 90px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; }

/* ---------- 氏名インクリメンタル検索 ---------- */
.search-results { position: relative; display: none; background: #fff; border: 1px solid var(--line); border-radius: 9px; margin-top: 4px; max-height: 280px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,.06); z-index: 5; }
.sr-item { padding: 9px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid #f1efe9; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: #f7f5f0; }
.sr-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }

/* ---------- 写真グリッド ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-item { margin: 0; background: #faf9f5; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.photo-item img { width: 100%; height: 150px; object-fit: cover; display: block; background: #eee; }
.photo-item figcaption { padding: 6px 8px; font-size: 12px; text-align: center; color: var(--text); }
.photo-del { text-align: center; padding: 0 0 8px; }
#files, [id] { scroll-margin-top: 70px; }

/* ---------- ソート可能な列見出し ---------- */
th.sortable { padding: 0; }
th.sortable a { display: block; padding: 10px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
th.sortable a:hover { background: #f4f2ed; color: var(--text); }
