:root {
  --c-primary: #e60020;
  --c-primary-dark: #c3001b;
  --c-primary-soft: #fde8ec;
  --c-bg: #ffffff;
  --c-bg-alt: #f6f7f8;
  --c-bg-muted: #eef1f3;
  --c-text: #292929;
  --c-text-sub: #636363;
  --c-text-mute: #999999;
  --c-border: #d7d7d7;
  --c-border-soft: #e7e7e7;
  --c-accent: #d7e1e7;
  --c-ok: #2e7d32;
  --c-ng: #e60020;
  --c-hold: #ed6c02;
  --c-pending: #9e9e9e;
  --c-ok-bg: #e8f4ea;
  --c-ng-bg: #fde8ec;
  --c-hold-bg: #fff3e0;
  --c-pending-bg: #f0f0f0;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.08);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg-alt);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { color: var(--c-primary-dark); text-decoration: underline; }

.app-header {
  background: #fff;
  border-bottom: 3px solid var(--c-primary);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--c-text);
  text-decoration: none;
}
.app-header .logo .mark { color: var(--c-primary); margin-right: 6px; }
.app-header nav { display: flex; gap: 4px; align-items: center; }
.app-header nav a {
  color: var(--c-text-sub);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.app-header nav a:hover {
  background: var(--c-bg-alt);
  text-decoration: none;
  color: var(--c-text);
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--c-bg-alt);
  border-radius: 20px;
  font-size: 13px;
  color: var(--c-text-sub);
}
.user-chip .dot {
  width: 8px;
  height: 8px;
  background: var(--c-primary);
  border-radius: 50%;
}
.user-chip button {
  background: none; border: none; cursor: pointer; color: var(--c-text-mute);
  font-size: 11px; padding: 0 0 0 8px;
}
.user-chip button:hover { color: var(--c-primary); }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}
.container-narrow { max-width: 720px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.page-head .sub { color: var(--c-text-sub); font-size: 13px; margin-top: 4px; }

.breadcrumb {
  font-size: 12px;
  color: var(--c-text-sub);
  margin-bottom: 12px;
}
.breadcrumb a { color: var(--c-text-sub); }
.breadcrumb .sep { margin: 0 6px; color: var(--c-text-mute); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: #fff;
  color: var(--c-text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: var(--c-bg-alt); text-decoration: none; }
.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: #fff; }
.btn-danger {
  background: #fff;
  color: var(--c-primary);
  border-color: var(--c-primary);
}
.btn-danger:hover { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; line-height: 1; }

.card {
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.project-card, .checklist-card {
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--c-text);
  display: block;
  position: relative;
}
.project-card:hover, .checklist-card:hover {
  border-color: var(--c-primary);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  transform: translateY(-1px);
}
.project-card h3, .checklist-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
}
.project-card .desc, .checklist-card .desc {
  font-size: 12px;
  color: var(--c-text-sub);
  margin-bottom: 12px;
  line-height: 1.4;
  min-height: 34px;
}
.project-card .meta, .checklist-card .meta {
  font-size: 11px;
  color: var(--c-text-mute);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.checklist-card .progress {
  margin-top: 10px;
  height: 6px;
  background: var(--c-bg-muted);
  border-radius: 3px;
  overflow: hidden;
}
.checklist-card .progress-bar {
  height: 100%;
  background: var(--c-primary);
  transition: width 0.3s;
}
.card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 4px;
}
.project-card:hover .card-actions, .checklist-card:hover .card-actions { display: flex; }
.card-actions button, .card-actions a {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
  color: var(--c-text-sub);
}
.card-actions button:hover, .card-actions a:hover {
  border-color: var(--c-primary); color: var(--c-primary);
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--c-text);
}
.form-group .hint { font-size: 11px; color: var(--c-text-sub); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--c-text);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(230,0,32,0.1);
}
.textarea { min-height: 80px; resize: vertical; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-text-sub);
}
.empty-state .icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state p { margin: 6px 0; }

.table-wrap {
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  overflow: auto;
}
table.checklist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.checklist-table th {
  background: var(--c-bg-muted);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--c-border);
  color: var(--c-text);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
