:root {
  --border: #d7dbe0;
  --bg: #f4f6f8;
  --primary: #2f6fed;
  --text: #23272e;
  --muted: #6b7280;
  --progress: #f59e0b;
  --done: #16a34a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  background: #1f2733;
  color: #fff;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
}
header h1 { margin: 0; font-size: 18px; font-weight: 600; }
header a { color: #cdd6e3; font-size: 13px; text-decoration: none; }
header a:hover { color: #fff; }

.header-title { display: flex; align-items: center; gap: 1.6em; }
.policy-link {
  border: 1px solid #46536b; border-radius: 999px; padding: 4px 14px;
  font-size: 12px; white-space: nowrap;
}
.policy-link:hover { background: #46536b; }

.close-btn {
  background: none; border: 1px solid #46536b; color: #cdd6e3; border-radius: 6px;
  padding: 6px 16px; font-size: 12px; cursor: pointer;
}
.close-btn:hover { background: #46536b; color: #fff; }

.template-picker { display: flex; align-items: center; gap: 8px; }
.template-picker label { color: #cdd6e3; font-size: 12px; white-space: nowrap; }
.template-picker select {
  border: 1px solid #3a4454; border-radius: 6px; padding: 6px 10px; font-size: 13px;
  background: #2a3342; color: #fff;
}
.template-picker button {
  white-space: nowrap; border: 1px solid var(--primary); background: var(--primary); color: #fff;
  border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.template-picker button:disabled { opacity: 0.5; cursor: not-allowed; }
.header-actions { display: flex; align-items: center; gap: 24px; }
.header-actions .danger-link {
  background: none; border: 1px solid #f87171; color: #f87171; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; cursor: pointer;
}
.header-actions .danger-link:hover { background: #f87171; color: #1f2733; }

/* index */
.wrap { max-width: 1280px; margin: 0 auto; padding: 24px; }
.lead { color: var(--muted); margin-bottom: 32px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  display: block; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 28px 20px; text-decoration: none; color: var(--text);
  transition: box-shadow .15s, transform .15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-2px); }
.card .icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 16px; color: #fff;
}
.card.new .icon { background: var(--primary); }
.card.progress .icon { background: var(--progress); }
.card.done .icon { background: var(--done); }
.card.preset .icon { background: #6b5bd6; }
.card.template .icon { background: #0d9488; }
.card.master .icon { background: #475569; }
.card.system .icon { background: #b45309; }
.card.policy .icon { background: #9d174d; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card p { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.6; }
.badge {
  display: inline-block; margin-top: 14px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 10px; width: 100%;
}

.top-policies { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }

/* list */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  padding: 8px 18px; border-radius: 999px; font-size: 13px; text-decoration: none;
  border: 1px solid var(--border); color: var(--muted); background: #fff;
}
.tab.active.progress { background: var(--progress); border-color: var(--progress); color: #fff; }
.tab.active.done { background: var(--done); border-color: var(--done); color: #fff; }

.search {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end;
}
.search .field { display: flex; flex-direction: column; gap: 4px; }
.search label { font-size: 12px; color: var(--muted); }
.search input, .search select {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 13px;
}
.search .range { display: flex; align-items: center; gap: 6px; }
.search button {
  background: var(--primary); color: #fff; border: none; border-radius: 6px;
  padding: 8px 20px; font-size: 13px; cursor: pointer; height: 33px;
}
.search .clear-link {
  display: inline-flex; align-items: center; background: #fff; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 8px 16px; font-size: 13px;
  text-decoration: none; height: 33px; box-sizing: border-box;
}
.search .clear-link:hover { color: var(--text); border-color: var(--muted); }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
thead th {
  background: #eef1f5; text-align: left; font-size: 12px; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #eef1f5; vertical-align: top; }
tbody tr:hover { background: #f7f9fc; cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
.note { max-width: 220px; color: var(--muted); font-size: 12px; }
.chk { text-align: center; }
.chk input { transform: scale(1.2); }
.id { color: var(--muted); font-variant-numeric: tabular-nums; }
.master-group-title { font-size: 14px; font-weight: 600; margin: 24px 0 10px; }
.master-group-title:first-child { margin-top: 0; }
.master-overview { margin-bottom: 8px; }
.empty-row td { text-align: center; color: var(--muted); padding: 32px; }

/* form */
.form-wrap { max-width: 1040px; margin: 0 auto; padding: 24px 24px 80px; }
fieldset { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px 24px; margin-bottom: 20px; }
legend { font-size: 14px; font-weight: 600; padding: 0 8px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; }
.row { display: flex; flex-direction: column; gap: 4px; }
.row.full { grid-column: 1 / -1; }
label { font-size: 12px; color: var(--muted); }
label .req { color: #dc2626; margin-left: 2px; }
input[type=text], input[type=number], input[type=date], select, textarea {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 13px; width: 100%; font-family: inherit;
}
input[disabled] { background: #f1f3f5; color: var(--muted); }
textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 11px; color: var(--muted); }

.work-types { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding: 6px 0; }
.work-types label { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); }
.work-types input[type=text] { width: 220px; }

.preset-row { display: flex; gap: 10px; align-items: center; }
.preset-row select { flex: 1; }
.preset-row button { white-space: nowrap; border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: 6px; padding: 7px 14px; font-size: 13px; cursor: pointer; }

table.materials { width: 100%; border-collapse: collapse; }
table.materials th, table.materials td { border: 1px solid var(--border); padding: 8px; font-size: 12px; }
table.materials th { background: #eef1f5; color: var(--muted); font-weight: 500; }
table.materials td.na { background: #f7f8fa; color: #c2c8d0; text-align: center; }
table.materials input { border: none; padding: 4px; font-size: 12px; width: 100%; }
table.materials input:focus { outline: 1px solid var(--primary); border-radius: 4px; }

.actions { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border); padding: 14px 24px; margin: 0 -24px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.actions .action-left { justify-self: start; }
.actions .action-center { justify-self: center; display: flex; align-items: center; gap: 10px; }
.actions .action-right { justify-self: end; display: flex; gap: 10px; }
.actions button { border-radius: 6px; padding: 10px 24px; font-size: 14px; cursor: pointer; }
.actions .primary { background: var(--primary); color: #fff; border: none; }
.actions .primary-update { background: var(--done); color: #fff; border: none; }
.actions .secondary { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.actions .danger { background: #fff; color: #dc2626; border: 1px solid #dc2626; }
.actions .pdf-btn { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.actions .pdf-btn:hover { background: var(--primary); color: #fff; }

.error-box { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

.policy-entry { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; margin-bottom: 14px; }
.policy-entry h3 { margin: 0 0 8px; font-size: 14px; }
.policy-body { font-size: 13px; line-height: 1.7; color: var(--text); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 20, 28, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 10px; padding: 24px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); }
.modal-box h2 { margin: 0 0 16px; font-size: 16px; }
.modal-box .row { margin-bottom: 14px; }
.modal-box .error-box { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal-actions button { border-radius: 6px; padding: 8px 20px; font-size: 14px; cursor: pointer; }
.modal-actions .primary { background: var(--primary); color: #fff; border: none; }
.modal-actions .secondary { background: #fff; color: var(--muted); border: 1px solid var(--border); }
.modal-actions-split { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.modal-box .policy-link { color: var(--primary); border-color: var(--primary); }
.modal-box .policy-link:hover { background: var(--primary); color: #fff; }

footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }
