@import url('https://cdn.jsdelivr.net/npm/@fontsource/line-seed-jp@5/index.css');

:root {
  --blue-900: #0b2d5c;
  --blue-700: #1554a8;
  --blue-500: #2f7fe0;
  --blue-100: #e4eefb;
  --ink: #16233a;
  --ink-soft: #5a6b85;
  --line: #d8e2f0;
  --card: #ffffff;
  --red: #d92c4b;
  --amber: #b7791f;
  --gray: #7c8798;
  --green: #1f8a5b;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(16, 42, 82, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'LINE Seed JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #eaf2fd 0%, #f7fafe 45%, #eef4fc 100%);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.7;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* ---------- ログイン ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { margin: 0 0 24px; color: var(--ink-soft); font-size: 13px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.field input:not([type=checkbox]), .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

/* チェックボックスは幅 100% の対象外。ラベル文と横並びにする。 */
.field label:has(input[type=checkbox]) {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 0;
}
.field input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--blue-100);
  border-color: var(--blue-500);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--blue-700);
  border-radius: 8px;
  background: var(--blue-700);
  color: #fff;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--blue-900); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--blue-700); }
.btn.ghost:hover { background: var(--blue-100); }
.btn.danger { background: #fff; color: var(--red); border-color: #f0c2cb; }
.btn.danger:hover { background: #fdeef1; }
.btn.wide { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

.msg { margin-top: 12px; font-size: 13px; min-height: 20px; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }

/* ---------- レイアウト ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--blue-900);
  color: #cfe0f6;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 0;
}

.brand { padding: 0 20px 20px; }
.brand strong { display: block; color: #fff; font-size: 15px; }
.brand span { font-size: 11px; color: #8fb2dd; }

.nav-item {
  display: block;
  padding: 10px 20px;
  color: #cfe0f6;
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  font-size: 13px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--blue-500); }

.sidebar-foot { padding: 20px; margin-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot .who { font-size: 12px; color: #8fb2dd; margin-bottom: 10px; word-break: break-all; }

.content { flex: 1; padding: 28px 32px 64px; min-width: 0; }
.content h2 { font-size: 20px; margin: 0 0 4px; }
.content .lead { color: var(--ink-soft); margin: 0 0 24px; font-size: 13px; }

/* ---------- 部品 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 14px; margin: 0 0 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat .label { font-size: 11px; color: var(--ink-soft); }
.stat .value { font-size: 26px; font-weight: 700; color: var(--blue-900); line-height: 1.3; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; color: var(--ink-soft); font-weight: 500; white-space: nowrap; }
tbody tr:hover { background: #f6f9fe; }
td.subject { font-weight: 500; cursor: pointer; color: var(--blue-700); }
td.subject:hover { text-decoration: underline; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge.action { background: #fdeef1; color: var(--red); border-color: #f5cbd5; }
.badge.none   { background: #f1f3f6; color: var(--gray); border-color: #e0e5ec; }
.badge.gray   { background: #fdf6e7; color: var(--amber); border-color: #f0e0bd; }
.badge.stage  { background: var(--blue-100); color: var(--blue-700); border-color: #cbdff7; }
.badge.pending{ background: #fdf6e7; color: var(--amber); border-color: #f0e0bd; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.toolbar input[type=search] { min-width: 220px; }

.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { margin-bottom: 0; flex: 1 1 160px; }

.empty { padding: 32px; text-align: center; color: var(--ink-soft); }

/* ---------- 詳細モーダル ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(11, 45, 92, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 50;
}
.modal {
  background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 820px;
  box-shadow: 0 12px 40px rgba(11,45,92,.28);
}
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; }
.close-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-soft); line-height: 1; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 18px; }
.kv dt { color: var(--ink-soft); font-size: 12px; }
.kv dd { margin: 0; word-break: break-word; }

.body-view {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; max-height: 320px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; font-size: 13px;
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 16px 0; }
  .content { padding: 20px 16px 48px; }
  .kv { grid-template-columns: 1fr; }
}