table.checklist-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border-soft);
  vertical-align: top;
}
table.checklist-table tr:hover td { background: var(--c-bg-alt); }
table.checklist-table tr.section-row td {
  background: linear-gradient(to right, var(--c-primary-soft), #fff);
  font-weight: 700;
  color: var(--c-primary-dark);
  padding: 12px 12px;
  border-top: 2px solid var(--c-primary);
}
table.checklist-table tr.section-row:hover td {
  background: linear-gradient(to right, var(--c-primary-soft), #fff);
}
.row-no { color: var(--c-text-mute); font-size: 11px; width: 40px; text-align: right; }
.row-handle { cursor: grab; color: var(--c-text-mute); width: 20px; text-align: center; user-select: none; }
.row-handle:hover { color: var(--c-primary); }
.cell-editable { cursor: text; min-width: 80px; min-height: 24px; }
.cell-editable:hover { background: var(--c-bg-alt); }
.cell-editable:focus {
  outline: 2px solid var(--c-primary);
  background: #fff;
}
.cell-saving { background: #fff8e1 !important; }
.cell-saved { background: #e8f4ea !important; transition: background 1s; }
.cell-error { background: #fde8ec !important; }

.status-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-ok { background: var(--c-ok-bg); color: var(--c-ok); border-color: var(--c-ok); }
.status-ng { background: var(--c-ng-bg); color: var(--c-ng); border-color: var(--c-ng); }
.status-hold { background: var(--c-hold-bg); color: var(--c-hold); border-color: var(--c-hold); }
.status-pending { background: var(--c-pending-bg); color: var(--c-pending); border-color: var(--c-border); }
.status-custom { background: var(--c-accent); color: var(--c-text); border-color: #b8c8d1; }
.status-empty { color: var(--c-text-mute); font-size: 11px; }

.status-btns {
  display: inline-flex;
  gap: 3px;
  flex-wrap: wrap;
}
.status-btn {
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--c-text-sub);
  transition: all .12s;
  white-space: nowrap;
}
.status-btn:hover {
  border-color: var(--c-text-sub);
  color: var(--c-text);
}
.status-btn.active.status-ok      { background: var(--c-ok-bg);      color: var(--c-ok);      border-color: var(--c-ok); font-weight: 600; }
.status-btn.active.status-ng      { background: var(--c-ng-bg);      color: var(--c-ng);      border-color: var(--c-ng); font-weight: 600; }
.status-btn.active.status-hold    { background: var(--c-hold-bg);    color: var(--c-hold);    border-color: var(--c-hold); font-weight: 600; }
.status-btn.active.status-pending { background: var(--c-pending-bg); color: var(--c-text-sub); border-color: var(--c-text-sub); font-weight: 600; }
.status-btn.active.status-custom  { background: var(--c-accent);     color: var(--c-text);    border-color: #b8c8d1; font-weight: 600; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success { background: var(--c-ok-bg); color: var(--c-ok); border-color: var(--c-ok); }
.alert-error { background: var(--c-ng-bg); color: var(--c-ng); border-color: var(--c-ng); }
.alert-info { background: var(--c-accent); color: var(--c-text); border-color: #b8c8d1; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #292929;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--c-primary); }
.toast.success { background: var(--c-ok); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 150;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin: 0 0 16px 0; font-size: 18px; }
.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
}
.toolbar .spacer { flex: 1; }
.toolbar .progress-summary {
  font-size: 12px;
  color: var(--c-text-sub);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar .progress-summary .count { font-weight: 600; color: var(--c-text); }

.column-editor {
  border: 1px solid var(--c-border-soft);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--c-bg-alt);
  margin-bottom: 10px;
}
.column-row {
  display: grid;
  grid-template-columns: auto 1fr 140px auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.column-row:last-child { margin-bottom: 0; }
.column-row .grip { cursor: grab; color: var(--c-text-mute); user-select: none; padding: 0 4px; }

.identify-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff 0%, var(--c-accent) 100%);
  padding: 20px;
}
.identify-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--c-primary);
}
.identify-card h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  text-align: center;
}
.identify-card .subtitle {
  text-align: center;
  color: var(--c-text-sub);
  margin-bottom: 28px;
  font-size: 13px;
}
.identify-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}
.identify-card .divider {
  text-align: center;
  color: var(--c-text-mute);
  font-size: 11px;
  margin: 20px 0;
  position: relative;
}
.identify-card .divider::before, .identify-card .divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--c-border);
}
.identify-card .divider::before { left: 0; }
.identify-card .divider::after { right: 0; }

.log-entry {
  padding: 10px 14px;
  border-left: 3px solid var(--c-border);
  background: #fff;
  margin-bottom: 6px;
  font-size: 13px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.log-entry .time { color: var(--c-text-mute); font-size: 11px; white-space: nowrap; }
.log-entry .user { font-weight: 600; color: var(--c-primary); }
.log-entry .action { color: var(--c-text-sub); font-size: 11px; }
.log-entry .label { color: var(--c-text); }
.log-entry.create { border-left-color: var(--c-ok); }
.log-entry.delete { border-left-color: var(--c-primary); }
.log-entry.update { border-left-color: var(--c-hold); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 11px;
  background: var(--c-bg-muted);
  border-radius: 10px;
  color: var(--c-text-sub);
}

.status-editor-row {
  display: grid;
  grid-template-columns: 1fr 100px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--c-border);
  cursor: pointer;
}

@media (max-width: 720px) {
  .container { padding: 14px; }
  .app-header { padding: 10px 14px; }
  .page-head h1 { font-size: 18px; }
  table.checklist-table { font-size: 12px; }
  table.checklist-table th, table.checklist-table td { padding: 6px 8px; }
}
